Move alltests plugin to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / project / handlers / ImportTraceHandler.java
CommitLineData
002f9f07 1/*******************************************************************************
ceb60136 2 * Copyright (c) 2009, 2014 Ericsson
002f9f07
BH
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
ceb60136 11 * Bernd Hufmann - Update selection handling
002f9f07
BH
12 *******************************************************************************/
13
14package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
15
16import org.eclipse.core.commands.AbstractHandler;
17import org.eclipse.core.commands.ExecutionEvent;
18import org.eclipse.core.commands.ExecutionException;
19import org.eclipse.jface.viewers.ISelection;
ceb60136 20import org.eclipse.jface.viewers.IStructuredSelection;
002f9f07 21import org.eclipse.jface.viewers.StructuredSelection;
002f9f07 22import org.eclipse.jface.wizard.WizardDialog;
1de10308 23import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard;
002f9f07
BH
24import org.eclipse.ui.IWorkbenchWindow;
25import org.eclipse.ui.PlatformUI;
ceb60136 26import org.eclipse.ui.handlers.HandlerUtil;
002f9f07
BH
27
28/**
29 * <b><u>ImportTraceHandler</u></b>
30 * <p>
31 * Starts an ImportTraceWizard that will handle the lowly details.
32 */
33public class ImportTraceHandler extends AbstractHandler {
34
35 // ------------------------------------------------------------------------
36 // Execution
37 // ------------------------------------------------------------------------
38
39 @Override
40 public Object execute(ExecutionEvent event) throws ExecutionException {
ceb60136
BH
41 ImportTraceWizard w = new ImportTraceWizard();
42 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
002f9f07 43
ceb60136
BH
44 if (window == null) {
45 return false;
002f9f07 46 }
002f9f07 47
ceb60136
BH
48 ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
49 // Menu Selection is only not null for context-sensitive menu
50 ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event);
002f9f07 51
ceb60136 52 IStructuredSelection sec = StructuredSelection.EMPTY;
002f9f07 53
ceb60136
BH
54 // Only use the selection if handler is called from context-sensitive menu
55 if ((menuSelection != null) && (currentSelection instanceof IStructuredSelection)) {
56 sec = (IStructuredSelection) currentSelection;
002f9f07
BH
57 }
58
ceb60136
BH
59 w.init(PlatformUI.getWorkbench(), sec);
60 WizardDialog dialog = new WizardDialog(window.getShell(), w);
61 dialog.open();
62 return null;
002f9f07 63 }
002f9f07 64}
This page took 0.039497 seconds and 5 git commands to generate.