Open a file in the editor from code [message #1003503] |
Mon, 21 January 2013 11:33 |
Marco Orlandin Messages: 6 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 12:12] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03196 seconds