问题
I am working on a eclipse plugin and reusing the 'Project Explorer' view to display the tree content.
I have few questions to make it best possible reuse:
How can I disable the sort - currently 'Project Explorer' view sort tree nodes which I dont want. Is thr a single place where i can change the flags or something? Or I will have to implement a View Sorter ?
How can I save the expanded state of projects the way it does for a java project , i want the same to implemented for custom plugin project.
How can I mark some nodes not to be displayed. I want few folders to be hidden and not displayed in 'Project Explorer' view.
Plugin is using Wizards (INewWizard) to create a IProject and add some IFolder(s) to it.
Code snippet:
private static IProject createBaseProject(String projectName, URI location) {
// it is acceptable to use the ResourcesPlugin class
IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (!newProject.exists()) {
URI projectLocation = location;
IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName());
if (location != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location)) {
projectLocation = null;
}
desc.setLocationURI(projectLocation);
try {
newProject.create(desc, null);
if (!newProject.isOpen()) {
newProject.open(null);
}
} catch (CoreException e) {
e.printStackTrace();
}
}
return newProject;
}
private static void createFolder(IFolder folder) throws CoreException {
IContainer parent = folder.getParent();
if (parent instanceof IFolder) {
createFolder((IFolder) parent);
}
if (!folder.exists()) {
folder.create(false, true, null);
}
}
回答1:
If you want to customize your own ProjectExplorer view, you need to study the Common Navigator Framework docs and tutorials like this one
来源:https://stackoverflow.com/questions/29432507/reuse-project-explorer-view-for-your-custom-plugin-project