Modifying Menu inside Job/Display.asyncExec() [message #330422] |
Mon, 28 July 2008 11:11  |
Eclipse User |
|
|
|
Hi,
I used the following to add MenuItems to an existing Menu object. In
which, createMenuDescriptor(), method is time consuming operation. So i
had to put this in a Job thread. But whatever changes applied to the Menu
object is not visible in the UI. Note that the same code worked in
eclipse3.2 but not in eclipse 3.4. A help would be really great. Thanks in
advance.
public void constructMenu( final Menu parent) {
MenuItem[] menuItems = parent.getItems();
for (int i = 0; i < menuItems.length; i++) {
menuItems[i].dispose();
}
MenuItem item = new MenuItem(parent, SWT.PUSH);
item.setText(Messages.getString("MenuBuilder.Loading"));
//$NON-NLS-1$
item.setEnabled(false);
Job job = new Job( "") {
@Override
protected IStatus run(IProgressMonitor monitor) {
final MenuDescriptor descriptor =
createMenuDescriptor(); //Time consuming operation
if (!parent.isDisposed()) {
parent.getDisplay().syncExec(new Runnable() {
public void run() {
if (!parent.isDisposed()) {
constructMenu( parent,
descriptor); //Which adds and diposes some of the menu-items in parent
object.
}
}
});
}
return Status.OK_STATUS;
}
};
job.setPriority(Job.SHORT);
job.schedule();
}
Regards,
Mathi
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05301 seconds