Skip to content
Snippets Groups Projects
Commit 1477611b authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Added first tutorial for data dictionary.

refs 2567
parent a72803ef
No related branches found
No related tags found
No related merge requests found
Showing with 164 additions and 41 deletions
......@@ -165,17 +165,6 @@
nsPrefix="org-fortiss-tooling-kernel-tutorial">
<eClassifiers xsi:type="ecore:EClass" name="TutorialDefinition">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="globalWhitelistProviderClassName"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="steps" lowerBound="1"
upperBound="-1" eType="#//tutorial/TutorialStep" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="TutorialStep">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="whitelistProviderClassName"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="completionCheckerClassName"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</eSubpackages>
</ecore:EPackage>
......@@ -83,13 +83,6 @@
disposableProviderFactory="true" ecorePackage="kernel.ecore#//tutorial">
<genClasses ecoreClass="kernel.ecore#//tutorial/TutorialDefinition">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute kernel.ecore#//tutorial/TutorialDefinition/title"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute kernel.ecore#//tutorial/TutorialDefinition/globalWhitelistProviderClassName"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference kernel.ecore#//tutorial/TutorialDefinition/steps"/>
</genClasses>
<genClasses ecoreClass="kernel.ecore#//tutorial/TutorialStep">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute kernel.ecore#//tutorial/TutorialStep/whitelistProviderClassName"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute kernel.ecore#//tutorial/TutorialStep/completionCheckerClassName"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute kernel.ecore#//tutorial/TutorialStep/description"/>
</genClasses>
</nestedGenPackages>
</genPackages>
......
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2016 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.extension;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
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.
*
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public interface ITutorialProvider {
/** Returns the top-level element of this tutorial. */
public ITopLevelElement getTopLevelElement();
/** Returns the tutorial definition element. */
public TutorialDefinition getTutorialDefinition();
/** Returns the initial step of this tutorial. */
public TutorialStep getInitialStep();
/** Returns the next tutorial step for the given step. */
public TutorialStep getNextStep(TutorialStep step);
/** Returns the global whitelist provider. */
public ITutorialWhitelistProvider getGlobalWhitelistProvider();
}
......@@ -17,6 +17,8 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.extension;
import org.eclipse.emf.ecore.EObject;
/**
* Instances of this interface provide white lists for tool functions
* globally enabled in tutorial or locally enabled in a tutorial step.
......@@ -27,5 +29,8 @@ package org.fortiss.tooling.kernel.extension;
* @ConQAT.Rating RED Hash:
*/
public interface ITutorialWhitelistProvider {
// TODO: define
/** Returns whether the given element should be displayed in the navigator tree. */
public boolean displayElementInNavigator(EObject element);
// TODO: define other methods
}
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2016 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.extension.data;
import org.fortiss.tooling.kernel.extension.ITutorialWhitelistProvider;
/**
* Data class for steps of tutorials.
*
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public abstract class TutorialStep {
/** Returns the step-specific whitelist provider. */
public ITutorialWhitelistProvider getWhitelistProvider() {
return null;
}
}
......@@ -22,8 +22,10 @@ import java.util.Collection;
import java.util.List;
import org.conqat.lib.commons.collections.UnmodifiableList;
import org.fortiss.tooling.kernel.model.tutorial.TutorialDefinition;
import org.fortiss.tooling.kernel.model.tutorial.TutorialStep;
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.ITutorialService;
/**
......@@ -34,13 +36,13 @@ import org.fortiss.tooling.kernel.service.ITutorialService;
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public final class TutorialService implements ITutorialService {
public final class TutorialService implements ITutorialService, ITutorialWhitelistProvider {
/** The collection of all defined tutorials. */
private List<TutorialDefinition> allTutorials = new ArrayList<>();
private List<ITutorialProvider> allTutorials = new ArrayList<>();
/** The active tutorial. */
private TutorialDefinition activeTutorial = null;
private ITutorialProvider activeTutorial = null;
/** The active tutorial step. */
private TutorialStep activeStep = null;
......@@ -52,7 +54,7 @@ public final class TutorialService implements ITutorialService {
/** {@inheritDoc} */
@Override
public TutorialDefinition getActiveTutorial() {
public ITutorialProvider getActiveTutorial() {
return activeTutorial;
}
......@@ -64,24 +66,23 @@ public final class TutorialService implements ITutorialService {
/** {@inheritDoc} */
@Override
public Collection<TutorialDefinition> getAllTutorials() {
public Collection<ITutorialProvider> getAllTutorialProviders() {
return new UnmodifiableList<>(allTutorials);
}
/** {@inheritDoc} */
@Override
public void registerTutorial(TutorialDefinition definition) {
if(!allTutorials.contains(definition)) {
allTutorials.add(definition);
public void registerTutorial(ITutorialProvider provider) {
if(!allTutorials.contains(provider)) {
allTutorials.add(provider);
}
}
/** {@inheritDoc} */
@Override
public void startTutorial(TutorialDefinition definition) {
activeTutorial = definition;
// steps relation is 1..* => get(0) always works
activeStep = activeTutorial.getSteps().get(0);
public void startTutorial(ITutorialProvider provider) {
activeTutorial = provider;
activeStep = activeTutorial.getInitialStep();
}
/** {@inheritDoc} */
......@@ -90,4 +91,18 @@ public final class TutorialService implements ITutorialService {
activeStep = null;
activeTutorial = null;
}
/** {@inheritDoc} */
@Override
public boolean displayElementInNavigator(EObject element) {
if(activeTutorial == null || activeStep == null) {
return false;
}
ITutorialWhitelistProvider global = activeTutorial.getGlobalWhitelistProvider();
if(global != null && global.displayElementInNavigator(element)) {
return true;
}
ITutorialWhitelistProvider local = activeStep.getWhitelistProvider();
return local != null && local.displayElementInNavigator(element);
}
}
......@@ -19,9 +19,9 @@ package org.fortiss.tooling.kernel.service;
import java.util.Collection;
import org.fortiss.tooling.kernel.extension.ITutorialProvider;
import org.fortiss.tooling.kernel.extension.data.TutorialStep;
import org.fortiss.tooling.kernel.internal.TutorialService;
import org.fortiss.tooling.kernel.model.tutorial.TutorialDefinition;
import org.fortiss.tooling.kernel.model.tutorial.TutorialStep;
/**
* The tutorial service provides pre-defined models with step-wise
......@@ -41,10 +41,10 @@ public interface ITutorialService {
public boolean isTutorialActive();
/** Returns the current tutorial definition or <code>null</code> if no tutorial is active. */
public TutorialDefinition getActiveTutorial();
public ITutorialProvider getActiveTutorial();
/** Starts the given tutorial. */
public void startTutorial(TutorialDefinition definition);
public void startTutorial(ITutorialProvider provider);
/** Stops the current tutorial. */
public void stopTutorial();
......@@ -52,9 +52,9 @@ public interface ITutorialService {
/** Returns the active tutorial step. */
public TutorialStep getActiveTutorialStep();
/** Returns all registered tutorial definitions. */
public Collection<TutorialDefinition> getAllTutorials();
/** Returns all registered tutorial providers. */
public Collection<ITutorialProvider> getAllTutorialProviders();
/** Programmatically register a tutorial. */
public void registerTutorial(TutorialDefinition definition);
/** Programmatically register a tutorial provider. */
public void registerTutorial(ITutorialProvider provider);
}
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2016 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.utils;
import org.fortiss.tooling.kernel.model.tutorial.TutorialDefinition;
import org.fortiss.tooling.kernel.model.tutorial.TutorialFactory;
/**
* Model element factory class for creating tutorial elements.
*
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 02F9DA7746CF3596881BF3775CE80BAB
*/
public final class TutorialModelElementFactory {
/** Creates a {@link TutorialDefinition}. */
public static TutorialDefinition createTutorialDefinition(String title) {
TutorialDefinition def = TutorialFactory.eINSTANCE.createTutorialDefinition();
def.setTitle(title);
return def;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment