1 /*******************************************************************************
2 * Copyright (c) 2009, 2010, 2011 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 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.tmf
.ui
.project
.handlers
;
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
.ISelectionProvider
;
20 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
21 import org
.eclipse
.jface
.viewers
.TreeSelection
;
22 import org
.eclipse
.jface
.wizard
.WizardDialog
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceFolder
;
24 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.wizards
.ImportTraceWizard
;
25 import org
.eclipse
.swt
.widgets
.Shell
;
26 import org
.eclipse
.ui
.IWorkbench
;
27 import org
.eclipse
.ui
.IWorkbenchPage
;
28 import org
.eclipse
.ui
.IWorkbenchPart
;
29 import org
.eclipse
.ui
.IWorkbenchWindow
;
30 import org
.eclipse
.ui
.PlatformUI
;
33 * <b><u>ImportTraceHandler</u></b>
35 * Starts an ImportTraceWizard that will handle the lowly details.
37 public class ImportTraceHandler
extends AbstractHandler
{
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
46 // Check if we are closing down
47 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
52 IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
53 IWorkbenchPart part
= page
.getActivePart();
54 ISelectionProvider selectionProvider
= part
.getSite().getSelectionProvider();
55 if (selectionProvider
== null)
57 ISelection selection
= selectionProvider
.getSelection();
59 TmfTraceFolder traceFolder
= null;
60 if (selection
instanceof TreeSelection
) {
61 TreeSelection sel
= (TreeSelection
) selection
;
62 // There should be only one item selected as per the plugin.xml
63 Object element
= sel
.getFirstElement();
64 if (element
instanceof TmfTraceFolder
) {
65 traceFolder
= (TmfTraceFolder
) element
;
68 if (traceFolder
== null)
71 // Fire the Import Trace Wizard
72 IWorkbench workbench
= PlatformUI
.getWorkbench();
73 Shell shell
= workbench
.getActiveWorkbenchWindow().getShell();
75 ImportTraceWizard wizard
= new ImportTraceWizard();
76 wizard
.init(PlatformUI
.getWorkbench(), new StructuredSelection(traceFolder
));
77 WizardDialog dialog
= new WizardDialog(shell
, wizard
);
80 traceFolder
.refresh();