1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 * Bernd Hufmann - Update selection handling
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.handlers
;
16 import org
.eclipse
.core
.commands
.AbstractHandler
;
17 import org
.eclipse
.core
.commands
.ExecutionEvent
;
18 import org
.eclipse
.core
.commands
.ExecutionException
;
19 import org
.eclipse
.jface
.viewers
.ISelection
;
20 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
21 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
22 import org
.eclipse
.jface
.wizard
.WizardDialog
;
23 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.ImportTraceWizard
;
24 import org
.eclipse
.ui
.IWorkbenchWindow
;
25 import org
.eclipse
.ui
.PlatformUI
;
26 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
29 * <b><u>ImportTraceHandler</u></b>
31 * Starts an ImportTraceWizard that will handle the lowly details.
33 public class ImportTraceHandler
extends AbstractHandler
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
40 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
41 ImportTraceWizard w
= new ImportTraceWizard();
42 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
48 ISelection currentSelection
= HandlerUtil
.getCurrentSelection(event
);
49 // Menu Selection is only not null for context-sensitive menu
50 ISelection menuSelection
= HandlerUtil
.getActiveMenuSelection(event
);
52 IStructuredSelection sec
= StructuredSelection
.EMPTY
;
54 // Only use the selection if handler is called from context-sensitive menu
55 if ((menuSelection
!= null) && (currentSelection
instanceof IStructuredSelection
)) {
56 sec
= (IStructuredSelection
) currentSelection
;
59 w
.init(PlatformUI
.getWorkbench(), sec
);
60 WizardDialog dialog
= new WizardDialog(window
.getShell(), w
);