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

Default editor for TutorialSteps working properly.

refs 2567
parent 97df8f93
No related branches found
No related tags found
No related merge requests found
Showing
with 137 additions and 34 deletions
......@@ -17,6 +17,7 @@
name="Extendable Model Editor">
</editor>
<editor
class="org.fortiss.tooling.kernel.ui.internal.editor.TutorialStepUIEditor"
default="false"
id="org.fortiss.tooling.kernel.ui.internal.editor.TutorialStepUIEditor"
name="Tutorial Editor">
......
......@@ -17,7 +17,6 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.extension;
import org.fortiss.tooling.kernel.ui.extension.data.TutorialStepUI;
/**
* Interface UI parts of tutorial providers.
......@@ -32,10 +31,4 @@ public interface ITutorialUIProvider {
* Returns the global whitelist provider. This method MUST never return <code>null</code>.
*/
public ITutorialUIWhitelistProvider getGlobalUIWhitelistProvider();
/**
* Returns the local whitelist provider for the given step. This method MUST never return
* <code>null</code>.
*/
public ITutorialUIWhitelistProvider getLocalUIWhitelistProvider(TutorialStepUI step);
}
......@@ -17,10 +17,12 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
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.TutorialStep;
import org.fortiss.tooling.kernel.ui.extension.ITutorialUIWhitelistProvider;
import org.fortiss.tooling.kernel.ui.extension.base.TutorialUIBlacklistAllProvider;
import org.fortiss.tooling.kernel.ui.internal.editor.TutorialStepUIDefaultGUI;
/**
* Data class for UI parts of {@link TutorialStep}s.
......@@ -36,14 +38,34 @@ public abstract class TutorialStepUI extends TutorialStep {
super(title);
}
/** Constructor. */
public TutorialStepUI(String title, String description) {
super(title, description);
}
/**
* Returns the short title for this tutorial step. Sub-classes may override. The default is
* equal to {@link #getTitle()}.
*/
public String getShortTitle() {
return getTitle();
}
/**
* Returns the step-specific whitelist provider. The default returns a provider blacklisting
* everything.
*/
public ITutorialUIWhitelistProvider getUIWhitelistProvider() {
public ITutorialUIWhitelistProvider getLocalUIWhitelistProvider() {
return new TutorialUIBlacklistAllProvider();
}
/** Creates the composite to be shown in the editor for the given tutorial step. */
public abstract void createDetailsComposite(Composite parent);
/**
* 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.
*/
public void createDetailsComposite(Composite parent) {
TutorialStepUIDefaultGUI gui = new TutorialStepUIDefaultGUI(parent, SWT.NONE);
gui.getTitleDisplayLabel().setText(getTitle());
gui.getDescriptionDisplayText().setText(getDescription());
}
}
......@@ -35,6 +35,7 @@ import org.fortiss.tooling.kernel.service.ITutorialService;
import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator;
import org.fortiss.tooling.kernel.ui.extension.ITutorialUIProvider;
import org.fortiss.tooling.kernel.ui.extension.data.TutorialStepUI;
import org.fortiss.tooling.kernel.ui.internal.editor.TutorialStepUIEditor;
import org.fortiss.tooling.kernel.ui.internal.editor.TutorialStepUIEditorInput;
import org.fortiss.tooling.kernel.ui.service.ITutorialUIService;
......@@ -93,8 +94,8 @@ public final class TutorialUIService implements ITutorialUIService {
}
TutorialStep step = ITutorialService.INSTANCE.getActiveTutorialStep();
if(step instanceof TutorialStepUI) {
return p.getLocalUIWhitelistProvider((TutorialStepUI)step).elementVisibleInNavigator(
element);
TutorialStepUI uiStep = (TutorialStepUI)step;
return uiStep.getLocalUIWhitelistProvider().elementVisibleInNavigator(element);
}
return false;
}
......@@ -108,8 +109,8 @@ public final class TutorialUIService implements ITutorialUIService {
}
TutorialStep step = ITutorialService.INSTANCE.getActiveTutorialStep();
if(step instanceof TutorialStepUI) {
return p.getLocalUIWhitelistProvider((TutorialStepUI)step)
.globalDefaultActionsVisible();
TutorialStepUI uiStep = (TutorialStepUI)step;
return uiStep.getLocalUIWhitelistProvider().globalDefaultActionsVisible();
}
return false;
}
......@@ -123,8 +124,9 @@ public final class TutorialUIService implements ITutorialUIService {
}
TutorialStep step = ITutorialService.INSTANCE.getActiveTutorialStep();
if(step instanceof TutorialStepUI) {
return p.getLocalUIWhitelistProvider((TutorialStepUI)step)
.contextMenuContributionVisible(element, contribution);
TutorialStepUI uiStep = (TutorialStepUI)step;
return uiStep.getLocalUIWhitelistProvider().contextMenuContributionVisible(element,
contribution);
}
return false;
}
......@@ -139,8 +141,9 @@ public final class TutorialUIService implements ITutorialUIService {
}
TutorialStep step = ITutorialService.INSTANCE.getActiveTutorialStep();
if(step instanceof TutorialStepUI) {
return p.getLocalUIWhitelistProvider((TutorialStepUI)step)
.contextMenuContributionVisible(element, contribution);
TutorialStepUI uiStep = (TutorialStepUI)step;
return uiStep.getLocalUIWhitelistProvider().contextMenuContributionVisible(element,
contribution);
}
return false;
}
......@@ -148,20 +151,14 @@ public final class TutorialUIService implements ITutorialUIService {
/** {@inheritDoc} */
@Override
public void openInEditor(TutorialStepUI selected) {
// TODO: fix it
try {
IEditorInput input = new TutorialStepUIEditorInput(selected);
IEditorPart part =
PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage()
.openEditor(
input,
"org.fortiss.tooling.kernel.ui.internal.editor.TutorialStepUIEditor",
true);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.openEditor(input, TutorialStepUIEditor.class.getName(), true);
// TODO: go on HERE
} catch(PartInitException pex) {
error(ToolingKernelUIActivator.getDefault(), pex.getMessage(), pex);
}
}
}
/*--------------------------------------------------------------------------+
$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.editor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
* Default GUI for tutorial steps.
*
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public final class TutorialStepUIDefaultGUI extends Composite {
private Label lblDisplayttitle;
private Text txtDisplaydescription;
/** Constructor. */
public TutorialStepUIDefaultGUI(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(2, false));
Label lblTitle = new Label(this, SWT.NONE);
lblTitle.setText("Title:");
lblDisplayttitle = new Label(this, SWT.NONE);
lblDisplayttitle.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
Label lblDescription = new Label(this, SWT.NONE);
lblDescription.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
lblDescription.setText("Description:");
txtDisplaydescription =
new Text(this, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.CANCEL | SWT.MULTI);
txtDisplaydescription.setEnabled(false);
txtDisplaydescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
}
public Label getTitleDisplayLabel() {
return lblDisplayttitle;
}
public Text getDescriptionDisplayText() {
return txtDisplaydescription;
}
}
......@@ -38,15 +38,23 @@ public final class TutorialStepUIEditor extends ReadonlyEditorBase {
/** {@inheritDoc} */
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
TutorialStepUI step = ((TutorialStepUIEditorInput)input).getStep();
if(input instanceof TutorialStepUIEditorInput) {
setSite(site);
setInput(input);
TutorialStepUI step = ((TutorialStepUIEditorInput)input).getStep();
setPartName(step.getShortTitle());
// TODO: go on HERE
} else {
throw new PartInitException(
"Tutorial step editor initialized with wrong editor input object.");
}
}
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
TutorialStepUI step = ((TutorialStepUIEditorInput)getEditorInput()).getStep();
step.createDetailsComposite(parent);
}
/** {@inheritDoc} */
......
......@@ -32,10 +32,18 @@ import org.fortiss.tooling.kernel.extension.base.TutorialBlacklistAllProvider;
public abstract class TutorialStep {
/** The title of the tutorial. */
private final String title;
/** The description of this tutorial step. */
private final String description;
/** Constructor. */
public TutorialStep(String title) {
public TutorialStep(String title, String description) {
this.title = title;
this.description = description;
}
/** Constructor. */
public TutorialStep(String title) {
this(title, "");
}
/** Returns the title of this tutorial step. */
......@@ -43,11 +51,16 @@ public abstract class TutorialStep {
return title;
}
/** Returns description. */
public String getDescription() {
return description;
}
/**
* Returns the step-specific whitelist provider. The default returns a provider blacklisting
* everything.
*/
public ITutorialWhitelistProvider getWhitelistProvider() {
public ITutorialWhitelistProvider getLocalWhitelistProvider() {
return new TutorialBlacklistAllProvider();
}
......
......@@ -138,7 +138,7 @@ public final class TutorialService implements ITutorialService, CommandStackList
@Override
public boolean prototypeActive(Prototype prototype) {
return activeTutorial.getGlobalWhitelistProvider().prototypeActive(prototype) ||
activeStep.getWhitelistProvider().prototypeActive(prototype);
activeStep.getLocalWhitelistProvider().prototypeActive(prototype);
}
/** {@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