Reputation: 25862
How can I arbitrarily display the same file dialog that occurs from New -> File
?
I have an Eclipse Action
where I wish to display the project file path dialog, and not the system file path dialog, as seen in this image:
Also there is one catch: I want to display existing files too, as I will not be creating a new file, but instead may be overwriting/synchronizing a file. If this is NOT possible, I'll still want to know how to just display the same dialog as is in New -> File
.
Upvotes: 2
Views: 1229
Reputation: 29139
To display a workspace file picker, you will need to do something along these lines:
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
shell,
new WorkbenchLabelProvider(),
new WorkbenchContentProvider());
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setAllowMultiple(false);
if (dialog.open() == Window.OK) {
IResource resource = (IResource) dialog.getFirstResult();
}
ElementTreeSelectionDialog
is quite customizable, so you can tune the behavior to your needs.
Upvotes: 2