Command Handler is not called since Kepler [message #1073163] |
Wed, 24 July 2013 04:49  |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.37286 seconds