Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » How to call feature's execute method explicitly
How to call feature's execute method explicitly [message #724323] Mon, 12 September 2011 01:36 Go to next message
samim  is currently offline samim
Messages: 7
Registered: August 2011
Junior Member
Hi,
I have to implement a scenario where on click on any container shape it will highlight any connection associated with it.Thus I used selection Listener inside the Editor class.But In editor class I don't get the editing domain.Thus the command stack is also not available so I cant make changes to on any graphiti model.Thus I tried implementing the functionality in a feature class by extending AbstractCustomFeature.But I have to instantiate the feature class explicitly and the editor also becomes dirty when any changes happen.So I have to handle the dirty thing explicitly.Can any one suggest any other way to do solve this problem.If you need I can also provide the code I have used
Re: How to call feature's execute method explicitly [message #724325 is a reply to message #724323] Mon, 12 September 2011 01:41 Go to previous messageGo to next message
Maqsood Ahmed is currently offline Maqsood Ahmed
Messages: 41
Registered: September 2010
Member
There's a hasDoneChanges() method ,provided by the superClasss that you have mentioned return false, it will not make the
editor dirty.
Re: How to call feature's execute method explicitly [message #724326 is a reply to message #724325] Mon, 12 September 2011 02:00 Go to previous messageGo to next message
samim  is currently offline samim
Messages: 7
Registered: August 2011
Junior Member
Actually that hasDoneChanges() method just set some Boolean to true or false but inside the super-class below part of code is called which uses the Boolean value.

TransactionalEditingDomain domain= TransactionUtil.getEditingDomain(ep.getModel());
WorkspaceCommandStackImpl workspaceCommandStackImpl = (WorkspaceCommandStackImpl)domain.getCommandStack();
IUndoContext context = workspaceCommandStackImpl.getDefaultUndoContext();
IUndoableOperation operation = workspaceCommandStackImpl.getOperationHistory().getUndoOperation(context);
// Replace the found operation with an empty set workspaceCommandStackImpl.getOperationHistory().replaceOperation(operation, new IUndoableOperation[0]);

But in my case as I am calling the feature explicitly this method is not called automatically and my editor becomes dirty.So I uses the above part of code in order to clear the dirtiness.But this process makes the editor dirty for fraction of second.
Re: How to call feature's execute method explicitly [message #724372 is a reply to message #724323] Mon, 12 September 2011 04:13 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1587
Registered: July 2009
Location: Walldorf, Germany
Senior Member
You can use the method getEditingDomain defined in DiagramEditorInternal to
get the TransactionalEditingDomain of the Editor. But any change you do
there will automatically make the editor dirty. After execution you might
reset that by removing the corresponding EMF operation from the command
stack (see GFCommandStack line 177 and following, there Graphiti does the
same for evaluating the hasDoneChanges feature method).

Just as a warning: this is tricky and not really supported in Graphiti now.
But this is a resonable request; would you please open an enhancement
Bugzilla for to request this?

Michael


"samim" schrieb im Newsbeitrag news:j4k52r$tue$1@news.eclipse.org...

Hi,
I have to implement a scenario where on click on any container shape it
will highlight any connection associated with it.Thus I used selection
Listener inside the Editor class.But In editor class I don't get the editing
domain.Thus the command stack is also not available so I cant make changes
to on any graphiti model.Thus I tried implementing the functionality in a
feature class by extending AbstractCustomFeature.But I have to instantiate
the feature class explicitly and the editor also becomes dirty when any
changes happen.So I have to handle the dirty thing explicitly.Can any one
suggest any other way to do solve this problem.If you need I can also
provide the code I have used
Previous Topic:Coding style of Graphiti plug-ins
Next Topic:Use emf editor property sheet page
Goto Forum:
  


Current Time: Wed Aug 27 15:26:30 EDT 2014

Powered by FUDForum. Page generated in 0.03274 seconds