From 2aefbd74e868038bdf0ca2bf3a85de1d74f80966 Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Mon, 2 May 2016 09:18:21 +0000 Subject: [PATCH] Tutorial is now opened as dummy element in navigator. refs 2567 --- .../trunk/plugin.xml | 9 +++ .../handler/TutorialDefinitionHandler.java | 73 +++++++++++++++++++ .../kernel/extension/ITutorialProvider.java | 11 ++- .../kernel/internal/DummyTopLevelElement.java | 3 + .../kernel/internal/PersistencyService.java | 5 +- .../kernel/internal/TutorialService.java | 5 ++ 6 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/handler/TutorialDefinitionHandler.java diff --git a/org.fortiss.tooling.kernel.ui/trunk/plugin.xml b/org.fortiss.tooling.kernel.ui/trunk/plugin.xml index 5e4aaeb17..d461fe82f 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/plugin.xml +++ b/org.fortiss.tooling.kernel.ui/trunk/plugin.xml @@ -150,5 +150,14 @@ provider="org.fortiss.tooling.kernel.ui.internal.ConstraintVerificationUIService"> </storagePostLoadProvider> </extension> + <extension + point="org.fortiss.tooling.kernel.ui.modelElementHandler"> + <modelElementHandler + handler="org.fortiss.tooling.kernel.ui.internal.handler.TutorialDefinitionHandler"> + <modelElementClass + modelElementClass="org.fortiss.tooling.kernel.model.tutorial.TutorialDefinition"> + </modelElementClass> + </modelElementHandler> + </extension> </plugin> diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/handler/TutorialDefinitionHandler.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/handler/TutorialDefinitionHandler.java new file mode 100644 index 000000000..5933408ae --- /dev/null +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/handler/TutorialDefinitionHandler.java @@ -0,0 +1,73 @@ +/*--------------------------------------------------------------------------+ +$Id: DataDictionaryHandler.java 11307 2014-08-04 13:32:46Z teufl $ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.ui.internal.handler; + +import static org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator.getImageDescriptor; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.resource.ImageDescriptor; +import org.fortiss.tooling.kernel.model.tutorial.TutorialDefinition; +import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; +import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase; + +/** + * {@link IModelElementHandler} for {@link TutorialDefinition}. + * + * @author eder + * @author $Author: teufl $ + * @version $Rev: 11307 $ + * @ConQAT.Rating GREEN Hash: FCF4A8026124D391128E28129C698161 + */ +public final class TutorialDefinitionHandler extends ModelElementHandlerBase<TutorialDefinition> { + + /** Navigator view height. */ + private static final int NAVIGATOR_VIEW_HEIGHT = 0; + + /** {@inheritDoc} */ + @Override + public String getName(TutorialDefinition element) { + return element.getName(); + } + + /** {@inheritDoc} */ + @Override + public String getDescription(TutorialDefinition element) { + return element.getComment(); + } + + /** {@inheritDoc} */ + @Override + public ImageDescriptor getIconImageDescriptor() { + return getImageDescriptor("icons/tutorial.gif"); + } + + /** {@inheritDoc} */ + @Override + public int getNavigatorViewWeight(TutorialDefinition element) { + return NAVIGATOR_VIEW_HEIGHT; + } + + /** {@inheritDoc} */ + @Override + public List<EObject> getSubnodes(TutorialDefinition element) { + return Collections.emptyList(); + } +} diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/ITutorialProvider.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/ITutorialProvider.java index a42a761ef..f04beac90 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/ITutorialProvider.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/ITutorialProvider.java @@ -17,9 +17,8 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.extension; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; +import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.extension.data.TutorialStep; -import org.fortiss.tooling.kernel.model.tutorial.TutorialDefinition; /** * A tutorial provider provides all data about a single tutorial to the kernel infrastructure. @@ -30,11 +29,11 @@ import org.fortiss.tooling.kernel.model.tutorial.TutorialDefinition; * @ConQAT.Rating RED Hash: */ public interface ITutorialProvider { - /** Returns the top-level element of this tutorial. */ - public ITopLevelElement getTopLevelElement(); + /** Returns the description of the tutorial. */ + public String getDescription(); - /** Returns the tutorial definition element. */ - public TutorialDefinition getTutorialDefinition(); + /** Returns the root element of this tutorial. */ + public EObject getRootElement(); /** Returns the initial step of this tutorial. */ public TutorialStep getInitialStep(); diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/DummyTopLevelElement.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/DummyTopLevelElement.java index 5d345d24d..d142bcc9f 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/DummyTopLevelElement.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/DummyTopLevelElement.java @@ -129,6 +129,9 @@ final class DummyTopLevelElement implements ITopLevelElement { /** {@inheritDoc} */ @Override public String getId(EObject modelElement) { + if(modelElement instanceof IIdLabeled) { + return String.valueOf(((IIdLabeled)modelElement).getId()); + } return null; } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PersistencyService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PersistencyService.java index 8d30706a2..212f776b0 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PersistencyService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PersistencyService.java @@ -279,6 +279,7 @@ public class PersistencyService implements IPersistencyService, IIntrospectiveKe DummyTopLevelElement dummy = new DummyTopLevelElement(dummyRoot); dummyCache.put(dummyRoot, dummy); elementCache.add(dummy); + notifyListenersAboutAdd(dummy); return dummy; } @@ -288,8 +289,10 @@ public class PersistencyService implements IPersistencyService, IIntrospectiveKe if(dummyCache == null || !dummyCache.containsKey(dummy)) { return; } - elementCache.remove(dummyCache.get(dummy)); + ITopLevelElement top = dummyCache.get(dummy); + elementCache.remove(top); dummyCache.remove(dummy); + notifyListenersAboutRemove(top); } /** {@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 8bf675b25..65f6b599f 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 @@ -26,6 +26,7 @@ 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.TutorialStep; +import org.fortiss.tooling.kernel.service.IPersistencyService; import org.fortiss.tooling.kernel.service.ITutorialService; /** @@ -83,6 +84,10 @@ public final class TutorialService implements ITutorialService, ITutorialWhiteli public void startTutorial(ITutorialProvider provider) { activeTutorial = provider; activeStep = activeTutorial.getInitialStep(); + + IPersistencyService.INSTANCE.addDummyEObjectAsTopLevelElement(activeTutorial + .getRootElement()); + System.out.println("start tutorial for provider: " + activeTutorial.getClass().getName()); } /** {@inheritDoc} */ -- GitLab