Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Open a file in the editor from code
Open a file in the editor from code [message #1003503] Mon, 21 January 2013 06:33 Go to previous message
Marco Orlandin is currently offline Marco Orlandin
Messages: 4
Registered: January 2013
Junior Member
Hi,
i need to open a project in my RCP application from code. I've done with this function

	
@Override
public void run() {
	IPath path = new Path("/MyReports/Coffee_4.jrxml");
	IFile sampleFile =  new FileTest(path,(Workspace)ResourcesPlugin.getWorkspace());
	try {
	 EditorUtility.openInEditor(sampleFile, true);
	} catch (PartInitException e) {
	 e.printStackTrace();
	}
}


Where FileTest is a subclass of org.eclipse.core.internal.resources.File, since its constructor is protected. It works but i get a lot of "discouraged access" warnings, so probably this method isn't a clean one. Is there some other way to do this?

UPDATE:

I've found a more clean way with

@Override
public void run() {
  IPath path = new Path("/MyReports/Coffee_4.jrxml");
  IFile sampleFile =  ResourcesPlugin.getWorkspace().getRoot().getFile(path);
  try {
    EditorUtility.openInEditor(sampleFile, true);
  } catch (PartInitException e) {
    e.printStackTrace();
  }
}


But i've still the same problem since even EditorUtility.openInEditor is discouraged

[Updated on: Mon, 21 January 2013 07:12]

Report message to a moderator

 
Read Message
Read Message
Previous Topic:How to override/modify a perspective layout from another plugin?
Next Topic:Add specific visual Editor from plugin to E4 RCP Application
Goto Forum:
  


Current Time: Sun May 19 17:20:54 EDT 2013

Powered by FUDForum. Page generated in 0.01626 seconds