diff options
author | Juergen Haug | 2015-06-30 18:10:22 +0000 |
---|---|---|
committer | Juergen Haug | 2015-06-30 18:11:15 +0000 |
commit | f7439c472f9d6a309af4a2a6d6628a21a2ad8b76 (patch) | |
tree | dd1bdcf2517f96be31b86ee2c38ac35053ff99f6 /plugins/org.eclipse.etrice.ui.common.base | |
parent | 1a6ebb9dab8f1e99bbaa72434deca2a6267538b5 (diff) | |
download | org.eclipse.etrice-f7439c472f9d6a309af4a2a6d6628a21a2ad8b76.tar.gz org.eclipse.etrice-f7439c472f9d6a309af4a2a6d6628a21a2ad8b76.tar.xz org.eclipse.etrice-f7439c472f9d6a309af4a2a6d6628a21a2ad8b76.zip |
[doc] added context help + prepared hover help + more reference content
Change-Id: I7a4c2cd8e95a8ddf8a0a6487b31ce544495e469b
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.common.base')
7 files changed, 245 insertions, 19 deletions
diff --git a/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF index ee88ad9bb..02f52e277 100644 --- a/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Bundle-Activator: org.eclipse.etrice.ui.common.base.UIBaseActivator Bundle-Vendor: eTrice (Incubation) Require-Bundle: org.eclipse.etrice.core.common.ui;bundle-version="0.5.0", org.eclipse.etrice.core.fsm.ui;bundle-version="0.5.0", + org.eclipse.etrice.doc;bundle-version="0.5.0", org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.emf.transaction;bundle-version="1.4.0", @@ -22,7 +23,8 @@ Require-Bundle: org.eclipse.etrice.core.common.ui;bundle-version="0.5.0", org.eclipse.ui.forms;bundle-version="3.6.1", org.eclipse.emf.workspace;bundle-version="1.5.0", org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.100", - org.eclipse.ui.ide;bundle-version="3.9.2" + org.eclipse.ui.ide;bundle-version="3.9.2", + org.eclipse.help Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Import-Package: org.apache.log4j diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/BaseImageProvider.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/BaseImageProvider.java new file mode 100644 index 000000000..096bd17cc --- /dev/null +++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/BaseImageProvider.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2015 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Juergen Haug (initial contribution) + * + *******************************************************************************/ + +package org.eclipse.etrice.ui.common.base; +import org.eclipse.graphiti.ui.platform.AbstractImageProvider; + + +public class BaseImageProvider extends AbstractImageProvider { + + // The prefix for all identifiers of this image provider + private static final String PREFIX = "org.eclipse.etrice.ui.common.base."; + + // The image identifier for an EReference. + public static final String IMG_HELP = PREFIX + "help"; + + @Override + protected void addAvailableImages() { + addImageFilePath(IMG_HELP, "icons/Help.gif"); + } + +} diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/dialogs/AbstractPropertyDialog.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/dialogs/AbstractPropertyDialog.java index 429051358..350ca7bd6 100644 --- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/dialogs/AbstractPropertyDialog.java +++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/dialogs/AbstractPropertyDialog.java @@ -40,6 +40,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.etrice.doc.ContextHelpProvider; import org.eclipse.etrice.ui.common.base.UIBaseActivator; import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.dialogs.IDialogConstants; @@ -293,6 +294,12 @@ public abstract class AbstractPropertyDialog extends FormDialog { displayedValidationStatus = new GlobalStatus(IStatus.class); bindingContext.bindValue(WidgetProperties.text().observe(validationText), displayedValidationStatus); + + String featureId = getFeatureContextHelpId(); + if(ContextHelpProvider.isAvailable(featureId)){ + ContextHelpProvider.setHelp(body, featureId); + setHelpAvailable(true); + } } /* (non-Javadoc) @@ -670,4 +677,6 @@ public abstract class AbstractPropertyDialog extends FormDialog { text.setSelection(start, end); } } + + protected abstract String getFeatureContextHelpId(); } diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java index c820d0b92..fb1a184f8 100644 --- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java +++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java @@ -42,6 +42,7 @@ import org.eclipse.graphiti.ui.editor.DiagramBehavior; import org.eclipse.graphiti.ui.editor.DiagramEditor; import org.eclipse.graphiti.ui.editor.EditorInputAdapter; import org.eclipse.graphiti.ui.editor.IDiagramEditorInput; +import org.eclipse.help.IContextProvider; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.TrayDialog; import org.eclipse.swt.widgets.Composite; @@ -78,7 +79,7 @@ public abstract class DiagramEditorBase extends DiagramEditor implements IInputU private Object textEditorClass; private SaveOnFocusLostListener saveOnFocusListener; - + private SuperClassListener superClassListener; public DiagramEditorBase(Object textEditorClass) { @@ -265,24 +266,25 @@ public abstract class DiagramEditorBase extends DiagramEditor implements IInputU @Override public void createPartControl(Composite parent) { - super.createPartControl(parent); - - saveOnFocusListener = new SaveOnFocusLostListener(this); - getSite().getPage().addPartListener(saveOnFocusListener); - - superClassListener = new SuperClassListener(this, textEditorClass); - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(superClassListener); + super.createPartControl(parent); + + saveOnFocusListener = new SaveOnFocusLostListener(this); + getSite().getPage().addPartListener(saveOnFocusListener); + + superClassListener = new SuperClassListener(this, textEditorClass); + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(superClassListener); + + /* we have to save here whether changes have been done or not to get rid of the dirty state + * CAUTION: save in + * init(IEditorSite site, IEditorInput input) + * or + * setInput(IEditorInput input) + * did not work correctly + */ +// if (AutoUpdateFeature.isLastDoneChanges()) + doSave(new NullProgressMonitor()); - /* we have to save here whether changes have been done or not to get rid of the dirty state - * CAUTION: save in - * init(IEditorSite site, IEditorInput input) - * or - * setInput(IEditorInput input) - * did not work correctly - */ - // if (AutoUpdateFeature.isLastDoneChanges()) - doSave(new NullProgressMonitor()); - } + } /** * Check whether the given diagram editor manages a super class @@ -364,5 +366,14 @@ public abstract class DiagramEditorBase extends DiagramEditor implements IInputU public URI getInputUri() { return inputUri; } + + @Override + public Object getAdapter(@SuppressWarnings("rawtypes") Class key) { + if (key.equals(IContextProvider.class)) { + return new SelectedModelHelpProvider(getDiagramBehavior()); + } + return super.getAdapter(key); + + } } diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/SelectedModelHelpProvider.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/SelectedModelHelpProvider.java new file mode 100644 index 000000000..5ac171f9d --- /dev/null +++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/SelectedModelHelpProvider.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2015 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Juergen Haug (initial contribution) + * + *******************************************************************************/ + +package org.eclipse.etrice.ui.common.base.editor; + +import org.eclipse.etrice.doc.ContextHelpProvider; +import org.eclipse.etrice.ui.common.base.support.HelpFeature; +import org.eclipse.graphiti.features.context.ICustomContext; +import org.eclipse.graphiti.features.context.impl.CustomContext; +import org.eclipse.graphiti.ui.editor.DiagramBehavior; +import org.eclipse.help.HelpSystem; +import org.eclipse.help.IContext; +import org.eclipse.help.IContextProvider; + +public class SelectedModelHelpProvider implements IContextProvider { + + private DiagramBehavior diagramBehavior; + + public SelectedModelHelpProvider(DiagramBehavior diagramBehavior) { + this.diagramBehavior = diagramBehavior; + } + + @Override + public int getContextChangeMask() { + return SELECTION; + } + + @Override + public IContext getContext(Object target) { + HelpFeature help = new HelpFeature(diagramBehavior.getDiagramTypeProvider().getFeatureProvider()); + ICustomContext context = new CustomContext(diagramBehavior.getSelectedPictogramElements()); + String featureId = help.getFeatureId(context); + if (featureId != null) + return HelpSystem.getContext(ContextHelpProvider.getContextId(featureId)); + + return null; + } + + @Override + public String getSearchExpression(Object target) { + return null; + } + +} diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/BaseToolBehaviorProvider.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/BaseToolBehaviorProvider.java new file mode 100644 index 000000000..1711179df --- /dev/null +++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/BaseToolBehaviorProvider.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2015 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Juergen Haug (initial contribution) + * + *******************************************************************************/ + +package org.eclipse.etrice.ui.common.base.support; + +import org.eclipse.graphiti.dt.IDiagramTypeProvider; +import org.eclipse.graphiti.features.context.IPictogramElementContext; +import org.eclipse.graphiti.features.context.impl.CustomContext; +import org.eclipse.graphiti.mm.pictograms.PictogramElement; +import org.eclipse.graphiti.tb.ContextButtonEntry; +import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider; +import org.eclipse.graphiti.tb.IContextButtonPadData; + +public class BaseToolBehaviorProvider extends DefaultToolBehaviorProvider { + + public BaseToolBehaviorProvider(IDiagramTypeProvider diagramTypeProvider) { + super(diagramTypeProvider); + } + + @Override + public IContextButtonPadData getContextButtonPad(IPictogramElementContext context) { + IContextButtonPadData data = super.getContextButtonPad(context); + + ContextButtonEntry help = new ContextButtonEntry(new HelpFeature(getFeatureProvider()), new CustomContext( + new PictogramElement[] { context.getPictogramElement() })); + data.getGenericContextButtons().add(help); + + return data; + } + +} diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/HelpFeature.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/HelpFeature.java new file mode 100644 index 000000000..fb3db9df6 --- /dev/null +++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/HelpFeature.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2015 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Juergen Haug (initial contribution) + * + *******************************************************************************/ + +package org.eclipse.etrice.ui.common.base.support; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.etrice.doc.ContextHelpProvider; +import org.eclipse.etrice.ui.common.base.BaseImageProvider; +import org.eclipse.graphiti.features.IFeatureProvider; +import org.eclipse.graphiti.features.context.ICustomContext; +import org.eclipse.graphiti.features.custom.AbstractCustomFeature; +import org.eclipse.graphiti.mm.pictograms.PictogramElement; + +public class HelpFeature extends AbstractCustomFeature { + + public HelpFeature(IFeatureProvider fp) { + super(fp); + } + + protected String getBoClassName(PictogramElement pe) { + Object bo = getBusinessObjectForPictogramElement(pe); + if (bo instanceof EObject) + return ((EObject) bo).eClass().getName(); + + return null; + } + + public String getFeatureId(ICustomContext context) { + if (context instanceof ICustomContext) { + ICustomContext peContext = (ICustomContext) context; + if (peContext.getPictogramElements() != null && peContext.getPictogramElements().length == 1) + return getBoClassName(peContext.getPictogramElements()[0]); + } + + return null; + } + + @Override + public boolean canExecute(ICustomContext context) { + String featureId = getFeatureId(context); + if (featureId != null) + return ContextHelpProvider.isAvailable(featureId); + + return false; + } + + @Override + public void execute(ICustomContext context) { + ContextHelpProvider.showHelp(getBoClassName(((ICustomContext) context).getPictogramElements()[0])); + } + + @Override + public String getName() { + return "Help"; + } + + @Override + public String getDescription() { + return "Open help view"; + } + + @Override + public String getImageId() { + return BaseImageProvider.IMG_HELP; + } + + @Override + public boolean hasDoneChanges() { + return false; + } + +} |