/**********************************************************************
* Copyright (c) 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* Bernd Hufmann - Initial API and implementation
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
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.core.control.model.TargetNodeState;
import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TargetNodeState;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TargetNodePropertySource;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.ICommandShell;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.RemoteSystemProxy;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandShell;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlService;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlServiceFactory;
+import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.IRSECallback;
+import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.CommunicationsEvent;
import org.eclipse.rse.core.subsystems.ICommunicationsListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.properties.IPropertySource;
/**
- * <b><u>TargetNodeComponent</u></b>
* <p>
* Implementation of the trace node component.
* </p>
+ *
+ * @author Bernd Hufmann
*/
public class TargetNodeComponent extends TraceControlComponent implements ICommunicationsListener {
// Constructors
// ------------------------------------------------------------------------
/**
- * Constructor
+ * Constructor
* @param name - the name of the component
* @param parent - the parent of the component
* @param host - the host connection implementation
}
/**
- * Constructor (using default proxy)
+ * Constructor (using default proxy)
* @param name - the name of the component
* @param parent - the parent of the component
* @param host - the host connection implementation
}
return fDisconnectedImage;
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getTargetNodeState()
public TargetNodeState getTargetNodeState() {
return fState;
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#setTargetNodeState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent.TargetNodeState)
fState = state;
fireComponentChanged(TargetNodeComponent.this);
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getControlService()
*/
@Override
public void setControlService(ILttngControlService service) {
- fService = (ILttngControlService)service;
+ fService = service;
}
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
*/
- @SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class adapter) {
if (adapter == IPropertySource.class) {
return new TargetNodePropertySource(this);
}
return null;
- }
-
+ }
+
/**
* @return remote host name
*/
public TraceSessionComponent[] getSessions() {
List<ITraceControlComponent> compenents = getChildren(TraceSessionGroup.class);
if (compenents.size() > 0) {
- TraceSessionGroup group = (TraceSessionGroup)compenents.get(0);
+ TraceSessionGroup group = (TraceSessionGroup)compenents.get(0);
List<ITraceControlComponent> sessions = group.getChildren(TraceSessionComponent.class);
- return (TraceSessionComponent[])sessions.toArray(new TraceSessionComponent[sessions.size()]);
+ return sessions.toArray(new TraceSessionComponent[sessions.size()]);
}
return new TraceSessionComponent[0];
}
-
+
+ /**
+ * @return node version
+ */
+ public String getNodeVersion() {
+ // Control service is null during connection to node
+ if (getControlService() != null) {
+ return getControlService().getVersion();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
-
+
/*
* @see org.eclipse.rse.core.subsystems.ICommunicationsListener#communicationsStateChange(org.eclipse.rse.core.subsystems.CommunicationsEvent)
*/
});
} catch (Exception e) {
setTargetNodeState(TargetNodeState.DISCONNECTED);
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ConnectionFailure + " (" + getName() + "). \n" + e)); //$NON-NLS-1$ //$NON-NLS-2$
+ Activator.getDefault().logError(Messages.TraceControl_ConnectionFailure + " (" + getName() + "). \n", e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
setTargetNodeState(TargetNodeState.DISCONNECTING);
fRemoteProxy.disconnect();
} catch (Exception e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_DisconnectionFailure + " (" + getName() + "). \n" + e)); //$NON-NLS-1$ //$NON-NLS-2$
+ Activator.getDefault().logError(Messages.TraceControl_DisconnectionFailure + " (" + getName() + "). \n", e); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
- handleDisconnected();
+ handleDisconnected();
}
}
}
/**
- * Retrieves the trace configuration from the target node and populates the information
- * in the tree model. The execution is done in a own job.
- *
- * @throws ExecutionException
+ * Retrieves the trace configuration from the target node and populates the
+ * information in the tree model. The execution is done in a own job.
*/
public void getConfigurationFromNode() {
Job job = new Job(Messages.TraceControl_RetrieveNodeConfigurationJob) {
TraceProviderGroup providerGroup = new TraceProviderGroup(Messages.TraceControl_ProviderDisplayName, TargetNodeComponent.this);
addChild(providerGroup);
providerGroup.getProviderFromNode(monitor);
-
+
// Get session information from node
TraceSessionGroup sessionGroup = new TraceSessionGroup(Messages.TraceControl_AllSessionsDisplayName, TargetNodeComponent.this);
addChild(sessionGroup);
sessionGroup.getSessionsFromNode(monitor);
} catch (ExecutionException e) {
removeAllChildren();
- return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
- }
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ListSessionFailure, e);
+ }
return Status.OK_STATUS;
}
job.schedule();
}
+ /**
+ * Refresh the node configuration
+ */
public void refresh() {
removeAllChildren();
getConfigurationFromNode();
}
+ /**
+ * Deregisters host from registry.
+ */
+ public void deregister() {
+ ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
+ registry.deleteHost(fHost);
+ }
+
// ------------------------------------------------------------------------
// Helper function
// ------------------------------------------------------------------------
fShell = fRemoteProxy.createCommandShell();
fRemoteProxy.addCommunicationListener(this);
}
- fService = new LTTngControlService(fShell);
+ fService = LTTngControlServiceFactory.getInstance().getLttngControlService(fShell);
return fService;
}
/**
- * Handles the connected event.
+ * Handles the connected event.
*/
private void handleConnected() {
setTargetNodeState(TargetNodeState.CONNECTED);
createControlService();
getConfigurationFromNode();
} catch (ExecutionException e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ListSessionFailure + " (" + getName() + "). \n" + e)); //$NON-NLS-1$ //$NON-NLS-2$
+ Activator.getDefault().logError(Messages.TraceControl_ListSessionFailure + " (" + getName() + "). \n", e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
/**
- * Handles the disconnected event.
+ * Handles the disconnected event.
*/
private void handleDisconnected() {
removeAllChildren();