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

Added tutorial UI service and did some refactoring on non-UI service interface.

refs 2567
parent 215a358d
No related branches found
No related tags found
No related merge requests found
/*--------------------------------------------------------------------------+
$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.ui.extension;
/**
* Interface UI parts of tutorial providers.
*
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public interface ITutorialUIProvider {
}
/*--------------------------------------------------------------------------+
$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.ui.extension;
/**
* Tutorial whitelist provider interface for the UI kernel services.
*
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public interface ITutorialUIWhitelistProvider {
}
/*--------------------------------------------------------------------------+
$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.ui.internal;
import org.fortiss.tooling.kernel.extension.ITutorialProvider;
import org.fortiss.tooling.kernel.ui.extension.ITutorialUIProvider;
import org.fortiss.tooling.kernel.ui.service.ITutorialUIService;
/**
* Implementation of {@link ITutorialUIService}.
*
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public final class TutorialUIService implements ITutorialUIService {
/** {@inheritDoc} */
@Override
public void registerTutorialProvider(Class<? extends ITutorialProvider> nonUIprovider,
Class<? extends ITutorialUIProvider> uiProvider) {
// TODO Auto-generated method stub
}
}
/*--------------------------------------------------------------------------+
$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.ui.service;
import org.fortiss.tooling.kernel.extension.ITutorialProvider;
import org.fortiss.tooling.kernel.service.ITutorialService;
import org.fortiss.tooling.kernel.ui.extension.ITutorialUIProvider;
import org.fortiss.tooling.kernel.ui.extension.ITutorialUIWhitelistProvider;
import org.fortiss.tooling.kernel.ui.internal.TutorialUIService;
/**
* Interface for the UI part of {@link ITutorialService}.
*
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public interface ITutorialUIService extends ITutorialUIWhitelistProvider {
/** Returns the singleton instance of the service. */
public static final ITutorialUIService INSTANCE = new TutorialUIService();
/** Programmatically register a tutorial provider. */
public void registerTutorialProvider(Class<? extends ITutorialProvider> nonUIprovider,
Class<? extends ITutorialUIProvider> uiProvider);
}
......@@ -17,7 +17,9 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
......@@ -28,6 +30,7 @@ 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;
import org.fortiss.tooling.kernel.service.listener.ITutorialServiceListener;
/**
* This class implements the {@link ITutorialService} interface.
......@@ -41,6 +44,9 @@ public final class TutorialService implements ITutorialService {
/** The collection of all defined tutorials. */
private Map<String, Class<? extends ITutorialProvider>> allTutorials = new HashMap<>();
/** The collection of listeners. */
private Collection<ITutorialServiceListener> listeners =
new LinkedList<ITutorialServiceListener>();
/** The active tutorial. */
private ITutorialProvider activeTutorial = null;
......@@ -73,18 +79,18 @@ public final class TutorialService implements ITutorialService {
/** {@inheritDoc} */
@Override
public void registerTutorial(String name, Class<? extends ITutorialProvider> provider) {
allTutorials.put(name, provider);
public void registerTutorialProvider(Class<? extends ITutorialProvider> provider) {
allTutorials.put(provider.getName(), provider);
}
/** {@inheritDoc} */
@Override
public void startTutorial(String name) {
if(!allTutorials.containsKey(name)) {
public void startTutorial(Class<? extends ITutorialProvider> provider) {
if(!allTutorials.containsKey(provider.getName())) {
return;
}
try {
activeTutorial = allTutorials.get(name).newInstance();
activeTutorial = allTutorials.get(provider.getName()).newInstance();
activeStep = activeTutorial.getInitialStep();
EObject root = activeTutorial.getRootElement();
IPersistencyService.INSTANCE.addDummyEObjectAsTopLevelElement(root);
......@@ -141,4 +147,18 @@ public final class TutorialService implements ITutorialService {
activeStep.getWhitelistProvider().contextMenuContributionVisible(element,
contribution);
}
/** {@inheritDoc} */
@Override
public void addTutorialServiceListener(ITutorialServiceListener l) {
if(!listeners.contains(l)) {
listeners.add(l);
}
}
/** {@inheritDoc} */
@Override
public void removeTutorialServiceListener(ITutorialServiceListener l) {
listeners.remove(l);
}
}
......@@ -23,6 +23,7 @@ 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;
import org.fortiss.tooling.kernel.service.listener.ITutorialServiceListener;
/**
* The tutorial service provides pre-defined models with step-wise
......@@ -50,7 +51,7 @@ public interface ITutorialService extends ITutorialWhitelistProvider {
public ITutorialProvider getActiveTutorial();
/** Starts the given tutorial. */
public void startTutorial(String name);
public void startTutorial(Class<? extends ITutorialProvider> provider);
/** Stops the current tutorial. */
public void stopTutorial();
......@@ -62,5 +63,11 @@ public interface ITutorialService extends ITutorialWhitelistProvider {
public Map<String, Class<? extends ITutorialProvider>> getAllTutorialProviders();
/** Programmatically register a tutorial provider. */
public void registerTutorial(String name, Class<? extends ITutorialProvider> provider);
public void registerTutorialProvider(Class<? extends ITutorialProvider> provider);
/** Adds a listener with this service. */
public void addTutorialServiceListener(ITutorialServiceListener l);
/** Removes a listener from this service. */
public void removeTutorialServiceListener(ITutorialServiceListener l);
}
/*--------------------------------------------------------------------------+
$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.service.listener;
import org.fortiss.tooling.kernel.extension.ITutorialProvider;
import org.fortiss.tooling.kernel.service.ITutorialService;
/**
* Listener interface for the {@link ITutorialService}.
*
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public interface ITutorialServiceListener {
/** Fired when the given tutorial is started. */
public void tutorialStarted(ITutorialProvider provider);
/** Fired when the given tutorial is stopped. */
public void tutorialStopped(ITutorialProvider provider);
}
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