Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-08-03 08:49:13 +0000
committercletavernie2012-08-03 08:49:13 +0000
commit12a0752d811b41eb7505c8ba7e4be2d439738f13 (patch)
treed81a63cb50728727c8fa75271a0ec0329d811666
parentc7805d263f81911fec2cbbd80c8d6d82d29d6ac1 (diff)
downloadorg.eclipse.papyrus-12a0752d811b41eb7505c8ba7e4be2d439738f13.tar.gz
org.eclipse.papyrus-12a0752d811b41eb7505c8ba7e4be2d439738f13.tar.xz
org.eclipse.papyrus-12a0752d811b41eb7505c8ba7e4be2d439738f13.zip
386545: [Control Mode] The Control/Uncontrol menus have disappeared in Papyrus - 0.9.0
https://bugs.eclipse.org/bugs/show_bug.cgi?id=386545
-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
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/schema/org.eclipse.papyrus.views.modelexplorer.actionHandler.exsd2
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/actionprovider/EditingDomainActionProvider.java88
8 files changed, 255 insertions, 69 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;
+ }
+
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/schema/org.eclipse.papyrus.views.modelexplorer.actionHandler.exsd b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/schema/org.eclipse.papyrus.views.modelexplorer.actionHandler.exsd
index 2aebf1ed109..4731b212198 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/schema/org.eclipse.papyrus.views.modelexplorer.actionHandler.exsd
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/schema/org.eclipse.papyrus.views.modelexplorer.actionHandler.exsd
@@ -67,7 +67,7 @@
implement the action handler factory to add your custom actions
</documentation>
<appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.navigator.factory.IActionHandlerFactory"/>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.views.modelexplorer.factory.IActionHandlerFactory"/>
</appinfo>
</annotation>
</attribute>
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/actionprovider/EditingDomainActionProvider.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/actionprovider/EditingDomainActionProvider.java
index c863df7a630..292a73a26e2 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/actionprovider/EditingDomainActionProvider.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/actionprovider/EditingDomainActionProvider.java
@@ -59,22 +59,17 @@ public class EditingDomainActionProvider extends AbstractSubmenuActionProvider {
this.activeViewPart = getCommonNavigator();
this.actionsFactoriesMap = new HashMap<IActionHandlerFactory, ActionProperties>();
- TransactionalEditingDomain editingDomain = EditorUtils
- .getTransactionalEditingDomain();
+ TransactionalEditingDomain editingDomain = EditorUtils.getTransactionalEditingDomain();
- IConfigurationElement[] registry = Platform.getExtensionRegistry()
- .getConfigurationElementsFor(ACTION_HANDLER_EXTENSION_POINT_ID);
- for (IConfigurationElement elt : registry) {
+ IConfigurationElement[] registry = Platform.getExtensionRegistry().getConfigurationElementsFor(ACTION_HANDLER_EXTENSION_POINT_ID);
+ for(IConfigurationElement elt : registry) {
try {
final String actionId = elt.getAttribute("actionId");
final String afterAction = elt.getAttribute("afterAction");
- boolean needSeparator = Boolean.valueOf(elt
- .getAttribute("needSeparator"));
- ActionProperties properties = new ActionProperties(actionId,
- afterAction, needSeparator);
+ boolean needSeparator = Boolean.valueOf(elt.getAttribute("needSeparator"));
+ ActionProperties properties = new ActionProperties(actionId, afterAction, needSeparator);
- IActionHandlerFactory factory = (IActionHandlerFactory) createExtension(
- elt, elt.getAttribute("actionHandler"));
+ IActionHandlerFactory factory = (IActionHandlerFactory)createExtension(elt, elt.getAttribute("actionHandler"));
// create registered actions
factory.createActions(editingDomain);
@@ -91,7 +86,7 @@ public class EditingDomainActionProvider extends AbstractSubmenuActionProvider {
@Override
public void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
- for (IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
+ for(IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
factory.fillActionBars(actionBars);
}
}
@@ -100,19 +95,17 @@ public class EditingDomainActionProvider extends AbstractSubmenuActionProvider {
* Load an instance of a class
*
* @param element
- * the extension point
+ * the extension point
* @param classAttribute
- * the name of the class to load
+ * the name of the class to load
* @return the loaded Class
* @throws Exception
- * if the class is not loaded
+ * if the class is not loaded
*/
@SuppressWarnings("rawtypes")
- private static Object createExtension(final IConfigurationElement element,
- final String classAttribute) throws Exception {
+ private static Object createExtension(final IConfigurationElement element, final String classAttribute) throws Exception {
try {
- Bundle extensionBundle = Platform.getBundle(element
- .getDeclaringExtension().getNamespaceIdentifier());
+ Bundle extensionBundle = Platform.getBundle(element.getDeclaringExtension().getNamespaceIdentifier());
Class clazz = extensionBundle.loadClass(classAttribute);
Object obj = clazz.newInstance();
return obj;
@@ -132,13 +125,12 @@ public class EditingDomainActionProvider extends AbstractSubmenuActionProvider {
List<IActionHandlerFactory> sortedFactories = sortFactories(actionsFactoriesMap);
// Add the edit menu actions
- for (IActionHandlerFactory factory : sortedFactories) {
- ActionProperties actionProperties = actionsFactoriesMap
- .get(factory);
- if (actionProperties != null && actionProperties.isNeedSeparator()) {
+ for(IActionHandlerFactory factory : sortedFactories) {
+ ActionProperties actionProperties = actionsFactoriesMap.get(factory);
+ if(actionProperties != null && actionProperties.isNeedSeparator()) {
menu.add(new Separator());
}
- for (Action action : factory.getActions()) {
+ for(Action action : factory.getActions()) {
menu.add(new ActionContributionItem(action));
}
}
@@ -149,14 +141,13 @@ public class EditingDomainActionProvider extends AbstractSubmenuActionProvider {
* Update actions
*/
public void update() {
- ISelection selection = getCommonNavigator().getCommonViewer()
- .getSelection();
+ ISelection selection = getCommonNavigator().getCommonViewer().getSelection();
IStructuredSelection structuredSelection = StructuredSelection.EMPTY;
- if (selection instanceof IStructuredSelection) {
- structuredSelection = (IStructuredSelection) selection;
+ if(selection instanceof IStructuredSelection) {
+ structuredSelection = (IStructuredSelection)selection;
}
- for (IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
+ for(IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
factory.update(structuredSelection);
}
}
@@ -165,7 +156,7 @@ public class EditingDomainActionProvider extends AbstractSubmenuActionProvider {
* Activate actions
*/
public void activate() {
- for (IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
+ for(IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
factory.activate(activeViewPart);
}
update();
@@ -176,7 +167,7 @@ public class EditingDomainActionProvider extends AbstractSubmenuActionProvider {
*/
// @unused
public void deactivate() {
- for (IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
+ for(IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
factory.deactivate(activeViewPart);
}
}
@@ -195,45 +186,39 @@ public class EditingDomainActionProvider extends AbstractSubmenuActionProvider {
* Sort factories.
*
* @param actionsFactoriesMap
- * the actions factories map
+ * the actions factories map
*
* @return the sorted list of factories
*/
- private List<IActionHandlerFactory> sortFactories(
- final Map<IActionHandlerFactory, ActionProperties> actionsFactoriesMap) {
+ private List<IActionHandlerFactory> sortFactories(final Map<IActionHandlerFactory, ActionProperties> actionsFactoriesMap) {
- List<IActionHandlerFactory> factories = new ArrayList<IActionHandlerFactory>(
- actionsFactoriesMap.keySet());
+ List<IActionHandlerFactory> factories = new ArrayList<IActionHandlerFactory>(actionsFactoriesMap.keySet());
Collections.sort(factories, new Comparator<IActionHandlerFactory>() {
- public int compare(IActionHandlerFactory factory1,
- IActionHandlerFactory factory2) {
+ public int compare(IActionHandlerFactory factory1, IActionHandlerFactory factory2) {
- ActionProperties properties1 = getDefaultForNull(actionsFactoriesMap
- .get(factory1));
- ActionProperties properties2 = getDefaultForNull(actionsFactoriesMap
- .get(factory2));
+ ActionProperties properties1 = getDefaultForNull(actionsFactoriesMap.get(factory1));
+ ActionProperties properties2 = getDefaultForNull(actionsFactoriesMap.get(factory2));
String after1 = properties1.getAfterAction();
String after2 = properties2.getAfterAction();
- if (properties1.getActionId().equals(properties2.getActionId())) {
+ if(properties1.getActionId().equals(properties2.getActionId())) {
return 0;
- } else if (properties1.getActionId().equals(after2)) {
+ } else if(properties1.getActionId().equals(after2)) {
return -1;
- } else if (properties2.getActionId().equals(after1)) {
+ } else if(properties2.getActionId().equals(after1)) {
return 1;
- } else if (after1 == null) {
+ } else if(after1 == null) {
return -1;
- } else if (after2 == null) {
+ } else if(after2 == null) {
return 1;
}
return 0;
}
- private ActionProperties getDefaultForNull(
- ActionProperties actionProperties) {
- if (actionProperties == null) {
+ private ActionProperties getDefaultForNull(ActionProperties actionProperties) {
+ if(actionProperties == null) {
actionProperties = new ActionProperties("", "", false);
}
return actionProperties;
@@ -261,8 +246,7 @@ public class EditingDomainActionProvider extends AbstractSubmenuActionProvider {
* @param needSeparator
*/
// @unused
- public ActionProperties(String actionId, String afterAction,
- boolean needSeparator) {
+ public ActionProperties(String actionId, String afterAction, boolean needSeparator) {
super();
this.actionId = actionId;
this.afterAction = afterAction;

Back to the top