Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT initialization
SWT initialization [message #437172] Sun, 30 May 2004 17:27 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:My apps get not to terminate with SWT/jface in M9 ... !?
Next Topic:problems GC.drawText alignment
Goto Forum:
  


Current Time: Fri Apr 26 13:36:51 GMT 2024

Powered by FUDForum. Page generated in 0.02746 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top