tmf: Move HandlerUtils to TMF
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Fri, 7 Jul 2017 20:58:40 +0000 (16:58 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Fri, 7 Jul 2017 20:58:40 +0000 (16:58 -0400)
This class in the LAMI plugins can actually be useful to all
handlers.

Change-Id: I019980ca92d00d6480afe9ef4a6c72a33cb91d33
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/handler/AddAnalysisHandler.java
analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/handler/HandlerUtils.java [deleted file]
analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/handler/RunAnalysisHandler.java
tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/handlers/HandlerUtils.java [new file with mode: 0644]

index 490771ce6c3a85397090ef13264eb6d09e18a414..269f5144a39ce0a55ba567f5e272b7ad2e44bc79 100644 (file)
@@ -28,6 +28,7 @@ import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.L
 import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysisFactoryException;
 import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysisFactoryFromConfigFile;
 import org.eclipse.tracecompass.tmf.core.analysis.ondemand.OnDemandAnalysisManager;
+import org.eclipse.tracecompass.tmf.ui.project.handlers.HandlerUtils;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfOnDemandAnalysesElement;
 import org.eclipse.ui.PlatformUI;
 
diff --git a/analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/handler/HandlerUtils.java b/analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/handler/HandlerUtils.java
deleted file mode 100644 (file)
index 334b3d6..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir, Philippe Proulx
- *
- * 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
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.handler;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Utilities for UI handlers
- *
- * @author Philippe Proulx
- */
-public final class HandlerUtils {
-
-    private HandlerUtils() {
-    }
-
-    /**
-     * Get the current selected UI element. Can be used instead of
-     * {@link org.eclipse.ui.handlers.HandlerUtil#getCurrentSelection} when an
-     * ExecutionEvent is not available.
-     *
-     * @return The element consisting of the selection
-     */
-    public static @Nullable Object getSelectedModelElement() {
-        // Check if we are closing down
-        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-        if (window == null) {
-            return null;
-        }
-
-        // Get the selection
-        final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-        final IWorkbenchPart part = page.getActivePart();
-        if (part == null) {
-            return null;
-        }
-        final ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
-        if (selectionProvider == null) {
-            return null;
-        }
-        final ISelection selection = selectionProvider.getSelection();
-
-        if (selection instanceof TreeSelection) {
-            final TreeSelection sel = (TreeSelection) selection;
-            // There should be only one item selected as per the plugin.xml
-            return sel.getFirstElement();
-        }
-
-        return null;
-    }
-
-}
index 47549d3307cdbdb99bd3082911732d2d8c32baff..6e432f6f674d1d75348c70d569a273191eca0d11 100644 (file)
@@ -38,6 +38,7 @@ import org.eclipse.tracecompass.tmf.core.analysis.ondemand.IOnDemandAnalysisRepo
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.ui.project.handlers.HandlerUtils;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfOnDemandAnalysisElement;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfReportsElement;
index ed88ebf7a703de8865e6ac41757aa54bc609a574..ea6cf8c762027c487e9e6bead7696efb55c52fcd 100644 (file)
@@ -67,6 +67,7 @@ Export-Package: org.eclipse.tracecompass.internal.tmf.ui;x-friends:="org.eclipse
  org.eclipse.tracecompass.tmf.ui.dialog,
  org.eclipse.tracecompass.tmf.ui.editors,
  org.eclipse.tracecompass.tmf.ui.markers,
+ org.eclipse.tracecompass.tmf.ui.project.handlers,
  org.eclipse.tracecompass.tmf.ui.project.model,
  org.eclipse.tracecompass.tmf.ui.project.wizards,
  org.eclipse.tracecompass.tmf.ui.properties,
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/handlers/HandlerUtils.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/handlers/HandlerUtils.java
new file mode 100644 (file)
index 0000000..50ca1ee
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir, Philippe Proulx
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ui.project.handlers;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Utilities for UI handlers
+ *
+ * @author Philippe Proulx
+ * @since 2.3
+ */
+@NonNullByDefault
+public final class HandlerUtils {
+
+    private HandlerUtils() {
+    }
+
+    /**
+     * Get the current selected UI element. Can be used instead of
+     * {@link org.eclipse.ui.handlers.HandlerUtil#getCurrentSelection} when an
+     * ExecutionEvent is not available.
+     *
+     * @return The element consisting of the selection
+     */
+    public static @Nullable Object getSelectedModelElement() {
+        // Check if we are closing down
+        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+        if (window == null) {
+            return null;
+        }
+
+        // Get the selection
+        final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+        final IWorkbenchPart part = page.getActivePart();
+        if (part == null) {
+            return null;
+        }
+        final ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
+        if (selectionProvider == null) {
+            return null;
+        }
+        final ISelection selection = selectionProvider.getSelection();
+
+        if (selection instanceof TreeSelection) {
+            final TreeSelection sel = (TreeSelection) selection;
+            // There should be only one item selected as per the plugin.xml
+            return sel.getFirstElement();
+        }
+
+        return null;
+    }
+
+}
This page took 0.029792 seconds and 5 git commands to generate.