tmf: Remove unnecessary global action handlers
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Thu, 24 Apr 2014 13:08:54 +0000 (09:08 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Thu, 1 May 2014 18:15:00 +0000 (14:15 -0400)
These actions were no longer necessary since the menu contributions were
changed to use the global command ids in commit 9625626.

The Delete action is also removed from the context menu when the
selection contains a mix of traces, folders or experiments.

Change-Id: I24a714f3935b09616e8f74e2970ba19981dc143c
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/25441
Tested-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
org.eclipse.linuxtools.tmf.ui/plugin.xml
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteAction.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/RefreshAction.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/TmfActionProvider.java

index 7adc74ab9d4a445f36cc2e70b79666c656e275a2..fb8d77504be6d055849075da1e68138bac96e1e0 100644 (file)
                   checkEnabled="false">
                <with
                      variable="selection">
-                  <iterate
-                        ifEmpty="false"
-                        operator="and">
-                     <or>
+                  <or>
+                     <iterate
+                           ifEmpty="false"
+                           operator="and">
                         <and>
                            <instanceof
                                  value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
                               </test>
                            </not>
                         </and>
+                     </iterate>
+                     <iterate
+                           ifEmpty="false"
+                           operator="and">
                         <instanceof
                               value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
                         </instanceof>
+                     </iterate>
+                     <iterate
+                           ifEmpty="false"
+                           operator="and">
                         <and>
                            <not>
                               <instanceof
                                  value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">
                            </instanceof>
                         </and>
-                     </or>
-                  </iterate>
+                     </iterate>
+                  </or>
                </with>
             </visibleWhen>
          </command>
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteAction.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteAction.java
deleted file mode 100644 (file)
index 43f9383..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2012, 2013 Ericsson
- *
- * 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:
- *   Patrick Tasse - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.handlers.IHandlerService;
-
-/**
- * <b><u>DeleteAction</u></b>
- * <p>
- * Implement me. Please.
- * <p>
- */
-public class DeleteAction extends Action {
-
-    private static final String DELETE_COMMAND_ID = "org.eclipse.ui.edit.delete"; //$NON-NLS-1$
-
-    private final IWorkbenchPage page;
-    private final ISelectionProvider selectionProvider;
-    private boolean tracesSelected;
-    private boolean experimentsSelected;
-
-    /**
-     * Default constructor
-     * @param page the workbench page
-     * @param selectionProvider the selection provider
-     */
-    public DeleteAction(IWorkbenchPage page, ISelectionProvider selectionProvider) {
-        this.page = page;
-        this.selectionProvider = selectionProvider;
-    }
-
-    @Override
-    public boolean isEnabled() {
-        ISelection selection = selectionProvider.getSelection();
-        if (!selection.isEmpty()) {
-            tracesSelected = false;
-            experimentsSelected = false;
-            IStructuredSelection sSelection = (IStructuredSelection) selection;
-            for (Object aSelection : sSelection.toList()) {
-                if (aSelection instanceof TmfTraceElement) {
-                    tracesSelected = true;
-                }
-                if (aSelection instanceof TmfExperimentElement) {
-                    experimentsSelected = true;
-                }
-            }
-            if (tracesSelected && experimentsSelected) {
-                return false;
-            }
-            return (tracesSelected || experimentsSelected);
-        }
-        return false;
-    }
-
-    @Override
-    public void run() {
-        try {
-            IHandlerService handlerService = (IHandlerService) page.getActivePart().getSite().getService(IHandlerService.class);
-            if (tracesSelected || experimentsSelected) {
-                handlerService.executeCommand(DELETE_COMMAND_ID, null);
-            }
-        } catch (ExecutionException e) {
-            Activator.getDefault().logError("Error deleting resources", e); //$NON-NLS-1$
-        } catch (NotDefinedException e) {
-            Activator.getDefault().logError("Error deleting resources", e); //$NON-NLS-1$
-        } catch (NotEnabledException e) {
-            Activator.getDefault().logError("Error deleting resources", e); //$NON-NLS-1$
-        } catch (NotHandledException e) {
-            Activator.getDefault().logError("Error deleting resources", e); //$NON-NLS-1$
-        }
-    }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/RefreshAction.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/RefreshAction.java
deleted file mode 100644 (file)
index 610adaa..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2012, 2013 Ericsson
- *
- * 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:
- *   Patrick Tasse - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.handlers.IHandlerService;
-
-/**
- * <b><u>RefreshAction</u></b>
- * <p>
- * Implement me. Please.
- * <p>
- */
-public class RefreshAction extends Action {
-
-    private static final String REFRESH_COMMAND_ID = "org.eclipse.ui.file.refresh"; //$NON-NLS-1$
-
-    private IWorkbenchPage page;
-    private ISelectionProvider selectionProvider;
-    private TmfProjectModelElement element;
-
-    /**
-     * Default constructor
-     * @param page the workbench page
-     * @param selectionProvider the selection provider
-     */
-    public RefreshAction(IWorkbenchPage page, ISelectionProvider selectionProvider) {
-        this.page = page;
-        this.selectionProvider = selectionProvider;
-    }
-
-    @Override
-    public boolean isEnabled() {
-        ISelection selection = selectionProvider.getSelection();
-        if (!selection.isEmpty()) {
-            IStructuredSelection sSelection = (IStructuredSelection) selection;
-            if (sSelection.size() == 1) {
-                if (sSelection.getFirstElement() instanceof TmfTraceFolder ||
-                        sSelection.getFirstElement() instanceof TmfExperimentFolder ||
-                        sSelection.getFirstElement() instanceof TmfExperimentElement) {
-                    element = (TmfProjectModelElement) sSelection.getFirstElement();
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public void run() {
-        try {
-            IHandlerService handlerService = (IHandlerService) page.getActivePart().getSite().getService(IHandlerService.class);
-            if (element instanceof TmfTraceFolder || element instanceof TmfExperimentFolder || element instanceof TmfExperimentElement) {
-                handlerService.executeCommand(REFRESH_COMMAND_ID, null);
-            }
-        } catch (ExecutionException e) {
-            Activator.getDefault().logError("Error refreshing resource " + element.getName(), e); //$NON-NLS-1$
-        } catch (NotDefinedException e) {
-            Activator.getDefault().logError("Error refreshing resource " + element.getName(), e); //$NON-NLS-1$
-        } catch (NotEnabledException e) {
-            Activator.getDefault().logError("Error refreshing resource " + element.getName(), e); //$NON-NLS-1$
-        } catch (NotHandledException e) {
-            Activator.getDefault().logError("Error refreshing resource " + element.getName(), e); //$NON-NLS-1$
-        }
-    }
-
-}
index 23bd5441a243c3e2fb84dbbbed392fdd8b88d163..e6921f77ca09b03d8ced19bab28ce0a27da2b0ca 100644 (file)
@@ -20,7 +20,6 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
 import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.actions.ActionFactory;
 import org.eclipse.ui.actions.OpenWithMenu;
 import org.eclipse.ui.navigator.CommonActionProvider;
 import org.eclipse.ui.navigator.ICommonActionConstants;
@@ -37,8 +36,6 @@ import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
 public class TmfActionProvider extends CommonActionProvider {
 
     private OpenAction openAction;
-    private DeleteAction deleteAction;
-    private RefreshAction refreshAction;
 
     private IWorkbenchPage page;
 
@@ -55,8 +52,6 @@ public class TmfActionProvider extends CommonActionProvider {
             ICommonViewerWorkbenchSite workbenchSite = (ICommonViewerWorkbenchSite) viewSite;
             page = workbenchSite.getPage();
             openAction = new OpenAction(page, workbenchSite.getSelectionProvider());
-            deleteAction = new DeleteAction(page, workbenchSite.getSelectionProvider());
-            refreshAction = new RefreshAction(page, workbenchSite.getSelectionProvider());
         }
     }
 
@@ -81,12 +76,6 @@ public class TmfActionProvider extends CommonActionProvider {
         if (openAction.isEnabled()) {
             actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, openAction);
         }
-        if (deleteAction.isEnabled()) {
-            actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
-        }
-        if (refreshAction.isEnabled()) {
-            actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
-        }
     }
 
 }
This page took 0.033573 seconds and 5 git commands to generate.