How can create right button menu like logic example? [message #98210] |
Fri, 10 October 2003 03:01  |
Eclipse User |
|
|
|
Originally posted by: nemo_fc.sina.com
In logic example,there will be "+1 increment" and "-1 increment" on the
right button menu when right button click the an LED model.It could change
the number on led.How can I implement such function? Or which code files
will tell me that in logic example?Could anyone tell me that? Thanks very
much!
|
|
|
|
|
|
Re: How can create right button menu like logic example? [message #99340 is a reply to message #98532] |
Mon, 13 October 2003 10:16   |
Eclipse User |
|
|
|
Originally posted by: nemo_fc.sina.com
I find the hashmap of the ActionRegistry which getActionRegistry() return
is null.So I instance it myself by such way:
nemoPropertyAction npa = new nemoPropertyAction(this);
getActionRegistry().registerAction(npa);
this.getSelectionActions().add(npa.getId());
nemoPropertyAction is Action defined myself.then I gets registered for
nemoContextMenuProvider by:
ContextMenuProvider provider = new
nemoContextMenuProvider(viewer,a);
viewer.setContextMenu(provider);
getSite().registerContextMenu("nemo.HelloGefeditor.contextmenu ",
provider, viewer);
Though those code,I implement right button menu.But I want to konw in
formal way,where should I arrange my code which set getActionRegistry()
retun value's hashmap isn't null? Maybe should I place it in
CreateActions()?If it is true,when will CreateActions() be called?called
by system automatic or by myself.
Eric Bordeau wrote:
> Take a look at ContextMenuProvider and LogicContextMenuProvider. The
> context menu gets registered in LogicEditor.configureGraphicalViewer()...
> ContextMenuProvider provider = new LogicContextMenuProvider(viewer,
> getActionRegistry());
> viewer.setContextMenu(provider);
>
getSite().registerContextMenu("org.eclipse.gef.examples.logic.editor.contextmenu ",
> provider, viewer);
> When the user clicks the right mouse button,
> ContextMenuProvider.menuAboutToShow(IMenuManager) is called, which then
> calls buildContextMenu(IMenuManager). This is where the actions get
> added to the menu.
|
|
|
Re: How can create right button menu like logic example? [message #99400 is a reply to message #99340] |
Mon, 13 October 2003 10:42   |
Eclipse User |
|
|
|
Yes, you should create your actions and add them to the ActionRegistry
in createActions(), which will be called automatically. Make sure you
call super.createActions(), since GraphicalEditor creates some actions
itself.
nemo wrote:
> I find the hashmap of the ActionRegistry which getActionRegistry() return
> is null.So I instance it myself by such way:
>
> nemoPropertyAction npa = new nemoPropertyAction(this);
> getActionRegistry().registerAction(npa);
> this.getSelectionActions().add(npa.getId());
> nemoPropertyAction is Action defined myself.then I gets registered for
> nemoContextMenuProvider by:
> ContextMenuProvider provider = new
> nemoContextMenuProvider(viewer,a);
> viewer.setContextMenu(provider);
> getSite().registerContextMenu("nemo.HelloGefeditor.contextmenu ",
> provider, viewer);
> Though those code,I implement right button menu.But I want to konw in
> formal way,where should I arrange my code which set getActionRegistry()
> retun value's hashmap isn't null? Maybe should I place it in
> CreateActions()?If it is true,when will CreateActions() be called?called
> by system automatic or by myself.
>
>
> Eric Bordeau wrote:
>
>
>>Take a look at ContextMenuProvider and LogicContextMenuProvider. The
>>context menu gets registered in LogicEditor.configureGraphicalViewer()...
>
>
>>ContextMenuProvider provider = new LogicContextMenuProvider(viewer,
>>getActionRegistry());
>>viewer.setContextMenu(provider);
>>
>
> getSite().registerContextMenu("org.eclipse.gef.examples.logic.editor.contextmenu ",
>
>>provider, viewer);
>
>
>>When the user clicks the right mouse button,
>>ContextMenuProvider.menuAboutToShow(IMenuManager) is called, which then
>>calls buildContextMenu(IMenuManager). This is where the actions get
>>added to the menu.
>
>
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03837 seconds