diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorNewMenu.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorNewMenu.java index d123c9f3dada440b443df22a53f50b72ca8a04d0..a1ddee8c8f12a7957cb4e661387fdc4cf601a9c1 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorNewMenu.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorNewMenu.java @@ -27,6 +27,7 @@ import org.fortiss.tooling.kernel.extension.data.Prototype; import org.fortiss.tooling.kernel.service.ICommandStackService; import org.fortiss.tooling.kernel.service.IElementCompositorService; import org.fortiss.tooling.kernel.service.IPrototypeService; +import org.fortiss.tooling.kernel.service.ITutorialService; import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator; import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor; import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; @@ -134,6 +135,12 @@ public class NavigatorNewMenu implements IContextMenuContributor { * prototype can be added to it. */ public boolean prepare(EObject container, boolean expert) { + if(ITutorialService.INSTANCE.isTutorialActive()) { + if(!ITutorialService.INSTANCE.prototypeActive(prototype)) { + this.container = null; + return false; + } + } IModelElementHandler<EObject> handler = IModelElementHandlerService.INSTANCE.getModelElementHandler(prototype .getPrototype()); diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/ITutorialWhitelistProvider.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/ITutorialWhitelistProvider.java index 5778975b912412e40065e61c37f36dd59b2dbec9..86c03d00cb9b8bcac8607e51e18810096a4a3077 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/ITutorialWhitelistProvider.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/ITutorialWhitelistProvider.java @@ -18,6 +18,7 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ package org.fortiss.tooling.kernel.extension; import org.eclipse.emf.ecore.EObject; +import org.fortiss.tooling.kernel.extension.data.Prototype; /** * Instances of this interface provide white lists for tool functions @@ -30,7 +31,10 @@ import org.eclipse.emf.ecore.EObject; */ public interface ITutorialWhitelistProvider { /** Returns whether the given element should be displayed in the navigator tree. */ - public boolean displayElementInNavigator(EObject element); + public boolean elementVisibleInNavigator(EObject element); + + /** Returns whether the given prototype is active in this tutorial. */ + public boolean prototypeActive(Prototype prototype); // TODO: define other methods } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java index 4908a41648667f3e45a9f9fab580988de4149adf..8e7ee92e876886e14a479a76be8d6c48dadb3495 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java @@ -18,6 +18,7 @@ $Id$ package org.fortiss.tooling.kernel.internal; import static java.util.Collections.emptyList; +import static org.conqat.lib.commons.collections.CollectionUtils.asUnmodifiable; import static org.fortiss.tooling.kernel.utils.ExtensionPointUtils.getBundle; import static org.fortiss.tooling.kernel.utils.ExtensionPointUtils.getConfigurationElements; import static org.fortiss.tooling.kernel.utils.ExtensionPointUtils.loadClass; @@ -26,6 +27,7 @@ import static org.fortiss.tooling.kernel.utils.LoggingUtils.error; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import java.util.stream.Collectors; import org.conqat.lib.commons.collections.CollectionUtils; import org.conqat.lib.commons.collections.UnmodifiableList; @@ -42,6 +44,7 @@ import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService import org.fortiss.tooling.kernel.introspection.items.PrototypeServiceIntrospectionDetailsItem; import org.fortiss.tooling.kernel.service.IElementCompositorService; import org.fortiss.tooling.kernel.service.IPrototypeService; +import org.fortiss.tooling.kernel.service.ITutorialService; import org.osgi.framework.Bundle; /** @@ -106,17 +109,27 @@ public class PrototypeService implements IPrototypeService, IIntrospectiveKernel /** {@inheritDoc} */ @Override public UnmodifiableList<Prototype> getAllPrototypes() { - return getPrototypes(false); + if(ITutorialService.INSTANCE.isTutorialActive()) { + ITutorialService service = ITutorialService.INSTANCE; + return asUnmodifiable(getPrototypes(false).stream() + .filter(proto -> service.prototypeActive(proto)).collect(Collectors.toList())); + } + return asUnmodifiable(getPrototypes(false)); } /** {@inheritDoc} */ @Override public UnmodifiableList<Prototype> getPrimaryPrototypes() { - return getPrototypes(true); + if(ITutorialService.INSTANCE.isTutorialActive()) { + ITutorialService service = ITutorialService.INSTANCE; + return asUnmodifiable(getPrototypes(true).stream() + .filter(proto -> service.prototypeActive(proto)).collect(Collectors.toList())); + } + return asUnmodifiable(getPrototypes(true)); } /** Returns prototypes including or excluding non-primaries. */ - private UnmodifiableList<Prototype> getPrototypes(boolean primaryOnly) { + private List<Prototype> getPrototypes(boolean primaryOnly) { List<Prototype> result = new ArrayList<Prototype>(); for(IPrototypeProvider provider : prototypeProviderList) { for(Prototype p : provider.getPrototypes()) { @@ -125,7 +138,7 @@ public class PrototypeService implements IPrototypeService, IIntrospectiveKernel } } } - return CollectionUtils.asUnmodifiable(result); + return result; } /** {@inheritDoc} */ diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/TutorialService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/TutorialService.java index e05d70180b232861e6ec778fa61bc0c60d6fb488..75205aa616e6bd34453a46878d31368f80ddf41e 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/TutorialService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/TutorialService.java @@ -24,6 +24,7 @@ import org.conqat.lib.commons.collections.UnmodifiableMap; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.extension.ITutorialProvider; import org.fortiss.tooling.kernel.extension.ITutorialWhitelistProvider; +import org.fortiss.tooling.kernel.extension.data.Prototype; import org.fortiss.tooling.kernel.extension.data.TutorialStep; import org.fortiss.tooling.kernel.service.IPersistencyService; import org.fortiss.tooling.kernel.service.ITutorialService; @@ -36,7 +37,7 @@ import org.fortiss.tooling.kernel.service.ITutorialService; * @version $Rev: 18709 $ * @ConQAT.Rating RED Hash: */ -public final class TutorialService implements ITutorialService, ITutorialWhitelistProvider { +public final class TutorialService implements ITutorialService { /** The collection of all defined tutorials. */ private Map<String, Class<? extends ITutorialProvider>> allTutorials = new HashMap<>(); @@ -104,15 +105,29 @@ public final class TutorialService implements ITutorialService, ITutorialWhiteli /** {@inheritDoc} */ @Override - public boolean displayElementInNavigator(EObject element) { + public boolean elementVisibleInNavigator(EObject element) { if(activeTutorial == null || activeStep == null) { return false; } ITutorialWhitelistProvider global = activeTutorial.getGlobalWhitelistProvider(); - if(global != null && global.displayElementInNavigator(element)) { + if(global != null && global.elementVisibleInNavigator(element)) { return true; } ITutorialWhitelistProvider local = activeStep.getWhitelistProvider(); - return local != null && local.displayElementInNavigator(element); + return local != null && local.elementVisibleInNavigator(element); + } + + /** {@inheritDoc} */ + @Override + public boolean prototypeActive(Prototype prototype) { + if(activeTutorial == null || activeStep == null) { + return false; + } + ITutorialWhitelistProvider global = activeTutorial.getGlobalWhitelistProvider(); + if(global != null && global.prototypeActive(prototype)) { + return true; + } + ITutorialWhitelistProvider local = activeStep.getWhitelistProvider(); + return local != null && local.prototypeActive(prototype); } } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/ITutorialService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/ITutorialService.java index 744f3a78bb8a44e76d748c85703233b0c596ad44..52b5729c83800e863226616d8d7b59f262a8d5d1 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/ITutorialService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/ITutorialService.java @@ -20,6 +20,7 @@ package org.fortiss.tooling.kernel.service; import java.util.Map; import org.fortiss.tooling.kernel.extension.ITutorialProvider; +import org.fortiss.tooling.kernel.extension.ITutorialWhitelistProvider; import org.fortiss.tooling.kernel.extension.data.TutorialStep; import org.fortiss.tooling.kernel.internal.TutorialService; @@ -27,13 +28,17 @@ import org.fortiss.tooling.kernel.internal.TutorialService; * The tutorial service provides pre-defined models with step-wise * example procedures for implementing educational tutorials to * the end-user. + * <P> + * This interface extends {@link ITutorialWhitelistProvider}, which delegates its method calls to + * the current {@link ITutorialProvider}'s global whitelist provider and the current + * {@link TutorialStep}'s local whitelist provider. * * @author hoelzl * @author $Author: hoelzl $ * @version $Rev: 18709 $ * @ConQAT.Rating RED Hash: */ -public interface ITutorialService { +public interface ITutorialService extends ITutorialWhitelistProvider { /** Returns the singleton instance of the service. */ public static final ITutorialService INSTANCE = new TutorialService();