Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Openning external files with the System Editor
Openning external files with the System Editor [message #436682] Wed, 14 September 2005 17:04 Go to next message
Eclipse UserFriend
I am looking for a cross-platform way to open documents (files) that
aren't in a workspace using the OS registered system editor. In SWT, there
is the Program class but what I found is that it only works on windows
(uses win registry) and is only partially implemented on other platform
(like Tiger).

I know the Eclipse navigator->Open With->System Editor works on all
platforms. What does it use? Do the files have to be in a workspace? Could
someone please provide a snippet?

Regards,

Ash
Re: Openning external files with the System Editor [message #436686 is a reply to message #436682] Wed, 14 September 2005 19:13 Go to previous messageGo to next message
Eclipse UserFriend
Actually, I found a way to do this using a linked resource (see below). I
was still wondering if there might be another way that doesn't pull in
additional dependencies like org.eclipse.core.resources.


IWorkspace ws = ResourcesPlugin.getWorkspace();
IProject project = ws.getRoot().getProject(
"External Files");
if (!project.exists())
project.create(null);
if (!project.isOpen())
project.open(null);

IPath location = new
Path(item.getProperty(RSS.link)
.getString());
IFile file =
project.getFile(location.lastSegment());
file.createLink(location, IResource.NONE, null);
FileEditorInput fileEditorInput = new
FileEditorInput(
file);
IEditorPart editor = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage()
.openEditor(
fileEditorInput,

IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID,
true);
Re: Openning external files with the System Editor [message #436719 is a reply to message #436686] Thu, 15 September 2005 08:43 Go to previous messageGo to next message
Eclipse UserFriend
Try org.eclipse.swt.program.Program.
Re: Openning external files with the System Editor [message #436726 is a reply to message #436719] Thu, 15 September 2005 11:22 Go to previous messageGo to next message
Eclipse UserFriend
Using org.eclipse.swt.program.Program was my first approach but I found
the implementation of this class for the Mac OS (Tiger) port atleast to be
pretty simplistic. Unlike the windows version, it doesn't seem to lookup
system file associations but has a few hardcoded mappings (extension
types).

Ash
Re: Openning external files with the System Editor [message #436748 is a reply to message #436726] Fri, 16 September 2005 14:45 Go to previous message
Eclipse UserFriend
Oops :) I apologize for missing that in your initial post.

--Bill
Previous Topic:where to store a derby database in a plugin?
Next Topic:Creating a detached view at startup
Goto Forum:
  


Current Time: Fri Jun 20 07:46:24 EDT 2025

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

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

Back to the top