Commit | Line | Data |
---|---|---|
d04ec5a7 | 1 | /******************************************************************************* |
ceb60136 | 2 | * Copyright (c) 2013, 2014 Ericsson |
d04ec5a7 MK |
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 | * Matthew Khouzam - Initial API and implementation | |
ceb60136 | 11 | * Bernd Hufmann - Simplify selection logic |
d04ec5a7 MK |
12 | *******************************************************************************/ |
13 | ||
14 | package org.eclipse.linuxtools.internal.tmf.ui.project.handlers; | |
15 | ||
ceb60136 | 16 | import org.eclipse.core.commands.AbstractHandler; |
d04ec5a7 MK |
17 | import org.eclipse.core.commands.ExecutionEvent; |
18 | import org.eclipse.core.commands.ExecutionException; | |
ceb60136 | 19 | import org.eclipse.jface.viewers.ISelection; |
f537c959 | 20 | import org.eclipse.jface.viewers.IStructuredSelection; |
d04ec5a7 MK |
21 | import org.eclipse.jface.viewers.StructuredSelection; |
22 | import org.eclipse.jface.wizard.WizardDialog; | |
1de10308 | 23 | import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.importtrace.BatchImportTraceWizard; |
d04ec5a7 MK |
24 | import org.eclipse.ui.IWorkbenchWindow; |
25 | import org.eclipse.ui.PlatformUI; | |
fe13246f | 26 | import org.eclipse.ui.handlers.HandlerUtil; |
d04ec5a7 MK |
27 | |
28 | /** | |
29 | * Batch import handler, spawn a wizard | |
30 | * | |
31 | * @author Matthew Khouzam | |
32 | * @since 2.0 | |
33 | */ | |
ceb60136 | 34 | public class BatchImportTraceHandler extends AbstractHandler { |
d04ec5a7 MK |
35 | |
36 | @Override | |
37 | public Object execute(ExecutionEvent event) throws ExecutionException { | |
d04ec5a7 | 38 | |
ceb60136 BH |
39 | BatchImportTraceWizard w = new BatchImportTraceWizard(); |
40 | IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); | |
41 | ||
42 | if (window == null) { | |
43 | return false; | |
d04ec5a7 | 44 | } |
fe13246f | 45 | |
ceb60136 BH |
46 | ISelection currentSelection = HandlerUtil.getCurrentSelection(event); |
47 | ||
48 | IStructuredSelection sec = StructuredSelection.EMPTY; | |
49 | if (currentSelection instanceof IStructuredSelection) { | |
50 | sec = (IStructuredSelection) currentSelection; | |
fe13246f MAL |
51 | } |
52 | ||
ceb60136 BH |
53 | w.init(PlatformUI.getWorkbench(), sec); |
54 | WizardDialog dialog = new WizardDialog(window.getShell(), w); | |
fe13246f MAL |
55 | dialog.open(); |
56 | ||
d04ec5a7 MK |
57 | return null; |
58 | } | |
59 | ||
60 | } |