Skip to main content



      Home
Home » Eclipse Projects » GEF » How can create right button menu like logic example?
How can create right button menu like logic example? [message #98210] Fri, 10 October 2003 03:01 Go to next message
Eclipse UserFriend
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 #98532 is a reply to message #98210] Fri, 10 October 2003 14:49 Go to previous messageGo to next message
Eclipse UserFriend
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.


nemo wrote:
> 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 #99054 is a reply to message #98210] Sun, 12 October 2003 22:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nemo_fc.sina.com

Think your notice,I flow your step done that but the menu is still not
showed.do I miss something?should I implement createaction in LogicEditor?Or
write some action class first?
"nemo" <nemo_fc@sina.com> д
Re: How can create right button menu like logic example? [message #99114 is a reply to message #98532] Mon, 13 October 2003 01:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nemo_fc.sina.com

I check my code.I find that getActionRegistry() return an ActionRegistry
whose map's entrySet,keySet,size are all null.I don't know why it is
"Eric Bordeau" <ebordeau@us.ibm.com> ???? news:bm6uue$f8u$1@eclipse.org...
> 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.context
menu",
> 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.
>
>
> nemo wrote:
> > 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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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.
>
>
>
Re: How can create right button menu like logic example? [message #99591 is a reply to message #99400] Mon, 13 October 2003 23:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nemo_fc.sina.com

Thanks! could you tell me when will createActions() be called.I write
System.out.println("call createactions()") to find it,but fail.

"Eric Bordeau" <ebordeau@us.ibm.com> ???? news:bmedke$b6$2@eclipse.org...
> 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.
Re: How can create right button menu like logic example? [message #99685 is a reply to message #99400] Tue, 14 October 2003 03:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nemo_fc.sina.com

Another question about that,I implement calculateEnabled() in
nemoPropertyAction class like that:

if(getSelectedObjects().isEmpty())
return false;
List parts = getSelectedObjects();
for (int i=0; i<parts.size(); i++){
Object o = parts.get(i);
if (!(o instanceof EditPart))
return false;
EditPart part = (EditPart)o;
if (!(part.getModel() instanceof HelloNodeModel))
return false;
}
return true;

In my opinion , right menu will show when Right click mouse on
HelloNodeModel .But I fail,whereever I right click the return value of
getSelectedObjects.isEmpty() is true, so that the right menu is never
showed.why?Could you tell me
Re: How can create right button menu like logic example? [message #99834 is a reply to message #99685] Wed, 15 October 2003 05:59 Go to previous message
Eclipse UserFriend
Originally posted by: nemo_fc.sina.com

I have found it reason.If register action by manual rather than by
CreateActions(),the getSelectedObject() can't get the model
"nemo" <nemo_fc@sina.com> д
Previous Topic:stuck in endless loop in DeferredUpdateManager
Next Topic:how to create a pop window in gef ?
Goto Forum:
  


Current Time: Wed Apr 30 16:51:42 EDT 2025

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

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

Back to the top