/*
 * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.wso2.developerstudio.eclipse.artifact.template.integration.validators;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

public class ProjectFilter extends ViewerFilter {
	private static final String GENERAL_PROJECT_NATURE = "org.wso2.developerstudio.eclipse.general.project.nature";
	private static final String INTEGRATION_PROJECT_NATURE = "org.wso2.developerstudio.eclipse.integration.project.nature";
	private static boolean showGeneralProjects;
	
	public ProjectFilter() {
	}
	
	public boolean select(Viewer viewer, Object parentElement, Object element) {
		if (element instanceof IProject) {
			try {
				if (((IProject) element)
						.hasNature(showGeneralProjects ? GENERAL_PROJECT_NATURE: INTEGRATION_PROJECT_NATURE)) {
					return true;
				}
			} catch (Exception e) {/*ignore*/}
		}
		return false;
	}
	
	public static void setShowGeneralProjects(boolean showGeneralProjects) {
		ProjectFilter.showGeneralProjects = showGeneralProjects;
	}
}
	

@@ -16,17 +16,17 @@
  (c) 201
-1
+6
 , WSO2 I
@@ -74,17 +74,16 @@
 rved.%0A *
- 
 %0A * Lice
@@ -255,17 +255,16 @@
 se at%0A *
- 
 %0A * http
@@ -304,17 +304,16 @@
 E-2.0%0A *
- 
 %0A * Unle
@@ -898,17 +898,20 @@
 ilter %7B%0A
-%09
+    
 private 
@@ -946,32 +946,87 @@
 PROJECT_NATURE =
+%0A                                                      
  %22org.wso2.devel
@@ -1061,33 +1061,36 @@
 roject.nature%22;%0A
-%09
+    
 private static f
@@ -1129,16 +1129,75 @@
 NATURE =
+%0A                                                          
  %22org.ws
@@ -1252,17 +1252,20 @@
 ature%22;%0A
-%09
+    
 private 
@@ -1300,19 +1300,21 @@
 ojects;%0A
-%09%0A%09
+%0A    
 public P
@@ -1330,22 +1330,27 @@
 ter() %7B%0A
-%09%7D%0A%09%0A%09
+    %7D%0A%0A    
 public b
@@ -1418,18 +1418,24 @@
 ment) %7B%0A
-%09%09
+        
 if (elem
@@ -1465,21 +1465,42 @@
 ) %7B%0A
-%09%09%09try %7B%0A%09%09%09%09
+            try %7B%0A                
 if (
@@ -1523,15 +1523,8 @@
 ent)
-%0A%09%09%09%09%09%09
 .has
@@ -1578,68 +1578,176 @@
 TURE
-: INTEGRATION_PROJECT_NATURE)) %7B%0A%09%09%09%09%09return true;%0A%09%09%09%09%7D%0A%09%09%09
+%0A                                                                       : INTEGRATION_PROJECT_NATURE)) %7B%0A                    return true;%0A                %7D%0A            
 %7D ca
@@ -1769,26 +1769,57 @@
 e) %7B
+%0A                
 /*
+ 
 ignore
+ 
 */%7D%0A
-%09%09%7D%0A%09%09
+        %7D%0A        
 retu
@@ -1832,14 +1832,19 @@
 se;%0A
-%09%7D%0A%09%0A%09
+    %7D%0A%0A    
 publ
@@ -1916,10 +1916,16 @@
 ) %7B%0A
-%09%09
+        
 Proj
@@ -1981,11 +1981,12 @@
 ts;%0A
-%09
+    
 %7D%0A%7D%0A
-%09%0A

format and copyright