Add preferences for LTTng 2.0 tracer control
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / handlers / BaseControlViewHandler.java
index d25f03e709d36295effc11c328d0b4517747becc..f08ce2781f7f0c44b07e46d85f8e4dec031c76ad 100644 (file)
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
 
+import java.util.concurrent.locks.ReentrantLock;
+
 import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchWindow;
@@ -26,6 +35,14 @@ import org.eclipse.ui.PlatformUI;
  */
 abstract public class BaseControlViewHandler extends AbstractHandler {
 
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+    /**
+     * The synchronization lock.
+     */
+    final protected ReentrantLock fLock = new ReentrantLock();
+    
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -51,4 +68,26 @@ abstract public class BaseControlViewHandler extends AbstractHandler {
         }
         return page;
     }
+
+    /**
+     * Refreshes the session information based on given session (in CommandParameter)
+     * @param param - command parameter containing the session to refresh
+     */
+    protected void refresh(final CommandParameter param) {
+        Job job = new Job(Messages.TraceControl_RetrieveNodeConfigurationJob) {
+            
+            @Override
+            protected IStatus run(IProgressMonitor monitor) {
+                try {
+                    param.getSession().getConfigurationFromNode(monitor);
+                } catch (ExecutionException e) {
+                    return new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ListSessionFailure, e);
+                } 
+                return Status.OK_STATUS;
+            }
+        };
+        job.setUser(true);
+        job.schedule();
+    }
+
 }
\ No newline at end of file
This page took 0.024273 seconds and 5 git commands to generate.