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;
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;
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;
* 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.
*/
/**
* 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();
}
fService = null;
final ICommandShell shell = fShell;
if (shell != null) {
- shell.disconnect();
+ shell.dispose();
fShell = null;
}
}
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;
}
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
// ------------------------------------------------------------------------
@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);
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;