Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » SWT Popup from Workbench menu bar
SWT Popup from Workbench menu bar [message #489846] Tue, 06 October 2009 08:50 Go to next message
rwf  is currently offline rwf Friend
Messages: 1
Registered: October 2009
Junior Member
Hi there!

I want to extend my Eclipse client. For that I created a small plugin with the needed ui contributions (extensions).

Now I want to start some UI stuff from the menu bar (i. e. a popup table). For that I created the following code.

My problem is, that I don't know which shell I should use (see code comment). The table opens, but within a workbench part, not as a popup.

-- Thx, rwf

public Object execute(final ExecutionEvent event) throws ExecutionException {
final Shell shell=HandlerUtil.getActiveShell(event);
final IWorkbenchWindow window= HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = window.getSelectionService().getSelection();

// do some stuff here

Job job = new Job("First Job"){
@Override
protected IStatus run(IProgressMonitor monitor) {
HandlerUtil.getActiveShell(event).getDisplay().getDefault(). asyncExec(new Runnable() {
public void run() {
Shell shell2 = window.getWorkbench().getDisplay().getActiveShell(); // HERE IS THE PROBLEM! What shell should I use??
shell2.setSize(280, 300);
shell2.setText("Table Example");

final Text text = new Text(shell2, SWT.BORDER);
text.setBounds(25, 240, 220, 25);

TableViewer viewer = new TableViewer(shell2, 2560);
Table restoreTable = viewer.getTable();
restoreTable.setLayout(new FillLayout());
restoreTable.setLinesVisible(true);
restoreTable.setHeaderVisible(true);
TableColumn column1 = new TableColumn(restoreTable, 0);
column1.setText("Archiving date");
column1.setWidth(100);

for (int loopIndex = 0; loopIndex < 24; loopIndex++) {
TableItem item = new TableItem(restoreTable, SWT.NULL);
item.setText("Item " + loopIndex);
item.setText(0, "Item " + loopIndex);
item.setText(1, "Yes");
item.setText(2, "No");
item.setText(3, "A table item");
}

restoreTable.setBounds(25, 25, 220, 200);

restoreTable.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.CHECK) {
text.setText("You checked " + event.item);
} else {
text.setText("You selected " + event.item);
}
}
});
shell2.pack();
}
});
return Status.OK_STATUS;
}

};

job.schedule();


// do other stuff

return null;
}
Re: SWT Popup from Workbench menu bar [message #491032 is a reply to message #489846] Mon, 12 October 2009 23:21 Go to previous message
Remy Suen is currently offline Remy SuenFriend
Messages: 462
Registered: July 2009
Senior Member
On Tue, 06 Oct 2009 04:50:35 -0400, rwf wrote:
> My problem is, that I don't know which shell I should use (see code
> comment). The table opens, but within a workbench part, not as a popup.

Not sure why you're creating widgets within the active shell. Create a
new one instead.

Remy
Previous Topic:Why works ElementListSelectionDialog only at complete started workbench?
Next Topic:Wizards
Goto Forum:
  


Current Time: Thu Sep 26 19:46:26 GMT 2024

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

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

Back to the top