SWT initialization [message #437172] |
Sun, 30 May 2004 17:27 |
Eclipse User |
|
|
|
Originally posted by: IgorKazarnovski.img.de
Hi,
I would like to open a file in a correspondent eclipse editor. The
function with the following code is called remotely by a web application
running on the tomcat server.
IFile file = project.getFile("/test.xml");
try {
myPlugin.getDefault().getWorkbech().getActiveWorkbenchWindow ().getActivePage().openEditor(file);
}
catch (PartInitException e) {
e.printStackTrace();
}
The eclipse workbench has no focus, since the action is invoked by a Web
application running in the Web browser. The getActiveWorkbenchWindow ()
function delivers a null value since Display.getCurrent() retuns a null:
public IWorkbenchWindow getActiveWorkbenchWindow() {
// Display will be null if SWT has not been initialized or
// this method was called from wrong thread.
Display display = Display.getCurrent();
if (display == null)
return null;
....}
How can I properly initialize SWT without having eclipse aktiv?
Thanks,
Igor
|
|
|
Re: SWT initialization [message #437173 is a reply to message #437172] |
Sun, 30 May 2004 18:19 |
Eclipse User |
|
|
|
Originally posted by: IgorKazarnovski.img.de
The problem is not in the SWT initialization, but in the wrong thread
calling the function. The current thread is "Thread[RMI TCP
Connection(51)-196.0.0.7,5,RMI Runtime]". The function findDisplay()
requires the "Thread[main,5,main]" thread.
/**
* Returns the display which the given thread is the
* user-interface thread for, or null if the given thread
* is not a user-interface thread for any display.
*
* @param thread the user-interface thread
* @return the display for the given thread
*/
public static synchronized Display findDisplay (Thread thread) {
for (int i=0; i<Displays.length; i++) {
Display display = Displays [i];
if (display != null && display.thread == thread) {
return display;
}
}
return null;
}
Does it means that it's not possible to get the diplay object from the RMI
thread, or there is a way to do it?
Igor Kazarnovski wrote:
> Hi,
> I would like to open a file in a correspondent eclipse editor. The
> function with the following code is called remotely by a web application
> running on the tomcat server.
> IFile file = project.getFile("/test.xml");
> try {
>
myPlugin.getDefault().getWorkbech().getActiveWorkbenchWindow ().getActivePage().openEditor(file);
> }
> catch (PartInitException e) {
> e.printStackTrace();
> }
> The eclipse workbench has no focus, since the action is invoked by a Web
> application running in the Web browser. The getActiveWorkbenchWindow ()
> function delivers a null value since Display.getCurrent() retuns a null:
> public IWorkbenchWindow getActiveWorkbenchWindow() {
> // Display will be null if SWT has not been initialized or
> // this method was called from wrong thread.
> Display display = Display.getCurrent();
> if (display == null)
> return null;
> ....}
> How can I properly initialize SWT without having eclipse aktiv?
> Thanks,
> Igor
|
|
|
Powered by
FUDForum. Page generated in 0.02746 seconds