From aee069e3c8724f0bb4f918e1fd3cb57472277777 Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Tue, 3 May 2016 08:25:13 +0000 Subject: [PATCH] Added tutorial UI service and did some refactoring on non-UI service interface. refs 2567 --- .../ui/extension/ITutorialUIProvider.java | 30 ++++++++++++++ .../ITutorialUIWhitelistProvider.java | 30 ++++++++++++++ .../kernel/ui/internal/TutorialUIService.java | 40 ++++++++++++++++++ .../kernel/ui/service/ITutorialUIService.java | 41 +++++++++++++++++++ .../kernel/internal/TutorialService.java | 30 +++++++++++--- .../kernel/service/ITutorialService.java | 11 ++++- .../listener/ITutorialServiceListener.java | 38 +++++++++++++++++ 7 files changed, 213 insertions(+), 7 deletions(-) create mode 100644 org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/ITutorialUIProvider.java create mode 100644 org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/ITutorialUIWhitelistProvider.java create mode 100644 org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/TutorialUIService.java create mode 100644 org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/ITutorialUIService.java create mode 100644 org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/listener/ITutorialServiceListener.java diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/ITutorialUIProvider.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/ITutorialUIProvider.java new file mode 100644 index 000000000..c49969c14 --- /dev/null +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/ITutorialUIProvider.java @@ -0,0 +1,30 @@ +/*--------------------------------------------------------------------------+ +$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 { + +} diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/ITutorialUIWhitelistProvider.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/ITutorialUIWhitelistProvider.java new file mode 100644 index 000000000..bc588c5f2 --- /dev/null +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/ITutorialUIWhitelistProvider.java @@ -0,0 +1,30 @@ +/*--------------------------------------------------------------------------+ +$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 { + +} diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/TutorialUIService.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/TutorialUIService.java new file mode 100644 index 000000000..08c93d13c --- /dev/null +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/TutorialUIService.java @@ -0,0 +1,40 @@ +/*--------------------------------------------------------------------------+ +$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 + } +} diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/ITutorialUIService.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/ITutorialUIService.java new file mode 100644 index 000000000..08c2c41cf --- /dev/null +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/ITutorialUIService.java @@ -0,0 +1,41 @@ +/*--------------------------------------------------------------------------+ +$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); +} 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 b5ac2cb61..bfe483d18 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 @@ -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); + } } 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 16f4eaa65..8e57fd551 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 @@ -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); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/listener/ITutorialServiceListener.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/listener/ITutorialServiceListener.java new file mode 100644 index 000000000..b95070abc --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/listener/ITutorialServiceListener.java @@ -0,0 +1,38 @@ +/*--------------------------------------------------------------------------+ +$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); +} -- GitLab