Update internal packages export in LTTng 2.0 control + update java doc
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / handlers / BaseControlViewHandler.java
1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
13
14 import java.util.concurrent.locks.ReentrantLock;
15
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.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;
29
30 /**
31 * <p>
32 * Abstract Command handler implementation for all control view handlers.
33 * </p>
34 *
35 * @author Bernd Hufmann
36 */
37 abstract public class BaseControlViewHandler extends AbstractHandler {
38
39 // ------------------------------------------------------------------------
40 // Attributes
41 // ------------------------------------------------------------------------
42 /**
43 * The synchronization lock.
44 */
45 final protected ReentrantLock fLock = new ReentrantLock();
46
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 }
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) {
79
80 @Override
81 protected IStatus run(IProgressMonitor monitor) {
82 try {
83 param.getSession().getConfigurationFromNode(monitor);
84 } catch (ExecutionException e) {
85 return new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ListSessionFailure, e);
86 }
87 return Status.OK_STATUS;
88 }
89 };
90 job.setUser(true);
91 job.schedule();
92 }
93
94 }
This page took 0.04458 seconds and 5 git commands to generate.