gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / views / handlers / BaseControlViewHandler.java
CommitLineData
498704b3 1/**********************************************************************
77735e82 2 * Copyright (c) 2012, 2013 Ericsson
cfdb727a 3 *
498704b3
BH
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
cfdb727a
AM
8 *
9 * Contributors:
498704b3
BH
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
8e8c0226 12package org.eclipse.linuxtools.internal.lttng2.control.ui.views.handlers;
498704b3 13
c56972bb
BH
14import java.util.concurrent.locks.ReentrantLock;
15
498704b3 16import org.eclipse.core.commands.AbstractHandler;
f455db37
BH
17import org.eclipse.core.commands.ExecutionException;
18import org.eclipse.core.runtime.IProgressMonitor;
19import org.eclipse.core.runtime.IStatus;
20import org.eclipse.core.runtime.Status;
21import org.eclipse.core.runtime.jobs.Job;
8e8c0226
AM
22import org.eclipse.linuxtools.internal.lttng2.control.ui.Activator;
23import org.eclipse.linuxtools.internal.lttng2.control.ui.views.ControlView;
24import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages;
498704b3
BH
25import org.eclipse.ui.IWorkbenchPage;
26import org.eclipse.ui.IWorkbenchPart;
27import org.eclipse.ui.IWorkbenchWindow;
28import org.eclipse.ui.PlatformUI;
29
30/**
498704b3
BH
31 * <p>
32 * Abstract Command handler implementation for all control view handlers.
33 * </p>
cfdb727a 34 *
dbd4432d 35 * @author Bernd Hufmann
498704b3 36 */
77735e82 37public abstract class BaseControlViewHandler extends AbstractHandler {
498704b3 38
c56972bb
BH
39 // ------------------------------------------------------------------------
40 // Attributes
41 // ------------------------------------------------------------------------
42 /**
43 * The synchronization lock.
44 */
77735e82 45 protected final ReentrantLock fLock = new ReentrantLock();
cfdb727a 46
498704b3
BH
47 // ------------------------------------------------------------------------
48 // Operations
49 // ------------------------------------------------------------------------
50 /**
51 * @return returns the workbench page for the Control View
52 */
53 protected IWorkbenchPage getWorkbenchPage() {
54 // Check if we are closing down
55 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
56 if (window == null) {
57 return null;
58 }
59
60 // Check if we are in the Project View
61 IWorkbenchPage page = window.getActivePage();
62 if (page == null) {
63 return null;
64 }
65
66 IWorkbenchPart part = page.getActivePart();
67 if (!(part instanceof ControlView)) {
68 return null;
69 }
70 return page;
71 }
f455db37
BH
72
73 /**
74 * Refreshes the session information based on given session (in CommandParameter)
75 * @param param - command parameter containing the session to refresh
76 */
77 protected void refresh(final CommandParameter param) {
78 Job job = new Job(Messages.TraceControl_RetrieveNodeConfigurationJob) {
cfdb727a 79
f455db37
BH
80 @Override
81 protected IStatus run(IProgressMonitor monitor) {
82 try {
83 param.getSession().getConfigurationFromNode(monitor);
84 } catch (ExecutionException e) {
cfdb727a
AM
85 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ListSessionFailure, e);
86 }
f455db37
BH
87 return Status.OK_STATUS;
88 }
89 };
90 job.setUser(true);
91 job.schedule();
92 }
93
498704b3 94}
This page took 0.057433 seconds and 5 git commands to generate.