// JUnit
// ------------------------------------------------------------------------
- /**
- * @throws java.lang.Exception
- */
@BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ public static void setUpBeforeClass() {
}
- /**
- * @throws java.lang.Exception
- */
@AfterClass
- public static void tearDownAfterClass() throws Exception {
+ public static void tearDownAfterClass() {
}
/**
assertTrue("equals", channel1.equals(channel3));
}
- public void testEqualsNull() throws Exception {
+ public void testEqualsNull() {
assertTrue("equals", !fChannelInfo1.equals(null));
assertTrue("equals", !fChannelInfo2.equals(null));
}
assertTrue("equals", channel1.equals(channel3));
}
- public void testEqualsNull() throws Exception {
+ public void testEqualsNull() {
assertTrue("equals", !fDomainInfo1.equals(null));
assertTrue("equals", !fDomainInfo2.equals(null));
}
assertTrue("equals", channel1.equals(channel3));
}
- public void testEqualsNull() throws Exception {
+ public void testEqualsNull() {
assertTrue("equals", !fSessionInfo1.equals(null));
assertTrue("equals", !fSessionInfo2.equals(null));
}
assertTrue("equals", UstProvider1.equals(UstProvider3));
}
- public void testEqualsNull() throws Exception {
+ public void testEqualsNull() {
assertTrue("equals", !fUstProviderInfo1.equals(null));
assertTrue("equals", !fUstProviderInfo2.equals(null));
}
// JUnit
// ------------------------------------------------------------------------
- /**
- * @throws java.lang.Exception
- */
@BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ public static void setUpBeforeClass() {
}
- /**
- * @throws java.lang.Exception
- */
@AfterClass
- public static void tearDownAfterClass() throws Exception {
+ public static void tearDownAfterClass() {
}
/**
// JUnit
// ------------------------------------------------------------------------
- /**
- * @throws java.lang.Exception
- */
@BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ public static void setUpBeforeClass() {
}
- /**
- * @throws java.lang.Exception
- */
@AfterClass
- public static void tearDownAfterClass() throws Exception {
+ public static void tearDownAfterClass() {
}
/**
/**\r
* Redraw state enum\r
*/\r
- private enum State { IDLE, BUSY, PENDING };\r
+ private enum State { IDLE, BUSY, PENDING }\r
\r
// ------------------------------------------------------------------------\r
// Fields\r
/**\r
* Redraw state enum\r
*/\r
- private enum State { IDLE, BUSY, PENDING };\r
+ private enum State { IDLE, BUSY, PENDING }\r
\r
// ------------------------------------------------------------------------\r
// Fields\r
// JUnit
// ------------------------------------------------------------------------
- /**
- * @throws java.lang.Exception
- */
@BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ public static void setUpBeforeClass() {
}
- /**
- * @throws java.lang.Exception
- */
@AfterClass
- public static void tearDownAfterClass() throws Exception {
+ public static void tearDownAfterClass() {
}
/**
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.eclipse.core.commands.ExecutionException;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState;
import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
* The class <code>TraceControlComponentTest</code> contains tests for the class <code>{@link TraceControlComponent}</code>.
*
*/
-@SuppressWarnings({"nls", "javadoc"})
+@SuppressWarnings("nls")
public class TraceControlComponentTest extends TestCase {
// ------------------------------------------------------------------------
/**
* Run the TraceControlComponent(String) constructor test.
*/
- public void testTraceControlComponent_1()
- throws Exception {
+ public void testTraceControlComponent_1() {
String name = "node";
/**
* Run the TraceControlComponent(String,ITraceControlComponent) constructor test.
- *
*/
- public void testTraceControlComponent_2()
- throws Exception {
+ public void testTraceControlComponent_2() {
String name = "node";
ITraceControlComponent parent = new TraceControlRoot();
/**
* Run the void addChild(ITraceControlComponent) method test.
- *
- * @throws Exception
- *
*/
- public void testAddAndGetChild1()
- throws Exception {
+ public void testAddAndGetChild1() {
TraceControlComponent fixture = new TraceControlComponent("node", new TraceControlRoot());
fixture.setToolTip("This is the test node");
fixture.addChild(new TraceControlRoot());
/**
* Run the void addChild(ITraceControlComponent) method test.
- *
- * @throws Exception
- *
*/
- public void testAddAndGetChild2()
- throws Exception {
+ public void testAddAndGetChild2() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
ITraceControlComponent component = null;
/**
* Run the void addComponentListener(ITraceControlComponentChangedListener) method test.
- *
- * @throws Exception
- *
*/
-
- public void testAddComponentListener_1()
- throws Exception {
+ public void testAddComponentListener_1() {
TraceControlComponent fixture = new TraceControlComponent("", (ITraceControlComponent) null);
fixture.setToolTip("");
/**
* Run the boolean containsChild(String) method test.
- *
- * @throws Exception
- *
*/
- public void testContainsChild_1()
- throws Exception {
+ public void testContainsChild_1() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
fixture.addChild(new TraceControlRoot());
/**
* Run the boolean containsChild(String) method test.
- *
- * @throws Exception
- *
*/
- public void testContainsChild_2()
- throws Exception {
+ public void testContainsChild_2() {
TraceControlComponent fixture = new TraceControlComponent("name", new TraceControlRoot());
fixture.setToolTip("");
* Run the void fireCompenentAdded(ITraceControlComponent,ITraceControlComponent) method test.
* Run the void fireCompenentRemoved(ITraceControlComponent,ITraceControlComponent) method test.
* Run the void fireCompenentChanged(ITraceControlComponent) method test
- *
- * @throws Exception
- *
*/
-
- public void testFireCompenentUpdated()
- throws Exception {
+ public void testFireCompenentUpdated() {
ITraceControlComponent parent = new TraceControlRoot();
TraceControlComponent fixture = new TraceControlComponent("node", parent);
/**
* Run the Object getAdapter(Class) method test.
- *
- * @throws Exception
- *
*/
-
- public void testGetAdapter()
- throws Exception {
+ public void testGetAdapter() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
fixture.addChild(new TraceControlRoot());
/**
* Run the ITraceControlComponent[] getChildren() method test.
- *
- * @throws Exception
- *
*/
- public void testGetChildren_1()
- throws Exception {
+ public void testGetChildren_1() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
fixture.addChild(new TraceControlRoot());
}
/**
- * Run the ILttngControlService getControlService()/setControlService() method test.
- *
- * @throws Exception
+ * Run the ILttngControlService getControlService()/setControlService()
+ * method test.
*
+ * @throws ExecutionException
+ * Would fail the test
*/
- public void testGetAndSetControlService_1()
- throws Exception {
+ public void testGetAndSetControlService_1() throws ExecutionException {
TraceControlComponent parent = new TraceControlComponent("parent") {
ILttngControlService fService = null;
/**
* Run the Image getImage() method test.
- *
- * @throws Exception
- *
*/
- public void testGetImage_1()
- throws Exception {
+ public void testGetImage_1() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
fixture.addChild(new TraceControlRoot());
/**
* Run the boolean hasChildren() method test.
- *
- * @throws Exception
- *
*/
- public void testHasChildren_1()
- throws Exception {
+ public void testHasChildren_1() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
fixture.addChild(new TraceControlRoot());
/**
* Run the boolean hasChildren() method test.
- *
- * @throws Exception
- *
*/
- public void testHasChildren_2()
- throws Exception {
+ public void testHasChildren_2() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
/**
* Run the void removeAllChildren() method test.
- *
- * @throws Exception
- *
*/
- public void testRemoveAllChildren_2()
- throws Exception {
+ public void testRemoveAllChildren_2() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
/**
* Run the void removeChild(ITraceControlComponent) method test.
- *
- * @throws Exception
- *
*/
- public void testRemoveChild_1()
- throws Exception {
+ public void testRemoveChild_1() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
TraceControlComponent child = new TraceControlComponent("child", fixture);
/**
* Run the void removeChild(ITraceControlComponent) method test.
- *
- * @throws Exception
- *
*/
-
- public void testRemoveChild_2()
- throws Exception {
+ public void testRemoveChild_2() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
fixture.addChild(new TraceControlRoot());
/**
* Run the void removeComponentListener(ITraceControlComponentChangedListener) method test.
- *
- * @throws Exception
- *
*/
- public void testRemoveComponentListener_1()
- throws Exception {
+ public void testRemoveComponentListener_1() {
TraceControlComponent fixture = new TraceControlComponent("", (ITraceControlComponent) null);
fixture.setToolTip("");
/**
* Run the void removeComponentListener(ITraceControlComponentChangedListener) method test.
- *
- * @throws Exception
- *
*/
- public void testRemoveComponentListener_2()
- throws Exception {
+ public void testRemoveComponentListener_2() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
fixture.addChild(new TraceControlRoot());
/**
* Run the void setChildren(List<ITraceControlComponent>)/ITraceControlComponent[] getChildren() method test.
- *
- *
- * @throws Exception
- *
*/
- public void testGetAndSetChildren()
- throws Exception {
+ public void testGetAndSetChildren() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
List<ITraceControlComponent> children = new LinkedList<ITraceControlComponent>();
/**
* Run the void String getName()/setName(String) method tests.
- *
- * @throws Exception
- *
*/
- public void testGetAndSetName()
- throws Exception {
+ public void testGetAndSetName() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
fixture.addChild(new TraceControlRoot());
/**
* Run the void ITraceControlComponent getParent()/setParent(ITraceControlComponent) method tests.
- *
- * @throws Exception
- *
*/
- public void testGetAndSetParent()
- throws Exception {
+ public void testGetAndSetParent() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("");
fixture.addChild(new TraceControlRoot());
/**
* Run the void TargetNodeState getTargetNodeState()/etTargetNodeState(TargetNodeState) method tests.
- *
- * @throws Exception
- *
*/
- public void testGetAndSetTargetNodeState_1()
- throws Exception {
-
+ public void testGetAndSetTargetNodeState_1() {
TraceControlComponent parent = new TraceControlComponent("parent") {
private TargetNodeState fState;
/**
* Run the void setToolTip(String) method test.
- *
- * @throws Exception
- *
-
*/
-
- public void testGetSndSetToolTip()
- throws Exception {
+ public void testGetSndSetToolTip() {
TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
fixture.setToolTip("This is a tooltip");
fixture.addChild(new TraceControlRoot());
if (domain != null) {
fChannels = domain.getChannels();
- String items[] = new String[fChannels.length];
- for (int i = 0; i < items.length; i++) {
- items[i] = String.valueOf(fChannels[i].getName());
+ String selectionItems[] = new String[fChannels.length];
+ for (int i = 0; i < selectionItems.length; i++) {
+ selectionItems[i] = String.valueOf(fChannels[i].getName());
}
- fChannelsCombo.setItems(items);
+ fChannelsCombo.setItems(selectionItems);
fChannelsCombo.setEnabled(fChannels.length > 0);
} else {
fChannelsCombo.setItems(new String[0]);
List<BaseEventComponent> events = param.getEvents();
// Create list of event names
for (Iterator<BaseEventComponent> iterator = events.iterator(); iterator.hasNext();) {
- BaseEventComponent event = iterator.next();
- eventNames.add(event.getName());
+ BaseEventComponent baseEvent = iterator.next();
+ eventNames.add(baseEvent.getName());
}
TraceChannelComponent channel = dialog.getChannel();
Job addJob = new Job(Messages.TraceControl_AddContextJob) {
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ protected IStatus run(IProgressMonitor monitor2) {
Exception error = null;
try {
List<String> contextNames = dialog.getContexts();
- addContexts(param, contextNames, monitor);
+ addContexts(param, contextNames, monitor2);
} catch (ExecutionException e) {
error = e;
for (Iterator<TraceEventComponent> iterator = events.iterator(); iterator.hasNext();) {
// Enable/disable all selected channels which are disabled
- TraceEventComponent event = iterator.next();
+ TraceEventComponent traceEvent = iterator.next();
// Workaround for wildcard handling in lttng-tools
- if ("*".equals(event.getName())) { //$NON-NLS-1$
+ if ("*".equals(traceEvent.getName())) { //$NON-NLS-1$
isAll = true;
} else {
- eventNames.add(event.getName());
+ eventNames.add(traceEvent.getName());
}
}
if (isAll) {
/**********************************************************************
* Copyright (c) 2012 Ericsson and others
- *
+ *
* 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
* Anna Dushistova(Montavista) - [382684] Allow reusing already defined connections that have Files and Shells subsystems
**********************************************************************/
* <p>
* Command handler for creation new connection for trace control.
* </p>
- *
+ *
* @author Bernd Hufmann
*/
public class NewConnectionHandler extends BaseControlViewHandler {
// Constants
// ------------------------------------------------------------------------
/**
- * The trace control system type defined for LTTng version 2.0 and later.
+ * The trace control system type defined for LTTng version 2.0 and later.
*/
public final static String TRACE_CONTROL_SYSTEM_TYPE = "org.eclipse.linuxtools.internal.lttng2.ui.control.systemType"; //$NON-NLS-1$
// Attributes
// ------------------------------------------------------------------------
/**
- * The parent trace control component the new node will be added to.
+ * The parent trace control component the new node will be added to.
*/
private ITraceControlComponent fRoot = null;
}
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
-
+
// get system type definition for LTTng 2.x connection
IRSESystemType sysType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(TRACE_CONTROL_SYSTEM_TYPE);
-
+
// get all hosts for this system type
IHost[] hosts = getSuitableHosts();
return null;
}
- String hostName = dialog.getConnectionName();
+ String hostName = dialog.getConnectionName();
String hostAddress = dialog.getHostName();
// get the singleton RSE registry
host = registry.createHost(
sysType, //System Type Name
hostName, //Connection name
- hostAddress, //IP Address
+ hostAddress, //IP Address
"Connection to Host"); //description //$NON-NLS-1$
}
catch (Exception e) {
return null;
}
}
-
+
if (host != null) {
fLock.lock();
try {
return null;
}
+ private static IHost[] getSuitableHosts() {
+ // need shells and files
+ ArrayList<IHost> result = new ArrayList<IHost>();
+ ArrayList<IHost> shellConnections = new ArrayList<IHost>(
+ Arrays.asList(RSECorePlugin.getTheSystemRegistry()
+ .getHostsBySubSystemConfigurationCategory("shells"))); //$NON-NLS-1$
+
+ for (IHost connection : shellConnections) {
+ if (!connection.getSystemType().isLocal()) {
+ ISubSystem[] subSystems = connection.getSubSystems();
+ for (int i = 0; i < subSystems.length; i++) {
+ if (subSystems[i] instanceof IFileServiceSubSystem) {
+ result.add(connection);
+ break;
+ }
+ }
+ }
+ }
- private IHost[] getSuitableHosts() {
- //need shells and files
- ArrayList<IHost> result = new ArrayList<IHost>();
- ArrayList<IHost> shellConnections = new ArrayList<IHost>(Arrays.asList(RSECorePlugin.getTheSystemRegistry()
- .getHostsBySubSystemConfigurationCategory("shells"))); //$NON-NLS-1$
-
- for(IHost connection:shellConnections){
- if(!connection.getSystemType().isLocal()){
- ISubSystem[] subSystems = connection.getSubSystems();
- for (int i = 0; i < subSystems.length; i++) {
- if (subSystems[i] instanceof IFileServiceSubSystem){
- result.add(connection);
- break;
- }
- }
- }
- }
-
- return (IHost[]) result.toArray(new IHost[result.size()]);
- }
-
+ return result.toArray(new IHost[result.size()]);
+ }
/*
* (non-Javadoc)
*/
@Override
public boolean isEnabled() {
-
+
// Get workbench page for the Control View
IWorkbenchPage page = getWorkbenchPage();
if (page == null) {
ITraceControlComponent root = null;
// no need to verify part because it has been already done in getWorkbenchPage()
- IWorkbenchPart part = page.getActivePart();
+ IWorkbenchPart part = page.getActivePart();
root = ((ControlView) part).getTraceControlRoot();
-
+
boolean isEnabled = root != null;
-
+
fLock.lock();
try {
fRoot = null;
} finally {
fLock.unlock();
}
-
+
return isEnabled;
}
}
/**********************************************************************
* 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;
* <p>
* Implementation of the base trace event component.
* </p>
- *
+ *
* @author Bernd Hufmann
*/
public class BaseEventComponent extends TraceControlComponent {
* Path to icon file for this component.
*/
public static final String TRACE_EVENT_ICON_FILE_ENABLED = "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
-
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
/**
- * The Event information implementation.
+ * The Event information implementation.
*/
private IBaseEventInfo fEventInfo;
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
-
+
/**
- * Constructor
+ * Constructor
* @param name - the name of the component.
* @param parent - the parent of this component.
*/
setImage(TRACE_EVENT_ICON_FILE_ENABLED);
fEventInfo = new EventInfo(name);
}
-
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
public void setEventInfo(IBaseEventInfo eventInfo) {
fEventInfo = eventInfo;
}
-
+
/**
* @return the event type.
*/
public TraceEventType getEventType() {
return fEventInfo.getEventType();
}
-
+
/**
* Sets the event type to the given value.
* @param type - type to set.
public void setEventType(TraceEventType type) {
fEventInfo.setEventType(type);
}
-
+
/**
* Sets the event type to the value specified by the give name.
* @param typeName - the type name.
public TraceLogLevel getLogLevel() {
return fEventInfo.getLogLevel();
}
-
+
/**
- * Sets the trace event log level to the given level
+ * Sets the trace event log level to the given level
* @param level - event log level to set
*/
public void setLogLevel(TraceLogLevel level) {
fEventInfo.setLogLevel(level);
}
-
+
/**
* Sets the trace event log level to the level specified by the given name.
* @param levelName - event log level name
* (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 BaseEventPropertySource(this);
}
return null;
- }
+ }
/**
- * @return target node component.
+ * @return target node component.
*/
public TargetNodeComponent getTargetNode() {
return (TargetNodeComponent) getParent().getParent();
* (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) {
* (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) {
* (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) {
* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
- @SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class adapter) {
return null;
* (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) {
* (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) {
/**********************************************************************
* 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;
* <p>
* Implementation of the trace channel component.
* </p>
- *
+ *
* @author Bernd Hufmann
*/
public class TraceProbeEventComponent extends TraceEventComponent {
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
-
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
/**
- * Constructor
+ * Constructor
* @param name - the name of the component.
* @param parent - the parent of this component.
- */
+ */
public TraceProbeEventComponent(String name, ITraceControlComponent parent) {
super(name, parent);
fEventInfo = new ProbeEventInfo(name);
}
-
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
}
throw new IllegalArgumentException("Invalid type passed. Only class of type ProbeEventInfo allowed:\n" + eventInfo.getClass()); //$NON-NLS-1$
}
-
+
/*
* (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) {
public void setSymbol(String symbol) {
getEventInfo().setSymbol(symbol);
}
-
+
// ------------------------------------------------------------------------
// Helper methods
// ------------------------------------------------------------------------
* (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) {
/**********************************************************************
* 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
**********************************************************************/
* <p>
* Implementation of the UST provider component.
* </p>
- *
+ *
* @author Bernd Hufmann
*/
public class UstProviderComponent extends TraceControlComponent {
-
+
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
* Path to icon file for this component.
*/
public static final String USTL_PROVIDER_ICON_FILE = "icons/obj16/targets.gif"; //$NON-NLS-1$
-
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
* The UST provider information.
*/
private IUstProviderInfo fProviderInfo = null;
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
/**
- * Constructor
+ * Constructor
* @param name - the name of the component.
* @param parent - the parent of this component.
- */
+ */
public UstProviderComponent(String name, ITraceControlComponent parent) {
super(name, parent);
setImage(USTL_PROVIDER_ICON_FILE);
// Accessors
// ------------------------------------------------------------------------
/**
- * Sets the UST provider information to the given value.
+ * Sets the UST provider information to the given value.
* @param providerInfo - the provider information to set
*/
public void setUstProvider(IUstProviderInfo providerInfo) {
}
setName(getName() + " [PID=" + fProviderInfo.getPid() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
* @return the process ID of the UST provider.
*/
* (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 UstProviderPropertySource(this);
}
return null;
- }
-
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
-
+
}
/**********************************************************************
* 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:
* Patrick Tasse - Initial API and implementation
* Bernd Hufmann - Updated using Executor Framework
**********************************************************************/
/**
* <p>
- * Implementation of remote command execution using RSE's shell service.
+ * Implementation of remote command execution using RSE's shell service.
* </p>
*
* @author Patrick Tasse
/** Sub-string to be echo'ed when running command in shell, used to indicate that the command has finished running */
public final static String DONE_MARKUP_STRING = "--RSE:donedonedone:--"; //$NON-NLS-1$
-
- /** Sub-string to be echoed when running a command in shell. */
+
+ /** Sub-string to be echoed when running a command in shell. */
public final static String BEGIN_END_TAG = "BEGIN-END-TAG:"; //$NON-NLS-1$
-
+
/** Command delimiter for shell */
public final static String CMD_DELIMITER = "\n"; //$NON-NLS-1$
/** Shell "echo" command */
public final static String SHELL_ECHO_CMD = " echo "; //$NON-NLS-1$
-
+
/** Default command separator */
public final static char CMD_SEPARATOR = ';';
private IHostShell fHostShell = null;
private BufferedReader fInputBufferReader = null;
private BufferedReader fErrorBufferReader = null;
- private ExecutorService fExecutor = Executors.newFixedThreadPool(1);
+ private final ExecutorService fExecutor = Executors.newFixedThreadPool(1);
private boolean fIsConnected = false;
- private Random fRandom = new Random(System.currentTimeMillis());;
+ private final Random fRandom = new Random(System.currentTimeMillis());
private int fReturnValue;
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+
+ /**
+ * Create a new command shell
+ *
+ * @param proxy
+ * The RSE proxy for this shell
+ */
public CommandShell(IRemoteSystemProxy proxy) {
fProxy = proxy;
}
@Override
public CommandResult call() throws IOException, CancellationException {
final ArrayList<String> result = new ArrayList<String>();
-
+
synchronized (fHostShell) {
// Initialize return value which will be updated in isAliasEchoResult()
fReturnValue = 0;
int startAlias = fRandom.nextInt();
int endAlias = fRandom.nextInt();
fHostShell.writeToShell(formatShellCommand(command, startAlias, endAlias));
-
+
String nextLine;
boolean isStartFound = false;
while ((nextLine = fInputBufferReader.readLine()) != null) {
if (monitor.isCanceled()) {
flushInput();
- throw new CancellationException();
+ throw new CancellationException();
}
- // check if line contains echoed start alias
+ // check if line contains echoed start alias
if (isAliasEchoResult(nextLine, startAlias, true)) {
isStartFound = true;
continue;
}
- // check if line contains is the end mark-up. This will retrieve also
- // the return value of the actual command.
+ // check if line contains is the end mark-up. This will retrieve also
+ // the return value of the actual command.
if (isAliasEchoResult(nextLine, endAlias, false)) {
break;
}
result.add(nextLine);
}
- // Read any left over output
+ // Read any left over output
flushInput();
-
+
// Read error stream output when command failed.
- if (fReturnValue != 0) {
+ if (fReturnValue != 0) {
while(fErrorBufferReader.ready()) {
if ((nextLine = fErrorBufferReader.readLine()) != null) {
result.add(nextLine);
/**
* Format the command to be sent into the shell command with start and end marker strings.
- * The start marker is need to know when the actual command output starts. The end marker
+ * The start marker is need to know when the actual command output starts. The end marker
* string is needed so we can tell that end of output has been reached.
- *
- * @param cmd The actual command
+ *
+ * @param cmd The actual command
* @param startAlias The command alias for start marker
* @param endAlias The command alias for end marker
* @return formatted command string
*/
- private String formatShellCommand(String cmd, int startAlias, int endAlias) {
+ private static String formatShellCommand(String cmd, int startAlias, int endAlias) {
if (cmd == null || cmd.equals("")) { //$NON-NLS-1$
return cmd;
}
StringBuffer formattedCommand = new StringBuffer();
- // Make multi-line command.
+ // Make multi-line command.
// Wrap actual command with start marker and end marker to wrap actual command.
formattedCommand.append(getEchoCmd(startAlias));
formattedCommand.append(CMD_DELIMITER);
formattedCommand.append(CMD_DELIMITER);
return formattedCommand.toString();
}
-
+
/**
* Creates a echo command line in the format: echo <start tag> <alias> <end tag> $?
- *
+ *
* @param alias The command alias integer to be included in the echoed message.
* @return the echo command line
*/
- private String getEchoCmd(int alias) {
+ private static String getEchoCmd(int alias) {
return SHELL_ECHO_CMD + getEchoResult(alias) + "$?"; //$NON-NLS-1$
}
/**
- * Creates the expected result for a given command alias:
+ * Creates the expected result for a given command alias:
* <start tag> <alias> <end tag> $?
- *
+ *
* @param alias The command alias integer to be included in the echoed message.
* @return the expected echo result
*/
- private String getEchoResult(int alias) {
+ private static String getEchoResult(int alias) {
return BEGIN_END_TAG + String.valueOf(alias) + DONE_MARKUP_STRING;
}
-
+
/**
* Verifies if given command line contains a command alias echo result.
- *
+ *
* @param line The output line to test.
* @param alias The command alias
* @param checkReturnValue <code>true</code> to retrieve command result (previous command) <code>false</code>
}
}
return true;
- } else {
- int index = line.indexOf(expected);
- if (index > 0) {
- if (line.indexOf(SHELL_ECHO_CMD) == -1) {
- return true;
- }
+ }
+ int index = line.indexOf(expected);
+ if (index > 0) {
+ if (line.indexOf(SHELL_ECHO_CMD) == -1) {
+ return true;
}
}
return false;
}
-
+
/**
- * Verifies if output line is an echo of the given command line. If the output line is longer then
- * the maximum line lengths (e.g. for ssh), the shell adds a line break character. This
- * method takes this in consideration by comparing the command line without any whitespaces.
- *
- * @param line The output line to verify
- * @param cmd The command executed
- * @return <code>true</code> if it's an echoed command line else <code>false</code>
+ * Verifies if output line is an echo of the given command line. If the
+ * output line is longer then the maximum line lengths (e.g. for ssh), the
+ * shell adds a line break character. This method takes this in
+ * consideration by comparing the command line without any whitespaces.
+ *
+ * @param line
+ * The output line to verify
+ * @param cmd
+ * The command executed
+ * @return <code>true</code> if it's an echoed command line else
+ * <code>false</code>
*/
@SuppressWarnings("nls")
- private boolean isCommandEcho(String line, String cmd) {
+ private static boolean isCommandEcho(String line, String cmd) {
String s1 = line.replaceAll("\\s","");
String s2 = cmd.replaceAll("\\s","");
- s2 = s2.replaceAll("(\\*)", "(\\\\*)");
+ s2 = s2.replaceAll("(\\*)", "(\\\\*)");
String patternStr = ".*(" + s2 +")$";
return s1.matches(patternStr);
}
/**
* Formats the output string as single string.
*
- * @param output
+ * @param result
* - output array
* @return - the formatted output
*/