1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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
.tmf
.ui
.views
.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
.StructuredSelection
;
20 import org
.eclipse
.jface
.wizard
.WizardDialog
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.project
.ProjectView
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.project
.dialogs
.AddTraceWizard
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.project
.model
.TmfExperimentNode
;
24 import org
.eclipse
.swt
.widgets
.Shell
;
25 import org
.eclipse
.ui
.IWorkbench
;
26 import org
.eclipse
.ui
.IWorkbenchPage
;
27 import org
.eclipse
.ui
.IWorkbenchWindow
;
28 import org
.eclipse
.ui
.PlatformUI
;
31 * <b><u>SelectTracesHandler</u></b>
33 * TODO: Implement me. Please.
35 public class SelectTracesHandler
extends AbstractHandler
{
37 private TmfExperimentNode fExperiment
= null;
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 public boolean isEnabled() {
46 // Check if we are closing down
47 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
51 // Check if we are in the Project View
52 IWorkbenchPage page
= window
.getActivePage();
53 if (!(page
.getActivePart() instanceof ProjectView
))
56 // Check that an experiment is selected
57 ISelection selection
= page
.getSelection(ProjectView
.ID
);
58 if (selection
instanceof StructuredSelection
) {
59 Object element
= ((StructuredSelection
) selection
).getFirstElement();
60 fExperiment
= (element
instanceof TmfExperimentNode
) ?
(TmfExperimentNode
) element
: null;
63 return (fExperiment
!= null);
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
71 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
73 // Open the trace addition wizard
74 IWorkbench workbench
= PlatformUI
.getWorkbench();
75 Shell shell
= workbench
.getActiveWorkbenchWindow().getShell();
77 AddTraceWizard wizard
= new AddTraceWizard(fExperiment
.getProject(), fExperiment
);
78 wizard
.init(PlatformUI
.getWorkbench(), null);
79 WizardDialog dialog
= new WizardDialog(shell
, wizard
);