GEF 可以使用 SWT Window 作为弹出窗口吗?
我正在使用 GEF 做一个项目。双击画布中的模型时,我需要打开一个弹出窗口。
我创建了一个 SWT 窗口并让 GEF 打开它。但问题是它会导致异常:
运行以下代码时,线程“Thread-5”中的异常org.eclipse.swt.SWTException:无法执行可运行的(org.eclipse.swt.SWTException:无效的线程访问)
。
while(!shell.isDisposed()){
**if(!display.readAndDispatch()){**
display.sleep();
}
}
我在项目中所做的是创建 SWT 窗口,然后创建一个线程来运行它,并在模型的编辑部分中调用该线程,如下所示:
public void performRequest(Request req)
{
swtthread aa = new swtthread();
aa.start();
}
Do possible a GEF can use SWT window as a popup window or is there any other way to做这个吗?
谢谢
I am doing a project using GEF. I need to open a popup window when double click the model in the canvas.
I create a SWT window and let GEF to open it. But the problem is it casue an exception:
Exception in thread "Thread-5" org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Invalid thread access)
when running following code.
while(!shell.isDisposed()){
**if(!display.readAndDispatch()){**
display.sleep();
}
}
What i did in my project is create the SWT window, then make a thread to run it, and call the thread in my model's editpart like this:
public void performRequest(Request req)
{
swtthread aa = new swtthread();
aa.start();
}
Do possible a GEF can use SWT window as a popup window or is there any other way to do this?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来很奇怪,但我对 GEF 没有任何经验。根据this SWT FAQ,您从非UI线程调用UI方法,尝试 您也可以使用 asyncExec包装代码
,具体取决于您的需要。
Sound strange, but I have no experiences with GEF though. According to this SWT FAQ you call UI method from non-UI thread, try to wrap the code with
You can also use asyncExec, depending on your needs..