Imediava's Blog

Just another site

Hide a project from the workspace in Eclipse

When you’re developing an Eclipse plugin sometimes you need to use the functionality JDT provides for tasks you don’t want the users of your plugin to be aware of. I ran into an example of this while developing a plugin. I needed to create a project in the workspace that I didn’t want users to see.

The solution came from the JavaElementFilters extension. To set up this extension you have to go to your plugin.xml file and add something like the following:

          description="Description of the filter you wanna create."

The description of each of this fields can be found at:

However the most important field is the class field. The class field points out to the actual class which implements the project filter. This class must extend org.eclipse.jface.viewers.ViewerFilter. To extend this abstract class we just have to override the select method. As an example of overriding this method I’m gonna use the code I used to solve my initial problem:

	public boolean select(Viewer viewer, Object parentElement, Object element) {
		if(element instanceof IJavaProject){
			return !((IJavaProject) element).getElementName().equals("ProjectNameToFilter");
		return true;

What this example does is just:

  • First it makes sure that the element received is an instance of IJavaProject (it’s a Java project in the workspace).
  • Then it filters the project if it has a concrete name.

PS: I have to thank Prakash from for redirecting me to the JavaElementFilters extension as the solution of my problem.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: