Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 21:04 Go to next message
Ash Maurya is currently offline Ash MauryaFriend
Messages: 23
Registered: July 2009
Location: Austin, TX
Junior Member
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


Founder, WiredReach (makers of BoxCloud and CloudFire)
blog: http://www.ashmaurya.com
Re: Openning external files with the System Editor [message #436686 is a reply to message #436682] Wed, 14 September 2005 23:13 Go to previous messageGo to next message
Ash Maurya is currently offline Ash MauryaFriend
Messages: 23
Registered: July 2009
Location: Austin, TX
Junior Member
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);


Founder, WiredReach (makers of BoxCloud and CloudFire)
blog: http://www.ashmaurya.com
Re: Openning external files with the System Editor [message #436719 is a reply to message #436686] Thu, 15 September 2005 12:43 Go to previous messageGo to next message
Bill Snyder is currently offline Bill SnyderFriend
Messages: 34
Registered: July 2009
Member
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 15:22 Go to previous messageGo to next message
Ash Maurya is currently offline Ash MauryaFriend
Messages: 23
Registered: July 2009
Location: Austin, TX
Junior Member
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


Founder, WiredReach (makers of BoxCloud and CloudFire)
blog: http://www.ashmaurya.com
Re: Openning external files with the System Editor [message #436748 is a reply to message #436726] Fri, 16 September 2005 18:45 Go to previous message
Bill Snyder is currently offline Bill SnyderFriend
Messages: 34
Registered: July 2009
Member
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: Tue Dec 03 00:33:45 GMT 2024

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

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

Back to the top