1 /**********************************************************************
2 * Copyright (c) 2012 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 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.handlers
;
14 import java
.util
.concurrent
.locks
.ReentrantLock
;
16 import org
.eclipse
.core
.commands
.AbstractHandler
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
19 import org
.eclipse
.core
.runtime
.IStatus
;
20 import org
.eclipse
.core
.runtime
.Status
;
21 import org
.eclipse
.core
.runtime
.jobs
.Job
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.ControlView
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.Messages
;
25 import org
.eclipse
.ui
.IWorkbenchPage
;
26 import org
.eclipse
.ui
.IWorkbenchPart
;
27 import org
.eclipse
.ui
.IWorkbenchWindow
;
28 import org
.eclipse
.ui
.PlatformUI
;
31 * <b><u>BaseControlViewHandler</u></b>
33 * Abstract Command handler implementation for all control view handlers.
36 abstract public class BaseControlViewHandler
extends AbstractHandler
{
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
42 * The synchronization lock.
44 protected ReentrantLock fLock
= new ReentrantLock();
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
50 * @return returns the workbench page for the Control View
52 protected IWorkbenchPage
getWorkbenchPage() {
53 // Check if we are closing down
54 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
59 // Check if we are in the Project View
60 IWorkbenchPage page
= window
.getActivePage();
65 IWorkbenchPart part
= page
.getActivePart();
66 if (!(part
instanceof ControlView
)) {
73 * Refreshes the session information based on given session (in CommandParameter)
74 * @param param - command parameter containing the session to refresh
76 protected void refresh(final CommandParameter param
) {
77 Job job
= new Job(Messages
.TraceControl_RetrieveNodeConfigurationJob
) {
80 protected IStatus
run(IProgressMonitor monitor
) {
82 param
.getSession().getConfigurationFromNode(monitor
);
83 } catch (ExecutionException e
) {
84 return new Status(Status
.ERROR
, Activator
.PLUGIN_ID
, Messages
.TraceControl_ListSessionFailure
, e
);
86 return Status
.OK_STATUS
;