Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.papyrus.tabbedproperties.core/src/org/eclipse/papyrus/tabbedproperties/core/filters/InterfaceFilter.java')
-rw-r--r--core/org.eclipse.papyrus.tabbedproperties.core/src/org/eclipse/papyrus/tabbedproperties/core/filters/InterfaceFilter.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/core/org.eclipse.papyrus.tabbedproperties.core/src/org/eclipse/papyrus/tabbedproperties/core/filters/InterfaceFilter.java b/core/org.eclipse.papyrus.tabbedproperties.core/src/org/eclipse/papyrus/tabbedproperties/core/filters/InterfaceFilter.java
new file mode 100644
index 00000000000..fc31558a786
--- /dev/null
+++ b/core/org.eclipse.papyrus.tabbedproperties.core/src/org/eclipse/papyrus/tabbedproperties/core/filters/InterfaceFilter.java
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * Copyright (c) 2008 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.tabbedproperties.core.filters;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+
+/**
+ * This is a filter to display list of Type
+ */
+public class InterfaceFilter extends ViewerFilter {
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ //this is a resource display it only if it contains a operation
+ if(element instanceof Resource){
+ TreeIterator<EObject> iter=(((Resource)element)).getAllContents();
+ while(iter.hasNext()){
+ if (iter.next() instanceof org.eclipse.uml2.uml.Interface){
+ return true;
+ }
+ }
+ }
+ if(element instanceof Package){
+ //this is a package display it only if it contains a operation
+ Iterator<Element> iter=(((Package)element)).allOwnedElements().iterator();
+ while(iter.hasNext()){
+ if (iter.next() instanceof org.eclipse.uml2.uml.Interface){
+ return true;
+ }
+ }
+
+ }
+ if(element instanceof Classifier){
+ Iterator<Element> iter=(((Classifier)element)).allOwnedElements().iterator();
+ while(iter.hasNext()){
+ if (iter.next() instanceof org.eclipse.uml2.uml.Interface){
+ return true;
+ }
+ }
+ }
+
+ // ok this is finally a Comment
+ if(element instanceof org.eclipse.uml2.uml.Interface){
+ return true;
+ }
+ //else
+ return false;
+ }
+
+}

Back to the top