In my Eclipse plugin, I need to use a file from package explorer. I click on a file with right mouse button and select “View” (my plugin name). So, how can I reach this file path in my plugin project?
http://i49.tinypic.com/2j29ifs.png
I have this:
public class ViewHandler extends AbstractHandler {
...
public Object execute(ExecutionEvent event) throws ExecutionException {
...
...
URI uri = null;
try {
test();
uri = URI.createURI("../models/task.cm");
Resource resource = resourceSet
.getResource(uri, true);
Model model = (Model) resource.getContents().get(0);
ModelExtractor showModel = new ModelExtractor(model);
showModel.run();
} catch (Exception e) {
System.out.print(e);
}
return null;
}
}
And I need to replace this line:
uri = URI.createURI("../models/task.cm");
with relative path to file.
Or if you have some good tuto.
In your Command Handler (I hope, you are using the Command Framework, not JFace Actions) you could check for the currently selected element, and then use the resulting IFile for parsing.