Bug 84542

Summary: [Ruler] Toggle Ruler and Grid Commands are not active in editor right click menu
Product: [Tools] GEF Reporter: Anshu Jain <anshu.jain>
Component: GEF-Legacy GEF (MVC)Assignee: Anthony Hunter <ahunter.eclipse>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: nyssen
Version: 3.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patched plugin.xml to define the commands for the GEF Toggle actions none

Description Anshu Jain CLA 2005-02-07 03:56:19 EST
The toggle grid and ruler commands(and other GEF specific commands) cannot be
shown in the right click menu of the editor. However the ZoomIN and Zoom Out are
shown. 
The reason seems to be because only two extensions (i:e zoom in and zoom out )
are made to "org.eclipse.ui.commands" in the GEF plugin. Which fails to add any
other command id (like toogle_ruler_visibility etc.) to the command definitions
in the registry while initial extension processing during loading. 
PATCH: 

Add more extensions for respective GEF specific actions to the current plugin.
Requires merely a change in the plugin.xml.
Comment 1 Anshu Jain CLA 2005-02-07 04:05:52 EST
Created attachment 17713 [details]
Patched plugin.xml to define the commands for the GEF Toggle actions
Comment 2 Randy Hudson CLA 2005-02-07 10:49:22 EST
The purpose of defining a Command definition is to allow keybindings to be set 
and changed by the user. How does this affect the ability to put something on a 
menu?  I don't see the connection.
Comment 3 Anshu Jain CLA 2005-02-08 03:26:15 EST
(In reply to comment #2)
> The purpose of defining a Command definition is to allow keybindings to be set 
> and changed by the user. How does this affect the ability to put something on a 
> menu?  I don't see the connection.

-> Well the definition is serving more than its intended purpose by actually
enabling the Command. The "handleAboutToShow" of a menumanager calls the update,
which checks the "isVisible()" of a contribution item. This function returns
true only is the associated CommandCallback returns isActive(String commandId) =
true for the particular commandID.For those GEF Actions which dont have a
commandId(derived from the actionDefinitinId of the Action class)the method
returns a true. Like DeleteAction,  DirectEditAction etc. However for those GEF
actions which have a commandID(actionDefinitionId) set in their constructors,
the method checks if the commandId is defined in the registry. This definition
comes only by extension to the 'org.eclipse.ui.commands' point as i have
suggested in the patch.

Another possible solution without adding command extensions would be to not set
the actionDefinitionId() in the constructor of these Actions which is this line. 
//setActionDefinitionId(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY);

however i am not sure of the effect of this change on the behaviour of the
actions elsewhere.

Please let me know if i made myself clear. otherwise i will try to help by
sending a test case along with a stack trace of the calls. 
Comment 4 Randy Hudson CLA 2005-02-08 11:16:10 EST
Thanks. I wish all bug reporters had comments as clear and helpful as yours. We 
will add command definitions because it makes sense. It sounds like there is 
also a potential bug in the workbench. If an action has an unmapped definition 
ID set, you should get a warning message in the .log file.
Comment 5 Anshu Jain CLA 2005-02-20 23:08:55 EST
I downloaded the latest interation build.
U seem to have added some command definitions, however the
toggle_ruler_visibility, toggle_grid_visibility, toggle_snap_to_geometry,
commands  have not been added. These were the commands whose use led me to the
bug in the first place. Any particular reason
Comment 6 Alexander Nyßen CLA 2013-10-17 09:44:47 EDT
Unset target milestone as the specified one is already passed.