[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: SWT and UI Thread block

I tried the Display.syncExec() first, but that didn't work.  I can try
again; thought that was the proper way.  I just don't know what to put in
the Runnable.  Just the m.setVisible()?  Is there a better method to get the
popup to work?  Should I send an event (pop-up request) instead.

Thanks.


On 6/13/08 6:40 AM, in article phj454h5hkcsacudjioh9asokt7nn6co27@xxxxxxx,
"Achim Lörke" <Achim.Loerke@xxxxxxxxx> wrote:

> Mark,
> 
> Wouldn't Display.syncExec() work? This wouldn't stop the UI execution
> but stop your thread until the Runnable is finished.
> 
> Achim
> 
> On Thu, 12 Jun 2008 17:55:14 -0400, Mark Ingerman
> <mingerman@xxxxxxxxxxxxx> wrote:
> 
>> I have a problem where I want the current UI execution to stop, and perform
>> some other ui (not a dialog box), and wait until that task is finished
>> before returning to the previous spot.
>> 
>> I have code that is running inside GEF that wants to put up a menu when the
>> end connection (mouse down) event is run.  I tried the following trick; it
>> works on the MAC and under windows, but not under Linux.  I wonder if there
>> is a better way.
>> 
>> Here is the code:
>> 
>>  do some code....
>> 
>>  Control c = Display.getCurrent().getFocusControl();
>>  if (c != null) {
>>    Menu old = c.getMenu();
>>    MenuManager mm = new MenuManager();
>>    for (String s : cats) {
>> 
>>      mm.add(new _Action(s, isSource));
>> 
>>    }
>> 
>>    final Menu m = mm.createContextMenu(c);
>>    c.setMenu(m);
>>    m.setVisible(true);
>>    c.getDisplay().readAndDispatch();
>>    c.setMenu(old);
>> 
>> }
>> 
>> 
>> finish the code....
>> 
>> 
>> With the c.getDisplay().readAndDispatch() code in, the menu comes up, and
>> until either one of the menu items are selected or ESC is pressed, the
>> c.setMenu(old) statement and the following statements don't execute.
>> 
>> Under Linux, however, it falls through, processes the rest of the event, and
>> then allows for the firing of the menu.
>> 
>> Is there a better way to do this?
> 
> Achim

-- 
Mark M. Ingerman
Senior Architect
Metatomix
www.metatomix.com
781 907-6746