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
.lttng
.ui
.views
.project
.handlers
;
15 import org
.eclipse
.core
.commands
.ExecutionEvent
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.core
.commands
.IHandler
;
18 import org
.eclipse
.core
.commands
.IHandlerListener
;
19 import org
.eclipse
.jface
.viewers
.ISelection
;
20 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
21 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.ProjectView
;
22 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.model
.LTTngExperimentNode
;
23 import org
.eclipse
.ui
.IWorkbenchPage
;
24 import org
.eclipse
.ui
.IWorkbenchWindow
;
25 import org
.eclipse
.ui
.PlatformUI
;
28 * <b><u>OpenExperimentHandler</u></b>
30 * TODO: Implement me. Please.
32 public class OpenExperimentHandler
implements IHandler
{
34 private LTTngExperimentNode fExperiment
= null;
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
41 public boolean isEnabled() {
42 // Check if we are closing down
43 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
47 // Check if a trace is selected
48 IWorkbenchPage page
= window
.getActivePage();
49 if (!(page
.getActivePart() instanceof ProjectView
))
52 // Check if a trace is selected
53 ISelection selection
= page
.getSelection(ProjectView
.ID
);
54 if (selection
instanceof StructuredSelection
) {
55 Object element
= ((StructuredSelection
) selection
).getFirstElement();
56 fExperiment
= (element
instanceof LTTngExperimentNode
) ?
(LTTngExperimentNode
) element
: null;
59 return (fExperiment
!= null);
62 // Handled if we are in the ProjectView
64 public boolean isHandled() {
68 // ------------------------------------------------------------------------
70 // ------------------------------------------------------------------------
73 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
75 // Set the selection to the project
76 IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
77 ProjectView projectView
= (ProjectView
) page
.getActivePart();
79 if (projectView
!= null) {
80 projectView
.selectExperiment(fExperiment
);
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
91 public void addHandlerListener(IHandlerListener handlerListener
) {
92 // TODO Auto-generated method stub
96 public void removeHandlerListener(IHandlerListener handlerListener
) {
97 // TODO Auto-generated method stub
101 public void dispose() {
102 // TODO Auto-generated method stub