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

Fixed bug with context menu contributions during tutorial and added support for element hiding.

refs 2567
parent 77042f2e
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ package org.fortiss.tooling.kernel.ui.extension.data;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.kernel.extension.data.TutorialAtomicStep;
import org.fortiss.tooling.kernel.ui.extension.ITutorialStepUI;
import org.fortiss.tooling.kernel.ui.internal.editor.TutorialStepUIDefaultGUI;
/**
......@@ -30,7 +31,7 @@ import org.fortiss.tooling.kernel.ui.internal.editor.TutorialStepUIDefaultGUI;
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public abstract class TutorialStepUIAtomic extends TutorialAtomicStep {
public abstract class TutorialStepUIAtomic extends TutorialAtomicStep implements ITutorialStepUI {
/** Constructor. */
public TutorialStepUIAtomic(String title) {
super(title);
......@@ -41,18 +42,14 @@ public abstract class TutorialStepUIAtomic extends TutorialAtomicStep {
super(title, description);
}
/**
* Returns the short title for this tutorial step. Sub-classes may override. The default is
* equal to {@link #getTitle()}.
*/
/** {@inheritDoc} */
@Override
public String getShortTitle() {
return getTitle();
}
/**
* Creates the composite to be shown in the editor for the given tutorial step. Sub-classes may
* override. The default shows the tutorial step title.
*/
/** {@inheritDoc} */
@Override
public void createDetailsComposite(Composite parent) {
TutorialStepUIDefaultGUI gui = new TutorialStepUIDefaultGUI(parent, SWT.NONE);
gui.getTitleDisplayLabel().setText(getTitle());
......
......@@ -19,10 +19,9 @@ package org.fortiss.tooling.kernel.ui.extension.data;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.kernel.extension.data.TutorialStepBase;
import org.fortiss.tooling.kernel.extension.data.TutorialCompositeStep;
import org.fortiss.tooling.kernel.ui.extension.ITutorialUIWhitelistProvider;
import org.fortiss.tooling.kernel.ui.extension.base.TutorialUIBlacklistAllProvider;
import org.fortiss.tooling.kernel.extension.data.TutorialStepBase;
import org.fortiss.tooling.kernel.ui.extension.ITutorialStepUI;
import org.fortiss.tooling.kernel.ui.internal.editor.TutorialStepUIDefaultGUI;
/**
......@@ -33,7 +32,8 @@ import org.fortiss.tooling.kernel.ui.internal.editor.TutorialStepUIDefaultGUI;
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public abstract class TutorialStepUIComposite extends TutorialCompositeStep {
public abstract class TutorialStepUIComposite extends TutorialCompositeStep implements
ITutorialStepUI {
/** Constructor. */
public TutorialStepUIComposite(String title, TutorialStepBase firstStep) {
super(title, firstStep);
......@@ -44,26 +44,14 @@ public abstract class TutorialStepUIComposite extends TutorialCompositeStep {
super(title, description, firstStep);
}
/**
* Returns the short title for this tutorial step. Sub-classes may override. The default is
* equal to {@link #getTitle()}.
*/
/** {@inheritDoc} */
@Override
public String getShortTitle() {
return getTitle();
}
/**
* Returns the step-specific whitelist provider. The default returns a provider blacklisting
* everything.
*/
public ITutorialUIWhitelistProvider getLocalUIWhitelistProvider() {
return new TutorialUIBlacklistAllProvider();
}
/**
* Creates the composite to be shown in the editor for the given tutorial step. Sub-classes may
* override. The default shows the tutorial step title.
*/
/** {@inheritDoc} */
@Override
public void createDetailsComposite(Composite parent) {
TutorialStepUIDefaultGUI gui = new TutorialStepUIDefaultGUI(parent, SWT.NONE);
gui.getTitleDisplayLabel().setText(getTitle());
......
......@@ -123,7 +123,7 @@ public final class TutorialUIService implements ITutorialUIService, ITutorialUIW
while(step != null) {
if(step instanceof ITutorialUIWhitelistProvider) {
ITutorialUIWhitelistProvider p = (ITutorialUIWhitelistProvider)step;
if(p.globalDefaultActionsVisible()) {
if(p.contextMenuContributionVisible(element, contribution)) {
return true;
}
}
......
......@@ -18,20 +18,23 @@ $Id$
package org.fortiss.tooling.kernel.ui.internal.views;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.extension.data.TutorialStepBase;
import org.fortiss.tooling.kernel.extension.data.TutorialCompositeStep;
import org.fortiss.tooling.kernel.extension.data.TutorialStepBase;
import org.fortiss.tooling.kernel.model.ILibrary;
import org.fortiss.tooling.kernel.model.ILibraryElementReference;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.service.ITutorialService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import org.fortiss.tooling.kernel.ui.service.ITutorialUIService;
/**
* Content provider for the model navigator tree viewer.
......@@ -83,8 +86,10 @@ public class NavigatorTreeContentProvider extends TreeContentProviderBase {
IModelElementHandlerService.INSTANCE.getModelElementHandler(parentElement);
if(handler != null) {
List<EObject> children = new ArrayList<EObject>();
children.addAll(filterExpertElements(handler.getSubnodes(parentElement)));
children.addAll(filterExpertElements(handler.getSpecifications(parentElement)));
children.addAll(filterTutorialElements(filterExpertElements(handler
.getSubnodes(parentElement))));
children.addAll(filterTutorialElements(filterExpertElements(handler
.getSpecifications(parentElement))));
return children.toArray();
}
}
......@@ -94,6 +99,19 @@ public class NavigatorTreeContentProvider extends TreeContentProviderBase {
return new Object[0];
}
/**
* If {@link ITutorialService#isTutorialActive()} is <code>true</code> then we filter elements,
* which are not whitelisted.
*/
private Collection<? extends EObject> filterTutorialElements(List<EObject> elements) {
if(ITutorialService.INSTANCE.isTutorialActive()) {
ITutorialUIService uiService = ITutorialUIService.INSTANCE;
return elements.stream().filter(e -> !uiService.elementVisibleInNavigator(e))
.collect(Collectors.toList());
}
return elements;
}
/**
* If {@link #expertViewActive} is false then we filter out elements
* according to {@link IModelElementHandler#hiddenInNonExpertView()}
......
......@@ -180,21 +180,17 @@ public final class TutorialService implements ITutorialService, CommandStackList
/** {@inheritDoc} */
@Override
public boolean prototypeActive(Prototype prototype) {
return checkPrototypeActive(prototype, activeStep);
}
/** Recursively checks if the given prototype is active. */
private boolean checkPrototypeActive(Prototype prototype, TutorialStepBase curStep) {
if(curStep == null) {
return false;
}
if(curStep instanceof ITutorialWhitelistProvider) {
ITutorialWhitelistProvider p = (ITutorialWhitelistProvider)curStep;
if(p.prototypeActive(prototype)) {
return true;
TutorialStepBase curStep = activeStep;
while(curStep != null) {
if(curStep instanceof ITutorialWhitelistProvider) {
ITutorialWhitelistProvider p = (ITutorialWhitelistProvider)curStep;
if(p.prototypeActive(prototype)) {
return true;
}
}
curStep = curStep.getParent();
}
return checkPrototypeActive(prototype, curStep.getParent());
return false;
}
/** {@inheritDoc} */
......
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