diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java index 1ac0f433ca1c9ac6ef2fed2ea3606d70f5a5d63b..7aa91bb25ec4375f1d277799e2b3f5780c7c7ebc 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java @@ -17,6 +17,9 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.ui.internal.views; +import static org.fortiss.tooling.kernel.utils.EcoreUtils.filterOutInstanceOf; +import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement; + import java.util.List; import java.util.Set; @@ -37,8 +40,10 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.dialogs.FilteredTree; import org.eclipse.ui.dialogs.PatternFilter; import org.eclipse.ui.part.ViewPart; +import org.fortiss.tooling.kernel.extension.data.LibraryPrototype; import org.fortiss.tooling.kernel.extension.data.Prototype; import org.fortiss.tooling.kernel.extension.data.PrototypeCategory; +import org.fortiss.tooling.kernel.model.ILibraryElement; import org.fortiss.tooling.kernel.service.IPrototypeService; import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; import org.fortiss.tooling.kernel.ui.extension.base.EditorBase; @@ -53,7 +58,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; * @author eder * @author $Author: hoelzl $ * @version $Rev: 18709 $ - * @ConQAT.Rating YELLOW Hash: 39E9DA9C8ED720A9B2BF2E8CF1F59132 + * @ConQAT.Rating YELLOW Hash: 5E0A6B7513494BEE591C87F52EF828B6 */ public class LibraryView extends ViewPart { @@ -134,8 +139,14 @@ public class LibraryView extends ViewPart { containerObject = editorBase.getEditedObject(); for(Class<? extends EObject> clazz : editorBase.getVisibleEObjectTypes()) { - supportedBaseClasses.addAll(IPrototypeService.INSTANCE - .getComposablePrototypes(clazz)); + List<Prototype> composablePrototypes = + IPrototypeService.INSTANCE.getComposablePrototypes(clazz); + if(getParentElement(containerObject, ILibraryElement.class) == null) { + supportedBaseClasses.addAll(composablePrototypes); + } else { + supportedBaseClasses.addAll(filterOutInstanceOf(LibraryPrototype.class, + composablePrototypes)); + } } } else { containerObject = null; diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java index d6549e33214bd69ea734bd25f206c73405bb9f63..242ff4b6679f0a738141c4a75ccfa00fed634b00 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java @@ -38,7 +38,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil; * @author ratiu * @author $Author: hoelzl $ * @version $Rev: 18709 $ - * @ConQAT.Rating GREEN Hash: 222CC17CBA6ACE77BF515B479798D738 + * @ConQAT.Rating YELLOW Hash: 75E3CD15A900A17ED827D63F214FAF98 */ public class EcoreUtils { @@ -121,6 +121,32 @@ public class EcoreUtils { return ECollections.unmodifiableEList(result); } + /** + * From a given EList with source objects of type S create another + * unmodifiable EList that DOES NOT contain objects of the type given by the + * parameter targetClass. The resulting EList is unmodifiable thereby it + * represents only a view over the source list. + * + * @param targetClass + * - a class representing types of elements to be picked + * @param sourceList + * - an EList with objects of type S + * @return an unmodifiable EList of objects of type S containing only the + * targetClass instances + */ + public static <S> EList<S> filterOutInstanceOf(Class<?> targetClass, List<S> sourceList) { + if(sourceList == null) + return null; + EList<S> result = new BasicEList<S>(); + for(S sourceElement : sourceList) { + Class<?> sourceClass = sourceElement.getClass(); + if(!targetClass.isAssignableFrom(sourceClass)) { + result.add(sourceElement); + } + } + return ECollections.unmodifiableEList(result); + } + /** * From a given EList with source objects of type S pick the first object * with type T, whereby T is a sub-type of S.