Improve package tangle index for LTTng 2.0 control design
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / ControlView.java
index eb0dc3ff94c988bc0111866289701c7240838955..a3765dcfcbd28c43f92a1c84ca68ae1d211f7153 100644 (file)
@@ -13,6 +13,9 @@
 
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control;
 
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
 import org.eclipse.jface.viewers.ISelection;
@@ -20,11 +23,15 @@ import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponentChangedListener;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlContentProvider;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlLabelProvider;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlRoot;
+import org.eclipse.rse.core.RSECorePlugin;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.progress.UIJob;
 
 /**
  * <b><u>ControlView</u></b>
@@ -98,6 +105,8 @@ public class ControlView extends ViewPart implements ITraceControlComponentChang
         createContextMenu();
         
         getSite().setSelectionProvider(fTreeViewer);
+        
+        RSECorePlugin.getTheSystemRegistry(); // to load RSE
     }
 
     /*
@@ -116,7 +125,7 @@ public class ControlView extends ViewPart implements ITraceControlComponentChang
      */
     @Override
     public void componentAdded(ITraceControlComponent parent, ITraceControlComponent component) {
-        componentChanged(component);
+        componentChanged(parent);
     }
 
     /*
@@ -125,7 +134,7 @@ public class ControlView extends ViewPart implements ITraceControlComponentChang
      */
     @Override
     public void componentRemoved(ITraceControlComponent parent, ITraceControlComponent component) {
-        componentChanged(component);
+        componentChanged(parent);
     }
 
     /*
@@ -133,24 +142,33 @@ public class ControlView extends ViewPart implements ITraceControlComponentChang
      * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponentChangedListener#componentChanged(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent)
      */
     @Override
-    public void componentChanged(ITraceControlComponent component) {
+    public void componentChanged(final ITraceControlComponent component) {
         if (fTreeViewer.getTree().isDisposed()) {
             return;
         }
 
-        fTreeViewer.getTree().getDisplay().asyncExec(new Runnable() {
+        UIJob myJob = new UIJob("Refresh") { //$NON-NLS-1$
             @Override
-            public void run() {
+            public IStatus runInUIThread(IProgressMonitor monitor) {
                 if (fTreeViewer.getTree().isDisposed()) {
-                    return;
+                    return Status.OK_STATUS;
                 }
-                fTreeViewer.refresh();
+
+                fTreeViewer.refresh(component);
+
                 // Change selection needed 
                 final ISelection sel = fTreeViewer.getSelection();
                 fTreeViewer.setSelection(null);
                 fTreeViewer.setSelection(sel);
+
+                // Show component that was changed
+                fTreeViewer.reveal(component);
+
+                return Status.OK_STATUS;
             }
-        });
+        };
+        myJob.setUser(false);
+        myJob.schedule();
     }
     
     /**
@@ -158,8 +176,9 @@ public class ControlView extends ViewPart implements ITraceControlComponentChang
      * @param component - component to select
      */
     public void setSelection(ITraceControlComponent component) {
-        StructuredSelection selection = new StructuredSelection(component);
-        fTreeViewer.setSelection(selection);
+        ITraceControlComponent[] components = new ITraceControlComponent[1];
+        components[0] = component;
+        setSelection(components);
     }
 
     /**
@@ -167,18 +186,24 @@ public class ControlView extends ViewPart implements ITraceControlComponentChang
      * @param component - array of components to select
      */
     public void setSelection(ITraceControlComponent[] components) {
-        StructuredSelection selection = new StructuredSelection(components);
-        fTreeViewer.setSelection(selection);
+        final StructuredSelection selection = new StructuredSelection(components);
+        UIJob myJob = new UIJob("Select") { //$NON-NLS-1$
+            @Override
+            public IStatus runInUIThread(IProgressMonitor monitor) {
+                fTreeViewer.setSelection(selection);
+                return Status.OK_STATUS;
+            }
+        };
+        myJob.setUser(false);
+        myJob.schedule();
     }
     
-//    public ITraceControlComponent getSelection() {
-//        ISelection selection = fTreeViewer.getSelection();
-//        
-//    }
-
     // ------------------------------------------------------------------------
     // Helper methods
     // ------------------------------------------------------------------------
+    /**
+     * Creates the context sensitive menu.
+     */
     private void createContextMenu() {
         // First we create a menu Manager
         final MenuManager menuManager = new MenuManager();
This page took 0.026666 seconds and 5 git commands to generate.