Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF4
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/plugin.xml43
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/ControlModePlugin.java6
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusControlAction.java19
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusControlHandler.java81
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusUncontrolHandler.java81
6 files changed, 218 insertions, 16 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF
index 9c02ffe6f39..f83861e1cd3 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF
@@ -11,7 +11,9 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.services.resourceloading;bundle-version="0.9.0",
org.eclipse.papyrus.infra.services.resourceloading.preferences;bundle-version="0.9.0",
org.eclipse.core.resources;bundle-version="3.7.0",
- org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.4.0"
+ org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.4.0",
+ org.eclipse.core.expressions;bundle-version="3.4.400",
+ org.eclipse.papyrus.infra.emf;bundle-version="0.9.0"
Export-Package: org.eclipse.papyrus.infra.services.controlmode,
org.eclipse.papyrus.infra.services.controlmode.action,
org.eclipse.papyrus.infra.services.controlmode.commands,
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/plugin.xml
index 9f52620988a..ea5423704e1 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/plugin.xml
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/plugin.xml
@@ -3,13 +3,42 @@
<plugin>
<extension-point id="org.eclipse.papyrus.infra.services.controlmode.customControlCommand" name="customControlCommand" schema="schema/customControlCommand.exsd"/>
<extension
- point="org.eclipse.papyrus.views.modelexplorer.actionHandler">
- <customAction
- actionHandler="org.eclipse.papyrus.infra.services.controlmode.action.CollaborativeActionsFactory"
- actionId="org.eclipse.papyrus.controlmode.action.collaborativeActions"
- afterAction="org.eclipse.papyrus.views.modelexplorer.factory.defaultEMFActions"
- needSeparator="false">
- </customAction>
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.papyrus.infra.services.controlmode.action.PapyrusControlHandler"
+ id="org.eclipse.papyrus.infra.services.controlmode.control"
+ name="Control">
+ </command>
+ <command
+ defaultHandler="org.eclipse.papyrus.infra.services.controlmode.action.PapyrusUncontrolHandler"
+ id="org.eclipse.papyrus.infra.services.controlmode.uncontrol"
+ name="Uncontrol">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup">
+ <command
+ commandId="org.eclipse.papyrus.infra.services.controlmode.control"
+ label="Control"
+ style="push"
+ tooltip="Split the model into an external model">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.services.controlmode.uncontrol"
+ label="Uncontrol"
+ style="push"
+ tooltip="Merge the external model with the current model">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
</extension>
</plugin>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/ControlModePlugin.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/ControlModePlugin.java
index 4c313c2219a..c1f026716bc 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/ControlModePlugin.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/ControlModePlugin.java
@@ -13,6 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.services.controlmode;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -27,6 +28,8 @@ public class ControlModePlugin extends AbstractUIPlugin {
// The shared instance
private static ControlModePlugin plugin;
+ public static LogHelper log;
+
/**
* The constructor
*/
@@ -38,9 +41,11 @@ public class ControlModePlugin extends AbstractUIPlugin {
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
+ @Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ log = new LogHelper(this);
}
/*
@@ -48,6 +53,7 @@ public class ControlModePlugin extends AbstractUIPlugin {
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
+ @Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusControlAction.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusControlAction.java
index 699172edf95..ae0226e3071 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusControlAction.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusControlAction.java
@@ -46,6 +46,7 @@ import org.eclipse.papyrus.infra.core.resource.ModelUtils;
import org.eclipse.papyrus.infra.core.resource.notation.NotationModel;
import org.eclipse.papyrus.infra.core.resource.uml.UmlModel;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModePlugin;
import org.eclipse.papyrus.infra.services.controlmode.commands.ControlCommand;
import org.eclipse.papyrus.infra.services.controlmode.commands.IControlCondition;
import org.eclipse.papyrus.infra.widgets.toolbox.notification.NotificationRunnable;
@@ -70,7 +71,7 @@ public class PapyrusControlAction extends ControlAction {
private static final String CONTROL_CONDITION_ELEMENT_EXTENSION_POINT = "enableControlCommand";
/** custom commands from extensions */
- /*package*/ static List<IControlCondition> commands;
+ /* package */static List<IControlCondition> commands;
/**
* Instantiates a new papyrus control action.
@@ -134,7 +135,7 @@ public class PapyrusControlAction extends ControlAction {
if(selection.size() == 1) {
Object object = AdapterFactoryEditingDomain.unwrap(selection.getFirstElement());
if(object instanceof IAdaptable) {
- object = (EObject)((IAdaptable)object).getAdapter(EObject.class);
+ object = ((IAdaptable)object).getAdapter(EObject.class);
}
// Check whether the selected object is controllable
result = domain.isControllable(object);
@@ -164,8 +165,8 @@ public class PapyrusControlAction extends ControlAction {
NotificationBuilder.createAsyncPopup("You must perform control action from the resource:\n" + eObject.eResource().getURI().trimFileExtension().toString() + " for this element").setType(Type.INFO).run();
return;
}
-
- if (!getDiagram(eObject)) {
+
+ if(!getDiagram(eObject)) {
NotificationBuilder.createAsyncPopup("The selected package must contain a diagram to perform control action").setType(Type.INFO).run();
return;
}
@@ -177,8 +178,8 @@ public class PapyrusControlAction extends ControlAction {
try {
ControlCommand transactionalCommand = new ControlCommand(EditorUtils.getTransactionalEditingDomain(), controlledModel, eObject, "Control", null);
IStatus status = CheckedOperationHistory.getInstance().execute(transactionalCommand, new NullProgressMonitor(), null);
- if (status.isOK()) {
- notifySave();
+ if(status.isOK()) {
+ notifySave();
} else {
NotificationBuilder.createErrorPopup(status.getMessage()).setTitle("Unable to control").run();
}
@@ -188,15 +189,17 @@ public class PapyrusControlAction extends ControlAction {
}
}
}
-
+
/**
* Display asynchronous popup to inform user about the control action
*/
protected void notifySave() {
new NotificationBuilder().setMessage("Your element has been controlled.\nYou need to save your model to see modifications in your workspace.\nDo you want to save ?").addAction(new NotificationRunnable() {
+
public void run(IContext context) {
try {
Display.getDefault().syncExec(new Runnable() {
+
public void run() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
}
@@ -288,7 +291,7 @@ public class PapyrusControlAction extends ControlAction {
IControlCondition controlCondition = (IControlCondition)e.createExecutableExtension(CONTROL_CONDITION_ATTRIBUTE_EXTENSION_POINT);
commands.add(controlCondition);
} catch (CoreException exception) {
- exception.printStackTrace();
+ ControlModePlugin.log.error(exception);
}
}
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusControlHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusControlHandler.java
new file mode 100644
index 00000000000..7631670cded
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusControlHandler.java
@@ -0,0 +1,81 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.controlmode.action;
+
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.ui.ISources;
+
+
+/**
+ *
+ * @author Camille Letavernier
+ *
+ */
+//FIXME: Partial implementation to repair the Control/Uncontrol menu. Introduces several issues.
+public class PapyrusControlHandler extends AbstractHandler {
+
+ //FIXME: EditingDomain is leaked here. The handler isn't destroyed after the editor is closed.
+ PapyrusControlAction action;
+
+ public PapyrusControlHandler() {
+ setBaseEnabled(false);
+ }
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if(action != null) {
+ action.run();
+ }
+ return null;
+ }
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ if(evaluationContext instanceof IEvaluationContext) {
+ IEvaluationContext context = (IEvaluationContext)evaluationContext;
+ Object selection = context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
+ if(selection instanceof IStructuredSelection) {
+ IStructuredSelection currentSelection = (IStructuredSelection)selection;
+
+ EditingDomain domain = null;
+
+ Iterator<?> iterator = currentSelection.iterator();
+ while(iterator.hasNext()) {
+ domain = EMFHelper.resolveEditingDomain(iterator.next());
+ if(domain != null) {
+ break;
+ }
+ }
+
+ action = new PapyrusControlAction(domain);
+ action.updateSelection(currentSelection);
+ setBaseEnabled(action.isEnabled());
+ }
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ action = null;
+ }
+
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusUncontrolHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusUncontrolHandler.java
new file mode 100644
index 00000000000..9eca15ac68c
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/action/PapyrusUncontrolHandler.java
@@ -0,0 +1,81 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.controlmode.action;
+
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.ui.ISources;
+
+/**
+ *
+ * @author Camille Letavernier
+ *
+ */
+//FIXME: Partial implementation to repair the Control/Uncontrol menu. Introduces several issues.
+public class PapyrusUncontrolHandler extends AbstractHandler {
+
+ //FIXME: EditingDomain is leaked here. The handler isn't destroyed after the editor is closed.
+ PapyrusUncontrolAction action;
+
+ public PapyrusUncontrolHandler() {
+ setBaseEnabled(false);
+ }
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if(action != null) {
+ action.run();
+ }
+ return null;
+ }
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ if(evaluationContext instanceof IEvaluationContext) {
+ IEvaluationContext context = (IEvaluationContext)evaluationContext;
+ Object selection = context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
+ if(selection instanceof IStructuredSelection) {
+ IStructuredSelection currentSelection = (IStructuredSelection)selection;
+
+ EditingDomain domain = null;
+
+ Iterator<?> iterator = currentSelection.iterator();
+ while(iterator.hasNext()) {
+ domain = EMFHelper.resolveEditingDomain(iterator.next());
+ if(domain != null) {
+ break;
+ }
+ }
+
+ action = new PapyrusUncontrolAction(domain);
+ action.updateSelection(currentSelection);
+ setBaseEnabled(action.isEnabled());
+ }
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ System.out.println("Dispose");
+ super.dispose();
+ action = null;
+ }
+
+}

Back to the top