views:

1591

answers:

1

I am opening an editor from a view on click of a treenode. Now, when editor loads and controls are displayed to the user, I want to display a warning message dialog to the user based on certain values present on the editor.

I tried by putting the warning dialog at the end of createPartControl method of the editor. Dialog appears on double cliking the treenode as per the required functionality. But, the problem is that when the dialog appears, the controls on the editor are not yet visible. It's only when I close the dialog the editor controls are shown.

I want it to happen the other way around. i.e. The editor controls to show up first and then the warning dialog should appear. What changes should I do to achieve this effect?

+2  A: 

You may want to call that MessageDialog in an asynchronous way, to leave the Editor the opportunity to complete itself, as suggested in this message.

show your warning dialog in an asyncExec() runnable would ensure that the editor's initialization all happens in the correct sequence.

So, something like (not tested) this code might do the trick:

getSite().getShell().getDisplay().asyncExec
    (new Runnable() {
        public void run() {
            MessageDialog.openWarning(getSite().getShell(),"wrong","no)
        }
    });
}

Some other examples in this MapEditor class, where a MessageDialog is displayed through an asyncExec which waits for the result:

PlatformGIS.syncInDisplayThread

VonC
yes, sir. works wonderfully well. well thought!
Chandan .