Author: scabanovich
Date: 2007-11-30 10:09:23 -0500 (Fri, 30 Nov 2007)
New Revision: 5167
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamReferencedFilter.java
Log:
JBIDE-1392
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamReferencedFilter.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamReferencedFilter.java 2007-11-30
15:06:56 UTC (rev 5166)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamReferencedFilter.java 2007-11-30
15:09:23 UTC (rev 5167)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.ui.views;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IResource;
@@ -17,6 +18,7 @@
import org.eclipse.jface.viewers.ViewerFilter;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamPackage;
/**
*
@@ -29,22 +31,42 @@
public boolean select(Viewer viewer, Object parentElement, Object element) {
if(element instanceof ISeamComponent) {
ISeamComponent component = (ISeamComponent)element;
- Set<ISeamComponentDeclaration> ds = component.getAllDeclarations();
- for (ISeamComponentDeclaration d : ds) {
- IResource r = d.getResource();
- if(r == null || !r.exists()) {
- //do not filter out the component if we cannot be sure that
- //its source is another project
- return true;
- }
- if(r != null && r.getProject() == d.getSeamProject().getProject()) {
- return true;
- }
- }
- return false;
+ return isComponentDeclaredInThisProject(component);
+ } else if(element instanceof ISeamPackage) {
+ ISeamPackage pkg = (ISeamPackage)element;
+ return isPackageDeclaredInThisProject(pkg);
}
return true;
}
+
+ boolean isComponentDeclaredInThisProject(ISeamComponent component) {
+ Set<ISeamComponentDeclaration> ds = component.getAllDeclarations();
+ for (ISeamComponentDeclaration d : ds) {
+ IResource r = d.getResource();
+ if(r == null || !r.exists()) {
+ //do not filter out the component if we cannot be sure that
+ //its source is another project
+ return true;
+ }
+ if(r != null && r.getProject() == d.getSeamProject().getProject()) {
+ return true;
+ }
+ }
+ return false;
+ }
+ boolean isPackageDeclaredInThisProject(ISeamPackage pkg) {
+ Set<ISeamComponent> cs = pkg.getComponents();
+ for (ISeamComponent c : pkg.getComponents()) {
+ if(isComponentDeclaredInThisProject(c)) return true;
+ }
+ Map<String,ISeamPackage> ps = pkg.getPackages();
+ for (ISeamPackage p : ps.values()) {
+ if(isPackageDeclaredInThisProject(p)) {
+ return true;
+ }
+ }
+ return false;
+ }
}