Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » How to get full path of opened file in editor
How to get full path of opened file in editor [message #11908] Wed, 09 July 2008 12:47 Go to next message
Eclipse UserFriend
Originally posted by: yeronimuz.aol.com

I'm running an RCP app with two plugins. I want to start the second
plugin with a parameter, which is the file name (full path) of the
currently opened file in the editor of the first plugin.
So I have an action defined and get the filename from the active editor.
Problem is that I need the full path. I only get the short file name.

public final class SimulatorAction implements
IWorkbenchWindowActionDelegate {
private IWorkbenchWindow m_window;

public void run(IAction action) {
SimulatorGui gui = new SimulatorGui();
String fName =
m_window.getActivePage().getActiveEditor().getEditorInput(). getName();
// Start the GUI
}

public void init(IWorkbenchWindow window) {
m_window = window;
}
}

Help is appreciated.
JL
Re: How to get full path of opened file in editor [message #12473 is a reply to message #11908] Wed, 09 July 2008 13:15 Go to previous message
Eclipse UserFriend
Originally posted by: yeronimuz.aol.com

Jeroen Lankheet wrote:
> I'm running an RCP app with two plugins. I want to start the second
> plugin with a parameter, which is the file name (full path) of the
> currently opened file in the editor of the first plugin.
> So I have an action defined and get the filename from the active editor.
> Problem is that I need the full path. I only get the short file name.
>
> public final class SimulatorAction implements
> IWorkbenchWindowActionDelegate {
> private IWorkbenchWindow m_window;
>
> public void run(IAction action) {
> SimulatorGui gui = new SimulatorGui();
> String fName =
> m_window.getActivePage().getActiveEditor().getEditorInput(). getName();
> // Start the GUI
> }
>
> public void init(IWorkbenchWindow window) {
> m_window = window;
> }
> }
>
> Help is appreciated.
> JL
Once again, I found the solution myself shortly after posting and after
some serious clicking around in the Object Inspector.

IResource fName = (IResource) m_window.getActivePage().getActiveEditor()
.getEditorInput().getAdapter(IResource.class);
String name = fName.getFullPath().toOSString();
String wsLocation =
fName.getWorkspace().getRoot().getLocation().toOSString();

// Now wsLocation + name are the full path to the opened file.
Thanks for the help...you're welcome ;-)
Re: How to get full path of opened file in editor [message #572765 is a reply to message #11908] Wed, 09 July 2008 13:15 Go to previous message
Jeroen Lankheet is currently offline Jeroen LankheetFriend
Messages: 31
Registered: July 2009
Member
Jeroen Lankheet wrote:
> I'm running an RCP app with two plugins. I want to start the second
> plugin with a parameter, which is the file name (full path) of the
> currently opened file in the editor of the first plugin.
> So I have an action defined and get the filename from the active editor.
> Problem is that I need the full path. I only get the short file name.
>
> public final class SimulatorAction implements
> IWorkbenchWindowActionDelegate {
> private IWorkbenchWindow m_window;
>
> public void run(IAction action) {
> SimulatorGui gui = new SimulatorGui();
> String fName =
> m_window.getActivePage().getActiveEditor().getEditorInput(). getName();
> // Start the GUI
> }
>
> public void init(IWorkbenchWindow window) {
> m_window = window;
> }
> }
>
> Help is appreciated.
> JL
Once again, I found the solution myself shortly after posting and after
some serious clicking around in the Object Inspector.

IResource fName = (IResource) m_window.getActivePage().getActiveEditor()
.getEditorInput().getAdapter(IResource.class);
String name = fName.getFullPath().toOSString();
String wsLocation =
fName.getWorkspace().getRoot().getLocation().toOSString();

// Now wsLocation + name are the full path to the opened file.
Thanks for the help...you're welcome ;-)
Previous Topic:How to get full path of opened file in editor
Next Topic:cluttered directory structure view in new file creation wizard
Goto Forum:
  


Current Time: Thu Apr 25 06:45:17 GMT 2024

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

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

Back to the top