Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » SWT/JFACE - How to set a selection on a pop-up menu
SWT/JFACE - How to set a selection on a pop-up menu [message #198708] Fri, 09 March 2007 08:21 Go to next message
Eclipse UserFriend
Originally posted by: baiyf99.yahoo.com

Sorry, this is post transferred from foundation forum.
I hope someone could help me on this issue.
Just to add on, I have a viewer (inherited from TreeViewer),
and upon right mouse click, it will display a pop-up menu.
I would like to programmatically set the options on this pop-up
menu.



---------------------------------------
Subject: Re: SWT/JFACE - How to set a selection on a pop-up menu
From: merks@xxxxxxxxxxxx (Ed Merks)
Newsgroups: eclipse.foundation
Organization: EclipseCorner
Date: Mar 09 2007 03:12:47

Sally,

This newsgroup is for discussion the operations of the Eclipse
organization itself. Please use the platform or newcomers newsgroup for
questions like this. (You're question totally confuses me. I don't
understand how the menu item is related to a selection in a viewer.)

sally wrote:

Hi,

Hope someone could advise me on the above issue.
I have written a pop-up menu using MenuManager.
For example, MenuItems are "Save" and "Cancel"
I would like to program using a timer to set a selection on one of
the menu items (for example, Save in this case), so that a save operation
is done at certain time intervals.
Please advise how (preferably with some java coding) on how to set the
selection to that particular menu item.

I have written a simple method. viewer in this case, is a Tree Viewer.
I am not sure what/how to pass in the selection parameter, in this case to
set the selection to Save MenuItem.

Pls advise, thanks.
Sally


//Set by the timer in certain time intervals to set Save MenuItem
public void setSelection(IStructuredSelection selection) { if ((viewer
!= null) && (viewer.getSelection() == null)) {
viewer.setSelection(selection); }
}
Re: SWT/JFACE - How to set a selection on a pop-up menu [message #199730 is a reply to message #198708] Thu, 15 March 2007 18:15 Go to previous message
Jeff Magill is currently offline Jeff MagillFriend
Messages: 15
Registered: July 2009
Junior Member
> Sorry, this is post transferred from foundation forum.
> I hope someone could help me on this issue. Just to add on, I have a
> viewer (inherited from TreeViewer),
> and upon right mouse click, it will display a pop-up menu.
> I would like to programmatically set the options on this pop-up
> menu.

I can't tell if you're trying to change the contents of the menu when it
pops up or if you're just trying to reuse the implementation of a menu
action from the timer.

A standard method for configuring the contents of a menu dynamically is to
setRemoveAllWhenShown(true) on your MenuManager and then add an
IMenuListener to the MenuManager that adds all your menu items every time
the menu is shown.

The tutorial at
http://www.eclipse.org/articles/viewArticle/ViewArticle2.htm l covers this.


Jeff
Previous Topic:EFS with Eclipse 3.1
Next Topic:how can i turn off "WARNING" log msgs?
Goto Forum:
  


Current Time: Fri Apr 26 19:41:02 GMT 2024

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

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

Back to the top