I am working on an Eclipse plugin project that implements an Import file wizard, designed for files that pertain to a custom project type. One of the wizard's pages is a WizardNewFileCreationPage
page, where a project explorer is automatically (as far as I can see) displayed. This project explorer displays all projects available in the workspace. However, since, as I said, the files the wizard deals with are useful to one particular project type, I want to restrict the explorer and only display projects of that custom type.
I know how to select projects of a custom type:
List<IProject> projectList = new LinkedList<IProject>();
try {
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = workspaceRoot.getProjects();
for(int i = 0; i < projects.length; i++) {
IProject project = projects[i];
if(project.hasNature("com.example.www.myNature")) {
projectList.add(project);
}
}
}
catch(CoreException ce) {
ce.printStackTrace();
}
found at this link: Get a list of all java projects open in an Eclipse workspace
I am assuming that the WizardNewFileCreationPage
class includes, behind the scenes, a TreeViewer
or something similar. In any case, how can I filter the contents of the project explorer in this wizard page?
I took a look at the following question: How to programmatically change the selection within package explorer, but in my case the activePart
variable is of type
org.eclipse.ui.navigator.resources.ProjectExplorer
which does not have a getTreeViewer()
method. It has a createPartControl()
method:
public void createPartControl(Composite aParent);
Could this be useful for what I want? Or is it a case of using extension points?
Thank you in advance for your answers.