ctf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / model / impl / TargetNodeComponent.java
index 8ffdfc6d9841f70fe1f4ffec41b47fe502c7c471..8991cde3c9ab6152ae9674248e601d1c4c5d83cb 100644 (file)
@@ -15,6 +15,7 @@
 package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl;
 
 import static java.text.MessageFormat.format;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import java.util.List;
 
@@ -25,6 +26,7 @@ import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.IJobChangeEvent;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jface.dialogs.ErrorDialog;
 import org.eclipse.remote.core.IRemoteConnection;
 import org.eclipse.remote.core.IRemoteConnectionChangeListener;
@@ -36,11 +38,10 @@ import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TargetNodePropertySource;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.remote.ICommandShell;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.remote.IRemoteSystemProxy;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.remote.RemoteSystemProxy;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.ILttngControlService;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceFactory;
+import org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy;
+import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandShell;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.views.properties.IPropertySource;
 
@@ -80,14 +81,10 @@ public class TargetNodeComponent extends TraceControlComponent implements IRemot
      * The image to be displayed in state disconnected.
      */
     private Image fDisconnectedImage = null;
-    /**
-     * The connection implementation.
-     */
-    private IRemoteConnection fHost = null;
     /**
      * The remote proxy implementation.
      */
-    private IRemoteSystemProxy fRemoteProxy = null;
+    private @NonNull RemoteSystemProxy fRemoteProxy;
     /**
      * The control service for LTTng specific commands.
      */
@@ -103,34 +100,40 @@ public class TargetNodeComponent extends TraceControlComponent implements IRemot
 
     /**
      * Constructor
-     * @param name - the name of the component
-     * @param parent - the parent of the component
-     * @param host - the host connection implementation
-     * @param proxy - the remote proxy implementation
+     *
+     * @param name
+     *            the name of the component
+     * @param parent
+     *            the parent of the component
+     * @param proxy
+     *            the remote proxy implementation
      */
-    public TargetNodeComponent(String name, ITraceControlComponent parent, IRemoteConnection host, IRemoteSystemProxy proxy) {
+    public TargetNodeComponent(String name, ITraceControlComponent parent, @NonNull RemoteSystemProxy proxy) {
         super(name, parent);
         setImage(TARGET_NODE_CONNECTED_ICON_FILE);
         fDisconnectedImage = Activator.getDefault().loadIcon(TARGET_NODE_DISCONNECTED_ICON_FILE);
-        fHost = host;
         fRemoteProxy = proxy;
-        fRemoteProxy.addConnectionChangeListener(this);
-        setToolTip(fHost.getName());
+        fRemoteProxy.getRemoteConnection().addConnectionChangeListener(this);
+        setToolTip(fRemoteProxy.getRemoteConnection().getName());
     }
 
     /**
      * Constructor (using default proxy)
-     * @param name - the name of the component
-     * @param parent - the parent of the component
-     * @param host - the host connection implementation
+     *
+     * @param name
+     *            the name of the component
+     * @param parent
+     *            the parent of the component
+     * @param host
+     *            the host connection implementation
      */
-    public TargetNodeComponent(String name, ITraceControlComponent parent, IRemoteConnection host) {
-        this(name, parent, host, new RemoteSystemProxy(host));
+    public TargetNodeComponent(String name, ITraceControlComponent parent, @NonNull IRemoteConnection host) {
+        this(name, parent, new RemoteSystemProxy(host));
     }
 
     @Override
     public void dispose() {
-        fRemoteProxy.removeConnectionChangeListener(this);
+        fRemoteProxy.getRemoteConnection().removeConnectionChangeListener(this);
         fRemoteProxy.dispose();
         disposeControlService();
     }
@@ -139,7 +142,7 @@ public class TargetNodeComponent extends TraceControlComponent implements IRemot
         fService = null;
         final ICommandShell shell = fShell;
         if (shell != null) {
-            shell.disconnect();
+            shell.dispose();
             fShell = null;
         }
     }
@@ -185,17 +188,10 @@ public class TargetNodeComponent extends TraceControlComponent implements IRemot
         return null;
     }
 
-    /**
-     * @return the remote connection associated with this node
-     */
-    public IRemoteConnection getRemoteConnection() {
-        return fHost;
-    }
-
     /**
      * @return remote system proxy implementation
      */
-    public IRemoteSystemProxy getRemoteSystemProxy() {
+    public @NonNull RemoteSystemProxy getRemoteSystemProxy() {
         return fRemoteProxy;
     }
 
@@ -288,6 +284,16 @@ public class TargetNodeComponent extends TraceControlComponent implements IRemot
         return !getControlService().isVersionSupported("2.2.0"); //$NON-NLS-1$
     }
 
+    /**
+     * Checks if given version is supported by this ILTTngControlService implementation.
+     *
+     * @param version The version to check
+     * @return <code>true</code> if version is supported else <code>false</code>
+     */
+    public boolean isVersionSupported(String version) {
+        return getControlService().isVersionSupported(version);
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -322,7 +328,7 @@ public class TargetNodeComponent extends TraceControlComponent implements IRemot
                     @Override
                     protected IStatus run(IProgressMonitor monitor) {
                         try {
-                            fRemoteProxy.connect(monitor);
+                            fRemoteProxy.connect(checkNotNull(monitor));
                             return Status.OK_STATUS;
                         } catch (Exception e) {
                             return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ConnectionFailure, e);
@@ -418,8 +424,9 @@ public class TargetNodeComponent extends TraceControlComponent implements IRemot
     private ILttngControlService createControlService() throws ExecutionException {
         if (fService == null) {
             try {
-                fShell = fRemoteProxy.createCommandShell();
-                fService = LTTngControlServiceFactory.getInstance().getLttngControlService(fShell);
+                ICommandShell shell = fRemoteProxy.createCommandShell();
+                fShell = shell;
+                fService = LTTngControlServiceFactory.getLttngControlService(shell);
             } catch (ExecutionException e) {
                 disposeControlService();
                 throw e;
This page took 0.027755 seconds and 5 git commands to generate.