Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Bégaudeau2018-05-24 07:35:52 +0000
committerPierre-Charles David2018-05-25 13:59:11 +0000
commita9de3742c427de4cc28e434ea9f7a0852cacd8ee (patch)
tree60f8096a4b58fb4e11e4fd791356e3abab3f092d
parentceb11f758365ceb98b4b8fb816bdbfc8bd7bed48 (diff)
downloadorg.eclipse.sirius-a9de3742c427de4cc28e434ea9f7a0852cacd8ee.tar.gz
org.eclipse.sirius-a9de3742c427de4cc28e434ea9f7a0852cacd8ee.tar.xz
org.eclipse.sirius-a9de3742c427de4cc28e434ea9f7a0852cacd8ee.zip
[509735] Add a menu builder for the workflow
Bug: 509735 Change-Id: I204e1c2a97b1d40f4ca41fc87fa7c7e1482051da Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.editor.workflow/.classpath1
-rw-r--r--plugins/org.eclipse.sirius.editor.workflow/META-INF/MANIFEST.MF8
-rw-r--r--plugins/org.eclipse.sirius.editor.workflow/build.properties3
-rw-r--r--plugins/org.eclipse.sirius.editor.workflow/plugin.properties3
-rw-r--r--plugins/org.eclipse.sirius.editor.workflow/plugin.xml3
-rw-r--r--plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/Messages.java39
-rw-r--r--plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/SiriusEditorWorkflowPlugin.java69
-rw-r--r--plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/menu/WorkflowCreateChildAction.java68
-rw-r--r--plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/menu/WorkflowMenuBuilder.java81
9 files changed, 272 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.editor.workflow/.classpath b/plugins/org.eclipse.sirius.editor.workflow/.classpath
index 26e67d64ad..50aae142c5 100644
--- a/plugins/org.eclipse.sirius.editor.workflow/.classpath
+++ b/plugins/org.eclipse.sirius.editor.workflow/.classpath
@@ -3,5 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/org.eclipse.sirius.editor.workflow/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius.editor.workflow/META-INF/MANIFEST.MF
index 7b156cc8e4..5c86523cde 100644
--- a/plugins/org.eclipse.sirius.editor.workflow/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.sirius.editor.workflow/META-INF/MANIFEST.MF
@@ -17,13 +17,17 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.300",
org.eclipse.ui.workbench.texteditor;bundle-version="3.8.0",
org.eclipse.sirius.workflow.model;bundle-version="6.0.0",
- org.eclipse.sirius.ext.swt;bundle-version="6.0.0"
+ org.eclipse.sirius.ext.swt;bundle-version="6.0.0",
+ org.eclipse.sirius.ext.base;bundle-version="6.0.0"
Eclipse-LazyStart: true
Bundle-Localization: plugin
Automatic-Module-Name: org.eclipse.sirius.editor.workflow
-Export-Package: org.eclipse.sirius.workflow.model.editor.properties.filters.workflow.activitydescription;version="6.0.0",
+Export-Package: org.eclipse.sirius.editor.workflow.internal;version="6.0.0";x-internal:=true,
+ org.eclipse.sirius.editor.workflow.internal.menu;version="6.0.0";x-internal:=true,
+ org.eclipse.sirius.workflow.model.editor.properties.filters.workflow.activitydescription;version="6.0.0",
org.eclipse.sirius.workflow.model.editor.properties.filters.workflow.pagedescription;version="6.0.0",
org.eclipse.sirius.workflow.model.editor.properties.filters.workflow.sectiondescription;version="6.0.0",
org.eclipse.sirius.workflow.model.editor.properties.sections.workflow.activitydescription;version="6.0.0",
org.eclipse.sirius.workflow.model.editor.properties.sections.workflow.pagedescription;version="6.0.0",
org.eclipse.sirius.workflow.model.editor.properties.sections.workflow.sectiondescription;version="6.0.0"
+Bundle-Activator: org.eclipse.sirius.editor.workflow.internal.SiriusEditorWorkflowPlugin$Implementation
diff --git a/plugins/org.eclipse.sirius.editor.workflow/build.properties b/plugins/org.eclipse.sirius.editor.workflow/build.properties
index e92269895c..8471e5d7b2 100644
--- a/plugins/org.eclipse.sirius.editor.workflow/build.properties
+++ b/plugins/org.eclipse.sirius.editor.workflow/build.properties
@@ -9,7 +9,8 @@
# Obeo - initial API and implementation
# ====================================================================
-source.. = src-gen/
+source.. = src-gen/,\
+ src/
output.. = bin/
bin.includes = META-INF/,\
.,\
diff --git a/plugins/org.eclipse.sirius.editor.workflow/plugin.properties b/plugins/org.eclipse.sirius.editor.workflow/plugin.properties
index 918b4d22f2..305aba61e4 100644
--- a/plugins/org.eclipse.sirius.editor.workflow/plugin.properties
+++ b/plugins/org.eclipse.sirius.editor.workflow/plugin.properties
@@ -11,3 +11,6 @@
pluginName = Sirius Workflow Specification Editor
providerName = Eclipse Modeling Project
+
+WorkflowMenuBuilder_label=New Workflow
+WorkflowMenuBuilder_NewWorkflow_label= New Workflow \ No newline at end of file
diff --git a/plugins/org.eclipse.sirius.editor.workflow/plugin.xml b/plugins/org.eclipse.sirius.editor.workflow/plugin.xml
index c957ac2a89..d94dd90f7b 100644
--- a/plugins/org.eclipse.sirius.editor.workflow/plugin.xml
+++ b/plugins/org.eclipse.sirius.editor.workflow/plugin.xml
@@ -100,6 +100,9 @@
<contexts file="help/contexts.xml" plugin="org.eclipse.sirius.workflow">
</contexts>
</extension>
+ <extension point="org.eclipse.sirius.editor.menuBuilder">
+ <builder class="org.eclipse.sirius.editor.workflow.internal.menu.WorkflowMenuBuilder" />
+ </extension>
</plugin>
<!-- End of user code plugin.xml end specifics --> \ No newline at end of file
diff --git a/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/Messages.java b/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/Messages.java
new file mode 100644
index 0000000000..0c7384a8fb
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/Messages.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.editor.workflow.internal;
+
+import org.eclipse.sirius.ext.base.I18N;
+import org.eclipse.sirius.ext.base.I18N.TranslatableMessage;
+
+/**
+ * Helper class to obtains translated strings.
+ *
+ * @author sbegaudeau
+ */
+public final class Messages {
+
+ static {
+ I18N.initializeMessages(Messages.class, SiriusEditorWorkflowPlugin.INSTANCE);
+ }
+
+ // CHECKSTYLE:OFF
+ @TranslatableMessage
+ public static String WorkflowMenuBuilder_label;
+
+ @TranslatableMessage
+ public static String WorkflowMenuBuilder_NewWorkflow_label;
+
+ // CHECKSTYLE:ON
+
+ private Messages() {
+ // Prevents instantiation.
+ }
+}
diff --git a/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/SiriusEditorWorkflowPlugin.java b/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/SiriusEditorWorkflowPlugin.java
new file mode 100644
index 0000000000..ff805fd233
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/SiriusEditorWorkflowPlugin.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.editor.workflow.internal;
+
+import org.eclipse.emf.common.EMFPlugin;
+import org.eclipse.emf.common.ui.EclipseUIPlugin;
+import org.eclipse.emf.common.util.ResourceLocator;
+
+/**
+ * This is the central singleton for the SiriusEditorWorkflow edit plugin.
+ *
+ * @author sbegaudeau
+ */
+public final class SiriusEditorWorkflowPlugin extends EMFPlugin {
+ /**
+ * The plug-in ID.
+ */
+ public static final String PLUGIN_ID = "org.eclipse.sirius.editor.workflow"; //$NON-NLS-1$
+
+ /**
+ * Singleton instance.
+ */
+ public static final SiriusEditorWorkflowPlugin INSTANCE = new SiriusEditorWorkflowPlugin();
+
+ private static Implementation plugin;
+
+ /**
+ * Create the instance.
+ */
+ public SiriusEditorWorkflowPlugin() {
+ super(new ResourceLocator[0]);
+ }
+
+ @Override
+ public ResourceLocator getPluginResourceLocator() {
+ return plugin;
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ *
+ * @return the singleton instance.
+ */
+ public static Implementation getPlugin() {
+ return plugin;
+ }
+
+ /**
+ * The actual implementation of the Eclipse <b>Plugin</b>.
+ */
+ public static class Implementation extends EclipseUIPlugin {
+
+ /**
+ * Creates an instance.
+ */
+ public Implementation() {
+ plugin = this;
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/menu/WorkflowCreateChildAction.java b/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/menu/WorkflowCreateChildAction.java
new file mode 100644
index 0000000000..2aed77acb5
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/menu/WorkflowCreateChildAction.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.editor.workflow.internal.menu;
+
+import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * A {@link CreateChildAction} with a specific label and priority.
+ *
+ * @author sbegaudeau
+ */
+public class WorkflowCreateChildAction extends CreateChildAction {
+
+ /**
+ * The label.
+ */
+ private String label;
+
+ /**
+ * The priority.
+ */
+ private int priority;
+
+ /**
+ * The constructor.
+ *
+ * @param editorPart
+ * The editor part
+ * @param selection
+ * The selection
+ * @param commandParameter
+ * The command parameter
+ * @param label
+ * The label
+ * @param priority
+ * The priority
+ */
+ public WorkflowCreateChildAction(IEditorPart editorPart, ISelection selection, CommandParameter commandParameter, String label, int priority) {
+ super(editorPart, selection, commandParameter);
+ this.label = label;
+ this.priority = priority;
+ }
+
+ /**
+ * Returns the priority.
+ *
+ * @return The priority
+ */
+ public int getPriority() {
+ return this.priority;
+ }
+
+ @Override
+ public String getText() {
+ return this.label;
+ }
+}
diff --git a/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/menu/WorkflowMenuBuilder.java b/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/menu/WorkflowMenuBuilder.java
new file mode 100644
index 0000000000..9c939a9434
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.workflow/src/org/eclipse/sirius/editor/workflow/internal/menu/WorkflowMenuBuilder.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.editor.workflow.internal.menu;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Optional;
+
+import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.sirius.editor.tools.api.menu.AbstractMenuBuilder;
+import org.eclipse.sirius.editor.tools.api.menu.AbstractTypeRestrictingMenuBuilder;
+import org.eclipse.sirius.editor.workflow.internal.Messages;
+import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
+import org.eclipse.sirius.viewpoint.description.Group;
+import org.eclipse.sirius.workflow.WorkflowDescription;
+import org.eclipse.sirius.workflow.WorkflowPackage;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * Menu builder used to create a new workflow.
+ *
+ * @author sbegaudeau
+ */
+public class WorkflowMenuBuilder extends AbstractTypeRestrictingMenuBuilder {
+ /**
+ * The constructor.
+ */
+ public WorkflowMenuBuilder() {
+ this.addValidType(WorkflowPackage.Literals.WORKFLOW_DESCRIPTION);
+ }
+
+ @Override
+ public String getLabel() {
+ return Messages.WorkflowMenuBuilder_label;
+ }
+
+ @Override
+ public int getPriority() {
+ return AbstractMenuBuilder.EXTENSION;
+ }
+
+ @Override
+ public void update(Collection<?> newChildDescriptors, ISelection selection, IEditorPart editor) {
+ this.depopulate();
+ this.advancedChildActions = new ArrayList<>();
+
+ Optional<CommandParameter> optionalNewWorkflowCommandParameter = newChildDescriptors.stream().filter(CommandParameter.class::isInstance).map(CommandParameter.class::cast)
+ .filter(parameter -> DescriptionPackage.Literals.GROUP__EXTENSIONS.equals(parameter.getEStructuralFeature()) && parameter.getEValue() instanceof WorkflowDescription).findFirst();
+
+ if (selection instanceof IStructuredSelection && optionalNewWorkflowCommandParameter.isPresent()) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+
+ // Add the parameter to our descriptor to prevent its use somewhere
+ // else which would create another "New" menu with this entry
+ CommandParameter newWorkflowCommandParameter = optionalNewWorkflowCommandParameter.get();
+ descriptors.add(newWorkflowCommandParameter);
+
+ Optional<Group> optionalGroup = Arrays.stream(structuredSelection.toArray()).filter(Group.class::isInstance).map(Group.class::cast).findFirst();
+ optionalGroup.ifPresent(group -> {
+ newWorkflowCommandParameter.setOwner(group);
+
+ Collection<CreateChildAction> actions = new ArrayList<>();
+ actions.add(new WorkflowCreateChildAction(editor, structuredSelection, newWorkflowCommandParameter, Messages.WorkflowMenuBuilder_NewWorkflow_label, 1000));
+
+ this.advancedChildActions = actions;
+ });
+ }
+ }
+}

Back to the top