SWT Popup from Workbench menu bar [message #489846] |
Tue, 06 October 2009 08:50 |
rwf 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;
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.03659 seconds