Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Command Handler is not called since Kepler
Command Handler is not called since Kepler [message #1073163] Wed, 24 July 2013 08:49 Go to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
Hi,
I want to contribute a command to the context menu of en existing editor
(GMF-based Ecore Diagram editor). In Juno it worked well but since
Kepler I have the problem that the HandledMenuItem is contributed but it
is not enabled. Thus, no handler is called. My fragment.e4xmi looks like
this:

<?xml version="1.0" encoding="ASCII"?>
<fragment:ModelFragments xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands"
xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment"
xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu"
xmi:id="_IU2pYGCJEeK-fpTrs2yrzw">
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_LgthYGCJEeK-fpTrs2yrzw" featurename="commands"
parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Command"
xmi:id="_S2HosGCJEeK-fpTrs2yrzw"
elementId="myplugin.ecoretools.commands.modifyFillColor"
commandName="Modify Fill Color of EClasses to white"
description="Modifies the fill color of each EClass in an open Ecore
Tools Diagram Editor to white" category="_mWvIoGCJEeK-fpTrs2yrzw"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_inHcQGCJEeK-fpTrs2yrzw" featurename="categories"
parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Category"
xmi:id="_mWvIoGCJEeK-fpTrs2yrzw"
elementId="myplugin.ecoretools.categories.ecoretoolsadditions"
name="Ecore Tools Additions" description="Some additional features for
the Ecore Tools"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_unv8kGCJEeK-fpTrs2yrzw" featurename="handlers"
parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Handler"
xmi:id="_xYe-0GCJEeK-fpTrs2yrzw"
elementId="myplugin.ecoretools.handlers.fillColorChangeHandler"
contributionURI="bundleclass://myplugin.ecoretools.additions/myplugin.ecoretools.additions.ModifyFillColorHandler"
command="_S2HosGCJEeK-fpTrs2yrzw"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment"
xmi:id="_Q4ShsGCXEeK-fpTrs2yrzw" featurename="menuContributions"
parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="menu:MenuContribution"
xmi:id="_g19fUGCXEeK-fpTrs2yrzw"
elementId="myplugin.ecoretools.modifyFillColor.menuitem"
accessibilityPhrase=""
parentId="org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu">
<children xsi:type="menu:HandledMenuItem"
xmi:id="_aj-cgGCaEeK-fpTrs2yrzw"
elementId="myplugin.ecoretools.modifyFillColor.menu.item" label="Modify
Fill Color of EClasses to white"
iconURI="platform:/plugin/myplugin.ecoretools.additions/icons/EclassModified.png"
command="_S2HosGCJEeK-fpTrs2yrzw"/>
</elements>
</fragments>
</fragment:ModelFragments>

And my handler looks like this:

public class ModifyFillColorHandler {

private EcoreDiagramEditor editor;

@CanExecute
public boolean checkEcoreDiagramEditor(@Active MPart activePart){
CompatibilityEditor compatibilityEditor = (CompatibilityEditor)
activePart.getObject();
IEditorPart editor = compatibilityEditor.getEditor();
if(editor instanceof EcoreDiagramEditor){
this.editor = (EcoreDiagramEditor) editor;
return true;
}
return false;
}

@Execute
public void fillColorsOfEClasses(){
final Diagram diagram = editor.getDiagram();
TransactionalEditingDomain editingDomain = editor.getEditingDomain();
RecordingCommand command = new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
@SuppressWarnings("unchecked")
EList<View> visibleChildren = diagram.getVisibleChildren();
for (View child : visibleChildren) {
if(child instanceof Node){
Node node = (Node) child;
if(node.getElement() instanceof EClassifier){
FillStyle fillStyle = (FillStyle)
node.getStyle(NotationPackage.Literals.FILL_STYLE);
// white
fillStyle.setFillColor(16777215);
}
}
}
}
};
editingDomain.getCommandStack().execute(command);
}
}

Any ideas how and where to debug this? How can I determine why the
handler isn't invoked? Any hints?

best regards,
Jan
Re: Command Handler is not called since Kepler [message #1073170 is a reply to message #1073163] Wed, 24 July 2013 09:01 Go to previous messageGo to next message
Eclipse UserFriend
Do you have the HandlerProcessingAddon in your list of addons? It is responsible for enabling handlers at startup and when the contexts come and go.
Re: Command Handler is not called since Kepler [message #1073171 is a reply to message #1073170] Wed, 24 July 2013 09:02 Go to previous messageGo to next message
Eclipse UserFriend
https://bugs.eclipse.org/bugs/show_bug.cgi?id=397837
Re: Command Handler is not called since Kepler [message #1073205 is a reply to message #1073170] Wed, 24 July 2013 10:10 Go to previous messageGo to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
No, I don't have it. How do I do this or where do I get the
HandlerProcessingAddon respectively?

best regards,
Jan

Sopot Cela wrote:
> Do you have the HandlerProcessingAddon in your list of addons? It is
> responsible for enabling handlers at startup and when the contexts come
> and go.
Re: Command Handler is not called since Kepler [message #1073207 is a reply to message #1073205] Wed, 24 July 2013 10:18 Go to previous messageGo to next message
Eclipse UserFriend
In the bug I referenced there are detailed instruction on the commit on comment 10.
Re: Command Handler is not called since Kepler [message #1073216 is a reply to message #1073207] Wed, 24 July 2013 10:37 Go to previous messageGo to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
You did not reference any bug.

best regards,
Jan

Sopot Cela wrote:
> In the bug I referenced there are detailed instruction on the commit on
> comment 10.
Re: Command Handler is not called since Kepler [message #1073218 is a reply to message #1073216] Wed, 24 July 2013 10:41 Go to previous messageGo to next message
Eclipse UserFriend
http://www.eclipse.org/forums/index.php/mv/msg/494115/1073171/#msg_1073171
Re: Command Handler is not called since Kepler [message #1073224 is a reply to message #1073218] Wed, 24 July 2013 10:46 Go to previous messageGo to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
Ok, that's strange. I use the forum within my Thunderbird as newsgroups.
And the post with your bug reference didn't appear in the tree view of
the discussion (see attached screenshot), so I missed it. Sorry, I'll
have a look at it.

best regards,
Jan

Sopot Cela wrote:
> http://www.eclipse.org/forums/index.php/mv/msg/494115/1073171/#msg_1073171
  • Attachment: treeView.png
    (Size: 480.93KB, Downloaded 255 times)
Re: Command Handler is not called since Kepler [message #1073226 is a reply to message #1073224] Wed, 24 July 2013 10:55 Go to previous messageGo to next message
Eclipse UserFriend
No problem. Hope that helps.
Re: Command Handler is not called since Kepler [message #1073231 is a reply to message #1073226] Wed, 24 July 2013 11:00 Go to previous message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
Thank you Sopot! It works now :)

best regards,
Jan

Sopot Cela wrote:
> No problem. Hope that helps.
Previous Topic:Editor behavior
Next Topic:create contextual menu in view part
Goto Forum:
  


Current Time: Tue Mar 19 08:46:52 GMT 2024

Powered by FUDForum. Page generated in 0.02655 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top