111894 gmf-head mmostafa 051201 Improve memory consumption of opened notation diagram
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/View.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/View.java index 622f41d..542bf94 100644 --- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/View.java +++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/View.java
@@ -194,6 +194,16 @@ * @see org.eclipse.gmf.runtime.notation.NotationPackage#getView_Children() */ EList getChildren(); + + /** + * Returns an <em><b>Unmodifable</b></em> list that contains all the + * visible children in the Children list. + * The list contents are of type {@link org.eclipse.gmf.runtime.notation.View}. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return <em><b>Unmodifable</b></em> list of Visible children + */ + EList getVisibleChildren(); /** * Returns the value of the '<em><b>Styles</b></em>' containment reference list.
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ViewImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ViewImpl.java index 633c187..45f02dd 100644 --- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ViewImpl.java +++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ViewImpl.java
@@ -26,6 +26,7 @@ import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.EModelElementImpl; import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EContentsEList; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.EObjectWithInverseEList; import org.eclipse.emf.ecore.util.InternalEList; @@ -191,6 +192,8 @@ * @ordered */ protected EList transientChildren = null; + + private EContentsEList allChildren = null; /** * <!-- begin-user-doc --> @@ -316,18 +319,13 @@ * <!-- end-user-doc --> */ public EList getChildren() { - List children = new ArrayList(); - if (persistedChildren!=null && - persistedChildren.size()>0){ - children.addAll(getPersistedChildren()); + if (allChildren == null){ + allChildren = new EContentsEList(this, + new EStructuralFeature[] { + NotationPackage.eINSTANCE.getView_PersistedChildren(), + NotationPackage.eINSTANCE.getView_TransientChildren()}); } - - if (transientChildren!=null&& - transientChildren.size()>0){ - children.addAll(getTransientChildren()); - } - - return new BasicEList.UnmodifiableEList(children.size(), children.toArray()); + return allChildren; } /** @@ -785,4 +783,31 @@ vContainer.persistChildren(); } } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + */ + public EList getVisibleChildren() { + List _children = new ArrayList(); + if (persistedChildren!=null && + persistedChildren.size()>0){ + for (Iterator iter = getPersistedChildren().iterator(); iter.hasNext();) { + View view = (View) iter.next(); + if (view.isVisible()) + _children.add(view); + } + } + + if (transientChildren!=null&& + transientChildren.size()>0){ + for (Iterator iter = getTransientChildren().iterator(); iter.hasNext();) { + View view = (View) iter.next(); + if (view.isVisible()) + _children.add(view); + } + } + return new BasicEList.UnmodifiableEList(_children.size(), _children.toArray()); + } + } //ViewImpl