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 0000000000000000000000000000000000000000..c49969c14e669f677d8dbf911917add92eb80549 --- /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 0000000000000000000000000000000000000000..bc588c5f296ecc145f6001eecf9e49e08f1a05a6 --- /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 0000000000000000000000000000000000000000..08c93d13cd49389dcd093e8e2458f588a9c5ac2e --- /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 0000000000000000000000000000000000000000..08c2c41cfd63b175e82f68c7b84ba9eac2059403 --- /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 b5ac2cb615c040db98ec21f56b85f3010abbbc6f..bfe483d18d19101bf34f7dc6945623285dd68794 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 16f4eaa65331942b6b729eef7469b0bdace5fa9c..8e57fd551a854ee88aa1ebf7632b26ea5e8541c7 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 0000000000000000000000000000000000000000..b95070abc179bc90a7a1a9bdcb850d1d31b8d1f7 --- /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); +}