Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Bricon2018-03-13 11:17:50 -0400
committerFred Bricon2018-03-13 11:17:50 -0400
commitc37f9e65db255fff1281647b55fe8477561f9050 (patch)
treea3c2cd7f6a73ccaaacd60bc70e65ba4411925487 /org.eclipse.m2e.profiles.ui
parenta7a2594b6953405b4b0ba1bdf1133a13bc90f0aa (diff)
downloadm2e-core-c37f9e65db255fff1281647b55fe8477561f9050.tar.gz
m2e-core-c37f9e65db255fff1281647b55fe8477561f9050.tar.xz
m2e-core-c37f9e65db255fff1281647b55fe8477561f9050.zip
Remove reference to old rg.jboss.tools.maven.ui.generic plugin
Change-Id: I3798d3597ef22aedbe80eb9879c48593e3de6903 Signed-off-by: Fred Bricon <fbricon@gmail.com>
Diffstat (limited to 'org.eclipse.m2e.profiles.ui')
-rw-r--r--org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/actions/GenericCommandActionDelegate.java392
1 files changed, 191 insertions, 201 deletions
diff --git a/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/actions/GenericCommandActionDelegate.java b/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/actions/GenericCommandActionDelegate.java
index 532c64ad..857a74d9 100644
--- a/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/actions/GenericCommandActionDelegate.java
+++ b/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/actions/GenericCommandActionDelegate.java
@@ -12,6 +12,7 @@
* Original code taken from <a href="http://wiki.eclipse.org/Platform_Command_Framework#Using_an_IActionDelegate_to_execute_a_command">
* http://wiki.eclipse.org/Platform_Command_Framework#Using_an_IActionDelegate_to_execute_a_command</a>
******************************************************************************/
+
package org.eclipse.m2e.profiles.ui.internal.actions;
import java.util.ArrayList;
@@ -42,207 +43,196 @@ import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
+import org.eclipse.m2e.profiles.ui.internal.MavenProfilesUIActivator;
+
+
/**
- * This action delegate can be used to specify a command with or without
- * parameters be called from an &lt;action/&gt; specified in actionSets,
- * editorActions, viewActions, or popupMenus.
+ * This action delegate can be used to specify a command with or without parameters be called from an &lt;action/&gt;
+ * specified in actionSets, editorActions, viewActions, or popupMenus.
*/
-public class GenericCommandActionDelegate implements
- IWorkbenchWindowActionDelegate, IViewActionDelegate,
- IEditorActionDelegate, IObjectActionDelegate, IExecutableExtension {
-
- /**
- * The commandId parameter needed when using the &lt;class/&gt; form for
- * this IActionDelegate. Value is "commandId".
- */
- public static final String PARM_COMMAND_ID = "commandId"; //$NON-NLS-1$
-
- private String commandId = null;
-
- private Map<?, ?> parameterMap = null;
-
- private ParameterizedCommand parameterizedCommand = null;
-
- private IHandlerService handlerService = null;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {
- handlerService = null;
- parameterizedCommand = null;
- parameterMap = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- if (handlerService == null) {
- // what, no handler service ... no problem
- return;
- }
- try {
- if (commandId != null) {
- handlerService.executeCommand(commandId, null);
- } else if (parameterizedCommand != null) {
- handlerService.executeCommand(parameterizedCommand, null);
- }
- // else there is no command for this delegate
- } catch (Exception e) {
- // exceptions reduced for brevity
- // and we won't just do a print out :-)
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- // we don't care, handlers get their selection from the
- // ExecutionEvent application context
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement,
- * java.lang.String, java.lang.Object)
- */
- public void setInitializationData(IConfigurationElement config,
- String propertyName, Object data) throws CoreException {
- String id = config.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- // save the data until our init(*) call, where we can get
- // the services.
- if (data instanceof String) {
- commandId = (String) data;
- } else if (data instanceof Map) {
- parameterMap = (Map<?, ?>) data;
- if (parameterMap.get(PARM_COMMAND_ID) == null) {
- Status status = new Status(IStatus.ERROR,
- "org.jboss.tools.maven.ui.generic", "The '" + id
- + "' action won't work without a commandId");
- throw new CoreException(status);
- }
- } else {
- Status status = new Status(
- IStatus.ERROR,
- "org.jboss.tools.maven.ui.generic",
- "The '"
- + id
- + "' action won't work without some initialization parameters");
- throw new CoreException(status);
- }
- }
-
- /**
- * Build a command from the executable extension information.
- *
- * @param commandService
- * to get the Command object
- */
- private void createCommand(ICommandService commandService) {
- String id = (String) parameterMap.get(PARM_COMMAND_ID);
- if (id == null) {
- return;
- }
- if (parameterMap.size() == 1) {
- commandId = id;
- return;
- }
- try {
- Command cmd = commandService.getCommand(id);
- if (!cmd.isDefined()) {
- // command not defined? no problem ...
- return;
- }
- ArrayList<Parameterization> parameters = new ArrayList<Parameterization>();
- Iterator<?> i = parameterMap.keySet().iterator();
- while (i.hasNext()) {
- String parmName = (String) i.next();
- if (PARM_COMMAND_ID.equals(parmName)) {
- continue;
- }
- IParameter parm = cmd.getParameter(parmName);
- if (parm == null) {
- // asking for a bogus parameter? No problem
- return;
- }
- parameters.add(new Parameterization(parm, (String) parameterMap
- .get(parmName)));
- }
- parameterizedCommand = new ParameterizedCommand(cmd,
- (Parameterization[]) parameters
- .toArray(new Parameterization[parameters.size()]));
- } catch (NotDefinedException e) {
- // command is bogus? No problem, we'll do nothing.
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- if (handlerService != null) {
- // already initialized
- return;
- }
-
- handlerService = (IHandlerService) window
- .getService(IHandlerService.class);
- if (parameterMap != null) {
- ICommandService commandService = (ICommandService) window
- .getService(ICommandService.class);
- createCommand(commandService);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
- */
- public void init(IViewPart view) {
- init(view.getSite().getWorkbenchWindow());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction,
- * org.eclipse.ui.IEditorPart)
- */
- public void setActiveEditor(IAction action, IEditorPart targetEditor) {
- // we don't actually care about the active editor, since that
- // information is in the ExecutionEvent application context
- // but we need to make sure we're initialized.
- if (targetEditor != null) {
- init(targetEditor.getSite().getWorkbenchWindow());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,
- * org.eclipse.ui.IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- // we don't actually care about the active part, since that
- // information is in the ExecutionEvent application context
- // but we need to make sure we're initialized.
- if (targetPart != null) {
- init(targetPart.getSite().getWorkbenchWindow());
- }
- }
+public class GenericCommandActionDelegate implements IWorkbenchWindowActionDelegate, IViewActionDelegate,
+ IEditorActionDelegate, IObjectActionDelegate, IExecutableExtension {
+
+ /**
+ * The commandId parameter needed when using the &lt;class/&gt; form for this IActionDelegate. Value is "commandId".
+ */
+ public static final String PARM_COMMAND_ID = "commandId"; //$NON-NLS-1$
+
+ private String commandId = null;
+
+ private Map<?, ?> parameterMap = null;
+
+ private ParameterizedCommand parameterizedCommand = null;
+
+ private IHandlerService handlerService = null;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose() {
+ handlerService = null;
+ parameterizedCommand = null;
+ parameterMap = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ if(handlerService == null) {
+ // what, no handler service ... no problem
+ return;
+ }
+ try {
+ if(commandId != null) {
+ handlerService.executeCommand(commandId, null);
+ } else if(parameterizedCommand != null) {
+ handlerService.executeCommand(parameterizedCommand, null);
+ }
+ // else there is no command for this delegate
+ } catch(Exception e) {
+ // exceptions reduced for brevity
+ // and we won't just do a print out :-)
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ // we don't care, handlers get their selection from the
+ // ExecutionEvent application context
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement,
+ * java.lang.String, java.lang.Object)
+ */
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+ throws CoreException {
+ String id = config.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
+ // save the data until our init(*) call, where we can get
+ // the services.
+ if(data instanceof String) {
+ commandId = (String) data;
+ } else if(data instanceof Map) {
+ parameterMap = (Map<?, ?>) data;
+ if(parameterMap.get(PARM_COMMAND_ID) == null) {
+ Status status = new Status(IStatus.ERROR, MavenProfilesUIActivator.PLUGIN_ID,
+ "The '" + id + "' action won't work without a commandId");
+ throw new CoreException(status);
+ }
+ } else {
+ Status status = new Status(IStatus.ERROR, MavenProfilesUIActivator.PLUGIN_ID,
+ "The '" + id + "' action won't work without some initialization parameters");
+ throw new CoreException(status);
+ }
+ }
+
+ /**
+ * Build a command from the executable extension information.
+ *
+ * @param commandService to get the Command object
+ */
+ private void createCommand(ICommandService commandService) {
+ String id = (String) parameterMap.get(PARM_COMMAND_ID);
+ if(id == null) {
+ return;
+ }
+ if(parameterMap.size() == 1) {
+ commandId = id;
+ return;
+ }
+ try {
+ Command cmd = commandService.getCommand(id);
+ if(!cmd.isDefined()) {
+ // command not defined? no problem ...
+ return;
+ }
+ ArrayList<Parameterization> parameters = new ArrayList<Parameterization>();
+ Iterator<?> i = parameterMap.keySet().iterator();
+ while(i.hasNext()) {
+ String parmName = (String) i.next();
+ if(PARM_COMMAND_ID.equals(parmName)) {
+ continue;
+ }
+ IParameter parm = cmd.getParameter(parmName);
+ if(parm == null) {
+ // asking for a bogus parameter? No problem
+ return;
+ }
+ parameters.add(new Parameterization(parm, (String) parameterMap.get(parmName)));
+ }
+ parameterizedCommand = new ParameterizedCommand(cmd,
+ (Parameterization[]) parameters.toArray(new Parameterization[parameters.size()]));
+ } catch(NotDefinedException e) {
+ // command is bogus? No problem, we'll do nothing.
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init(IWorkbenchWindow window) {
+ if(handlerService != null) {
+ // already initialized
+ return;
+ }
+
+ handlerService = (IHandlerService) window.getService(IHandlerService.class);
+ if(parameterMap != null) {
+ ICommandService commandService = (ICommandService) window.getService(ICommandService.class);
+ createCommand(commandService);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public void init(IViewPart view) {
+ init(view.getSite().getWorkbenchWindow());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction,
+ * org.eclipse.ui.IEditorPart)
+ */
+ public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+ // we don't actually care about the active editor, since that
+ // information is in the ExecutionEvent application context
+ // but we need to make sure we're initialized.
+ if(targetEditor != null) {
+ init(targetEditor.getSite().getWorkbenchWindow());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,
+ * org.eclipse.ui.IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ // we don't actually care about the active part, since that
+ // information is in the ExecutionEvent application context
+ // but we need to make sure we're initialized.
+ if(targetPart != null) {
+ init(targetPart.getSite().getWorkbenchWindow());
+ }
+ }
}
-

Back to the top