Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Open External File from a class implementing IStartup
Open External File from a class implementing IStartup [message #289485] Fri, 05 August 2005 15:02 Go to next message
Eclipse UserFriend
Originally posted by: no_email_please.hotmail.com

Hi,

Is there a way of triggering an OpenExternalFileAction within a class
implementing IStartup (or during startup)?

So far I've got this:

IWorkbench workbench = PlatformUI.getWorkbench();
File file = new File(myFilePath);
IPath path = new Path(file.getAbsolutePath());
IEditorInput input = new
FileEditorInput(ResourcesPlugin.getWorkspace().getRoot().get File(new
Path(file.getAbsolutePath())));
try{
IWorkbenchWindow window = workbench.openWorkbenchWindow(input);
window.openPage(input);
}catch(Exception e){
System.out.println(e);
}


The problem is that the current thread is not the display thread so when I
try to create my window object, I get invalid thread access.

Any ideas?

Thanks
Nic
Re: Open External File from a class implementing IStartup [message #289495 is a reply to message #289485] Fri, 05 August 2005 17:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nico.mook.laposte.net

Hi,

Have you tried to make your action in a syncExec/asyncExec call ?


Display.getDefault().asyncExec(new Runnable() {
public void run() {
...your code ...
}
});


Tchuss,
Nico.
Re: Open External File from a class implementing IStartup [message #289497 is a reply to message #289495] Fri, 05 August 2005 17:43 Go to previous message
Eclipse UserFriend
Originally posted by: no_email_please.hotmail.com

Thanks, that seems to work.... but not completely. It's a good step forward
though.
The problem now is that it opens a second workbench... I just need a
workbench page (I think that's what it's called) or editor to open.
This is what I do now:

final IWorkbench workbench = PlatformUI.getWorkbench();
myTest t = new myTest();
t.setFilePath(filename);
t.setWorkbench(workbench);
workbench.getDisplay().asyncExec(t);

class myTest implements Runnable{
private String myFilePath;
private IWorkbench myWorkbench;
public void setFilePath(String filepath){
myFilePath = filepath;
}
public void setWorkbench(IWorkbench workbench){
myWorkbench = workbench;
}
public void run() {

File file = new File(myFilePath);
IPath path = new Path(file.getAbsolutePath());
IEditorInput input = new
FileEditorInput(ResourcesPlugin.getWorkspace().getRoot().get File(new
Path(file.getAbsolutePath())));
IWorkbenchWindow window = myWorkbench.getActiveWorkbenchWindow();
try{
if (window != null){
IWorkbenchPage iwp = window.openPage(input);
iwp.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
}
}catch(Exception e){
System.out.println(e);
}
}
}

"nicolas" <nico.mook@laposte.net> wrote in message
news:b2633cf70a2171bcf9d0ca3693361f81$1@www.eclipse.org...
> Hi,
>
> Have you tried to make your action in a syncExec/asyncExec call ?
>
>
> Display.getDefault().asyncExec(new Runnable() {
> public void run() {
> ...your code ...
> }
> });
>
>
> Tchuss,
> Nico.
>
>
Previous Topic:How to overide Paste action in NavigatorView
Next Topic:ActionFactory.QUIT and preWindowShellClose
Goto Forum:
  


Current Time: Thu Mar 28 12:41:51 GMT 2024

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

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

Back to the top