Commit | Line | Data |
---|---|---|
6e651d8b MAL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 Ericsson | |
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 | * Marc-Andre Laperle - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport; | |
14 | ||
15 | import org.eclipse.core.commands.AbstractHandler; | |
16 | import org.eclipse.core.commands.ExecutionEvent; | |
17 | import org.eclipse.core.commands.ExecutionException; | |
18 | import org.eclipse.jface.viewers.ISelection; | |
19 | import org.eclipse.jface.viewers.IStructuredSelection; | |
20 | import org.eclipse.jface.viewers.StructuredSelection; | |
21 | import org.eclipse.jface.wizard.WizardDialog; | |
22 | import org.eclipse.ui.IWorkbenchWindow; | |
23 | import org.eclipse.ui.PlatformUI; | |
24 | import org.eclipse.ui.handlers.HandlerUtil; | |
25 | ||
26 | /** | |
27 | * Handler for exporting a trace package | |
28 | * | |
29 | * @author Marc-Andre Laperle | |
30 | */ | |
31 | public class ExportTracePackageHandler extends AbstractHandler { | |
32 | ||
33 | @Override | |
34 | public Object execute(ExecutionEvent event) throws ExecutionException { | |
35 | ExportTracePackageWizard w = new ExportTracePackageWizard(); | |
36 | IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); | |
37 | ||
38 | if (window == null) { | |
39 | return false; | |
40 | } | |
41 | ||
42 | ISelection currentSelection = HandlerUtil.getCurrentSelection(event); | |
43 | IStructuredSelection sec = StructuredSelection.EMPTY; | |
44 | if (currentSelection instanceof IStructuredSelection) { | |
45 | sec = (IStructuredSelection) currentSelection; | |
46 | } | |
47 | ||
48 | w.init(PlatformUI.getWorkbench(), sec); | |
49 | WizardDialog dialog = new WizardDialog(window.getShell(), w); | |
50 | dialog.open(); | |
51 | return null; | |
52 | } | |
53 | ||
54 | } |