Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » add context menu to table editor
add context menu to table editor [message #438326] Tue, 22 June 2004 08:58 Go to next message
Eclipse UserFriend
Originally posted by: franz.tucher-63.gmx.net

Hello,

I have a table editor like the example under
http://www.eclipse.org/articles/Article-Table-viewer/table_v iewer.html in my
application.
Now I want to add a context menu programmatically to the rows with entries
(delete, rename and so on).
Does anybody know how I can achieve this?

Thank you, Franz
Re: add context menu to table editor [message #438333 is a reply to message #438326] Tue, 22 June 2004 12:29 Go to previous messageGo to next message
Richard Moore is currently offline Richard MooreFriend
Messages: 71
Registered: July 2009
Member
Hi Franz,



Sorry about the format but the code below adds a pop up menu (with 2 items)
on the selected row in a table...

// popup menu: open partner

Menu pop = new Menu(theParent.getShell(), SWT.POP_UP);

MenuItem item = new MenuItem(pop, SWT.PUSH);

item.setText(ClientTranslator.getString("PartnerSearchView.Open_Partner "));

item.addSelectionListener(new SelectionListener() {

public void widgetDefaultSelected(SelectionEvent e) {

}

public void widgetSelected(SelectionEvent e) {

Object o = e.getSource();

if (o instanceof MenuItem) {

TableItem[] ti = cTable.getTable().getSelection();

if (ti != null && ti.length > 0) {

Integer partnerId = getPartnerIdFromTableItem(ti[0]);

Application.setActivePartnerId(partnerId);

}

else

Application.setStatusLineMsg(ClientTranslator.getString("PartnerQuickSearch.
NoPartnerToOpen"));

}

}

});

// popup menu: add to favorites

item = new MenuItem(pop, SWT.PUSH);

item.setText(ClientTranslator.getString("PartnerSearchView.Add_to_Favorites "
)); //$NON-NLS-1$

item.addSelectionListener(new SelectionListener() {

public void widgetDefaultSelected(SelectionEvent e) {

}

public void widgetSelected(SelectionEvent e) {

Object o = e.getSource();

if (o instanceof MenuItem) {

IStructuredSelection sel = (IStructuredSelection)
cTable.getTableViewer().getSelection();

addToFavorites(sel);

}

}

});

cTable.getTable().setMenu(pop);

"Franz Tucher" <franz.tucher-63@gmx.net> wrote in message
news:cb8sae$bih$1@eclipse.org...
> Hello,
>
> I have a table editor like the example under
> http://www.eclipse.org/articles/Article-Table-viewer/table_v iewer.html in
my
> application.
> Now I want to add a context menu programmatically to the rows with entries
> (delete, rename and so on).
> Does anybody know how I can achieve this?
>
> Thank you, Franz
>
>
Re: add context menu to table editor [message #438335 is a reply to message #438333] Tue, 22 June 2004 13:36 Go to previous message
Eclipse UserFriend
Originally posted by: franz.tucher-63.gmx.net

Thank you, that helped, Franz.
Previous Topic:look and feel
Next Topic:Can wrap mPlayer(linux) with SWT?
Goto Forum:
  


Current Time: Fri Apr 19 04:08:41 GMT 2024

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

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

Back to the top