org.eclipse.ui;bundle-version="3.7.0",
org.eclipse.core.resources;bundle-version="3.7.0",
org.eclipse.core.runtime;bundle-version="3.7.0",
- org.eclipse.rse.core;bundle-version="3.2.0",
- org.eclipse.rse.services;bundle-version="3.2.100",
- org.eclipse.ui.views;bundle-version="3.6.0",
- org.eclipse.rse.subsystems.files.core;bundle-version="3.2.100"
+ org.eclipse.ui.views;bundle-version="3.6.0"
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin
Bundle-ActivationPolicy: lazy
public static Test suite() {
TestSuite suite = new TestSuite(AllLTTngUITests.class.getName());
//$JUnit-BEGIN$
- suite.addTest(org.eclipse.linuxtools.lttng.ui.tests.control.model.impl.AllTests.suite());
- suite.addTest(org.eclipse.linuxtools.lttng.ui.tests.control.service.AllTests.suite());
suite.addTest(org.eclipse.linuxtools.lttng.ui.tests.distribution.AllTests.suite());
- suite.addTest(org.eclipse.linuxtools.lttng.ui.tests.control.model.component.AllTests.suite());
//$JUnit-END$
return suite;
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests {
-
- public static Test suite() {
-
- TestSuite suite = new TestSuite(AllTests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(TraceControlComponentTest.class);
- suite.addTestSuite(TraceControlTreeModelTest.class);
- suite.addTestSuite(TraceControlProviderTests.class);
- suite.addTestSuite(TraceControlPropertiesTest.class);
- //$JUnit-END$
- return new ModelImplTestSetup(suite);
- }
-}
+++ /dev/null
-/*******************************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-/**
- * Test setup class for one-time setUp() and tearDown() across test cases.
- */
-public class ModelImplTestSetup extends TestSetup {
-
- public ModelImplTestSetup(Test test) {
- super(test);
- }
-
- /*
- * (non-Javadoc)
- * @see junit.extensions.TestSetup#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- TraceControlTestFacility.getInstance().init();
- }
-
- /*
- * (non-Javadoc)
- * @see junit.extensions.TestSetup#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- TraceControlTestFacility.getInstance().dispose();
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponentChangedListener;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlRoot;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.LTTngControlService;
-import org.eclipse.linuxtools.lttng.stubs.service.TestRemoteSystemProxy;
-import org.eclipse.linuxtools.lttng.ui.tests.control.model.impl.ListenerValidator;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * The class <code>TraceControlComponentTest</code> contains tests for the class <code>{@link TraceControlComponent}</code>.
- *
- */
-@SuppressWarnings("nls")
-public class TraceControlComponentTest extends TestCase {
-
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Static methods
- // ------------------------------------------------------------------------
-
- /**
- * Returns test setup used when executing test case stand-alone.
- * @return Test setup class
- */
- public static Test suite() {
- return new ModelImplTestSetup(new TestSuite(TraceControlComponentTest.class));
- }
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- */
- @Override
- @Before
- public void setUp() throws Exception {
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- */
- @Override
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Run the TraceControlComponent(String) constructor test.
- */
- public void testTraceControlComponent_1()
- throws Exception {
-
- String name = "node";
-
- TraceControlComponent result = new TraceControlComponent(name);
-
- assertNotNull(result);
- assertEquals(name, result.getName());
- assertEquals(null, result.getParent());
- assertEquals(false, result.hasChildren());
- assertEquals(null, result.getImage());
- assertEquals(null, result.getControlService());
- assertEquals(null, result.getToolTip());
- }
-
- /**
- * Run the TraceControlComponent(String,ITraceControlComponent) constructor test.
- *
- */
- public void testTraceControlComponent_2()
- throws Exception {
- String name = "node";
-
- ITraceControlComponent parent = new TraceControlRoot();
- TraceControlComponent result = new TraceControlComponent(name, parent);
-
- assertNotNull(result);
- assertEquals(name, result.getName());
- assertEquals(false, result.hasChildren());
- assertEquals(null, result.getImage());
- assertEquals(null, result.getControlService());
- assertEquals(null, result.getToolTip());
- }
-
- /**
- * Run the void addChild(ITraceControlComponent) method test.
- *
- * @throws Exception
- *
- */
- public void testAddAndGetChild1()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("node", new TraceControlRoot());
- fixture.setToolTip("This is the test node");
- fixture.addChild(new TraceControlRoot());
- ITraceControlComponent component = new TraceControlRoot();
- fixture.addChild(component);
-
- ITraceControlComponent child = fixture.getChild(TraceControlRoot.TRACE_CONTROL_ROOT_NAME);
- assertNotNull(child);
- assertEquals(TraceControlRoot.TRACE_CONTROL_ROOT_NAME, child.getName());
- }
-
- /**
- * Run the void addChild(ITraceControlComponent) method test.
- *
- * @throws Exception
- *
- */
- public void testAddAndGetChild2()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- ITraceControlComponent component = null;
-
- fixture.addChild(component);
- assertFalse(fixture.hasChildren());
- }
-
- /**
- * Run the void addComponentListener(ITraceControlComponentChangedListener) method test.
- *
- * @throws Exception
- *
- */
-
- public void testAddComponentListener_1()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", (ITraceControlComponent) null);
- fixture.setToolTip("");
-
- ListenerValidator validator = new ListenerValidator();
- fixture.addComponentListener(validator);
-
- TraceControlRoot root = new TraceControlRoot();
- fixture.addChild(root);
- assertTrue(validator.isAddedCalled());
-
- fixture.removeChild(root);
- assertTrue(validator.isRemovedCalled());
-
- fixture.fireComponentChanged(fixture);
- assertTrue(validator.isChangedCalled());
- }
-
- /**
- * Run the boolean containsChild(String) method test.
- *
- * @throws Exception
- *
- */
- public void testContainsChild_1()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- fixture.addChild(new TraceControlRoot());
- String name = "node";
-
- boolean result = fixture.containsChild(name);
-
- assertEquals(false, result);
- }
-
- /**
- * Run the boolean containsChild(String) method test.
- *
- * @throws Exception
- *
- */
- public void testContainsChild_2()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("name", new TraceControlRoot());
- fixture.setToolTip("");
-
- boolean result = fixture.containsChild(TraceControlRoot.TRACE_CONTROL_ROOT_NAME);
-
- assertEquals(false, result);
- }
-
- /**
- * 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 {
- ITraceControlComponent parent = new TraceControlRoot();
-
- TraceControlComponent fixture = new TraceControlComponent("node", parent);
- fixture.setToolTip("");
-
- ITraceControlComponent component = new TraceControlComponent("child");
- fixture.addChild(component);
-
- ListenerValidator validator = new ListenerValidator();
- fixture.addComponentListener(validator);
-
- fixture.fireComponentAdded(parent, component);
- assertTrue(validator.isAddedCalled());
- assertEquals(parent.getName(), validator.getSavedParent().getName());
- assertEquals(component.getName(), validator.getSavedChild().getName());
-
- validator.initialize();
-
- fixture.fireComponentRemoved(parent, component);
- assertTrue(validator.isRemovedCalled());
- assertEquals(parent.getName(), validator.getSavedParent().getName());
- assertEquals(component.getName(), validator.getSavedChild().getName());
-
- validator.initialize();
- fixture.fireComponentChanged(fixture);
- assertTrue(validator.isChangedCalled());
- assertEquals(fixture.getName(), validator.getSavedComponent().getName());
- }
-
- /**
- * Run the Object getAdapter(Class) method test.
- *
- * @throws Exception
- *
- */
-
- public void testGetAdapter()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- fixture.addChild(new TraceControlRoot());
- Class<Object> adapter = Object.class;
-
- Object result = fixture.getAdapter(adapter);
-
- assertEquals(null, result);
- }
-
- /**
- * Run the ITraceControlComponent[] getChildren() method test.
- *
- * @throws Exception
- *
- */
- public void testGetChildren_1()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- fixture.addChild(new TraceControlRoot());
-
- ITraceControlComponent[] result = fixture.getChildren();
-
- assertNotNull(result);
- assertEquals(1, result.length);
- assertNotNull(result[0]);
- assertEquals("trace_control_root", result[0].getName());
- assertEquals(null, result[0].getParent());
- assertEquals(false, result[0].hasChildren());
- assertEquals(null, result[0].getImage());
- assertEquals(null, result[0].getControlService());
- assertEquals(null, result[0].getToolTip());
- }
-
- /**
- * Run the ILttngControlService getControlService()/setControlService() method test.
- *
- * @throws Exception
- *
- */
- public void testGetAndSetControlService_1()
- throws Exception {
-
- TraceControlComponent parent = new TraceControlComponent("parent") {
- ILttngControlService fService = null;
-
- @Override
- public void setControlService(ILttngControlService service ) {
- fService = service;
- }
-
- @Override
- public ILttngControlService getControlService() {
- return fService;
- }
- };
-
- TraceControlComponent fixture = new TraceControlComponent("", parent);
- parent.addChild(fixture);
- fixture.setToolTip("");
- TraceControlComponent child = new TraceControlComponent("child", fixture);
- fixture.addChild(child);
-
- ILttngControlService result = fixture.getControlService();
- assertEquals(null, result);
-
- TestRemoteSystemProxy proxy = new TestRemoteSystemProxy();
- ILttngControlService service = new LTTngControlService(proxy.createCommandShell());
- fixture.setControlService(service);
- result = fixture.getControlService();
- assertNotNull(service);
- assertEquals(service, result);
-
- result = fixture.getChildren()[0].getControlService();
- assertNotNull(service);
- assertEquals(service, result);
- }
-
- /**
- * Run the Image getImage() method test.
- *
- * @throws Exception
- *
- */
- public void testGetImage_1()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- fixture.addChild(new TraceControlRoot());
-
- Image result = fixture.getImage();
- assertEquals(null, result);
-
- fixture.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
- assertNotNull(fixture.getImage());
- }
-
- /**
- * Run the boolean hasChildren() method test.
- *
- * @throws Exception
- *
- */
- public void testHasChildren_1()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- fixture.addChild(new TraceControlRoot());
-
- boolean result = fixture.hasChildren();
-
- assertTrue(result);
- }
-
- /**
- * Run the boolean hasChildren() method test.
- *
- * @throws Exception
- *
- */
- public void testHasChildren_2()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
-
- boolean result = fixture.hasChildren();
-
- assertFalse(result);
- }
-
- /**
- * Run the void removeAllChildren() method test.
- *
- * @throws Exception
- *
- */
- public void testRemoveAllChildren_2()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
-
- fixture.addChild(new TraceControlRoot());
- fixture.addChild(new TraceControlComponent("child"));
-
- fixture.removeAllChildren();
- assertFalse(fixture.hasChildren());
- }
-
- /**
- * Run the void removeChild(ITraceControlComponent) method test.
- *
- * @throws Exception
- *
- */
- public void testRemoveChild_1()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- TraceControlComponent child = new TraceControlComponent("child", fixture);
-
- fixture.addChild(child);
- fixture.removeChild(child);
- assertFalse(fixture.hasChildren());
- }
-
- /**
- * Run the void removeChild(ITraceControlComponent) method test.
- *
- * @throws Exception
- *
- */
-
- public void testRemoveChild_2()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- fixture.addChild(new TraceControlRoot());
- ITraceControlComponent component = null;
-
- fixture.removeChild(component);
- assertTrue(fixture.hasChildren());
- }
-
- /**
- * Run the void removeComponentListener(ITraceControlComponentChangedListener) method test.
- *
- * @throws Exception
- *
- */
- public void testRemoveComponentListener_1()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", (ITraceControlComponent) null);
- fixture.setToolTip("");
-
- ListenerValidator validator = new ListenerValidator();
- fixture.addComponentListener(validator);
-
- // Remove listener and check that validator is not called anymore
- validator.initialize();
- fixture.removeComponentListener(validator);
- TraceControlRoot root = new TraceControlRoot();
- fixture.addChild(root);
- assertFalse(validator.isAddedCalled());
-
- fixture.removeChild(root);
- assertFalse(validator.isRemovedCalled());
-
- fixture.fireComponentChanged(fixture);
- assertFalse(validator.isChangedCalled());
- }
-
- /**
- * Run the void removeComponentListener(ITraceControlComponentChangedListener) method test.
- *
- * @throws Exception
- *
- */
- public void testRemoveComponentListener_2()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- fixture.addChild(new TraceControlRoot());
- ITraceControlComponentChangedListener listener = new ControlView();
-
- fixture.removeComponentListener(listener);
-
- }
-
- /**
- * Run the void setChildren(List<ITraceControlComponent>)/ITraceControlComponent[] getChildren() method test.
- *
- *
- * @throws Exception
- *
- */
- public void testGetAndSetChildren()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- List<ITraceControlComponent> children = new LinkedList<ITraceControlComponent>();
- children.add(new TraceControlComponent("child1"));
- children.add(new TraceControlComponent("child2"));
-
- fixture.setChildren(children);
-
- ITraceControlComponent[] result = fixture.getChildren();
- assertEquals(2, result.length);
- assertEquals("child1", result[0].getName());
- assertEquals("child2", result[1].getName());
- }
-
- /**
- * Run the void String getName()/setName(String) method tests.
- *
- * @throws Exception
- *
- */
- public void testGetAndSetName()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- fixture.addChild(new TraceControlRoot());
- String name = "node";
-
- fixture.setName(name);
- assertEquals(name,fixture.getName());
-
- }
-
- /**
- * Run the void ITraceControlComponent getParent()/setParent(ITraceControlComponent) method tests.
- *
- * @throws Exception
- *
- */
- public void testGetAndSetParent()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("");
- fixture.addChild(new TraceControlRoot());
- ITraceControlComponent parent = new TraceControlRoot();
- parent.addChild(fixture);
-
- fixture.setParent(parent);
- ITraceControlComponent retrievedParent = fixture.getParent();
- assertNotNull(retrievedParent);
- assertEquals(parent.getName(), retrievedParent.getName());
- assertEquals(TraceControlRoot.TRACE_CONTROL_ROOT_NAME, retrievedParent.getName());
- assertEquals(null, retrievedParent.getParent());
- assertEquals(true, retrievedParent.hasChildren());
- }
-
- /**
- * Run the void TargetNodeState getTargetNodeState()/etTargetNodeState(TargetNodeState) method tests.
- *
- * @throws Exception
- *
- */
- public void testGetAndSetTargetNodeState_1()
- throws Exception {
-
- TraceControlComponent parent = new TraceControlComponent("parent") {
- private TargetNodeState fState;
-
- @Override
- public void setTargetNodeState(TargetNodeState state ) {
- fState = state;
- }
-
- @Override
- public TargetNodeState getTargetNodeState() {
- return fState;
- }
- };
-
- TraceControlComponent fixture = new TraceControlComponent("", parent);
- parent.addChild(fixture);
-
- fixture.setToolTip("");
- TargetNodeState state = TargetNodeState.CONNECTED;
-
- fixture.setTargetNodeState(state);
- TargetNodeState result = fixture.getTargetNodeState();
-
- assertNotNull(result);
- assertEquals(state, result);
- // Check also parent
- assertEquals(state, fixture.getParent().getTargetNodeState());
- assertEquals("CONNECTED", result.name());
- assertEquals("CONNECTED", result.toString());
- assertEquals(2, result.ordinal());
-
- fixture.setTargetNodeState(TargetNodeState.DISCONNECTED);
- result = fixture.getTargetNodeState();
- assertNotNull(result);
- assertEquals("DISCONNECTED", result.name());
- assertEquals("DISCONNECTED", result.toString());
- assertEquals(0, result.ordinal());
-
- state = TargetNodeState.CONNECTING;
-
- fixture.setTargetNodeState(state);
- result = fixture.getTargetNodeState();
- assertNotNull(result);
- assertEquals("CONNECTING", result.name());
- assertEquals("CONNECTING", result.toString());
- assertEquals(3, result.ordinal());
-
- fixture.setTargetNodeState(TargetNodeState.DISCONNECTING);
- result = fixture.getTargetNodeState();
- assertNotNull(result);
- assertEquals("DISCONNECTING", result.name());
- assertEquals("DISCONNECTING", result.toString());
- assertEquals(1, result.ordinal());
-
- }
-
- /**
- * Run the void setToolTip(String) method test.
- *
- * @throws Exception
- *
-
- */
-
- public void testGetSndSetToolTip()
- throws Exception {
- TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
- fixture.setToolTip("This is a tooltip");
- fixture.addChild(new TraceControlRoot());
-
- String result = fixture.getToolTip();
-
- assertEquals("This is a tooltip", result);
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
-
-import java.io.File;
-import java.net.URL;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.KernelProviderComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceProbeEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.UstProviderComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BaseEventPropertySource;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.KernelProviderPropertySource;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TargetNodePropertySource;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TraceChannelPropertySource;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TraceDomainPropertySource;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TraceEventPropertySource;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TraceProbeEventPropertySource;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TraceSessionPropertySource;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.UstProviderPropertySource;
-import org.eclipse.linuxtools.lttng.stubs.service.TestRemoteSystemProxy;
-import org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin;
-import org.eclipse.rse.core.model.Host;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.internal.core.model.SystemProfile;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * The class <code>TraceControlPropertiesTest</code> contains tests for the all property class</code>.
- *
- */
-@SuppressWarnings("nls")
-public class TraceControlPropertiesTest extends TestCase {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- private static final String DIRECTORY = "testfiles";
- private static final String TEST_STREAM = "ListInfoTest.cfg";
- private static final String SCEN_LIST_INFO_TEST = "ListInfoTest";
-
-
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Static methods
- // ------------------------------------------------------------------------
-
- /**
- * Returns test setup used when executing test case stand-alone.
- * @return Test setup class
- */
- public static Test suite() {
- return new ModelImplTestSetup(new TestSuite(TraceControlPropertiesTest.class));
- }
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- */
- @Override
- @Before
- public void setUp() throws Exception {
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- */
- @Override
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Run the TraceControlComponent.
- */
- public void testTraceControlComponents()
- throws Exception {
-
- TestRemoteSystemProxy proxy = new TestRemoteSystemProxy();
-
- URL location = FileLocator.find(LTTngUITestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
- File testfile = new File(FileLocator.toFileURL(location).toURI());
- proxy.setTestFile(testfile.getAbsolutePath());
- proxy.setScenario(SCEN_LIST_INFO_TEST);
-
- ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
-
- @SuppressWarnings("restriction")
- IHost host = new Host(new SystemProfile("myProfile", true));
- host.setHostName("127.0.0.1");
-
- TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, proxy);
-
- root.addChild(node);
- node.connect();
-
- TraceControlTestFacility.getInstance().waitForJobs();
-
- // ------------------------------------------------------------------------
- // Verify Node Properties (adapter)
- // ------------------------------------------------------------------------
- Object adapter = node.getAdapter(IPropertySource.class);
- assertNotNull(adapter);
- assertTrue(adapter instanceof TargetNodePropertySource);
-
- TargetNodePropertySource source = (TargetNodePropertySource)adapter;
-
- assertNull(source.getEditableValue());
- assertFalse(source.isPropertySet(TargetNodePropertySource.TARGET_NODE_NAME_PROPERTY_ID));
- assertNotNull(source.getPropertyDescriptors());
-
- assertEquals("myNode", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_NAME_PROPERTY_ID));
- assertEquals("127.0.0.1", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_ADDRESS_PROPERTY_ID));
- assertEquals(TargetNodeState.CONNECTED.name(), source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_STATE_PROPERTY_ID));
- assertNull(source.getPropertyValue("test"));
-
- adapter = node.getAdapter(IChannelInfo.class);
- assertNull(adapter);
-
- ITraceControlComponent[] groups = node.getChildren();
- assertNotNull(groups);
- assertEquals(2, groups.length);
-
- ITraceControlComponent[] providers = groups[0].getChildren();
-
- assertNotNull(providers);
- assertEquals(3, providers.length);
-
- // ------------------------------------------------------------------------
- // Verify Kernel Provider Properties (adapter)
- // ------------------------------------------------------------------------
- KernelProviderComponent kernelProvider = (KernelProviderComponent) providers[0];
-
- adapter = kernelProvider.getAdapter(IPropertySource.class);
- assertNotNull(adapter);
- assertTrue(adapter instanceof KernelProviderPropertySource);
-
- KernelProviderPropertySource kernelSource = (KernelProviderPropertySource)adapter;
- assertNotNull(kernelSource.getPropertyDescriptors());
-
- assertEquals("Kernel", kernelSource.getPropertyValue(KernelProviderPropertySource.KERNEL_PROVIDER_NAME_PROPERTY_ID));
-
- // ------------------------------------------------------------------------
- // Verify UST Provider Properties (adapter)
- // ------------------------------------------------------------------------
- UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
-
- adapter = ustProvider.getAdapter(IPropertySource.class);
- assertNotNull(adapter);
- assertTrue(adapter instanceof UstProviderPropertySource);
-
- UstProviderPropertySource ustSource = (UstProviderPropertySource)adapter;
- assertNotNull(ustSource.getPropertyDescriptors());
-
- assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustSource.getPropertyValue(UstProviderPropertySource.UST_PROVIDER_NAME_PROPERTY_ID));
- assertEquals(String.valueOf(9379), ustSource.getPropertyValue(UstProviderPropertySource.UST_PROVIDER_PID_PROPERTY_ID));
-
- // ------------------------------------------------------------------------
- // Verify Base Event Properties (adapter)
- // ------------------------------------------------------------------------
- ITraceControlComponent[] events = ustProvider.getChildren();
- assertNotNull(events);
- assertEquals(2, events.length);
-
- BaseEventComponent baseEventInfo = (BaseEventComponent) events[0];
- assertNotNull(baseEventInfo);
-
- adapter = baseEventInfo.getAdapter(IPropertySource.class);
- assertNotNull(adapter);
- assertTrue(adapter instanceof BaseEventPropertySource);
-
- BaseEventPropertySource baseSource = (BaseEventPropertySource)adapter;
- assertNotNull(baseSource.getPropertyDescriptors());
-
- assertEquals("ust_tests_hello:tptest_sighandler", baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_NAME_PROPERTY_ID));
- assertEquals(TraceEventType.TRACEPOINT.name(), baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_TYPE_PROPERTY_ID));
- assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE.name(), baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_LOGLEVEL_PROPERTY_ID));
-
- // ------------------------------------------------------------------------
- // Verify Session Properties (adapter)
- // ------------------------------------------------------------------------
- ITraceControlComponent[] sessions = groups[1].getChildren();
- assertNotNull(sessions);
- assertEquals(2, sessions.length);
-
- TraceSessionComponent session = (TraceSessionComponent)sessions[1];
-
- adapter = session.getAdapter(IPropertySource.class);
- assertNotNull(adapter);
- assertTrue(adapter instanceof TraceSessionPropertySource);
-
- TraceSessionPropertySource sessionSource = (TraceSessionPropertySource)adapter;
- assertNotNull(sessionSource.getPropertyDescriptors());
-
- assertEquals("mysession", sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_NAME_PROPERTY_ID));
- assertEquals("/home/user/lttng-traces/mysession-20120129-084256", sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_PATH_PROPERTY_ID));
- assertEquals(TraceSessionState.ACTIVE.name(), sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_STATE_PROPERTY_ID));
-
- // ------------------------------------------------------------------------
- // Verify Domain Provider Properties (adapter)
- // ------------------------------------------------------------------------
- ITraceControlComponent[] domains = session.getChildren();
- assertNotNull(domains);
- assertEquals(2, domains.length);
-
- TraceDomainComponent domain = (TraceDomainComponent) domains[0];
- adapter = domain.getAdapter(IPropertySource.class);
- assertNotNull(adapter);
- assertTrue(adapter instanceof TraceDomainPropertySource);
-
- TraceDomainPropertySource domainSource = (TraceDomainPropertySource)adapter;
- assertNotNull(domainSource.getPropertyDescriptors());
-
- assertEquals("Kernel", domainSource.getPropertyValue(TraceDomainPropertySource.TRACE_DOMAIN_NAME_PROPERTY_ID));
-
- ITraceControlComponent[] channels = domains[0].getChildren();
- assertNotNull(channels);
- assertEquals(2, channels.length);
-
- // ------------------------------------------------------------------------
- // Verify Channel Properties (adapter)
- // ------------------------------------------------------------------------
- assertTrue(channels[0] instanceof TraceChannelComponent);
- TraceChannelComponent channel = (TraceChannelComponent) channels[0];
-
- adapter = channel.getAdapter(IPropertySource.class);
- assertNotNull(adapter);
- assertTrue(adapter instanceof TraceChannelPropertySource);
-
- TraceChannelPropertySource channelSource = (TraceChannelPropertySource)adapter;
- assertNotNull(channelSource.getPropertyDescriptors());
-
- assertEquals("channel0", channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_NAME_PROPERTY_ID));
- assertEquals(String.valueOf(4), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID));
- assertEquals(TraceEnablement.ENABLED.name(), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_STATE_PROPERTY_ID));
- assertEquals(String.valueOf(false), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID));
- assertEquals("splice()", channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID));
- assertEquals(String.valueOf(200), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_READ_TIMER_PROPERTY_ID));
- assertEquals(String.valueOf(262144), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID));
- assertEquals(String.valueOf(0), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID));
-
- // ------------------------------------------------------------------------
- // Verify Event Properties (adapter)
- // ------------------------------------------------------------------------
- ITraceControlComponent[] channel0Events = channel.getChildren();
- assertNotNull(channel0Events);
- assertEquals(5, channel0Events.length);
- assertTrue(channel0Events[0] instanceof TraceEventComponent);
-
- TraceEventComponent event = (TraceEventComponent) channel0Events[0];
-
- adapter = event.getAdapter(IPropertySource.class);
- assertNotNull(adapter);
- assertTrue(adapter instanceof TraceEventPropertySource);
-
- TraceEventPropertySource eventSource = (TraceEventPropertySource)adapter;
- assertNotNull(eventSource.getPropertyDescriptors());
-
- assertEquals("block_rq_remap", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
- assertEquals(TraceLogLevel.TRACE_EMERG.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
- assertEquals(TraceEventType.TRACEPOINT.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
- assertEquals(TraceEnablement.ENABLED.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
-
- // ------------------------------------------------------------------------
- // Verify Probe Event Properties (adapter)
- // ------------------------------------------------------------------------
- assertTrue(channel0Events[2] instanceof TraceProbeEventComponent);
-
- TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2];
-
- adapter = probeEvent.getAdapter(IPropertySource.class);
- assertNotNull(adapter);
- assertTrue(adapter instanceof TraceProbeEventPropertySource);
-
- TraceProbeEventPropertySource probeEventSource = (TraceProbeEventPropertySource)adapter;
- assertNotNull(probeEventSource.getPropertyDescriptors());
- assertEquals(4, probeEventSource.getPropertyDescriptors().length);
-
- assertEquals("myevent2", probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
- assertEquals(TraceEventType.PROBE.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
- assertEquals(TraceEnablement.ENABLED.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
- assertEquals("0xc0101340", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID));
-
- assertTrue(channel0Events[3] instanceof TraceProbeEventComponent);
-
- probeEvent = (TraceProbeEventComponent) channel0Events[3];
-
- adapter = probeEvent.getAdapter(IPropertySource.class);
- assertNotNull(adapter);
- assertTrue(adapter instanceof TraceProbeEventPropertySource);
-
- probeEventSource = (TraceProbeEventPropertySource)adapter;
- assertNotNull(probeEventSource.getPropertyDescriptors());
- assertEquals(5, probeEventSource.getPropertyDescriptors().length);
-
- assertEquals("myevent0", probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
- assertEquals(TraceEventType.PROBE.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
- assertEquals(TraceEnablement.ENABLED.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
- assertEquals("0x0", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID));
- assertEquals("init_post", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID));
-
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
-
-import java.io.File;
-import java.net.URL;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IConfirmDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateChannelOnSessionDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateSessionDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IGetEventInfoDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.ChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.KernelProviderComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionGroup;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.UstProviderComponent;
-import org.eclipse.linuxtools.lttng.stubs.service.TestRemoteSystemProxy;
-import org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin;
-import org.eclipse.rse.core.model.Host;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.internal.core.model.SystemProfile;
-import org.eclipse.swt.widgets.Shell;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * The class <code>TraceControlTreeModelTest</code> contains tests for the tree component classes.
- */
-@SuppressWarnings("nls")
-public class TraceControlProviderTests extends TestCase {
-
- private static final String DIRECTORY = "testfiles";
- private static final String TEST_STREAM = "CreateTreeTest.cfg";
- private static final String SCEN_INIT_TEST = "Initialize";
- private static final String SCEN_SCENARIO1_TEST = "Scenario1";
- private static final String SCEN_SCENARIO2_TEST = "Scenario2";
-
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
- private TraceControlTestFacility fFacility;
- private TestRemoteSystemProxy fProxy;
- private String fTestFile;
-
- // ------------------------------------------------------------------------
- // Static methods
- // ------------------------------------------------------------------------
-
- /**
- * Returns test setup used when executing test case stand-alone.
- * @return Test setup class
- */
- public static Test suite() {
- return new ModelImplTestSetup(new TestSuite(TraceControlProviderTests.class));
- }
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- */
- @Override
- @Before
- public void setUp() throws Exception {
- fFacility = TraceControlTestFacility.getInstance();
- fProxy = new TestRemoteSystemProxy();
- URL location = FileLocator.find(LTTngUITestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
- File testfile = new File(FileLocator.toFileURL(location).toURI());
- fTestFile = testfile.getAbsolutePath();
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- */
- @Override
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Run the TraceControlComponent.
- */
- public void testTraceControlComponents()
- throws Exception {
-
- fProxy.setTestFile(fTestFile);
- fProxy.setScenario(SCEN_INIT_TEST);
-
- ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
-
- @SuppressWarnings("restriction")
- IHost host = new Host(new SystemProfile("myProfile", true));
- host.setHostName("127.0.0.1");
-
- TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy);
-
- root.addChild(node);
- node.connect();
-
- fFacility.waitForJobs();
-
- // Verify that node is connected
- assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState());
-
- // Get provider groups
- ITraceControlComponent[] groups = node.getChildren();
- assertNotNull(groups);
- assertEquals(2, groups.length);
-
- // Get kernel provider
- ITraceControlComponent[] providers = groups[0].getChildren();
- KernelProviderComponent kernelProvider = (KernelProviderComponent) providers[0];
-
- // Get kernel provider events and select 2 events
- ITraceControlComponent[] events = kernelProvider.getChildren();
- assertNotNull(events);
- assertEquals(3, events.length);
-
- BaseEventComponent baseEventInfo0 = (BaseEventComponent) events[0];
- BaseEventComponent baseEventInfo1 = (BaseEventComponent) events[1];
-
- // Initialize dialog implementations for command execution
- TraceControlDialogFactory.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
- TraceControlDialogFactory.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
- TraceControlDialogFactory.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
-
- // Initialize scenario
- fProxy.setScenario(SCEN_SCENARIO1_TEST);
-
- // ------------------------------------------------------------------------
- // Create session
- // ------------------------------------------------------------------------
- TraceSessionComponent session = createSession(groups[1]);
-
- // Verify that session was created
- assertNotNull(session);
- assertEquals("mysession", session.getName());
- assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session.getSessionPath());
- assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
-
- // ------------------------------------------------------------------------
- // Enable event on default channel on created session above
- // ------------------------------------------------------------------------
- ITraceControlComponent[] components = { baseEventInfo0, baseEventInfo1 };
-
- fFacility.getControlView().setSelection(components);
- // Give GUI time to actually execute refresh
- fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
-
- fFacility.executeCommand("assign.event");
- fFacility.waitForJobs();
-
- // Verify that kernel domain was created
- ITraceControlComponent[] domains = session.getChildren();
- assertNotNull(domains);
- assertEquals(1, domains.length);
-
- assertEquals("Kernel", domains[0].getName());
-
- // Verify that channel0 was created with default values
- ITraceControlComponent[] channels = domains[0].getChildren();
- assertNotNull(channels);
- assertEquals(1, channels.length);
-
- assertTrue(channels[0] instanceof TraceChannelComponent);
- TraceChannelComponent channel = (TraceChannelComponent) channels[0];
- assertEquals("channel0", channel.getName());
- assertEquals(4, channel.getNumberOfSubBuffers());
- assertEquals("splice()", channel.getOutputType());
- assertEquals(false, channel.isOverwriteMode());
- assertEquals(200, channel.getReadTimer());
- assertEquals(TraceEnablement.ENABLED, channel.getState());
- assertEquals(262144, channel.getSubBufferSize());
- assertEquals(0, channel.getSwitchTimer());
-
- // Verify that event components were created
- ITraceControlComponent[] channel0Events = channel.getChildren();
- assertNotNull(channel0Events);
- assertEquals(2, channel0Events.length);
- assertTrue(channel0Events[0] instanceof TraceEventComponent);
- assertTrue(channel0Events[1] instanceof TraceEventComponent);
-
- TraceEventComponent event = (TraceEventComponent) channel0Events[0];
- assertEquals("sched_kthread_stop_ret", event.getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
- assertEquals(TraceEnablement.ENABLED, event.getState());
-
- TraceEventComponent event1 = (TraceEventComponent) channel0Events[1];
- assertEquals("sched_kthread_stop", event1.getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, event1.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, event1.getEventType());
- assertEquals(TraceEnablement.ENABLED, event1.getState());
-
- // ------------------------------------------------------------------------
- // Disable event components
- // ------------------------------------------------------------------------
- ITraceControlComponent[] selection = { event, event1 };
- fFacility.getControlView().setSelection(selection);
- // Give GUI time to actually execute the selection
- fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
- fFacility.executeCommand("disable.event");
- fFacility.waitForJobs();
-
- assertEquals(TraceEnablement.DISABLED, event.getState());
- assertEquals(TraceEnablement.DISABLED, event1.getState());
-
- // ------------------------------------------------------------------------
- // Enable event component
- // ------------------------------------------------------------------------
- fFacility.getControlView().setSelection(event1);
- fFacility.executeCommand("enable.event");
- fFacility.waitForJobs();
-
- // Verify event state
- assertEquals(TraceEnablement.ENABLED, event1.getState());
-
- // ------------------------------------------------------------------------
- // Destroy session
- // ------------------------------------------------------------------------
- destroySession(session);
-
- // Verify that no more session components exist
- assertEquals(0, groups[1].getChildren().length);
-
-
- // ------------------------------------------------------------------------
- // Create session
- // ------------------------------------------------------------------------
- fProxy.setScenario(SCEN_SCENARIO2_TEST);
-
- CreateSessionDialogStub sessionDialogStub = new CreateSessionDialogStub();
- sessionDialogStub.setSessionPath("/home/user/temp");
- TraceControlDialogFactory.getInstance().setCreateSessionDialog(sessionDialogStub);
-
- session = createSession(groups[1]);
-
- // Verify that session was created
- assertNotNull(session);
- assertEquals("mysession", session.getName());
- assertEquals("/home/user/temp", session.getSessionPath());
- assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
-
- // ------------------------------------------------------------------------
- // Create Channel on UST global domain
- // ------------------------------------------------------------------------
- TraceControlDialogFactory.getInstance().setCreateChannelOnSessionDialog(new CreateChannelOnSessionDialogStub());
-
- fFacility.getControlView().setSelection(session);
- // Give GUI time to actually execute refresh
- fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
-
- fFacility.executeCommand("createChannelOnSession");
- fFacility.waitForJobs();
-
- // Verify that UST domain was created
- domains = session.getChildren();
- assertNotNull(domains);
- assertEquals(1, domains.length);
-
- assertEquals("UST global", domains[0].getName());
-
- // Verify that channel was created with correct data
- channels = domains[0].getChildren();
- assertNotNull(channels);
- assertEquals(1, channels.length);
-
- assertTrue(channels[0] instanceof TraceChannelComponent);
- channel = (TraceChannelComponent) channels[0];
- assertEquals("mychannel", channel.getName());
- assertEquals(2, channel.getNumberOfSubBuffers());
- assertEquals("mmap()", channel.getOutputType());
- assertEquals(false, channel.isOverwriteMode());
- assertEquals(100, channel.getReadTimer());
- assertEquals(TraceEnablement.ENABLED, channel.getState());
- assertEquals(16384, channel.getSubBufferSize());
- assertEquals(200, channel.getSwitchTimer());
-
- // ------------------------------------------------------------------------
- // Enable event on default channel on created session above
- // ------------------------------------------------------------------------
- // Get first UST provider
- UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
- assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
- assertEquals(9379, ustProvider.getPid());
-
- // Get events
- events = ustProvider.getChildren();
- assertNotNull(events);
- assertEquals(2, events.length);
-
- baseEventInfo0 = (BaseEventComponent) events[0];
- baseEventInfo1 = (BaseEventComponent) events[1];
-
- ITraceControlComponent[] ustSelection = { baseEventInfo0, baseEventInfo1 };
-
- fFacility.getControlView().setSelection(ustSelection);
- // Give GUI time to actually execute refresh
- fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
- fFacility.executeCommand("assign.event");
- fFacility.waitForJobs();
-
- // verify that events were created under the channel
- // Note that domain and channel has to be re-read because the tree is re-created
-
- domains = session.getChildren();
-
- // Verify that channel was created with correct data
- channels = domains[0].getChildren();
-
- ITraceControlComponent[] ustEvents = channels[0].getChildren();
- assertEquals(2, ustEvents.length);
-
- event = (TraceEventComponent) ustEvents[0];
- assertEquals("ust_tests_hello:tptest_sighandler", event.getName());
- assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
- assertEquals(TraceEnablement.ENABLED, event.getState());
-
- event = (TraceEventComponent) ustEvents[1];
- assertEquals("ust_tests_hello:tptest", ustEvents[1].getName());
- assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
- assertEquals(TraceEnablement.ENABLED, event.getState());
-
- // ------------------------------------------------------------------------
- // Disable event components
- // ------------------------------------------------------------------------
- fFacility.getControlView().setSelection(event);
- // Give GUI time to actually execute the selection
- fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
- fFacility.executeCommand("disable.event");
- fFacility.waitForJobs();
-
- assertEquals(TraceEnablement.DISABLED, event.getState());
-
- // ------------------------------------------------------------------------
- // Enable event component
- // ------------------------------------------------------------------------
- fFacility.getControlView().setSelection(event);
- fFacility.executeCommand("enable.event");
- fFacility.waitForJobs();
-
- // Verify event state
- assertEquals(TraceEnablement.ENABLED, event.getState());
-
- // ------------------------------------------------------------------------
- // Destroy session
- // ------------------------------------------------------------------------
- destroySession(session);
-
- // Verify that no more session components exist
- assertEquals(0, groups[1].getChildren().length);
-
-
-// fFacility.delay(60000);
- }
-
- private TraceSessionComponent createSession(ITraceControlComponent group) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
- fFacility.getControlView().setSelection(group);
- // Give GUI time to actually execute the selection
- fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
- fFacility.executeCommand("createSession");
- fFacility.waitForJobs();
-
- ITraceControlComponent[] sessions = group.getChildren();
- if ((sessions == null) || (sessions.length == 0)) {
- return null;
- }
- return (TraceSessionComponent)sessions[0];
- }
-
- private void destroySession(TraceSessionComponent session) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
- fFacility.getControlView().setSelection(session);
- // Give GUI time to actually execute the selection
- fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
- fFacility.executeCommand("destroySession");
- fFacility.waitForJobs();
- }
-
-// assertEquals("sched_kthread_stop_ret", baseEventInfo.getName());
-// assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
-// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-//
-// baseEventInfo = (BaseEventComponent) events[2];
-// assertEquals("sched_wakeup_new", baseEventInfo.getName());
-// assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
-// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-//
-// // ------------------------------------------------------------------------
-// // Verify UstProviderComponent
-// // ------------------------------------------------------------------------
-// UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
-// assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
-// assertEquals(9379, ustProvider.getPid());
-//
-// // ------------------------------------------------------------------------
-// // Verify event info (UST provider)
-// // ------------------------------------------------------------------------
-// events = ustProvider.getChildren();
-// assertNotNull(events);
-// assertEquals(2, events.length);
-//
-// baseEventInfo = (BaseEventComponent) events[0];
-// assertNotNull(baseEventInfo);
-// assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
-// assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel());
-// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-//
-// baseEventInfo = (BaseEventComponent) events[1];
-// assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
-// assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel());
-// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-//
-// // ------------------------------------------------------------------------
-// // Verify UstProviderComponent
-// // ------------------------------------------------------------------------
-// ustProvider = (UstProviderComponent) providers[2];
-// assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
-// assertEquals(4852, ustProvider.getPid());
-//
-// // verify getters and setter
-// verifyUstProviderGettersSetters(ustProvider);
-//
-// // ------------------------------------------------------------------------
-// // Verify event info (UST provider)
-// // ------------------------------------------------------------------------
-// events = ustProvider.getChildren();
-// assertNotNull(events);
-// assertEquals(2, events.length);
-//
-// baseEventInfo = (BaseEventComponent) events[0];
-// assertNotNull(baseEventInfo);
-// assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
-// assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel());
-// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-//
-// baseEventInfo = (BaseEventComponent) events[1];
-// assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
-// assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel());
-// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-//
-// // verify getters and setters
-// verifyBaseEventGettersSetters(baseEventInfo);
-//
-// // ------------------------------------------------------------------------
-// // Verify TraceSessionGroup
-// // ------------------------------------------------------------------------
-// ITraceControlComponent[] sessions = groups[1].getChildren();
-// assertNotNull(sessions);
-// assertEquals(2, sessions.length);
-// for (int i = 0; i < sessions.length; i++) {
-// assertTrue(sessions[i] instanceof TraceSessionComponent);
-// }
-// assertEquals("mysession1", sessions[0].getName());
-// assertEquals("mysession", sessions[1].getName());
-//
-// // ------------------------------------------------------------------------
-// // Verify TraceSessionComponent
-// // ------------------------------------------------------------------------
-// TraceSessionComponent session = (TraceSessionComponent)sessions[1];
-// assertEquals("mysession", session.getName());
-// assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
-// assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
-//
-// // Verify setters and setters
-// verifySessionGetterSetters(session);
-//
-// ITraceControlComponent[] domains = session.getChildren();
-// assertNotNull(domains);
-// assertEquals(2, domains.length);
-//
-// // ------------------------------------------------------------------------
-// // Verify Kernel domain
-// // ------------------------------------------------------------------------
-// assertEquals("Kernel", domains[0].getName());
-// ITraceControlComponent[] channels = domains[0].getChildren();
-// assertNotNull(channels);
-// assertEquals(2, channels.length);
-//
-// // ------------------------------------------------------------------------
-// // Verify Kernel's channel0
-// // ------------------------------------------------------------------------
-// assertTrue(channels[0] instanceof TraceChannelComponent);
-// TraceChannelComponent channel = (TraceChannelComponent) channels[0];
-// assertEquals("channel0", channel.getName());
-// assertEquals(4, channel.getNumberOfSubBuffers());
-// assertEquals("splice()", channel.getOutputType());
-// assertEquals(false, channel.isOverwriteMode());
-// assertEquals(200, channel.getReadTimer());
-// assertEquals(TraceEnablement.ENABLED, channel.getState());
-// assertEquals(262144, channel.getSubBufferSize());
-// assertEquals(0, channel.getSwitchTimer());
-//
-// // ------------------------------------------------------------------------
-// // Verify event info (kernel, channel0)
-// // ------------------------------------------------------------------------
-// ITraceControlComponent[] channel0Events = channel.getChildren();
-// assertNotNull(channel0Events);
-// assertEquals(5, channel0Events.length);
-// assertTrue(channel0Events[0] instanceof TraceEventComponent);
-// assertTrue(channel0Events[1] instanceof TraceEventComponent);
-// assertTrue(channel0Events[2] instanceof TraceProbeEventComponent);
-// assertTrue(channel0Events[3] instanceof TraceProbeEventComponent);
-// assertTrue(channel0Events[4] instanceof TraceEventComponent);
-//
-// TraceEventComponent event = (TraceEventComponent) channel0Events[0];
-// assertEquals("block_rq_remap", event.getName());
-// assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
-// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
-// assertEquals(TraceEnablement.ENABLED, event.getState());
-//
-// event = (TraceEventComponent) channel0Events[1];
-// assertEquals("block_bio_remap", event.getName());
-// assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
-// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
-// assertEquals(TraceEnablement.DISABLED, event.getState());
-//
-// TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2];
-// assertEquals("myevent2", probeEvent.getName());
-// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
-// assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
-// assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
-// assertEquals("0xc0101340", probeEvent.getAddress());
-// assertNull(probeEvent.getOffset());
-// assertNull(probeEvent.getSymbol());
-//
-// probeEvent = (TraceProbeEventComponent) channel0Events[3];
-// assertEquals("myevent0", probeEvent.getName());
-// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
-// assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
-// assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
-// assertNull(probeEvent.getAddress());
-// assertEquals("0x0", probeEvent.getOffset());
-// assertEquals("init_post", probeEvent.getSymbol());
-//
-// event = (TraceEventComponent) channel0Events[4];
-// assertEquals("syscalls", event.getName());
-// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
-// assertEquals(TraceEventType.SYSCALL, event.getEventType());
-// assertEquals(TraceEnablement.ENABLED, event.getState());
-//
-// // ------------------------------------------------------------------------
-// // Verify Kernel's channel1
-// // ------------------------------------------------------------------------
-// assertEquals("channel1", channels[1].getName());
-// channel = (TraceChannelComponent) channels[1];
-// assertEquals(4, channel.getNumberOfSubBuffers());
-// assertEquals("splice()", channel.getOutputType());
-// assertEquals(true, channel.isOverwriteMode());
-// assertEquals(400, channel.getReadTimer());
-// assertEquals(TraceEnablement.DISABLED, channel.getState());
-// assertEquals(524288, channel.getSubBufferSize());
-// assertEquals(100, channel.getSwitchTimer());
-//
-// // ------------------------------------------------------------------------
-// // Verify event info (kernel, channel1)
-// // ------------------------------------------------------------------------
-// ITraceControlComponent[] channel1Events = channels[1].getChildren();
-// assertEquals(0, channel1Events.length);
-//
-// // ------------------------------------------------------------------------
-// // Verify domain UST global
-// // ------------------------------------------------------------------------
-// assertEquals("UST global", domains[1].getName());
-//
-// ITraceControlComponent[] ustChannels = domains[1].getChildren();
-//
-// for (int i = 0; i < ustChannels.length; i++) {
-// assertTrue(ustChannels[i] instanceof TraceChannelComponent);
-// }
-//
-// // ------------------------------------------------------------------------
-// // Verify UST global's mychannel1
-// // ------------------------------------------------------------------------
-// channel = (TraceChannelComponent) ustChannels[0];
-// assertEquals("mychannel1", channel.getName());
-// assertEquals(8, channel.getNumberOfSubBuffers());
-// assertEquals("mmap()", channel.getOutputType());
-// assertEquals(true, channel.isOverwriteMode());
-// assertEquals(100, channel.getReadTimer());
-// assertEquals(TraceEnablement.DISABLED, channel.getState());
-// assertEquals(8192, channel.getSubBufferSize());
-// assertEquals(200, channel.getSwitchTimer());
-//
-// // verify getters and setters
-// verifyChannelGettersSetters(channel);
-//
-// // ------------------------------------------------------------------------
-// // Verify event info (UST global, mychannel1)
-// // ------------------------------------------------------------------------
-// ITraceControlComponent[] ustEvents = channel.getChildren();
-// assertEquals(0, ustEvents.length);
-//
-// // ------------------------------------------------------------------------
-// // Verify UST global's channel0
-// // ------------------------------------------------------------------------
-// channel = (TraceChannelComponent) ustChannels[1];
-// assertEquals("channel0", channel.getName());
-// assertEquals(4, channel.getNumberOfSubBuffers());
-// assertEquals("mmap()", channel.getOutputType());
-// assertEquals(false, channel.isOverwriteMode());
-// assertEquals(200, channel.getReadTimer());
-// assertEquals(TraceEnablement.ENABLED, channel.getState());
-// assertEquals(4096, channel.getSubBufferSize());
-// assertEquals(0, channel.getSwitchTimer());
-//
-// // ------------------------------------------------------------------------
-// // Verify event info (UST global, channel0)
-// // ------------------------------------------------------------------------
-// ustEvents = channel.getChildren();
-// assertEquals(2, ustEvents.length);
-//
-// event = (TraceEventComponent) ustEvents[0];
-// assertEquals("ust_tests_hello:tptest_sighandler", event.getName());
-// assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
-// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
-// assertEquals(TraceEnablement.DISABLED, event.getState());
-//
-// event = (TraceEventComponent) ustEvents[1];
-// assertEquals("*", ustEvents[1].getName());
-// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
-// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
-// assertEquals(TraceEnablement.ENABLED, event.getState());
-//
-// // verify getters and setters
-// verifyEventGettersSetters(event);
-//
-// // disconnect
-// node.disconnect();
-// assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
-// assertNotNull(node.getImage());
-// assertNotSame(connectedImage, node.getImage());
-// }
-//
-// private void verifySessionGetterSetters(TraceSessionComponent session) {
-// // save original values
-// String name = session.getName();
-// String origPath = session.getSessionPath();
-// TraceSessionState origState = session.getSessionState();
-//
-// // test cases
-// session.setName("newName");
-// assertEquals("newName", session.getName());
-//
-// session.setSessionPath("/home/user/tmp");
-// assertEquals("/home/user/tmp", session.getSessionPath());
-//
-// session.setSessionState(TraceSessionState.INACTIVE);
-// assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
-// Image inactiveImage = session.getImage();
-// assertNotNull(inactiveImage);
-//
-// session.setSessionState("active");
-// assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
-//
-// Image activeImage = session.getImage();
-// assertNotNull(activeImage);
-// assertNotSame(activeImage, inactiveImage);
-//
-//
-// // restore original values
-// session.setName(name);
-// session.setSessionPath(origPath);
-// session.setSessionState(origState);
-// }
-//
-// private void verifyBaseEventGettersSetters(BaseEventComponent event) {
-// // save original values
-// String name = event.getName();
-// TraceLogLevel level = event.getLogLevel();
-// TraceEventType type = event.getEventType();
-//
-// // test cases
-// event.setName("newName");
-// assertEquals("newName", event.getName());
-//
-// event.setLogLevel(TraceLogLevel.TRACE_INFO);
-// assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel());
-// event.setLogLevel("TRACE_ALERT");
-// assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel());
-//
-// event.setEventType(TraceEventType.UNKNOWN);
-// assertEquals(TraceEventType.UNKNOWN, event.getEventType());
-// event.setEventType("tracepoint");
-// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
-//
-// // restore original values
-// event.setName(name);
-// event.setLogLevel(level);
-// event.setEventType(type);
-// }
-//
-// private void verifyEventGettersSetters(TraceEventComponent event) {
-// // save original values
-// String name = event.getName();
-// TraceLogLevel level = event.getLogLevel();
-// TraceEventType type = event.getEventType();
-// TraceEnablement state = event.getState();
-//
-// // test cases
-// event.setName("newName");
-// assertEquals("newName", event.getName());
-//
-// event.setLogLevel(TraceLogLevel.TRACE_INFO);
-// assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel());
-// event.setLogLevel("TRACE_ALERT");
-// assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel());
-//
-// event.setEventType(TraceEventType.UNKNOWN);
-// assertEquals(TraceEventType.UNKNOWN, event.getEventType());
-// event.setEventType("tracepoint");
-// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
-//
-// event.setState("disabled");
-// assertEquals(TraceEnablement.DISABLED, event.getState());
-//
-// Image disabledImage = event.getImage();
-// assertNotNull(disabledImage);
-//
-// event.setState(TraceEnablement.ENABLED);
-// assertEquals(TraceEnablement.ENABLED, event.getState());
-//
-// Image enabledImage = event.getImage();
-// assertNotNull(enabledImage);
-// assertNotSame(enabledImage, disabledImage);
-//
-// // restore original values
-// event.setName(name);
-// event.setLogLevel(level);
-// event.setEventType(type);
-// event.setState(state);
-// }
-//
-// private void verifyChannelGettersSetters(TraceChannelComponent channel) {
-// // save original values
-// String name = channel.getName();
-// int nbSubBuffers = channel.getNumberOfSubBuffers();
-// String type = channel.getOutputType();
-// boolean mode = channel.isOverwriteMode();
-// long readTimer = channel.getReadTimer();
-// TraceEnablement state = channel.getState();
-// long subBufferSize = channel.getSubBufferSize();
-// long switchTimer = channel.getSwitchTimer();
-//
-// // test cases
-// channel.setName("newName");
-// assertEquals("newName", channel.getName());
-//
-// channel.setNumberOfSubBuffers(2);
-// assertEquals(2, channel.getNumberOfSubBuffers());
-//
-// channel.setOutputType("splice()");
-// assertEquals("splice()", channel.getOutputType());
-//
-// channel.setOverwriteMode(false);
-// assertEquals(false, channel.isOverwriteMode());
-//
-// channel.setReadTimer(250);
-// assertEquals(250, channel.getReadTimer());
-//
-// channel.setState("enabled");
-// assertEquals(TraceEnablement.ENABLED, channel.getState());
-//
-// Image enabledImage = channel.getImage();
-// assertNotNull(enabledImage);
-// channel.setState(TraceEnablement.DISABLED);
-// assertEquals(TraceEnablement.DISABLED, channel.getState());
-//
-// Image disabledImage = channel.getImage();
-// assertNotNull(disabledImage);
-// assertNotSame(enabledImage, disabledImage);
-//
-// channel.setSubBufferSize(1024);
-// assertEquals(1024, channel.getSubBufferSize());
-//
-// channel.setSwitchTimer(1000);
-// assertEquals(1000, channel.getSwitchTimer());
-//
-// // restore original values
-// channel.setName(name);
-// channel.setNumberOfSubBuffers(nbSubBuffers);
-// channel.setOutputType(type);
-// channel.setOverwriteMode(mode);
-// channel.setReadTimer(readTimer);
-// channel.setState(state);
-// channel.setSubBufferSize(subBufferSize);
-// channel.setSwitchTimer(switchTimer);
-// }
-//
-// private void verifyUstProviderGettersSetters(UstProviderComponent ustProvider) {
-// // save original values
-// String name = ustProvider.getName();
-// int pid = ustProvider.getPid();
-//
-// // test cases
-// ustProvider.setName("newName");
-// assertEquals("newName", ustProvider.getName());
-//
-// ustProvider.setPid(9876);
-// assertEquals(9876, ustProvider.getPid());
-//
-// // restore original values
-// ustProvider.setName(name);
-// ustProvider.setPid(pid);
-// }
-
- public class CreateSessionDialogStub implements ICreateSessionDialog {
- public String fPath = null;
-
- @Override
- public String getSessionName() {
- return "mysession";
- }
-
- @Override
- public String getSessionPath() {
- return fPath;
- }
-
- @Override
- public boolean isDefaultSessionPath() {
- return fPath == null;
- }
-
- @Override
- public void setTraceSessionGroup(TraceSessionGroup group) {
-
- }
-
- @Override
- public int open() {
- return 0;
- }
-
- public void setSessionPath(String path) {
- fPath = path;
- }
- }
-
- public class GetEventInfoDialogStub implements IGetEventInfoDialog {
-
- private TraceSessionComponent[] fSessions;
-
- @Override
- public TraceSessionComponent getSession() {
- return fSessions[0];
- }
-
- @Override
- public TraceChannelComponent getChannel() {
- return null;
- }
-
- @Override
- public void setIsKernel(boolean isKernel) {
- }
-
- @Override
- public void setSessions(TraceSessionComponent[] sessions) {
- fSessions = sessions;
- }
-
- @Override
- public int open() {
- return 0;
- }
- }
-
- public class DestroyConfirmDialogStub implements IConfirmDialog {
-
- @Override
- public boolean openConfirm(Shell parent, String title, String message) {
- return true;
- }
- }
-
- public class CreateChannelOnSessionDialogStub implements ICreateChannelOnSessionDialog {
-
- @Override
- public IChannelInfo getChannelInfo() {
- ChannelInfo info = new ChannelInfo("mychannel");
- info.setNumberOfSubBuffers(2);
- info.setOverwriteMode(false);
- info.setReadTimer(100);
- info.setSwitchTimer(200);
- info.setSubBufferSize(16384);
- return info;
- }
-
- @Override
- public void setDomainComponent(TraceDomainComponent domain) {
- }
-
- @Override
- public int open() {
- return 0;
- }
-
- @Override
- public boolean isKernel() {
- return false;
- }
-
- }
-}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.handlers.IHandlerService;
-
-/**
- * Singleton class to facilitate the test cases. Creates UML2SD view and loader objects as well as provides
- * utility methods for interacting with the loader/view.
- */
-public class TraceControlTestFacility {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- final static public int WAIT_FOR_JOBS_DELAY = 1000;
- final static public int GUI_REFESH_DELAY = 500;
-
- final static public String COMMAND_CATEGORY_PREFIX = "org.eclipse.linuxtools.internal.lttng.ui.commands.control."; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- private static TraceControlTestFacility fInstance = null;
- private ControlView fControlView = null;
- private boolean fIsInitialized = false;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- private TraceControlTestFacility() {
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- public static TraceControlTestFacility getInstance() {
- if (fInstance == null) {
- fInstance = new TraceControlTestFacility();
- }
- return fInstance;
- }
-
- /**
- * Initial the test facility.
- */
- public void init() {
-
- if (!fIsInitialized) {
-
- IViewPart view;
- try {
- view = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow()
- .getActivePage()
- .showView(ControlView.ID);
-
- } catch (PartInitException e) {
- throw new RuntimeException(e);
- }
-
- fControlView = (ControlView) view;
-
- delay(3000);
- fIsInitialized = true;
- }
- }
-
-
- public void dispose() {
- if (fIsInitialized) {
- waitForJobs();
-
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(fControlView);
- fIsInitialized = false;
- }
- }
-
- public void delay(long waitTimeMillis) {
- Display display = Display.getCurrent();
- if (display != null) {
- long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
- while(System.currentTimeMillis() < endTimeMillis) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- display.update();
- }
- } else {
- try {
- Thread.sleep(waitTimeMillis);
- } catch (InterruptedException e) {
- // Ignored
- }
- }
- }
-
- /**
- * Waits for all Eclipse jobs to finish
- */
- public void waitForJobs() {
- while (!Job.getJobManager().isIdle()) {
- delay(WAIT_FOR_JOBS_DELAY);
- }
- }
-
-
- /**
- * @return current control view
- */
- public ControlView getControlView() {
- return fControlView;
- }
-
- public void executeCommand(String commandId) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
-// ICommandService commandService = (ICommandService) fControlView.getSite().getService(ICommandService.class);
- IHandlerService handlerService = (IHandlerService) fControlView.getSite().getService(IHandlerService.class);
- handlerService.executeCommand(COMMAND_CATEGORY_PREFIX + commandId, null);
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
-
-import java.io.File;
-import java.net.URL;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.KernelProviderComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceProbeEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceProviderGroup;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionGroup;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.UstProviderComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.LTTngControlService;
-import org.eclipse.linuxtools.lttng.stubs.service.TestRemoteSystemProxy;
-import org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin;
-import org.eclipse.rse.core.model.Host;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.internal.core.model.SystemProfile;
-import org.eclipse.swt.graphics.Image;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * The class <code>TraceControlTreeModelTest</code> contains tests for the tree component classes.
- */
-@SuppressWarnings("nls")
-public class TraceControlTreeModelTest extends TestCase {
-
- private static final String DIRECTORY = "testfiles";
- private static final String TEST_STREAM = "ListInfoTest.cfg";
- private static final String SCEN_LIST_INFO_TEST = "ListInfoTest";
-
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
-
- private TestRemoteSystemProxy fProxy;
- private String fTestFile;
-
- // ------------------------------------------------------------------------
- // Static methods
- // ------------------------------------------------------------------------
-
- /**
- * Returns test setup used when executing test case stand-alone.
- * @return Test setup class
- */
- public static Test suite() {
- return new ModelImplTestSetup(new TestSuite(TraceControlTreeModelTest.class));
- }
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- */
- @Override
- @Before
- public void setUp() throws Exception {
- fProxy = new TestRemoteSystemProxy();
- URL location = FileLocator.find(LTTngUITestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
- File testfile = new File(FileLocator.toFileURL(location).toURI());
- fTestFile = testfile.getAbsolutePath();
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- */
- @Override
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Run the TraceControlComponent.
- */
- public void testTraceControlComponents()
- throws Exception {
-
- fProxy.setTestFile(fTestFile);
- fProxy.setScenario(SCEN_LIST_INFO_TEST);
-
- ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
-
- @SuppressWarnings("restriction")
- IHost host = new Host(new SystemProfile("myProfile", true));
- host.setHostName("127.0.0.1");
-
- TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy);
-
- root.addChild(node);
- node.connect();
-
- TraceControlTestFacility.getInstance().waitForJobs();
-
- // ------------------------------------------------------------------------
- // Verify Parameters of TargetNodeComponent
- // ------------------------------------------------------------------------
- assertEquals("127.0.0.1", node.getHostName());
- assertEquals("127.0.0.1", node.getToolTip());
- Image connectedImage = node.getImage();
- assertNotNull(connectedImage);
- assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState());
- assertNotNull(node.getControlService());
- ILttngControlService service = node.getControlService();
- assertTrue(service instanceof LTTngControlService);
- node.setControlService(service);
- assertTrue(node.getControlService() instanceof LTTngControlService);
-
- assertTrue(node.isPassiveCommunicationsListener());
-
- // ------------------------------------------------------------------------
- // Verify Children of TargetNodeComponent
- // ------------------------------------------------------------------------
- ITraceControlComponent[] groups = node.getChildren();
- assertNotNull(groups);
- assertEquals(2, groups.length);
-
- assertTrue(groups[0] instanceof TraceProviderGroup);
- assertTrue(groups[1] instanceof TraceSessionGroup);
-
- assertEquals("Provider", groups[0].getName());
- assertEquals("Sessions", groups[1].getName());
-
- // ------------------------------------------------------------------------
- // Verify TraceProviderGroup
- // ------------------------------------------------------------------------
- ITraceControlComponent[] providers = groups[0].getChildren();
-
- assertNotNull(providers);
- assertEquals(3, providers.length);
-
- // ------------------------------------------------------------------------
- // Verify UstProviderComponent
- // ------------------------------------------------------------------------
- KernelProviderComponent kernelProvider = (KernelProviderComponent) providers[0];
-
- // ------------------------------------------------------------------------
- // Verify event info (kernel provider)
- // ------------------------------------------------------------------------
- ITraceControlComponent[] events = kernelProvider.getChildren();
- assertNotNull(events);
- assertEquals(3, events.length);
-
- BaseEventComponent baseEventInfo = (BaseEventComponent) events[0];
- assertNotNull(baseEventInfo);
- assertEquals("sched_kthread_stop", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- baseEventInfo = (BaseEventComponent) events[1];
- assertEquals("sched_kthread_stop_ret", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- baseEventInfo = (BaseEventComponent) events[2];
- assertEquals("sched_wakeup_new", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- // ------------------------------------------------------------------------
- // Verify UstProviderComponent
- // ------------------------------------------------------------------------
- UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
- assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
- assertEquals(9379, ustProvider.getPid());
-
- // ------------------------------------------------------------------------
- // Verify event info (UST provider)
- // ------------------------------------------------------------------------
- events = ustProvider.getChildren();
- assertNotNull(events);
- assertEquals(2, events.length);
-
- baseEventInfo = (BaseEventComponent) events[0];
- assertNotNull(baseEventInfo);
- assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- baseEventInfo = (BaseEventComponent) events[1];
- assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- // ------------------------------------------------------------------------
- // Verify UstProviderComponent
- // ------------------------------------------------------------------------
- ustProvider = (UstProviderComponent) providers[2];
- assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
- assertEquals(4852, ustProvider.getPid());
-
- // verify getters and setter
- verifyUstProviderGettersSetters(ustProvider);
-
- // ------------------------------------------------------------------------
- // Verify event info (UST provider)
- // ------------------------------------------------------------------------
- events = ustProvider.getChildren();
- assertNotNull(events);
- assertEquals(2, events.length);
-
- baseEventInfo = (BaseEventComponent) events[0];
- assertNotNull(baseEventInfo);
- assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- baseEventInfo = (BaseEventComponent) events[1];
- assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- // verify getters and setters
- verifyBaseEventGettersSetters(baseEventInfo);
-
- // ------------------------------------------------------------------------
- // Verify TraceSessionGroup
- // ------------------------------------------------------------------------
- ITraceControlComponent[] sessions = groups[1].getChildren();
- assertNotNull(sessions);
- assertEquals(2, sessions.length);
- for (int i = 0; i < sessions.length; i++) {
- assertTrue(sessions[i] instanceof TraceSessionComponent);
- }
- assertEquals("mysession1", sessions[0].getName());
- assertEquals("mysession", sessions[1].getName());
-
- // ------------------------------------------------------------------------
- // Verify TraceSessionComponent
- // ------------------------------------------------------------------------
- TraceSessionComponent session = (TraceSessionComponent)sessions[1];
- assertEquals("mysession", session.getName());
- assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
- assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
-
- // Verify setters and setters
- verifySessionGetterSetters(session);
-
- ITraceControlComponent[] domains = session.getChildren();
- assertNotNull(domains);
- assertEquals(2, domains.length);
-
- // ------------------------------------------------------------------------
- // Verify Kernel domain
- // ------------------------------------------------------------------------
- assertEquals("Kernel", domains[0].getName());
- ITraceControlComponent[] channels = domains[0].getChildren();
- assertNotNull(channels);
- assertEquals(2, channels.length);
-
- // ------------------------------------------------------------------------
- // Verify Kernel's channel0
- // ------------------------------------------------------------------------
- assertTrue(channels[0] instanceof TraceChannelComponent);
- TraceChannelComponent channel = (TraceChannelComponent) channels[0];
- assertEquals("channel0", channel.getName());
- assertEquals(4, channel.getNumberOfSubBuffers());
- assertEquals("splice()", channel.getOutputType());
- assertEquals(false, channel.isOverwriteMode());
- assertEquals(200, channel.getReadTimer());
- assertEquals(TraceEnablement.ENABLED, channel.getState());
- assertEquals(262144, channel.getSubBufferSize());
- assertEquals(0, channel.getSwitchTimer());
-
- // ------------------------------------------------------------------------
- // Verify event info (kernel, channel0)
- // ------------------------------------------------------------------------
- ITraceControlComponent[] channel0Events = channel.getChildren();
- assertNotNull(channel0Events);
- assertEquals(5, channel0Events.length);
- assertTrue(channel0Events[0] instanceof TraceEventComponent);
- assertTrue(channel0Events[1] instanceof TraceEventComponent);
- assertTrue(channel0Events[2] instanceof TraceProbeEventComponent);
- assertTrue(channel0Events[3] instanceof TraceProbeEventComponent);
- assertTrue(channel0Events[4] instanceof TraceEventComponent);
-
- TraceEventComponent event = (TraceEventComponent) channel0Events[0];
- assertEquals("block_rq_remap", event.getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
- assertEquals(TraceEnablement.ENABLED, event.getState());
-
- event = (TraceEventComponent) channel0Events[1];
- assertEquals("block_bio_remap", event.getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
- assertEquals(TraceEnablement.DISABLED, event.getState());
-
- TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2];
- assertEquals("myevent2", probeEvent.getName());
- assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
- assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
- assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
- assertEquals("0xc0101340", probeEvent.getAddress());
- assertNull(probeEvent.getOffset());
- assertNull(probeEvent.getSymbol());
-
- probeEvent = (TraceProbeEventComponent) channel0Events[3];
- assertEquals("myevent0", probeEvent.getName());
- assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
- assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
- assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
- assertNull(probeEvent.getAddress());
- assertEquals("0x0", probeEvent.getOffset());
- assertEquals("init_post", probeEvent.getSymbol());
-
- event = (TraceEventComponent) channel0Events[4];
- assertEquals("syscalls", event.getName());
- assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
- assertEquals(TraceEventType.SYSCALL, event.getEventType());
- assertEquals(TraceEnablement.ENABLED, event.getState());
-
- // ------------------------------------------------------------------------
- // Verify Kernel's channel1
- // ------------------------------------------------------------------------
- assertEquals("channel1", channels[1].getName());
- channel = (TraceChannelComponent) channels[1];
- assertEquals(4, channel.getNumberOfSubBuffers());
- assertEquals("splice()", channel.getOutputType());
- assertEquals(true, channel.isOverwriteMode());
- assertEquals(400, channel.getReadTimer());
- assertEquals(TraceEnablement.DISABLED, channel.getState());
- assertEquals(524288, channel.getSubBufferSize());
- assertEquals(100, channel.getSwitchTimer());
-
- // ------------------------------------------------------------------------
- // Verify event info (kernel, channel1)
- // ------------------------------------------------------------------------
- ITraceControlComponent[] channel1Events = channels[1].getChildren();
- assertEquals(0, channel1Events.length);
-
- // ------------------------------------------------------------------------
- // Verify domain UST global
- // ------------------------------------------------------------------------
- assertEquals("UST global", domains[1].getName());
-
- ITraceControlComponent[] ustChannels = domains[1].getChildren();
-
- for (int i = 0; i < ustChannels.length; i++) {
- assertTrue(ustChannels[i] instanceof TraceChannelComponent);
- }
-
- // ------------------------------------------------------------------------
- // Verify UST global's mychannel1
- // ------------------------------------------------------------------------
- channel = (TraceChannelComponent) ustChannels[0];
- assertEquals("mychannel1", channel.getName());
- assertEquals(8, channel.getNumberOfSubBuffers());
- assertEquals("mmap()", channel.getOutputType());
- assertEquals(true, channel.isOverwriteMode());
- assertEquals(100, channel.getReadTimer());
- assertEquals(TraceEnablement.DISABLED, channel.getState());
- assertEquals(8192, channel.getSubBufferSize());
- assertEquals(200, channel.getSwitchTimer());
-
- // verify getters and setters
- verifyChannelGettersSetters(channel);
-
- // ------------------------------------------------------------------------
- // Verify event info (UST global, mychannel1)
- // ------------------------------------------------------------------------
- ITraceControlComponent[] ustEvents = channel.getChildren();
- assertEquals(0, ustEvents.length);
-
- // ------------------------------------------------------------------------
- // Verify UST global's channel0
- // ------------------------------------------------------------------------
- channel = (TraceChannelComponent) ustChannels[1];
- assertEquals("channel0", channel.getName());
- assertEquals(4, channel.getNumberOfSubBuffers());
- assertEquals("mmap()", channel.getOutputType());
- assertEquals(false, channel.isOverwriteMode());
- assertEquals(200, channel.getReadTimer());
- assertEquals(TraceEnablement.ENABLED, channel.getState());
- assertEquals(4096, channel.getSubBufferSize());
- assertEquals(0, channel.getSwitchTimer());
-
- // ------------------------------------------------------------------------
- // Verify event info (UST global, channel0)
- // ------------------------------------------------------------------------
- ustEvents = channel.getChildren();
- assertEquals(2, ustEvents.length);
-
- event = (TraceEventComponent) ustEvents[0];
- assertEquals("ust_tests_hello:tptest_sighandler", event.getName());
- assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
- assertEquals(TraceEnablement.DISABLED, event.getState());
-
- event = (TraceEventComponent) ustEvents[1];
- assertEquals("*", ustEvents[1].getName());
- assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
- assertEquals(TraceEnablement.ENABLED, event.getState());
-
- // verify getters and setters
- verifyEventGettersSetters(event);
-
- // disconnect
- node.disconnect();
- assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
- assertNotNull(node.getImage());
- assertNotSame(connectedImage, node.getImage());
- }
-
- private void verifySessionGetterSetters(TraceSessionComponent session) {
- // save original values
- String name = session.getName();
- String origPath = session.getSessionPath();
- TraceSessionState origState = session.getSessionState();
-
- // test cases
- session.setName("newName");
- assertEquals("newName", session.getName());
-
- session.setSessionPath("/home/user/tmp");
- assertEquals("/home/user/tmp", session.getSessionPath());
-
- session.setSessionState(TraceSessionState.INACTIVE);
- assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
- Image inactiveImage = session.getImage();
- assertNotNull(inactiveImage);
-
- session.setSessionState("active");
- assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
-
- Image activeImage = session.getImage();
- assertNotNull(activeImage);
- assertNotSame(activeImage, inactiveImage);
-
-
- // restore original values
- session.setName(name);
- session.setSessionPath(origPath);
- session.setSessionState(origState);
- }
-
- private void verifyBaseEventGettersSetters(BaseEventComponent event) {
- // save original values
- String name = event.getName();
- TraceLogLevel level = event.getLogLevel();
- TraceEventType type = event.getEventType();
-
- // test cases
- event.setName("newName");
- assertEquals("newName", event.getName());
-
- event.setLogLevel(TraceLogLevel.TRACE_INFO);
- assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel());
- event.setLogLevel("TRACE_ALERT");
- assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel());
-
- event.setEventType(TraceEventType.UNKNOWN);
- assertEquals(TraceEventType.UNKNOWN, event.getEventType());
- event.setEventType("tracepoint");
- assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
-
- // restore original values
- event.setName(name);
- event.setLogLevel(level);
- event.setEventType(type);
- }
-
- private void verifyEventGettersSetters(TraceEventComponent event) {
- // save original values
- String name = event.getName();
- TraceLogLevel level = event.getLogLevel();
- TraceEventType type = event.getEventType();
- TraceEnablement state = event.getState();
-
- // test cases
- event.setName("newName");
- assertEquals("newName", event.getName());
-
- event.setLogLevel(TraceLogLevel.TRACE_INFO);
- assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel());
- event.setLogLevel("TRACE_ALERT");
- assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel());
-
- event.setEventType(TraceEventType.UNKNOWN);
- assertEquals(TraceEventType.UNKNOWN, event.getEventType());
- event.setEventType("tracepoint");
- assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
-
- event.setState("disabled");
- assertEquals(TraceEnablement.DISABLED, event.getState());
-
- Image disabledImage = event.getImage();
- assertNotNull(disabledImage);
-
- event.setState(TraceEnablement.ENABLED);
- assertEquals(TraceEnablement.ENABLED, event.getState());
-
- Image enabledImage = event.getImage();
- assertNotNull(enabledImage);
- assertNotSame(enabledImage, disabledImage);
-
- // restore original values
- event.setName(name);
- event.setLogLevel(level);
- event.setEventType(type);
- event.setState(state);
- }
-
- private void verifyChannelGettersSetters(TraceChannelComponent channel) {
- // save original values
- String name = channel.getName();
- int nbSubBuffers = channel.getNumberOfSubBuffers();
- String type = channel.getOutputType();
- boolean mode = channel.isOverwriteMode();
- long readTimer = channel.getReadTimer();
- TraceEnablement state = channel.getState();
- long subBufferSize = channel.getSubBufferSize();
- long switchTimer = channel.getSwitchTimer();
-
- // test cases
- channel.setName("newName");
- assertEquals("newName", channel.getName());
-
- channel.setNumberOfSubBuffers(2);
- assertEquals(2, channel.getNumberOfSubBuffers());
-
- channel.setOutputType("splice()");
- assertEquals("splice()", channel.getOutputType());
-
- channel.setOverwriteMode(false);
- assertEquals(false, channel.isOverwriteMode());
-
- channel.setReadTimer(250);
- assertEquals(250, channel.getReadTimer());
-
- channel.setState("enabled");
- assertEquals(TraceEnablement.ENABLED, channel.getState());
-
- Image enabledImage = channel.getImage();
- assertNotNull(enabledImage);
- channel.setState(TraceEnablement.DISABLED);
- assertEquals(TraceEnablement.DISABLED, channel.getState());
-
- Image disabledImage = channel.getImage();
- assertNotNull(disabledImage);
- assertNotSame(enabledImage, disabledImage);
-
- channel.setSubBufferSize(1024);
- assertEquals(1024, channel.getSubBufferSize());
-
- channel.setSwitchTimer(1000);
- assertEquals(1000, channel.getSwitchTimer());
-
- // restore original values
- channel.setName(name);
- channel.setNumberOfSubBuffers(nbSubBuffers);
- channel.setOutputType(type);
- channel.setOverwriteMode(mode);
- channel.setReadTimer(readTimer);
- channel.setState(state);
- channel.setSubBufferSize(subBufferSize);
- channel.setSwitchTimer(switchTimer);
- }
-
- private void verifyUstProviderGettersSetters(UstProviderComponent ustProvider) {
- // save original values
- String name = ustProvider.getName();
- int pid = ustProvider.getPid();
-
- // test cases
- ustProvider.setName("newName");
- assertEquals("newName", ustProvider.getName());
-
- ustProvider.setPid(9876);
- assertEquals(9876, ustProvider.getPid());
-
- // restore original values
- ustProvider.setName(name);
- ustProvider.setPid(pid);
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests {
-
- public static Test suite() {
-
- TestSuite suite = new TestSuite(AllTests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(BaseEventInfoTest.class);
- suite.addTestSuite(DomainInfoTest.class);
- suite.addTestSuite(EventInfoTest.class);
- suite.addTestSuite(ProbeEventInfoTest.class);
- suite.addTestSuite(ChannelInfoTest.class);
- suite.addTestSuite(SessionInfoTest.class);
- suite.addTestSuite(TraceInfoTest.class);
- suite.addTestSuite(UstProviderInfoTest.class);
- //$JUnit-END$
- return suite;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import junit.framework.TestCase;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo;
-
-/**
- * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>.
- */
-@SuppressWarnings("nls")
-public class BaseEventInfoTest extends TestCase {
-
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
- private IBaseEventInfo fEventInfo1 = null;
- private IBaseEventInfo fEventInfo2 = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception if the initialization fails for some reason
- *
- */
- @Override
- public void setUp() throws Exception {
- super.setUp();
- ModelImplFactory factory = new ModelImplFactory();
- fEventInfo1 = factory.getBaseEventInfo1();
- fEventInfo2 = factory.getBaseEventInfo2();
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() throws Exception {
- }
-
- // ------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------
-
- /**
- * Run the BaseEventInfo() constructor test.
- *
- */
- public void testBaseEventInfo() {
- BaseEventInfo fixture = new BaseEventInfo("event");
- assertNotNull(fixture);
-
- TraceEventType result = fixture.getEventType();
-
- assertEquals("event", fixture.getName());
- assertEquals("unknown", result.getInName());
- assertEquals("UNKNOWN", result.name());
- assertEquals("UNKNOWN", result.toString());
- assertEquals(3, result.ordinal());
-
- TraceLogLevel level = fixture.getLogLevel();
- assertEquals("TRACE_DEBUG", level.getInName());
- assertEquals("TRACE_DEBUG", level.name());
- assertEquals("TRACE_DEBUG", level.toString());
- assertEquals(14, level.ordinal());
- }
-
- /**
- * Test Copy Constructor
- */
- public void testEventInfoCopy() {
- BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo1);
-
- assertEquals(fEventInfo1.getName(), info.getName());
- assertEquals(fEventInfo1.getEventType(), info.getEventType());
- assertEquals(fEventInfo1.getLogLevel(), info.getLogLevel());
- }
-
- /**
- * Test Copy Constructor
- */
- public void testEventCopy2() {
- try {
- BaseEventInfo info = null;
- new BaseEventInfo(info);
- fail("null copy");
- }
- catch (IllegalArgumentException e) {
- // Success
- }
- }
-
- /**
- * Run the TraceEventType getEventType() method test.
- *
- * @throws Exception
- *
- */
- public void testGetEventType_1() {
- BaseEventInfo fixture = new BaseEventInfo("event");
- fixture.setEventType("unknown");
-
- TraceEventType result = fixture.getEventType();
-
- assertNotNull(result);
- assertEquals("unknown", result.getInName());
- assertEquals("UNKNOWN", result.name());
- assertEquals("UNKNOWN", result.toString());
- assertEquals(3, result.ordinal());
-
- fixture.setEventType("");
- result = fixture.getEventType();
- assertEquals("unknown", result.getInName());
- assertEquals("UNKNOWN", result.name());
- assertEquals("UNKNOWN", result.toString());
- assertEquals(3, result.ordinal());
-
- fixture.setEventType("tracepoint");
- result = fixture.getEventType();
- assertNotNull(result);
- assertEquals("tracepoint", result.getInName());
- assertEquals("TRACEPOINT", result.name());
- assertEquals("TRACEPOINT", result.toString());
- assertEquals(0, result.ordinal());
-
- fixture.setEventType("syscall");
- result = fixture.getEventType();
- assertNotNull(result);
- assertEquals("syscall", result.getInName());
- assertEquals("SYSCALL", result.name());
- assertEquals("SYSCALL", result.toString());
- assertEquals(1, result.ordinal());
-
- fixture.setEventType("probe");
- result = fixture.getEventType();
- assertNotNull(result);
- assertEquals("probe", result.getInName());
- assertEquals("PROBE", result.name());
- assertEquals("PROBE", result.toString());
- assertEquals(2, result.ordinal());
-
- }
-
- /**
- * Run the void setEventType(TraceEventType) method test.
- *
- */
- public void testSetEventType_2() {
- BaseEventInfo fixture = new BaseEventInfo("event");
- fixture.setEventType(TraceEventType.TRACEPOINT);
-
- TraceEventType result = fixture.getEventType();
-
- assertNotNull(result);
- assertEquals("tracepoint", result.getInName());
- assertEquals("TRACEPOINT", result.name());
- assertEquals("TRACEPOINT", result.toString());
- assertEquals(0, result.ordinal());
-
- fixture.setEventType(TraceEventType.UNKNOWN);
- result = fixture.getEventType();
-
- assertNotNull(result);
- assertEquals("unknown", result.getInName());
- assertEquals("UNKNOWN", result.name());
- assertEquals("UNKNOWN", result.toString());
- assertEquals(3, result.ordinal());
-
- fixture.setEventType(TraceEventType.SYSCALL);
- result = fixture.getEventType();
- assertNotNull(result);
- assertEquals("syscall", result.getInName());
- assertEquals("SYSCALL", result.name());
- assertEquals("SYSCALL", result.toString());
- assertEquals(1, result.ordinal());
-
- fixture.setEventType(TraceEventType.PROBE);
- result = fixture.getEventType();
- assertNotNull(result);
- assertEquals("probe", result.getInName());
- assertEquals("PROBE", result.name());
- assertEquals("PROBE", result.toString());
- assertEquals(2, result.ordinal());
-
- }
-
- /**
- * Run the void setLogLevel(TraceLogLevel) method test.
- * Run the TraceLogLevel getLogLevel() method test
- *
- */
- public void testSetLogLevel1() {
- BaseEventInfo fixture = new BaseEventInfo("event");
- fixture.setEventType(TraceEventType.TRACEPOINT);
- fixture.setLogLevel(TraceLogLevel.TRACE_CRIT);
-
- // 2 set/get-operations are enough to test the method
- TraceLogLevel result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_CRIT", result.getInName());
- assertEquals("TRACE_CRIT", result.name());
- assertEquals("TRACE_CRIT", result.toString());
- assertEquals(2, result.ordinal());
-
- fixture.setLogLevel(TraceLogLevel.TRACE_DEBUG_FUNCTION);
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_DEBUG_FUNCTION", result.getInName());
- assertEquals("TRACE_DEBUG_FUNCTION", result.name());
- assertEquals("TRACE_DEBUG_FUNCTION", result.toString());
- assertEquals(12, result.ordinal());
- }
-
- /**
- * Run the void setLogLevel(String) method test.
- * Run the TraceLogLevel getLogLevel() method test
- *
- */
- public void testSetLogLevel2() {
- BaseEventInfo fixture = new BaseEventInfo("event");
- fixture.setEventType(TraceEventType.TRACEPOINT);
- fixture.setLogLevel("TRACE_EMERG");
-
- TraceLogLevel result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_EMERG", result.getInName());
- assertEquals("TRACE_EMERG", result.name());
- assertEquals(0, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_ALERT");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_ALERT", result.getInName());
- assertEquals("TRACE_ALERT", result.name());
- assertEquals(1, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_CRIT");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_CRIT", result.getInName());
- assertEquals("TRACE_CRIT", result.name());
- assertEquals(2, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_ERR");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_ERR", result.getInName());
- assertEquals("TRACE_ERR", result.name());
- assertEquals(3, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_WARNING");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_WARNING", result.getInName());
- assertEquals("TRACE_WARNING", result.name());
- assertEquals(4, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_NOTICE");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_NOTICE", result.getInName());
- assertEquals("TRACE_NOTICE", result.name());
- assertEquals(5, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_INFO");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_INFO", result.getInName());
- assertEquals("TRACE_INFO", result.name());
- assertEquals(6, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_DEBUG_SYSTEM");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_DEBUG_SYSTEM", result.getInName());
- assertEquals("TRACE_DEBUG_SYSTEM", result.name());
- assertEquals(7, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_DEBUG_PROGRAM");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_DEBUG_PROGRAM", result.getInName());
- assertEquals("TRACE_DEBUG_PROGRAM", result.name());
- assertEquals(8, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_DEBUG_PROCESS");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_DEBUG_PROCESS", result.getInName());
- assertEquals("TRACE_DEBUG_PROCESS", result.name());
- assertEquals(9, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_DEBUG_MODULE");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_DEBUG_MODULE", result.getInName());
- assertEquals("TRACE_DEBUG_MODULE", result.name());
- assertEquals(10, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_DEBUG_UNIT");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_DEBUG_UNIT", result.getInName());
- assertEquals("TRACE_DEBUG_UNIT", result.name());
- assertEquals(11, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_DEBUG_FUNCTION");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_DEBUG_FUNCTION", result.getInName());
- assertEquals("TRACE_DEBUG_FUNCTION", result.name());
- assertEquals(12, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_DEBUG_LINE");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_DEBUG_LINE", result.getInName());
- assertEquals("TRACE_DEBUG_LINE", result.name());
- assertEquals(13, result.ordinal());
-
- //------------------------
- fixture.setLogLevel("TRACE_DEBUG");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_DEBUG", result.getInName());
- assertEquals("TRACE_DEBUG", result.name());
- assertEquals(14, result.ordinal());
-
- //-------------------------
- fixture.setLogLevel("LEVEL_UNKNOWN");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("LEVEL_UNKNOWN", result.getInName());
- assertEquals("LEVEL_UNKNOWN", result.name());
- assertEquals(15, result.ordinal());
-
- fixture.setLogLevel("garbage");
-
- result = fixture.getLogLevel();
- assertNotNull(result);
- assertEquals("TRACE_DEBUG", result.getInName());
- assertEquals("TRACE_DEBUG", result.name());
- assertEquals(14, result.ordinal());
- }
-
-
- /**
- * Run the String toString() method test.
- *
- */
- public void testToString_1() {
- BaseEventInfo fixture = new BaseEventInfo("event");
- fixture.setName("testName");
- fixture.setEventType(TraceEventType.TRACEPOINT);
- fixture.setLogLevel(TraceLogLevel.TRACE_ERR);
-
- String result = fixture.toString();
-
- // add additional test code here
- assertEquals("[BaseEventInfo([TraceInfo(Name=testName)],type=TRACEPOINT,level=TRACE_ERR)]", result);
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- public void testEqualsReflexivity() {
- assertTrue("equals", fEventInfo1.equals(fEventInfo1));
- assertTrue("equals", fEventInfo2.equals(fEventInfo2));
-
- assertTrue("equals", !fEventInfo1.equals(fEventInfo2));
- assertTrue("equals", !fEventInfo2.equals(fEventInfo1));
- }
-
- public void testEqualsSymmetry() {
- BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
- BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2);
-
- assertTrue("equals", info1.equals(fEventInfo1));
- assertTrue("equals", fEventInfo1.equals(info1));
-
- assertTrue("equals", info2.equals(fEventInfo2));
- assertTrue("equals", fEventInfo2.equals(info2));
- }
-
- public void testEqualsTransivity() {
- BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
- BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
- BaseEventInfo info3 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
-
- assertTrue("equals", info1.equals(info2));
- assertTrue("equals", info2.equals(info3));
- assertTrue("equals", info1.equals(info3));
- }
-
- public void testEqualsNull() {
- assertTrue("equals", !fEventInfo1.equals(null));
- assertTrue("equals", !fEventInfo2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- public void testHashCode() {
- BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
- BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2);
-
- assertTrue("hashCode", fEventInfo1.hashCode() == info1.hashCode());
- assertTrue("hashCode", fEventInfo2.hashCode() == info2.hashCode());
-
- assertTrue("hashCode", fEventInfo1.hashCode() != info2.hashCode());
- assertTrue("hashCode", fEventInfo2.hashCode() != info1.hashCode());
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.ChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.EventInfo;
-
-/**
- * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link ChannelInfo}</code>.
- *
- */
-@SuppressWarnings("nls")
-public class ChannelInfoTest extends TestCase {
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
- private IChannelInfo fChannelInfo1 = null;
- private IChannelInfo fChannelInfo2 = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- */
- @Override
- public void setUp() {
- ModelImplFactory factory = new ModelImplFactory();
- fChannelInfo1 = factory.getChannel1();
- fChannelInfo2 = factory.getChannel2();
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() {
- }
-
- // ------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Run the ChannelInfo() constructor test.
- *
- */
- public void testChannelInfo() {
- ChannelInfo result = new ChannelInfo("test");
- assertNotNull(result);
-
- assertEquals("test", result.getName());
- assertEquals(0, result.getNumberOfSubBuffers());
- assertEquals("", result.getOutputType());
- assertEquals(false, result.isOverwriteMode());
- assertEquals(0, result.getReadTimer());
- assertEquals("disabled", result.getState().getInName());
- assertEquals(0, result.getSubBufferSize());
- assertEquals(0, result.getSwitchTimer());
- }
-
- public void testChannelInfoCopy() {
- ChannelInfo channelInfo = new ChannelInfo((ChannelInfo)fChannelInfo1);
-
- assertEquals(fChannelInfo1.getName(), channelInfo.getName());
- assertEquals(fChannelInfo1.getNumberOfSubBuffers(), channelInfo.getNumberOfSubBuffers());
- assertEquals(fChannelInfo1.getOutputType(), channelInfo.getOutputType());
- assertEquals(fChannelInfo1.isOverwriteMode(), channelInfo.isOverwriteMode());
- assertEquals(fChannelInfo1.getReadTimer(), channelInfo.getReadTimer());
- assertEquals(fChannelInfo1.getState(), channelInfo.getState());
- assertEquals(fChannelInfo1.getSwitchTimer(), channelInfo.getSwitchTimer());
- assertEquals(fChannelInfo1.getEvents().length, channelInfo.getEvents().length);
-
- IEventInfo[] orignalEvents = fChannelInfo1.getEvents();
- IEventInfo[] resultEvents = channelInfo.getEvents();
- for (int i = 0; i < orignalEvents.length; i++) {
- assertEquals(orignalEvents[i], resultEvents[i]);
- }
- }
-
- public void testChannelCopy2() {
- try {
- ChannelInfo channel = null;
- new ChannelInfo(channel);
- fail("null copy");
- }
- catch (IllegalArgumentException e) {
- // Success
- }
- }
-
- /**
- * Run the IEventInfo[] getEvents() method test.
- *
- */
- public void testAddAndGetEvents_1() {
- ChannelInfo fixture = new ChannelInfo("test");
- fixture.setSwitchTimer(1L);
- fixture.setOverwriteMode(true);
- fixture.setReadTimer(1L);
- fixture.setState(TraceEnablement.DISABLED);
- fixture.setNumberOfSubBuffers(1);
- fixture.setOutputType("");
- fixture.setSubBufferSize(1L);
-
- // add an event
- IEventInfo event = new EventInfo("event");
- fixture.addEvent(event);
-
- // Verify the stored events
- IEventInfo[] result = fixture.getEvents();
-
- assertNotNull(result);
- assertEquals(1, result.length);
- assertNotNull(result[0]);
- assertTrue(event.equals(result[0]));
- }
-
- /**
- * Run the long getNumberOfSubBuffers() method test.
- *
- */
- public void testGetAndSetters() {
- ChannelInfo fixture = new ChannelInfo("test");
- fixture.setSwitchTimer(2L);
- fixture.setOverwriteMode(true);
- fixture.setReadTimer(3L);
- fixture.setState(TraceEnablement.DISABLED);
- fixture.setNumberOfSubBuffers(4);
- fixture.setOutputType("splice()");
- fixture.setSubBufferSize(1L);
- fixture.addEvent(new EventInfo("event"));
-
- long switchTimer = fixture.getSwitchTimer();
- assertEquals(2L, switchTimer);
-
- boolean mode = fixture.isOverwriteMode();
- assertTrue(mode);
-
- long readTimer = fixture.getReadTimer();
- assertEquals(3L, readTimer);
-
- TraceEnablement state = fixture.getState();
- assertEquals("disabled", state.getInName());
-
- long numSubBuffers = fixture.getNumberOfSubBuffers();
- assertEquals(4, numSubBuffers);
-
- String outputType = fixture.getOutputType();
- assertEquals("splice()", outputType);
-
- long subBufferSize = fixture.getSubBufferSize();
- assertEquals(1L, subBufferSize);
-
- fixture.setSwitchTimer(5L);
- fixture.setOverwriteMode(false);
- fixture.setReadTimer(6L);
- fixture.setState(TraceEnablement.ENABLED);
- fixture.setNumberOfSubBuffers(7);
- fixture.setOutputType("mmap()");
- fixture.setSubBufferSize(8L);
-
- switchTimer = fixture.getSwitchTimer();
- assertEquals(5L, switchTimer);
-
- mode = fixture.isOverwriteMode();
- assertFalse(mode);
-
- readTimer = fixture.getReadTimer();
- assertEquals(6L, readTimer);
-
- state = fixture.getState();
- assertEquals("enabled", state.getInName());
-
- numSubBuffers = fixture.getNumberOfSubBuffers();
- assertEquals(7, numSubBuffers);
-
- outputType = fixture.getOutputType();
- assertEquals("mmap()", outputType);
-
- subBufferSize = fixture.getSubBufferSize();
- assertEquals(8L, subBufferSize);
- }
-
- /**
- * Run the void setEvents(List<IEventInfo>) method test.
- *
- */
- public void testSetEvents_1() {
- ChannelInfo fixture = new ChannelInfo("test");
- fixture.setSwitchTimer(1L);
- fixture.setOverwriteMode(true);
- fixture.setReadTimer(1L);
- fixture.setState(TraceEnablement.DISABLED);
- fixture.setNumberOfSubBuffers(1);
- fixture.setOutputType("");
- fixture.setSubBufferSize(1L);
- List<IEventInfo> events = new LinkedList<IEventInfo>();
-
- for (int i = 0; i < 2; i++) {
- IEventInfo info = new EventInfo("event" + i);
- info.setEventType("tracepoint");
- info.setState((i % 2 == 0 ? "enabled" : "disabled"));
- events.add(info);
- }
-
- fixture.setEvents(events);
-
- IEventInfo[] infos = fixture.getEvents();
-
- assertEquals(events.size(), infos.length);
-
- for (int i = 0; i < infos.length; i++) {
- assertEquals(events.get(i), infos[i]);
- }
- }
-
- public void testToString_1() {
- ChannelInfo fixture = new ChannelInfo("channel");
- fixture.setSwitchTimer(1L);
- fixture.setOverwriteMode(true);
- fixture.setReadTimer(1L);
- fixture.setState(TraceEnablement.DISABLED);
- fixture.setNumberOfSubBuffers(1);
- fixture.setOutputType("splice()");
- fixture.setSubBufferSize(1L);
-
- String result = fixture.toString();
-
- // add additional test code here
- assertEquals("[ChannelInfo([TraceInfo(Name=channel)],State=DISABLED,OverwriteMode=true,SubBuffersSize=1,NumberOfSubBuffers=1,SwitchTimer=1,ReadTimer=1,output=splice(),Events=None)]", result);
- }
-
- /**
- * Run the String toString() method test.
- *
- */
- public void testToString_2() {
- String result = fChannelInfo1.toString();
-
- // add additional test code here
- assertEquals("[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])]", result);
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- public void testEqualsReflexivity() {
- assertTrue("equals", fChannelInfo1.equals(fChannelInfo1));
- assertTrue("equals", fChannelInfo2.equals(fChannelInfo2));
-
- assertTrue("equals", !fChannelInfo1.equals(fChannelInfo2));
- assertTrue("equals", !fChannelInfo2.equals(fChannelInfo1));
- }
-
- public void testEqualsSymmetry() {
- ChannelInfo event1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
- ChannelInfo event2 = new ChannelInfo((ChannelInfo)fChannelInfo2);
-
- assertTrue("equals", event1.equals(fChannelInfo1));
- assertTrue("equals", fChannelInfo1.equals(event1));
-
- assertTrue("equals", event2.equals(fChannelInfo2));
- assertTrue("equals", fChannelInfo2.equals(event2));
- }
-
- public void testEqualsTransivity() {
- ChannelInfo channel1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
- ChannelInfo channel2 = new ChannelInfo((ChannelInfo)fChannelInfo1);
- ChannelInfo channel3 = new ChannelInfo((ChannelInfo)fChannelInfo1);
-
- assertTrue("equals", channel1.equals(channel2));
- assertTrue("equals", channel2.equals(channel3));
- assertTrue("equals", channel1.equals(channel3));
- }
-
- public void testEqualsNull() throws Exception {
- assertTrue("equals", !fChannelInfo1.equals(null));
- assertTrue("equals", !fChannelInfo2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- public void testHashCode() {
- ChannelInfo channel1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
- ChannelInfo channel2 = new ChannelInfo((ChannelInfo)fChannelInfo2);
-
- assertTrue("hashCode", fChannelInfo1.hashCode() == channel1.hashCode());
- assertTrue("hashCode", fChannelInfo2.hashCode() == channel2.hashCode());
-
- assertTrue("hashCode", fChannelInfo1.hashCode() != channel2.hashCode());
- assertTrue("hashCode", fChannelInfo2.hashCode() != channel1.hashCode());
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.DomainInfo;
-
-/**
- * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link DomainInfo}</code>.
- *
- */
-@SuppressWarnings("nls")
-public class DomainInfoTest extends TestCase {
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
- private IDomainInfo fDomainInfo1 = null;
- private IDomainInfo fDomainInfo2 = null;
- private IChannelInfo fChannelInfo1 = null;
- private IChannelInfo fChannelInfo2 = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- */
- @Override
- public void setUp() {
- // Get test instances from the factory
- ModelImplFactory factory = new ModelImplFactory();
- fChannelInfo1 = factory.getChannel1();
- fChannelInfo2 = factory.getChannel2();
- fDomainInfo1 = factory.getDomainInfo1();
- fDomainInfo2 = factory.getDomainInfo2();
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() {
- }
-
- // ------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Run the ChannelInfo() constructor test.
- *
- */
- public void testDomainInfo() {
- DomainInfo result = new DomainInfo("test");
- assertNotNull(result);
-
- assertEquals("test", result.getName());
- assertEquals(0, result.getChannels().length);
- }
-
- public void testDomainInfoCopy() {
- DomainInfo channelInfo = new DomainInfo((DomainInfo)fDomainInfo1);
- IChannelInfo[] orignalEvents = fDomainInfo1.getChannels();
- IChannelInfo[] resultEvents = channelInfo.getChannels();
- for (int i = 0; i < orignalEvents.length; i++) {
- assertEquals(orignalEvents[i], resultEvents[i]);
- }
- }
-
- public void testDomainlCopy2() {
- try {
- DomainInfo domain = null;
- new DomainInfo(domain);
- fail("null copy");
- }
- catch (IllegalArgumentException e) {
- // Success
- }
- }
-
- /**
- * Run the long getNumberOfSubBuffers() method test.
- *
- */
- public void testGetAndSetters() {
-
- // Note that addChannel() has been executed in setUp()
- // check get method here
- assertEquals(1, fDomainInfo1.getChannels().length);
- assertNotNull(fDomainInfo1.getChannels()[0]);
- assertEquals(fChannelInfo1, fDomainInfo1.getChannels()[0]);
-
- IDomainInfo domain = new DomainInfo("domain");
- List<IChannelInfo> list = new LinkedList<IChannelInfo>();
- list.add(fChannelInfo1);
- list.add(fChannelInfo2);
- domain.setChannels(list);
-
- IChannelInfo[] result = domain.getChannels();
- assertEquals(2, result.length);
- assertEquals(fChannelInfo1, result[0]);
- assertEquals(fChannelInfo2, result[1]);
- }
-
- public void testToString_1() {
- DomainInfo fixture = new DomainInfo("domain");
-
- String result = fixture.toString();
-
- assertEquals("[DomainInfo([TraceInfo(Name=domain)],Channels=None,isKernel=false)]", result);
- }
-
- /**
- * Run the String toString() method test.
- *
- */
- public void testToString_2() {
- String result = fDomainInfo1.toString();
-
- assertEquals("[DomainInfo([TraceInfo(Name=test1)],Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],isKernel=false)]", result);
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- public void testEqualsReflexivity() {
- assertTrue("equals", fDomainInfo1.equals(fDomainInfo1));
- assertTrue("equals", fDomainInfo2.equals(fDomainInfo2));
-
- assertTrue("equals", !fDomainInfo1.equals(fDomainInfo2));
- assertTrue("equals", !fDomainInfo2.equals(fDomainInfo1));
- }
-
- public void testEqualsSymmetry() {
- DomainInfo event1 = new DomainInfo((DomainInfo)fDomainInfo1);
- DomainInfo event2 = new DomainInfo((DomainInfo)fDomainInfo2);
-
- assertTrue("equals", event1.equals(fDomainInfo1));
- assertTrue("equals", fDomainInfo1.equals(event1));
-
- assertTrue("equals", event2.equals(fDomainInfo2));
- assertTrue("equals", fDomainInfo2.equals(event2));
- }
-
- public void testEqualsTransivity() {
- DomainInfo channel1 = new DomainInfo((DomainInfo)fDomainInfo1);
- DomainInfo channel2 = new DomainInfo((DomainInfo)fDomainInfo1);
- DomainInfo channel3 = new DomainInfo((DomainInfo)fDomainInfo1);
-
- assertTrue("equals", channel1.equals(channel2));
- assertTrue("equals", channel2.equals(channel3));
- assertTrue("equals", channel1.equals(channel3));
- }
-
- public void testEqualsNull() throws Exception {
- assertTrue("equals", !fDomainInfo1.equals(null));
- assertTrue("equals", !fDomainInfo2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- public void testHashCode() {
- DomainInfo channel1 = new DomainInfo((DomainInfo)fDomainInfo1);
- DomainInfo channel2 = new DomainInfo((DomainInfo)fDomainInfo2);
-
- assertTrue("hashCode", fDomainInfo1.hashCode() == channel1.hashCode());
- assertTrue("hashCode", fDomainInfo2.hashCode() == channel2.hashCode());
-
- assertTrue("hashCode", fDomainInfo1.hashCode() != channel2.hashCode());
- assertTrue("hashCode", fDomainInfo2.hashCode() != channel1.hashCode());
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import junit.framework.TestCase;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.EventInfo;
-
-/**
- * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>.
- */
-@SuppressWarnings("nls")
-public class EventInfoTest extends TestCase {
-
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
- private IEventInfo fEventInfo1 = null;
- private IEventInfo fEventInfo2 = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception if the initialization fails for some reason
- *
- */
- @Override
- public void setUp() throws Exception {
- ModelImplFactory factory = new ModelImplFactory();
- fEventInfo1 = factory.getEventInfo1();
- fEventInfo2 = factory.getEventInfo2();
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() throws Exception {
- }
-
- // ------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------
-
- /**
- * Run the BaseEventInfo() constructor test.
- *
- */
- public void testBaseEventInfo() {
- EventInfo fixture = new EventInfo("event");
- assertNotNull(fixture);
-
- TraceEventType result = fixture.getEventType();
-
- assertEquals("event", fixture.getName());
- assertEquals("unknown", result.getInName());
- assertEquals("UNKNOWN", result.name());
- assertEquals("UNKNOWN", result.toString());
- assertEquals(3, result.ordinal());
-
- TraceEnablement state = fixture.getState();
- assertEquals("disabled", state.getInName());
- assertEquals("DISABLED", state.name());
- assertEquals("DISABLED", state.toString());
- assertEquals(0, state.ordinal());
-
- }
-
- /**
- * Test Copy Constructor
- */
- public void testEventInfoCopy() {
- EventInfo info = new EventInfo((EventInfo)fEventInfo1);
-
- assertEquals(fEventInfo1.getName(), info.getName());
- assertEquals(fEventInfo1.getEventType(), info.getEventType());
- assertEquals(fEventInfo1.getState(), info.getState());
- }
-
- /**
- * Test Copy Constructor
- */
- public void testEventCopy2() {
- try {
- EventInfo info = null;
- new EventInfo(info);
- fail("null copy");
- }
- catch (IllegalArgumentException e) {
- // Success
- }
- }
-
- /**
- * Getter/Setter tests
- */
- public void testGetAndSetter() {
- EventInfo fixture = new EventInfo("event");
-
- fixture.setEventType(TraceEventType.TRACEPOINT);
- TraceEventType result = fixture.getEventType();
-
- // setEventType(TraceEventType type)
- assertNotNull(result);
- assertEquals("tracepoint", result.getInName());
- assertEquals("TRACEPOINT", result.name());
- assertEquals("TRACEPOINT", result.toString());
- assertEquals(0, result.ordinal());
-
- fixture.setEventType(TraceEventType.UNKNOWN);
- result = fixture.getEventType();
- assertEquals("unknown", result.getInName());
- assertEquals("UNKNOWN", result.name());
- assertEquals("UNKNOWN", result.toString());
- assertEquals(3, result.ordinal());
-
- // setEventType(String typeName)
- String typeName = "";
- fixture.setEventType(typeName);
- result = fixture.getEventType();
-
- assertEquals("unknown", result.getInName());
- assertEquals("UNKNOWN", result.name());
- assertEquals("UNKNOWN", result.toString());
- assertEquals(3, result.ordinal());
-
- typeName = "unknown";
-
- fixture.setEventType(typeName);
- result = fixture.getEventType();
-
- assertEquals("unknown", result.getInName());
- assertEquals("UNKNOWN", result.name());
- assertEquals("UNKNOWN", result.toString());
- assertEquals(3, result.ordinal());
-
- // setState(String stateName)
- fixture.setState("disabled");
- TraceEnablement state = fixture.getState();
- assertEquals("disabled", state.getInName());
- assertEquals("DISABLED", state.name());
- assertEquals("DISABLED", state.toString());
- assertEquals(0, state.ordinal());
-
- fixture.setState("bla");
- state = fixture.getState();
- assertEquals("disabled", state.getInName());
- assertEquals("DISABLED", state.name());
- assertEquals("DISABLED", state.toString());
- assertEquals(0, state.ordinal());
-
- fixture.setState("enabled");
- state = fixture.getState();
- assertEquals("enabled", state.getInName());
- assertEquals("ENABLED", state.name());
- assertEquals("ENABLED", state.toString());
- assertEquals(1, state.ordinal());
-
- // setState(TraceEnablement state)
- fixture.setState(TraceEnablement.DISABLED);
- state = fixture.getState();
- assertEquals("disabled", state.getInName());
- assertEquals("DISABLED", state.name());
- assertEquals("DISABLED", state.toString());
- assertEquals(0, state.ordinal());
-
- fixture.setState(TraceEnablement.ENABLED);
- state = fixture.getState();
- assertEquals("enabled", state.getInName());
- assertEquals("ENABLED", state.name());
- assertEquals("ENABLED", state.toString());
- assertEquals(1, state.ordinal());
- }
-
- /**
- * Run the String toString() method test.
- */
- public void testToString_1() {
- EventInfo fixture = new EventInfo("event");
- fixture.setName("testName");
- fixture.setEventType(TraceEventType.TRACEPOINT);
-
- String result = fixture.toString();
-
- // add additional test code here
- assertEquals("[EventInfo([BaseEventInfo([TraceInfo(Name=testName)],type=TRACEPOINT,level=TRACE_DEBUG)],State=DISABLED)]", result);
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
- public void testEqualsReflexivity() {
- assertTrue("equals", fEventInfo1.equals(fEventInfo1));
- assertTrue("equals", fEventInfo2.equals(fEventInfo2));
-
- assertTrue("equals", !fEventInfo1.equals(fEventInfo2));
- assertTrue("equals", !fEventInfo2.equals(fEventInfo1));
- }
-
- public void testEqualsSymmetry() {
- EventInfo info1 = new EventInfo((EventInfo)fEventInfo1);
- EventInfo info2 = new EventInfo((EventInfo)fEventInfo2);
-
- assertTrue("equals", info1.equals(fEventInfo1));
- assertTrue("equals", fEventInfo1.equals(info1));
-
- assertTrue("equals", info2.equals(fEventInfo2));
- assertTrue("equals", fEventInfo2.equals(info2));
- }
-
- public void testEqualsTransivity() {
- EventInfo info1 = new EventInfo((EventInfo)fEventInfo1);
- EventInfo info2 = new EventInfo((EventInfo)fEventInfo1);
- EventInfo info3 = new EventInfo((EventInfo)fEventInfo1);
-
- assertTrue("equals", info1.equals(info2));
- assertTrue("equals", info2.equals(info3));
- assertTrue("equals", info1.equals(info3));
- }
-
- public void testEqualsNull() {
- assertTrue("equals", !fEventInfo1.equals(null));
- assertTrue("equals", !fEventInfo2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- public void testHashCode() {
- EventInfo info1 = new EventInfo((EventInfo)fEventInfo1);
- EventInfo info2 = new EventInfo((EventInfo)fEventInfo2);
-
- assertTrue("hashCode", fEventInfo1.hashCode() == info1.hashCode());
- assertTrue("hashCode", fEventInfo2.hashCode() == info2.hashCode());
-
- assertTrue("hashCode", fEventInfo1.hashCode() != info2.hashCode());
- assertTrue("hashCode", fEventInfo2.hashCode() != info1.hashCode());
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponentChangedListener;
-
-/**
- * The class can be used to validate the listener interface.
- *
- */
-public class ListenerValidator implements ITraceControlComponentChangedListener {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- private boolean fisAddedCalled = false;
- private boolean fisRemoveCalled = false;
- private boolean fisChangedCalled = false;
-
- private ITraceControlComponent fParent = null;
- private ITraceControlComponent fChild = null;
- private ITraceControlComponent fChangedComponent = null;
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- public boolean isAddedCalled() {
- return fisAddedCalled;
- }
-
- public boolean isRemovedCalled() {
- return fisRemoveCalled;
- }
-
- public boolean isChangedCalled() {
- return fisChangedCalled;
- }
-
- public ITraceControlComponent getSavedParent() {
- return fParent;
- }
-
- public ITraceControlComponent getSavedChild() {
- return fChild;
- }
-
- public ITraceControlComponent getSavedComponent() {
- return fChangedComponent;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- public void initialize() {
- fisAddedCalled = false;
- fisRemoveCalled = false;
- fisChangedCalled = false;
- fParent = null;
- fChild = null;
- fChangedComponent = null;
- }
-
- @Override
- public void componentAdded(ITraceControlComponent parent, ITraceControlComponent component) {
- fisAddedCalled = true;
- fParent = parent;
- fChild = component;
- }
-
- @Override
- public void componentRemoved(ITraceControlComponent parent, ITraceControlComponent component) {
- fisRemoveCalled = true;
- fParent = parent;
- fChild = component;
- }
-
- @Override
- public void componentChanged(ITraceControlComponent component) {
- fisChangedCalled = true;
- fParent = null;
- fChangedComponent = component;
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.ChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.DomainInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.EventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.ProbeEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.SessionInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.UstProviderInfo;
-
-/**
- * Test facility to constants across test case
- */
-@SuppressWarnings("nls")
-public class ModelImplFactory {
-
- private ISessionInfo fSessionInfo1 = null;
- private ISessionInfo fSessionInfo2 = null;
- private IDomainInfo fDomainInfo1 = null;
- private IDomainInfo fDomainInfo2 = null;
- private IChannelInfo fChannelInfo1 = null;
- private IChannelInfo fChannelInfo2 = null;
- private IEventInfo fEventInfo1 = null;
- private IEventInfo fEventInfo2 = null;
- private IEventInfo fEventInfo3 = null;
- private IBaseEventInfo fBaseEventInfo1 = null;
- private IBaseEventInfo fBaseEventInfo2 = null;
- private IUstProviderInfo fUstProviderInfo1 = null;
- private IUstProviderInfo fUstProviderInfo2 = null;
- private IProbeEventInfo fProbeEventInfo1 = null;
- private IProbeEventInfo fProbeEventInfo2 = null;
-
- public ModelImplFactory() {
- fBaseEventInfo1 = new BaseEventInfo("event1");
- fBaseEventInfo1.setEventType(TraceEventType.UNKNOWN);
- fBaseEventInfo1.setLogLevel(TraceLogLevel.TRACE_ERR);
- fBaseEventInfo2 = new BaseEventInfo("event2");
- fBaseEventInfo2.setEventType(TraceEventType.TRACEPOINT);
- fBaseEventInfo1.setLogLevel(TraceLogLevel.TRACE_DEBUG);
-
- fEventInfo1 = new EventInfo("event1");
- fEventInfo1.setEventType(TraceEventType.TRACEPOINT);
- fEventInfo1.setState(TraceEnablement.ENABLED);
-
- fEventInfo2 = new EventInfo("event2");
- fEventInfo2.setEventType(TraceEventType.UNKNOWN);
- fEventInfo2.setState(TraceEnablement.DISABLED);
-
- fEventInfo3 = new EventInfo("event3");
- fEventInfo3.setEventType(TraceEventType.TRACEPOINT);
- fEventInfo3.setState(TraceEnablement.DISABLED);
-
- fUstProviderInfo1 = new UstProviderInfo("myUST1");
- fUstProviderInfo1.setPid(1234);
- fUstProviderInfo1.addEvent(fBaseEventInfo1);
-
- fUstProviderInfo2 = new UstProviderInfo("myUST2");
- fUstProviderInfo2.setPid(2345);
- fUstProviderInfo2.addEvent(fBaseEventInfo1);
- fUstProviderInfo2.addEvent(fBaseEventInfo2);
-
- fChannelInfo1 = new ChannelInfo("channel1");
- fChannelInfo1.setSwitchTimer(10L);
- fChannelInfo1.setOverwriteMode(true);
- fChannelInfo1.setReadTimer(11L);
- fChannelInfo1.setState(TraceEnablement.DISABLED);
- fChannelInfo1.setNumberOfSubBuffers(12);
- fChannelInfo1.setOutputType("splice()");
- fChannelInfo1.setSubBufferSize(13L);
- fChannelInfo1.addEvent(fEventInfo1);
-
- fChannelInfo2 = new ChannelInfo("channel2");
- fChannelInfo2.setSwitchTimer(1L);
- fChannelInfo2.setOverwriteMode(false);
- fChannelInfo2.setReadTimer(2L);
- fChannelInfo2.setState(TraceEnablement.ENABLED);
- fChannelInfo2.setNumberOfSubBuffers(3);
- fChannelInfo2.setOutputType("mmap()");
- fChannelInfo2.setSubBufferSize(4L);
- fChannelInfo2.addEvent(fEventInfo2);
- fChannelInfo2.addEvent(fEventInfo3);
-
- fDomainInfo1 = new DomainInfo("test1");
- fDomainInfo1.addChannel(fChannelInfo1);
-
- fDomainInfo2 = new DomainInfo("test2");
- fDomainInfo2.addChannel(fChannelInfo1);
- fDomainInfo2.addChannel(fChannelInfo2);
-
- fSessionInfo1 = new SessionInfo("session1");
- fSessionInfo1.setSessionPath("/home/user");
- fSessionInfo1.setSessionState(TraceSessionState.ACTIVE);
- fSessionInfo1.addDomain(fDomainInfo1);
-
- fSessionInfo2 = new SessionInfo("session2");
- fSessionInfo2.setSessionPath("/home/user1");
- fSessionInfo2.setSessionState(TraceSessionState.INACTIVE);
- fSessionInfo2.addDomain(fDomainInfo1);
- fSessionInfo2.addDomain(fDomainInfo2);
-
- fProbeEventInfo1 = new ProbeEventInfo("probeEvent1");
- fProbeEventInfo1.setEventType(TraceEventType.TRACEPOINT);
- fProbeEventInfo1.setState(TraceEnablement.ENABLED);
- fProbeEventInfo1.setAddress("0xc1231234");
-
- fProbeEventInfo2 = new ProbeEventInfo("probeEvent2");
- fProbeEventInfo2.setEventType(TraceEventType.UNKNOWN);
- fProbeEventInfo2.setState(TraceEnablement.DISABLED);
- fProbeEventInfo2.setOffset("0x100");
- fProbeEventInfo2.setSymbol("init_post");
- }
-
- public ISessionInfo getSessionInfo1() {
- return fSessionInfo1;
- }
-
- public ISessionInfo getSessionInfo2() {
- return fSessionInfo2;
- }
-
- public IDomainInfo getDomainInfo1() {
- return fDomainInfo1;
- }
-
- public IDomainInfo getDomainInfo2() {
- return fDomainInfo2;
- }
-
- public IChannelInfo getChannel1() {
- return fChannelInfo1;
- }
-
- public IChannelInfo getChannel2() {
- return fChannelInfo2;
- }
-
- public IEventInfo getEventInfo1() {
- return fEventInfo1;
- }
-
- public IEventInfo getEventInfo2() {
- return fEventInfo2;
- }
-
- public IEventInfo getEventInfo3() {
- return fEventInfo3;
- }
-
- public IBaseEventInfo getBaseEventInfo1() {
- return fBaseEventInfo1;
- }
-
- public IBaseEventInfo getBaseEventInfo2() {
- return fBaseEventInfo2;
- }
-
- public IUstProviderInfo getUstProviderInfo1() {
- return fUstProviderInfo1;
- }
-
- public IUstProviderInfo getUstProviderInfo2() {
- return fUstProviderInfo2;
- }
-
- public IProbeEventInfo getProbeEventInfo1() {
- return fProbeEventInfo1;
- }
-
- public IProbeEventInfo getProbeEventInfo2() {
- return fProbeEventInfo2;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import junit.framework.TestCase;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.EventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.ProbeEventInfo;
-
-/**
- * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>.
- */
-@SuppressWarnings("nls")
-public class ProbeEventInfoTest extends TestCase {
-
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
- private IProbeEventInfo fEventInfo1 = null;
- private IProbeEventInfo fEventInfo2 = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception if the initialization fails for some reason
- *
- */
- @Override
- public void setUp() throws Exception {
- ModelImplFactory factory = new ModelImplFactory();
- fEventInfo1 = factory.getProbeEventInfo1();
- fEventInfo2 = factory.getProbeEventInfo2();
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() throws Exception {
- }
-
- // ------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------
-
- /**
- * Run the BaseEventInfo() constructor test.
- *
- */
- public void testBaseEventInfo() {
- ProbeEventInfo fixture = new ProbeEventInfo("event");
- assertNotNull(fixture);
-
- TraceEventType result = fixture.getEventType();
-
- assertEquals("event", fixture.getName());
- assertEquals("unknown", result.getInName());
- assertEquals("UNKNOWN", result.name());
- assertEquals("UNKNOWN", result.toString());
- assertEquals(3, result.ordinal());
-
- TraceEnablement state = fixture.getState();
- assertEquals("disabled", state.getInName());
- assertEquals("DISABLED", state.name());
- assertEquals("DISABLED", state.toString());
- assertEquals(0, state.ordinal());
-
- assertNull(fixture.getAddress());
- assertNull(fixture.getOffset());
- assertNull(fixture.getSymbol());
- }
-
- /**
- * Test Copy Constructor
- */
- public void testEventInfoCopy() {
- ProbeEventInfo info = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
-
- assertEquals(fEventInfo1.getName(), info.getName());
- assertEquals(fEventInfo1.getEventType(), info.getEventType());
- assertEquals(fEventInfo1.getState(), info.getState());
- assertEquals(fEventInfo1.getAddress(), info.getAddress());
- assertEquals(fEventInfo1.getOffset(), info.getOffset());
- assertEquals(fEventInfo1.getSymbol(), info.getSymbol());
- }
-
- /**
- * Test Copy Constructor
- */
- public void testEventCopy2() {
- try {
- ProbeEventInfo info = null;
- new ProbeEventInfo(info);
- fail("null copy");
- }
- catch (IllegalArgumentException e) {
- // Success
- }
- }
-
- /**
- * Getter/Setter tests
- */
- public void testGetAndSetter() {
- ProbeEventInfo fixture = new ProbeEventInfo("event");
-
- // Make sure that ProbeEventInfo extends EventInfo
- // -> so we don't need to re-test common parts
- assertTrue(fixture instanceof EventInfo);
-
- fixture.setAddress("0xc12344321");
- String result = fixture.getAddress();
-
- assertNotNull(result);
- assertEquals("0xc12344321", result);
-
- fixture.setOffset("0x1000");
- result = fixture.getOffset();
-
- assertNotNull(result);
- assertEquals("0x1000", result);
-
- fixture.setSymbol("cpu_idle");
- result = fixture.getSymbol();
-
- assertNotNull(result);
- assertEquals("cpu_idle", result);
- }
-
- /**
- * Run the String toString() method test.
- */
- public void testToString_1() {
- assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)],fAddress=0xc1231234)]", fEventInfo1.toString());
- assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent2)],type=UNKNOWN,level=TRACE_DEBUG)],State=DISABLED)],fOffset=0x100,fSymbol=init_post)]", fEventInfo2.toString());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
- public void testEqualsReflexivity() {
- assertTrue("equals", fEventInfo1.equals(fEventInfo1));
- assertTrue("equals", fEventInfo2.equals(fEventInfo2));
-
- assertTrue("equals", !fEventInfo1.equals(fEventInfo2));
- assertTrue("equals", !fEventInfo2.equals(fEventInfo1));
- }
-
- public void testEqualsSymmetry() {
- ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
- ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo2);
-
- assertTrue("equals", info1.equals(fEventInfo1));
- assertTrue("equals", fEventInfo1.equals(info1));
-
- assertTrue("equals", info2.equals(fEventInfo2));
- assertTrue("equals", fEventInfo2.equals(info2));
- }
-
- public void testEqualsTransivity() {
- ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
- ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
- ProbeEventInfo info3 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
-
- assertTrue("equals", info1.equals(info2));
- assertTrue("equals", info2.equals(info3));
- assertTrue("equals", info1.equals(info3));
- }
-
- public void testEqualsNull() {
- assertTrue("equals", !fEventInfo1.equals(null));
- assertTrue("equals", !fEventInfo2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- public void testHashCode() {
- ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
- ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo2);
-
- assertTrue("hashCode", fEventInfo1.hashCode() == info1.hashCode());
- assertTrue("hashCode", fEventInfo2.hashCode() == info2.hashCode());
-
- assertTrue("hashCode", fEventInfo1.hashCode() != info2.hashCode());
- assertTrue("hashCode", fEventInfo2.hashCode() != info1.hashCode());
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.SessionInfo;
-
-/**
- * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link SessionInfo}</code>.
- *
- */
-@SuppressWarnings("nls")
-public class SessionInfoTest extends TestCase {
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
- private ISessionInfo fSessionInfo1 = null;
- private ISessionInfo fSessionInfo2 = null;
-
- private IDomainInfo fDomainInfo1 = null;
- private IDomainInfo fDomainInfo2 = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- */
- @Override
- public void setUp() {
- ModelImplFactory factory = new ModelImplFactory();
- fSessionInfo1 = factory.getSessionInfo1();
- fDomainInfo1 = factory.getDomainInfo1();
- fSessionInfo2 = factory.getSessionInfo2();
- fDomainInfo2 = factory.getDomainInfo2();
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() {
- }
-
- // ------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Run the ChannelInfo() constructor test.
- *
- */
- public void testSessionInfo() {
- ISessionInfo result = new SessionInfo("test");
- assertNotNull(result);
-
- assertEquals("test", result.getName());
- assertEquals("", result.getSessionPath());
- TraceSessionState state = result.getSessionState();
- assertEquals("inactive", state.getInName());
- assertEquals("INACTIVE", state.name());
- assertEquals("INACTIVE", state.toString());
- assertEquals(0, state.ordinal());
- assertEquals(0, result.getDomains().length);
- }
-
- public void testSessionInfoCopy() {
- SessionInfo sessionInfo = new SessionInfo((SessionInfo)fSessionInfo1);
-
- assertEquals(sessionInfo.getName(), fSessionInfo1.getName());
- assertEquals(sessionInfo.getSessionPath(), fSessionInfo1.getSessionPath());
- assertEquals(sessionInfo.getSessionState(), fSessionInfo1.getSessionState());
-
- IDomainInfo[] orignalDomains = fSessionInfo1.getDomains();
- IDomainInfo[] resultDomains = sessionInfo.getDomains();
- for (int i = 0; i < orignalDomains.length; i++) {
- assertEquals(orignalDomains[i], resultDomains[i]);
- }
- }
-
- public void testSessionCopy2() {
- try {
- SessionInfo session = null;
- new SessionInfo(session);
- fail("null copy");
- }
- catch (IllegalArgumentException e) {
- // Success
- }
- }
-
- /**
- * Run the long getNumberOfSubBuffers() method test.
- *
- */
- public void testGetAndSetters() {
-
- // Note that addDomain() has been executed in setUp()
- // check get method here
- assertEquals(1, fSessionInfo1.getDomains().length);
- assertNotNull(fSessionInfo1.getDomains()[0]);
- assertEquals(fDomainInfo1, fSessionInfo1.getDomains()[0]);
-
- ISessionInfo session = new SessionInfo("session");
- List<IDomainInfo> list = new LinkedList<IDomainInfo>();
- list.add(fDomainInfo1);
- list.add(fDomainInfo2);
- session.setDomains(list);
-
- IDomainInfo[] result = session.getDomains();
- assertEquals(2, result.length);
- assertEquals(fDomainInfo1, result[0]);
- assertEquals(fDomainInfo2, result[1]);
-
- session.setSessionPath("/home/user");
- assertEquals("/home/user", session.getSessionPath());
-
- session.setSessionState("active");
- TraceSessionState state = session.getSessionState();
- state = session.getSessionState();
- assertEquals("active", state.getInName());
- assertEquals("ACTIVE", state.name());
- assertEquals("ACTIVE", state.toString());
- assertEquals(1, state.ordinal());
-
- session.setSessionState("inactive");
- state = session.getSessionState();
- assertEquals("inactive", state.getInName());
- assertEquals("INACTIVE", state.name());
- assertEquals("INACTIVE", state.toString());
- assertEquals(0, state.ordinal());
-
- session.setSessionState("test");
- state = session.getSessionState();
- assertEquals("inactive", state.getInName());
- assertEquals("INACTIVE", state.name());
- assertEquals("INACTIVE", state.toString());
- assertEquals(0, state.ordinal());
-
- session.setSessionState(TraceSessionState.ACTIVE);
- state = session.getSessionState();
- assertEquals("active", state.getInName());
- assertEquals("ACTIVE", state.name());
- assertEquals("ACTIVE", state.toString());
- assertEquals(1, state.ordinal());
-
- session.setSessionState(TraceSessionState.INACTIVE);
- state = session.getSessionState();
- assertEquals("inactive", state.getInName());
- assertEquals("INACTIVE", state.name());
- assertEquals("INACTIVE", state.toString());
- assertEquals(0, state.ordinal());
- }
-
- public void testToString_1() {
- ISessionInfo fixture = new SessionInfo("sessionName");
-
- String result = fixture.toString();
-
- // add additional test code here
- assertEquals("[SessionInfo([TraceInfo(Name=sessionName)],State=INACTIVE,Domains=)]", result);
- }
-
- /**
- * Run the String toString() method test.
- *
- */
- public void testToString_2() {
- String result = fSessionInfo1.toString();
-
- // add additional test code here
- assertEquals("[SessionInfo([TraceInfo(Name=session1)],State=ACTIVE,Domains=[DomainInfo([TraceInfo(Name=test1)],Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],isKernel=false)])]", result);
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- public void testEqualsReflexivity() {
- assertTrue("equals", fSessionInfo1.equals(fSessionInfo1));
- assertTrue("equals", fSessionInfo2.equals(fSessionInfo2));
-
- assertTrue("equals", !fSessionInfo1.equals(fSessionInfo2));
- assertTrue("equals", !fSessionInfo2.equals(fSessionInfo1));
- }
-
- public void testEqualsSymmetry() {
- SessionInfo event1 = new SessionInfo((SessionInfo)fSessionInfo1);
- SessionInfo event2 = new SessionInfo((SessionInfo)fSessionInfo2);
-
- assertTrue("equals", event1.equals(fSessionInfo1));
- assertTrue("equals", fSessionInfo1.equals(event1));
-
- assertTrue("equals", event2.equals(fSessionInfo2));
- assertTrue("equals", fSessionInfo2.equals(event2));
- }
-
- public void testEqualsTransivity() {
- SessionInfo channel1 = new SessionInfo((SessionInfo)fSessionInfo1);
- SessionInfo channel2 = new SessionInfo((SessionInfo)fSessionInfo1);
- SessionInfo channel3 = new SessionInfo((SessionInfo)fSessionInfo1);
-
- assertTrue("equals", channel1.equals(channel2));
- assertTrue("equals", channel2.equals(channel3));
- assertTrue("equals", channel1.equals(channel3));
- }
-
- public void testEqualsNull() throws Exception {
- assertTrue("equals", !fSessionInfo1.equals(null));
- assertTrue("equals", !fSessionInfo2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- public void testHashCode() {
- SessionInfo channel1 = new SessionInfo((SessionInfo)fSessionInfo1);
- SessionInfo channel2 = new SessionInfo((SessionInfo)fSessionInfo2);
-
- assertTrue("hashCode", fSessionInfo1.hashCode() == channel1.hashCode());
- assertTrue("hashCode", fSessionInfo2.hashCode() == channel2.hashCode());
-
- assertTrue("hashCode", fSessionInfo1.hashCode() != channel2.hashCode());
- assertTrue("hashCode", fSessionInfo2.hashCode() != channel1.hashCode());
- }}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import junit.framework.TestCase;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo;
-
-/**
- * The class <code>TraceInfoTest</code> contains test for the class <code>{@link TraceInfo}</code>.
- */
-@SuppressWarnings("nls")
-public class TraceInfoTest extends TestCase {
-
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
- private ITraceInfo fTraceInfo1 = null;
- private ITraceInfo fTraceInfo2 = null;
-
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception if the initialization fails for some reason
- *
- */
- @Override
- public void setUp() throws Exception {
- fTraceInfo1 = new TraceInfo("event1");
- fTraceInfo2 = new TraceInfo("event2");
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() throws Exception {
- }
-
- // ------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------
-
- /**
- * Run the BaseEventInfo() constructor test.
- *
- */
- public void testTraceInfo() {
- TraceInfo fixture = new TraceInfo("event");
- assertNotNull(fixture);
-
- assertEquals("event", fixture.getName());
- }
-
- /**
- * Test Copy Constructor
- */
- public void testTraceInfo2() {
- try {
- String name = null;
- new TraceInfo(name);
- fail("null name in custructor");
- }
- catch (IllegalArgumentException e) {
- // Success
- }
- }
-
- /**
- * Test Copy Constructor
- */
- public void testTraceInfoCopy() {
- TraceInfo info = new TraceInfo((TraceInfo)fTraceInfo1);
-
- assertEquals(fTraceInfo1.getName(), info.getName());
- }
-
- /**
- * Test Copy Constructor
- */
- public void testTraceCopy2() {
- try {
- TraceInfo info = null;
- new TraceInfo(info);
- fail("null copy");
- }
- catch (IllegalArgumentException e) {
- // Success
- }
- }
-
- /**
- * Run the void setEventType(String) method test.
- *
- */
- public void testSetName() {
- TraceInfo fixture = new TraceInfo("event");
- fixture.setName("newName");
- assertEquals("newName", fixture.getName());
- }
-
- /**
- * Run the String toString() method test.
- *
- */
- public void testToString_1() {
- String result = fTraceInfo1.toString();
-
- // add additional test code here
- assertEquals("[TraceInfo(Name=event1)]", result);
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- public void testEqualsReflexivity() {
- assertTrue("equals", fTraceInfo1.equals(fTraceInfo1));
- assertTrue("equals", fTraceInfo2.equals(fTraceInfo2));
-
- assertTrue("equals", !fTraceInfo1.equals(fTraceInfo2));
- assertTrue("equals", !fTraceInfo2.equals(fTraceInfo1));
- }
-
- public void testEqualsSymmetry() {
- TraceInfo info1 = new TraceInfo((TraceInfo)fTraceInfo1);
- TraceInfo info2 = new TraceInfo((TraceInfo)fTraceInfo2);
-
- assertTrue("equals", info1.equals(fTraceInfo1));
- assertTrue("equals", fTraceInfo1.equals(info1));
-
- assertTrue("equals", info2.equals(fTraceInfo2));
- assertTrue("equals", fTraceInfo2.equals(info2));
- }
-
- public void testEqualsTransivity() {
- TraceInfo info1 = new TraceInfo((TraceInfo)fTraceInfo1);
- TraceInfo info2 = new TraceInfo((TraceInfo)fTraceInfo1);
- TraceInfo info3 = new TraceInfo((TraceInfo)fTraceInfo1);
-
- assertTrue("equals", info1.equals(info2));
- assertTrue("equals", info2.equals(info3));
- assertTrue("equals", info1.equals(info3));
- }
-
- public void testEqualsNull() {
- assertTrue("equals", !fTraceInfo1.equals(null));
- assertTrue("equals", !fTraceInfo2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- public void testHashCode() {
- TraceInfo info1 = new TraceInfo((TraceInfo)fTraceInfo1);
- TraceInfo info2 = new TraceInfo((TraceInfo)fTraceInfo2);
-
- assertTrue("hashCode", fTraceInfo1.hashCode() == info1.hashCode());
- assertTrue("hashCode", fTraceInfo2.hashCode() == info2.hashCode());
-
- assertTrue("hashCode", fTraceInfo1.hashCode() != info2.hashCode());
- assertTrue("hashCode", fTraceInfo2.hashCode() != info1.hashCode());
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.UstProviderInfo;
-
-/**
- * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link UstProviderInfo}</code>.
- *
- */
-@SuppressWarnings("nls")
-public class UstProviderInfoTest extends TestCase {
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
- private IUstProviderInfo fUstProviderInfo1 = null;
- private IUstProviderInfo fUstProviderInfo2 = null;
-
- private IBaseEventInfo fEventInfo1 = null;
- private IBaseEventInfo fEventInfo2 = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- */
- @Override
- public void setUp() {
- ModelImplFactory factory = new ModelImplFactory();
- fUstProviderInfo1 = factory.getUstProviderInfo1();
- fUstProviderInfo2 = factory.getUstProviderInfo2();
- fEventInfo1 = factory.getBaseEventInfo1();
- fEventInfo1 = factory.getBaseEventInfo2();
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() {
- }
-
- // ------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Run the UstProviderInfo() constructor test.
- *
- */
- public void testUstProviderInfo() {
- IUstProviderInfo result = new UstProviderInfo("test");
- assertNotNull(result);
-
- assertEquals("test", result.getName());
- assertEquals(0, result.getPid());
- assertEquals(0, result.getEvents().length);
- }
-
- public void testUstProviderInfoCopy() {
- IUstProviderInfo providerInf = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
-
- assertEquals(fUstProviderInfo1.getName(), providerInf.getName());
- assertEquals(fUstProviderInfo1.getPid(), providerInf.getPid());
- assertEquals(fUstProviderInfo1.getEvents().length, providerInf.getEvents().length);
-
- IBaseEventInfo[] orignalEvents = fUstProviderInfo1.getEvents();
- IBaseEventInfo[] resultEvents = providerInf.getEvents();
- for (int i = 0; i < orignalEvents.length; i++) {
- assertEquals(orignalEvents[i], resultEvents[i]);
- }
- }
-
- public void testUstProviderCopy2() {
- try {
- UstProviderInfo providerInfo = null;
- new UstProviderInfo(providerInfo);
- fail("null copy");
- }
- catch (IllegalArgumentException e) {
- // Success
- }
- }
-
- /**
- * Run the IEventInfo[] getEvents() method test.
- *
- */
- public void testGetAndSetters() {
- IUstProviderInfo fixture = new UstProviderInfo("test");
- fixture.setPid(2468);
-
- // add an event
- IBaseEventInfo event = new BaseEventInfo("event");
- fixture.addEvent(event);
-
- // Verify the stored events
- IBaseEventInfo[] result = fixture.getEvents();
-
- assertNotNull(result);
- assertEquals(1, result.length);
- assertNotNull(result[0]);
- assertTrue(event.equals(result[0]));
-
- assertEquals(2468, fixture.getPid());
- }
-
- /**
- * Run the void setEvents(List<IBaseEventInfo>) method test.
- *
- */
- public void testSetEvents_1() {
- UstProviderInfo fixture = new UstProviderInfo("test");
- fixture.setPid(2468);
- List<IBaseEventInfo> events = new LinkedList<IBaseEventInfo>();
- events.add(fEventInfo1);
- events.add(fEventInfo2);
- fixture.setEvents(events);
-
- IBaseEventInfo[] infos = fixture.getEvents();
-
- assertEquals(events.size(), infos.length);
-
- for (int i = 0; i < infos.length; i++) {
- assertEquals(events.get(i), infos[i]);
- }
- }
-
- public void testToString_1() {
- UstProviderInfo fixture = new UstProviderInfo("test");
- fixture.setPid(2468);
- String result = fixture.toString();
-
- assertEquals("[EventInfo([TraceInfo(Name=test)],PID=2468,Events=None)]", result);
- }
-
- /**
- * Run the String toString() method test.
- *
- */
- public void testToString_2() {
- String result = fUstProviderInfo2.toString();
- assertEquals("[EventInfo([TraceInfo(Name=myUST2)],PID=2345,Events=[BaseEventInfo([TraceInfo(Name=event1)],type=UNKNOWN,level=TRACE_DEBUG)][BaseEventInfo([TraceInfo(Name=event2)],type=TRACEPOINT,level=TRACE_DEBUG)])]", result);
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- public void testEqualsReflexivity() {
- assertTrue("equals", fUstProviderInfo1.equals(fUstProviderInfo1));
- assertTrue("equals", fUstProviderInfo2.equals(fUstProviderInfo2));
-
- assertTrue("equals", !fUstProviderInfo1.equals(fUstProviderInfo2));
- assertTrue("equals", !fUstProviderInfo2.equals(fUstProviderInfo1));
- }
-
- public void testEqualsSymmetry() {
- UstProviderInfo event1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
- UstProviderInfo event2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo2);
-
- assertTrue("equals", event1.equals(fUstProviderInfo1));
- assertTrue("equals", fUstProviderInfo1.equals(event1));
-
- assertTrue("equals", event2.equals(fUstProviderInfo2));
- assertTrue("equals", fUstProviderInfo2.equals(event2));
- }
-
- public void testEqualsTransivity() {
- UstProviderInfo UstProvider1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
- UstProviderInfo UstProvider2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
- UstProviderInfo UstProvider3 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
-
- assertTrue("equals", UstProvider1.equals(UstProvider2));
- assertTrue("equals", UstProvider2.equals(UstProvider3));
- assertTrue("equals", UstProvider1.equals(UstProvider3));
- }
-
- public void testEqualsNull() throws Exception {
- assertTrue("equals", !fUstProviderInfo1.equals(null));
- assertTrue("equals", !fUstProviderInfo2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- public void testHashCode() {
- UstProviderInfo UstProvider1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
- UstProviderInfo UstProvider2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo2);
-
- assertTrue("hashCode", fUstProviderInfo1.hashCode() == UstProvider1.hashCode());
- assertTrue("hashCode", fUstProviderInfo2.hashCode() == UstProvider2.hashCode());
-
- assertTrue("hashCode", fUstProviderInfo1.hashCode() != UstProvider2.hashCode());
- assertTrue("hashCode", fUstProviderInfo2.hashCode() != UstProvider1.hashCode());
- }
-}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.service;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AllTests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(LTTngControlServiceTest.class);
- //$JUnit-END$
- return suite;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.ui.tests.control.service;
-
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.ChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.LTTngControlService;
-import org.eclipse.linuxtools.lttng.stubs.service.CommandShellFactory;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.LTTngToolsFileShell;
-import org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin;
-/**
- * The class <code>LTTngControlServiceTest</code> contains test for the class <code>{@link LTTngControlService}</code>.
- */
-@SuppressWarnings("nls")
-public class LTTngControlServiceTest extends TestCase {
-
- private static final String DIRECTORY = "testfiles";
- private static final String TEST_STREAM = "LTTngServiceTest.cfg";
-
- private static final String SCEN_LTTNG_NOT_INSTALLED = "LttngNotInstalled";
- private static final String SCEN_NO_SESSION_AVAILABLE = "NoSessionAvailable";
- private static final String SCEN_GET_SESSION_NAMES1 = "GetSessionNames1";
- private static final String SCEN_GET_SESSION_NAME_NOT_EXIST = "GetSessionNameNotExist";
- private static final String SCEN_GET_SESSION_GARBAGE_OUT = "GetSessionGarbageOut";
- private static final String SCEN_GET_SESSION1 = "GetSession1";
- private static final String SCEN_GET_KERNEL_PROVIDER1 = "GetKernelProvider1";
- private static final String SCEN_GET_UST_PROVIDER1 = "GetUstProvider1";
- private static final String SCEN_GET_UST_PROVIDER2 = "GetUstProvider2";
- private static final String SCEN_CREATE_SESSION1 = "CreateSession1";
- private static final String SCEN_CREATE_SESSION_VARIANTS = "CreateSessionVariants";
- private static final String SCEN_DESTROY_SESSION1 = "DestroySession1";
- private static final String SCEN_CHANNEL_HANDLING = "ChannelHandling";
- private static final String SCEN_EVENT_HANDLING = "EventHandling";
-
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
- private CommandShellFactory fShellFactory;
- private String fTestfile;
- private LTTngToolsFileShell fShell;
- private ILttngControlService fService;
-
-
- // ------------------------------------------------------------------------
- // Static methods
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception if the initialization fails for some reason
- *
- */
- @Override
- public void setUp() throws Exception {
- super.setUp();
- fShellFactory = CommandShellFactory.getInstance();
-
- URL location = FileLocator.find(LTTngUITestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
- File testfile = new File(FileLocator.toFileURL(location).toURI());
- fTestfile = testfile.getAbsolutePath();
-
- fShell = fShellFactory.getFileShell();
- fShell.loadScenarioFile(fTestfile);
- fService = new LTTngControlService(fShell);
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() throws Exception {
- }
-
- // ------------------------------------------------------------------------
- // Test Cases
- // ------------------------------------------------------------------------
-
- public void testGetSessionNames() {
- try {
- fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED);
- fService.getSessionNames(new NullProgressMonitor());
- fail("No exeption thrown");
- } catch (ExecutionException e) {
- // success
- }
- }
-
- public void testGetSessionNames1() {
- try {
- fShell.setScenario(SCEN_NO_SESSION_AVAILABLE);
- String[] result = fService.getSessionNames(new NullProgressMonitor());
-
- assertNotNull(result);
- assertEquals(0, result.length);
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testGetSessionNames2() {
- try {
- fShell.setScenario(SCEN_GET_SESSION_NAMES1);
- String[] result = fService.getSessionNames(new NullProgressMonitor());
-
- assertNotNull(result);
- assertEquals(2, result.length);
- assertEquals("mysession1", result[0]);
- assertEquals("mysession", result[1]);
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testGetSessionNotExist() {
- try {
- fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST);
- fService.getSessionNames(new NullProgressMonitor());
- fail("No exeption thrown");
-
- } catch (ExecutionException e) {
- // success
- }
- }
-
- public void testGetSessionNameGarbage() {
- try {
- fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT);
- String[] result = fService.getSessionNames(new NullProgressMonitor());
-
- assertNotNull(result);
- assertEquals(0, result.length);
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testGetSession1() {
- try {
- fShell.setScenario(SCEN_GET_SESSION1);
- ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor());
-
- // Verify Session
- assertNotNull(session);
- assertEquals("mysession", session.getName());
- assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
- assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
-
- IDomainInfo[] domains = session.getDomains();
- assertNotNull(domains);
- assertEquals(2, domains.length);
-
- // Verify Kernel domain
- assertEquals("Kernel", domains[0].getName());
- IChannelInfo[] channels = domains[0].getChannels();
- assertNotNull(channels);
- assertEquals(2, channels.length);
-
- // Verify Kernel's channel0
- assertEquals("channel0", channels[0].getName());
- assertEquals(4, channels[0].getNumberOfSubBuffers());
- assertEquals("splice()", channels[0].getOutputType());
- assertEquals(false, channels[0].isOverwriteMode());
- assertEquals(200, channels[0].getReadTimer());
- assertEquals(TraceEnablement.ENABLED, channels[0].getState());
- assertEquals(262144, channels[0].getSubBufferSize());
- assertEquals(0, channels[0].getSwitchTimer());
-
- // Verify event info
- IEventInfo[] channel0Events = channels[0].getEvents();
- assertNotNull(channel0Events);
- assertEquals(2, channel0Events.length);
- assertEquals("block_rq_remap", channel0Events[0].getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType());
- assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState());
-
- assertEquals("block_bio_remap", channel0Events[1].getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[1].getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, channel0Events[1].getEventType());
- assertEquals(TraceEnablement.DISABLED, channel0Events[1].getState());
-
- // Verify Kernel's channel1
- assertEquals("channel1", channels[1].getName());
- assertEquals(4, channels[1].getNumberOfSubBuffers());
- assertEquals("splice()", channels[1].getOutputType());
- assertEquals(true, channels[1].isOverwriteMode());
- assertEquals(400, channels[1].getReadTimer());
- assertEquals(TraceEnablement.DISABLED, channels[1].getState());
- assertEquals(524288, channels[1].getSubBufferSize());
- assertEquals(100, channels[1].getSwitchTimer());
-
- // Verify event info
- IEventInfo[] channel1Events = channels[1].getEvents();
- assertEquals(0, channel1Events.length);
-
- // Verify domain UST global
- assertEquals("UST global", domains[1].getName());
-
- IChannelInfo[] ustChannels = domains[1].getChannels();
-
- // Verify UST global's mychannel1
- assertEquals("mychannel1", ustChannels[0].getName());
- assertEquals(8, ustChannels[0].getNumberOfSubBuffers());
- assertEquals("mmap()", ustChannels[0].getOutputType());
- assertEquals(true, ustChannels[0].isOverwriteMode());
- assertEquals(100, ustChannels[0].getReadTimer());
- assertEquals(TraceEnablement.DISABLED, ustChannels[0].getState());
- assertEquals(8192, ustChannels[0].getSubBufferSize());
- assertEquals(200, ustChannels[0].getSwitchTimer());
-
- // Verify event info
- IEventInfo[] ustEvents = ustChannels[0].getEvents();
- assertEquals(0, ustEvents.length);
-
- // Verify UST global's channel0
- assertEquals("channel0", ustChannels[1].getName());
- assertEquals(4, ustChannels[1].getNumberOfSubBuffers());
- assertEquals("mmap()", ustChannels[1].getOutputType());
- assertEquals(false, ustChannels[1].isOverwriteMode());
- assertEquals(200, ustChannels[1].getReadTimer());
- assertEquals(TraceEnablement.ENABLED, ustChannels[1].getState());
- assertEquals(4096, ustChannels[1].getSubBufferSize());
- assertEquals(0, ustChannels[1].getSwitchTimer());
-
- // Verify event info
- ustEvents = ustChannels[1].getEvents();
- assertEquals(2, ustEvents.length);
-
- assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName());
- assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType());
- assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState());
-
- assertEquals("*", ustEvents[1].getName());
- assertEquals(TraceLogLevel.LEVEL_UNKNOWN, ustEvents[1].getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, ustEvents[1].getEventType());
- assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState());
-
- // next session (no detailed information available)
- session = fService.getSession("mysession1", new NullProgressMonitor());
- assertNotNull(session);
- assertEquals("mysession1", session.getName());
- assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session.getSessionPath());
- assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
-
- domains = session.getDomains();
- assertNotNull(domains);
- assertEquals(0, domains.length);
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testGetKernelProvider() {
- try {
- fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1);
- List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor());
-
- // Verify event info
- assertNotNull(events);
- assertEquals(3, events.size());
-
- IBaseEventInfo baseEventInfo = (IBaseEventInfo) events.get(0);
- assertNotNull(baseEventInfo);
- assertEquals("sched_kthread_stop", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- baseEventInfo = (IBaseEventInfo) events.get(1);
- assertEquals("sched_kthread_stop_ret", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- baseEventInfo = (IBaseEventInfo) events.get(2);
- assertEquals("sched_wakeup_new", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testGetUstProvider() {
- try {
- fShell.setScenario(SCEN_GET_UST_PROVIDER1);
- List<IUstProviderInfo> providers = fService.getUstProvider();
-
- // Check all providers
- assertNotNull(providers);
- assertEquals(2, providers.size());
-
- //Verify first provider
- assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName());
- assertEquals(9379, providers.get(0).getPid());
-
- // Verify event info
- IBaseEventInfo[] events = providers.get(0).getEvents();
- assertNotNull(events);
- assertEquals(2, events.length);
-
- IBaseEventInfo baseEventInfo = (IBaseEventInfo) events[0];
- assertNotNull(baseEventInfo);
- assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- baseEventInfo = (IBaseEventInfo) events[1];
- assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- //Verify second provider
- assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName());
- assertEquals(4852, providers.get(1).getPid());
-
- // Verify event info
- events = providers.get(1).getEvents();
- assertNotNull(events);
- assertEquals(2, events.length);
-
- baseEventInfo = (IBaseEventInfo) events[0];
- assertNotNull(baseEventInfo);
- assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- baseEventInfo = (IBaseEventInfo) events[1];
- assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
- assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel());
- assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testUstProvider2() {
- try {
- fShell.setScenario(SCEN_GET_UST_PROVIDER2);
- List<IUstProviderInfo> providers = fService.getUstProvider();
-
- assertNotNull(providers);
- assertEquals(0, providers.size());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testCreateSession() {
- try {
- fShell.setScenario(SCEN_CREATE_SESSION1);
-
- ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor());
- assertNotNull(info);
- assertEquals("mysession2", info.getName());
- assertNotNull(info.getSessionPath());
- assertTrue(info.getSessionPath().contains("mysession2"));
- assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testCreateSessionVariants() {
-
- fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS);
-
- try {
- fService.createSession("alreadyExist", null, new NullProgressMonitor());
- fail("No exeption thrown");
- } catch (ExecutionException e) {
- // success
- }
-
- try {
- fService.createSession("wrongName", null, new NullProgressMonitor());
- fail("No exeption thrown");
- } catch (ExecutionException e) {
- // success
- }
-
- try {
- fService.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
- fail("No exeption thrown");
- } catch (ExecutionException e) {
- // success
- }
-
- try {
- ISessionInfo info = fService.createSession("session with spaces", null, new NullProgressMonitor());
- assertNotNull(info);
- assertEquals("session with spaces", info.getName());
- assertNotNull(info.getSessionPath());
- assertTrue(info.getSessionPath().contains("session with spaces"));
- assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
-
- try {
- ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
- assertNotNull(info);
- assertEquals("pathWithSpaces", info.getName());
- assertNotNull(info.getSessionPath());
- assertTrue(info.getSessionPath().contains("/home/user/hallo user/here"));
- assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testDestroySession() {
- try {
- fShell.setScenario(SCEN_DESTROY_SESSION1);
- fService.destroySession("mysession2", new NullProgressMonitor());
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testCreateChannel() {
- try {
-
- String sessionName = "mysession2";
- List<String> list = new ArrayList<String>();
- String kernelChannel0 = "mychannel0";
- String kernelChannel1 = "mychannel1";
- list.add(kernelChannel0);
- list.add(kernelChannel1);
-
- fShell.setScenario(SCEN_CHANNEL_HANDLING);
-
- // Create/enable/configure 2 kernel channels
- ChannelInfo chanInfo = new ChannelInfo("");
- chanInfo.setOverwriteMode(true);
- chanInfo.setSubBufferSize(16384);
- chanInfo.setReadTimer(100);
- chanInfo.setSwitchTimer(200);
- chanInfo.setNumberOfSubBuffers(2);
- fService.enableChannels(sessionName, list, true, chanInfo, new NullProgressMonitor());
-
- // Create/enable/configure 1 UST channel
- list.clear();
- list.add("ustChannel");
-
- chanInfo = new ChannelInfo("");
- chanInfo.setOverwriteMode(true);
- chanInfo.setSubBufferSize(32768);
- chanInfo.setReadTimer(200);
- chanInfo.setSwitchTimer(100);
- chanInfo.setNumberOfSubBuffers(1);
- fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testDisableChannel() {
- try {
-
- String sessionName = "mysession2";
- List<String> list = new ArrayList<String>();
- String kernelChannel0 = "mychannel0";
- String kernelChannel1 = "mychannel1";
- list.add(kernelChannel0);
- list.add(kernelChannel1);
-
- fShell.setScenario(SCEN_CHANNEL_HANDLING);
- fService.disableChannels(sessionName, list, true, new NullProgressMonitor());
-
- list.clear();
- list.add("ustChannel");
- fService.disableChannels(sessionName, list, false, new NullProgressMonitor());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testEnableChannel() {
- try {
-
- String sessionName = "mysession2";
- List<String> list = new ArrayList<String>();
- String kernelChannel0 = "mychannel0";
- String kernelChannel1 = "mychannel1";
- list.add(kernelChannel0);
- list.add(kernelChannel1);
-
- fShell.setScenario(SCEN_CHANNEL_HANDLING);
- fService.enableChannels(sessionName, list, true, null, new NullProgressMonitor());
-
- // Create/enable/configure 1 UST channel
- list.clear();
- list.add("ustChannel");
-
- fService.enableChannels(sessionName, list, false, null, new NullProgressMonitor());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
-// public void tesEnableChannelNoTracer() {
-// try {
-// ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer());
-// service.getSessionNames(new NullProgressMonitor());
-// fail("No exeption thrown");
-//
-// } catch (ExecutionException e) {
-// // success
-// }
-// }
-
- public void testEnableEvents() {
- try {
- // 1) session name, channel = null, 3 event names, kernel
- String sessionName = "mysession2";
- List<String> list = new ArrayList<String>();
- String eventName0 = "block_rq_remap";
- String eventName1 = "block_bio_remap";
- String eventName2 = "softirq_entry";
- list.add(eventName0);
- list.add(eventName1);
- list.add(eventName2);
- fShell.setScenario(SCEN_EVENT_HANDLING);
- fService.enableEvents(sessionName, null, list, true, new NullProgressMonitor());
-
- // 2) session name, channel=mychannel, event name= null, kernel
- String channelName = "mychannel";
- fService.enableEvents(sessionName, channelName, null, true, new NullProgressMonitor());
-
- // 3) session name, channel=mychannel, 1 event name, ust
- String ustEventName = "ust_tests_hello:tptest_sighandler";
- list.clear();
- list.add(ustEventName);
- fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
-
- // 4) session name, channel = mychannel, no event name, ust
- list.clear();
- fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testEnableSyscalls() {
- try {
- // 1) session name, channel = null, 3 event names, kernel
- String sessionName = "mysession2";
- String channelName = "mychannel";
-
- fShell.setScenario(SCEN_EVENT_HANDLING);
-
- // 1) session name, channel = null
- fService.enableSyscalls(sessionName, null, new NullProgressMonitor());
-
- // 2) session name, channel = mychannel
- fService.enableSyscalls(sessionName, channelName, new NullProgressMonitor());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testDynamicProbe() {
- try {
- // 1) session name, channel = null, 3 event names, kernel
- String sessionName = "mysession2";
- String channelName = "mychannel";
- String eventName0 = "myevent0";
- String eventName1 = "myevent1";
- String functionProbe = "0xc0101340";
- String dynProbe = "init_post";
-
- fShell.setScenario(SCEN_EVENT_HANDLING);
-
- // 1) session name, channel = null, event name, function probe, probe
- fService.enableProbe(sessionName, null, eventName0, true, functionProbe, new NullProgressMonitor());
-
- // 2) session name, channel = mychannel
- fService.enableProbe(sessionName, channelName, eventName1, false, dynProbe, new NullProgressMonitor());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
- public void testEnableLogLevel() {
- try {
- // 1) session name, channel = null, 3 event names, kernel
- String sessionName = "mysession2";
- String channelName = "mychannel";
- String eventName4 = "myevent4";
- String eventName5 = "myevent5";
-
- fShell.setScenario(SCEN_EVENT_HANDLING);
-
- // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
- fService.enableLogLevel(sessionName, null, eventName4, LogLevelType.LOGLEVEL_ONLY, TraceLogLevel.TRACE_DEBUG, new NullProgressMonitor());
-
- // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
- fService.enableLogLevel(sessionName, channelName, eventName5, LogLevelType.LOGLEVEL, TraceLogLevel.TRACE_DEBUG_FUNCTION, new NullProgressMonitor());
-
- } catch (ExecutionException e) {
- fail(e.toString());
- }
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.stubs.service;
-
-import org.eclipse.linuxtools.lttng.stubs.service.shells.LTTngToolsFileShell;
-
-public class CommandShellFactory {
-
- public static final int GET_SESSION_NAMES_COMMAND_SHELL = 0;
-
- private static CommandShellFactory fInstance = null;
-
- public static CommandShellFactory getInstance() {
- if (fInstance == null) {
- fInstance = new CommandShellFactory();
- }
- return fInstance;
- }
-
-// public ICommandShell getRealShell() {
-// ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
-// IHost host = registry.getLocalHost();
-// RemoteSystemProxy proxy = new RemoteSystemProxy(host);
-// ICommandShell shell = new LTTngToolsSimulatorShell(proxy);
-// return shell;
-// }
-
- public LTTngToolsFileShell getFileShell() {
- return new LTTngToolsFileShell();
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.stubs.service;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.remote.IRemoteSystemProxy;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandShell;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.LTTngToolsFileShell;
-import org.eclipse.rse.core.model.IRSECallback;
-import org.eclipse.rse.core.subsystems.ICommunicationsListener;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.services.shells.IShellService;
-import org.eclipse.rse.services.terminals.ITerminalService;
-import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
-
-public class TestRemoteSystemProxy implements IRemoteSystemProxy {
-
- private LTTngToolsFileShell fShell = null;
- private String fTestFile = null;
- private String fScenario = null;
-
- @Override
- public IShellService getShellService() {
- return null;
- }
-
- @Override
- public ITerminalService getTerminalService() {
- return null;
- }
-
- @Override
- public ISubSystem getShellServiceSubSystem() {
- return null;
- }
-
- @Override
- public ISubSystem getTerminalServiceSubSystem() {
- return null;
- }
- @Override
- public IFileServiceSubSystem getFileServiceSubSystem() {
- return null;
- }
-
- @Override
- public void connect(IRSECallback callback) throws ExecutionException {
- if (callback != null) {
- callback.done(Status.OK_STATUS, null);
- }
- }
-
- @Override
- public void disconnect() throws ExecutionException {
- fShell = null;
- }
-
- @Override
- public ICommandShell createCommandShell() throws ExecutionException {
- if (fShell == null) {
- fShell = CommandShellFactory.getInstance().getFileShell();
- if ((fTestFile != null) && (fScenario != null)) {
- try {
- fShell.loadScenarioFile(fTestFile);
- } catch (Exception e) {
- throw new ExecutionException(e.toString());
- }
- fShell.setScenario(fScenario);
- }
- }
- return fShell;
- }
-
- @Override
- public void addCommunicationListener(ICommunicationsListener listener) {
- }
-
- @Override
- public void removeCommunicationListener(ICommunicationsListener listener) {
- }
-
- public void setTestFile(String testFile) {
- fTestFile = testFile;
- }
-
- public void setScenario(String scenario) {
- fScenario = scenario;
- if (fShell != null) {
- fShell.setScenario(fScenario);
- }
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.stubs.service.shells;
-
-import java.io.BufferedReader;
-import java.io.DataInputStream;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.CommandResult;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandResult;
-
-public class LTTngToolsFileShell extends TestCommandShell {
-
- // ------------------------------------------------------------------------
- // CONSTANTS
- // ------------------------------------------------------------------------
- private final static String SCENARIO_KEY = "<SCENARIO>"; //$NON-NLS-1$
- private final static String SCENARIO_END_KEY = "</SCENARIO>"; //$NON-NLS-1$
- private final static String INPUT_KEY = "<COMMAND_INPUT>"; //$NON-NLS-1$
- private final static String INPUT_END_KEY = "</COMMAND_INPUT>"; //$NON-NLS-1$
- private final static String RESULT_KEY = "<COMMAND_RESULT>"; //$NON-NLS-1$
- @SuppressWarnings("unused")
- private final static String RESULT_END_KEY = "</COMMAND_RESULT>"; //$NON-NLS-1$
- private final static String OUTPUT_KEY = "<COMMAND_OUTPUT>"; //$NON-NLS-1$
- private final static String OUTPUT_END_KEY = "</COMMAND_OUTPUT>"; //$NON-NLS-1$
- private final static String COMMENT_KEY = "#.*"; //$NON-NLS-1$
-
- private final static Pattern LTTNG_LIST_SESSION_PATTERN = Pattern.compile("lttng\\s+list\\s+(.+)"); //$NON-NLS-1$
- private final static String LTTNG_LIST_PROVIDER_PATTERN = "lttng\\s+list\\s+(-u|-k)"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- private String fScenariofile;
- private String fScenario;
-
- private Map<String, Map<String, ICommandResult>> fScenarioMap = new HashMap<String, Map<String, ICommandResult>>();
- private Map<String, Integer> fSessionNameMap = new HashMap<String, Integer>();
-
- /**
- * Parse a scenario file with the format:
- * <SCENARIO>
- * ScenarioName
- *
- * <COMMAND_INPUT>
- * Command
- * </COMAND_INPUT>
- *
- * <COMMAND_RESULT>
- * CommandResult
- * </COMMAND_RESULT>
- *
- * <COMMAND_OUTPUT>
- * CommandOutput
- * </COMMAND_OUTPUT>
- *
- * </SCENARIO>
- *
- * Where: ScenarioName - is the scenario name
- * Command - the command line string
- * CommandResult - the result integer of the command (0 for success, 1 for failure)
- * ComandOutput - the command output string (multi-line possible)
- *
- * Note: 1) There can be many scenarios per file
- * 2) There can be many (Command-CommandResult-CommandOutput) triples per scenario
- * 3) Lines starting with # will be ignored (comments)
- *
- * @param scenariofile - path to scenario file
- * @throws Exception
- */
- public void loadScenarioFile(String scenariofile) throws Exception {
- fScenariofile = scenariofile;
-
- // clean up map
- Collection<Map<String, ICommandResult>> values = fScenarioMap.values();
- for (Iterator<Map<String, ICommandResult>> iterator = values.iterator(); iterator.hasNext();) {
- Map<String, ICommandResult> map = (Map<String, ICommandResult>) iterator.next();
- map.clear();
- }
- fScenarioMap.clear();
-
- // load from file
-
- // Open the file
- FileInputStream fstream = new FileInputStream(fScenariofile);
-
- // Get the object of DataInputStream
- DataInputStream in = new DataInputStream(fstream);
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
- String strLine;
-
- // Read File Line by Line
-
- // Temporary map for generating instance numbers for lttng list <session> commands.
- // The numbers are per scenario.
- Map<String, Integer> tmpSessionNameMap = new HashMap<String, Integer>();
- while ((strLine = br.readLine()) != null) {
-
- // Ignore comments
- if(isComment(strLine)) {
- continue;
- }
-
- if (SCENARIO_KEY.equals(strLine)) {
- // scenario start
-
- // Ignore comments
- strLine = br.readLine();
- while (isComment(strLine)) {
- strLine = br.readLine();
- }
-
- String scenario = strLine;
- Map<String, ICommandResult> commandMap = new HashMap<String, ICommandResult>();
- fScenarioMap.put(scenario, commandMap);
- List<String> output = null;
- String input = null;
- boolean inOutput = false;
- int result = 0;
- tmpSessionNameMap.clear();
- while ((strLine = br.readLine()) != null) {
- // Ignore comments
- if(isComment(strLine)) {
- continue;
- }
-
- if (SCENARIO_END_KEY.equals(strLine)) {
- // Scenario is finished
- break;
- }
- if (INPUT_KEY.equals(strLine)) {
- strLine = br.readLine();
- // Ignore comments
- while (isComment(strLine)) {
- strLine = br.readLine();
- }
- // Read command
- input = strLine;
-
- // Handle instances of 'lttng list <session"-comamand
- Matcher matcher = LTTNG_LIST_SESSION_PATTERN.matcher(strLine);
- if (matcher.matches() && !input.matches(LTTNG_LIST_PROVIDER_PATTERN)) {
- String sessionName = matcher.group(1).trim();
- Integer i = tmpSessionNameMap.get(sessionName);
- if (i != null) {
- i++;
- } else {
- i = 0;
- }
- tmpSessionNameMap.put(sessionName, i);
- input += String.valueOf(i);
- }
- } else if (INPUT_END_KEY.equals(strLine)) {
- // Initialize output array
- output = new ArrayList<String>();
- } else if (RESULT_KEY.equals(strLine)) {
- strLine = br.readLine();
- // Ignore comments
- while (isComment(strLine)) {
- strLine = br.readLine();
- }
- // Save result value
- result = Integer.parseInt(strLine);
- } else if (OUTPUT_END_KEY.equals(strLine)) {
- // Save output/result in command map
- commandMap.put(input, new CommandResult(result, output.toArray(new String[output.size()])));
- inOutput = false;
- } else if (OUTPUT_KEY.equals(strLine)) {
- // first line of output
- inOutput = true;
- strLine = br.readLine();
-
- // Ignore comments
- while (isComment(strLine)) {
- strLine = br.readLine();
- }
- output.add(strLine);
- } else if (inOutput) {
- // subsequent lines of output
- output.add(strLine);
- }
-// else {
-// if (RESULT_END_KEY.equals(strLine)) {
- // nothing to do
-// }
- }
- }
- }
- //Close the input stream
- in.close();
- }
-
- // Set the scenario to consider in executeCommand()
- public synchronized void setScenario(String scenario) {
- fScenario = scenario;
- fSessionNameMap.clear();
- if (!fScenarioMap.containsKey(fScenario)) {
- throw new IllegalArgumentException();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.stubs.service.shells.TestCommandShell#executeCommand(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- @SuppressWarnings("nls")
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
- Map<String, ICommandResult> commands = fScenarioMap.get(fScenario);
-
- Matcher matcher = LTTNG_LIST_SESSION_PATTERN.matcher(command);
- if (matcher.matches() && !command.matches(LTTNG_LIST_PROVIDER_PATTERN)) {
- String sessionName = matcher.group(1).trim();
- Integer i = fSessionNameMap.get(sessionName);
- if (i != null) {
- i++;
- } else {
- i = 0;
- }
- fSessionNameMap.put(sessionName, i);
- command += String.valueOf(i);
- }
-
- if (commands.containsKey(command)) {
- return commands.get(command);
- }
-
- String[] output = new String[1];
- output[0] = String.valueOf("Command not found");
- return new CommandResult(1, output);
- }
-
- // ------------------------------------------------------------------------
- // Helper methods
- // ------------------------------------------------------------------------
- private boolean isComment(String line) {
- return line.matches(COMMENT_KEY);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.lttng.stubs.service.shells;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.CommandResult;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandResult;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandShell;
-
-public class TestCommandShell implements ICommandShell {
-
- protected boolean fIsConnected = false;
-
- @Override
- public void connect() throws ExecutionException {
- fIsConnected = true;
- }
-
- @Override
- public void disconnect() {
- fIsConnected = false;
- }
-
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor) throws ExecutionException {
- return executeCommand(command, monitor, true);
- }
-
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
- if (fIsConnected) {
-
- }
- return new CommandResult(0, new String[0]);
- }
-}
+++ /dev/null
-####################################################################
-# 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:
-# Bernd Hufmann - Initial API and implementation
-####################################################################
-####################################################################
-# Scenario: Test no sessions available
-####################################################################
-<SCENARIO>
-Initialize
-<COMMAND_INPUT>
-lttng list
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Currently no available tracing session
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng list -k
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Kernel events
--------------
- sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)
- sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)
- sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)
-
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng list -u
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST events:
--------------
-
-PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
- ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
- ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
-
-PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
- ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
- ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
-
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Enable events from kernel provider events
-####################################################################
-<SCENARIO>
-Scenario1
-<COMMAND_INPUT>
-lttng create mysession
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session mysession created.
-Traces will be written in /home/user/lttng-traces/mysession-20120314-132824
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng list mysession
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Tracing session mysession: [inactive]
- Trace path: /home/user/lttng-traces/mysession-20120314-132824
-
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-event sched_kthread_stop,sched_kthread_stop_ret -k -s mysession --tracepoint
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-kernel event sched_kthread_stop created in channel channel0
-kernel sched_kthread_stop_ret created in channel channel0
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng list mysession
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Tracing session mysession: [inactive]
- Trace path: /home/user/lttng-traces/mysession-20120314-132824
-
-=== Domain: Kernel ===
-
-Channels:
--------------
-- channel0: [enabled]
-
- Attributes:
- overwrite mode: 0
- subbufers size: 262144
- number of subbufers: 4
- switch timer interval: 0
- read timer interval: 200
- output: splice()
-
- Events:
- sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
- sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
-
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng disable-event sched_kthread_stop_ret,sched_kthread_stop -k -s mysession -c channel0
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-kernel event sched_kthread_stop_ret disabled in channel channel0
-kernel event sched_kthread_stop disabled in channel channel0
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-event sched_kthread_stop -k -s mysession -c channel0 --tracepoint
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-kernel event sched_kthread_stop enabled in channel channel0
-</COMMAND_OUTPUT>
-
-
-<COMMAND_INPUT>
-lttng destroy mysession
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session mysession destroyed.
-</COMMAND_OUTPUT>
-
-</SCENARIO>
-
-####################################################################
-# Scenario: Enable events from UST provider events
-####################################################################
-<SCENARIO>
-Scenario2
-<COMMAND_INPUT>
-lttng create mysession -o /home/user/temp
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session mysession created.
-Traces will be written in /home/user/temp
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng list mysession
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Tracing session mysession: [inactive]
- Trace path: /home/user/temp
-
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-channel mychannel -u -s mysession --subbuf-size 16384 --num-subbuf 2 --switch-timer 200 --read-timer 100
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST channel mychannel enabled for session mysession
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng list mysession
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Tracing session mysession: [inactive]
- Trace path: /home/user/temp
-
-=== Domain: UST global ===
-
-Channels:
--------------
-- mychannel: [enabled]
-
- Attributes:
- overwrite mode: 0
- subbufers size: 16384
- number of subbufers: 2
- switch timer interval: 200
- read timer interval: 100
- output: mmap()
-
- Events:
- None
-
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-event ust_tests_hello:tptest_sighandler,ust_tests_hello:tptest -u -s mysession --tracepoint
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST event ust_tests_hello:tptest_sighandler in channel channel0
-UST sched_ust_tests_hello:tptest created in channel channel0
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng list mysession
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Tracing session mysession: [inactive]
- Trace path: /home/user/temp
-
-=== Domain: UST global ===
-
-Channels:
--------------
-- mychannel: [enabled]
-
- Attributes:
- overwrite mode: 0
- subbufers size: 16384
- number of subbufers: 2
- switch timer interval: 200
- read timer interval: 100
- output: mmap()
-
- Events:
- ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [enabled]
- ust_tests_hello:tptest (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [enabled]
-
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng disable-event ust_tests_hello:tptest -u -s mysession -c mychannel
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-kernel event ust_tests_hello:tptest in channel mychannel
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-event ust_tests_hello:tptest -u -s mysession -c mychannel --tracepoint
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-kernel event ust_tests_hello:tptest enabled in channel mychannel
-</COMMAND_OUTPUT>
-
-
-<COMMAND_INPUT>
-lttng destroy mysession
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session mysession destroyed.
-</COMMAND_OUTPUT>
-
-</SCENARIO>
-
+++ /dev/null
-####################################################################
-# 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:
-# Bernd Hufmann - Initial API and implementation
-####################################################################
-####################################################################
-# Scenario: Test lttng not installed
-####################################################################
-<SCENARIO>
-LttngNotInstalled
-<COMMAND_INPUT>
-lttng list
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-1
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Command not found
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test no sessions available
-####################################################################
-<SCENARIO>
-NoSessionAvailable
-<COMMAND_INPUT>
-lttng list
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Currently no available tracing session
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test get sessions
-####################################################################
-<SCENARIO>
-GetSessionNames1
-<COMMAND_INPUT>
-lttng list
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Available tracing sessions:
- 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive]
- 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive]
-
- Use lttng list <session_name> for more details
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test lttng list <name> where session doesn't exist
-####################################################################
-<SCENARIO>
-GetSessionNameNotExist
-<COMMAND_INPUT>
-lttng list test
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-1
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session test not found
-Error: Session name not found
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test lttng list with garbage output
-####################################################################
-<SCENARIO>
-GetSessionGarbageOut
-<COMMAND_INPUT>
-lttng list
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-asdfaereafsdcv 12333456434&*89**(())(^%$*
-@#$%^&*()@#$%^&*()0834523094578kj;djkfs
-a;sdf094v5u dsafj;sd9
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test lttng list <name> with sample outputs
-####################################################################
-<SCENARIO>
-GetSession1
-<COMMAND_INPUT>
-lttng list mysession
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Tracing session mysession: [active]
- Trace path: /home/user/lttng-traces/mysession-20120129-084256
-
-=== Domain: Kernel ===
-
-Channels:
--------------
-- channel0: [enabled]
-
- Attributes:
- overwrite mode: 0
- subbufers size: 262144
- number of subbufers: 4
- switch timer interval: 0
- read timer interval: 200
- output: splice()
-
- Events:
- block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
- block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [disabled]
-
-- channel1: [disabled]
-
- Attributes:
- overwrite mode: 1
- subbufers size: 524288
- number of subbufers: 4
- switch timer interval: 100
- read timer interval: 400
- output: splice()
-
- Events:
- None
-
-=== Domain: UST global ===
-
-Channels:
--------------
-- mychannel1: [disabled]
-
- Attributes:
- overwrite mode: 1
- subbufers size: 8192
- number of subbufers: 8
- switch timer interval: 200
- read timer interval: 100
- output: mmap()
-
- Events:
- None
-
-- channel0: [enabled]
-
- Attributes:
- overwrite mode: 0
- subbufers size: 4096
- number of subbufers: 4
- switch timer interval: 0
- read timer interval: 200
- output: mmap()
-
- Events:
- ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled]
- * (type: tracepoint) [enabled]
-
-</COMMAND_OUTPUT>
-<COMMAND_INPUT>
-lttng list mysession1
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Tracing session mysession1: [inactive]
- Trace path: /home/user/lttng-traces/mysession1-20120203-133225
-
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-
-####################################################################
-# Scenario: Test "lttng list -k" with sample output
-####################################################################
-<SCENARIO>
-GetKernelProvider1
-<COMMAND_INPUT>
-lttng list -k
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Kernel events
--------------
- sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)
- sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)
- sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)
-
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test "lttng list -u" with sample output
-####################################################################
-<SCENARIO>
-GetUstProvider1
-<COMMAND_INPUT>
-lttng list -u
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST events:
--------------
-
-PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
- ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
- ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
-
-PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
- ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
- ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
-
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test "lttng list -u" with no UST provider available
-####################################################################
-<SCENARIO>
-GetUstProvider2
-<COMMAND_INPUT>
-lttng list -u
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST events:
--------------
-None
-
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test "lttng create <session>
-####################################################################
-<SCENARIO>
-CreateSession1
-<COMMAND_INPUT>
-lttng create mysession2
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session mysession2 created.
-Traces will be written in /home/user/lttng-traces/mysession2-20120209-095418
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test "lttng create <session> with different variants
-# and errors
-####################################################################
-<SCENARIO>
-CreateSessionVariants
-<COMMAND_INPUT>
-lttng create alreadyExist
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-1
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Error: Session name already exist
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng create "session with spaces"
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session session with spaces created.
-Traces will be written in /home/user/lttng-traces/session with spaces-20120209-095418
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng create wrongName
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session auto created.
-Traces will be written in /home/user/lttng-traces/auto-20120209-095418
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng create wrongPath -o /home/user/hallo
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session wrongPath created.
-Traces will be written in /home/user/lttng-traces/wrongPath-20120209-095418
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng create pathWithSpaces -o "/home/user/hallo user/here"
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session pathWithSpaces created.
-Traces will be written in /home/user/hallo user/here/pathWithSpaces-20120209-095418
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test "lttng destroy <session>
-####################################################################
-
-<SCENARIO>
-DestroySession1
-<COMMAND_INPUT>
-lttng destroy mysession2
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Session mysession2 destroyed.
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-####################################################################
-# Scenario: Test "lttng enable-channel ..." with different inputs
-####################################################################
-
-<SCENARIO>
-ChannelHandling
-<COMMAND_INPUT>
-lttng enable-channel mychannel0,mychannel1 -k -s mysession2 --overwrite --subbuf-size 16384 --num-subbuf 2 --switch-timer 200 --read-timer 100
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Kernel channel mychannel0 enabled for session mysession2
-Kernel channel mychannel1 enabled for session mysession2
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-channel ustChannel -u -s mysession2 --overwrite --subbuf-size 32768 --num-subbuf 1 --switch-timer 100 --read-timer 200
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST channel channel0 enabled for session mysession2
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-channel mychannel0,mychannel1 -k -s mysession2
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Kernel channel mychannel0 enabled for session mysession2
-Kernel channel mychannel1 enabled for session mysession2
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-channel ustChannel -u -s mysession2
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST channel mychannel0 enabled for session mysession2
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng disable-channel mychannel0,mychannel1 -k -s mysession2
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Kernel channel mychannel0 disabled for session mysession2
-Kernel channel mychannel1 disabled for session mysession2
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng disable-channel ustChannel -u -s mysession2
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST channel mychannel0 enabled for session mysession2
-</COMMAND_OUTPUT>
-</SCENARIO>
-
-
-####################################################################
-# Scenario: Test "lttng enable-events ..." with different inputs
-####################################################################
-<SCENARIO>
-EventHandling
-
-# Tracepoint test cases
-
-<COMMAND_INPUT>
-lttng enable-event block_rq_remap,block_bio_remap,softirq_entry -k -s mysession2 --tracepoint
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-kernel event block_rq_remap created in channel channel0
-kernel event block_bio_remap created in channel channel0
-kernel event softirq_entry created in channel channel0
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-event -a -k -s mysession2 -c mychannel --tracepoint
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-All kernel tracepoints are enabled in channel channel0
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-event ust_tests_hello:tptest_sighandler -u -s mysession2 -c mychannel --tracepoint
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST event ust_tests_hello:tptest_sighandler created in channel mychannel
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-event -a -u -s mysession2 -c mychannel --tracepoint
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-All UST tracepoints are enabled in channel mychannel
-</COMMAND_OUTPUT>
-
-# Syscall test cases
-
-<COMMAND_INPUT>
-lttng enable-event -a -k -s mysession2 --syscall
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-All kernel system calls are enabled in channel channel0
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-event -a -k -s mysession2 -c mychannel --syscall
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-All kernel system calls are enabled in channel mychannel
-</COMMAND_OUTPUT>
-
-# dynamic probe/function probe test cases
-
-<COMMAND_INPUT>
-lttng enable-event myevent0 -k -s mysession2 --function 0xc0101340
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-kernel event myevent0 created in channel mychannel
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-event myevent1 -k -s mysession2 -c mychannel --probe init_post
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-kernel event myevent1 created in channel mychannel
-</COMMAND_OUTPUT>
-
-# log level test cases
-
-<COMMAND_INPUT>
-lttng enable-event myevent4 -u -s mysession2 --loglevel-only TRACE_DEBUG
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST event myevent4 created in channel channel0
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng enable-event myevent5 -u -s mysession2 -c mychannel --loglevel TRACE_DEBUG_FUNCTION
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST event myevent5 created in channel mychannel
-</COMMAND_OUTPUT>
-
-</SCENARIO>
-
-
+++ /dev/null
-####################################################################
-# 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:
-# Bernd Hufmann - Initial API and implementation
-####################################################################
-####################################################################
-# Scenario: Test lttng list <name> with sample outputs
-####################################################################
-<SCENARIO>
-ListInfoTest
-<COMMAND_INPUT>
-lttng list
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Available tracing sessions:
- 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive]
- 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive]
-
- Use lttng list <session_name> for more details
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng list mysession
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Tracing session mysession: [active]
- Trace path: /home/user/lttng-traces/mysession-20120129-084256
-
-=== Domain: Kernel ===
-
-Channels:
--------------
-- channel0: [enabled]
-
- Attributes:
- overwrite mode: 0
- subbufers size: 262144
- number of subbufers: 4
- switch timer interval: 0
- read timer interval: 200
- output: splice()
-
- Events:
- block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
- block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [disabled]
- myevent2 (type: probe) [enabled]
- addr: 0xc0101340
- myevent0 (type: probe) [enabled]
- offset: 0x0
- symbol: init_post
- syscalls (type: syscall) [enabled]
-
-- channel1: [disabled]
-
- Attributes:
- overwrite mode: 1
- subbufers size: 524288
- number of subbufers: 4
- switch timer interval: 100
- read timer interval: 400
- output: splice()
-
- Events:
- None
-
-=== Domain: UST global ===
-
-Channels:
--------------
-- mychannel1: [disabled]
-
- Attributes:
- overwrite mode: 1
- subbufers size: 8192
- number of subbufers: 8
- switch timer interval: 200
- read timer interval: 100
- output: mmap()
-
- Events:
- None
-
-- channel0: [enabled]
-
- Attributes:
- overwrite mode: 0
- subbufers size: 4096
- number of subbufers: 4
- switch timer interval: 0
- read timer interval: 200
- output: mmap()
-
- Events:
- ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled]
- * (type: tracepoint) [enabled]
-
-</COMMAND_OUTPUT>
-<COMMAND_INPUT>
-lttng list mysession1
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Tracing session mysession1: [inactive]
- Trace path: /home/user/lttng-traces/mysession1-20120203-133225
-
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng list -k
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-Kernel events
--------------
- sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)
- sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)
- sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)
-
-</COMMAND_OUTPUT>
-
-<COMMAND_INPUT>
-lttng list -u
-</COMMAND_INPUT>
-<COMMAND_RESULT>
-0
-</COMMAND_RESULT>
-<COMMAND_OUTPUT>
-UST events:
--------------
-
-PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
- ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
- ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
-
-PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
- ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
- ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
-
-</COMMAND_OUTPUT>
-
-</SCENARIO>
org.eclipse.linuxtools.internal.lttng.ui.tracecontrol.wizards;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
org.eclipse.linuxtools.internal.lttng.ui.views;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
org.eclipse.linuxtools.internal.lttng.ui.views.common;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.internal.lttng.ui.views.control;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.internal.lttng.ui.views.control.model;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.internal.lttng.ui.views.control.property;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.internal.lttng.ui.views.control.remote;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.internal.lttng.ui.views.control.service;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
org.eclipse.linuxtools.internal.lttng.ui.views.controlflow;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
org.eclipse.linuxtools.internal.lttng.ui.views.controlflow.evProcessor;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
org.eclipse.linuxtools.internal.lttng.ui.views.controlflow.model;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
commands.experiment.delete = Delete Experiment
commands.experiment.delete.description = Delete an LTTng Experiment
-# LTTng 2.0 trace control commands
-trace.control.rse.system.type.name=LTTng (v2.0 or later)
-trace.control.rse.system.type.description=LTTng Trace Control (v2.0 or later)
-
-commands.control.category=LTTng Trace Control Commands
-commands.control.category.description=LTTng Trace Control Commands
-
-commands.control.new=New Connection
-commands.control.new.description=New Connection to Target Node
-
-commands.control.connect=Connect
-commands.control.connect.description=Connect to Target Node
-
-commands.control.disconnect=Disconnect
-commands.control.discconnect.description=Disconnect to Target Node
-
-commands.control.refresh=Refresh
-commands.control.refresh.description=Refresh Node Configuration
-
-
-commands.control.delete=Delete
-commands.control.deleete.description=Delete Target Node
-
-commands.control.create.session=Create Session
-commands.control.create.session.description=Create a Trace Session
-
-commands.control.destroy.session=Destroy Session
-commands.control.destroy.session.description=Destroy a Trace Session
-
-commands.control.create.channel=Create Channel
-commands.control.create.channel.description=Create a Trace Channel
-
-commands.control.enable.channel=Enable Channel
-commands.control.enable.channel.description=Enable a Trace Channel
-
-commands.control.disable.channel=Disable Channel
-commands.control.disable.channel.description=Disable a Trace Channel
-
-commands.control.start=Start
-commands.control.start.description=Start Trace Session
-
-commands.control.stop=Stop
-commands.control.stop.description=Stop Trace Session
-
-#commands.control.enable.event=Enable
-commands.control.enable.assign.description=Assign Event to Session and Channel and Enable Event
-
-commands.control.enable.event=Enable Event
-commands.control.enable.event.description=Enable Event
-
-commands.control.enable.eventOnDomain=Enable Event (default channel)
-commands.control.enable.eventOnDomain.description=Enable Event on Default Channel
-
-commands.control.disable.event=Disable Event
-commands.control.disable.event.description=Disable Event
-
# trace control (RSE) properties (LTTng 0.x)
lttng.rse.subsystem.type.name=LTTng (v0.x)
lttng.rse.subsystem.type.description=LTTng Trace Control (v0.x)
id="org.eclipse.linuxtools.lttng.ui.views.category"
name="%views.category.name">
</category>
- <view
- allowMultiple="false"
- category="org.eclipse.linuxtools.lttng.ui.views.category"
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView"
- icon="icons/eview16/control_view.gif"
- id="org.eclipse.linuxtools.internal.lttng.ui.views.control"
- name="%control.view.name"
- restorable="true">
- </view>
<view
allowMultiple="false"
category="org.eclipse.linuxtools.lttng.ui.views.category"
visible="true">
</actionSet>
</extension>
- <extension
- point="org.eclipse.ui.commands">
- <category
- description="%commands.control.category.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- name="%commands.control.category">
- </category>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.new.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.newConnection"
- name="%commands.control.new">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.connect.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.connect"
- name="%commands.control.connect">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.disconnect.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.disconnect"
- name="%commands.control.disconnect">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.refresh.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.refresh"
- name="%commands.control.refresh">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.delete.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.delete"
- name="%commands.control.delete">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.create.session.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.createSession"
- name="%commands.control.create.session">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.destroy.session.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.destroySession"
- name="%commands.control.destroy.session">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.create.channel.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.createChannelOnSession"
- name="%commands.control.create.channel">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.create.channel.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.createChannelOnDomain"
- name="%commands.control.create.channel">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.enable.channel.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enableChannel"
- name="%commands.control.enable.channel">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.disable.channel.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.disableChannel"
- name="%commands.control.disable.channel">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.start.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.start"
- name="%commands.control.start">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.stop.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.stop"
- name="%commands.control.stop">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.enable.assign.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.assign.event"
- name="%commands.control.enable.event">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.enable.event.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.event"
- name="%commands.control.enable.event">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.disable.event.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.disable.event"
- name="%commands.control.disable.event">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.enable.event.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.eventOnChannel"
- name="%commands.control.enable.event">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.enable.eventOnDomain.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.eventOnDomain"
- name="%commands.control.enable.eventOnDomain">
- </command>
- <command
- categoryId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.category"
- description="%commands.control.enable.eventOnDomain.description"
- id="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.eventOnSession"
- name="%commands.control.enable.eventOnDomain">
- </command>
-
- </extension>
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="false"
- locationURI="toolbar:org.eclipse.linuxtools.internal.lttng.ui.views.control">
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.newConnection"
- icon="icons/elcl16/target_add.gif"
- label="%commands.control.new"
- style="push">
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.connect"
- icon="icons/elcl16/connect.gif"
- label="%commands.control.connect"
- style="push">
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.disconnect"
- icon="icons/elcl16/disconnect.gif"
- label="%commands.control.disconnect"
- style="push">
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.refresh"
- icon="icons/elcl16/refresh.gif"
- label="%commands.control.refresh"
- style="push">
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.delete"
- icon="icons/elcl16/target_delete.gif"
- label="%commands.control.delete"
- style="push">
- </command>
- <separator
- name="org.eclipse.linuxtools.internal.lttng.ui.views.control.toolbar.separator1"
- visible="true">
- </separator>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.start"
- icon="icons/elcl16/start_trace.gif"
- label="%commands.control.start"
- style="push">
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.stop"
- icon="icons/elcl16/pause_trace.gif"
- label="%commands.control.stop"
- style="push">
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.destroySession"
- icon="icons/elcl16/delete_trace.gif"
- label="%commands.control.destroy.session"
- style="push">
- </command>
-
- </menuContribution>
- <menuContribution
- allPopups="false"
- locationURI="popup:org.eclipse.linuxtools.internal.lttng.ui.views.control">
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.connect"
- icon="icons/elcl16/connect.gif"
- label="%commands.control.connect"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.disconnect"
- icon="icons/elcl16/disconnect.gif"
- label="%commands.control.disconnect"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.refresh"
- icon="icons/elcl16/refresh.gif"
- label="%commands.control.refresh"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.delete"
- icon="icons/elcl16/target_delete.gif"
- label="%commands.control.delete"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.createSession"
- icon="icons/elcl16/add_button.gif"
- label="%commands.control.create.session"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionGroup">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.start"
- icon="icons/elcl16/start_trace.gif"
- label="%commands.control.start"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.stop"
- icon="icons/elcl16/pause_trace.gif"
- label="%commands.control.stop"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.destroySession"
- icon="icons/elcl16/delete_trace.gif"
- label="%commands.control.destroy.session"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- <separator
- name="org.eclipse.linuxtools.internal.lttng.ui.views.control.popup.separator1"
- visible="true">
- </separator>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.createChannelOnSession"
- icon="icons/elcl16/add_button.gif"
- label="%commands.control.create.channel"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <and>
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- <not>
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent">
- </instanceof>
- </iterate>
- </not>
- <count
- value="1">
- </count>
- </and>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.eventOnSession"
- icon="icons/elcl16/edit.gif"
- label="%commands.control.enable.eventOnDomain"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <and>
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- <count
- value="1">
- </count>
- </and>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.createChannelOnDomain"
- icon="icons/elcl16/add_button.gif"
- label="%commands.control.create.channel"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <and>
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent">
- </instanceof>
- </iterate>
- <not>
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- </not>
- <count
- value="1">
- </count>
- </and>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.eventOnDomain"
- icon="icons/elcl16/edit.gif"
- label="%commands.control.enable.eventOnDomain"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <and>
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent">
- </instanceof>
- </iterate>
- <count
- value="1">
- </count>
- </and>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enableChannel"
- icon="icons/elcl16/edit.gif"
- label="%commands.control.enable.channel"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.disableChannel"
- icon="icons/elcl16/edit.gif"
- label="%commands.control.disable.channel"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
-
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.assign.event"
- icon="icons/elcl16/edit.gif"
- label="%commands.control.enable.event"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
-
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.event"
- icon="icons/elcl16/edit.gif"
- label="%commands.control.enable.event"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceEventComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
-
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.disable.event"
- icon="icons/elcl16/edit.gif"
- label="%commands.control.disable.event"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceEventComponent">
- </instanceof>
- </iterate>
- </with>
- </visibleWhen>
- </command>
-
- <command
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.eventOnChannel"
- icon="icons/elcl16/edit.gif"
- label="%commands.control.enable.event"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <and>
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent">
- </instanceof>
- </iterate>
- <count
- value="1">
- </count>
- </and>
- </with>
- </visibleWhen>
- </command>
-
-
-
- </menuContribution>
-
- </extension>
- <extension
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.NewConnectionHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.newConnection">
- <activeWhen>
- <with
- variable="activePart">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView">
- </instanceof>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.ConnectHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.connect">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.DisconnectHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.disconnect">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.RefreshHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.refresh">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.DeleteHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.delete">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.CreateSessionHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.createSession">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionGroup">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.DestroySessionHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.destroySession">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.CreateChannelOnSessionHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.createChannelOnSession">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.CreateChannelOnDomainHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.createChannelOnDomain">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.EnableChannelHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enableChannel">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.DisableChannelHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.disableChannel">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
-
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.StartHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.start">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
-
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.StopHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.stop">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
-
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.AssignEventHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.assign.event">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
-
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.EnableEventHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.event">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceEventComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
-
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.DisableEventHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.disable.event">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceEventComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
-
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.EnableEventOnChannelHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.eventOnChannel">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
-
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.EnableEventOnDomainHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.eventOnDomain">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.EnableEventOnSessionHandler"
- commandId="org.eclipse.linuxtools.internal.lttng.ui.commands.control.enable.eventOnSession">
- <activeWhen>
- <with
- variable="selection">
- <iterate
- operator="or">
- <instanceof
- value="org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- </handler>
- </extension>
<!-- ======================================= -->
<!-- SubSystem Configuration -->
name="org.eclipse.linuxtools.internal.lttng.ui.tracecontrol.systemType"
subsystemConfigurationIds="org.eclipse.linuxtools.internal.lttng.ui.tracecontrol.subsystems.TraceSubSystemConfiguration;org.eclipse.tm.tcf.rse.Processes;org.eclipse.tm.tcf.rse.Shells;org.eclipse.tm.tcf.rse.Files;org.eclipse.tm.tcf.rse.Terminals">
</systemType>
- <systemType
- description="%trace.control.rse.system.type.description"
- icon="icons/obj16/systemlttng2.gif"
- iconLive="icons/obj16/systemlttng2-live.gif"
- id="org.eclipse.linuxtools.internal.lttng.ui.control.systemType"
- label="%trace.control.rse.system.type.name"
- name="org.eclipse.linuxtools.internal.lttng.ui.control.systemType"
- subsystemConfigurationIds="ssh.shells;ssh.files;ssh.terminals;processes.shell.linux">
- </systemType>
</extension>
<!-- ======================================= -->
package org.eclipse.linuxtools.internal.lttng.ui.views;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
import org.eclipse.linuxtools.internal.lttng.ui.views.controlflow.ControlFlowView;
import org.eclipse.linuxtools.internal.lttng.ui.views.resources.ResourcesView;
import org.eclipse.linuxtools.internal.lttng.ui.views.statistics.StatisticsView;
private static final String RESOURCES_VIEW_ID = ResourcesView.ID;
private static final String STATISTICS_VIEW_ID = StatisticsView.ID;
private static final String HISTOGRAM_VIEW_ID = HistogramView.ID;
- private static final String CONTROL_VIEW_ID = ControlView.ID;
+
// Standard Eclipse views
private static final String PROJECT_VIEW_ID = IPageLayout.ID_PROJECT_EXPLORER;
IFolderLayout topLeftFolder = layout.createFolder(
"topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
topLeftFolder.addView(PROJECT_VIEW_ID);
- topLeftFolder.addView(CONTROL_VIEW_ID);
// Create the top right folder
IFolderLayout topRightFolder = layout.createFolder(
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 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:
- * Francois Chouinard - Initial API and implementation
- * Bernd Hufmann - Filled with content
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.lttng.ui.views.control;
-
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponentChangedListener;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlRoot;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * <b><u>ControlView</u></b>
- * <p>
- * View implementation for Trace Control.
- * </p>
- */
-public class ControlView extends ViewPart implements ITraceControlComponentChangedListener {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * View ID.
- */
- public static final String ID = "org.eclipse.linuxtools.internal.lttng.ui.views.control"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /**
- * The tree viewer.
- */
- private TreeViewer fTreeViewer = null;
-
- /**
- * The trace control root node. This provides access to the whole model.
- */
- private ITraceControlComponent fRoot = null;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return returns the trace control tree node (model).
- */
- public ITraceControlComponent getTraceControlRoot() {
- return fRoot;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createPartControl(Composite parent) {
- // Create tree viewer
- fTreeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- ColumnViewerToolTipSupport.enableFor(fTreeViewer);
-
- fTreeViewer.setContentProvider(new TraceControlContentProvider());
- fTreeViewer.setLabelProvider(new TraceControlLabelProvider());
-
- // Create model root
- fRoot = new TraceControlRoot();
- fRoot.addComponentListener(this);
- fTreeViewer.setInput(fRoot);
-
- // Create context menu for the tree viewer
- createContextMenu();
-
- getSite().setSelectionProvider(fTreeViewer);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
- */
- @Override
- public void setFocus() {
- fTreeViewer.getControl().setFocus();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponentChangedListener#componentAdded(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent)
- */
- @Override
- public void componentAdded(ITraceControlComponent parent, ITraceControlComponent component) {
- componentChanged(component);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponentChangedListener#componentRemoved(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent)
- */
- @Override
- public void componentRemoved(ITraceControlComponent parent, ITraceControlComponent component) {
- componentChanged(component);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponentChangedListener#componentChanged(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent)
- */
- @Override
- public void componentChanged(ITraceControlComponent component) {
- if (fTreeViewer.getTree().isDisposed()) {
- return;
- }
-
- fTreeViewer.getTree().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (fTreeViewer.getTree().isDisposed()) {
- return;
- }
- fTreeViewer.refresh();
- // Change selection needed
- final ISelection sel = fTreeViewer.getSelection();
- fTreeViewer.setSelection(null);
- fTreeViewer.setSelection(sel);
- }
- });
- }
-
- /**
- * Sets the selected component in the tree
- * @param component - component to select
- */
- public void setSelection(ITraceControlComponent component) {
- StructuredSelection selection = new StructuredSelection(component);
- fTreeViewer.setSelection(selection);
- }
-
- /**
- * Sets the selected components in the tree
- * @param component - array of components to select
- */
- public void setSelection(ITraceControlComponent[] components) {
- StructuredSelection selection = new StructuredSelection(components);
- fTreeViewer.setSelection(selection);
- }
-
-// public ITraceControlComponent getSelection() {
-// ISelection selection = fTreeViewer.getSelection();
-//
-// }
-
- // ------------------------------------------------------------------------
- // Helper methods
- // ------------------------------------------------------------------------
- private void createContextMenu() {
- // First we create a menu Manager
- final MenuManager menuManager = new MenuManager();
- final Menu menu = menuManager.createContextMenu(fTreeViewer.getTree());
- // Set the MenuManager
- fTreeViewer.getTree().setMenu(menu);
- getSite().registerContextMenu(menuManager, fTreeViewer);
- }
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011 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:
- * Bernd Hufmann - Initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * <b><u>Messages</u></b>
- * <p>
- * Messages file for the trace control package.
- * </p>
- */
-final public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.lttng.ui.views.control.messages"; //$NON-NLS-1$
-
- // Failures
- public static String TraceControl_ConnectionFailure;
- public static String TraceControl_DisconnectionFailure;
- public static String TraceControl_ExecutionCancelled;
- public static String TraceControl_ExecutionFailure;
- public static String TraceControl_ExecutionTimeout;
- public static String TraceControl_ShellNotConnected;
-
- public static String TraceControl_CommandShellError;
- public static String TraceControl_CommandError;
- public static String TraceControl_UnexpectedCommnadOutputFormat;
- public static String TraceControl_UnexpectedNameError;
- public static String TraceControl_UnexpectedPathError;
-
- // Commands
- public static String TraceControl_RetrieveNodeConfigurationJob;
- public static String TraceControl_ListSessionFailure;
- public static String TraceControl_EclipseCommandFailure;
- public static String TraceControl_NewNodeCreationFailure;
- public static String TraceControl_CreateSessionJob;
-
- public static String TraceControl_DestroySessionJob;
- public static String TraceControl_DestroyConfirmationTitle;
- public static String TraceControl_DestroyConfirmationMessage;
-
- public static String TraceControl_StartSessionJob;
- public static String TraceControl_StopSessionJob;
-
- public static String TraceControl_ChangeChannelStateJob;
- public static String TraceControl_ChangeEventStateJob;
-
- public static String TraceControl_EnableEventsJob;
- public static String TraceControl_EnableEventsFailure;
- public static String TraceControl_DisableEventsJob;
-
- // Dialogs
- public static String TraceControl_NewDialogTitle;
- public static String TraceControl_NewNodeExistingConnectionGroupName;
- public static String TraceControl_NewNodeEditButtonName;
- public static String TraceControl_NewNodeComboToolTip;
- public static String TraceControl_NewNodeConnectionNameLabel;
- public static String TraceControl_NewNodeConnectionNameTooltip;
- public static String TraceControl_NewNodeHostNameLabel;
- public static String TraceControl_NewNodeHostNameTooltip;
- public static String TraceControl_AlreadyExistsError;
-
- public static String TraceControl_CreateSessionDialogTitle;
- public static String TraceControl_CreateSessionNameLabel;
- public static String TraceControl_CreateSessionNameTooltip;
- public static String TraceControl_CreateSessionPathLabel;
- public static String TraceControl_CreateSessionPathTooltip;
- public static String TraceControl_InvalidSessionNameError;
- public static String TraceControl_SessionAlreadyExistsError;
- public static String TraceControl_SessionPathAlreadyExistsError;
- public static String TraceControl_InvalidSessionPathError;
- public static String TraceControl_FileSubSystemError;
-
- public static String TraceControl_EnableChannelDialogTitle;
- public static String TraceControl_EnableChannelNameLabel;
- public static String TraceControl_EnableChannelNameTooltip;
- public static String TraceControl_EnableChannelSubBufferSizeTooltip;
- public static String TraceControl_EnableChannelNbSubBuffersTooltip;
- public static String TraceControl_EnableChannelSwitchTimerTooltip;
- public static String TraceControl_EnableChannelReadTimerTooltip;
- public static String TraceControl_EnableChannelOutputTypeTooltip;
- public static String TraceControl_EnableChannelOverwriteModeTooltip;
-
- public static String TraceControl_InvalidChannelNameError;
- public static String TraceControl_ChannelAlreadyExistsError;
-
- public static String TraceControl_EnableEventsDialogTitle;
- public static String TraceControl_EnableEventsSessionGroupName;
- public static String TraceControl_EnableEventsChannelGroupName;
- public static String TraceControl_EnableEventsSessionsTooltip;
- public static String TraceControl_EnableEventsChannelsTooltip;
- public static String TraceControl_EnableEventsNoSessionError;
- public static String TraceControl_EnableEventsNoChannelError;
-
- public static String TraceControl_EnableGroupSelectionName;
- public static String TraceControl_EnableEventsTracepointGroupName;
- public static String TraceControl_EnableEventsTracepointTreeTooltip;
- public static String TraceControl_EnableEventsTracepointTreeAllLabel;
- public static String TraceControl_EnableEventsSyscallName;
- public static String TraceControl_EnableEventsSyscallTooltip;
- public static String TraceControl_EnableEventsProbeGroupName;
- public static String TraceControl_EnableEventsEventNameLabel;
- public static String TraceControl_EnableEventsProbeEventNameTooltip;
- public static String TraceControl_EnableEventsProbeNameLabel;
- public static String TraceControl_EnableEventsProbeNameTooltip;
- public static String TraceControl_EnableEventsFucntionGroupName;
- public static String TraceControl_EnableEventsFunctionEventNameTooltip;
- public static String TraceControl_EnableEventsFunctionNameLabel;
-
- public static String TraceControl_EnableEventsWildcardGroupName;
- public static String TraceControl_EnableEventsWildcardLabel;
- public static String TraceControl_EnableEventsWildcardTooltip;
- public static String TraceControl_EnableEventsLogLevelGroupName;
- public static String TraceControl_EnableEventsLogLevelTypeName;
- public static String TraceControl_EnableEventsLogLevelTypeTooltip;
- public static String TraceControl_EnableEventsLogLevelOnlyTypeName;
- public static String TraceControl_EnableEventsLogLevelOnlyTypeTooltip;
- public static String TraceControl_EnableEventsLogLevelTooltip;
- public static String TraceControl_EnableEventsLoglevelEventNameTooltip;
-
- public static String TraceControl_InvalidProbeNameError;
- public static String TraceControl_InvalidWildcardError;
- public static String TraceControl_InvalidLogLevelEventNameError;
-
-
- // Tree structure strings
- public static String TraceControl_KernelDomainDisplayName;
- public static String TraceControl_UstDisplayName;
- public static String TraceControl_UstGlobalDomainDisplayName;
- public static String TraceControl_AllSessionsDisplayName;
- public static String TraceControl_SessionDisplayName;
- public static String TraceControl_DomainDisplayName;
- public static String TraceControl_ChannelDisplayName;
- public static String TraceControl_EventDisplayName;
- public static String TraceControl_ProviderDisplayName;
- public static String TraceControl_KernelProviderDisplayName;
-
- // Property names
- public static String TraceControl_SessionNamePropertyName;
- public static String TraceControl_EventNamePropertyName;
- public static String TraceControl_EventTypePropertyName;
- public static String TraceControl_LogLevelPropertyName;
- public static String TraceControl_StatePropertyName;
- public static String TraceControl_DomainNamePropertyName;
- public static String TraceControl_ChannelNamePropertyName;
- public static String TraceControl_OverwriteModePropertyName;
- public static String TraceControl_SubBufferSizePropertyName;
- public static String TraceControl_NbSubBuffersPropertyName;
- public static String TraceControl_SwitchTimerPropertyName;
- public static String TraceControl_ReadTimerPropertyName;
- public static String TraceControl_OutputTypePropertyName;
- public static String TraceControl_HostNamePropertyName;
- public static String TraceControl_HostAddressPropertyName;
- public static String TraceControl_SessionPathPropertyName;
- public static String TraceControl_ProviderNamePropertyName;
- public static String TraceControl_ProcessIdPropertyName;
- public static String TraceControl_ProbeAddressPropertyName;
- public static String TraceControl_ProbeOffsetPropertyName;
- public static String TraceControl_ProbeSymbolPropertyName;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-
-/**
- * <b><u>TraceControlContentProvider</u></b>
- * <p>
- * Tree content provider implementation for trace control view.
- * </p>
- */
-public class TraceControlContentProvider implements ITreeContentProvider {
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- @Override
- public void dispose() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
- */
- @Override
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- @Override
- public Object[] getChildren(Object parentElement) {
-
- if (parentElement instanceof ITraceControlComponent) {
- return ((ITraceControlComponent)parentElement).getChildren();
- }
- return new Object[0];
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- @Override
- public Object getParent(Object element) {
- if (element instanceof ITraceControlComponent) {
- return ((ITraceControlComponent)element).getParent();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- @Override
- public boolean hasChildren(Object element) {
- if (element instanceof ITraceControlComponent) {
- return ((ITraceControlComponent)element).hasChildren();
- }
- return false;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control;
-
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * <b><u>TraceControlLabelProvider</u></b>
- * <p>
- * Label provider for trace control tree viewer.
- * </p>
- */
-public class TraceControlLabelProvider extends ColumnLabelProvider {
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- @Override
- public Image getImage(Object element) {
- if ((element != null) && (element instanceof ITraceControlComponent)) {
- return ((ITraceControlComponent) element).getImage();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- @Override
- public String getText(Object element) {
- if ((element != null) && (element instanceof ITraceControlComponent)) {
- return ((ITraceControlComponent) element).getName();
- }
- return "";//$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
- */
- @Override
- public String getToolTipText(Object element) {
- if ((element != null) && (element instanceof ITraceControlComponent)) {
- return ((ITraceControlComponent) element).getToolTip();
- }
- return null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * <b><u>ConfirmDialog</u></b>
- * <p>
- * Confirmation dialog implementation.
- * </p>
- */
-
-public class ConfirmDialog implements IConfirmDialog {
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IConfirmDialog#openConfirm(org.eclipse.swt.widgets.Shell, java.lang.String, java.lang.String)
- */
- @Override
- public boolean openConfirm(Shell parent, String title, String message) {
- return MessageDialog.openConfirm(parent,
- Messages.TraceControl_DestroyConfirmationTitle,
- Messages.TraceControl_DestroyConfirmationMessage);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.ChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * <b><u>CreateChannelDialog</u></b>
- * <p>
- * Dialog box for collecting channel creation information.
- * </p>
- */
-public class CreateChannelDialog extends Dialog implements ICreateChannelOnSessionDialog {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The icon file for this dialog box.
- */
- public static final String ENABLE_CHANNEL_ICON_FILE = "icons/elcl16/edit.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The dialog composite.
- */
- private Composite fDialogComposite = null;
- /**
- * The text widget for the channel name
- */
- private Text fChannelNameText = null;
- /**
- * The overwrite mode of the channel.
- */
- private Button fOverwriteModeButton;
- /**
- * The sub-buffer size of the channel.
- */
- private Text fSubBufferSizeText;
- /**
- * The number of sub-buffers of the channel.
- */
- private Text fNumberOfSubBuffersText;
- /**
- * The switch timer interval of the channel.
- */
- private Text fSwitchTimerText;
- /**
- * The read timer interval of the channel.
- */
- private Text fReadTimerText;
- /**
- * Group composite for domain selection.
- */
- private Group fDomainGroup = null;
- /**
- * Radio button for selecting kernel domain.
- */
- private Button fKernelButton;
- /**
- * Radio button for selecting UST domain.
- */
- private Button fUstButton;
- /**
- * The parent domain component where the channel node should be added.
- * Null in case of creation on session level.
- */
- private TraceDomainComponent fDomain;
- /**
- * Common verify listener for numeric text input.
- */
- private VerifyListener fVerifyListener;
- /**
- * Output channel information.
- */
- private IChannelInfo fChannelInfo;
- /**
- * Output domain information. True in case of Kernel domain. False for UST.
- */
- private boolean fIsKernel;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- * @param shell - a shell for the display of the dialog
- */
- public CreateChannelDialog(Shell shell) {
- super(shell);
- fIsKernel = true;
-
- // Common verify listener
- fVerifyListener = new VerifyListener() {
- @Override
- public void verifyText(VerifyEvent e) {
- // only numbers are allowed.
- e.doit = e.text.matches("[0-9]*"); //$NON-NLS-1$
- }
- };
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateChannelDialog#getChannelInfo()
- */
- @Override
- public IChannelInfo getChannelInfo() {
- return fChannelInfo;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateChannelDialog#setDomainComponent(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent)
- */
- @Override
- public void setDomainComponent(TraceDomainComponent domain) {
- fDomain = domain;
- if (fDomain != null) {
- fIsKernel = fDomain.isKernel();
- } else {
- fIsKernel = true;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateChannelOnSessionDialog#isKernel()
- */
- @Override
- public boolean isKernel() {
- return fIsKernel;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(Messages.TraceControl_EnableChannelDialogTitle);
- newShell.setImage(Activator.getDefault().loadIcon(ENABLE_CHANNEL_ICON_FILE));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
-
- // Main dialog panel
- fDialogComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(2, true);
- fDialogComposite.setLayout(layout);
-
- Label channelNameLabel = new Label(fDialogComposite, SWT.RIGHT);
- channelNameLabel.setText(Messages.TraceControl_EnableChannelNameLabel);
- fChannelNameText = new Text(fDialogComposite, SWT.NONE);
- fChannelNameText.setToolTipText(Messages.TraceControl_EnableChannelNameTooltip);
-
- Label subBufferSizeLabel = new Label(fDialogComposite, SWT.RIGHT);
- subBufferSizeLabel.setText(Messages.TraceControl_SubBufferSizePropertyName);
- fSubBufferSizeText = new Text(fDialogComposite, SWT.NONE);
- fSubBufferSizeText.setToolTipText(Messages.TraceControl_EnableChannelSubBufferSizeTooltip);
- fSubBufferSizeText.addVerifyListener(fVerifyListener);
-
- Label numSubBufferLabel = new Label(fDialogComposite, SWT.RIGHT);
- numSubBufferLabel.setText(Messages.TraceControl_NbSubBuffersPropertyName);
- fNumberOfSubBuffersText = new Text(fDialogComposite, SWT.NONE);
- fNumberOfSubBuffersText.setToolTipText(Messages.TraceControl_EnableChannelNbSubBuffersTooltip);
- fNumberOfSubBuffersText.addVerifyListener(fVerifyListener);
-
- Label switchTimerLabel = new Label(fDialogComposite, SWT.RIGHT);
- switchTimerLabel.setText(Messages.TraceControl_SwitchTimerPropertyName);
- fSwitchTimerText = new Text(fDialogComposite, SWT.NONE);
- fSwitchTimerText.setToolTipText(Messages.TraceControl_EnableChannelSwitchTimerTooltip);
- fSwitchTimerText.addVerifyListener(fVerifyListener);
-
- Label readTimerLabel = new Label(fDialogComposite, SWT.RIGHT);
- readTimerLabel.setText(Messages.TraceControl_ReadTimerPropertyName);
- fReadTimerText = new Text(fDialogComposite, SWT.NONE);
- fReadTimerText.setToolTipText(Messages.TraceControl_EnableChannelReadTimerTooltip);
- fReadTimerText.addVerifyListener(fVerifyListener);
-
- fOverwriteModeButton = new Button(fDialogComposite, SWT.CHECK);
- fOverwriteModeButton.setText(Messages.TraceControl_OverwriteModePropertyName);
- fOverwriteModeButton.setToolTipText(Messages.TraceControl_EnableChannelOverwriteModeTooltip);
- new Label(fDialogComposite, SWT.RIGHT);
-
- fDomainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
- fDomainGroup.setText(Messages.TraceControl_DomainDisplayName);
- layout = new GridLayout(2, true);
- fDomainGroup.setLayout(layout);
-
- fKernelButton = new Button(fDomainGroup, SWT.RADIO);
- fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName);
- fKernelButton.setSelection(fIsKernel);
- fUstButton = new Button(fDomainGroup, SWT.RADIO);
- fUstButton.setText(Messages.TraceControl_UstDisplayName);
- fUstButton.setSelection(!fIsKernel);
-
- if (fDomain != null) {
- fKernelButton.setEnabled(false);
- fUstButton.setEnabled(false);
- }
-
- // layout widgets
- GridData data = new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1);
- fDomainGroup.setLayoutData(data);
-
- data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
- fKernelButton.setLayoutData(data);
- data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
- fUstButton.setLayoutData(data);
-
- data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- fSubBufferSizeText.setText("666.666.666.666"); //$NON-NLS-1$
- Point minSize = fSubBufferSizeText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- data.widthHint = minSize.x + 5;
-
- fChannelNameText.setLayoutData(data);
- fSubBufferSizeText.setLayoutData(data);
- fNumberOfSubBuffersText.setLayoutData(data);
- fSwitchTimerText.setLayoutData(data);
- fReadTimerText.setLayoutData(data);
-
- fSubBufferSizeText.setText(""); //$NON-NLS-1$
-
- setDefaults();
-
- return fDialogComposite;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.DETAILS_ID, "Default", true); //$NON-NLS-1$
- createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- @Override
- protected void okPressed() {
- // Set channel information
- fChannelInfo = new ChannelInfo(fChannelNameText.getText());
- fChannelInfo.setSubBufferSize(Long.parseLong(fSubBufferSizeText.getText()));
- fChannelInfo.setNumberOfSubBuffers(Integer.parseInt(fNumberOfSubBuffersText.getText()));
- fChannelInfo.setSwitchTimer(Long.parseLong(fSwitchTimerText.getText()));
- fChannelInfo.setReadTimer(Long.parseLong(fReadTimerText.getText()));
- fChannelInfo.setOverwriteMode(fOverwriteModeButton.getSelection());
-
- if (fKernelButton.getSelection() == true) {
- fIsKernel = true;
- } else {
- fIsKernel = false;
- }
-
- // Check for invalid names
- if (!fChannelInfo.getName().matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableChannelDialogTitle,
- Messages.TraceControl_InvalidChannelNameError + " (" + fChannelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- // Check for duplicate names
- if (fDomain != null && fDomain.containsChild(fChannelInfo.getName())) {
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableChannelDialogTitle,
- Messages.TraceControl_ChannelAlreadyExistsError + " (" + fChannelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- // validation successful -> call super.okPressed()
- super.okPressed();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
- */
- @Override
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.DETAILS_ID) {
- setDefaults();
- return;
- }
- super.buttonPressed(buttonId);
- }
-
- // ------------------------------------------------------------------------
- // Helper methods
- // ------------------------------------------------------------------------
- /**
- * Sets default value depending on Kernel or UST
- */
- private void setDefaults() {
- fSwitchTimerText.setText(String.valueOf(IChannelInfo.DEFAULT_SWITCH_TIMER));
- fReadTimerText.setText(String.valueOf(IChannelInfo.DEFAULT_READ_TIMER));
- fOverwriteModeButton.setSelection(IChannelInfo.DEFAULT_OVERWRITE_MODE);
- if (fKernelButton.getSelection()) {
- fSubBufferSizeText.setText(String.valueOf(IChannelInfo.DEFAULT_SUB_BUFFER_SIZE_KERNEL));
- fNumberOfSubBuffersText.setText(String.valueOf(IChannelInfo.DEFAULT_NUMBER_OF_SUB_BUFFERS_KERNEL));
- } else {
- fSubBufferSizeText.setText(String.valueOf(IChannelInfo.DEFAULT_SUB_BUFFER_SIZE_UST));
- fNumberOfSubBuffersText.setText(String.valueOf(IChannelInfo.DEFAULT_NUMBER_OF_SUB_BUFFERS_UST));
- }
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionGroup;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.remote.IRemoteSystemProxy;
-import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
-import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
-import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * <b><u>CreateSessionDialog</u></b>
- * <p>
- * Dialog box for collecting session creation information.
- * </p>
- */
-public class CreateSessionDialog extends Dialog implements ICreateSessionDialog {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The icon file for this dialog box.
- */
- public static final String CREATE_SESSION_ICON_FILE = "icons/elcl16/add_button.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The dialog composite.
- */
- private Composite fDialogComposite = null;
- /**
- * The text widget for the session name
- */
- private Text fSessionNameText = null;
- /**
- * The text widget for the session path
- */
- private Text fSessionPathText = null;
- /**
- * The parent where the new node should be added.
- */
- private TraceSessionGroup fParent;
- /**
- * The session name string.
- */
- private String fSessionName = null;
- /**
- * The session path string.
- */
- private String fSessionPath = null;
- /**
- * Flag whether default location (path) shall be used or not
- */
- private boolean fIsDefaultPath = true;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param shell - a shell for the display of the dialog
- */
- public CreateSessionDialog(Shell shell) {
- super(shell);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateSessionDialog#getSessionName()
- */
- @Override
- public String getSessionName() {
- return fSessionName;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateSessionDialog#getSessionPath()
- */
- @Override
- public String getSessionPath() {
- return fSessionPath;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateSessionDialog#isDefaultSessionPath()
- */
- @Override
- public boolean isDefaultSessionPath() {
- return fIsDefaultPath;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateSessionDialog#setTraceSessionGroup(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionGroup)
- */
- @Override
- public void setTraceSessionGroup(TraceSessionGroup group) {
- fParent = group;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(Messages.TraceControl_CreateSessionDialogTitle);
- newShell.setImage(Activator.getDefault().loadIcon(CREATE_SESSION_ICON_FILE));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
-
- // Main dialog panel
- fDialogComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(2, true);
- fDialogComposite.setLayout(layout);
-
- Label sessionNameLabel = new Label(fDialogComposite, SWT.RIGHT);
- sessionNameLabel.setText(Messages.TraceControl_CreateSessionNameLabel);
- fSessionNameText = new Text(fDialogComposite, SWT.NONE);
- fSessionNameText.setToolTipText(Messages.TraceControl_CreateSessionNameTooltip);
-
- Label sessionPath = new Label(fDialogComposite, SWT.RIGHT);
- sessionPath.setText(Messages.TraceControl_CreateSessionPathLabel);
- fSessionPathText = new Text(fDialogComposite, SWT.NONE);
- fSessionPathText.setToolTipText(Messages.TraceControl_CreateSessionPathTooltip);
-
- // layout widgets
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- fSessionPathText.setText("666.666.666.666"); //$NON-NLS-1$
- Point minSize = fSessionPathText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- data.widthHint = minSize.x + 5;
-
- fSessionNameText.setLayoutData(data);
- fSessionPathText.setLayoutData(data);
-
- fSessionPathText.setText(""); //$NON-NLS-1$
-
- return fDialogComposite;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- @Override
- protected void okPressed() {
- // Validate input data
- fSessionName = fSessionNameText.getText();
- fSessionPath = fSessionPathText.getText();
-
- if (!"".equals(fSessionPath)) { //$NON-NLS-1$
- // validate sessionPath
-
- TargetNodeComponent node = (TargetNodeComponent)fParent.getParent();
- IRemoteSystemProxy proxy = node.getRemoteSystemProxy();
- IFileServiceSubSystem fsss = proxy.getFileServiceSubSystem();
- if (fsss != null) {
- try {
- IRemoteFile remoteFolder = fsss.getRemoteFileObject(fSessionPath, new NullProgressMonitor());
- if (remoteFolder.exists()) {
- MessageDialog.openError(getShell(),
- Messages.TraceControl_CreateSessionDialogTitle,
- Messages.TraceControl_SessionPathAlreadyExistsError + " (" + fSessionPath + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
- } catch (SystemMessageException e) {
- MessageDialog.openError(getShell(),
- Messages.TraceControl_CreateSessionDialogTitle,
- Messages.TraceControl_FileSubSystemError + "\n" + e); //$NON-NLS-1$
- return;
- }
- }
- fIsDefaultPath = false;
- }
-
- // If no session name is specified use default name auto
- if ("".equals(fSessionName)) { //$NON-NLS-1$
- fSessionName = "auto"; //$NON-NLS-1$
- }
-
- // Check for invalid names
- if (!fSessionName.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$
- MessageDialog.openError(getShell(),
- Messages.TraceControl_CreateSessionDialogTitle,
- Messages.TraceControl_InvalidSessionNameError + " (" + fSessionName + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- // Check if node with name already exists in parent
- if(fParent.containsChild(fSessionName)) {
- MessageDialog.openError(getShell(),
- Messages.TraceControl_CreateSessionDialogTitle,
- Messages.TraceControl_SessionAlreadyExistsError + " (" + fSessionName + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- // validation successful -> call super.okPressed()
- super.okPressed();
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import java.util.List;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceProviderGroup;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * <b><u>EnableEventsDialog</u></b>
- * <p>
- * Dialog box for collecting information events to be enabled.
- * </p>
- */
-public class EnableEventsDialog extends Dialog implements IEnableEventsDialog {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- /**
- * The icon file for this dialog box.
- */
- public static final String ENABLE_EVENT_ICON_FILE = "icons/elcl16/edit.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The dialog composite.
- */
- private Composite fDialogComposite;
- /**
- * The composite with widgets for collecting information about kernel events.
- */
- private EnableKernelEventComposite fKernelComposite;
- /**
- * The composite with widgets for collecting information about UST events.
- */
- private EnableUstEventsComposite fUstComposite;
- /**
- * Radio button for selecting kernel domain.
- */
- private Button fKernelButton;
- /**
- * Radio button for selecting UST domain.
- */
- private Button fUstButton;
- /**
- * The referenced trace provider group containing the kernel provider and UST
- * provider component which contains a list of available tracepoints.
- */
- private TraceProviderGroup fProviderGroup;
- /**
- * The parent domain component where the channel node should be added.
- * Null in case the domain is not known (i.e. on session level).
- */
- private TraceDomainComponent fDomain;
- /**
- * Output domain information. True in case of Kernel domain. False for UST.
- */
- private boolean fIsKernel;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param shell - a shell for the display of the dialog
- * @param providerGroup - the trace provider group
- */
- public EnableEventsDialog(Shell shell) {
- super(shell);
- setShellStyle(SWT.RESIZE);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isTracpoints()
- */
- @Override
- public boolean isTracepoints() {
- if (fIsKernel) {
- return fKernelComposite.isTracepoints();
- }
- return fUstComposite.isTracepoints();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isAllTracePoints()
- */
- @Override
- public boolean isAllTracePoints() {
- if (fIsKernel) {
- return fKernelComposite.isAllTracePoints();
- }
- return fUstComposite.isAllTracePoints();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isSysCalls()
- */
- @Override
- public boolean isSysCalls() {
- if (fIsKernel) {
- return fKernelComposite.isSysCalls();
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isAllSysCalls()
- */
- @Override
- public boolean isAllSysCalls() {
- if (fIsKernel) {
- return fKernelComposite.isSysCalls();
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#getEventNames()
- */
- @Override
- public List<String> getEventNames() {
- if (fIsKernel) {
- return fKernelComposite.getEventNames();
- }
- return fUstComposite.getEventNames();
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isDynamicProbe()
- */
- @Override
- public boolean isDynamicProbe() {
- if (fIsKernel) {
- return fKernelComposite.isDynamicProbe();
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#getProbeName()
- */
- @Override
- public String getProbeName() {
- if (fIsKernel) {
- return fKernelComposite.getProbeName();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#getProbeEventName()
- */
- @Override
- public String getProbeEventName() {
- if (fIsKernel) {
- return fKernelComposite.getProbeEventName();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isDynamicFunctionProbe()
- */
- @Override
- public boolean isDynamicFunctionProbe() {
- if (fIsKernel) {
- return fKernelComposite.isDynamicFunctionProbe();
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#getFunctionEventName()
- */
- @Override
- public String getFunctionEventName() {
- if (fIsKernel) {
- return fKernelComposite.getFunctionEventName();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#getFunction()
- */
- @Override
- public String getFunction() {
- if (fIsKernel) {
- return fKernelComposite.getFunction();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#isWildcard()
- */
- @Override
- public boolean isWildcard() {
- if (!fIsKernel) {
- return fUstComposite.isWildcard();
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#getWildcard()
- */
- @Override
- public String getWildcard() {
- if (!fIsKernel) {
- return fUstComposite.getWildcard();
- }
- return null;
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#isLogLevel()
- */
- @Override
- public boolean isLogLevel() {
- if (!fIsKernel) {
- return fUstComposite.isLogLevel();
- }
- return false;
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#getLogLevelType()
- */
- @Override
- public LogLevelType getLogLevelType() {
- if (!fIsKernel) {
- return fUstComposite.getLogLevelType();
- }
- return null;
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#getLogLevel()
- */
- @Override
- public TraceLogLevel getLogLevel() {
- if (!fIsKernel) {
- return fUstComposite.getLogLevel();
- }
- return null;
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#getLogLevelEventName()
- */
- @Override
- public String getLogLevelEventName() {
- if (!fIsKernel) {
- return fUstComposite.getLogLevelEventName();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableEventsDialog#isKernel()
- */
- @Override
- public boolean isKernel() {
- return fIsKernel;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableEventsDialog#setTraceProviderGroup(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceProviderGroup)
- */
- @Override
- public void setTraceProviderGroup(TraceProviderGroup providerGroup) {
- fProviderGroup = providerGroup;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableEventsDialog#setTraceDomainComponent(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent)
- */
- @Override
- public void setTraceDomainComponent(TraceDomainComponent domain) {
- fDomain = domain;
- if (fDomain != null) {
- fIsKernel = fDomain.isKernel();
- } else {
- fIsKernel = true;
- }
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(Messages.TraceControl_EnableEventsDialogTitle);
- newShell.setImage(Activator.getDefault().loadIcon(ENABLE_EVENT_ICON_FILE));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
-
- // Main dialog panel
- fDialogComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(1, true);
- fDialogComposite.setLayout(layout);
- fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // ------------------------------------------------------------------------
- // Domain Group
- // ------------------------------------------------------------------------
- Group domainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
- domainGroup.setText(Messages.TraceControl_DomainDisplayName);
- layout = new GridLayout(2, true);
- domainGroup.setLayout(layout);
-
- fKernelButton = new Button(domainGroup, SWT.RADIO);
- fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName);
- fKernelButton.setSelection(fIsKernel);
- fUstButton = new Button(domainGroup, SWT.RADIO);
- fUstButton.setText(Messages.TraceControl_UstDisplayName);
- fUstButton.setSelection(!fIsKernel);
-
- if (fDomain != null) {
- fKernelButton.setEnabled(false);
- fUstButton.setEnabled(false);
- }
-
- // layout widgets
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- domainGroup.setLayoutData(data);
-
- data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
- fKernelButton.setLayoutData(data);
- data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
- fUstButton.setLayoutData(data);
-
- // ------------------------------------------------------------------------
- // Kernel or UST event data group
- // ------------------------------------------------------------------------
- fUstComposite = null;
- fKernelComposite = null;
- if (fIsKernel) {
- createKernelComposite();
- fUstComposite = null;
- } else {
- createUstComposite();
- }
-
- fKernelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (fKernelButton.getSelection()) {
- disposeUstComposite();
- createKernelComposite();
- fDialogComposite.layout();
- }
- }
- });
-
- fUstButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (fUstButton.getSelection()) {
- disposeKernelComposite();
- createUstComposite();
- fDialogComposite.layout();
- }
- }
- });
-
- fDialogComposite.layout();
-
- getShell().setMinimumSize(new Point(500, 650));
-
- return fDialogComposite;
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- @Override
- protected void okPressed() {
- if (fKernelButton.getSelection() == true) {
- fIsKernel = true;
- } else {
- fIsKernel = false;
- }
-
- // Validate kernel composite in case of kernel domain
- if (fKernelComposite != null && !fKernelComposite.isValid()) {
- return;
- }
-
- // Validate UST composite in case of UST domain
- if (fUstComposite != null && !fUstComposite.isValid()) {
- return;
- }
-
- // validation successful -> call super.okPressed()
- super.okPressed();
- }
-
- // ------------------------------------------------------------------------
- // Helper methods
- // ------------------------------------------------------------------------
- /**
- * Creates the kernel composite (if not existing)
- */
- private void createKernelComposite() {
- if (fKernelComposite == null) {
- fKernelComposite = new EnableKernelEventComposite(fDialogComposite, SWT.NONE, fProviderGroup);
- GridLayout layout = new GridLayout(1, true);
- fKernelComposite.setLayout(layout);
- fKernelComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fKernelComposite.createContent();
- }
- }
-
- /**
- * Disposes the kernel composite (if existing)
- */
- private void disposeKernelComposite() {
- if (fKernelComposite != null) {
- fKernelComposite.dispose();
- fKernelComposite = null;
- }
- }
-
- /**
- * Creates the UST composite (if not existing)
- */
- private void createUstComposite() {
- if (fUstComposite == null) {
- fUstComposite = new EnableUstEventsComposite(fDialogComposite, SWT.NONE, fProviderGroup);
- GridLayout layout = new GridLayout(1, true);
- fUstComposite.setLayout(layout);
- fUstComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fUstComposite.createContent();
- }
- }
-
- /**
- * Disposes the UST composite (if existing)
- */
- private void disposeUstComposite() {
- if (fUstComposite != null) {
- fUstComposite.dispose();
- fUstComposite = null;
- }
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.TraceControlContentProvider;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.TraceControlLabelProvider;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.KernelProviderComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceProviderGroup;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * <b><u>EnableKernelEventsComposite</u></b>
- * <p>
- * A composite for collecting information about kernel events to be enabled.
- * </p>
- */
-public class EnableKernelEventComposite extends Composite implements IEnableKernelEvents {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- private enum KernelGroupEnum { TRACEPOINTS, SYSCALLS, PROBE, FUNCTION };
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /**
- * A button to enable/disable the tracepoints group
- */
- private Button fTracepointsActivateButton;
- /**
- * A tree viewer for displaying and selection of available tracepoints.
- */
- private CheckboxTreeViewer fTracepointsViewer;
- /**
- * A button to enable/disable the syscalls group
- */
- private Button fSysCallsActivateButton;
- /**
- * A button to enable or disable the dynamic probe group.
- */
- private Button fProbeActivateButton;
- /**
- * The text field for the event name for the dynamic probe.
- */
- private Text fProbeEventNameText;
- /**
- * The text field for the dynamic probe.
- */
- private Text fProbeText;
- /**
- * A button to enable or disable the dynamic function probe group.
- */
- private Button fFunctionActivateButton;
- /**
- * The text field for the event name for the dynamic probe.
- */
- private Text fFunctionEventNameText;
- /**
- * The text field for the dynamic function entry/return probe.
- */
- private Text fFunctionText;
- /**
- * The referenced trace provider group containing the kernel provider
- * component which contains a list of available tracepoints.
- */
- private TraceProviderGroup fProviderGroup;
- /**
- * The flag indicating that tracepoints are selected.
- */
- private boolean fIsTracepoints;
- /**
- * The flag indicating that all tracepoints are selected.
- */
- private boolean fIsAllTracepoints;
- /**
- * The flag indicating that syscalls are selected.
- */
- private boolean fIsSysCalls;
- /**
- * The list of tracepoints to be enabled.
- */
- private List<String> fSelectedEvents;
- /**
- * The flag indicating that dynamic probe is selected.
- */
- private boolean fIsDynamicProbe;
- /**
- * The event name of the dynamic probe.
- */
- private String fProbeEventName;
- /**
- * The dynamic probe.
- */
- private String fProbeString;
- /**
- * The flag indicating that the dynamic function probe is selected.
- */
- private boolean fIsDynamicFunctionProbe;
- /**
- * The event name of the dynamic function entry/return probe.
- */
- private String fFunctionEventName;
- /**
- * The dynamic function entry/return probe.
- */
- private String fFunctionString;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- public EnableKernelEventComposite(Composite parent, int style, TraceProviderGroup providerGroup) {
- super(parent, style);
- fProviderGroup = providerGroup;
- }
-
- // ------------------------------------------------------------------------
- // Acessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isTracpoints()
- */
- @Override
- public boolean isTracepoints() {
- return fIsTracepoints;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isAllTracePoints()
- */
- @Override
- public boolean isAllTracePoints() {
- return fIsAllTracepoints;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isSysCalls()
- */
- @Override
- public boolean isSysCalls() {
- return fIsSysCalls;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isAllSysCalls()
- */
- @Override
- public boolean isAllSysCalls() {
- return fIsSysCalls;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#getEventNames()
- */
- @Override
- public List<String> getEventNames() {
- return new ArrayList<String>(fSelectedEvents);
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isDynamicProbe()
- */
- @Override
- public boolean isDynamicProbe() {
- return fIsDynamicProbe;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#getProbeName()
- */
- @Override
- public String getProbeName() {
- return fProbeString;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#getProbeEventName()
- */
- @Override
- public String getProbeEventName() {
- return fProbeEventName;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#isDynamicFunctionProbe()
- */
- @Override
- public boolean isDynamicFunctionProbe() {
- return fIsDynamicFunctionProbe;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#getFunctionEventName()
- */
- @Override
- public String getFunctionEventName() {
- return fFunctionEventName;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableKernelEvents#getFunction()
- */
- @Override
- public String getFunction() {
- return fFunctionString;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Creates the composite content
- */
- public void createContent() {
-
- // Tracepoints Group
- createTracepointsGroup();
-
- // Syscalls Group
- createSysCallsGroup();
-
- // Dynamic Probe Group
- createDynamicProbeGroup();
-
- // Dynamic Function Probe Group
- createDynamicFunctionPropeGroup();
-
- // Set default enablements
- setKernelEnablements(KernelGroupEnum.TRACEPOINTS);
- }
-
- /**
- * Validates the kernel composite input data.
- * @return true if configured data is valid and can be retrieved.
- */
- public boolean isValid() {
- fIsTracepoints = fTracepointsActivateButton.getSelection();
- fIsSysCalls = fSysCallsActivateButton.getSelection();
- fIsDynamicProbe = fProbeActivateButton.getSelection();
- fIsDynamicFunctionProbe = fFunctionActivateButton.getSelection();
-
- List<ITraceControlComponent> comps = fProviderGroup.getChildren(KernelProviderComponent.class);
- fIsAllTracepoints = fTracepointsViewer.getChecked(comps.get(0));
-
- Object[] checkedElements = fTracepointsViewer.getCheckedElements();
- fSelectedEvents = new ArrayList<String>();
- for (int i = 0; i < checkedElements.length; i++) {
- ITraceControlComponent component = (ITraceControlComponent)checkedElements[i];
- if (component instanceof BaseEventComponent) {
- fSelectedEvents.add(component.getName());
- }
- }
-
- // initialize probe string
- fProbeEventName = null;
- fProbeString = null;
- String temp = fProbeEventNameText.getText();
- if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableEventsDialogTitle,
- Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- return false;
- }
-
- if(!fProbeText.getText().matches("\\s*")) { //$NON-NLS-1$
- fProbeEventName = temp;
- // fProbeString will be validated by lttng-tools
- fProbeString = fProbeText.getText();
- }
-
- // initialize function string
- fFunctionEventName = null;
- fFunctionString = null;
-
- temp = fFunctionEventNameText.getText();
- if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableEventsDialogTitle,
- Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- return false;
- }
-
- if(!fFunctionText.getText().matches("\\s*")) { //$NON-NLS-1$
- fFunctionEventName = temp;
- // fFunctionString will be validated by lttng-tools
- fFunctionString = fFunctionText.getText();
- }
-
- return true;
- }
-
- /**
- * Creates tracepoints group.
- */
- private void createTracepointsGroup() {
-
- GridLayout layout;
- GridData data;
- Group tpMainGroup = new Group(this, SWT.SHADOW_NONE);
- tpMainGroup.setText(Messages.TraceControl_EnableEventsTracepointGroupName);
- layout = new GridLayout(2, false);
- tpMainGroup.setLayout(layout);
- data = new GridData(GridData.FILL_BOTH);
- tpMainGroup.setLayoutData(data);
-
- Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE);
- layout = new GridLayout(1, true);
- buttonComposite.setLayout(layout);
- data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
- buttonComposite.setLayoutData(data);
-
- fTracepointsActivateButton = new Button(buttonComposite, SWT.RADIO);
- fTracepointsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fTracepointsActivateButton.setLayoutData(data);
- fTracepointsActivateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setKernelEnablements(KernelGroupEnum.TRACEPOINTS);
- }
- });
-
- Group tracepointsGroup = new Group(tpMainGroup, SWT.SHADOW_NONE);
- layout = new GridLayout(1, true);
- tracepointsGroup.setLayout(layout);
- data = new GridData(GridData.FILL_BOTH);
- tracepointsGroup.setLayoutData(data);
-
- fTracepointsViewer = new CheckboxTreeViewer(tracepointsGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip);
-
- fTracepointsViewer.setContentProvider(new KernelContentProvider());
- fTracepointsViewer.setLabelProvider(new KernelLabelProvider());
- fTracepointsViewer.addCheckStateListener(new KernelCheckListener());
- fTracepointsViewer.setInput(fProviderGroup);
-
- fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
- }
-
- /**
- * Creates syscalls group.
- */
- private void createSysCallsGroup() {
- GridLayout layout;
- GridData data;
- Group sysCallsMainGroup = new Group(this, SWT.SHADOW_NONE);
- sysCallsMainGroup.setText(Messages.TraceControl_EnableEventsSyscallName);
- sysCallsMainGroup.setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip);
- layout = new GridLayout(2, false);
- sysCallsMainGroup.setLayout(layout);
- data = new GridData(GridData.FILL_HORIZONTAL);
- sysCallsMainGroup.setLayoutData(data);
-
- Composite buttonComposite = new Composite(sysCallsMainGroup, SWT.NONE);
- layout = new GridLayout(1, false);
- buttonComposite.setLayout(layout);
- data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
- buttonComposite.setLayoutData(data);
-
- fSysCallsActivateButton = new Button(buttonComposite, SWT.RADIO);
- fSysCallsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
- fSysCallsActivateButton.setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip);
- fSysCallsActivateButton.setSelection(false);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fSysCallsActivateButton.setLayoutData(data);
- fSysCallsActivateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setKernelEnablements(KernelGroupEnum.SYSCALLS);
- }
- });
- }
-
- /**
- * Creates dynamic probe group.
- */
- private void createDynamicProbeGroup() {
- GridLayout layout;
- GridData data;
- Group probeMainGroup = new Group(this, SWT.SHADOW_NONE);
- probeMainGroup.setText(Messages.TraceControl_EnableEventsProbeGroupName);
- layout = new GridLayout(2, false);
- probeMainGroup.setLayout(layout);
- data = new GridData(GridData.FILL_HORIZONTAL);
- probeMainGroup.setLayoutData(data);
-
- Composite buttonComposite = new Composite(probeMainGroup, SWT.NONE);
- layout = new GridLayout(1, false);
- buttonComposite.setLayout(layout);
- data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
- buttonComposite.setLayoutData(data);
-
- fProbeActivateButton = new Button(buttonComposite, SWT.RADIO);
- fProbeActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
- fProbeActivateButton.setSelection(false);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fProbeActivateButton.setLayoutData(data);
- fProbeActivateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setKernelEnablements(KernelGroupEnum.PROBE);
- }
- });
-
- Group probeGroup = new Group(probeMainGroup, SWT.SHADOW_NONE);
- layout = new GridLayout(4, true);
- probeGroup.setLayout(layout);
- probeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label probeNameLabel = new Label(probeGroup, SWT.LEFT);
- probeNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 1;
- probeNameLabel.setLayoutData(data);
-
- fProbeEventNameText = new Text(probeGroup, SWT.LEFT);
- fProbeEventNameText.setToolTipText(Messages.TraceControl_EnableEventsProbeEventNameTooltip);
-
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 3;
- fProbeEventNameText.setLayoutData(data);
-
- Label probeLabel = new Label(probeGroup, SWT.LEFT);
- probeLabel.setText(Messages.TraceControl_EnableEventsProbeNameLabel);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 1;
- probeLabel.setLayoutData(data);
-
- fProbeText = new Text(probeGroup, SWT.LEFT);
- fProbeText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 3;
- fProbeText.setLayoutData(data);
- }
-
- /**
- * Creates dynamic function entry/return probe group.
- */
- private void createDynamicFunctionPropeGroup() {
- GridLayout layout;
- GridData data;
- Group functionMainGroup = new Group(this, SWT.SHADOW_NONE);
- functionMainGroup.setText(Messages.TraceControl_EnableEventsFucntionGroupName);
- layout = new GridLayout(2, false);
- functionMainGroup.setLayout(layout);
- data = new GridData(GridData.FILL_HORIZONTAL);
- functionMainGroup.setLayoutData(data);
-
- Composite buttonComposite = new Composite(functionMainGroup, SWT.NONE);
- layout = new GridLayout(1, false);
- buttonComposite.setLayout(layout);
- data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
- buttonComposite.setLayoutData(data);
-
- fFunctionActivateButton = new Button(buttonComposite, SWT.RADIO);
- fFunctionActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
- fFunctionActivateButton.setSelection(false);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fFunctionActivateButton.setLayoutData(data);
- fFunctionActivateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setKernelEnablements(KernelGroupEnum.FUNCTION);
- }
- });
-
- Group functionGroup = new Group(functionMainGroup, SWT.SHADOW_NONE);
- layout = new GridLayout(4, true);
- functionGroup.setLayout(layout);
- functionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label functionNameLabel = new Label(functionGroup, SWT.LEFT);
- functionNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 1;
- functionNameLabel.setLayoutData(data);
-
- fFunctionEventNameText = new Text(functionGroup, SWT.LEFT);
- fFunctionEventNameText.setToolTipText(Messages.TraceControl_EnableEventsFunctionEventNameTooltip);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 3;
- fFunctionEventNameText.setLayoutData(data);
-
- Label functionLabel = new Label(functionGroup, SWT.LEFT);
- functionLabel.setText(Messages.TraceControl_EnableEventsFunctionNameLabel);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 1;
- functionLabel.setLayoutData(data);
-
- fFunctionText = new Text(functionGroup, SWT.LEFT);
- fFunctionText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 3;
- fFunctionText.setLayoutData(data);
- }
-
- /**
- * Enable/selects widgets depending on the group specified.
- * @param group - group to enable.
- */
- private void setKernelEnablements(KernelGroupEnum group) {
- fTracepointsActivateButton.setSelection(group == KernelGroupEnum.TRACEPOINTS);
- fTracepointsViewer.getTree().setEnabled(group == KernelGroupEnum.TRACEPOINTS);
-
- fSysCallsActivateButton.setSelection(group == KernelGroupEnum.SYSCALLS);
-
- fProbeActivateButton.setSelection(group == KernelGroupEnum.PROBE);
- fProbeEventNameText.setEnabled(group == KernelGroupEnum.PROBE);
- fProbeText.setEnabled(group == KernelGroupEnum.PROBE);
-
- fFunctionActivateButton.setSelection(group == KernelGroupEnum.FUNCTION);
- fFunctionEventNameText.setEnabled(group == KernelGroupEnum.FUNCTION);
- fFunctionText.setEnabled(group == KernelGroupEnum.FUNCTION);
- }
-
- // ------------------------------------------------------------------------
- // Local classes
- // ------------------------------------------------------------------------
- /**
- * Content provider for the tracepoints tree.
- */
- final public class KernelContentProvider extends TraceControlContentProvider {
- @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof TraceProviderGroup) {
- List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(KernelProviderComponent.class);
- return (ITraceControlComponent[]) children.toArray(new ITraceControlComponent[children.size()]);
- }
- if (parentElement instanceof ITraceControlComponent) {
- return ((ITraceControlComponent)parentElement).getChildren();
- }
- return new Object[0];
- }
- }
-
- /**
- * Content label for the tracepoints tree.
- */
- final public class KernelLabelProvider extends TraceControlLabelProvider {
- @Override
- public Image getImage(Object element) {
- return null;
- }
- @Override
- public String getText(Object element) {
- if ((element != null) && (element instanceof KernelProviderComponent)) {
- return Messages.TraceControl_EnableEventsTracepointTreeAllLabel;
- }
- return super.getText(element);
- }
- }
-
- /**
- * Check state listener for the tracepoints tree.
- */
- final public class KernelCheckListener implements ICheckStateListener {
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- if (event.getChecked()) {
- if (event.getElement() instanceof KernelProviderComponent) {
- fTracepointsViewer.setSubtreeChecked(event.getElement(), true);
- }
- } else {
- if (event.getElement() instanceof KernelProviderComponent) {
- fTracepointsViewer.setSubtreeChecked(event.getElement(), false);
- } else {
- ITraceControlComponent component = (ITraceControlComponent) event.getElement();
- fTracepointsViewer.setChecked(component.getParent(), false);
- }
- }
- }
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.TraceControlContentProvider;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.TraceControlLabelProvider;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceProviderGroup;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.UstProviderComponent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * <b><u>EnableUstEventsComposite</u></b>
- * <p>
- * A composite for collecting information about UST events to be enabled.
- * </p>
- */
-public class EnableUstEventsComposite extends Composite implements IEnableUstEvents {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- private enum GroupEnum { TRACEPOINTS, WILDCARD, LOGLEVEL };
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /**
- * A button to enable/disable the tracepoints group
- */
- private Button fTracepointsActivateButton;
- /**
- * A tree viewer for diplaying and selection of available tracepoints.
- */
- private CheckboxTreeViewer fTracepointsViewer;
- /**
- * A button to enable/disable the wildcard group
- */
- private Button fWildcardActivateButton;
- /**
- * A Text field for the event's wildcard.
- */
- private Text fWildcardText;
- /**
- * A button to enable/disable the log level group
- */
- private Button fLogLevelActivateButton;
- /**
- * A Text field for the event name for the log level enablement.
- */
- private Text fLogLevelEventNameText;
- /**
- * A Combo box for selecting the log level.
- */
- private CCombo fLogLevelCombo;
- /**
- * A button for selecting the log level (range 0 to level).
- */
- private Button fLogLevelButton;
- /**
- * A button for selecting the specified log level only.
- */
- private Button fLogLevelOnlyButton;
- /**
- * The referenced trace provider group containing the UST providers
- * component which contains a list of available tracepoints.
- */
- private TraceProviderGroup fProviderGroup;
- /**
- * The flag indicating that tracepoints are selected.
- */
- private boolean fIsTracepoints;
- /**
- * The flag indicating that all tracepoints (across providers) are selected.
- */
- private boolean fIsAllTracepoints;
- /**
- * The list of tracepoints to be enabled.
- */
- private List<String> fSelectedEvents;
- /**
- * The flag indicating that all wildcard are selected..
- */
- private boolean fIsWildcard;
- /**
- * The wildcard if wildcard is selected.
- */
- private String fWildcard;
- /**
- *The flag indicating that all log level are selected.
- */
- private boolean fIsLogLevel;
- /**
- * The event name for the log level enablement.
- */
- private String fLogLevelEventName;
- /**
- * The type of the log level (loglevel or loglevel-only)
- */
- private LogLevelType fLogLevelType;
- /**
- * The actual selected log level.
- */
- private TraceLogLevel fLogLevel;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param parent - a parent composite
- * @Param style - a compsite style
- * @param providerGroup - the trace provider group
- */
- public EnableUstEventsComposite(Composite parent, int style, TraceProviderGroup providerGroup) {
- super(parent, style);
- fProviderGroup = providerGroup;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#isTracepoints()
- */
- @Override
- public boolean isTracepoints() {
- return fIsTracepoints;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#isAllTracePoints()
- */
- @Override
- public boolean isAllTracePoints() {
- return fIsAllTracepoints;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#getEventNames()
- */
- @Override
- public List<String> getEventNames() {
- return new ArrayList<String>(fSelectedEvents);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#isWildcard()
- */
- @Override
- public boolean isWildcard() {
- return fIsWildcard;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#getWildcard()
- */
- @Override
- public String getWildcard() {
- return "\"" + fWildcard + "\""; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#isLogLevel()
- */
- @Override
- public boolean isLogLevel() {
- return fIsLogLevel;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#getLogLevelType()
- */
- @Override
- public LogLevelType getLogLevelType() {
- return fLogLevelType;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#getLogLevel()
- */
- @Override
- public TraceLogLevel getLogLevel() {
- return fLogLevel;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableUstEvents#getLogLevelEventName()
- */
- @Override
- public String getLogLevelEventName() {
- return fLogLevelEventName;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- public void createContent() {
-
- // Tracepoints Group
- createTracepointsGroup();
-
- // Wildcard Group
- createWildCardGroup();
-
- // Log Level Group
- createLogLevelGroup();
-
- // Set default enablements
- setEnablements(GroupEnum.TRACEPOINTS);
- }
-
- /**
- * Validates the kernel composite input data.
- * @return true if configured data is valid and can be retrieved.
- */
- public boolean isValid() {
-
- fIsTracepoints = fTracepointsActivateButton.getSelection();
- fIsWildcard = fWildcardActivateButton.getSelection();
- fIsLogLevel = fLogLevelActivateButton.getSelection();
-
- fIsAllTracepoints = fTracepointsViewer.getChecked(fProviderGroup);
-
- Set<String> set = new HashSet<String>();
- Object[] checkedElements = fTracepointsViewer.getCheckedElements();
- fSelectedEvents = new ArrayList<String>();
- for (int i = 0; i < checkedElements.length; i++) {
- ITraceControlComponent component = (ITraceControlComponent)checkedElements[i];
- if (!set.contains(component.getName()) && (component instanceof BaseEventComponent)) {
- set.add(component.getName());
- fSelectedEvents.add(component.getName());
- }
- }
-
- if (fLogLevelButton.getSelection()) {
- fLogLevelType = LogLevelType.LOGLEVEL;
- } else if (fLogLevelOnlyButton.getSelection()) {
- fLogLevelType = LogLevelType.LOGLEVEL_ONLY;
- } else {
- fLogLevelType = LogLevelType.LOGLEVEL_NONE;
- }
-
- // initialize log level event name string
- fLogLevelEventName = null;
- String temp = fLogLevelEventNameText.getText();
- if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableEventsDialogTitle,
- Messages.TraceControl_InvalidLogLevelEventNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- return false;
- }
-
- if(!temp.matches("\\s*")) { //$NON-NLS-1$
- fLogLevelEventName = temp;
- }
-
- // initialize log level event name string
- fWildcard = null;
- temp = fWildcardText.getText();
- if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_\\*]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableEventsDialogTitle,
- Messages.TraceControl_InvalidWildcardError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- return false;
- }
-
- if(!temp.matches("\\s*")) { //$NON-NLS-1$
- fWildcard = temp;
- }
-
- // validation successful -> call super.okPressed()
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Helper methods
- // ------------------------------------------------------------------------
-
- /**
- * Creates tracepoints group.
- */
- private void createTracepointsGroup() {
- Group tpMainGroup = new Group(this, SWT.SHADOW_NONE);
- tpMainGroup.setText(Messages.TraceControl_EnableEventsTracepointGroupName);
- GridLayout layout = new GridLayout(2, false);
- tpMainGroup.setLayout(layout);
- GridData data = new GridData(GridData.FILL_BOTH);
- tpMainGroup.setLayoutData(data);
-
- Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE);
- layout = new GridLayout(1, true);
- buttonComposite.setLayout(layout);
- data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
- buttonComposite.setLayoutData(data);
-
- fTracepointsActivateButton = new Button(buttonComposite, SWT.RADIO);
- fTracepointsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fTracepointsActivateButton.setLayoutData(data);
- fTracepointsActivateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setEnablements(GroupEnum.TRACEPOINTS);
- }
- });
-
- Group tpGroup = new Group(tpMainGroup, SWT.SHADOW_NONE);
- layout = new GridLayout(1, true);
- tpGroup.setLayout(layout);
- data = new GridData(GridData.FILL_BOTH);
- tpGroup.setLayoutData(data);
-
- fTracepointsViewer = new CheckboxTreeViewer(tpGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip);
- fTracepointsViewer.setContentProvider(new UstContentProvider());
-
- fTracepointsViewer.setLabelProvider(new UstLabelProvider());
- fTracepointsViewer.addCheckStateListener(new UstCheckStateListener());
-
- fTracepointsViewer.setInput(fProviderGroup.getParent());
- fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
- }
-
- /**
- * Creates wildcard group.
- */
- private void createWildCardGroup() {
- Group wildcardMainGroup = new Group(this, SWT.SHADOW_NONE);
- wildcardMainGroup.setText(Messages.TraceControl_EnableEventsWildcardGroupName);
- GridLayout layout = new GridLayout(2, false);
- wildcardMainGroup.setLayout(layout);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- wildcardMainGroup.setLayoutData(data);
-
- Composite buttonComposite = new Composite(wildcardMainGroup, SWT.NONE);
- layout = new GridLayout(1, false);
- buttonComposite.setLayout(layout);
- data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
- buttonComposite.setLayoutData(data);
-
- fWildcardActivateButton = new Button(buttonComposite, SWT.RADIO);
- fWildcardActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
- fWildcardActivateButton.setSelection(false);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fWildcardActivateButton.setLayoutData(data);
- fWildcardActivateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setEnablements(GroupEnum.WILDCARD);
- }
- });
-
- Group wildcardGroup = new Group(wildcardMainGroup, SWT.SHADOW_NONE);
- layout = new GridLayout(3, true);
- wildcardGroup.setLayout(layout);
- data = new GridData(GridData.FILL_HORIZONTAL);
- wildcardGroup.setLayoutData(data);
-
- Label wildcardLabel = new Label(wildcardGroup, SWT.LEFT);
- wildcardLabel.setText(Messages.TraceControl_EnableEventsWildcardLabel);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 1;
- wildcardLabel.setLayoutData(data);
-
- fWildcardText = new Text(wildcardGroup, SWT.LEFT);
- fWildcardText.setToolTipText(Messages.TraceControl_EnableEventsWildcardTooltip);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 2;
- fWildcardText.setLayoutData(data);
- }
-
- /**
- * Creates log level group.
- */
- private void createLogLevelGroup() {
- Group logLevelMainGroup = new Group(this, SWT.SHADOW_NONE);
- logLevelMainGroup.setText(Messages.TraceControl_EnableEventsLogLevelGroupName);
- GridLayout layout = new GridLayout(2, false);
- logLevelMainGroup.setLayout(layout);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- logLevelMainGroup.setLayoutData(data);
-
- Composite buttonComposite = new Composite(logLevelMainGroup, SWT.NONE);
- layout = new GridLayout(1, false);
- buttonComposite.setLayout(layout);
- data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
- buttonComposite.setLayoutData(data);
-
- fLogLevelActivateButton = new Button(buttonComposite, SWT.RADIO);
- fLogLevelActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
- fLogLevelActivateButton.setSelection(false);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fLogLevelActivateButton.setLayoutData(data);
- fLogLevelActivateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setEnablements(GroupEnum.LOGLEVEL);
- }
- });
-
- Group logLevelGroup = new Group(logLevelMainGroup, SWT.SHADOW_NONE);
- layout = new GridLayout(3, true);
- logLevelGroup.setLayout(layout);
- logLevelGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label logLevelEventNameLabel = new Label(logLevelGroup, SWT.LEFT);
- logLevelEventNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel);
-
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 1;
- logLevelEventNameLabel.setLayoutData(data);
-
- fLogLevelEventNameText = new Text(logLevelGroup, SWT.LEFT);
- fLogLevelEventNameText.setToolTipText(Messages.TraceControl_EnableEventsLoglevelEventNameTooltip);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 2;
- fLogLevelEventNameText.setLayoutData(data);
-
- TraceLogLevel[] levels = TraceLogLevel.values();
-
- String[] levelNames = new String[levels.length - 1];
- int k = 0;
- for (int i = 0; i < levels.length; i++) {
- if (levels[i] != TraceLogLevel.LEVEL_UNKNOWN) {
- levelNames[k++] = levels[i].getInName();
- }
- }
-
- fLogLevelCombo = new CCombo(logLevelGroup, SWT.READ_ONLY);
- fLogLevelCombo.setItems(levelNames);
- fLogLevelCombo.setToolTipText(Messages.TraceControl_EnableEventsLogLevelTooltip);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 4;
- fLogLevelCombo.setLayoutData(data);
-
- fLogLevelButton = new Button(logLevelGroup, SWT.RADIO);
- fLogLevelButton.setText(Messages.TraceControl_EnableEventsLogLevelTypeName);
- fLogLevelButton.setToolTipText(Messages.TraceControl_EnableEventsLogLevelTypeTooltip);
- data = new GridData(GridData.FILL_BOTH);
- fLogLevelButton.setLayoutData(data);
-
- fLogLevelOnlyButton = new Button(logLevelGroup, SWT.RADIO);
- fLogLevelOnlyButton.setText(Messages.TraceControl_EnableEventsLogLevelOnlyTypeName);
- fLogLevelOnlyButton.setToolTipText(Messages.TraceControl_EnableEventsLogLevelOnlyTypeTooltip);
- data = new GridData(GridData.FILL_BOTH);
- fLogLevelButton.setLayoutData(data);
- }
-
- /**
- * Enable/selects widgets depending on the group specified.
- * @param group - group to enable.
- */
- private void setEnablements(GroupEnum group) {
-
- // Enable/disable trace point items
- fTracepointsActivateButton.setSelection(group == GroupEnum.TRACEPOINTS);
- fTracepointsViewer.getTree().setEnabled(group == GroupEnum.TRACEPOINTS);
-
- // Enable/disable wildcard items
- fWildcardActivateButton.setSelection(group == GroupEnum.WILDCARD);
- fWildcardText.setEnabled(group == GroupEnum.WILDCARD);
-
- // Enable/disable log level items
- fLogLevelActivateButton.setSelection(group == GroupEnum.LOGLEVEL);
- fLogLevelEventNameText.setEnabled(group == GroupEnum.LOGLEVEL);
- fLogLevelCombo.setEnabled(group == GroupEnum.LOGLEVEL);
- fLogLevelButton.setEnabled(group == GroupEnum.LOGLEVEL);
- fLogLevelOnlyButton.setEnabled(group == GroupEnum.LOGLEVEL);
- }
-
- // ------------------------------------------------------------------------
- // Local classes
- // ------------------------------------------------------------------------
- /**
- * Content provider for the tracepoints tree.
- */
- final public class UstContentProvider extends TraceControlContentProvider {
- @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof TargetNodeComponent) {
- List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(TraceProviderGroup.class);
- return (ITraceControlComponent[]) children.toArray(new ITraceControlComponent[children.size()]);
- }
- if (parentElement instanceof TraceProviderGroup) {
- List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(UstProviderComponent.class);
- return (ITraceControlComponent[]) children.toArray(new ITraceControlComponent[children.size()]);
- }
- if (parentElement instanceof ITraceControlComponent) {
- return ((ITraceControlComponent)parentElement).getChildren();
- }
- return new Object[0];
- }
- }
-
- /**
- * Content label for the tracepoints tree.
- */
- final public class UstLabelProvider extends TraceControlLabelProvider {
- @Override
- public Image getImage(Object element) {
- return null;
- }
- @Override
- public String getText(Object element) {
- if ((element != null) && (element instanceof TraceProviderGroup)) {
- return Messages.TraceControl_EnableEventsTracepointTreeAllLabel;
- }
-
- if ((element != null) && (element instanceof UstProviderComponent)) {
- return Messages.TraceControl_EnableEventsTracepointTreeAllLabel + " - " + ((UstProviderComponent)element).getName(); //$NON-NLS-1$
- }
- return super.getText(element);
- }
- }
-
- /**
- * Check state listener for the tracepoints tree.
- */
- final public class UstCheckStateListener implements ICheckStateListener {
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- if (event.getChecked()) {
- if (event.getElement() instanceof TraceProviderGroup) {
- fTracepointsViewer.setSubtreeChecked(event.getElement(), true);
- }
- if (event.getElement() instanceof UstProviderComponent) {
- fTracepointsViewer.setSubtreeChecked(event.getElement(), true);
- }
- } else {
- if (event.getElement() instanceof TraceProviderGroup) {
- fTracepointsViewer.setSubtreeChecked(event.getElement(), true);
- }
- if (event.getElement() instanceof UstProviderComponent) {
- ITraceControlComponent component = (ITraceControlComponent) event.getElement();
- fTracepointsViewer.setSubtreeChecked(event.getElement(), false);
- fTracepointsViewer.setChecked(component.getParent(), false);
- } else {
- ITraceControlComponent component = (ITraceControlComponent) event.getElement();
- fTracepointsViewer.setChecked(component.getParent(), false);
- fTracepointsViewer.setChecked(component.getParent().getParent(), false);
- }
- }
- }
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import java.util.Arrays;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * <b><u>EnableEventsDialog</u></b>
- * <p>
- * Dialog box for collecting information about the events to enable.
- * </p>
- */
-public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The icon file for this dialog box.
- */
- public static final String TARGET_NEW_CONNECTION_ICON_FILE = "icons/elcl16/edit.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The dialog composite.
- */
- private Composite fDialogComposite = null;
- /**
- * The Group for the session combo box.
- */
- private Group fSessionsGroup = null;
- /**
- * The Group for the channel combo box.
- */
- private Group fChannelsGroup = null;
- /**
- * The session combo box.
- */
- private CCombo fSessionsCombo = null;
- /**
- * The channel combo box.
- */
- private CCombo fChannelsCombo = null;
- /**
- * The list of available sessions.
- */
- private TraceSessionComponent[] fSessions;
- /**
- * True for kernel, false for UST.
- */
- private boolean fIsKernel;
- /**
- * Index in session array (selected session).
- */
- private int fSessionIndex = 0;
- /**
- * The Channel where the events should be enabled.
- */
- private TraceChannelComponent fChannel;
- /**
- * List of available channels of the selected session.
- */
- private TraceChannelComponent[] fChannels;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor of dialog box.
- * @param shell - the shell for the dialog box
- */
- public GetEventInfoDialog(Shell shell) {
- super(shell);
- setShellStyle(SWT.RESIZE);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableEventsDialog#getSession()
- */
- @Override
- public TraceSessionComponent getSession() {
- return fSessions[fSessionIndex];
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableEventsDialog#getChannel()
- */
- @Override
- public TraceChannelComponent getChannel() {
- return fChannel;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IGetEventInfoDialog#setIsKernel(boolean)
- */
- @Override
- public void setIsKernel(boolean isKernel) {
- fIsKernel = isKernel;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IGetEventInfoDialog#setSessions(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent[])
- */
- @Override
- public void setSessions(TraceSessionComponent[] sessions) {
- fSessions = Arrays.copyOf(sessions, sessions.length);
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(Messages.TraceControl_EnableEventsDialogTitle);
- newShell.setImage(Activator.getDefault().loadIcon(TARGET_NEW_CONNECTION_ICON_FILE));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
-
- // Main dialog panel
- fDialogComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(1, true);
- fDialogComposite.setLayout(layout);
- fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fSessionsGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
- fSessionsGroup.setText(Messages.TraceControl_EnableEventsSessionGroupName);
- layout = new GridLayout(1, true);
- fSessionsGroup.setLayout(layout);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- fSessionsGroup.setLayoutData(data);
-
- fSessionsCombo = new CCombo(fSessionsGroup, SWT.READ_ONLY);
- fSessionsCombo.setToolTipText(Messages.TraceControl_EnableEventsSessionsTooltip);
- fSessionsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- String items[] = new String[fSessions.length];
- for (int i = 0; i < items.length; i++) {
- items[i] = String.valueOf(fSessions[i].getName());
- }
-
- fSessionsCombo.setItems(items);
- fSessionsCombo.setEnabled(fSessions.length > 0);
-
- fChannelsGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
- fChannelsGroup.setText(Messages.TraceControl_EnableEventsChannelGroupName);
- layout = new GridLayout(1, true);
- fChannelsGroup.setLayout(layout);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fChannelsGroup.setLayoutData(data);
-
- fChannelsCombo = new CCombo(fChannelsGroup, SWT.READ_ONLY);
- fChannelsCombo.setToolTipText(Messages.TraceControl_EnableEventsChannelsTooltip);
- fChannelsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fChannelsCombo.setEnabled(false);
-
- fSessionsCombo.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- fSessionIndex = fSessionsCombo.getSelectionIndex();
-
- if (fSessionIndex >= 0) {
- TraceDomainComponent domain = null;
- TraceDomainComponent[] domains = fSessions[fSessionIndex].getDomains();
- for (int i = 0; i < domains.length; i++) {
-
- if (domains[i].isKernel() == fIsKernel) {
- domain = domains[i];
- break;
- }
- }
-
- 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());
- }
- fChannelsCombo.setItems(items);
- fChannelsCombo.setEnabled(fChannels.length > 0);
- } else {
- fChannelsCombo.setItems(new String[0]);
- fChannelsCombo.setEnabled(false);
- fChannels = null;
- }
- fChannelsCombo.getParent().getParent().layout();
- }
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- return fDialogComposite;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- @Override
- protected void okPressed() {
-
- if (fSessionsCombo.getSelectionIndex() < 0) {
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableEventsDialogTitle,
- Messages.TraceControl_EnableEventsNoSessionError);
- return;
- }
-
- fSessionIndex = fSessionsCombo.getSelectionIndex();
-
- if ((fChannels != null) && (fChannels.length > 0) && (fChannelsCombo.getSelectionIndex() < 0)) {
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableEventsDialogTitle,
- Messages.TraceControl_EnableEventsNoChannelError);
- return;
- }
-
- if ((fChannels != null) && (fChannels.length > 0)) {
- fChannel = fChannels[fChannelsCombo.getSelectionIndex()];
- }
-
- super.okPressed();
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * <b><u>IConfirmDialog</u></b>
- * <p>
- * Interface for a confirmation dialog.
- * </p>
- */
-public interface IConfirmDialog {
-
- public boolean openConfirm(Shell parent, String title, String message);
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-
-/**
- * <b><u>ICreateChannelDialog</u></b>
- * <p>
- * Interface for the create channel dialog when domain is known.
- * </p>
- */
-public interface ICreateChannelDialog {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return the configuration info for the new channel.
- */
- public IChannelInfo getChannelInfo();
-
- /**
- * Sets the domain component
- * @param domain - the trace domain component
- */
- public void setDomainComponent(TraceDomainComponent domain);
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * @return the open return value
- */
- int open();
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-
-/**
- * <b><u>ICreateChannelOnSessionDialog</u></b>
- * <p>
- * Interface for the create channel dialog when domain is known, i.e. dialog
- * was opened on session level.
- * </p>
- */
-public interface ICreateChannelOnSessionDialog extends ICreateChannelDialog {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return true for Kernel domain. False for UST.
- */
- public boolean isKernel();
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionGroup;
-
-/**
- * <b><u>ICreateSessionDialog</u></b>
- * <p>
- * Interface for create session dialog.
- * </p>
- */
-public interface ICreateSessionDialog {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return the session name.
- */
- public String getSessionName();
-
- /**
- * @return the session path (null for default path)
- */
- public String getSessionPath();
-
- /**
- * @return true for default location else false
- */
- public boolean isDefaultSessionPath();
-
- /**
- * Set trace session group.
- * @param group - the session group
- */
- public void setTraceSessionGroup(TraceSessionGroup group);
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * @return the open return value
- */
- int open();
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceProviderGroup;
-
-/**
- * <b><u>IEnableKernelEvents</u></b>
- * <p>
- * Interface for providing information about Kernel or UST events to be enabled.
- * </p>
- */
-public interface IEnableEventsDialog extends IEnableKernelEvents, IEnableUstEvents {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return the session the events shall be enabled.
- */
- public boolean isKernel();
-
- /**
- * Sets the trace provider group.
- * @param providerGroup - a trace provider group
- */
- public void setTraceProviderGroup(TraceProviderGroup providerGroup);
-
- /**
- * Sets the trace domain component.
- * @param domain - a domain of the events (null if not known)
- */
- public void setTraceDomainComponent(TraceDomainComponent domain);
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * @return returns the open return value
- */
- int open();
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import java.util.List;
-
-/**
- * <b><u>IEnableKernelEvents</u></b>
- * <p>
- * Interface for providing information about kernel events to be enabled.
- * </p>
- */
-public interface IEnableKernelEvents {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return a flag whether the tracepoints shall be configured.
- */
- public boolean isTracepoints();
-
- /**
- * @return a flag indicating whether all tracepoints shall be enabled or not.
- */
- public boolean isAllTracePoints();
-
- /**
- * @return a flag whether the syscalls shall be configured.
- */
- public boolean isSysCalls();
-
- /**
- * @return a flag indicating whether syscalls shall be enabled or not.
- */
- public boolean isAllSysCalls();
-
- /**
- * @return a list of event names to be enabled.
- */
- public List<String> getEventNames();
-
- /**
- * @return a flag whether the dynamic probe shall be configured.
- */
- public boolean isDynamicProbe();
-
- /**
- * @return event name of the dynamic probe (or null if no dynamic probe).
- */
- public String getProbeEventName();
-
- /**
- * @return the dynamic probe (or null if no dynamic probe).
- */
- public String getProbeName();
-
- /**
- * @return a flag whether the dynamic function entry/return probe shall be configured.
- */
- public boolean isDynamicFunctionProbe();
-
- /**
- * @return event name of the dynamic function entry/exit probe (or null if no dynamic probe).
- */
- public String getFunctionEventName();
-
- /**
- * @return the dynamic function entry/exit probe (or null if no dynamic probe).
- */
- public String getFunction();
-
-// /**
-// * @return a flag whether events using wildcards should be enabled
-// */
-// public boolean isWildcard();
-//
-// /**
-// * @return a wildcard
-// */
-// public String getWildcard();
-//
-// /**
-// * @return a flag whether events using log levels should be enabled
-// */
-// public boolean isLogLevel();
-//
-// /**
-// * @return a log level type (loglevel or loglevel-only)
-// */
-// public LogLevelType getLogLevelType();
-//
-// /**
-// * @return a log level
-// */
-// public TraceLogLevel getLogLevel();
-//
-// /**
-// * @return a event name for the log level enable action
-// */
-// public String getLogLevelEventName();
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import java.util.List;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-
-/**
- * <b><u>IEnableKernelEvents</u></b>
- * <p>
- * Interface for providing information about UST events to be enabled.
- * </p>
- */
-public interface IEnableUstEvents {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return a flag whether the tracepoints shall be configured.
- */
- public boolean isTracepoints();
-
- /**
- * @return a flag indicating whether all tracepoints shall be enabled or not.
- */
- public boolean isAllTracePoints();
-
- /**
- * @return a list of event names to be enabled.
- */
- public List<String> getEventNames();
-
- /**
- * @return a flag whether events using wildcards should be enabled
- */
- public boolean isWildcard();
-
- /**
- * @return a wildcard
- */
- public String getWildcard();
-
- /**
- * @return a flag whether events using log levels should be enabled
- */
- public boolean isLogLevel();
-
- /**
- * @return a log level type (loglevel or loglevel-only)
- */
- public LogLevelType getLogLevelType();
-
- /**
- * @return a log level
- */
- public TraceLogLevel getLogLevel();
-
- /**
- * @return a event name for the log level enable action
- */
- public String getLogLevelEventName();
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-
-/**
- * <b><u>IEnableEventsDialog</u></b>
- * <p>
- * Interface for a dialog box for collecting information about the events to enable.
- * </p>
- */
-public interface IGetEventInfoDialog {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return the session the events shall be enabled.
- */
- public TraceSessionComponent getSession();
-
- /**
- * @return the channel the events shall be enabled. Null for default channel.
- */
- public TraceChannelComponent getChannel();
-
- /**
- * Sets flag about domain.
- * @param isKernel - true for kernel, false for UST
- */
- public void setIsKernel(boolean isKernel);
-
- /**
- * Sets available session.
- * @param sessions - a array of available sessions.
- */
- public void setSessions(TraceSessionComponent[] sessions);
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * @return returns the open return value
- */
- int open();
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.rse.core.model.IHost;
-
-/**
- * <b><u>INewConnectionDialog</u></b>
- * <p>
- * Interface for connection information dialog.
- * </p>
- */
-public interface INewConnectionDialog {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return the connection name (alias).
- */
- public String getConnectionName();
-
- /**
- * @return the host name (IP address or DNS name)
- */
- public String getHostName();
-
- /**
- * Sets the trace control root
- * @param parent - the trace control parent
- */
- public void setTraceControlParent(ITraceControlComponent parent);
-
- /**
- * Sets the available hosts to select.
- * @param hosts - the available hosts
- */
- public void setHosts(IHost[] hosts);
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * @return returns the open return value
- */
- int open();
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import java.util.Arrays;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * <b><u>NewConnectionDialog</u></b>
- * <p>
- * Dialog box for connection information.
- * </p>
- */
-public class NewConnectionDialog extends Dialog implements INewConnectionDialog {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The icon file for this dialog box.
- */
- public static final String TARGET_NEW_CONNECTION_ICON_FILE = "icons/elcl16/target_add.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The dialog composite.
- */
- private Composite fDialogComposite = null;
- /**
- * The Group for the host combo box.
- */
- private Group fComboGroup = null;
- /**
- * The Group for the text input.
- */
- private Group fTextGroup = null;
- /**
- * The host combo box.
- */
- private CCombo fExistingHostsCombo = null;
- /**
- * The check box button for enabling/disabling the text input.
- */
- private Button fButton = null;
- /**
- * The text widget for the node name (alias)
- */
- private Text fConnectionNameText = null;
- /**
- * The text widget for the node address (IP or DNS name)
- */
- private Text fHostNameText = null;
- /**
- * The parent where the new node should be added.
- */
- private ITraceControlComponent fParent;
- /**
- * The node name (alias) string.
- */
- private String fConnectionName = null;
- /**
- * The node address (IP or DNS name) string.
- */
- private String fHostName = null;
-
- /**
- * Input list of existing RSE hosts available for selection.
- */
- private IHost[] fExistingHosts = new IHost[0];
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- public NewConnectionDialog(Shell shell) {
- super(shell);
- setShellStyle(SWT.RESIZE);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.INewConnectionDialog#getConnectionName()
- */
- @Override
- public String getConnectionName() {
- return fConnectionName;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.INewConnectionDialog#getHostName()
- */
- @Override
- public String getHostName() {
- return fHostName;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.INewConnectionDialog#setTraceControlParent(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent)
- */
- @Override
- public void setTraceControlParent(ITraceControlComponent parent) {
- fParent = parent;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.INewConnectionDialog#setHosts(org.eclipse.rse.core.model.IHost[])
- */
- @Override
- public void setHosts(IHost[] hosts) {
- if (hosts != null) {
- fExistingHosts = Arrays.copyOf(hosts, hosts.length);
- }
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(Messages.TraceControl_NewDialogTitle);
- newShell.setImage(Activator.getDefault().loadIcon(TARGET_NEW_CONNECTION_ICON_FILE));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
-
- // Main dialog panel
- fDialogComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(1, true);
- fDialogComposite.setLayout(layout);
- fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // Existing connections group
- fComboGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
- fComboGroup.setText(Messages.TraceControl_NewNodeExistingConnectionGroupName);
- layout = new GridLayout(2, true);
- fComboGroup.setLayout(layout);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- fComboGroup.setLayoutData(data);
-
- fExistingHostsCombo = new CCombo(fComboGroup, SWT.READ_ONLY);
- fExistingHostsCombo.setToolTipText(Messages.TraceControl_NewNodeComboToolTip);
- fExistingHostsCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
-
- String items[] = new String[fExistingHosts.length];
- for (int i = 0; i < items.length; i++) {
- items[i] = String.valueOf(fExistingHosts[i].getAliasName() + " - " + fExistingHosts[i].getHostName()); //$NON-NLS-1$
- }
-
- fExistingHostsCombo.setItems(items);
- fExistingHostsCombo.setEnabled(fExistingHosts.length > 0);
-
- // Node information grop
- fTextGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
- layout = new GridLayout(3, true);
- fTextGroup.setLayout(layout);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fTextGroup.setLayoutData(data);
-
- fButton = new Button(fTextGroup, SWT.CHECK);
- fButton.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
- fButton.setText(Messages.TraceControl_NewNodeEditButtonName);
- fButton.setEnabled(fExistingHosts.length > 0);
-
- Label connectionNameLabel = new Label(fTextGroup, SWT.RIGHT);
- connectionNameLabel.setText(Messages.TraceControl_NewNodeConnectionNameLabel);
- fConnectionNameText = new Text(fTextGroup, SWT.NONE);
- fConnectionNameText.setToolTipText(Messages.TraceControl_NewNodeConnectionNameTooltip);
- fConnectionNameText.setEnabled(fExistingHosts.length == 0);
-
- Label hostNameLabel = new Label(fTextGroup, SWT.RIGHT);
- hostNameLabel.setText(Messages.TraceControl_NewNodeHostNameLabel);
- fHostNameText = new Text(fTextGroup, SWT.NONE);
- fHostNameText.setToolTipText(Messages.TraceControl_NewNodeHostNameTooltip);
- fHostNameText.setEnabled(fExistingHosts.length == 0);
-
- fButton.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (fButton.getSelection()) {
- fExistingHostsCombo.deselectAll();
- fExistingHostsCombo.setEnabled(false);
- fConnectionNameText.setEnabled(true);
- fHostNameText.setEnabled(true);
- } else {
- fExistingHostsCombo.setEnabled(true);
- fConnectionNameText.setEnabled(false);
- fHostNameText.setEnabled(false);
- }
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- fExistingHostsCombo.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int index = fExistingHostsCombo.getSelectionIndex();
- fConnectionNameText.setText(fExistingHosts[index].getAliasName());
- fHostNameText.setText(fExistingHosts[index].getHostName());
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- // layout widgets
- data = new GridData(GridData.FILL_HORIZONTAL);
- fHostNameText.setText("666.666.666.666"); //$NON-NLS-1$
- Point minSize = fHostNameText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- data.widthHint = minSize.x + 5;
- data.horizontalSpan = 2;
-
- fConnectionNameText.setLayoutData(data);
- fHostNameText.setLayoutData(data);
-
- fHostNameText.setText(""); //$NON-NLS-1$
-
- return fDialogComposite;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- @Override
- protected void okPressed() {
- // Validate input data
- fConnectionName = fConnectionNameText.getText();
- fHostName = fHostNameText.getText();
-
- if (!"".equals(fHostName)) { //$NON-NLS-1$
- // If no node name is specified use the node address as name
- if ("".equals(fConnectionName)) { //$NON-NLS-1$
- fConnectionName = fHostName;
- }
- // Check if node with name already exists in parent
- if(fParent.containsChild(fConnectionName)) {
- MessageDialog.openError(getShell(),
- Messages.TraceControl_NewDialogTitle,
- Messages.TraceControl_AlreadyExistsError + " (" + fConnectionName + ")"); //$NON-NLS-1$//$NON-NLS-2$
- return;
- }
- }
- else {
- return;
- }
- // validation successful -> call super.okPressed()
- super.okPressed();
- }
-}
+++ /dev/null
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs;
-
-import org.eclipse.ui.PlatformUI;
-
-
-public class TraceControlDialogFactory {
-
- // ------------------------------------------------------------------------
- // Members
- // ------------------------------------------------------------------------
-
- /**
- * The factory instance.
- */
- private static TraceControlDialogFactory fInstance;
-
- /**
- * The new connection dialog reference.
- */
- private INewConnectionDialog fNewConnectionDialog;
-
- /**
- * The create channel dialog (on domain level)
- */
- private ICreateChannelDialog fCreateChannelDialog;
-
- /**
- * The create channel dialog (on session level)
- */
- private ICreateChannelOnSessionDialog fCreateChannelOnSessionDialog;
-
- /**
- * The create session dialog.
- */
- private ICreateSessionDialog fCreateSessionDialog;
-
- /**
- * The enable events dialog.
- */
- private IEnableEventsDialog fEnableEventsDialog;
-
- /**
- * The get event info dialog.
- */
- private IGetEventInfoDialog fGetEventInfoDialog;
-
- /**
- * The confirmation dialog implementation
- */
- private IConfirmDialog fConfirmDialog;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor for R4EUIDialogFactory.
- */
- private TraceControlDialogFactory() {
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * @return TraceControlDialogFactory instance
- */
- public static TraceControlDialogFactory getInstance() {
- if (null == fInstance) {
- fInstance = new TraceControlDialogFactory();
- }
- return fInstance;
- }
-
- /**
- * @return new connection dialog
- */
- public INewConnectionDialog getNewConnectionDialog() {
- if (null == fNewConnectionDialog) {
- fNewConnectionDialog = new NewConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- }
- return fNewConnectionDialog;
- }
-
- /**
- * Sets a new connection dialog implementation.
- * @param newConnectionDialog - new connection dialog implementation
- */
- public void setNewConnectionDialog(INewConnectionDialog newConnectionDialog) {
- fNewConnectionDialog = newConnectionDialog;
- }
-
- /**
- * @return create channel dialog (on domain level)
- */
- public ICreateChannelDialog getCreateChannelDialog() {
- if (null == fCreateChannelDialog) {
- fCreateChannelDialog = new CreateChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- }
- return fCreateChannelDialog;
- }
-
- /**
- * Sets a create channel dialog implementation (on domain level).
- * @param createChannelDialog - a create channel dialog implementation
- */
- public void setCreateChannelDialog(ICreateChannelDialog createChannelDialog) {
- fCreateChannelDialog = createChannelDialog;
- }
-
- /**
- * @return create channel dialog (on session level)
- */
- public ICreateChannelOnSessionDialog getCreateChannelOnSessionDialog() {
- if (null == fCreateChannelOnSessionDialog) {
- fCreateChannelOnSessionDialog = new CreateChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- }
- return fCreateChannelOnSessionDialog;
- }
-
- /**
- * Sets a create channel dialog implementation (on domain level).
- * @param createChannelDialog - a create channel dialog implementation
- */
- public void setCreateChannelOnSessionDialog(ICreateChannelOnSessionDialog createChannelDialog) {
- fCreateChannelOnSessionDialog = createChannelDialog;
- }
-
- /**
- * @return create session dialog implementation
- */
- public ICreateSessionDialog getCreateSessionDialog() {
- if (null == fCreateSessionDialog) {
- fCreateSessionDialog = new CreateSessionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- }
- return fCreateSessionDialog;
- }
-
- /**
- * Sets a create session dialog implementation.
- * @param createSessionDialog - a create session implementation.
- */
- public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog) {
- fCreateSessionDialog = createSessionDialog;
- }
-
- /**
- * @return enable events dialog implementation.
- */
- public IEnableEventsDialog getEnableEventsDialog() {
- if (null == fEnableEventsDialog) {
- fEnableEventsDialog = new EnableEventsDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- }
- return fEnableEventsDialog;
- }
-
- /**
- * Sets a enable events dialog implementation.
- * @param enableEventsDialog - a enable events dialog implementation.
- */
- public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog) {
- fEnableEventsDialog = enableEventsDialog;
- }
-
- /**
- * @return get events info dialog implementation.
- */
- public IGetEventInfoDialog getGetEventInfoDialog() {
- if (null == fGetEventInfoDialog) {
- fGetEventInfoDialog = new GetEventInfoDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- }
- return fGetEventInfoDialog;
- }
-
- /**
- * Sets a get events info dialog implementation.
- * @param getEventInfoDialog - a get events info dialog implementation
- */
- public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog) {
- fGetEventInfoDialog = getEventInfoDialog;
- }
-
- /**
- * @return the confirmation dialog implementation
- */
- public IConfirmDialog getConfirmDialog() {
- if (null == fConfirmDialog) {
- fConfirmDialog = new ConfirmDialog();
- }
- return fConfirmDialog;
- }
-
- /**
- * Sets the confirmation dialog implementation
- * @param confirmDialog
- */
- public void setConfirmDialog(IConfirmDialog confirmDialog) {
- fConfirmDialog = confirmDialog;
- }
-}
-
-
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IGetEventInfoDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.KernelProviderComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.UstProviderComponent;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>EnableEventHandler</u></b>
- * <p>
- * Command handler implementation to assign events to a session and channel and enable/configure them.
- * This is done on the trace provider level.
- * </p>
- */
-public class AssignEventHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The list of event components the command is to be executed on.
- */
- private List<BaseEventComponent> fEvents = new ArrayList<BaseEventComponent>();
-
- /**
- * The list of available sessions.
- */
- private TraceSessionComponent[] fSessions;
-
- /**
- * Flag for indicating Kernel or UST.
- */
- Boolean fIsKernel = null;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- // Open dialog box to retrieve the session and channel where the events should be enabled in.
- final IGetEventInfoDialog dialog = TraceControlDialogFactory.getInstance().getGetEventInfoDialog();
- dialog.setIsKernel(fIsKernel);
- dialog.setSessions(fSessions);
-
- if (dialog.open() != Window.OK) {
- return null;
- }
-
- Job job = new Job(Messages.TraceControl_EnableEventsJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
-
- String errorString = null;
- try {
- List<String> eventNames = new ArrayList<String>();
- // Create list of event names
- for (Iterator<BaseEventComponent> iterator = fEvents.iterator(); iterator.hasNext();) {
- BaseEventComponent event = (BaseEventComponent) iterator.next();
- eventNames.add(event.getName());
- }
-
- TraceChannelComponent channel = dialog.getChannel();
- if (channel == null) {
- // enable events on default channel (which will be created by lttng-tools)
- dialog.getSession().enableEvents(eventNames, fIsKernel, monitor);
- } else {
- channel.enableEvents(eventNames, monitor);
- }
-
- } catch (ExecutionException e) {
- errorString = e.toString() + "\n"; //$NON-NLS-1$
- }
-
- // get session configuration in all cases
- try {
- dialog.getSession().getConfigurationFromNode(monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
- }
-
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- fEvents.clear();
- fSessions = null;
- fIsKernel = null;
-
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- // Check if one or more session are selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
-
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof BaseEventComponent) {
- BaseEventComponent event = (BaseEventComponent) element;
- ITraceControlComponent provider = event.getParent();
-
- // check for kernel or UST provider
- boolean temp = false;
- if (provider instanceof KernelProviderComponent) {
- temp = true;
- } else if (provider instanceof UstProviderComponent) {
- temp = false;
- } else {
- return false;
- }
- if (fIsKernel == null) {
- fIsKernel = Boolean.valueOf(temp);
- } else {
- // don't mix events from Kernel and UST provider
- if (fIsKernel.booleanValue() != temp) {
- return false;
- }
- }
-
- // Add BaseEventComponents
- fEvents.add(event);
-
- if (fSessions == null) {
- TargetNodeComponent root = (TargetNodeComponent)event.getParent().getParent().getParent();
- fSessions = root.getSessions();
- }
- }
- }
- }
- return ((fEvents.size() > 0) && (fSessions != null) && (fSessions.length > 0));
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>BaseControlViewHandler</u></b>
- * <p>
- * Abstract Command handler implementation for all control view handlers.
- * </p>
- */
-abstract public class BaseControlViewHandler extends AbstractHandler {
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * @return returns the workbench page for the Control View
- */
- protected IWorkbenchPage getWorkbenchPage() {
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- return null;
- }
-
- // Check if we are in the Project View
- IWorkbenchPage page = window.getActivePage();
- if (page == null) {
- return null;
- }
-
- IWorkbenchPart part = page.getActivePart();
- if (!(part instanceof ControlView)) {
- return null;
- }
- return page;
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IEnableEventsDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceProviderGroup;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>EnableEventOnSessionHandler</u></b>
- * <p>
- * Base command handler implementation to enable events.
- * </p>
- */
-abstract public class BaseEnableEventHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The session component the command is to be executed on.
- */
- protected TraceSessionComponent fSession = null;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Enables a list of events for given parameters.
- * @param eventNames - list of event names
- * @param isKernel - true if kernel domain else false
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- abstract public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
- /**
- * Enables all syscall events.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- abstract public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Enables a dynamic probe.
- * @param eventName - a event name
- * @param isFunction - true for dynamic function entry/return probe else false
- * @param probe - a dynamic probe information
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- abstract public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Enables events using log level
- * @param eventName - a event name
- * @param logLevelType - a log level type
- * @param level - a log level
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- abstract public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * @return returns the relevant domain (null if domain is not known)
- */
- abstract TraceDomainComponent getDomain();
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- if (window == null) {
- return false;
- }
-
- TargetNodeComponent node = fSession.getTargetNode();
- List<ITraceControlComponent> providers = node.getChildren(TraceProviderGroup.class);
-
- final IEnableEventsDialog dialog = TraceControlDialogFactory.getInstance().getEnableEventsDialog();
- dialog.setTraceProviderGroup((TraceProviderGroup)providers.get(0));
- dialog.setTraceDomainComponent(getDomain());
-
- if (dialog.open() != Window.OK) {
- return null;
- }
-
- Job job = new Job(Messages.TraceControl_ChangeEventStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- try {
- // Enable tracepoint events
- if (dialog.isTracepoints()) {
- if (dialog.isAllTracePoints()) {
- enableEvents(null, dialog.isKernel(), monitor);
- } else {
- List<String> eventNames = dialog.getEventNames();
- if (eventNames.size() > 0) {
- enableEvents(eventNames, dialog.isKernel(), monitor);
- }
- }
- }
-
- // Enable syscall events
- if (dialog.isAllSysCalls()) {
- if (dialog.isAllSysCalls()) {
- enableSyscalls(monitor);
- }
- }
-
- // Enable dynamic probe
- if (dialog.isDynamicProbe()) {
- if ((dialog.getProbeEventName() != null && dialog.getProbeName() != null)) {
- enableProbe(dialog.getProbeEventName(), false, dialog.getProbeName(), monitor);
- }
- }
-
- // Enable dynamic function probe
- if (dialog.isDynamicFunctionProbe()) {
- if ((dialog.getFunctionEventName() != null) && (dialog.getFunction() != null)) {
- enableProbe(dialog.getFunctionEventName(), true, dialog.getFunction(), monitor);
- }
- }
-
- // Enable event using a wildcard
- if (dialog.isWildcard()) {
- List<String> eventNames = dialog.getEventNames();
- eventNames.add(dialog.getWildcard());
-
- if (eventNames.size() > 0) {
- enableEvents(eventNames, dialog.isKernel(), monitor);
- }
- }
-
- // Enable events using log level
- if (dialog.isLogLevel()) {
- enableLogLevel(dialog.getLogLevelEventName(), dialog.getLogLevelType(), dialog.getLogLevel(), monitor);
- }
-
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += e.toString() + "\n"; //$NON-NLS-1$
- }
-
- // get session configuration in all cases
- try {
- fSession.getConfigurationFromNode(monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
- }
-
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
-
- return null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>BaseNodeHandler</u></b>
- * <p>
- * Command handler implementation to delete a target host.
- * </p>
- */
-abstract public class BaseNodeHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The target node component the command is to be executed on.
- */
- protected TargetNodeComponent fTargetNode = null;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
-
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- fTargetNode = null;
-
- // Check if the node component is selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- fTargetNode = (element instanceof TargetNodeComponent) ? (TargetNodeComponent) element : null;
- }
- return fTargetNode != null;
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>ChangeChannelStateHandler</u></b>
- * <p>
- * Abstract command handler implementation to enable or disabling a trace channel.
- * </p>
- */
-abstract public class ChangeChannelStateHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * Kernel domain component reference.
- */
- protected TraceDomainComponent fKernelDomain = null;
- /**
- * UST domain component reference.
- */
- protected TraceDomainComponent fUstDomain = null;
- /**
- * The list of kernel channel components the command is to be executed on.
- */
- protected List<TraceChannelComponent> fKernelChannels = new ArrayList<TraceChannelComponent>();
- /**
- * The list of UST channel components the command is to be executed on.
- */
- protected List<TraceChannelComponent> fUstChannels = new ArrayList<TraceChannelComponent>();
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return the new state to set
- */
- abstract protected TraceEnablement getNewState();
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Changes the state of the given channels.
- * @param domain - the domain of the channels.
- * @param channelNames - a list of channel names
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- abstract protected void changeState(TraceDomainComponent domain, List<String> channelNames, IProgressMonitor monitor) throws ExecutionException;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- if (window == null) {
- return false;
- }
-
- Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- TraceSessionComponent session = null;
-
- try {
- if (fKernelDomain != null) {
- session = (TraceSessionComponent)fKernelDomain.getParent();
- List<String> channelNames = new ArrayList<String>();
- for (Iterator<TraceChannelComponent> iterator = fKernelChannels.iterator(); iterator.hasNext();) {
- // Enable all selected channels which are disabled
- TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
- channelNames.add(channel.getName());
- }
-
- changeState(fKernelDomain, channelNames, monitor);
-
- for (Iterator<TraceChannelComponent> iterator = fKernelChannels.iterator(); iterator.hasNext();) {
- // Enable all selected channels which are disabled
- TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
- channel.setState(getNewState());
- }
- }
-
- if (fUstDomain != null) {
- if (session == null) {
- session = (TraceSessionComponent)fUstDomain.getParent();
- }
-
- List<String> channelNames = new ArrayList<String>();
- for (Iterator<TraceChannelComponent> iterator = fUstChannels.iterator(); iterator.hasNext();) {
- // Enable all selected channels which are disabled
- TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
- channelNames.add(channel.getName());
- }
-
- changeState(fUstDomain, channelNames, monitor);
-
- for (Iterator<TraceChannelComponent> iterator = fUstChannels.iterator(); iterator.hasNext();) {
- // Enable all selected channels which are disabled
- TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
- channel.setState(getNewState());
- }
- }
- } catch (ExecutionException e) {
- errorString = e.toString() + "\n"; //$NON-NLS-1$
- }
-
- // In all cases notify listeners
- session.fireComponentChanged(session);
-
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
- }
-
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- reset();
-
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- // Check if one or more session are selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- String sessionName = null;
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
-
- if (element instanceof TraceChannelComponent) {
-
- // Add only TraceChannelComponents that are disabled
- TraceChannelComponent channel = (TraceChannelComponent) element;
- if (sessionName == null) {
- sessionName = String.valueOf(channel.getSessionName());
- }
-
- // Enable command only for channels of same session
- if (!sessionName.equals(channel.getSessionName())) {
- reset();
- break;
- }
-
- if ((channel.getState() != getNewState())) {
- if (channel.isKernel()) {
- fKernelChannels.add(channel);
- if (fKernelDomain == null) {
- fKernelDomain = (TraceDomainComponent) channel.getParent();
- }
- } else {
- fUstChannels.add(channel);
- if (fUstDomain == null) {
- fUstDomain = (TraceDomainComponent) channel.getParent();
- }
- }
- }
- }
- }
- }
- return fKernelChannels.size() + fUstChannels.size() > 0;
- }
-
- /**
- * Reset members
- */
- private void reset() {
- fKernelDomain = null;
- fUstDomain = null;
- fKernelChannels.clear();
- fUstChannels.clear();
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>EnableChannelHandler</u></b>
- * <p>
- * Base Command handler implementation to enable or disabling a trace channel.
- * </p>
- */
-abstract public class ChangeEventStateHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * Channel component reference.
- */
- protected TraceChannelComponent fChannel = null;
- /**
- * The list of kernel channel components the command is to be executed on.
- */
- protected List<TraceEventComponent> fEvents = new ArrayList<TraceEventComponent>();
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return the new state to set
- */
- abstract protected TraceEnablement getNewState();
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Change the state
- * @param channel - channel of events to be enabled
- * @param eventNames - list event names
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- abstract protected void changeState(TraceChannelComponent channel, List<String> eventNames, IProgressMonitor monitor) throws ExecutionException;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- if (window == null) {
- return false;
- }
-
- Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- TraceSessionComponent session = null;
-
- try {
- boolean isAll = false;
- if (fChannel != null) {
- session = fChannel.getSession();
- List<String> eventNames = new ArrayList<String>();
- for (Iterator<TraceEventComponent> iterator = fEvents.iterator(); iterator.hasNext();) {
- // Enable/disable all selected channels which are disabled
- TraceEventComponent event = (TraceEventComponent) iterator.next();
-
- // Workaround for wildcard handling in lttng-tools
- if ("*".equals(event.getName())) { //$NON-NLS-1$
- isAll = true;
- } else {
- eventNames.add(event.getName());
- }
- }
- if (isAll) {
- changeState(fChannel, null, monitor);
- }
-
- if (eventNames.size() > 0) {
- changeState(fChannel, eventNames, monitor);
- }
-
- for (Iterator<TraceEventComponent> iterator = fEvents.iterator(); iterator.hasNext();) {
- // Enable all selected channels which are disabled
- TraceEventComponent ev = (TraceEventComponent) iterator.next();
- ev.setState(getNewState());
- }
- }
- } catch (ExecutionException e) {
- errorString = e.toString() + "\n"; //$NON-NLS-1$
- }
-
- // In all cases notify listeners
- session.fireComponentChanged(session);
-
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
- }
-
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- reset();
-
- // Check if one or more session are selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- String sessionName = null;
- String channelName = null;
-
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
-
- if (element instanceof TraceEventComponent) {
-
- TraceEventComponent event = (TraceEventComponent) element;
- if (sessionName == null) {
- sessionName = String.valueOf(event.getSessionName());
- }
-
- if (fChannel == null) {
- fChannel = (TraceChannelComponent)event.getParent();
- }
-
- if (channelName == null) {
- channelName = event.getChannelName();
- }
-
- // Enable command only for events of same session, same channel and domain
- if ((!sessionName.equals(event.getSessionName())) ||
- (!channelName.equals(event.getChannelName())) ||
- (fChannel.isKernel() != event.isKernel())) {
- reset();
- break;
- }
-
- if ((event.getState() != getNewState())) {
- fEvents.add(event);
- }
- }
- }
- }
- return fEvents.size() > 0;
- }
-
- /**
- * Reset members
- */
- private void reset() {
- fChannel = null;
- fEvents.clear();
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>ChangeSessionStateHandler</u></b>
- * <p>
- * Abstract command handler implementation to start or stop one or more trace sessions.
- * </p>
- */
-abstract public class ChangeSessionStateHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The list of session components the command is to be executed on.
- */
- protected List<TraceSessionComponent> fSessions = new ArrayList<TraceSessionComponent>();
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return new required state.
- */
- abstract TraceSessionState getNewState();
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * Performs the state change on given session.
- * @param session - a session which state is to be changed
- * @param monitor - a progress monitor
- */
- abstract public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- if (window == null) {
- return false;
- }
-
- Job job = new Job(Messages.TraceControl_StartSessionJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- for (Iterator<TraceSessionComponent> iterator = fSessions.iterator(); iterator.hasNext();) {
-
- // Start all selected sessions
- TraceSessionComponent session = (TraceSessionComponent) iterator.next();
- changeState(session, monitor);
-
- // Set Session state
- session.setSessionState(getNewState());
- session.fireComponentChanged(session);
- }
- } catch (ExecutionException e) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- fSessions.clear();
-
- // Check if one or more session are selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof TraceSessionComponent) {
- // Add only TraceSessionComponents that are inactive and not destroyed
- TraceSessionComponent session = (TraceSessionComponent) element;
- if ((session.getSessionState() != getNewState()) && (!session.isDestroyed())) {
- fSessions.add((TraceSessionComponent)element);
- }
- }
- }
- }
- return fSessions.size() > 0;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState;
-
-/**
- * <b><u>ConnectHandler</u></b>
- * <p>
- * Command handler implementation to connect to a target host.
- * </p>
- */
-public class ConnectHandler extends BaseNodeHandler {
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseNodeHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- fTargetNode.connect();
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseNodeHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- return (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED));
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateChannelDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>CreateChannelOnDomainHandler</u></b>
- * <p>
- * Command handler implementation to create a trace channel for known domain.
- * </p>
- */
-public class CreateChannelOnDomainHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The the domain component the command is to be executed on.
- */
- private TraceDomainComponent fDomain;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- // Get channel information from user
- final ICreateChannelDialog dialog = TraceControlDialogFactory.getInstance().getCreateChannelDialog();
- dialog.setDomainComponent(fDomain);
-
- if (dialog.open() != Window.OK) {
- return null;
- }
-
- Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- List<String> channelNames = new ArrayList<String>();
- channelNames.add(dialog.getChannelInfo().getName());
-
- try {
- fDomain.enableChannels(channelNames, dialog.getChannelInfo(), monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += e.toString() + "\n"; //$NON-NLS-1$
- }
-
- // get session configuration in all cases
- try {
- fDomain.getConfigurationFromNode(monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
- }
-
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
- }
- return Status.OK_STATUS;
- }
- };
-
- job.setUser(true);
- job.schedule();
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
-
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
- fDomain = null;
-
- // Check if one domain is selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof TraceDomainComponent) {
- TraceDomainComponent domain = (TraceDomainComponent) element;
- TraceSessionComponent session = (TraceSessionComponent) domain.getParent();
- // Add only TraceDomainComponent whose TraceSessionComponent parent is inactive and not destroyed
- if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
- fDomain = domain;
- }
- }
- }
- }
- return fDomain != null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateChannelOnSessionDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>CreateChannelOnSessionHandler</u></b>
- * <p>
- * Command handler implementation to create a trace channel for unknown domain
- * (on session level).
- * </p>
- */
-public class CreateChannelOnSessionHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The session component the command is to be executed on.
- */
- private TraceSessionComponent fSession = null;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- final ICreateChannelOnSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateChannelOnSessionDialog();
-
- if (dialog.open() != Window.OK) {
- return null;
- }
-
- Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- List<String> channelNames = new ArrayList<String>();
- TraceDomainComponent newDomain = new TraceDomainComponent("dummy", fSession); //$NON-NLS-1$
- channelNames.add(dialog.getChannelInfo().getName());
- newDomain.setIsKernel(dialog.isKernel());
-
- try {
- newDomain.enableChannels(channelNames, dialog.getChannelInfo(), monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += e.toString() + "\n"; //$NON-NLS-1$
- }
-
- // get session configuration in all cases
- try {
- fSession.getConfigurationFromNode(monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
- }
-
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- fSession = null;
-
- // Check if one session is selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof TraceSessionComponent) {
- // Add only TraceSessionComponents that are inactive and not destroyed
- TraceSessionComponent session = (TraceSessionComponent) element;
- if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
- fSession = session;
- }
- }
- }
- }
- return fSession != null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.ICreateSessionDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionGroup;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>CreateSessionHandler</u></b>
- * <p>
- * Command handler implementation to create a trace session.
- * </p>
- */
-public class CreateSessionHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The trace session group the command is to be executed on.
- */
- private TraceSessionGroup fSessionGroup = null;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- // Open dialog box for the node name and address
- ICreateSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateSessionDialog();
- dialog.setTraceSessionGroup(fSessionGroup);
-
- if (dialog.open() != Window.OK) {
- return null;
- }
-
- final String sessionName = dialog.getSessionName();
- final String sessionPath = dialog.isDefaultSessionPath() ? null : dialog.getSessionPath();
-
- Job job = new Job(Messages.TraceControl_CreateSessionJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- fSessionGroup.createSession(sessionName, sessionPath, monitor);
- } catch (ExecutionException e) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
-
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- fSessionGroup = null;
-
- // Check if the session group project is selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- fSessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
- }
- return fSessionGroup != null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState;
-
-/**
- * <b><u>DeleteHandler</u></b>
- * <p>
- * Command handler implementation to delete a target host.
- * </p>
- */
-public class DeleteHandler extends BaseNodeHandler {
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseNodeHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ITraceControlComponent root = fTargetNode.getParent();
- fTargetNode.removeAllChildren();
- root.removeChild(fTargetNode);
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseNodeHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- return (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED));
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.IConfirmDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionGroup;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>DestroySessionHandler</u></b>
- * <p>
- * Command handler implementation to destroy one or more trace sessions.
- * </p>
- */
-public class DestroySessionHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The list of session components the command is to be executed on.
- */
- private List<TraceSessionComponent> fSessions = new ArrayList<TraceSessionComponent>();
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- if (window == null) {
- return false;
- }
- // Get user confirmation
- IConfirmDialog dialog = TraceControlDialogFactory.getInstance().getConfirmDialog();
- if (!dialog.openConfirm(window.getShell(),
- Messages.TraceControl_DestroyConfirmationTitle,
- Messages.TraceControl_DestroyConfirmationMessage)) {
-
- return null;
- }
-
- Job job = new Job(Messages.TraceControl_DestroySessionJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- // Make a copy of the list of sessions to avoid ConcurrentModificationException when iterating
- // over fSessions, since fSessions is modified in another thread triggered by the tree viewer refresh
- // after removing a session.
- TraceSessionComponent[] sessions = (TraceSessionComponent[])fSessions.toArray(new TraceSessionComponent[fSessions.size()]);
-
- for (int i = 0; i < sessions.length; i++) {
- // Destroy all selected sessions
- TraceSessionComponent session = sessions[i];
- TraceSessionGroup sessionGroup = (TraceSessionGroup)session.getParent();
- sessionGroup.destroySession(session, monitor);
- }
- } catch (ExecutionException e) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
- fSessions.clear();
-
- // Check if one or more session are selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof TraceSessionComponent) {
- // Add only TraceSessionComponents that are inactive and not destroyed
- TraceSessionComponent session = (TraceSessionComponent) element;
- if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
- fSessions.add((TraceSessionComponent)element);
- }
- }
- }
- }
- return fSessions.size() > 0;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-
-/**
- * <b><u>DisableChannelHandler</u></b>
- * <p>
- * Command handler implementation to disable one or more trace channels per session and domain.
- * </p>
- */
-public class DisableChannelHandler extends ChangeChannelStateHandler {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseChangeChannelStateHandler#getNewState()
- */
- @Override
- protected TraceEnablement getNewState() {
- return TraceEnablement.DISABLED;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseChangeChannelStateHandler#changeState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected void changeState(TraceDomainComponent domain, List<String> channelNames, IProgressMonitor monitor) throws ExecutionException {
- domain.disableChannels(channelNames, monitor);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-
-/**
- * <b><u>DisableEventHandler</u></b>
- * <p>
- * Command handler implementation to disable one or more events session, domain and channel.
- * </p>
- */
-public class DisableEventHandler extends ChangeEventStateHandler {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.ChangeEventStateHandler#getNewState()
- */
- @Override
- protected TraceEnablement getNewState() {
- return TraceEnablement.DISABLED;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.ChangeEventStateHandler#changeState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected void changeState(TraceChannelComponent channel, List<String> eventNames, IProgressMonitor monitor) throws ExecutionException{
- channel.disableEvent(eventNames, monitor);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState;
-
-/**
- * <b><u>DisconnectHandler</u></b>
- * <p>
- * Command handler implementation to disconnect from a target host.
- * </p>
- */
-public class DisconnectHandler extends BaseNodeHandler {
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseNodeHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- fTargetNode.disconnect();
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseNodeHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- return super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.CONNECTED);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-
-/**
- * <b><u>EnableChannelHandler</u></b>
- * <p>
- * Command handler implementation to enable one or more trace channels per session and domain.
- * </p>
- */
-public class EnableChannelHandler extends ChangeChannelStateHandler {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseChangeChannelStateHandler#getNewState()
- */
- @Override
- protected TraceEnablement getNewState() {
- return TraceEnablement.ENABLED;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseChangeChannelStateHandler#changeState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected void changeState(TraceDomainComponent domain, List<String> channelNames, IProgressMonitor monitor) throws ExecutionException {
- domain.enableChannels(channelNames, null, monitor);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-
-/**
- * <b><u>EnableEventHandler</u></b>
- * <p>
- * Command handler implementation to enable one or more events session, domain and channel.
- * </p>
- */
-public class EnableEventHandler extends ChangeEventStateHandler {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.ChangeEventStateHandler#getNewState()
- */
- @Override
- protected TraceEnablement getNewState() {
- return TraceEnablement.ENABLED;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.ChangeEventStateHandler#changeState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected void changeState(TraceChannelComponent channel, List<String> eventNames, IProgressMonitor monitor) throws ExecutionException{
- channel.enableEvents(eventNames, monitor);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>EnableEventOnChannelHandler</u></b>
- * <p>
- * Command handler implementation to enable events for a known channel.
- * </p>
- */
-public class EnableEventOnChannelHandler extends BaseEnableEventHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The channel component the command is to be executed on.
- */
- private TraceChannelComponent fChannel = null;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
- fChannel.enableEvents(eventNames, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
- fChannel.enableSyscalls(monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
- fChannel.enableProbe(eventName, isFunction, probe, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
- fChannel.enableLogLevel(eventName, logLevelType, level, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
- */
- @Override
- public TraceDomainComponent getDomain() {
- return (TraceDomainComponent) fChannel.getParent();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- fChannel = null;
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof TraceChannelComponent) {
- // Add only if corresponding TraceSessionComponents is inactive and not destroyed
- TraceChannelComponent channel = (TraceChannelComponent) element;
- TraceSessionComponent session = channel.getSession();
- if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
- fChannel = channel;
- fSession = session;
- }
- }
- }
- }
- return fChannel != null;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>EnableEventOnDomainHandler</u></b>
- * <p>
- * Command handler implementation to enable events for a known domain and default channel 'channel0'
- * (which will be created if doesn't exist).
- * </p>
- */
-public class EnableEventOnDomainHandler extends BaseEnableEventHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The domain component the command is to be executed on.
- */
- private TraceDomainComponent fDomain = null;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
- fDomain.enableEvents(eventNames, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
- fDomain.enableSyscalls(monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
- fDomain.enableProbe(eventName, isFunction, probe, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
- fDomain.enableLogLevel(eventName, logLevelType, level, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
- */
- @Override
- public TraceDomainComponent getDomain() {
- return fDomain;
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- fDomain = null;
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof TraceDomainComponent) {
- // Add only if corresponding TraceSessionComponents is inactive and not destroyed
- TraceDomainComponent domain = (TraceDomainComponent) element;
- TraceSessionComponent session = domain.getSession();
- if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
- fDomain = domain;
- fSession = session;
- }
- }
- }
- }
- return fDomain != null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>EnableEventOnSessionHandler</u></b>
- * <p>
- * Command handler implementation to enable events for a known session and default channel 'channel0'
- * (which will be created if doesn't exist).
- * </p>
- */
-public class EnableEventOnSessionHandler extends BaseEnableEventHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- //-------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
- fSession.enableEvents(eventNames, isKernel, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
- fSession.enableSyscalls(monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
- fSession.enableProbe(eventName, isFunction, probe, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
- fSession.enableLogLevel(eventName, logLevelType, level, monitor);
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
- */
- @Override
- public TraceDomainComponent getDomain() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- fSession = null;
-
- // Check if one session is selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof TraceSessionComponent) {
- // Add only if corresponding TraceSessionComponents is inactive and not destroyed
- TraceSessionComponent session = (TraceSessionComponent) element;
- if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
- fSession = session;
- }
- }
- }
- }
- return fSession != null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.INewConnectionDialog;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>NewConnectionHandler</u></b>
- * <p>
- * Command handler for creation new connection for trace control.
- * </p>
- */
-public class NewConnectionHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * 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.lttng.ui.control.systemType"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The parent trace control component the new node will be added to.
- */
- private ITraceControlComponent fRoot = null;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- assert (fRoot != null);
-
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- return false;
- }
-
- 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 = registry.getHostsBySystemType(sysType);
-
- // Open dialog box for the node name and address
- final INewConnectionDialog dialog = TraceControlDialogFactory.getInstance().getNewConnectionDialog();
- dialog.setTraceControlParent(fRoot);
- dialog.setHosts(hosts);
-
- if (dialog.open() != Window.OK) {
- return null;
- }
-
- String hostName = dialog.getConnectionName();
- String hostAddress = dialog.getHostName();
-
- // get the singleton RSE registry
- IHost host = null;
-
- for (int i = 0; i < hosts.length; i++) {
- if (hosts[i].getAliasName().equals(hostName)) {
- host = hosts[i];
- break;
- }
- }
-
- if (host == null) {
- // if there's no host then we will create it
- try {
- // create the host object as an SSH Only connection
- host = registry.createHost(
- sysType, //System Type Name
- hostName, //Connection name
- hostAddress, //IP Address
- "Connection to Host"); //description //$NON-NLS-1$
- }
- catch (Exception e) {
- MessageDialog.openError(window.getShell(),
- Messages.TraceControl_EclipseCommandFailure,
- Messages.TraceControl_NewNodeCreationFailure + " (" + hostName + ", " + hostAddress + ")" + ":\n" + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return null;
- }
- }
-
- if (host != null) {
- // successful creation of host
- TargetNodeComponent node = null;
- if (!fRoot.containsChild(hostName)) {
- node = new TargetNodeComponent(hostName, fRoot, host);
- fRoot.addChild(node);
- }
- else {
- node = (TargetNodeComponent)fRoot.getChild(hostName);
- }
-
- node.connect();
- }
- return null;
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
-
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- fRoot = null;
-
- // no need to verify part because it has been already done in getWorkbenchPage()
- IWorkbenchPart part = page.getActivePart();
- fRoot = ((ControlView) part).getTraceControlRoot();
-
- return (fRoot != null);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import java.util.Iterator;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>RefreshHandler</u></b>
- * <p>
- * Command handler implementation to refresh node configuration.
- * </p>
- */
-public class RefreshHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The node component reference.
- */
- private TargetNodeComponent fNode;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- fNode.refresh();
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- fNode = null;
-
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- // Check if one or more session are selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
-
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof TraceControlComponent) {
- TraceControlComponent component = (TraceControlComponent) element;
- boolean isConnected = component.getTargetNodeState() == TargetNodeState.CONNECTED;
- if (isConnected) {
- while ((component != null) && component.getClass() != TargetNodeComponent.class) {
- component = (TraceControlComponent) component.getParent();
- }
- if (component != null) {
- fNode = (TargetNodeComponent) component;
- }
- }
- }
- }
- }
- return fNode != null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-
-/**
- * <b><u>StartHandler</u></b>
- * <p>
- * Command handler implementation to start one or more trace sessions.
- * </p>
- */
-public class StartHandler extends ChangeSessionStateHandler {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.ChangeSessionStateHandler#getNewState()
- */
- @Override
- public TraceSessionState getNewState() {
- return TraceSessionState.ACTIVE;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.ChangeSessionStateHandler#changeState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
- session.startSession(monitor);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-
-/**
- * <b><u>StopHandler</u></b>
- * <p>
- * Command handler implementation to stop one or more trace sessions.
- * </p>
- */
-public class StopHandler extends ChangeSessionStateHandler {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.ChangeSessionStateHandler#getNewState()
- */
- @Override
- public TraceSessionState getNewState() {
- return TraceSessionState.INACTIVE;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.ChangeSessionStateHandler#changeState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
- session.stopSession(monitor);
- }
-}
+++ /dev/null
-TraceControl_ConnectionFailure=Connecting to host failed
-TraceControl_DisconnectionFailure=Disconnection to host failed
-TraceControl_ExecutionCancelled=Command Execution cancelled
-TraceControl_ExecutionFailure=Command Execution failed
-TraceControl_ExecutionTimeout=Command Execution timed-out
-TraceControl_ShellNotConnected=Command shell not connected
-TraceControl_CommandShellError=Could not create HostShellProcessAdapter
-TraceControl_CommandError=Command failed! Command:
-TraceControl_UnexpectedCommnadOutputFormat=Unexpected command output
-TraceControl_UnexpectedNameError=Unexpected session name returned
-TraceControl_UnexpectedPathError=Unexpected session path returned
-
-# Commands
-TraceControl_ListSessionFailure=List sessions failed
-TraceControl_RetrieveNodeConfigurationJob=Retrieving Target Node Configuration...
-TraceControl_EclipseCommandFailure=Command failed
-TraceControl_NewNodeCreationFailure=Creation of new connection failed
-TraceControl_CreateSessionJob=Creating Session...
-
-TraceControl_DestroySessionJob=Destroying Session...
-TraceControl_DestroyConfirmationTitle=Destroy Confirmation
-TraceControl_DestroyConfirmationMessage=Do you want to delete all selected sessions?
-
-TraceControl_StartSessionJob=Starting Session...
-TraceControl_StopSessionJob=Stopping Session...
-
-TraceControl_ChangeChannelStateJob=Changing State of Channels...
-TraceControl_ChangeEventStateJob=Changing State of Events...
-
-TraceControl_EnableEventsJob=Enabling Events...
-TraceControl_EnableEventsFailure=Enable Events failed
-TraceControl_DisableEventsJob=Disabling Events...
-
-# Dialogs
-TraceControl_NewDialogTitle=New Connection
-TraceControl_NewNodeExistingConnectionGroupName=Existing Connections
-TraceControl_NewNodeEditButtonName=Edit connection information
-TraceControl_NewNodeComboToolTip=List of existing connections (connection name - host name)
-TraceControl_NewNodeConnectionNameLabel=Connection Name
-TraceControl_NewNodeConnectionNameTooltip=Alias to be displayed for node to connect to.
-TraceControl_NewNodeHostNameLabel=Host Name
-TraceControl_NewNodeHostNameTooltip=IP Address or DNS name of node to connect to.
-TraceControl_AlreadyExistsError=Node name already exists in Control View
-
-TraceControl_CreateSessionDialogTitle=Create Session
-TraceControl_CreateSessionNameLabel=Session Name
-TraceControl_CreateSessionNameTooltip=The name of the session to be created.
-TraceControl_CreateSessionPathLabel=Session Path
-TraceControl_CreateSessionPathTooltip=The session path (keep empty for default location)
-TraceControl_InvalidSessionNameError=The session name is invalid
-TraceControl_SessionAlreadyExistsError=The session name already exists
-TraceControl_SessionPathAlreadyExistsError=Session path already exists
-TraceControl_InvalidSessionPathError=The session path is invalid
-TraceControl_FileSubSystemError=File subsystem error in session creation dialog.
-
-TraceControl_EnableChannelDialogTitle=Enable Channel
-TraceControl_EnableChannelNameLabel=Channel Name
-TraceControl_EnableChannelNameTooltip=The name of the channel to be enabled.
-TraceControl_EnableChannelSubBufferSizeTooltip=The sub-buffers size of the channel.
-TraceControl_EnableChannelNbSubBuffersTooltip=The number of sub-buffers of the channel.
-TraceControl_EnableChannelSwitchTimerTooltip=The switch timer interval in usec.
-TraceControl_EnableChannelReadTimerTooltip=The switch timer interval in usec.
-TraceControl_EnableChannelOutputTypeTooltip=The output type of the channel.
-TraceControl_EnableChannelOverwriteModeTooltip=Select for overwrite mode (Flight recorder mode).
-
-TraceControl_InvalidChannelNameError=The channel name is invalid or empty
-TraceControl_ChannelAlreadyExistsError=Channel already exists
-
-TraceControl_EnableEventsDialogTitle=Enable Events
-TraceControl_EnableEventsSessionGroupName=Session List
-TraceControl_EnableEventsChannelGroupName=Channel List
-TraceControl_EnableEventsSessionsTooltip=List of available sessions.
-TraceControl_EnableEventsChannelsTooltip=List of available channels of selected session.\nIf no channel is available default channel will be created.
-TraceControl_EnableEventsNoSessionError=No session from session list is selected.
-TraceControl_EnableEventsNoChannelError=No channel from channel list is selected.
-
-TraceControl_EnableGroupSelectionName=Select
-TraceControl_EnableEventsTracepointGroupName=Tracepoint Events
-TraceControl_EnableEventsTracepointTreeTooltip=List of available kernel tracepoint events
-TraceControl_EnableEventsTracepointTreeAllLabel=All
-TraceControl_EnableEventsSyscallName=All Syscalls
-TraceControl_EnableEventsSyscallTooltip=Enable all Syscalls
-TraceControl_EnableEventsProbeGroupName=Dynamic Probe
-TraceControl_EnableEventsEventNameLabel=Event Name
-TraceControl_EnableEventsProbeEventNameTooltip=The name of the event for enabling a dynamic probe
-TraceControl_EnableEventsProbeNameLabel=Probe
-TraceControl_EnableEventsProbeNameTooltip=[addr | symbol | symbol+offset]\nAddr and offset can be octal (0NNN...),\ndecimal (NNN...) or hexadecimal (0xNNN...)
-TraceControl_EnableEventsFucntionGroupName=Dynamic Function Entry/Return Probe
-TraceControl_EnableEventsFunctionEventNameTooltip=The name of the event for enabling a dynamic function entry/return probe
-TraceControl_EnableEventsFunctionNameLabel=Function
-
-TraceControl_EnableEventsWildcardGroupName=Wildcard
-TraceControl_EnableEventsWildcardLabel=Wildcard
-TraceControl_EnableEventsWildcardTooltip=The wild card string of event names
-TraceControl_EnableEventsLogLevelGroupName=Log Level
-TraceControl_EnableEventsLogLevelTypeName=loglevel
-TraceControl_EnableEventsLogLevelTypeTooltip=The tracepoint log level range from 0 to loglevel
-TraceControl_EnableEventsLogLevelOnlyTypeName=loglevel-only
-TraceControl_EnableEventsLogLevelOnlyTypeTooltip=The tracepoint log level (only this loglevel)
-TraceControl_EnableEventsLogLevelTooltip=The available log levels
-TraceControl_EnableEventsLoglevelEventNameTooltip=Event name for enabling log levels
-
-TraceControl_InvalidProbeNameError=The probe name is invalid
-TraceControl_InvalidWildcardError=The wild card name is invalid
-TraceControl_InvalidLogLevelEventNameError=The event name for log level is invalid
-
-# Tree structure strings
-TraceControl_KernelDomainDisplayName=Kernel
-TraceControl_UstGlobalDomainDisplayName=UST global
-TraceControl_UstDisplayName=UST
-TraceControl_AllSessionsDisplayName=Sessions
-TraceControl_SessionDisplayName=Session
-TraceControl_DomainDisplayName=Domain
-TraceControl_ChannelDisplayName=Channel
-TraceControl_EventDisplayName=Event
-TraceControl_ProviderDisplayName=Provider
-TraceControl_KernelProviderDisplayName=Kernel
-
-# Property names
-TraceControl_SessionNamePropertyName=Session Name
-TraceControl_EventNamePropertyName=Event Name
-TraceControl_EventTypePropertyName=Event Type
-TraceControl_LogLevelPropertyName=Log Level
-TraceControl_StatePropertyName=State
-TraceControl_DomainNamePropertyName=Domain Name
-TraceControl_ChannelNamePropertyName=Channel Name
-TraceControl_OverwriteModePropertyName=Overwrite Mode
-TraceControl_SubBufferSizePropertyName=Sub Buffer Size
-TraceControl_NbSubBuffersPropertyName=Number of Sub Buffers
-TraceControl_SwitchTimerPropertyName=Switch Timer Interval
-TraceControl_ReadTimerPropertyName=Read Timer Interval
-TraceControl_OutputTypePropertyName=Output Type
-TraceControl_HostNamePropertyName=Connection Name
-TraceControl_HostAddressPropertyName=Host Name
-TraceControl_SessionPathPropertyName=Session Path
-TraceControl_ProviderNamePropertyName=Provider Name
-TraceControl_ProcessIdPropertyName=Process ID
-TraceControl_ProbeAddressPropertyName=Address
-TraceControl_ProbeOffsetPropertyName=Offset
-TraceControl_ProbeSymbolPropertyName=Symbol
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>IBaseEventInfo</u></b>
- * <p>
- * Interface for retrieval of basic trace event information.
- * </p>
- */
-public interface IBaseEventInfo extends ITraceInfo {
-
- /**
- * @return the trace event type
- */
- public TraceEventType getEventType();
-
- /**
- * Sets the trace event type to the given type
- * @param type - type to set
- */
- public void setEventType(TraceEventType type);
-
- /**
- * Sets the trace event type to the type specified by the given name.
- * @param typeName - event type name
- */
- public void setEventType(String typeName);
-
- /**
- * @return the trace event log level
- */
- public TraceLogLevel getLogLevel();
-
- /**
- * Sets the trace event log level to the given level
- * @param level - event log level to set
- */
- public void setLogLevel(TraceLogLevel level);
-
- /**
- * Sets the trace event log level to the level specified by the given name.
- * @param levelName - event log level name
- */
- public void setLogLevel(String levelName);
-
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-import java.util.List;
-
-/**
- * <b><u>IChannelInfo</u></b>
- * <p>
- * Interface for retrieval of trace channel information.
- * </p>
- */
-public interface IChannelInfo extends ITraceInfo {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * Default value for overwrite mode.
- */
- public final static boolean DEFAULT_OVERWRITE_MODE = false;
- /**
- * Default value for sub-buffer size for a UST channel.
- */
- public final static long DEFAULT_SUB_BUFFER_SIZE_UST = 4096L;
- /**
- * Default value for sub-buffer size for a Kernel channel.
- */
- public final static long DEFAULT_SUB_BUFFER_SIZE_KERNEL = 262144L;
- /**
- * Default value for number of sub-buffer a UST channel.
- */
- public final static int DEFAULT_NUMBER_OF_SUB_BUFFERS_UST = 8;
- /**
- * Default value for number of sub-buffer a Kernel channel.
- */
- public final static int DEFAULT_NUMBER_OF_SUB_BUFFERS_KERNEL = 4;
- /**
- * Default value for number of the switch timer interval.
- */
- public final static long DEFAULT_SWITCH_TIMER = 0;
- /**
- * Default value for number of the read timer interval.
- */
- public final static long DEFAULT_READ_TIMER = 200;
-
- /**
- * @return the overwrite mode value.
- */
- public boolean isOverwriteMode();
- /**
- * Sets the overwrite mode value to the given mode.
- * @param mode - mode to set.
- */
- public void setOverwriteMode(boolean mode);
-
- /**
- * @return the sub-buffer size.
- */
- public long getSubBufferSize();
- /**
- * Sets the sub-buffer size to the given value.
- * @param bufferSize - size to set to set.
- */
- public void setSubBufferSize(long bufferSize);
-
- /**
- * @return the number of sub-buffers.
- */
- public int getNumberOfSubBuffers();
- /**
- * Sets the number of sub-buffers to the given value.
- * @param numberOfSubBuffers - value to set.
- */
- public void setNumberOfSubBuffers(int numberOfSubBuffers);
-
- /**
- * @return the switch timer interval.
- */
- public long getSwitchTimer();
- /**
- * Sets the switch timer interval to the given value.
- * @param timer - timer value to set.
- */
- public void setSwitchTimer(long timer);
-
- /**
- * @return the read timer interval.
- */
- public long getReadTimer();
- /**
- * Sets the read timer interval to the given value.
- * @param timer - timer value to set..
- */
- public void setReadTimer(long timer);
-
- /**
- * @return the output type.
- */
- public String getOutputType();
- /**
- * Sets the output type to the given value.
- * @param type - type to set.
- */
- public void setOutputType(String type);
-
- /**
- * @return the channel state (enabled or disabled).
- */
- public TraceEnablement getState();
- /**
- * Sets the channel state (enablement) to the given value.
- * @param state - state to set.
- */
- public void setState(TraceEnablement state);
- /**
- * Sets the channel state (enablement) to the value specified by the given name.
- * @param stateName - state to set.
- */
- public void setState(String stateName);
-
- /**
- * @return all event information as array.
- */
- public IEventInfo[] getEvents();
- /**
- * Sets the event information specified by given list.
- * @param events - all event information to set.
- */
- public void setEvents(List<IEventInfo> events);
- /**
- * Adds a single event information.
- * @param event - event information to add.
- */
- public void addEvent(IEventInfo event);
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-import java.util.List;
-
-/**
- * <b><u>IDomainInfo</u></b>
- * <p>
- * Interface for retrieval of trace domain information.
- * </p>
- */
-
-public interface IDomainInfo extends ITraceInfo {
-
- /**
- * @return information about all channels
- */
- public IChannelInfo[] getChannels();
-
- /**
- * Sets the channel information specified by given list.
- * @param channels - all channel information to set.
- */
- public void setChannels(List<IChannelInfo> channels);
-
- /**
- * Adds a single channel information.
- * @param channel - channel information to add.
- */
- public void addChannel(IChannelInfo channel);
-
- /**
- * @return true if domain is kernel, false for UST
- */
- public boolean isKernel();
-
- /**
- * Sets whether domain is Kernel domain or UST
- * @param isKernel true for kernel, false for UST
- */
- public void setIsKernel(boolean isKernel);
-
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>IEventInfo</u></b>
- * <p>
- * Interface for retrieval of trace event information.
- * </p>
- */
-public interface IEventInfo extends IBaseEventInfo {
-
- /**
- * @return the event state (enabled or disabled).
- */
- public TraceEnablement getState();
-
- /**
- * Sets the event state (enablement) to the given value.
- * @param state - state to set.
- */
- public void setState(TraceEnablement state);
-
- /**
- * Sets the event state (enablement) to the value specified by the given name.
- * @param stateName - state to set.
- */
- public void setState(String stateName);
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>IProbeEventInfo</u></b>
- * <p>
- * Interface for retrieval of probe event information.
- * </p>
- */
-public interface IProbeEventInfo extends IEventInfo {
-
- /**
- * @return the address of the probe. (null if not used)
- */
- public String getAddress();
-
- /**
- * Sets the address of the probe.
- * @param address - a address (null if not used)
- */
- public void setAddress(String address);
-
- /**
- * @return the offset applied to the symbol (null if not used).
- */
- public String getOffset();
-
- /**
- * Sets the offset applied to the symbol.
- * @param offset - a offset ((null if not used)
- */
- public void setOffset(String offset);
-
- /**
- * @return the symbol name. ((null if not used))
- */
- public String getSymbol();
-
- /**
- * Sets the symbol name.
- * @param symbol - a symbol name ((null if not used))
- */
- public void setSymbol(String symbol);
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-import java.util.List;
-
-/**
- * <b><u>ISessionInfo</u></b>
- * <p>
- * Interface for retrieval of trace session information.
- * </p>
- */
-public interface ISessionInfo extends ITraceInfo {
-
- /**
- * @return the session state state (active or inactive).
- */
- public TraceSessionState getSessionState();
- /**
- * Sets the session state to the given value.
- * @param state - state to set.
- */
- public void setSessionState(TraceSessionState state);
-
- /**
- * Sets the event state to the value specified by the given name.
- * @param stateName - state to set.
- */
- public void setSessionState(String stateName);
-
- /**
- * @return path string where session is located.
- */
- public String getSessionPath();
-
- /**
- * Sets the path string (where session is located) to the given value.
- * @param path - session path to set.
- */
- public void setSessionPath(String path);
-
- /**
- * @return all domain information as array.
- */
- public IDomainInfo[] getDomains();
-
- /**
- * Sets all domain information specified by given list.
- * @param domains - all domain information to set.
- */
- public void setDomains(List<IDomainInfo> domains);
-
- /**
- * Adds a single domain information.
- * @param domain - domain information to add.
- */
- public void addDomain(IDomainInfo domainInfo);
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * <b><u>ITraceControlComponent</u></b>
- * <p>
- * Interface for trace control components that can be displayed in the
- * trace control tree viewer.
- * </p>
- */
-public interface ITraceControlComponent extends IAdaptable {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return the name of the component
- */
- public String getName();
- /**
- * Sets the name of the component to the given value.
- * @param name - name to set
- */
- public void setName(String name);
-
- /**
- * @return the image representing the component.
- */
- public Image getImage();
- /**
- * Sets the image path of the component.
- * @param path - path to the image location
- */
- public void setImage(String path);
- /**
- * Sets the image the component.
- * @param image - image to the image location
- */
- public void setImage(Image image);
-
- /**
- * @return tool tip with information about the component.
- */
- public String getToolTip();
- /**
- * Sets the tool tip with information about the component.
- * @param toolTip - the tool tip to set.
- */
- public void setToolTip(String toolTip);
-
- /**
- * @return the node's connection state
- */
- public TargetNodeState getTargetNodeState();
- /**
- * Sets the node's connection state.
- * @param state - the state to set
- */
- public void setTargetNodeState(TargetNodeState state);
-
- /**
- * @return returns the parent component.
- */
- public ITraceControlComponent getParent();
- /**
- * Sets the parent component.
- * @param parent - the parent to set.
- */
- public void setParent(ITraceControlComponent parent);
-
- /**
- * @return the children components
- */
- public ITraceControlComponent[] getChildren();
- /**
- * Sets the children components.
- * @param children - the children to set.
- */
- public void setChildren(List<ITraceControlComponent> children);
- /**
- * Returns the child component with given name.
- * @param name - name of child to find.
- * @return child component or null.
- */
- public ITraceControlComponent getChild(String name);
- /**
- * Gets children for given class type.
- * @param clazz - a class type to get
- * @return list of trace control components matching given class type.
- */
- public List<ITraceControlComponent> getChildren(Class<? extends ITraceControlComponent> clazz);
-
- /**
- * @return the LTTng control service implementation.
- */
- public ILttngControlService getControlService();
-
- /**
- * Sets the LTTng control service implementation.
- * @param service - the service to set.
- */
- public void setControlService(ILttngControlService service);
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Dispose any resource.
- */
- public void dispose();
-
- /**
- * Adds a child component.
- * @param component - child to add.
- */
- public void addChild(ITraceControlComponent component);
-
- /**
- * Removes the given child component.
- * @param component - the child to remove.
- */
- public void removeChild(ITraceControlComponent component);
-
- /**
- * Removes all children.
- */
- public void removeAllChildren();
-
- /**
- * Checks if child with given name exists.
- * @param name - child name to search for.
- * @return - true if exists else false.
- */
- public boolean containsChild(String name);
-
- /**
- * Checks for children.
- * @return true if one or more children exist else false
- */
- public boolean hasChildren();
-
- /**
- * Adds a component listener for notification of component changes.
- * @param listener - listener interface implementation to add.
- */
- public void addComponentListener(ITraceControlComponentChangedListener listener);
-
- /**
- * Removes a component listener for notification of component changes.
- * @param listener - listener interface implementation to remove.
- */
- public void removeComponentListener(ITraceControlComponentChangedListener listener);
-
- /**
- * Notifies listeners about the addition of a child.
- * @param parent - the parent where the child was added.
- * @param component - the child that was added.
- */
- public void fireComponentAdded(ITraceControlComponent parent, ITraceControlComponent component);
-
- /**
- * Notifies listeners about the removal of a child.
- * @param parent - the parent where the child was removed.
- * @param component - the child that was removed.
- */
- public void fireComponentRemoved(ITraceControlComponent parent, ITraceControlComponent component);
-
- /**
- * Notifies listeners about the change of a component.
- * @param component - the component that was changed.
- */
- public void fireComponentChanged(ITraceControlComponent component);
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>ITraceControlComponentChangedListener</u></b>
- * <p>
- * Listener interface a class can implement to be notified about changes
- * of components
- * </p>
- */
-public interface ITraceControlComponentChangedListener {
- /**
- * Interface for notifications about the addition of a component.
- * @param parent - the parent where the child was added.
- * @param component - the child that was added.
- */
- public void componentAdded(ITraceControlComponent parent, ITraceControlComponent component);
-
- /**
- * Interface for notifications about the removal of a child.
- * @param parent - the parent where the child was removed.
- * @param component - the child that was removed.
- */
- public void componentRemoved(ITraceControlComponent parent, ITraceControlComponent component);
- /**
- * NInterface for notifications about the change of a component.
- * @param component - the component that was changed.
- */
- public void componentChanged(ITraceControlComponent component);
-}
-
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>ITraceInfo</u></b>
- * <p>
- * Interface for retrieve trace comon information.
- * </p>
- */
-
-public interface ITraceInfo {
- /**
- * @return the name of the information element.
- */
- public String getName();
-
- /**
- * Sets the name of the information element.
- * @param name
- */
- public void setName(String name);
-
- /**
- * @return a formated (readable) String with content.
- */
- public String formatString();
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-import java.util.List;
-
-/**
- * <b><u>IUstProviderInfo</u></b>
- * <p>
- * Interface for retrieval of UST provider information.
- * </p>
- */
-public interface IUstProviderInfo extends ITraceInfo {
-
- /**
- * @return the process ID of the UST provider.
- */
- public int getPid();
-
- /**
- * Sets the process ID of the UST provider to the given value.
- * @param pid - process ID to set
- */
- public void setPid(int pid);
-
- /**
- * @return all event information as array.
- */
- public IBaseEventInfo[] getEvents();
-
- /**
- * Sets the event information specified by given list.
- * @param events - all event information to set.
- */
- public void setEvents(List<IBaseEventInfo> events);
-
- /**
- * Adds a single event information.
- * @param event - event information to add.
- */
- public void addEvent(IBaseEventInfo event);
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- *********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>LogLevelType</u></b>
- * <p>
- * Type of log Level enumeration.
- * </p>
- */
-public enum LogLevelType {
-
- // ------------------------------------------------------------------------
- // Enum definition
- // ------------------------------------------------------------------------
- LOGLEVEL, // range of log levels [0,logLevel]
- LOGLEVEL_ONLY, // single log level
- LOGLEVEL_NONE; // no log level
-};
-
-
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>TargetNodeState</u></b>
- * <p>
- * Enumeration for the node connection state.
- * </p>
- */
-public enum TargetNodeState {
- DISCONNECTED,
- DISCONNECTING,
- CONNECTED,
- CONNECTING;
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>TraceEnablement</u></b>
- * <p>
- * Enumeration for enabled/disabled states.
- * </p>
- */
-public enum TraceEnablement {
-
- // ------------------------------------------------------------------------
- // Enum definition
- // ------------------------------------------------------------------------
- DISABLED("disabled"), //$NON-NLS-1$
- ENABLED("enabled"); //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * Name of enum
- */
- private final String fInName;
-
- // ------------------------------------------------------------------------
- // Constuctors
- // ------------------------------------------------------------------------
-
- /**
- * Private constructor
- * @param name the name of state
- */
- private TraceEnablement(String name) {
- fInName = name;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return state name
- */
- public String getInName() {
- return fInName;
- }
-};
-
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>TraceEventType</u></b>
- * <p>
- * Trace event type enumeration.
- * </p>
- */
-public enum TraceEventType {
- TRACEPOINT("tracepoint"), //$NON-NLS-1$
- SYSCALL("syscall"), //$NON-NLS-1$
- PROBE("probe"), //$NON-NLS-1$
- UNKNOWN("unknown"); //$NON-NLS-1$
-
- private final String fInName;
-
- private TraceEventType(String name) {
- fInName = name;
- }
-
- public String getInName() {
- return fInName;
- }
-};
-
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- *********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>TraceLogLevels</u></b>
- * <p>
- * Log Level enumeration.
- * </p>
- */
-@SuppressWarnings("nls")
-public enum TraceLogLevel {
-
- // ------------------------------------------------------------------------
- // Enum definition
- // ------------------------------------------------------------------------
- TRACE_EMERG("TRACE_EMERG"), // 0
- TRACE_ALERT("TRACE_ALERT"), // 1
- TRACE_CRIT("TRACE_CRIT"), // 2
- TRACE_ERR("TRACE_ERR"), // 3
- TRACE_WARNING("TRACE_WARNING"), // 4
- TRACE_NOTICE("TRACE_NOTICE"), // 5
- TRACE_INFO("TRACE_INFO"), // 6
- TRACE_DEBUG_SYSTEM("TRACE_DEBUG_SYSTEM"), // 7
- TRACE_DEBUG_PROGRAM("TRACE_DEBUG_PROGRAM"), // 8
- TRACE_DEBUG_PROCESS("TRACE_DEBUG_PROCESS"), // 9
- TRACE_DEBUG_MODULE("TRACE_DEBUG_MODULE"), // 10
- TRACE_DEBUG_UNIT("TRACE_DEBUG_UNIT"), // 11
- TRACE_DEBUG_FUNCTION("TRACE_DEBUG_FUNCTION"), //12
- TRACE_DEBUG_LINE("TRACE_DEBUG_LINE"), //13
- TRACE_DEBUG("TRACE_DEBUG"), // 14
- LEVEL_UNKNOWN("LEVEL_UNKNOWN"); // 15
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * Name of enum.
- */
- private final String fInName;
-
- // ------------------------------------------------------------------------
- // Constuctors
- // ------------------------------------------------------------------------
-
- /**
- * Private constructor
- * @param name the name of state
- */
- private TraceLogLevel(String name) {
- fInName = name;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return state name
- */
- public String getInName() {
- return fInName;
- }
-};
-
-
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- *********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model;
-
-/**
- * <b><u>TraceSessionState</u></b>
- * <p>
- * Session state enumeration.
- * </p>
- */
-public enum TraceSessionState {
-
- // ------------------------------------------------------------------------
- // Enum definition
- // ------------------------------------------------------------------------
- INACTIVE("inactive"), //$NON-NLS-1$
- ACTIVE("active"); //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * Name of enum.
- */
- private final String fInName;
-
- // ------------------------------------------------------------------------
- // Constuctors
- // ------------------------------------------------------------------------
-
- /**
- * Private constructor
- * @param name the name of state
- */
- private TraceSessionState(String name) {
- fInName = name;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return state name
- */
- public String getInName() {
- return fInName;
- }
-};
-
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BaseEventPropertySource;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * <b><u>BaseEventComponent</u></b>
- * <p>
- * Implementation of the base trace event component.
- * </p>
- */
-public class BaseEventComponent extends TraceControlComponent {
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * 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.
- */
- private IBaseEventInfo fEventInfo;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- * @param name - the name of the component.
- * @param parent - the parent of this component.
- */
- public BaseEventComponent(String name, ITraceControlComponent parent) {
- super(name, parent);
- setImage(TRACE_EVENT_ICON_FILE_ENABLED);
- fEventInfo = new EventInfo(name);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * Sets the event information.
- * @param eventInfo - the event info to set.
- */
- 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 void setEventType(String typeName) {
- fEventInfo.setEventType(typeName);
- }
-
- /**
- * @return the trace event log level
- */
- public TraceLogLevel getLogLevel() {
- return fEventInfo.getLogLevel();
- }
-
- /**
- * 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
- */
- public void setLogLevel(String levelName) {
- fEventInfo.setLogLevel(levelName);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.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.
- */
- public TargetNodeComponent getTargetNode() {
- return (TargetNodeComponent) getParent().getParent();
- }
-
- /**
- * @return if provider kernel or UST
- */
- public boolean isKernel() {
- return getParent() instanceof KernelProviderComponent;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-
-/**
-* <b><u>BaseEventInfo</u></b>
-* <p>
-* Implementation of the basic trace event interface (IEventInfo) to store event
-* related data.
-* </p>
-*/
-public class BaseEventInfo extends TraceInfo implements IBaseEventInfo {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The trace event type.
- */
- private TraceEventType fEventType = TraceEventType.UNKNOWN;
- /**
- * The trace log level.
- */
- private TraceLogLevel fLogLevel = TraceLogLevel.TRACE_DEBUG;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - name of base event
- */
- public BaseEventInfo(String name) {
- super(name);
- }
-
- /**
- * Copy constructor
- * @param other - the instance to copy
- */
- public BaseEventInfo(BaseEventInfo other) {
- super(other);
- fEventType = other.fEventType;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo#getEventType()
- */
- @Override
- public TraceEventType getEventType() {
- return fEventType;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo#setEventType(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType)
- */
- @Override
- public void setEventType(TraceEventType type) {
- fEventType = type;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo#setEventType(java.lang.String)
- */
- @Override
- public void setEventType(String typeName) {
- if(TraceEventType.TRACEPOINT.getInName().equals(typeName)) {
- fEventType = TraceEventType.TRACEPOINT;
- } else if(TraceEventType.SYSCALL.getInName().equals(typeName)) {
- fEventType = TraceEventType.SYSCALL;
- } else if (TraceEventType.PROBE.getInName().equals(typeName)) {
- fEventType = TraceEventType.PROBE;
- } else {
- fEventType = TraceEventType.UNKNOWN;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo#getLogLevel()
- */
- @Override
- public TraceLogLevel getLogLevel() {
- return fLogLevel;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo#setLogLevel(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel)
- */
- @Override
- public void setLogLevel(TraceLogLevel level) {
- fLogLevel = level;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo#setLogLevel(java.lang.String)
- */
- @Override
- public void setLogLevel(String levelName) {
- if(TraceLogLevel.TRACE_EMERG.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_EMERG;
- } else if(TraceLogLevel.TRACE_ALERT.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_ALERT;
- } else if(TraceLogLevel.TRACE_CRIT.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_CRIT;
- } else if(TraceLogLevel.TRACE_ERR.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_ERR;
- } else if(TraceLogLevel.TRACE_WARNING.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_WARNING;
- } else if(TraceLogLevel.TRACE_NOTICE.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_NOTICE;
- } else if(TraceLogLevel.TRACE_INFO.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_INFO;
- } else if(TraceLogLevel.TRACE_DEBUG_SYSTEM.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_DEBUG_SYSTEM;
- } else if(TraceLogLevel.TRACE_DEBUG_PROGRAM.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_DEBUG_PROGRAM;
- } else if(TraceLogLevel.TRACE_DEBUG_PROCESS.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_DEBUG_PROCESS;
- } else if(TraceLogLevel.TRACE_DEBUG_MODULE.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_DEBUG_MODULE;
- } else if(TraceLogLevel.TRACE_DEBUG_UNIT.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_DEBUG_UNIT;
- } else if(TraceLogLevel.TRACE_DEBUG_FUNCTION.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_DEBUG_FUNCTION;
- } else if(TraceLogLevel.TRACE_DEBUG_LINE.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_DEBUG_LINE;
- } else if(TraceLogLevel.TRACE_DEBUG.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.TRACE_DEBUG;
- } else if(TraceLogLevel.LEVEL_UNKNOWN.getInName().equals(levelName)) {
- fLogLevel = TraceLogLevel.LEVEL_UNKNOWN;
- } else {
- fLogLevel = TraceLogLevel.TRACE_DEBUG;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#formatString()
- */
- @SuppressWarnings("nls")
- @Override
- public String formatString() {
- StringBuffer output = new StringBuffer();
- // ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)");
- output.append("\n ");
- output.append(getName());
- if (fLogLevel != TraceLogLevel.LEVEL_UNKNOWN) {
- output.append(" (loglevel: ");
- output.append(fLogLevel.getInName());
- output.append(" (");
- output.append(fLogLevel.ordinal());
- output.append("))");
- }
- output.append(" (type: ");
- output.append(fEventType.getInName());
- output.append(")");
- return output.toString();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((fEventType == null) ? 0 : (fEventType.ordinal() + 1));
- result = prime * result + ((fLogLevel == null) ? 0 : (fLogLevel.ordinal() + 1));
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- BaseEventInfo other = (BaseEventInfo) obj;
- if (fEventType != other.fEventType) {
- return false;
- }
- if (fLogLevel != other.fLogLevel) {
- return false;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#toString()
- */
- @SuppressWarnings("nls")
- @Override
- public String toString() {
- StringBuffer output = new StringBuffer();
- output.append("[BaseEventInfo(");
- output.append(super.toString());
- output.append(",type=");
- output.append(fEventType);
- output.append(",level=");
- output.append(fLogLevel);
- output.append(")]");
- return output.toString();
- }
-
-
-
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-
-/**
- * <b><u>ChannelInfo</u></b>
- * <p>
- * Implementation of the trace channel interface (IChannelInfo) to store channel
- * related data.
- * </p>
- */
-public class ChannelInfo extends TraceInfo implements IChannelInfo {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The overwrite mode of the channel.
- */
- private boolean fOverwriteMode;
- /**
- * The sub-buffer size of the channel.
- */
- private long fSubBufferSize;
- /**
- * The number of sub-buffers of the channel.
- */
- private int fNumberOfSubBuffers;
- /**
- * The switch timer interval of the channel.
- */
- private long fSwitchTimer;
- /**
- * The read timer interval of the channel.
- */
- private long fReadTimer;
- /**
- * The Output type of the channel.
- */
- private String fOutputType = ""; //$NON-NLS-1$
- /**
- * The channel enable state.
- */
- private TraceEnablement fState = TraceEnablement.DISABLED;
- /**
- * The events information of the channel.
- */
- private List<IEventInfo> fEvents = new ArrayList<IEventInfo>();
-
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - name channel
- */
- public ChannelInfo(String name) {
- super(name);
- }
-
- /**
- * Copy constructor
- * @param other - the instance to copy
- */
- public ChannelInfo(ChannelInfo other) {
- super(other);
- fOverwriteMode = other.fOverwriteMode;
- fSubBufferSize = other.fSubBufferSize;
- fNumberOfSubBuffers = other.fNumberOfSubBuffers;
- fSwitchTimer = other.fSwitchTimer;
- fReadTimer = other.fReadTimer;
- fOutputType = (other.fOutputType == null ? null : String.valueOf(other.fOutputType));
- fState = other.fState;
- for (Iterator<IEventInfo> iterator = other.fEvents.iterator(); iterator.hasNext();) {
- IEventInfo event = iterator.next();
- if (event instanceof EventInfo) {
- fEvents.add(new EventInfo((EventInfo)event));
- } else {
- fEvents.add(event);
- }
- }
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#getOverwriteMode()
- */
- @Override
- public boolean isOverwriteMode() {
- return fOverwriteMode;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#setOverwriteMode(boolean)
- */
- @Override
- public void setOverwriteMode(boolean mode) {
- fOverwriteMode = mode;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#getSubBufferSize()
- */
- @Override
- public long getSubBufferSize() {
- return fSubBufferSize;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#setSubBufferSize(long)
- */
- @Override
- public void setSubBufferSize(long bufferSize) {
- fSubBufferSize = bufferSize;
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#getNumberOfSubBuffers()
- */
- @Override
- public int getNumberOfSubBuffers() {
- return fNumberOfSubBuffers;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#setNumberOfSubBuffers(int)
- */
- @Override
- public void setNumberOfSubBuffers(int numberOfSubBuffers) {
- fNumberOfSubBuffers = numberOfSubBuffers;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#getSwitchTimer()
- */
- @Override
- public long getSwitchTimer() {
- return fSwitchTimer;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#setSwitchTimer(long)
- */
- @Override
- public void setSwitchTimer(long timer) {
- fSwitchTimer = timer;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#getReadTimer()
- */
- @Override
- public long getReadTimer() {
- return fReadTimer;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#setReadTimer(long)
- */
- @Override
- public void setReadTimer(long timer) {
- fReadTimer = timer;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#getOutputType()
- */
- @Override
- public String getOutputType() {
- return fOutputType;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#setOutputType(java.lang.String)
- */
- @Override
- public void setOutputType(String type) {
- fOutputType = type;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#getState()
- */
- @Override
- public TraceEnablement getState() {
- return fState;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#setState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement)
- */
- @Override
- public void setState(TraceEnablement state) {
- fState = state;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#setState(java.lang.String)
- */
- @Override
- public void setState(String stateName) {
- fState = TraceEnablement.ENABLED;
- if (TraceEnablement.DISABLED.getInName().equals(stateName)) {
- fState = TraceEnablement.DISABLED;
- } else if (TraceEnablement.ENABLED.getInName().equals(stateName)) {
- fState = TraceEnablement.ENABLED;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#getEvents()
- */
- @Override
- public IEventInfo[] getEvents() {
- return fEvents.toArray(new IEventInfo[fEvents.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#setEvents(java.util.List)
- */
- @Override
- public void setEvents(List<IEventInfo> events) {
- for (Iterator<IEventInfo> iterator = events.iterator(); iterator.hasNext();) {
- IEventInfo eventInfo = (IEventInfo) iterator.next();
- fEvents.add(eventInfo);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo#addEvent(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo)
- */
- @Override
- public void addEvent(IEventInfo channel) {
- fEvents.add(channel);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#formatString()
- */
- @SuppressWarnings("nls")
- @Override
- public String formatString() {
- StringBuffer output = new StringBuffer();
- //- channel0: [enabled]
- output.append("\n- ");
- output.append(getName());
- output.append(": [");
- output.append(getState().getInName());
- output.append("]\n");
- // Attributes:
- output.append("\n Attributes:\n");
- // overwrite mode: 0
- output.append(" overwrite mode: ");
- output.append(isOverwriteMode() ? "1" : "0");
- // subbufers size: 262144
- output.append("\n subbufers size: ");
- output.append(getSubBufferSize());
- // number of subbufers: 4
- output.append("\n number of subbufers: ");
- output.append(getNumberOfSubBuffers());
- // switch timer interval: 0
- output.append("\n switch timer interval: ");
- output.append(getSwitchTimer());
- // read timer interval: 200
- output.append("\n read timer interval: ");
- output.append(getReadTimer());
- // output: splice()
- output.append("\n output: ");
- output.append(getOutputType());
- output.append("\n\n");
-
- output.append(" Events:");
- if (fEvents.isEmpty()) {
- output.append("\n None");
- } else {
- for (Iterator<IEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
- IEventInfo event = (IEventInfo) iterator.next();
- output.append(event.formatString());
- }
- }
- output.append("\n");
-
- return output.toString();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((fEvents == null) ? 0 : fEvents.hashCode());
- result = prime * result + fNumberOfSubBuffers;
- result = prime * result + ((fOutputType == null) ? 0 : fOutputType.hashCode());
- result = prime * result + (fOverwriteMode ? 1231 : 1237);
- result = prime * result + (int) (fReadTimer ^ (fReadTimer >>> 32));
- result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
- result = prime * result + (int) (fSubBufferSize ^ (fSubBufferSize >>> 32));
- result = prime * result + (int) (fSwitchTimer ^ (fSwitchTimer >>> 32));
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ChannelInfo other = (ChannelInfo) obj;
- if (fEvents == null) {
- if (other.fEvents != null) {
- return false;
- }
- } else if (!fEvents.equals(other.fEvents)) {
- return false;
- }
- if (fNumberOfSubBuffers != other.fNumberOfSubBuffers) {
- return false;
- }
- if (fOutputType == null) {
- if (other.fOutputType != null) {
- return false;
- }
- } else if (!fOutputType.equals(other.fOutputType)) {
- return false;
- }
- if (fOverwriteMode != other.fOverwriteMode) {
- return false;
- }
- if (fReadTimer != other.fReadTimer) {
- return false;
- }
- if (fState != other.fState) {
- return false;
- }
- if (fSubBufferSize != other.fSubBufferSize) {
- return false;
- }
- if (fSwitchTimer != other.fSwitchTimer) {
- return false;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#toString()
- */
- @SuppressWarnings("nls")
- @Override
- public String toString() {
- StringBuffer output = new StringBuffer();
- output.append("[ChannelInfo(");
- output.append(super.toString());
- output.append(",State=");
- output.append(fState);
- output.append(",OverwriteMode=");
- output.append(fOverwriteMode);
- output.append(",SubBuffersSize=");
- output.append(fSubBufferSize);
- output.append(",NumberOfSubBuffers=");
- output.append(fNumberOfSubBuffers);
- output.append(",SwitchTimer=");
- output.append(fSwitchTimer);
- output.append(",ReadTimer=");
- output.append(fReadTimer);
- output.append(",output=");
- output.append(fOutputType);
- output.append(",Events=");
- if (fEvents.isEmpty()) {
- output.append("None");
- } else {
- for (Iterator<IEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
- IEventInfo event = (IEventInfo) iterator.next();
- output.append(event.toString());
- }
- }
- output.append(")]");
- return output.toString();
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo;
-
-/**
- * <b><u>DomainInfo</u></b>
- * <p>
- * Implementation of the trace domain interface (IDomainInfo) to store domain
- * related data.
- * </p>
- */
-public class DomainInfo extends TraceInfo implements IDomainInfo {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The channels information of the domain.
- */
- private List<IChannelInfo> fChannels = new ArrayList<IChannelInfo>();
- private boolean fIsKernel = false;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - name of domain
- */
- public DomainInfo(String name) {
- super(name);
- }
-
- /**
- * Copy constructor
- * @param other - the instance to copy
- */
- public DomainInfo(DomainInfo other) {
- super(other);
- for (int i = 0; i < other.fChannels.size(); i++) {
- if (other.fChannels.get(i) instanceof ChannelInfo) {
- fChannels.add(new ChannelInfo((ChannelInfo)other.fChannels.get(i)));
- } else {
- fChannels.add(other.fChannels.get(i));
- }
- }
- fIsKernel = other.fIsKernel;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo#isKernel()
- */
- @Override
- public boolean isKernel() {
- return fIsKernel;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo#setIsKernel(boolean)
- */
- @Override
- public void setIsKernel(boolean isKernel) {
- fIsKernel = isKernel;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo#getChannels()
- */
- @Override
- public IChannelInfo[] getChannels() {
- return fChannels.toArray(new IChannelInfo[fChannels.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo#setChannels(java.util.List)
- */
- @Override
- public void setChannels(List<IChannelInfo> channels) {
- for (Iterator<IChannelInfo> iterator = channels.iterator(); iterator.hasNext();) {
- IChannelInfo channelInfo = (IChannelInfo) iterator.next();
- fChannels.add(channelInfo);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo#addChannel(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo)
- */
- @Override
- public void addChannel(IChannelInfo channel) {
- fChannels.add(channel);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#formatString()
- */
- @SuppressWarnings("nls")
- @Override
- public String formatString() {
- StringBuffer output = new StringBuffer();
- //=== Domain: Kernel ===
- output.append("\n=== Domain: ");
- output.append(getName());
- output.append(" ===\n");
- output.append("\n");
- // Channels:
- output.append("Channels:\n");
- // -------------
- output.append("-------------");
- if (fChannels.isEmpty()) {
- output.append("\nNone");
- } else {
- for (Iterator<IChannelInfo> iterator = fChannels.iterator(); iterator.hasNext();) {
- IChannelInfo channel = (IChannelInfo) iterator.next();
- output.append(channel.formatString());
- }
- }
- output.append("\n");
- return output.toString();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((fChannels == null) ? 0 : fChannels.hashCode());
- result = prime * result + (fIsKernel ? 1231 : 1237);
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- DomainInfo other = (DomainInfo) obj;
- if (fChannels == null) {
- if (other.fChannels != null) {
- return false;
- }
- } else if (!fChannels.equals(other.fChannels)) {
- return false;
- }
- if (fIsKernel != other.fIsKernel) {
- return false;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#toString()
- */
- @SuppressWarnings("nls")
- @Override
- public String toString() {
- StringBuffer output = new StringBuffer();
- output.append("[DomainInfo(");
- output.append(super.toString());
- output.append(",Channels=");
- if (fChannels.isEmpty()) {
- output.append("None");
- } else {
- for (Iterator<IChannelInfo> iterator = fChannels.iterator(); iterator.hasNext();) {
- IChannelInfo channel = (IChannelInfo) iterator.next();
- output.append(channel.toString());
- }
- }
- output.append(",isKernel=");
- output.append(String.valueOf(fIsKernel));
- output.append(")]");
- return output.toString();
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-
-/**
-* <b><u>EventInfo</u></b>
-* <p>
-* Implementation of the trace event interface (IEventInfo) to store event
-* related data.
-* </p>
-*/
-public class EventInfo extends BaseEventInfo implements IEventInfo {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The enable state of the event.
- */
- private TraceEnablement fState = TraceEnablement.DISABLED;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - name of event
- */
- public EventInfo(String name) {
- super(name);
- }
-
- /**
- * Copy constructor
- * @param other - the instance to copy
- */
- public EventInfo(EventInfo other) {
- super(other);
- fState = other.fState;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo#getState()
- */
- @Override
- public TraceEnablement getState() {
- return fState;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo#setState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement)
- */
- @Override
- public void setState(TraceEnablement state) {
- fState = state;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#formatString()
- */
- @SuppressWarnings("nls")
- @Override
- public String formatString() {
- StringBuffer output = new StringBuffer();
- // ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint) [enabled]");
- output.append(super.formatString());
- output.append(" [");
- output.append(fState.getInName());
- output.append("]");
- return output.toString();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo#setState(java.lang.String)
- */
- @Override
- public void setState(String stateName) {
- fState = TraceEnablement.DISABLED;
- if (TraceEnablement.DISABLED.getInName().equals(stateName)) {
- fState = TraceEnablement.DISABLED;
- } else if (TraceEnablement.ENABLED.getInName().equals(stateName)) {
- fState = TraceEnablement.ENABLED;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- EventInfo other = (EventInfo) obj;
- if (fState != other.fState) {
- return false;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo#toString()
- */
- @SuppressWarnings("nls")
- @Override
- public String toString() {
- StringBuffer output = new StringBuffer();
- output.append("[EventInfo(");
- output.append(super.toString());
- output.append(",State=");
- output.append(fState);
- output.append(")]");
- return output.toString();
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.KernelProviderPropertySource;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * <b><u>KernelProviderComponent</u></b>
- * <p>
- * TODO
- * </p>
- */
-public class KernelProviderComponent extends TraceControlComponent {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * Path to icon file for this component.
- */
- public static final String KERNEL_PROVIDER_ICON_FILE = "icons/obj16/targets.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - the name of the component.
- * @param parent - the parent of this component.
- */
- public KernelProviderComponent(String name, ITraceControlComponent parent) {
- super(name, parent);
- setImage(KERNEL_PROVIDER_ICON_FILE);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * Sets the events information for this component.
- * @param eventInfos - events information to set.
- */
- public void setEventInfo(List<IBaseEventInfo> eventInfos) {
- for (Iterator<IBaseEventInfo> iterator = eventInfos.iterator(); iterator.hasNext();) {
- IBaseEventInfo baseEventInfo = (IBaseEventInfo) iterator.next();
- BaseEventComponent component = new BaseEventComponent(baseEventInfo.getName(), this);
- component.setEventInfo(baseEventInfo);
- addChild(component);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IPropertySource.class) {
- return new KernelProviderPropertySource(this);
- }
- return null;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo;
-
-/**
-* <b><u>ProbleEventInfo</u></b>
-* <p>
-* Implementation of the trace event interface (IProbeEventInfo) to store probe event
-* related data.
-* </p>
-*/
-public class ProbeEventInfo extends EventInfo implements IProbeEventInfo {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The dynamic probe address (null if symbol is used).
- */
- private String fAddress;
- /**
- * The dynamic probe offset (if symbol is used).
- */
- private String fOffset;
-
- /**
- * The symbol name (null if address is used)
- */
- private String fSymbol;
-
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - name of event
- */
- public ProbeEventInfo(String name) {
- super(name);
- }
-
- /**
- * Copy constructor
- * @param other - the instance to copy
- */
- public ProbeEventInfo(ProbeEventInfo other) {
- super(other);
- fAddress = other.fAddress;
- fOffset = other.fOffset;
- fSymbol = other.fSymbol;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#getAddress()
- */
- @Override
- public String getAddress() {
- return fAddress;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#setAddress(java.lang.String)
- */
- @Override
- public void setAddress(String address) {
- fAddress = address;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#getOffset()
- */
- @Override
- public String getOffset() {
- return fOffset;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#setOffset(java.lang.String)
- */
- @Override
- public void setOffset(String offset) {
- fOffset = offset;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#getSymbol()
- */
- @Override
- public String getSymbol() {
- return fSymbol;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#setSymbol(java.lang.String)
- */
- @Override
- public void setSymbol(String symbol) {
- fSymbol = symbol;
- }
-
- // ------------------------------------------------------------------------
- // Operation
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#formatString()
- */
- @SuppressWarnings("nls")
- @Override
- public String formatString() {
- StringBuffer output = new StringBuffer();
- // name (type: probe) [enabled]");
- // address:
- output.append(super.formatString());
- if (fAddress != null) {
- output.append("\n addr: ");
- output.append(fAddress);
- } else {
- output.append("\n offset: ");
- output.append(fOffset);
- output.append("\n");
- output.append(" symbol: ");
- output.append(fSymbol);
- }
- return output.toString();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((fAddress == null) ? 0 : fAddress.hashCode());
- result = prime * result + ((fOffset == null) ? 0 : fOffset.hashCode());
- result = prime * result + ((fSymbol == null) ? 0 : fSymbol.hashCode());
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ProbeEventInfo other = (ProbeEventInfo) obj;
- if (fAddress == null) {
- if (other.fAddress != null) {
- return false;
- }
- } else if (!fAddress.equals(other.fAddress)) {
- return false;
- }
- if (fOffset == null) {
- if (other.fOffset != null) {
- return false;
- }
- } else if (!fOffset.equals(other.fOffset)) {
- return false;
- }
- if (fSymbol == null) {
- if (other.fSymbol != null) {
- return false;
- }
- } else if (!fSymbol.equals(other.fSymbol)) {
- return false;
- }
- return true;
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.EventInfo#toString()
- */
- @SuppressWarnings("nls")
- @Override
- public String toString() {
- StringBuffer output = new StringBuffer();
- output.append("[ProbeEventInfo(");
- output.append(super.toString());
- if (fAddress != null) {
- output.append(",fAddress=");
- output.append(fAddress);
- } else {
- output.append(",fOffset=");
- output.append(fOffset);
- output.append(",fSymbol=");
- output.append(fSymbol);
- }
- output.append(")]");
- return output.toString();
- }
-
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-
-/**
- * <b><u>SessionInfo</u></b>
- * <p>
- * Implementation of the trace session interface (ISessionInfo) to store session
- * related data.
- * </p>
- */
-public class SessionInfo extends TraceInfo implements ISessionInfo {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The trace session state.
- */
- private TraceSessionState fState = TraceSessionState.INACTIVE;
- /**
- * The trace session path for storing traces.
- */
- private String fSessionPath = ""; //$NON-NLS-1$
- /**
- * The domains information of this session.
- */
- private List<IDomainInfo> fDomains = new ArrayList<IDomainInfo>();
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - name of base event
- */
- public SessionInfo(String name) {
- super(name);
- }
-
- /**
- * Copy constructor
- * @param other - the instance to copy
- */
- public SessionInfo(SessionInfo other) {
- super(other);
- fState = other.fState;
- fSessionPath = other.fSessionPath;
-
- for (Iterator<IDomainInfo> iterator = other.fDomains.iterator(); iterator.hasNext();) {
- IDomainInfo domain = iterator.next();
- if (domain instanceof DomainInfo) {
- fDomains.add(new DomainInfo((DomainInfo)domain));
- } else {
- fDomains.add(domain);
- }
- }
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo#getSessionState()
- */
- @Override
- public TraceSessionState getSessionState() {
- return fState;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo#setSessionState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState)
- */
- @Override
- public void setSessionState(TraceSessionState state) {
- fState = state;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo#setSessionState(java.lang.String)
- */
- @Override
- public void setSessionState(String stateName) {
- if (TraceSessionState.INACTIVE.getInName().equals(stateName)) {
- fState = TraceSessionState.INACTIVE;
- } else if (TraceSessionState.ACTIVE.getInName().equals(stateName)) {
- fState = TraceSessionState.ACTIVE;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo#getSessionPath()
- */
- @Override
- public String getSessionPath() {
- return fSessionPath;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo#setSessionPath(java.lang.String)
- */
- @Override
- public void setSessionPath(String path) {
- fSessionPath = path;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo#getDomains()
- */
- @Override
- public IDomainInfo[] getDomains() {
- return fDomains.toArray(new IDomainInfo[fDomains.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo#setDomains(java.util.List)
- */
- @Override
- public void setDomains(List<IDomainInfo> domains) {
- for (Iterator<IDomainInfo> iterator = domains.iterator(); iterator.hasNext();) {
- IDomainInfo domainInfo = (IDomainInfo) iterator.next();
- fDomains.add(domainInfo);
- }
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo#addDomain(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo)
- */
- @Override
- public void addDomain(IDomainInfo domainInfo) {
- fDomains.add(domainInfo);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#formatString()
- */
- @Override
- @SuppressWarnings("nls")
- public String formatString() {
- StringBuffer output = new StringBuffer();
- // Tracing session mysession: [active]
- output.append("Tracing session ");
- output.append(getName());
- output.append(": [");
- output.append(getSessionState().getInName());
- output.append("]\n");
-
- // Trace path: /home/user/lttng-traces/mysession-20120129-084256
- output.append(" Trace path: ");
- output.append(getSessionPath());
- output.append("\n");
-
- for (Iterator<IDomainInfo> iterator = fDomains.iterator(); iterator.hasNext();) {
- IDomainInfo domain = (IDomainInfo) iterator.next();
- output.append(domain.formatString());
- }
- return output.toString();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((fDomains == null) ? 0 : fDomains.hashCode());
- result = prime * result + ((fSessionPath == null) ? 0 : fSessionPath.hashCode());
- result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- SessionInfo other = (SessionInfo) obj;
- if (fDomains == null) {
- if (other.fDomains != null) {
- return false;
- }
- } else if (!fDomains.equals(other.fDomains)) {
- return false;
- }
- if (fSessionPath == null) {
- if (other.fSessionPath != null) {
- return false;
- }
- } else if (!fSessionPath.equals(other.fSessionPath)) {
- return false;
- }
- if (fState != other.fState) {
- return false;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#toString()
- */
- @SuppressWarnings("nls")
- @Override
- public String toString() {
- StringBuffer output = new StringBuffer();
- output.append("[SessionInfo(");
- output.append(super.toString());
- output.append(",State=");
- output.append(fState);
- output.append(",Domains=");
- for (Iterator<IDomainInfo> iterator = fDomains.iterator(); iterator.hasNext();) {
- IDomainInfo domain = (IDomainInfo) iterator.next();
- output.append(domain.toString());
- }
- output.append(")]");
- return output.toString();
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TargetNodePropertySource;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.remote.IRemoteSystemProxy;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.remote.RemoteSystemProxy;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandShell;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.LTTngControlService;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.IRSECallback;
-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>
- */
-public class TargetNodeComponent extends TraceControlComponent implements ICommunicationsListener {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * Path to icon file for this component (state connected).
- */
- public static final String TARGET_NODE_CONNECTED_ICON_FILE = "icons/obj16/target_connected.gif"; //$NON-NLS-1$
- /**
- * Path to icon file for this component (state disconnected).
- */
- public static final String TARGET_NODE_DISCONNECTED_ICON_FILE = "icons/obj16/target_disconnected.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The node connection state.
- */
- private TargetNodeState fState = TargetNodeState.DISCONNECTED;
- /**
- * The image to be displayed in state disconnected.
- */
- private Image fDisconnectedImage = null;
- /**
- * The connection implementation.
- */
- private IHost fHost = null;
- /**
- * The remote proxy implementation.
- */
- private IRemoteSystemProxy fRemoteProxy = null;
- /**
- * The control service for LTTng specific commands.
- */
- private ILttngControlService fService = null;
- /**
- * The command shell for issuing commands.
- */
- private ICommandShell fShell = null;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * 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
- */
- public TargetNodeComponent(String name, ITraceControlComponent parent, IHost host, IRemoteSystemProxy proxy) {
- super(name, parent);
- setImage(TARGET_NODE_CONNECTED_ICON_FILE);
- fDisconnectedImage = Activator.getDefault().loadIcon(TARGET_NODE_DISCONNECTED_ICON_FILE);
- fHost = host;
- fRemoteProxy = proxy;
- setToolTip(fHost.getHostName());
- }
-
- /**
- * Constructor (using default proxy)
- * @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, IHost host) {
- this(name, parent, host, new RemoteSystemProxy(host));
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
- */
- @Override
- public Image getImage() {
- if (fState == TargetNodeState.CONNECTED) {
- return super.getImage();
- }
- return fDisconnectedImage;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getTargetNodeState()
- */
- @Override
- public TargetNodeState getTargetNodeState() {
- return fState;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#setTargetNodeState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent.TargetNodeState)
- */
- @Override
- public void setTargetNodeState(TargetNodeState state) {
- fState = state;
- fireComponentChanged(TargetNodeComponent.this);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getControlService()
- */
- @Override
- public ILttngControlService getControlService() {
- return fService;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#setControlService(org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService)
- */
- @Override
- public void setControlService(ILttngControlService service) {
- fService = (ILttngControlService)service;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.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 String getHostName() {
- return fHost.getHostName();
- }
-
- /**
- * @return remote system proxy implementation
- */
- public IRemoteSystemProxy getRemoteSystemProxy() {
- return fRemoteProxy;
- }
-
- /**
- * @return all available sessions.
- */
- public TraceSessionComponent[] getSessions() {
- List<ITraceControlComponent> compenents = getChildren(TraceSessionGroup.class);
- if (compenents.size() > 0) {
- TraceSessionGroup group = (TraceSessionGroup)compenents.get(0);
- List<ITraceControlComponent> sessions = group.getChildren(TraceSessionComponent.class);
- return (TraceSessionComponent[])sessions.toArray(new TraceSessionComponent[sessions.size()]);
- }
- return new TraceSessionComponent[0];
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * @see org.eclipse.rse.core.subsystems.ICommunicationsListener#communicationsStateChange(org.eclipse.rse.core.subsystems.CommunicationsEvent)
- */
- @Override
- public void communicationsStateChange(CommunicationsEvent e) {
- if (e.getState() == CommunicationsEvent.AFTER_DISCONNECT ||
- e.getState() == CommunicationsEvent.CONNECTION_ERROR) {
- handleDisconnected();
- } if ((e.getState() == CommunicationsEvent.AFTER_CONNECT) && (fState != TargetNodeState.CONNECTING)) {
- handleConnected();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.ICommunicationsListener#isPassiveCommunicationsListener()
- */
- @Override
- public boolean isPassiveCommunicationsListener() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceControlComponent#dispose()
- */
- @Override
- public void dispose() {
- fRemoteProxy.removeCommunicationListener(this);
- }
-
- /**
- * Method to connect this node component to the remote target node.
- */
- public void connect() {
- if (fState == TargetNodeState.DISCONNECTED) {
- try {
- setTargetNodeState(TargetNodeState.CONNECTING);
- fRemoteProxy.connect(new IRSECallback() {
- @Override
- public void done(IStatus status, Object result) {
- // Note: result might be null!
- if(status.isOK()) {
- handleConnected();
- } else {
- handleDisconnected();
- }
- }
- });
- } catch (Exception e) {
- setTargetNodeState(TargetNodeState.DISCONNECTED);
- Activator.logError(Messages.TraceControl_ConnectionFailure + " (" + getName() + ").", e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- /**
- * Method to disconnect this node component to the remote target node.
- */
- public void disconnect() {
- if (fState == TargetNodeState.CONNECTED) {
- try {
- setTargetNodeState(TargetNodeState.DISCONNECTING);
- fRemoteProxy.disconnect();
- } catch (Exception e) {
- Activator.logError(Messages.TraceControl_DisconnectionFailure + getName(), e);
- } finally {
- 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
- */
- public void getConfigurationFromNode() {
- Job job = new Job(Messages.TraceControl_RetrieveNodeConfigurationJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
-
- try {
- // Get provider information from node
- 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 Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
- }
-
- public void refresh() {
- removeAllChildren();
- getConfigurationFromNode();
- }
-
- // ------------------------------------------------------------------------
- // Helper function
- // ------------------------------------------------------------------------
- /**
- * @return returns the control service for LTTng specific commands.
- * @throws ExecutionException
- */
- private ILttngControlService createControlService() throws ExecutionException {
- if (fShell == null) {
- fShell = fRemoteProxy.createCommandShell();
- fRemoteProxy.addCommunicationListener(this);
- }
- fService = new LTTngControlService(fShell);
- return fService;
- }
-
- /**
- * Handles the connected event.
- */
- private void handleConnected() {
- setTargetNodeState(TargetNodeState.CONNECTED);
- try {
- createControlService();
- getConfigurationFromNode();
- } catch (ExecutionException e) {
- Activator.logError(Messages.TraceControl_ListSessionFailure, e);
- }
- }
-
- /**
- * Handles the disconnected event.
- */
- private void handleDisconnected() {
- removeAllChildren();
- setTargetNodeState(TargetNodeState.DISCONNECTED);
- fShell = null;
- fService = null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TraceChannelPropertySource;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-
-/**
- * <b><u>TraceChannelComponent</u></b>
- * <p>
- * Implementation of the trace channel component.
- * </p>
- */
-public class TraceChannelComponent extends TraceControlComponent {
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * Path to icon file for this component (state enabled).
- */
- public static final String TRACE_CHANNEL_ICON_FILE_ENABLED = "icons/obj16/channel.gif"; //$NON-NLS-1$
- /**
- * Path to icon file for this component (state disabled).
- */
- public static final String TRACE_CHANNEL_ICON_FILE_DISABLED = "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The channel information.
- */
- private IChannelInfo fChannelInfo = null;
- /**
- * The image to be displayed in disabled state.
- */
- private Image fDisabledImage = null;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - the name of the component.
- * @param parent - the parent of this component.
- */
- public TraceChannelComponent(String name, ITraceControlComponent parent) {
- super(name, parent);
- setImage(TRACE_CHANNEL_ICON_FILE_ENABLED);
- setToolTip(Messages.TraceControl_ChannelDisplayName);
- fChannelInfo = new ChannelInfo(name);
- fDisabledImage = Activator.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
- */
- @Override
- public Image getImage() {
- if (fChannelInfo.getState() == TraceEnablement.DISABLED) {
- return fDisabledImage;
- }
- return super.getImage();
- }
-
- /**
- * Sets the channel information.
- * @param channelInfo
- */
- public void setChannelInfo(IChannelInfo channelInfo) {
- fChannelInfo = channelInfo;
- IEventInfo[] events = fChannelInfo.getEvents();
- for (int i = 0; i < events.length; i++) {
- TraceEventComponent event = null;
- if (events[i].getClass() == ProbeEventInfo.class) {
- event = new TraceProbeEventComponent(events[i].getName(), this);
- } else {
- event = new TraceEventComponent(events[i].getName(), this);
- }
-
- event.setEventInfo(events[i]);
- addChild(event);
- }
- }
-
- /**
- * @return the overwrite mode value.
- */
- public boolean isOverwriteMode() {
- return fChannelInfo.isOverwriteMode();
- }
- /**
- * Sets the overwrite mode value to the given mode.
- * @param mode - mode to set.
- */
- public void setOverwriteMode(boolean mode){
- fChannelInfo.setOverwriteMode(mode);
- }
- /**
- * @return the sub-buffer size.
- */
- public long getSubBufferSize() {
- return fChannelInfo.getSubBufferSize();
- }
- /**
- * Sets the sub-buffer size to the given value.
- * @param bufferSize - size to set to set.
- */
- public void setSubBufferSize(long bufferSize) {
- fChannelInfo.setSubBufferSize(bufferSize);
- }
- /**
- * @return the number of sub-buffers.
- */
- public int getNumberOfSubBuffers() {
- return fChannelInfo.getNumberOfSubBuffers();
- }
- /**
- * Sets the number of sub-buffers to the given value.
- * @param numberOfSubBuffers - value to set.
- */
- public void setNumberOfSubBuffers(int numberOfSubBuffers) {
- fChannelInfo.setNumberOfSubBuffers(numberOfSubBuffers);
- }
- /**
- * @return the switch timer interval.
- */
- public long getSwitchTimer() {
- return fChannelInfo.getSwitchTimer();
- }
- /**
- * Sets the switch timer interval to the given value.
- * @param timer - timer value to set.
- */
- public void setSwitchTimer(long timer) {
- fChannelInfo.setSwitchTimer(timer);
- }
- /**
- * @return the read timer interval.
- */
- public long getReadTimer() {
- return fChannelInfo.getReadTimer();
- }
- /**
- * Sets the read timer interval to the given value.
- * @param timer - timer value to set..
- */
- public void setReadTimer(long timer) {
- fChannelInfo.setReadTimer(timer);
- }
- /**
- * @return the output type.
- */
- public String getOutputType() {
- return fChannelInfo.getOutputType();
- }
- /**
- * Sets the output type to the given value.
- * @param type - type to set.
- */
- public void setOutputType(String type) {
- fChannelInfo.setOutputType(type);
- }
- /**
- * @return the channel state (enabled or disabled).
- */
- public TraceEnablement getState() {
- return fChannelInfo.getState();
- }
- /**
- * Sets the channel state (enablement) to the given value.
- * @param state - state to set.
- */
- public void setState(TraceEnablement state) {
- fChannelInfo.setState(state);
- }
- /**
- * Sets the channel state (enablement) to the value specified by the given name.
- * @param stateName - state to set.
- */
- public void setState(String stateName) {
- fChannelInfo.setState(stateName);
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IPropertySource.class) {
- return new TraceChannelPropertySource(this);
- }
- return null;
- }
-
- /**
- * @return session name from parent
- */
- public String getSessionName() {
- return ((TraceDomainComponent)getParent()).getSessionName();
- }
-
- /**
- * @return session from parent
- */
- public TraceSessionComponent getSession() {
- return ((TraceDomainComponent)getParent()).getSession();
- }
-
- /**
- * @return if domain is kernel or UST
- */
- public boolean isKernel() {
- return ((TraceDomainComponent)getParent()).isKernel();
- }
-
- /**
- * @return the parent target node
- */
- public TargetNodeComponent getTargetNode() {
- return ((TraceDomainComponent)getParent()).getTargetNode();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Enables a list of events with no additional parameters.
- * @param eventNames - a list of event names to enabled.
- * @throws ExecutionException
- */
- public void enableEvents(List<String> eventNames) throws ExecutionException {
- enableEvents(eventNames, new NullProgressMonitor());
- }
-
- /**
- * Enables a list of events with no additional parameters.
- * @param eventNames - a list of event names to enabled.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableEvents(getSessionName(), getName(), eventNames, isKernel(), monitor);
- }
-
- /**
- * Enables all syscalls (for kernel domain)
- * @throws ExecutionException
- */
- public void enableSyscalls() throws ExecutionException {
- enableSyscalls(new NullProgressMonitor());
- }
-
- /**
- * Enables all syscalls (for kernel domain)
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableSyscalls(getSessionName(), getName(), monitor);
- }
-
- /**
- * Enables a dynamic probe (for kernel domain)
- * @param eventName - event name for probe
- * @param isFunction - true for dynamic function entry/return probe else false
- * @param probe - the actual probe
- * @throws ExecutionException
- */
- public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException {
- enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
- }
-
- /**
- * Enables a dynamic probe (for kernel domain)
- * @param eventName - event name for probe
- * @param isFunction - true for dynamic function entry/return probe else false
- * @param probe - the actual probe
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableProbe(getSessionName(), getName(), eventName, isFunction, probe, monitor);
- }
-
- /**
- * Enables events using log level.
- * @param eventName - a event name
- * @param logLevelType - a log level type
- * @param level - a log level
- * @throws ExecutionException
- */
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level) throws ExecutionException {
- enableLogLevel(eventName, logLevelType, level, new NullProgressMonitor());
- }
-
- /**
- * Enables events using log level.
- * @param eventName - a event name
- * @param logLevelType - a log level type
- * @param level - a log level
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableLogLevel(getSessionName(), getName(), eventName, logLevelType, level, monitor);
- }
-
- /**
- * Enables a list of events with no additional parameters.
- * @param eventNames - a list of event names to enabled.
- * @throws ExecutionException
- */
- public void disableEvent(List<String> eventNames) throws ExecutionException {
- disableEvent(eventNames, new NullProgressMonitor());
- }
-
- /**
- * Enables a list of events with no additional parameters.
- * @param eventNames - a list of event names to enabled.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void disableEvent(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
- getControlService().disableEvent(getParent().getParent().getName(), getName(), eventNames, isKernel(), monitor);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponentChangedListener;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TargetNodeState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * <b><u>TraceControlComponent</u></b>
- * <p>
- * Base implementation for trace control component.
- * </p>
- */
-public class TraceControlComponent implements ITraceControlComponent {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The name of the component
- */
- private String fName = ""; //$NON-NLS-1$
- /**
- * The image to be displayed for the component.
- */
- private Image fImage = null;
- /**
- * The tool tip to be displayed for the component.
- */
- private String fToolTip = null;
- /**
- * The parent component.
- */
- private ITraceControlComponent fParent = null;
- /**
- * The list if children components.
- */
- private List<ITraceControlComponent> fChildren = new ArrayList<ITraceControlComponent>();
- /**
- * The list of listeners to be notified about changes.
- */
- private ListenerList fListeners = new ListenerList();
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- * @param name - the name of the component.
- */
- public TraceControlComponent(String name) {
- this(name, null);
- }
-
- /**
- * Constructor
- * @param name - the name of the component.
- * @param parent - the parent component.
- */
- public TraceControlComponent(String name, ITraceControlComponent parent) {
- fName = name;
- fParent = parent;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#getName()
- */
- @Override
- public String getName() {
- return fName;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#setName(java.lang.String)
- */
- @Override
- public void setName(String name) {
- fName = name;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#getImage()
- */
- @Override
- public Image getImage() {
- return fImage;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#setImage(java.lang.String)
- */
- @Override
- public void setImage(String path) {
- fImage = Activator.getDefault().loadIcon(path);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#setImage(org.eclipse.swt.graphics.Image)
- */
- @Override
- public void setImage(Image image) {
- fImage = image;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#getToolTip()
- */
- @Override
- public String getToolTip() {
- return fToolTip;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#setToolTip(java.lang.String)
- */
- @Override
- public void setToolTip(String toolTip) {
- fToolTip = toolTip;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#getTargetNodeState()
- */
- @Override
- public TargetNodeState getTargetNodeState() {
- if (getParent() != null) {
- return getParent().getTargetNodeState();
- }
- return TargetNodeState.DISCONNECTED;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#setTargetNodeState(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent.TargetNodeState)
- */
- @Override
- public void setTargetNodeState(TargetNodeState state) {
- if (getParent() != null) {
- getParent().setTargetNodeState(state);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#getParent()
- */
- @Override
- public ITraceControlComponent getParent() {
- return fParent;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#setParent(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent)
- */
- @Override
- public void setParent(ITraceControlComponent parent) {
- fParent = parent;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#getChildren()
- */
- @Override
- public ITraceControlComponent[] getChildren() {
- return (ITraceControlComponent [])fChildren.toArray(new ITraceControlComponent[fChildren.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#setChildren(java.util.List)
- */
- @Override
- public void setChildren(List<ITraceControlComponent> children) {
- for (Iterator<ITraceControlComponent> iterator = children.iterator(); iterator.hasNext();) {
- ITraceControlComponent traceControlComponent = (ITraceControlComponent) iterator.next();
- fChildren.add(traceControlComponent);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#getChild(java.lang.String)
- */
- @Override
- public ITraceControlComponent getChild(String name) {
- ITraceControlComponent child = null;
- for (int i = 0; i < fChildren.size(); i++) {
- if (fChildren.get(i).getName().equals(name)) {
- child = fChildren.get(i);
- break;
- }
- }
- return child;
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#getChildren(java.lang.Class)
- */
- @Override
- public List<ITraceControlComponent> getChildren(Class<? extends ITraceControlComponent> clazz) {
- List<ITraceControlComponent> list = new ArrayList<ITraceControlComponent>();
-
- for (Iterator<ITraceControlComponent> iterator = fChildren.iterator(); iterator.hasNext();) {
- ITraceControlComponent child = (ITraceControlComponent) iterator.next();
- if (child.getClass() == clazz) {
- list.add(child);
- }
- }
- return list;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#getControlService()
- */
- @Override
- public ILttngControlService getControlService() {
- if (getParent() != null) {
- return getParent().getControlService();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#setControlService(org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService)
- */
- @Override
- public void setControlService(ILttngControlService service) {
- if (getParent() != null) {
- getParent().setControlService(service);
- }
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#dispose()
- */
- @Override
- public void dispose() {
- // default implementation
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#addChild(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent)
- */
- @Override
- public void addChild(ITraceControlComponent component) {
- if (component != null) {
- fChildren.add(component);
- }
- fireComponentAdded(this, component);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#removeChild(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent)
- */
- @Override
- public void removeChild(ITraceControlComponent component) {
- if (component != null) {
- fChildren.remove(component);
- component.dispose();
- }
- fireComponentRemoved(this, component);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#removeAllChildren()
- */
- @Override
- public void removeAllChildren() {
- for (Iterator<ITraceControlComponent> iterator = fChildren.iterator(); iterator.hasNext();) {
- ITraceControlComponent child = (ITraceControlComponent) iterator.next();
- child.removeAllChildren();
- }
- fChildren.clear();
-// fireCompenentChanged(this);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#containsChild(java.lang.String)
- */
- @Override
- public boolean containsChild(String name) {
- boolean retValue = false;
- for (int i = 0; i < fChildren.size(); i++) {
- if (fChildren.get(i).getName().equals(name)) {
- retValue = true;
- break;
- }
- }
- return retValue;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#hasChildren()
- */
- @Override
- public boolean hasChildren() {
- return !fChildren.isEmpty();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#addComponentListener(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponentChangedListener)
- */
- @Override
- public void addComponentListener(ITraceControlComponentChangedListener listener) {
- if (fParent != null)
- fParent.addComponentListener(listener);
- else {
- fListeners.add(listener);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#removeComponentListener(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponentChangedListener)
- */
- @Override
- public void removeComponentListener(ITraceControlComponentChangedListener listener) {
- if (fParent != null)
- fParent.removeComponentListener(listener);
- else {
- fListeners.remove(listener);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#fireCompenentAdded(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent)
- */
- @Override
- public void fireComponentAdded(ITraceControlComponent parent, ITraceControlComponent component) {
- if (component == null) {
- return;
- }
-
- if (fParent != null) {
- fParent.fireComponentAdded(parent, component);
- } else {
- Object[] listeners = fListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ITraceControlComponentChangedListener listener = (ITraceControlComponentChangedListener) listeners[i];
- listener.componentAdded(parent, component);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#fireCompenentRemoved(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent)
- */
- @Override
- public void fireComponentRemoved(ITraceControlComponent parent, ITraceControlComponent component) {
- if (component == null) {
- return;
- }
-
- if (fParent != null) {
- fParent.fireComponentRemoved(parent, component);
- } else {
- Object[] listeners = fListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ITraceControlComponentChangedListener listener = (ITraceControlComponentChangedListener) listeners[i];
- listener.componentRemoved(parent, component);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent#fireCompenentChanged(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent)
- */
- @Override
- public void fireComponentChanged(ITraceControlComponent component) {
- if (component == null) {
- return;
- }
-
- if (fParent != null) {
- fParent.fireComponentChanged(component);
- } else {
- Object[] listeners = fListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ITraceControlComponentChangedListener listener = (ITraceControlComponentChangedListener) listeners[i];
- listener.componentChanged(component);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- return null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-
-/**
- * <b><u>TraceControlRoot</u></b>
- * <p>
- * Root element in trace control tree.
- * </p>
- */
-public class TraceControlRoot extends TraceControlComponent {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The name of the root component
- */
- public final static String TRACE_CONTROL_ROOT_NAME = "trace_control_root"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Default constructor
- */
- public TraceControlRoot() {
- super(TRACE_CONTROL_ROOT_NAME);
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TraceDomainPropertySource;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * <b><u>TraceDomainComponent</u></b>
- * <p>
- * Implementation of the trace domain component.
- * </p>
- */
-public class TraceDomainComponent extends TraceControlComponent {
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * Path to icon file for this component.
- */
- public static final String TRACE_DOMAIN_ICON_FILE = "icons/obj16/domain.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The domain information.
- */
- private IDomainInfo fDomainInfo = null;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - the name of the component.
- * @param parent - the parent of this component.
- */
- public TraceDomainComponent(String name, ITraceControlComponent parent) {
- super(name, parent);
- setImage(TRACE_DOMAIN_ICON_FILE);
- setToolTip(Messages.TraceControl_DomainDisplayName);
- fDomainInfo = new DomainInfo(name);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * Sets the domain information.
- * @param domainInfo - the domain information to set.
- */
- public void setDomainInfo(IDomainInfo domainInfo) {
- fDomainInfo = domainInfo;
- IChannelInfo[] channels = fDomainInfo.getChannels();
- for (int i = 0; i < channels.length; i++) {
- TraceChannelComponent channel = new TraceChannelComponent(channels[i].getName(), this);
- channel.setChannelInfo(channels[i]);
- addChild(channel);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IPropertySource.class) {
- return new TraceDomainPropertySource(this);
- }
- return null;
- }
-
- /**
- * @return session name from parent
- */
- public String getSessionName() {
- return ((TraceSessionComponent)getParent()).getName();
- }
-
- /**
- * @return session from parent
- */
- public TraceSessionComponent getSession() {
- return (TraceSessionComponent)getParent();
- }
-
- /**
- * @return true if domain is kernel, false for UST
- */
- public boolean isKernel() {
- return fDomainInfo.isKernel();
- }
-
- /**
- * Sets whether domain is Kernel domain or UST
- * @param isKernel true for kernel, false for UST
- */
- public void setIsKernel(boolean isKernel) {
- fDomainInfo.setIsKernel(isKernel);
- }
-
- /**
- * @return returns all available channels for this domain.
- */
- public TraceChannelComponent[] getChannels() {
- List<ITraceControlComponent> channels = getChildren(TraceChannelComponent.class);
- return (TraceChannelComponent[])channels.toArray(new TraceChannelComponent[channels.size()]);
- }
-
- /**
- * @return the parent target node
- */
- public TargetNodeComponent getTargetNode() {
- return ((TraceSessionComponent)getParent()).getTargetNode();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Retrieves the session configuration from the node.
- * @throws ExecutionException
- */
- public void getConfigurationFromNode() throws ExecutionException {
- getConfigurationFromNode(new NullProgressMonitor());
- }
- /**
- * Retrieves the session configuration from the node.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
- TraceSessionComponent session = (TraceSessionComponent) getParent();
- session.getConfigurationFromNode(monitor);
- }
- /**
- * Enables channels with given names which are part of this domain. If a given channel
- * doesn't exists it creates a new channel with the given parameters (or default values
- * if given parameter is null).
- * @param channelNames - a list of channel names to enable on this domain
- * @param info - channel information to set for the channel (use null for default)
- * @throws ExecutionException
- */
- public void enableChannels(List<String> channelNames, IChannelInfo info) throws ExecutionException {
- enableChannels(channelNames, info, new NullProgressMonitor());
- }
- /**
- * Enables channels with given names which are part of this domain. If a given channel
- * doesn't exists it creates a new channel with the given parameters (or default values
- * if given parameter is null).
- * @param channelNames - a list of channel names to enable on this domain
- * @param info - channel information to set for the channel (use null for default)
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableChannels(List<String> channelNames, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableChannels(getParent().getName(), channelNames, isKernel(), info, monitor);
- }
- /**
- * Disables channels with given names which are part of this domain.
- * @param channelNames - a list of channel names to enable on this domain
- * @throws ExecutionException
- */
- public void disableChannels(List<String> channelNames) throws ExecutionException {
- disableChannels(channelNames, new NullProgressMonitor());
- }
- /**
- * Disables channels with given names which are part of this domain.
- * @param channelNames - a list of channel names to enable on this domain
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void disableChannels(List<String> channelNames, IProgressMonitor monitor) throws ExecutionException {
- getControlService().disableChannels(getParent().getName(), channelNames, isKernel(), monitor);
- }
-
- /**
- * Enables a list of events with no additional parameters.
- * @param eventNames - a list of event names to enabled.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableEvents(getSessionName(), null, eventNames, isKernel(), monitor);
- }
-
- /**
- * Enables all syscalls (for kernel domain)
- * @throws ExecutionException
- */
- public void enableSyscalls() throws ExecutionException {
- enableSyscalls(new NullProgressMonitor());
- }
-
- /**
- * Enables all syscalls (for kernel domain)
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
-
- public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableSyscalls(getSessionName(), null, monitor);
- }
-
- /**
- * Enables a dynamic probe (for kernel domain)
- * @param eventName - event name for probe
- * @param isFunction - true for dynamic function entry/return probe else false
- * @param probe - the actual probe
- * @throws ExecutionException
- */
- public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException {
- enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
- }
-
- /**
- * Enables a dynamic probe (for kernel domain)
- * @param eventName - event name for probe
- * @param isFunction - true for dynamic function entry/return probe else false
- * @param probe - the actual probe
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableProbe(getSessionName(), null, eventName, isFunction, probe, monitor);
- }
-
- /**
- * Enables events using log level.
- * @param eventName - a event name
- * @param logLevelType - a log level type
- * @param level - a log level
- * @throws ExecutionException
- */
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level) throws ExecutionException {
- enableLogLevel(eventName, logLevelType, level, new NullProgressMonitor());
- }
-
- /**
- * Enables events using log level.
- * @param eventName - a event name
- * @param logLevelType - a log level type
- * @param level - a log level
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableLogLevel(getSessionName(), null, eventName, logLevelType, level, monitor);
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TraceEventPropertySource;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-
-/**
- * <b><u>TraceEventComponent</u></b>
- * <p>
- * Implementation of the trace channel component.
- * </p>
- */
-public class TraceEventComponent extends TraceControlComponent {
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * Path to icon file for this component (enabled state).
- */
- public static final String TRACE_EVENT_ICON_FILE_ENABLED = "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
- /**
- * Path to icon file for this component (disabled state).
- */
- public static final String TRACE_EVENT_ICON_FILE_DISABLED = "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The event information.
- */
- protected IEventInfo fEventInfo = null;
- /**
- * The image to be displayed when in disabled state.
- */
- private Image fDisabledImage = null;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - the name of the component.
- * @param parent - the parent of this component.
- */
- public TraceEventComponent(String name, ITraceControlComponent parent) {
- super(name, parent);
- setImage(TRACE_EVENT_ICON_FILE_ENABLED);
- setToolTip(Messages.TraceControl_EventDisplayName);
- fEventInfo = new EventInfo(name);
- fDisabledImage = Activator.getDefault().loadIcon(TRACE_EVENT_ICON_FILE_DISABLED);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
- */
- @Override
- public Image getImage() {
- if (fEventInfo.getState() == TraceEnablement.DISABLED) {
- return fDisabledImage;
- }
- return super.getImage();
- }
-
- /**
- * Sets the event information.
- * @param eventInfo - the event information to set.
- */
- public void setEventInfo(IEventInfo eventInfo) {
- fEventInfo = eventInfo;
- }
-
- /**
- * @return the trace event type
- */
- public TraceEventType getEventType() {
- return fEventInfo.getEventType();
- }
-
- /**
- * Sets the trace event type to the given type
- * @param type - type to set
- */
- public void setEventType(TraceEventType type) {
- fEventInfo.setEventType(type);
- }
-
- /**
- * Sets the trace event type to the type specified by the given name.
- * @param type - event type name
- */
- public void setEventType(String typeName) {
- fEventInfo.setEventType(typeName);
- }
-
- /**
- * @return the event state (enabled or disabled).
- */
- public TraceEnablement getState() {
- return fEventInfo.getState();
- }
-
- /**
- * Sets the event state (enablement) to the given value.
- * @param state - state to set.
- */
- public void setState(TraceEnablement state) {
- fEventInfo.setState(state);
- }
-
- /**
- * Sets the event state (enablement) to the value specified by the given name.
- * @param stateName - state to set.
- */
- public void setState(String stateName) {
- fEventInfo.setState(stateName);
- }
-
- /**
- * @return the trace event log level
- */
- public TraceLogLevel getLogLevel() {
- return fEventInfo.getLogLevel();
- }
-
- /**
- * 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
- */
- public void setLogLevel(String levelName) {
- fEventInfo.setLogLevel(levelName);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IPropertySource.class) {
- return new TraceEventPropertySource(this);
- }
- return null;
- }
-
- /**
- * @return session name from parent
- */
- public String getSessionName() {
- return ((TraceChannelComponent)getParent()).getSessionName();
- }
-
- /**
- * @return channel name from parent
- */
- public String getChannelName() {
- return getParent().getName();
- }
-
- /**
- * @return if domain is kernel or UST
- */
- public boolean isKernel() {
- return ((TraceChannelComponent)getParent()).isKernel();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo;
-
-/**
- * <b><u>TraceInfo</u></b>
- * <p>
- * Implementation of the base trace information interface (ITraceInfo) to
- * store common data.
- * </p>
- */
-public class TraceInfo implements ITraceInfo {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The name of the element.
- */
- private String fName = null;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - name of trace element
- */
- public TraceInfo(String name) {
- if (name == null) {
- throw new IllegalArgumentException();
- }
- fName = name;
- }
-
- /**
- * Copy constructor
- * @param other - the instance to copy
- */
- public TraceInfo(TraceInfo other) {
- if (other == null) {
- throw new IllegalArgumentException();
- } else {
- fName = String.valueOf(other.fName);
- }
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#getName()
- */
- @Override
- public String getName() {
- return fName;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#setName(java.lang.String)
- */
- @Override
- public void setName(String name) {
- fName = name;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#formatString()
- */
- @Override
- public String formatString() {
- return toString();
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fName == null) ? 0 : fName.hashCode());
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- TraceInfo other = (TraceInfo) obj;
- if (fName == null) {
- if (other.fName != null) {
- return false;
- }
- } else if (!fName.equals(other.fName)) {
- return false;
- }
- return true;
- }
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @SuppressWarnings("nls")
- @Override
- public String toString() {
- StringBuffer output = new StringBuffer();
- output.append("[TraceInfo(");
- output.append("Name=");
- output.append(getName());
- output.append(")]");
- return output.toString();
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TraceProbeEventPropertySource;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-
-/**
- * <b><u>TraceProbeEventComponent</u></b>
- * <p>
- * Implementation of the trace channel component.
- * </p>
- */
-public class TraceProbeEventComponent extends TraceEventComponent {
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * 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
- // ------------------------------------------------------------------------
-
- /**
- * Sets the event information.
- * @param eventInfo - the event information to set.
- */
- @Override
- public void setEventInfo(IEventInfo eventInfo) {
- if (eventInfo instanceof ProbeEventInfo) {
- fEventInfo = eventInfo;
- return;
- }
- 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.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IPropertySource.class) {
- return new TraceProbeEventPropertySource(this);
- }
- return null;
- }
- /**
- * @return the address of the probe. (null if Symbol is used)
- */
- public String getAddress() {
- return getEventInfo().getAddress();
- }
- /**
- * Sets the address of the probe.
- * @param address - a address
- */
- public void setAddress(String address) {
- getEventInfo().setAddress(address);
- }
- /**
- * @return the offset applied to the symbol.
- */
- public String getOffset() {
- return getEventInfo().getOffset();
- }
- /**
- * Sets the offset applied to the symbol. (valid if symbol is used)
- * @param offset - a offset
- */
- public void setOffset(String offset) {
- getEventInfo().setOffset(offset);
- }
- /**
- * @return the symbol name. (null if address is used)
- */
- public String getSymbol() {
- return getEventInfo().getSymbol();
- }
- /**
- * Sets the symbol name.
- * @param symbol - a symbol name (null if address is used)
- */
- public void setSymbol(String symbol) {
- getEventInfo().setSymbol(symbol);
- }
-
- // ------------------------------------------------------------------------
- // Helper methods
- // ------------------------------------------------------------------------
- private ProbeEventInfo getEventInfo() {
- return (ProbeEventInfo) fEventInfo;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo;
-
-/**
- * <b><u>TraceProviderGroup</u></b>
- * <p>
- * Implementation of the trace provider group.
- * </p>
- */
-public class TraceProviderGroup extends TraceControlComponent {
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * Path to icon file for this component.
- */
- public static final String TRACE_PROVIDERS_ICON_FILE = "icons/obj16/providers.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - the name of the component.
- * @param parent - the parent of this component.
- */
- public TraceProviderGroup(String name, ITraceControlComponent parent) {
- super(name, parent);
- setImage(TRACE_PROVIDERS_ICON_FILE);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * Gets the provider information from the target node.
- * @throws ExecutionException
- */
- public void getProviderFromNode() throws ExecutionException {
- getProviderFromNode(new NullProgressMonitor());
- }
-
- /**
- * Gets the provider information from the target node.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void getProviderFromNode(IProgressMonitor monitor) throws ExecutionException {
-
- List<IBaseEventInfo> eventInfos = getControlService().getKernelProvider(monitor);
- KernelProviderComponent component = new KernelProviderComponent(Messages.TraceControl_KernelProviderDisplayName, this);
- addChild(component);
- component.setEventInfo(eventInfos);
-
- List<IUstProviderInfo> allProviders = getControlService().getUstProvider(monitor);
-
- for (Iterator<IUstProviderInfo> iterator = allProviders.iterator(); iterator.hasNext();) {
- IUstProviderInfo ustProviderInfo = (IUstProviderInfo) iterator.next();
- UstProviderComponent ustComponent = new UstProviderComponent(ustProviderInfo.getName(), this);
- addChild(ustComponent);
- ustComponent.setUstProvider(ustProviderInfo);
- }
- }
-}
-
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.TraceSessionPropertySource;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * <b><u>TraceSessionComponent</u></b>
- * <p>
- * Implementation of the trace session component.
- * </p>
- */
-public class TraceSessionComponent extends TraceControlComponent {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * Path to icon file for this component (inactive state).
- */
- public static final String TRACE_SESSION_ICON_FILE_INACTIVE = "icons/obj16/session_inactive.gif"; //$NON-NLS-1$
- /**
- * Path to icon file for this component (active state).
- */
- public static final String TRACE_SESSION_ICON_FILE_ACTIVE = "icons/obj16/session_active.gif"; //$NON-NLS-1$
- /**
- * Path to icon file for this component (destroyed state).
- */
- public static final String TRACE_SESSION_ICON_FILE_DESTROYED = "icons/obj16/session_destroyed.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The session information.
- */
- private ISessionInfo fSessionInfo = null;
- /**
- * A flag to indicate if session has been destroyed.
- */
- private boolean fIsDestroyed = false;
- /**
- * The image to be displayed in state active.
- */
- private Image fActiveImage = null;
- /**
- * The image to be displayed in state destroyed
- */
- private Image fDestroyedImage = null;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - the name of the component.
- * @param parent - the parent of this component.
- */
- public TraceSessionComponent(String name, ITraceControlComponent parent) {
- super(name, parent);
- setImage(TRACE_SESSION_ICON_FILE_INACTIVE);
- setToolTip(Messages.TraceControl_SessionDisplayName);
- fSessionInfo = new SessionInfo(name);
- fActiveImage = Activator.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_ACTIVE);
- fDestroyedImage = Activator.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_DESTROYED);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
- */
- @Override
- public Image getImage() {
- if (fIsDestroyed) {
- return fDestroyedImage;
- }
-
- if (fSessionInfo.getSessionState() == TraceSessionState.INACTIVE) {
- return super.getImage();
- }
-
- return fActiveImage;
- }
-
- /**
- * @return the whether the session is destroyed or not.
- */
- public boolean isDestroyed() {
- return fIsDestroyed;
- }
-
- /**
- * Sets the session destroyed state to the given value.
- * @param destroyed - value to set.
- */
- public void setDestroyed(boolean destroyed) {
- fIsDestroyed = destroyed;
- }
-
- /**
- * @return the session state state (active or inactive).
- */
- public TraceSessionState getSessionState() {
- return fSessionInfo.getSessionState();
- }
-
- /**
- * Sets the session state to the given value.
- * @param state - state to set.
- */
- public void setSessionState(TraceSessionState state) {
- fSessionInfo.setSessionState(state);
- }
-
- /**
- * Sets the event state to the value specified by the given name.
- * @param stateName - state to set.
- */
- public void setSessionState(String stateName) {
- fSessionInfo.setSessionState(stateName);
- }
-
- /**
- * @return path string where session is located.
- */
- public String getSessionPath() {
- return fSessionInfo.getSessionPath();
- }
-
- /**
- * Sets the path string (where session is located) to the given value.
- * @param path - session path to set.
- */
- public void setSessionPath(String sessionPath) {
- fSessionInfo.setSessionPath(sessionPath);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IPropertySource.class) {
- return new TraceSessionPropertySource(this);
- }
- return null;
- }
-
- /**
- * @return all available domains of this session.
- */
- public TraceDomainComponent[] getDomains() {
- List<ITraceControlComponent> sessions = getChildren(TraceDomainComponent.class);
- return (TraceDomainComponent[])sessions.toArray(new TraceDomainComponent[sessions.size()]);
- }
-
- /**
- * @return the parent target node
- */
- public TargetNodeComponent getTargetNode() {
- return ((TraceSessionGroup)getParent()).getTargetNode();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Retrieves the session configuration from the node.
- * @throws ExecutionException
- */
- public void getConfigurationFromNode() throws ExecutionException {
- getConfigurationFromNode(new NullProgressMonitor());
- }
-
- /**
- * Retrieves the session configuration from the node.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
- removeAllChildren();
- fSessionInfo = getControlService().getSession(getName(), monitor);
- IDomainInfo[] domains = fSessionInfo.getDomains();
- for (int i = 0; i < domains.length; i++) {
- TraceDomainComponent domainComponent = new TraceDomainComponent(domains[i].getName(), this);
- addChild(domainComponent);
- domainComponent.setDomainInfo(domains[i]);
- }
- }
-
- /**
- * Starts the session.
- * throws ExecutionExecption
- */
- public void startSession() throws ExecutionException {
- startSession(new NullProgressMonitor());
- }
-
- /**
- * Starts the session.
- * @param monitor - a progress monitor
- * throws ExecutionExecption
- */
- public void startSession(IProgressMonitor monitor) throws ExecutionException {
- getControlService().startSession(getName(), monitor);
- }
-
- /**
- * Starts the session.
- * throws ExecutionExecption
- */
- public void stopSession() throws ExecutionException {
- startSession(new NullProgressMonitor());
- }
-
- /**
- * Starts the session.
- * @param monitor - a progress monitor
- * throws ExecutionExecption
- */
- public void stopSession(IProgressMonitor monitor) throws ExecutionException {
- getControlService().stopSession(getName(), monitor);
- }
-
- /**
- * Enables a list of events with no additional parameters.
- * @param eventNames - a list of event names to enabled.
- * @param isKernel - a flag for indicating kernel or UST.
- * @throws ExecutionException
- */
- public void enableEvent(List<String> eventNames, boolean isKernel) throws ExecutionException {
- enableEvents(eventNames, isKernel, new NullProgressMonitor());
- }
-
- /**
- * Enables a list of events with no additional parameters.
- * @param eventNames - a list of event names to enabled.
- * @param isKernel - a flag for indicating kernel or UST.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableEvents(getName(), null, eventNames, isKernel, monitor);
- }
-
- /**
- * Enables all syscalls (for kernel domain)
- * @throws ExecutionException
- */
- public void enableSyscalls() throws ExecutionException {
- enableSyscalls(new NullProgressMonitor());
- }
-
- /**
- * Enables all syscalls (for kernel domain)
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableSyscalls(getName(), null, monitor);
- }
-
- /**
- * Enables a dynamic probe (for kernel domain)
- * @param eventName - event name for probe
- * @param isFunction - true for dynamic function entry/return probe else false
- * @param probe - the actual probe
- * @throws ExecutionException
- */
- public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException {
- enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
- }
-
- /**
- * Enables a dynamic probe (for kernel domain)
- * @param eventName - event name for probe
- * @param isFunction - true for dynamic function entry/return probe else false
- * @param probe - the actual probe
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableProbe(getName(), null, eventName, isFunction, probe, monitor);
- }
-
- /**
- * Enables events using log level.
- * @param eventName - a event name
- * @param logLevelType - a log level type
- * @param level - a log level
- * @throws ExecutionException
- */
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level) throws ExecutionException {
- enableLogLevel(eventName, logLevelType, level, new NullProgressMonitor());
- }
-
- /**
- * Enables events using log level.
- * @param eventName - a event name
- * @param logLevelType - a log level type
- * @param level - a log level
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableLogLevel(getName(), null, eventName, logLevelType, level, monitor);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-
-/**
- * <b><u>TraceSessionGroup</u></b>
- * <p>
- * Implementation of the trace session group.
- * </p>
- */
-public class TraceSessionGroup extends TraceControlComponent {
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * Path to icon file for this component.
- */
- public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - the name of the component.
- * @param parent - the parent of this component.
- */
- public TraceSessionGroup(String name, ITraceControlComponent parent) {
- super(name, parent);
- setImage(TRACE_SESSIONS_ICON_FILE);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return the parent target node
- */
- public TargetNodeComponent getTargetNode() {
- return (TargetNodeComponent)getParent();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Retrieves the sessions information from the node.
- * @throws ExecutionException
- */
- public void getSessionsFromNode() throws ExecutionException {
- getSessionsFromNode(new NullProgressMonitor());
- }
-
- /**
- * Retrieves the sessions information from the node.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void getSessionsFromNode(IProgressMonitor monitor) throws ExecutionException {
- String[] sessionNames = getControlService().getSessionNames(monitor);
- for (int i = 0; i < sessionNames.length; i++) {
- TraceSessionComponent session = new TraceSessionComponent(sessionNames[i], this);
- addChild(session);
- session.getConfigurationFromNode(monitor);
- }
- }
-
- /**
- * Creates a session with given session name and location.
- * @param sessionName - a session name to create
- * @param sessionPath - a path for storing the traces (use null for default)
- * @return the session information
- * throws ExecutionExecption
- */
- public void createSession(String sessionName, String sessionPath) throws ExecutionException {
- createSession(sessionName, sessionPath, new NullProgressMonitor());
- }
-
- /**
- * Creates a session with given session name and location.
- * @param sessionName - a session name to create
- * @param sessionPath - a path for storing the traces (use null for default)
- * @Param monitor - a progress monitor
- * @return the session information
- * throws ExecutionExecption
- */
- public void createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
- ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, monitor);
- if (sessionInfo != null) {
- TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
- addChild(session);
- session.getConfigurationFromNode(monitor);
- }
- }
-
- /**
- * Destroys a session with given session name.
- * @param session - a session component to destroy
- * throws ExecutionExecption
- */
- public void destroySession(TraceSessionComponent session) throws ExecutionException {
- destroySession(session, new NullProgressMonitor());
- }
-
- /**
- * Destroys a session with given session name.
- * @param session - a session component to destroy
- * @param monitor - a progress monitor
- * throws ExecutionExecption
- */
- public void destroySession(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
- getControlService().destroySession(session.getName(), monitor);
- session.removeAllChildren();
- removeChild(session);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.property.UstProviderPropertySource;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * <b><u>UstProviderComponent</u></b>
- * <p>
- * Implementation of the UST provider component.
- * </p>
- */
-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
- * @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);
- fProviderInfo = new UstProviderInfo(name);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * Sets the UST provider information to the given value.
- * @param providerInfo - the provider information to set
- */
- public void setUstProvider(IUstProviderInfo providerInfo) {
- fProviderInfo = providerInfo;
- IBaseEventInfo[] events = providerInfo.getEvents();
- for (int i = 0; i < events.length; i++) {
- BaseEventComponent component = new BaseEventComponent(events[i].getName(), this);
- component.setEventInfo(events[i]);
- addChild(component);
- }
- setToolTip("PID=" + fProviderInfo.getPid()); //$NON-NLS-1$
- }
-
- /**
- * @return the process ID of the UST provider.
- */
- public int getPid() {
- return fProviderInfo.getPid();
- }
-
- /**
- * Sets the process ID of the UST provider to the given value.
- * @param pid - process ID to set
- */
- public void setPid(int pid) {
- fProviderInfo.setPid(pid);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.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
- // ------------------------------------------------------------------------
-
-}
-
-
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo;
-
-/**
- * <b><u>UstProviderInfo</u></b>
- * <p>
- * Implementation of the Ust Provider interface (IUstProviderInfo) to store UST
- * provider related data.
- * </p>
- */
-public class UstProviderInfo extends TraceInfo implements IUstProviderInfo {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The process ID of the UST provider.
- */
- private int fPid = 0;
- /**
- * List of event information.
- */
- private List<IBaseEventInfo> fEvents = new ArrayList<IBaseEventInfo>();
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param name - name of UST provider
- */
- public UstProviderInfo(String name) {
- super(name);
- }
-
- /**
- * Copy constructor
- * @param other - the instance to copy
- */
- public UstProviderInfo(UstProviderInfo other) {
- super(other);
- fPid = other.fPid;
- for (Iterator<IBaseEventInfo> iterator = other.fEvents.iterator(); iterator.hasNext();) {
- IBaseEventInfo event = iterator.next();
- if (event instanceof BaseEventInfo) {
- fEvents.add(new BaseEventInfo((BaseEventInfo)event));
- } else {
- fEvents.add(event);
- }
- }
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo#getPid()
- */
- @Override
- public int getPid() {
- return fPid;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo#setPid(int)
- */
- @Override
- public void setPid(int pid) {
- fPid = pid;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo#getEvents()
- */
- @Override
- public IBaseEventInfo[] getEvents() {
- return fEvents.toArray(new IBaseEventInfo[fEvents.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo#setEvents(java.util.List)
- */
- @Override
- public void setEvents(List<IBaseEventInfo> events) {
- for (Iterator<IBaseEventInfo> iterator = events.iterator(); iterator.hasNext();) {
- IBaseEventInfo eventInfo = (IBaseEventInfo) iterator.next();
- fEvents.add(eventInfo);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo#addEvent(org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo)
- */
- @Override
- public void addEvent(IBaseEventInfo event) {
- fEvents.add(event);
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#formatString()
- */
- @SuppressWarnings("nls")
- @Override
- public String formatString() {
- StringBuffer output = new StringBuffer();
- //PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
- output.append("\nPID: ");
- output.append(fPid);
- output.append(" - Name: ");
- output.append(getName());
- for (Iterator<IBaseEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
- IBaseEventInfo event = (IBaseEventInfo) iterator.next();
- output.append(event.formatString());
- }
- output.append("\n");
-
- return output.toString();
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((fEvents == null) ? 0 : fEvents.hashCode());
- result = prime * result + fPid;
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- UstProviderInfo other = (UstProviderInfo) obj;
- if (fEvents == null) {
- if (other.fEvents != null) {
- return false;
- }
- } else if (!fEvents.equals(other.fEvents)) {
- return false;
- }
- if (fPid != other.fPid) {
- return false;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceInfo#toString()
- */
- @SuppressWarnings("nls")
- @Override
- public String toString() {
- StringBuffer output = new StringBuffer();
- output.append("[EventInfo(");
- output.append(super.toString());
- output.append(",PID=");
- output.append(fPid);
- output.append(",Events=");
- if (fEvents.isEmpty()) {
- output.append("None");
- } else {
- for (Iterator<IBaseEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
- IBaseEventInfo event = (IBaseEventInfo) iterator.next();
- output.append(event.toString());
- }
- }
- output.append(")]");
- return output.toString();
- }
-
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.property;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventComponent;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * <b><u>BaseEventPropertySource</u></b>
- * <p>
- * Property source implementation for the base event component.
- * </p>
- */
-public class BaseEventPropertySource extends BasePropertySource {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- /**
- * The base event 'name' property ID.
- */
- public static final String BASE_EVENT_NAME_PROPERTY_ID = "base.event.name"; //$NON-NLS-1$
- /**
- * The base event 'type' property ID.
- */
- public static final String BASE_EVENT_TYPE_PROPERTY_ID = "base.event.type"; //$NON-NLS-1$
- /**
- * The base event 'log level' property ID.
- */
- public static final String BASE_EVENT_LOGLEVEL_PROPERTY_ID = "base.event.loglevel"; //$NON-NLS-1$
- /**
- * The base event 'name' property name.
- */
- public static final String BASE_EVENT_NAME_PROPERTY_NAME = Messages.TraceControl_EventNamePropertyName;
- /**
- * The base event 'type' property name.
- */
- public static final String BASE_EVENT_TYPE_PROPERTY_NAME = Messages.TraceControl_EventTypePropertyName;
- /**
- * The base event 'log level' property name.
- */
- public static final String BASE_EVENT_LOGLEVEL_PROPERTY_NAME = Messages.TraceControl_LogLevelPropertyName;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The base event component which this property source is for.
- */
- private final BaseEventComponent fBaseEvent;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param component - the base event component
- */
- public BaseEventPropertySource(BaseEventComponent component) {
- fBaseEvent = component;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
- */
- @Override
- public IPropertyDescriptor[] getPropertyDescriptors() {
- List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> ();
- list.add(new TextPropertyDescriptor(BASE_EVENT_NAME_PROPERTY_ID, BASE_EVENT_NAME_PROPERTY_NAME));
- list.add(new TextPropertyDescriptor(BASE_EVENT_TYPE_PROPERTY_ID, BASE_EVENT_TYPE_PROPERTY_NAME));
- if (fBaseEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) {
- list.add(new TextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID, BASE_EVENT_LOGLEVEL_PROPERTY_NAME));
- }
- return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
- */
- @Override
- public Object getPropertyValue(Object id) {
- if(BASE_EVENT_NAME_PROPERTY_ID.equals(id)) {
- return fBaseEvent.getName();
- }
- if (BASE_EVENT_TYPE_PROPERTY_ID.equals(id)) {
- return fBaseEvent.getEventType().name();
- }
- if (BASE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) {
- return fBaseEvent.getLogLevel().name();
- }
- return null;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.property;
-
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * <b><u>BaseEventPropertySource</u></b>
- * <p>
- * Base property source implementation.
- * </p>
- */
-abstract public class BasePropertySource implements IPropertySource {
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- @Override
- public Object getEditableValue() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- @Override
- abstract public IPropertyDescriptor[] getPropertyDescriptors();
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- @Override
- abstract public Object getPropertyValue(Object id);
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- @Override
- public boolean isPropertySet(Object id) {
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- @Override
- public void resetPropertyValue(Object id) {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- @Override
- public void setPropertyValue(Object id, Object value) {
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.property;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.KernelProviderComponent;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * <b><u>KernelProviderPropertySource</u></b>
- * <p>
- * Property source implementation for the kernl provider component.
- * </p>
- */
-public class KernelProviderPropertySource extends BasePropertySource {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The kernel provider 'name' property ID.
- */
- public static final String KERNEL_PROVIDER_NAME_PROPERTY_ID = "ust.provider.name"; //$NON-NLS-1$
- /**
- * The kernel provider 'name' property name.
- */
- public static final String KERNEL_PROVIDER_NAME_PROPERTY_NAME = Messages.TraceControl_ProviderNamePropertyName;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The kernel provider component which this property source is for.
- */
- private KernelProviderComponent fProvider;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param component - the kernel provider component
- */
- public KernelProviderPropertySource(KernelProviderComponent component) {
- fProvider = component;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
- */
- @Override
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return new IPropertyDescriptor[] {
- new TextPropertyDescriptor(KERNEL_PROVIDER_NAME_PROPERTY_ID, KERNEL_PROVIDER_NAME_PROPERTY_NAME)};
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
- */
- @Override
- public Object getPropertyValue(Object id) {
- if(KERNEL_PROVIDER_NAME_PROPERTY_ID.equals(id)) {
- return fProvider.getName();
- }
- return null;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.property;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * <b><u>TargetNodePropertySource</u></b>
- * <p>
- * Property source implementation for the target node component.
- * </p>
- */
-public class TargetNodePropertySource extends BasePropertySource {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The node name property ID.
- */
- public static final String TARGET_NODE_NAME_PROPERTY_ID = "target.node.name"; //$NON-NLS-1$
- /**
- * The node address property ID.
- */
- public static final String TARGET_NODE_ADDRESS_PROPERTY_ID = "target.node.address"; //$NON-NLS-1$
- /**
- * The state property ID.
- */
- public static final String TARGET_NODE_STATE_PROPERTY_ID = "target.node.state"; //$NON-NLS-1$
- /**
- * The node name property name.
- */
- public static final String TARGET_NODE_NAME_PROPERTY_NAME = Messages.TraceControl_HostNamePropertyName;
- /**
- * The node address property name.
- */
- public static final String TARGET_NODE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_HostAddressPropertyName;
- /**
- * The state address property name.
- */
- public static final String TARGET_NODE_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The node component which this property source is for.
- */
- private final TargetNodeComponent fTargetNode;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param component - the node component
- */
- public TargetNodePropertySource(TargetNodeComponent component) {
- fTargetNode = component;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
- */
- @Override
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return new IPropertyDescriptor[] {
- new TextPropertyDescriptor(TARGET_NODE_NAME_PROPERTY_ID, TARGET_NODE_NAME_PROPERTY_NAME),
- new TextPropertyDescriptor(TARGET_NODE_ADDRESS_PROPERTY_ID, TARGET_NODE_ADDRESS_PROPERTY_NAME),
- new TextPropertyDescriptor(TARGET_NODE_STATE_PROPERTY_ID, TARGET_NODE_STATE_PROPERTY_NAME)};
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
- */
- @Override
- public Object getPropertyValue(Object id) {
- if(TARGET_NODE_NAME_PROPERTY_ID.equals(id)) {
- return fTargetNode.getName();
- }
- if (TARGET_NODE_ADDRESS_PROPERTY_ID.equals(id)) {
- return fTargetNode.getHostName();
- }
- if (TARGET_NODE_STATE_PROPERTY_ID.equals(id)) {
- return fTargetNode.getTargetNodeState().name();
- }
- return null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.property;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * <b><u>TraceChannelPropertySource</u></b>
- * <p>
- * Property source implementation for the trace channel component.
- * </p>
- */
-public class TraceChannelPropertySource extends BasePropertySource {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The trace channel 'name' property ID.
- */
- public static final String TRACE_CHANNEL_NAME_PROPERTY_ID = "trace.channel.name"; //$NON-NLS-1$
- /**
- * The trace channel 'state' ID.
- */
- public static final String TRACE_CHANNEL_STATE_PROPERTY_ID = "trace.channel.state"; //$NON-NLS-1$
- /**
- * The trace channel 'overwrite mode' property ID.
- */
- public static final String TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID = "trace.channel.overwrite.mode"; //$NON-NLS-1$
- /**
- * The trace channel 'sub-buffer size' property ID.
- */
- public static final String TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID = "trace.channel.subbuffer.size"; //$NON-NLS-1$
- /**
- * The trace channel 'number of sub-buffers' property ID.
- */
- public static final String TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID = "trace.channel.no.subbuffers"; //$NON-NLS-1$
- /**
- * The trace channel 'switch timer interval' property ID.
- */
- public static final String TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID = "trace.channel.switch.timer"; //$NON-NLS-1$
- /**
- * The trace channel 'read timer interval' property ID.
- */
- public static final String TRACE_CHANNEL_READ_TIMER_PROPERTY_ID = "trace.channel.read.timer"; //$NON-NLS-1$
- /**
- * The trace channel 'output type' property ID.
- */
- public static final String TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID = "trace.channel.output.type"; //$NON-NLS-1$
- /**
- * The trace channel 'name' property name.
- */
- public static final String TRACE_CHANNEL_NAME_PROPERTY_NAME = Messages.TraceControl_ChannelNamePropertyName;
- /**
- * The trace channel 'state' property name.
- */
- public static final String TRACE_CHANNEL_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
- /**
- * The trace channel 'overwrite mode' property name.
- */
- public static final String TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME = Messages.TraceControl_OverwriteModePropertyName;
- /**
- * The trace channel 'sub-buffer size' property name.
- */
- public static final String TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME = Messages.TraceControl_SubBufferSizePropertyName;
- /**
- * The trace channel 'sub-buffer size' property name.
- */
- public static final String TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME = Messages.TraceControl_NbSubBuffersPropertyName;
- /**
- * The trace channel 'switch timer interval' property name.
- */
- public static final String TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME = Messages.TraceControl_SwitchTimerPropertyName;
- /**
- * The trace channel 'read timer interval' property name.
- */
- public static final String TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME = Messages.TraceControl_ReadTimerPropertyName;
- /**
- * The trace channel 'output type' property name.
- */
- public static final String TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME = Messages.TraceControl_OutputTypePropertyName;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The channel component which this property source is for.
- */
- private final TraceChannelComponent fChannel;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param component - the channel component
- */
- public TraceChannelPropertySource(TraceChannelComponent component) {
- fChannel = component;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
- */
- @Override
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return new IPropertyDescriptor[] {
- new TextPropertyDescriptor(TRACE_CHANNEL_NAME_PROPERTY_ID, TRACE_CHANNEL_NAME_PROPERTY_NAME),
- new TextPropertyDescriptor(TRACE_CHANNEL_STATE_PROPERTY_ID, TRACE_CHANNEL_STATE_PROPERTY_NAME),
- new TextPropertyDescriptor(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID, TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME),
- new TextPropertyDescriptor(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID, TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME),
- new TextPropertyDescriptor(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID, TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME),
- new TextPropertyDescriptor(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID, TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME),
- new TextPropertyDescriptor(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID, TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME),
- new TextPropertyDescriptor(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID, TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME)};
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
- */
- @Override
- public Object getPropertyValue(Object id) {
- if(TRACE_CHANNEL_NAME_PROPERTY_ID.equals(id)) {
- return fChannel.getName();
- }
- if (TRACE_CHANNEL_STATE_PROPERTY_ID.equals(id)) {
- return fChannel.getState().name();
- }
- if(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID.equals(id)) {
- return String.valueOf(fChannel.isOverwriteMode());
- }
- if(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID.equals(id)) {
- return String.valueOf(fChannel.getSubBufferSize());
- }
- if(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID.equals(id)) {
- return String.valueOf(fChannel.getNumberOfSubBuffers());
- }
- if(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID.equals(id)) {
- return String.valueOf(fChannel.getSwitchTimer());
- }
- if(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID.equals(id)) {
- return String.valueOf(fChannel.getReadTimer());
- }
- if(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID.equals(id)) {
- return fChannel.getOutputType();
- }
- return null;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.property;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * <b><u>TraceDomainPropertySource</u></b>
- * <p>
- * Property source implementation for the trace domain component.
- * </p>
- */
-public class TraceDomainPropertySource extends BasePropertySource {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- /**
- * The trace domain 'name' property ID.
- */
- public static final String TRACE_DOMAIN_NAME_PROPERTY_ID = "trace.domain.name"; //$NON-NLS-1$
- /**
- * The trace domain 'name' property name.
- */
- public static final String TRACE_DOMAIN_NAME_PROPERTY_NAME = Messages.TraceControl_DomainNamePropertyName;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The trace domain component which this property source is for.
- */
- private final TraceDomainComponent fBaseEvent;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param component - the trace domain component
- */
- public TraceDomainPropertySource(TraceDomainComponent component) {
- fBaseEvent = component;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
- */
- @Override
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return new IPropertyDescriptor[] {
- new TextPropertyDescriptor(TRACE_DOMAIN_NAME_PROPERTY_ID, TRACE_DOMAIN_NAME_PROPERTY_NAME)};
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
- */
- @Override
- public Object getPropertyValue(Object id) {
- if(TRACE_DOMAIN_NAME_PROPERTY_ID.equals(id)) {
- return fBaseEvent.getName();
- }
- return null;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.property;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceEventComponent;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * <b><u>TraceEventPropertySource</u></b>
- * <p>
- * Property source implementation for the trace event component.
- * </p>
- */
-public class TraceEventPropertySource extends BasePropertySource {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The trace event 'name' property ID.
- */
- public static final String TRACE_EVENT_NAME_PROPERTY_ID = "trace.event.name"; //$NON-NLS-1$
- /**
- * The trace event 'type' property ID.
- */
- public static final String TRACE_EVENT_TYPE_PROPERTY_ID = "trace.event.type"; //$NON-NLS-1$
- /**
- * The trace event 'log level' property ID.
- */
- public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_ID = "trace.event.loglevel"; //$NON-NLS-1$
- /**
- * The trace event 'state' property ID.
- */
- public static final String TRACE_EVENT_STATE_PROPERTY_ID = "trace.event.state"; //$NON-NLS-1$
- /**
- * The trace event 'name' property name.
- */
- public static final String TRACE_EVENT_NAME_PROPERTY_NAME = Messages.TraceControl_EventNamePropertyName;
- /**
- * The trace event 'type' property name.
- */
- public static final String TRACE_EVENT_TYPE_PROPERTY_NAME = Messages.TraceControl_EventTypePropertyName;
- /**
- * The trace event 'log level' property name.
- */
- public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_NAME = Messages.TraceControl_LogLevelPropertyName;
- /**
- * The trace event 'state' property name.
- */
- public static final String TRACE_EVENT_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The event component which this property source is for.
- */
- protected final TraceEventComponent fEvent;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param component - the base event component
- */
- public TraceEventPropertySource(TraceEventComponent component) {
- fEvent = component;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
- */
- @Override
- public IPropertyDescriptor[] getPropertyDescriptors() {
- List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> ();
- list.add(new TextPropertyDescriptor(TRACE_EVENT_NAME_PROPERTY_ID, TRACE_EVENT_NAME_PROPERTY_NAME));
- list.add(new TextPropertyDescriptor(TRACE_EVENT_TYPE_PROPERTY_ID, TRACE_EVENT_TYPE_PROPERTY_NAME));
- list.add( new TextPropertyDescriptor(TRACE_EVENT_STATE_PROPERTY_ID, TRACE_EVENT_STATE_PROPERTY_NAME));
- if (fEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) {
- list.add(new TextPropertyDescriptor(TRACE_EVENT_LOGLEVEL_PROPERTY_ID, TRACE_EVENT_LOGLEVEL_PROPERTY_NAME));
- }
- return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
- */
- @Override
- public Object getPropertyValue(Object id) {
- if(TRACE_EVENT_NAME_PROPERTY_ID.equals(id)) {
- return fEvent.getName();
- }
- if (TRACE_EVENT_TYPE_PROPERTY_ID.equals(id)) {
- return fEvent.getEventType().name();
- }
- if (TRACE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) {
- return fEvent.getLogLevel().name();
- }
- if (TRACE_EVENT_STATE_PROPERTY_ID.equals(id)) {
- return fEvent.getState().name();
- }
- return null;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.property;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceEventComponent;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceProbeEventComponent;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * <b><u>TraceEventPropertySource</u></b>
- * <p>
- * Property source implementation for the trace probe event component.
- * </p>
- */
-public class TraceProbeEventPropertySource extends TraceEventPropertySource {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The trace event 'probe address' property ID.
- */
- public static final String TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID = "trace.event.probe.address"; //$NON-NLS-1$
- /**
- * The trace event 'probe offset' property ID.
- */
- public static final String TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID = "trace.event.probe.offset"; //$NON-NLS-1$
- /**
- * The trace event 'probe symbol' property ID.
- */
- public static final String TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID = "trace.event.probe.symbol"; //$NON-NLS-1$
- /**
- * The trace event 'probe address' property name.
- */
- public static final String TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_ProbeAddressPropertyName;
- /**
- * The trace event 'probe offset' property ID.
- */
- public static final String TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME = Messages.TraceControl_ProbeOffsetPropertyName;
- /**
- * The trace event 'probe symbol' property ID.
- */
- public static final String TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME = Messages.TraceControl_ProbeSymbolPropertyName;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- public TraceProbeEventPropertySource(TraceEventComponent component) {
- super(component);
- if (component.getClass() != TraceProbeEventComponent.class) {
- throw new IllegalArgumentException("Invalid type passed. Only class of type TraceProbeEventComponent allowed:\n" + component.getClass()); //$NON-NLS-1$
- }
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
- */
- @Override
- public IPropertyDescriptor[] getPropertyDescriptors() {
- IPropertyDescriptor[] superProperties = super.getPropertyDescriptors();
- List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor>();
- for (int i = 0; i < superProperties.length; i++) {
- list.add(superProperties[i]);
- }
-
- if (fEvent instanceof TraceProbeEventComponent) {
- TraceProbeEventComponent event = (TraceProbeEventComponent) fEvent;
- if (event.getAddress() != null) {
- list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID, TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME));
- }
-
- if (event.getOffset() != null) {
- list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID, TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME));
- }
-
- if (event.getSymbol() != null) {
- list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID, TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME));
- }
- }
- return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
- */
- @Override
- public Object getPropertyValue(Object id) {
- if(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID.equals(id)) {
- return ((TraceProbeEventComponent)fEvent).getAddress();
- }
- if (TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID.equals(id)) {
- return ((TraceProbeEventComponent)fEvent).getOffset();
- }
- if (TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID.equals(id)) {
- return ((TraceProbeEventComponent)fEvent).getSymbol();
- }
- return super.getPropertyValue(id);
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.property;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * <b><u>TraceSessionPropertySource</u></b>
- * <p>
- * Property source implementation for the trace session component.
- * </p>
- */
-public class TraceSessionPropertySource extends BasePropertySource {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The trace session name property ID.
- */
- public static final String TRACE_SESSION_NAME_PROPERTY_ID = "trace.session.name"; //$NON-NLS-1$
- /**
- * The trace session path property ID.
- */
- public static final String TRACE_SESSION_PATH_PROPERTY_ID = "trace.session.path"; //$NON-NLS-1$
- /**
- * The trace session state ID.
- */
- public static final String TRACE_SESSION_STATE_PROPERTY_ID = "trace.session.state"; //$NON-NLS-1$
- /**
- * The trace session name property name.
- */
- public static final String TRACE_SESSION_NAME_PROPERTY_NAME = Messages.TraceControl_SessionNamePropertyName;
- /**
- * The trace session path property name.
- */
- public static final String TRACE_SESSION_PATH_PROPERTY_NAME = Messages.TraceControl_SessionPathPropertyName;
- /**
- * The trace session state property name.
- */
- public static final String TRACE_SESSION_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The session component which this property source is for.
- */
- private final TraceSessionComponent fSession;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param component - the session component
- */
- public TraceSessionPropertySource(TraceSessionComponent component) {
- fSession = component;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- @Override
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return new IPropertyDescriptor[] {
- new TextPropertyDescriptor(TRACE_SESSION_NAME_PROPERTY_ID, TRACE_SESSION_NAME_PROPERTY_NAME),
- new TextPropertyDescriptor(TRACE_SESSION_PATH_PROPERTY_ID, TRACE_SESSION_PATH_PROPERTY_NAME),
- new TextPropertyDescriptor(TRACE_SESSION_STATE_PROPERTY_ID, TRACE_SESSION_STATE_PROPERTY_NAME)};
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- @Override
- public Object getPropertyValue(Object id) {
- if(TRACE_SESSION_NAME_PROPERTY_ID.equals(id)) {
- return fSession.getName();
- }
- if(TRACE_SESSION_PATH_PROPERTY_ID.equals(id)) {
- return fSession.getSessionPath();
- }
- if (TRACE_SESSION_STATE_PROPERTY_ID.equals(id)) {
- return fSession.getSessionState().name();
- }
- return null;
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.property;
-
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.UstProviderComponent;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * <b><u>UstProviderPropertySource</u></b>
- * <p>
- * Property source implementation for the UST provider component.
- * </p>
- */
-public class UstProviderPropertySource extends BasePropertySource {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The UST provider 'name' property ID.
- */
- public static final String UST_PROVIDER_NAME_PROPERTY_ID = "ust.provider.name"; //$NON-NLS-1$
- /**
- * The UST provider 'PID' property ID.
- */
- public static final String UST_PROVIDER_PID_PROPERTY_ID = "ust.provider.pid"; //$NON-NLS-1$
- /**
- * The UST provider 'name' property name.
- */
- public static final String UST_PROVIDER_NAME_PROPERTY_NAME = Messages.TraceControl_ProviderNamePropertyName;
- /**
- * The UST provider 'type' property name.
- */
- public static final String UST_PROVIDER_PID_PROPERTY_NAME = Messages.TraceControl_ProcessIdPropertyName;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The UST provider component which this property source is for.
- */
- private UstProviderComponent fUstProvider;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- * @param component - the UST provider component
- */
- public UstProviderPropertySource(UstProviderComponent component) {
- fUstProvider = component;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
- */
- @Override
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return new IPropertyDescriptor[] {
- new TextPropertyDescriptor(UST_PROVIDER_NAME_PROPERTY_ID, UST_PROVIDER_NAME_PROPERTY_NAME),
- new TextPropertyDescriptor(UST_PROVIDER_PID_PROPERTY_ID, UST_PROVIDER_PID_PROPERTY_NAME)};
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
- */
- @Override
- public Object getPropertyValue(Object id) {
- if(UST_PROVIDER_NAME_PROPERTY_ID.equals(id)) {
- return fUstProvider.getName();
- }
- if (UST_PROVIDER_PID_PROPERTY_ID.equals(id)) {
- return String.valueOf(fUstProvider.getPid());
- }
- return null;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.remote;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandShell;
-import org.eclipse.rse.core.model.IRSECallback;
-import org.eclipse.rse.core.subsystems.ICommunicationsListener;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.services.shells.IShellService;
-import org.eclipse.rse.services.terminals.ITerminalService;
-import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
-
-/**
- * <b><u>IRemoteSystemProxy</u></b>
- * <p>
- * Remote System Proxy interface.
- * </p>
- */
-public interface IRemoteSystemProxy {
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Find the first shell service.
- *
- * @return shell service object, or <code>null</code> if not found.
- */
- public IShellService getShellService();
-
- /**
- * Find the first terminal service.
- *
- * @return shell service object, or <code>null</code> if not found.
- */
- public ITerminalService getTerminalService();
-
- /**
- * Find the first IShellServiceSubSystem service.
- *
- * @return shell service subsystem, or <code>null</code> if not found.
- */
- public ISubSystem getShellServiceSubSystem();
-
- /**
- * Find the first ITerminalServiceSubSystem service.
- *
- * @param host the connection
- * @return shell service subsystem, or <code>null</code> if not found.
- */
- public ISubSystem getTerminalServiceSubSystem();
-
- /**
- * Finds the File Service Subsystem.
- * @return file service subsystem, or <code>null</code> if not found.
- */
- public IFileServiceSubSystem getFileServiceSubSystem();
-
- /**
- * Connects the shell service sub system.
- *
- * @param callback - call-back method being called when connection was finished
- * @throws Exception
- */
- public void connect(IRSECallback callback) throws ExecutionException;
-
- /**
- * Disconnects from the shell service sub system.
- *
- * @throws Exception
- */
- public void disconnect() throws ExecutionException;
-
- /**
- * Creates a command shell.
- *
- * @return the command shell implementation
- * @throws Exception
- */
- public ICommandShell createCommandShell() throws ExecutionException;
-
- /**
- * Method to add a communication listener to the connector service defined for
- * the given connection.
- *
- * @param listener - listener to add
- * @throws Exception
- */
- public void addCommunicationListener(ICommunicationsListener listener);
-
- /**
- * Method to remove a communication listener from the connector service defined for
- * the given connection.
- *
- * @param listener - listener to remove
- * @throws Exception
- */
- public void removeCommunicationListener(ICommunicationsListener listener);
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.remote;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.CommandShell;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandShell;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.IRSECallback;
-import org.eclipse.rse.core.subsystems.ICommunicationsListener;
-import org.eclipse.rse.core.subsystems.IConnectorService;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.services.IService;
-import org.eclipse.rse.services.shells.IShellService;
-import org.eclipse.rse.services.terminals.ITerminalService;
-import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
-
-/**
- * <b><u>RemoteSystemProxy</u></b>
- * <p>
- * RemoteSystemProxy implementation.
- * </p>
- */
-public class RemoteSystemProxy implements IRemoteSystemProxy {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- private IHost fHost;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- public RemoteSystemProxy(IHost host) {
- fHost = host;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.util.IRemoteSystemProxy#getShellService(org.eclipse.rse.core.model.IHost)
- */
- @Override
- public IShellService getShellService() {
- ISubSystem ss = getShellServiceSubSystem();
- if (ss != null) {
- return (IShellService)ss.getSubSystemConfiguration().getService(fHost).getAdapter(IShellService.class);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.util.IRemoteSystemProxy#getTerminalService()
- */
- @Override
- public ITerminalService getTerminalService() {
- ISubSystem ss = getTerminalServiceSubSystem();
- if (ss != null) {
- return (ITerminalService)ss.getSubSystemConfiguration().getService(fHost).getAdapter(ITerminalService.class);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.util.IRemoteSystemProxy#getShellServiceSubSystem()
- */
- @Override
- public ISubSystem getShellServiceSubSystem() {
- if (fHost == null) {
- return null;
- }
- ISubSystem[] subSystems = fHost.getSubSystems();
- IShellService ssvc = null;
- for (int i = 0; subSystems != null && i < subSystems.length; i++) {
- IService svc = subSystems[i].getSubSystemConfiguration().getService(fHost);
- if (svc!=null) {
- ssvc = (IShellService)svc.getAdapter(IShellService.class);
- if (ssvc != null) {
- return subSystems[i];
- }
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.util.IRemoteSystemProxy#getTerminalServiceSubSystem()
- */
- @Override
- public ISubSystem getTerminalServiceSubSystem() {
- if (fHost == null) {
- return null;
- }
- ISubSystem[] subSystems = fHost.getSubSystems();
- ITerminalService ssvc = null;
- for (int i = 0; subSystems != null && i < subSystems.length; i++) {
- IService svc = subSystems[i].getSubSystemConfiguration().getService(fHost);
- if (svc!=null) {
- ssvc = (ITerminalService)svc.getAdapter(ITerminalService.class);
- if (ssvc != null) {
- return subSystems[i];
- }
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.remote.IRemoteSystemProxy#getFileServiceSubSystem()
- */
- @Override
- public IFileServiceSubSystem getFileServiceSubSystem() {
- if (fHost == null) {
- return null;
- }
- ISubSystem[] subSystems = fHost.getSubSystems();
- for (int i = 0; subSystems != null && i < subSystems.length; i++) {
- if (subSystems[i] instanceof IFileServiceSubSystem) {
- return (IFileServiceSubSystem)subSystems[i];
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.util.IRemoteSystemProxy#connect(org.eclipse.rse.core.model.IRSECallback)
- */
- @Override
- public void connect(IRSECallback callback) throws ExecutionException {
- ISubSystem shellSubSystem = getShellServiceSubSystem();
- if (shellSubSystem != null) {
- if (!shellSubSystem.isConnected()) {
- try {
- shellSubSystem.connect(false, callback);
- } catch (Exception e) {
- throw new ExecutionException(e.toString(), e);
- }
- } else {
- callback.done(Status.OK_STATUS, null);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.util.IRemoteSystemProxy#disconnect()
- */
- @Override
- public void disconnect() throws ExecutionException {
- ISubSystem shellSubSystem = getShellServiceSubSystem();
- if (shellSubSystem != null) {
- try {
- shellSubSystem.disconnect();
- } catch (Exception e) {
- throw new ExecutionException(e.toString(), e);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.util.IRemoteSystemProxy#createCommandShell()
- */
- @Override
- public ICommandShell createCommandShell() throws ExecutionException {
- ICommandShell shell = new CommandShell(this);
- shell.connect();
- return shell;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.util.IRemoteSystemProxy#addCommunicationListener(org.eclipse.rse.core.subsystems.ICommunicationsListener)
- */
- @Override
- public void addCommunicationListener(ICommunicationsListener listener) {
- IConnectorService[] css = fHost.getConnectorServices();
- for (IConnectorService cs : css) {
- cs.addCommunicationsListener(listener);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.util.IRemoteSystemProxy#removeCommunicationListener(org.eclipse.rse.core.subsystems.ICommunicationsListener)
- */
- @Override
- public void removeCommunicationListener(ICommunicationsListener listener) {
- IConnectorService[] css = fHost.getConnectorServices();
- for (IConnectorService cs : css) {
- cs.removeCommunicationsListener(listener);
- }
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.service;
-
-import java.util.Arrays;
-
-/**
- * <b><u>CommandResult</u></b>
- * <p>
- * Class containing command result of remote command execution.
- * </p>
- */
-public class CommandResult implements ICommandResult {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The result of the command. 0 if successful else > 0
- */
- private int fResult;
-
- /**
- * The output as String array.
- */
- private String[] fOutput = new String[0];
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
- public CommandResult(int result, String[] output) {
- fResult = result;
- if (output != null) {
- fOutput = Arrays.copyOf(output, output.length);
- }
- }
-
- // ------------------------------------------------------------------------
- // Accessor
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandResult#getResult()
- */
- @Override
- public int getResult() {
- return fResult;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandResult#setResult(int)
- */
- @Override
- public void setResult(int result) {
- fResult = result;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandResult#getOutput()
- */
- @Override
- public String[] getOutput() {
- return Arrays.copyOf(fOutput, fOutput.length);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandResult#setOutput(java.lang.String[])
- */
- @Override
- public void setOutput(String[] output) {
- fOutput = new String[0];
- if (output != null) {
- fOutput = Arrays.copyOf(output, output.length);
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Patrick Tasse - Initial API and implementation
- * Bernd Hufmann - Updated using Executor Framework
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.service;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.remote.IRemoteSystemProxy;
-import org.eclipse.rse.services.shells.HostShellProcessAdapter;
-import org.eclipse.rse.services.shells.IHostShell;
-import org.eclipse.rse.services.shells.IShellService;
-
-/**
- * <b><u>CommandShell</u></b>
- * <p>
- * Implementation of remote command execution using RSE's shell service.
- * </p>
- */
-public class CommandShell implements ICommandShell {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- // 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$
-
- //command delimiter for shell
- public final static String CMD_DELIMITER = "\n"; //$NON-NLS-1$
-
- public final static String SHELL_ECHO_CMD = " echo "; //$NON-NLS-1$
-
- private final static int DEFAULT_TIMEOUT_VALUE = 15000; // in milliseconds
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- private IRemoteSystemProxy fProxy = null;
- private IHostShell fHostShell = null;
- private BufferedReader fBufferReader = null;
- private ExecutorService fExecutor = Executors.newFixedThreadPool(1);
- private boolean fIsConnected = false;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- public CommandShell(IRemoteSystemProxy proxy) {
- fProxy = proxy;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandShell#connect()
- */
- @Override
- public void connect() throws ExecutionException {
- IShellService shellService = fProxy.getShellService();
- Process p = null;
- try {
- fHostShell = shellService.launchShell("", new String[0], new NullProgressMonitor()); //$NON-NLS-1$
- p = new HostShellProcessAdapter(fHostShell);
- } catch (Exception e) {
- throw new ExecutionException(Messages.TraceControl_CommandShellError, e);
- }
- fBufferReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
- fIsConnected = true;
-
- // Flush Login messages
- executeCommand(" ", new NullProgressMonitor(), false); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandShell#disconnect()
- */
- @Override
- public void disconnect() {
- fIsConnected = false;
- try {
- fBufferReader.close();
- } catch (IOException e) {
- // ignore
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandShell#executeCommand(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor) throws ExecutionException {
- return executeCommand(command, monitor, true);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandShell#executeCommand(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- @Override
- public ICommandResult executeCommand(final String command, final IProgressMonitor monitor, final boolean checkReturnValue) throws ExecutionException {
- if (fIsConnected) {
- FutureTask<CommandResult> future = new FutureTask<CommandResult>(new Callable<CommandResult>() {
- @Override
- public CommandResult call() throws IOException, CancellationException {
- final ArrayList<String> result = new ArrayList<String>();
- int returnValue = 0;
-
- synchronized (fHostShell) {
- fHostShell.writeToShell(formatShellCommand(command));
- String nextLine;
- while ((nextLine = fBufferReader.readLine()) != null) {
-
- if (monitor.isCanceled()) {
- flushInput();
- throw new CancellationException();
- }
-
- if (nextLine.contains(DONE_MARKUP_STRING) && nextLine.contains(SHELL_ECHO_CMD)) {
- break;
- }
- }
-
- while ((nextLine = fBufferReader.readLine()) != null) {
- // check if job was cancelled
- if (monitor.isCanceled()) {
- flushInput();
- throw new CancellationException();
- }
-
- if (!nextLine.contains(DONE_MARKUP_STRING)) {
- result.add(nextLine);
- } else {
- if (checkReturnValue) {
- returnValue = Integer.valueOf(nextLine.substring(DONE_MARKUP_STRING.length()+1));
- }
- break;
- }
- }
-
- flushInput();
- }
- return new CommandResult(returnValue, result.toArray(new String[result.size()]));
- }
- });
-
- fExecutor.execute(future);
-
- try {
- return future.get(DEFAULT_TIMEOUT_VALUE, TimeUnit.MILLISECONDS);
- } catch (java.util.concurrent.ExecutionException ex) {
- throw new ExecutionException(Messages.TraceControl_ExecutionFailure, ex);
- } catch (InterruptedException ex) {
- throw new ExecutionException(Messages.TraceControl_ExecutionCancelled, ex);
- } catch (TimeoutException ex) {
- throw new ExecutionException(Messages.TraceControl_ExecutionTimeout, ex);
- }
- }
- throw new ExecutionException(Messages.TraceControl_ShellNotConnected, null);
- }
-
- // ------------------------------------------------------------------------
- // Helper methods
- // ------------------------------------------------------------------------
- /**
- * Flushes the buffer reader
- * @throws IOException
- */
- private void flushInput() throws IOException {
- char[] cbuf = new char[1];
- while (fBufferReader.ready()) {
- if (fBufferReader.read(cbuf, 0, 1) == -1) {
- break;
- }
- }
- }
-
- /**
- * format the command to be sent into the shell command with the done markup string.
- * The done markup string is needed so we can tell that end of output has been reached.
- *
- * @param cmd
- * @return formatted command string
- */
- private String formatShellCommand(String cmd) {
- if (cmd == null || cmd.equals("")) //$NON-NLS-1$
- return cmd;
- StringBuffer formattedCommand = new StringBuffer();
- // Make a multi line command by using \ and \r. This is needed for matching
- // the DONE_MARKUP_STRING in echoed command when having a long command
- // (bigger than max SSH line)
- formattedCommand.append(cmd).append("\\\r;"); //$NON-NLS-1$
- formattedCommand.append(SHELL_ECHO_CMD).append(DONE_MARKUP_STRING);
- formattedCommand.append(" $?"); //$NON-NLS-1$
- formattedCommand.append(CMD_DELIMITER);
- return formattedCommand.toString();
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- *********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.service;
-
-/**
- * <b><u>IommandResult</u></b>
- * <p>
- * Interface for providing command execution result.
- * </p>
- */
-public interface ICommandResult {
- /**
- * The result of the command.
- * @return 0 if successful else >0
- */
- public int getResult() ;
-
- /**
- * Sets the command result value.
- * @param result
- */
- public void setResult(int result);
-
- /**
- * @return returns the command output.
- */
- public String[] getOutput();
-
- /**
- * Sets the command output.
- * @param output
- */
- public void setOutput(String[] output);
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.service;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * <b><u>ICommandShell</u></b>
- * <p>
- * Interface for a command shell implementation
- * </p>
- */
-public interface ICommandShell {
-
- /**
- * Method to connect the command shell.
- * @throws ExecutionException
- */
- public void connect() throws ExecutionException;
-
- /**
- * Method to disconnect the command shell.
- */
- public void disconnect();
-
- /**
- * Method to execute a command on the command shell.
- *
- * @param command - the command to executed
- * @param monitor - a progress monitor
- * @return the command result
- * @throws ExecutionException
- */
- public ICommandResult executeCommand(String command, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Method to execute a command on the command shell.
- *
- * @param command - the command to executed
- * @param monitor - a progress monitor
- * @param checkReturnValue - flag to indicate that the command result should be checked. If false the command result will be always 0.
- * @return the command result
- * @throws ExecutionException
- */
- public ICommandResult executeCommand(final String command, final IProgressMonitor monitor, final boolean checkReturnValue) throws ExecutionException;
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.service;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-
-
-/** <b><u>ILttngControlService</u></b>
-* <p>
-* Interface for LTTng trace control command service.
-* </p>
-*/
-public interface ILttngControlService {
- /**
- * Retrieves the existing sessions names from the node.
- * @param monitor - a progress monitor
- * @return an array with session names.
- * @throws ExecutionException
- */
- public String[] getSessionNames(IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Retrieves the session information with the given name the node.
- * @param sessionName - the session name
- * @param monitor - a progress monitor
- * @return session information
- * @throws ExecutionException
- */
- public ISessionInfo getSession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Retrieves the kernel provider information (i.e. the kernel events)
- * @param monitor - a progress monitor
- * @return the list of existing kernel events.
- * @throws ExecutionException
- */
- public List<IBaseEventInfo> getKernelProvider(IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Retrieves the UST provider information from the node.
- * @return - the UST provider information.
- * @throws ExecutionException
- */
- public List<IUstProviderInfo> getUstProvider() throws ExecutionException;
- /**
- * Retrieves the UST provider information from the node.
- * @param monitor - a progress monitor
- * @return the UST provider information.
- * @throws ExecutionException
- */
- public List<IUstProviderInfo> getUstProvider(IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Creates a session with given session name and location.
- * @param sessionName - a session name to create
- * @param sessionPath - a path for storing the traces (use null for default)
- * @param monitor - a progress monitor
- * @return the session information
- * @throws ExecutionException
- */
- public ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Destroys a session with given session name.
- * @param sessionName - a session name to destroy
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void destroySession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Starts a session with given session name.
- * @param sessionName - a session name to start
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void startSession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Stops a session with given session name.
- * @param sessionName - a session name to stop
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void stopSession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
-
-
- /**
- * Enables a list of channels for given session and given channel information (configuration).
- * @param sessionName - a session name to create
- * @param channelNames - a list of channel names to be enabled
- * @param isKernel - a flag to indicate Kernel or UST (true for Kernel, false for UST)
- * @param info - channel information used for creation of a channel (or null for default)
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableChannels(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Disables a list of channels for given session and given channel information (configuration).
- * @param sessionName - a session name to create
- * @param channelNames - a list of channel names to be enabled
- * @param isKernel - a flag to indicate Kernel or UST (true for Kernel, false for UST)
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void disableChannels(String sessionName, List<String> channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Enables a list of events with no additional parameters.
- * @param sessionName - a session name
- * @param channelName - a channel name or null for default channel
- * @param eventNames - a list of event names to be enabled, or null (list of size = 0)for all events .
- * @param isKernel - a flag for indicating kernel or UST.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableEvents(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Enables all syscall events.
- * @param sessionName - a session name
- * @param channelName - a channel name or null for default channel
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableSyscalls(String sessionName, String channelName, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Enables a dynamic probe or dynamic function entry/return probe.
- * @param sessionName - a session name
- * @param channelName - a channel name or null for default channel
- * @param eventName - a event name
- * @param isFunction - true for dynamic function entry/return probe else false
- * @param probe - a dynamic probe information
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableProbe(String sessionName, String channelName, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Enables events using log level
- * @param sessionName - a session name
- * @param channelName - a channel name (null for default channel)
- * @param eventName - a event name
- * @param logLevelType - a log level type
- * @param level - a log level
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableLogLevel(String sessionName, String channelName, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Disables a list of events with no additional parameters.
- * @param sessionName - a session name
- * @param channelName - a channel name (null for default channel)
- * @param eventNames - a list of event names to enabled.
- * @param isKernel - a flag for indicating kernel or UST.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void disableEvent(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng.ui.views.control.service;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.ChannelInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.DomainInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.EventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.ProbeEventInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.SessionInfo;
-import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.UstProviderInfo;
-
-/**
- * <b><u>LTTngControlService</u></b>
- * <p>
- * Service for sending LTTng trace control commands to remote host.
- * </p>
- */
-public class LTTngControlService implements ILttngControlService {
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- // Command constants
- /**
- * The lttng tools command.
- */
- private final static String CONTROL_COMMAND = "lttng"; //$NON-NLS-1$
- /**
- * Command: lttng list.
- */
- private final static String COMMAND_LIST = CONTROL_COMMAND + " list "; //$NON-NLS-1$
- /**
- * Command to list kernel tracer information.
- */
- private final static String COMMAND_LIST_KERNEL = COMMAND_LIST + "-k"; //$NON-NLS-1$
- /**
- * Command to list user space trace information.
- */
- private final static String COMMAND_LIST_UST = COMMAND_LIST + "-u"; //$NON-NLS-1$
- /**
- * Command to create a session.
- */
- private final static String COMMAND_CREATE_SESSION = CONTROL_COMMAND + " create "; //$NON-NLS-1$
- /**
- * Command to destroy a session.
- */
- private final static String COMMAND_DESTROY_SESSION = CONTROL_COMMAND + " destroy "; //$NON-NLS-1$
- /**
- * Command to destroy a session.
- */
- private final static String COMMAND_START_SESSION = CONTROL_COMMAND + " start "; //$NON-NLS-1$
- /**
- * Command to destroy a session.
- */
- private final static String COMMAND_STOP_SESSION = CONTROL_COMMAND + " stop "; //$NON-NLS-1$
- /**
- * Command to enable a channel.
- */
- private final static String COMMAND_ENABLE_CHANNEL = CONTROL_COMMAND + " enable-channel "; //$NON-NLS-1$
- /**
- * Command to disable a channel.
- */
- private final static String COMMAND_DISABLE_CHANNEL = CONTROL_COMMAND + " disable-channel "; //$NON-NLS-1$
- /**
- * Command to enable a event.
- */
- private final static String COMMAND_ENABLE_EVENT = CONTROL_COMMAND + " enable-event "; //$NON-NLS-1$
- /**
- * Command to disable a event.
- */
- private final static String COMMAND_DISABLE_EVENT = CONTROL_COMMAND + " disable-event "; //$NON-NLS-1$
-
- // Command options constants
- /**
- * Command line option for kernel tracer.
- */
- private final static String OPTION_KERNEL = " -k "; //$NON-NLS-1$
- /**
- * Command line option for UST tracer.
- */
- private final static String OPTION_UST = " -u "; //$NON-NLS-1$
- /**
- * Command line option for specifying a session.
- */
- private final static String OPTION_SESSION = " -s "; //$NON-NLS-1$
- /**
- * Command line option for specifying a channel.
- */
- private final static String OPTION_CHANNEL = " -c "; //$NON-NLS-1$
- /**
- * Command line option for specifying all events.
- */
- private final static String OPTION_ALL = " -a "; //$NON-NLS-1$
- /**
- * Command line option for specifying tracepoint events.
- */
- private final static String OPTION_TRACEPOINT = " --tracepoint "; //$NON-NLS-1$
- /**
- * Command line option for specifying syscall events.
- */
- private final static String OPTION_SYSCALL = " --syscall "; //$NON-NLS-1$
- /**
- * Command line option for specifying a dynamic probe.
- */
- private final static String OPTION_PROBE = " --probe "; //$NON-NLS-1$
- /**
- * Command line option for specifying a dynamic function entry/return probe.
- */
- private final static String OPTION_FUNCTION_PROBE = " --function "; //$NON-NLS-1$
- /**
- * Command line option for specifying a log level range.
- */
- private final static String OPTION_LOGLEVEL = " --loglevel "; //$NON-NLS-1$
- /**
- * Command line option for specifying a specific log level.
- */
- private final static String OPTION_LOGLEVEL_ONLY = " --loglevel-only "; //$NON-NLS-1$
- /**
- * Optional command line option for configuring a channel's overwrite mode.
- */
- private final static String OPTION_OVERWRITE = " --overwrite "; //$NON-NLS-1$
- /**
- * Optional command line option for configuring a channel's number of sub buffers.
- */
- private final static String OPTION_NUM_SUB_BUFFERS = " --num-subbuf "; //$NON-NLS-1$
- /**
- * Optional command line option for configuring a channel's sub buffer size.
- */
- private final static String OPTION_SUB_BUFFER_SIZE = " --subbuf-size "; //$NON-NLS-1$
- /**
- * Optional command line option for configuring a channel's switch timer interval.
- */
- private final static String OPTION_SWITCH_TIMER = " --switch-timer "; //$NON-NLS-1$
- /**
- * Optional command line option for configuring a channel's read timer interval.
- */
- private final static String OPTION_READ_TIMER = " --read-timer "; //$NON-NLS-1$
-
- // Parsing constants
- /**
- * Pattern to match for error output
- */
- private final static Pattern ERROR_PATTERN = Pattern.compile("\\s*Error\\:.*"); //$NON-NLS-1$
- /**
- * Pattern to match for session information (lttng list)
- */
- private final static Pattern SESSION_PATTERN = Pattern.compile("\\s+(\\d+)\\)\\s+(.*)\\s+\\((.*)\\)\\s+\\[(active|inactive)\\].*"); //$NON-NLS-1$
- /**
- * Pattern to match for session information (lttng list <session>)
- */
- private final static Pattern TRACE_SESSION_PATTERN = Pattern.compile("\\s*Tracing\\s+session\\s+(.*)\\:\\s+\\[(active|inactive)\\].*"); //$NON-NLS-1$
- /**
- * Pattern to match for session path information (lttng list <session>)
- */
- private final static Pattern TRACE_SESSION_PATH_PATTERN = Pattern.compile("\\s*Trace\\s+path\\:\\s+(.*)"); //$NON-NLS-1$
- /**
- * Pattern to match for kernel domain information (lttng list <session>)
- */
- private final static Pattern DOMAIN_KERNEL_PATTERN = Pattern.compile("=== Domain: Kernel ==="); //$NON-NLS-1$
- /**
- * Pattern to match for ust domain information (lttng list <session>)
- */
- private final static Pattern DOMAIN_UST_GLOBAL_PATTERN = Pattern.compile("=== Domain: UST global ==="); //$NON-NLS-1$
- /**
- * Pattern to match for channels section (lttng list <session>)
- */
- private final static Pattern CHANNELS_SECTION_PATTERN = Pattern.compile("\\s*Channels\\:"); //$NON-NLS-1$
- /**
- * Pattern to match for channel information (lttng list <session>)
- */
- private final static Pattern CHANNEL_PATTERN = Pattern.compile("\\s*-\\s+(.*)\\:\\s+\\[(enabled|disabled)\\]"); //$NON-NLS-1$
- /**
- * Pattern to match for events section information (lttng list <session>)
- */
- private final static Pattern EVENT_SECTION_PATTERN = Pattern.compile("\\s*Events\\:"); //$NON-NLS-1$
- /**
- * Pattern to match for event information (no enabled events) (lttng list <session>)
- */
- // private final static String EVENT_NONE_PATTERN = "\\s+None"; //$NON-NLS-1$
- /**
- * Pattern to match for event information (lttng list <session>)
- */
- private final static Pattern EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
- /**
- * Pattern to match a wildcarded event information (lttng list <session>)
- */
- private final static Pattern WILDCARD_EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
- /**
- * Pattern to match a probe address information (lttng list <session>)
- */
- private final static Pattern PROBE_ADDRESS_PATTERN = Pattern.compile("\\s+(addr)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
- /**
- * Pattern to match a probe OFFSET information (lttng list <session>)
- */
- private final static Pattern PROBE_OFFSET_PATTERN = Pattern.compile("\\s+(offset)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
- /**
- * Pattern to match a probe SYMBOL information (lttng list <session>)
- */
- private final static Pattern PROBE_SYMBOL_PATTERN = Pattern.compile("\\s+(symbol)\\:\\s+(.+)"); //$NON-NLS-1$
- /**
- * Pattern to match for channel (overwite mode) information (lttng list
- * <session>)
- */
- private final static Pattern OVERWRITE_MODE_ATTRIBUTE = Pattern.compile("\\s+overwrite\\s+mode\\:.*"); //$NON-NLS-1$
- /**
- * Pattern to match indicating false for overwrite mode
- */
- private final static String OVERWRITE_MODE_ATTRIBUTE_FALSE = "0"; //$NON-NLS-1$
- /**
- * Pattern to match for channel (sub-buffer size) information (lttng list
- * <session>)
- */
- private final static Pattern SUBBUFFER_SIZE_ATTRIBUTE = Pattern.compile("\\s+subbufers\\s+size\\:.*"); //$NON-NLS-1$
- /**
- * Pattern to match for channel (number of sub-buffers) information (lttng
- * list <session>)
- */
- private final static Pattern NUM_SUBBUFFERS_ATTRIBUTE = Pattern.compile("\\s+number\\s+of\\s+subbufers\\:.*"); //$NON-NLS-1$
- /**
- * Pattern to match for channel (switch timer) information (lttng list
- * <session>)
- */
- private final static Pattern SWITCH_TIMER_ATTRIBUTE = Pattern.compile("\\s+switch\\s+timer\\s+interval\\:.*"); //$NON-NLS-1$
- /**
- * Pattern to match for channel (read timer) information (lttng list
- * <session>)
- */
- private final static Pattern READ_TIMER_ATTRIBUTE = Pattern.compile("\\s+read\\s+timer\\s+interval\\:.*"); //$NON-NLS-1$
- /**
- * Pattern to match for channel (output type) information (lttng list
- * <session>)
- */
- private final static Pattern OUTPUT_ATTRIBUTE = Pattern.compile("\\s+output\\:.*"); //$NON-NLS-1$
- /**
- * Pattern to match for provider information (lttng list -k/-u)
- */
- private final static Pattern PROVIDER_EVENT_PATTERN = Pattern.compile("\\s*(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)"); //$NON-NLS-1$
- /**
- * Pattern to match for UST provider information (lttng list -u)
- */
- private final static Pattern UST_PROVIDER_PATTERN = Pattern.compile("\\s*PID\\:\\s+(\\d+)\\s+-\\s+Name\\:\\s+(.*)"); //$NON-NLS-1$
- /**
- * Pattern to match for session information (lttng create <session name>)
- */
- private final static Pattern CREATE_SESSION_NAME_PATTERN = Pattern.compile("\\s*Session\\s+(.*)\\s+created\\."); //$NON-NLS-1$
- /**
- * Pattern to match for session path information (lttng create <session name>)
- */
- private final static Pattern CREATE_SESSION_PATH_PATTERN = Pattern.compile("\\s*Traces\\s+will\\s+be\\s+written\\s+in\\s+(.*).*"); //$NON-NLS-1$
- /**
- * Pattern to match for session command output for "session name not found".
- */
- private final static Pattern SESSION_NOT_FOUND_ERROR_PATTERN = Pattern.compile("\\s*Error:\\s+Session\\s+name\\s+not\\s+found"); //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The command shell implementation
- */
- private ICommandShell fCommandShell = null;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param shell
- * - the command shell implementation to use
- */
- public LTTngControlService(ICommandShell shell) {
- fCommandShell = shell;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService
- * #getSessionNames(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public String[] getSessionNames(IProgressMonitor monitor) throws ExecutionException {
-
- String command = COMMAND_LIST;
- ICommandResult result = fCommandShell.executeCommand(command, monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Output:
- // Available tracing sessions:
- // 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928)
- // [inactive]
- // 2) mysession (/home/user/lttng-traces/mysession-20120123-083318)
- // [inactive]
- //
- // Use lttng list <session_name> for more details
-
- ArrayList<String> retArray = new ArrayList<String>();
- int index = 0;
- while (index < result.getOutput().length) {
- String line = result.getOutput()[index];
- Matcher matcher = SESSION_PATTERN.matcher(line);
- if (matcher.matches()) {
- retArray.add(matcher.group(2).trim());
- }
- index++;
- }
- return retArray.toArray(new String[retArray.size()]);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService
- * #getSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public ISessionInfo getSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
-
- String command = COMMAND_LIST + sessionName;
- ICommandResult result = fCommandShell.executeCommand(command, monitor);
-
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- int index = 0;
-
- // Output:
- // Tracing session mysession2: [inactive]
- // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330
- ISessionInfo sessionInfo = new SessionInfo(sessionName);
-
- while (index < result.getOutput().length) {
- // Tracing session mysession2: [inactive]
- // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330
- //
- // === Domain: Kernel ===
- //
- String line = result.getOutput()[index];
- Matcher matcher = TRACE_SESSION_PATTERN.matcher(line);
- if (matcher.matches()) {
- sessionInfo.setSessionState(matcher.group(2));
- index++;
- continue;
- }
-
- matcher = TRACE_SESSION_PATH_PATTERN.matcher(line);
- if (matcher.matches()) {
- sessionInfo.setSessionPath(matcher.group(1).trim());
- index++;
- continue;
- }
-
- matcher = DOMAIN_KERNEL_PATTERN.matcher(line);
- if (matcher.matches()) {
- // Create Domain
- IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_KernelDomainDisplayName);
- sessionInfo.addDomain(domainInfo);
-
- // in domain kernel
- ArrayList<IChannelInfo> channels = new ArrayList<IChannelInfo>();
- index = parseDomain(result.getOutput(), index, channels);
-
- // set channels
- domainInfo.setChannels(channels);
-
- // set kernel flag
- domainInfo.setIsKernel(true);
- continue;
- }
-
- matcher = DOMAIN_UST_GLOBAL_PATTERN.matcher(line);
- if (matcher.matches()) {
- IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_UstGlobalDomainDisplayName);
- sessionInfo.addDomain(domainInfo);
-
- // in domain UST
- ArrayList<IChannelInfo> channels = new ArrayList<IChannelInfo>();
- index = parseDomain(result.getOutput(), index, channels);
-
- // set channels
- domainInfo.setChannels(channels);
-
- // set kernel flag
- domainInfo.setIsKernel(false);
- continue;
- }
- index++;
- }
- return sessionInfo;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService
- * #getKernelProvider(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public List<IBaseEventInfo> getKernelProvider(IProgressMonitor monitor) throws ExecutionException {
- String command = COMMAND_LIST_KERNEL;
- ICommandResult result = fCommandShell.executeCommand(command, monitor);
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Kernel events:
- // -------------
- // sched_kthread_stop (type: tracepoint)
- List<IBaseEventInfo> events = new ArrayList<IBaseEventInfo>();
- getProviderEventInfo(result.getOutput(), 0, events);
- return events;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService
- * #getUstProvider()
- */
- @Override
- public List<IUstProviderInfo> getUstProvider() throws ExecutionException {
- return getUstProvider(new NullProgressMonitor());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService
- * #getUstProvider(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public List<IUstProviderInfo> getUstProvider(IProgressMonitor monitor) throws ExecutionException {
- String command = COMMAND_LIST_UST;
- ICommandResult result = fCommandShell.executeCommand(command, monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // UST events:
- // -------------
- //
- // PID: 3635 - Name:
- // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
- // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
- // tracepoint)
- // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
- //
- // PID: 6459 - Name:
- // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
- // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
- // tracepoint)
- // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
-
- List<IUstProviderInfo> allProviders = new ArrayList<IUstProviderInfo>();
- IUstProviderInfo provider = null;
-
- int index = 0;
- while (index < result.getOutput().length) {
- String line = result.getOutput()[index];
- Matcher matcher = UST_PROVIDER_PATTERN.matcher(line);
- if (matcher.matches()) {
-
- provider = new UstProviderInfo(matcher.group(2).trim());
- provider.setPid(Integer.valueOf(matcher.group(1).trim()));
- List<IBaseEventInfo> events = new ArrayList<IBaseEventInfo>();
- index = getProviderEventInfo(result.getOutput(), ++index, events);
- provider.setEvents(events);
- allProviders.add(provider);
-
- } else {
- index++;
- }
-
- }
- return allProviders;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService#createSession(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
-
- String newName = formatParameter(sessionName);
- String newPath = formatParameter(sessionPath);
-
- String command = COMMAND_CREATE_SESSION + newName;
- if (newPath != null && !"".equals(newPath)) { //$NON-NLS-1$
- command += " -o " + newPath; //$NON-NLS-1$
- }
-
- ICommandResult result = fCommandShell.executeCommand(command, monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- //Session myssession2 created.
- //Traces will be written in /home/user/lttng-traces/myssession2-20120209-095418
- String[] output = result.getOutput();
-
- // Get and verify session name
- Matcher matcher = CREATE_SESSION_NAME_PATTERN.matcher(output[0]);
- String name = null;
-
- if (matcher.matches()) {
- name = String.valueOf(matcher.group(1).trim());
- } else {
- // Output format not expected
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
- Messages.TraceControl_UnexpectedCommnadOutputFormat + ":\n" + //$NON-NLS-1$
- formatOutput(result.getOutput()));
- }
-
- if ((name == null) || (!name.equals(sessionName))) {
- // Unexpected name returned
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
- Messages.TraceControl_UnexpectedNameError + ": " + name); //$NON-NLS-1$
- }
-
- // Get and verify session path
- matcher = CREATE_SESSION_PATH_PATTERN.matcher(output[1]);
- String path = null;
-
- if (matcher.matches()) {
- path = String.valueOf(matcher.group(1).trim());
- } else {
- // Output format not expected
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
- Messages.TraceControl_UnexpectedCommnadOutputFormat + ":\n" + //$NON-NLS-1$
- formatOutput(result.getOutput()));
- }
-
- if ((path == null) || ((sessionPath != null) && (!path.contains(sessionPath)))) {
- // Unexpected path
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
- Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$
- }
-
- SessionInfo sessionInfo = new SessionInfo(name);
- sessionInfo.setSessionPath(path);
-
- return sessionInfo;
- }
-
- @Override
- public void destroySession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
- String newName = formatParameter(sessionName);
- String command = COMMAND_DESTROY_SESSION + newName;
-
- ICommandResult result = fCommandShell.executeCommand(command, monitor);
- String[] output = result.getOutput();
-
- if (isError(result)) {
- // In case "session not found" treat it as success
- if ((output == null) || (!SESSION_NOT_FOUND_ERROR_PATTERN.matcher(output[0]).matches())) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- //Session <sessionName> destroyed
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService#startSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void startSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
-
- String newSessionName = formatParameter(sessionName);
-
- String command = COMMAND_START_SESSION + newSessionName;
-
- ICommandResult result = fCommandShell.executeCommand(command, monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- //Session <sessionName> started
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService#stopSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void stopSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
- String newSessionName = formatParameter(sessionName);
- String command = COMMAND_STOP_SESSION + newSessionName;
-
- ICommandResult result = fCommandShell.executeCommand(command, monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- //Session <sessionName> stopped
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService#enableChannel(java.lang.String, java.util.List, boolean, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableChannels(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
-
- // no channels to enable
- if (channelNames.size() == 0) {
- return;
- }
-
- String newSessionName = formatParameter(sessionName);
-
- StringBuffer command = new StringBuffer(COMMAND_ENABLE_CHANNEL);
-
- for (Iterator<String> iterator = channelNames.iterator(); iterator.hasNext();) {
- String channel = (String) iterator.next();
- command.append(channel);
- if (iterator.hasNext()) {
- command.append(","); //$NON-NLS-1$
- }
- }
-
- if (isKernel) {
- command.append(OPTION_KERNEL);
- } else {
- command.append(OPTION_UST);
- }
-
- command.append(OPTION_SESSION);
- command.append(newSessionName);
-
- if (info != null) {
-// --discard Discard event when buffers are full (default)
-
-// --overwrite Flight recorder mode
- if (info.isOverwriteMode()) {
- command.append(OPTION_OVERWRITE);
- }
-// --subbuf-size SIZE Subbuffer size in bytes
-// (default: 4096, kernel default: 262144)
- command.append(OPTION_SUB_BUFFER_SIZE);
- command.append(String.valueOf(info.getSubBufferSize()));
-
-// --num-subbuf NUM Number of subbufers
-// (default: 8, kernel default: 4)
- command.append(OPTION_NUM_SUB_BUFFERS);
- command.append(String.valueOf(info.getNumberOfSubBuffers()));
-
-// --switch-timer USEC Switch timer interval in usec (default: 0)
- command.append(OPTION_SWITCH_TIMER);
- command.append(String.valueOf(info.getSwitchTimer()));
-
-// --read-timer USEC Read timer interval in usec (default: 200)
- command.append(OPTION_READ_TIMER);
- command.append(String.valueOf(info.getReadTimer()));
- }
-
- ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService#disableChannel(java.lang.String, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void disableChannels(String sessionName, List<String> channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
-
- // no channels to enable
- if (channelNames.size() == 0) {
- return;
- }
-
- String newSessionName = formatParameter(sessionName);
-
- StringBuffer command = new StringBuffer(COMMAND_DISABLE_CHANNEL);
-
- for (Iterator<String> iterator = channelNames.iterator(); iterator.hasNext();) {
- String channel = (String) iterator.next();
- command.append(channel);
- if (iterator.hasNext()) {
- command.append(","); //$NON-NLS-1$
- }
- }
-
- if (isKernel) {
- command.append(OPTION_KERNEL);
- } else {
- command.append(OPTION_UST);
- }
-
- command.append(OPTION_SESSION);
- command.append(newSessionName);
-
- ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService#enableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableEvents(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
-
- String newSessionName = formatParameter(sessionName);
-
- StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
-
- if (eventNames == null || eventNames.size() == 0) {
- command.append(OPTION_ALL);
- } else {
-
- for (Iterator<String> iterator = eventNames.iterator(); iterator.hasNext();) {
- String event = (String) iterator.next();
- command.append(event);
- if (iterator.hasNext()) {
- command.append(","); //$NON-NLS-1$
- }
- }
- }
-
- if (isKernel) {
- command.append(OPTION_KERNEL);
- } else {
- command.append(OPTION_UST);
- }
-
- command.append(OPTION_SESSION);
- command.append(newSessionName);
-
- if (channelName != null) {
- command.append(OPTION_CHANNEL);
- command.append(channelName);
- }
-
- command.append(OPTION_TRACEPOINT);
-
- ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService#enableSyscalls(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableSyscalls(String sessionName, String channelName, IProgressMonitor monitor) throws ExecutionException {
- String newSessionName = formatParameter(sessionName);
-
- StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
-
- command.append(OPTION_ALL);
- command.append(OPTION_KERNEL);
-
- command.append(OPTION_SESSION);
- command.append(newSessionName);
-
- if (channelName != null) {
- command.append(OPTION_CHANNEL);
- command.append(channelName);
- }
-
- command.append(OPTION_SYSCALL);
-
- ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService#enableProbe(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableProbe(String sessionName, String channelName, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
- String newSessionName = formatParameter(sessionName);
-
- StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
-
- command.append(eventName);
- command.append(OPTION_KERNEL);
-
- command.append(OPTION_SESSION);
- command.append(newSessionName);
-
- if (channelName != null) {
- command.append(OPTION_CHANNEL);
- command.append(channelName);
- }
- if (isFunction) {
- command.append(OPTION_FUNCTION_PROBE);
- } else {
- command.append(OPTION_PROBE);
- }
-
- command.append(probe);
-
- ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService#enableLogLevel(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableLogLevel(String sessionName, String channelName, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
- String newSessionName = formatParameter(sessionName);
-
- StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
-
- command.append(eventName);
- command.append(OPTION_UST);
-
- command.append(OPTION_SESSION);
- command.append(newSessionName);
-
- if (channelName != null) {
- command.append(OPTION_CHANNEL);
- command.append(channelName);
- }
-
- if (logLevelType == LogLevelType.LOGLEVEL) {
- command.append(OPTION_LOGLEVEL);
- } else if (logLevelType == LogLevelType.LOGLEVEL_ONLY) {
- command.append(OPTION_LOGLEVEL_ONLY);
-
- } else {
- return;
- }
- command.append(level.getInName());
-
- ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService#disableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void disableEvent(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
- String newSessionName = formatParameter(sessionName);
-
- StringBuffer command = new StringBuffer(COMMAND_DISABLE_EVENT);
- if (eventNames == null) {
- command.append(OPTION_ALL);
- } else {
- // no events to enable
- if (eventNames.size() == 0) {
- return;
- }
-
- for (Iterator<String> iterator = eventNames.iterator(); iterator.hasNext();) {
- String event = (String) iterator.next();
- command.append(event);
- if (iterator.hasNext()) {
- command.append(","); //$NON-NLS-1$
- }
- }
- }
-
- if (isKernel) {
- command.append(OPTION_KERNEL);
- } else {
- command.append(OPTION_UST);
- }
-
- command.append(OPTION_SESSION);
- command.append(newSessionName);
-
- if (channelName != null) {
- command.append(OPTION_CHANNEL);
- command.append(channelName);
- }
-
- ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- // ------------------------------------------------------------------------
- // Helper methods
- // ------------------------------------------------------------------------
- /**
- * Checks if command result is an error result.
- *
- * @param result
- * - the command result to check
- * @return true if error else false
- */
- private boolean isError(ICommandResult result) {
- if ((result.getResult()) != 0 || (result.getOutput().length < 1 || ERROR_PATTERN.matcher(result.getOutput()[0]).matches())) {
- return true;
- }
- return false;
- }
-
- /**
- * Formats the output string as single string.
- *
- * @param output
- * - output array
- * @return - the formatted output
- */
- private String formatOutput(String[] output) {
- if (output == null || output.length == 0) {
- return ""; //$NON-NLS-1$
- }
-
- StringBuffer ret = new StringBuffer();
- for (int i = 0; i < output.length; i++) {
- ret.append(output[i] + "\n"); //$NON-NLS-1$
- }
- return ret.toString();
- }
-
- /**
- * Parses the domain information.
- *
- * @param output
- * - a command output array
- * @param currentIndex
- * - current index in command output array
- * @param channels
- * - list for returning channel information
- * @return the new current index in command output array
- */
- private int parseDomain(String[] output, int currentIndex, List<IChannelInfo> channels) {
- int index = currentIndex;
-
- // Channels:
- // -------------
- // - channnel1: [enabled]
- //
- // Attributes:
- // overwrite mode: 0
- // subbufers size: 262144
- // number of subbufers: 4
- // switch timer interval: 0
- // read timer interval: 200
- // output: splice()
-
- while (index < output.length) {
- String line = output[index];
-
- Matcher outerMatcher = CHANNELS_SECTION_PATTERN.matcher(line);
- if (outerMatcher.matches()) {
- IChannelInfo channelInfo = null;
- while (index < output.length) {
- String subLine = output[index];
-
- Matcher innerMatcher = CHANNEL_PATTERN.matcher(subLine);
- if (innerMatcher.matches()) {
- channelInfo = new ChannelInfo(""); //$NON-NLS-1$
- // get channel name
- channelInfo.setName(innerMatcher.group(1));
-
- // get channel enablement
- channelInfo.setState(innerMatcher.group(2));
-
- // add channel
- channels.add(channelInfo);
-
- } else if (OVERWRITE_MODE_ATTRIBUTE.matcher(subLine).matches()) {
- String value = getAttributeValue(subLine);
- channelInfo.setOverwriteMode(!OVERWRITE_MODE_ATTRIBUTE_FALSE.equals(value));
- } else if (SUBBUFFER_SIZE_ATTRIBUTE.matcher(subLine).matches()) {
- channelInfo.setSubBufferSize(Long.valueOf(getAttributeValue(subLine)));
-
- } else if (NUM_SUBBUFFERS_ATTRIBUTE.matcher(subLine).matches()) {
- channelInfo.setNumberOfSubBuffers(Integer.valueOf(getAttributeValue(subLine)));
-
- } else if (SWITCH_TIMER_ATTRIBUTE.matcher(subLine).matches()) {
- channelInfo.setSwitchTimer(Long.valueOf(getAttributeValue(subLine)));
-
- } else if (READ_TIMER_ATTRIBUTE.matcher(subLine).matches()) {
- channelInfo.setReadTimer(Long.valueOf(getAttributeValue(subLine)));
-
- } else if (OUTPUT_ATTRIBUTE.matcher(subLine).matches()) {
- channelInfo.setOutputType(getAttributeValue(subLine));
-
- } else if (EVENT_SECTION_PATTERN.matcher(subLine).matches()) {
- List<IEventInfo> events = new ArrayList<IEventInfo>();
- index = parseEvents(output, index, events);
- channelInfo.setEvents(events);
- // we want to stay at the current index to be able to
- // exit the domain
- continue;
- } else if (DOMAIN_KERNEL_PATTERN.matcher(subLine).matches()) {
- return index;
-
- } else if (DOMAIN_UST_GLOBAL_PATTERN.matcher(subLine).matches()) {
- return index;
- }
- index++;
- }
- }
- index++;
- }
- return index;
- }
-
- /**
- * Parses the event information within a domain.
- *
- * @param output
- * - a command output array
- * @param currentIndex
- * - current index in command output array
- * @param events
- * - list for returning event information
- * @return the new current index in command output array
- */
- private int parseEvents(String[] output, int currentIndex, List<IEventInfo> events) {
- int index = currentIndex;
-
- while (index < output.length) {
- String line = output[index];
- if (CHANNEL_PATTERN.matcher(line).matches()) {
- // end of channel
- return index;
- } else if (DOMAIN_KERNEL_PATTERN.matcher(line).matches()) {
- // end of domain
- return index;
- } else if (DOMAIN_UST_GLOBAL_PATTERN.matcher(line).matches()) {
- // end of domain
- return index;
- }
-
- Matcher matcher = EVENT_PATTERN.matcher(line);
- Matcher matcher2 = WILDCARD_EVENT_PATTERN.matcher(line);
-
- if (matcher.matches()) {
- IEventInfo eventInfo = new EventInfo(matcher.group(1).trim());
- eventInfo.setLogLevel(matcher.group(2).trim());
- eventInfo.setEventType(matcher.group(3).trim());
- eventInfo.setState(matcher.group(4));
- events.add(eventInfo);
- index++;
- } else if (matcher2.matches()) {
- IEventInfo eventInfo = new EventInfo(matcher2.group(1).trim());
- eventInfo.setLogLevel(TraceLogLevel.LEVEL_UNKNOWN);
- eventInfo.setEventType(matcher2.group(2).trim());
- eventInfo.setState(matcher2.group(3));
-
- if (eventInfo.getEventType() == TraceEventType.PROBE) {
- IProbeEventInfo probeEvent = new ProbeEventInfo(eventInfo.getName());
- probeEvent.setLogLevel(eventInfo.getLogLevel());
- probeEvent.setEventType(eventInfo.getEventType());
- probeEvent.setState(eventInfo.getState());
-
- // Overwrite eventinfo
- eventInfo = probeEvent;
-
- // myevent2 (type: probe) [enabled]
- // addr: 0xc0101340
- // myevent0 (type: probe) [enabled]
- // offset: 0x0
- // symbol: init_post
- index++;
- while (index < output.length) {
- String probeLine = output[index];
- // parse probe
- Matcher addrMatcher = PROBE_ADDRESS_PATTERN.matcher(probeLine);
- Matcher offsetMatcher = PROBE_OFFSET_PATTERN.matcher(probeLine);
- Matcher symbolMatcher = PROBE_SYMBOL_PATTERN.matcher(probeLine);
- if (addrMatcher.matches()) {
- String addr = addrMatcher.group(2).trim();
- probeEvent.setAddress(addr);
- } else if (offsetMatcher.matches()) {
- String offset = offsetMatcher.group(2).trim();
- probeEvent.setOffset(offset);
- } else if (symbolMatcher.matches()) {
- String symbol = symbolMatcher.group(2).trim();
- probeEvent.setSymbol(symbol);
- } else if ((EVENT_PATTERN.matcher(probeLine).matches()) || (WILDCARD_EVENT_PATTERN.matcher(probeLine).matches())) {
- break;
- } else if (CHANNEL_PATTERN.matcher(probeLine).matches()) {
- break;
- } else if (DOMAIN_KERNEL_PATTERN.matcher(probeLine).matches()) {
- // end of domain
- break;
- } else if (DOMAIN_UST_GLOBAL_PATTERN.matcher(probeLine).matches()) {
- // end of domain
- break;
- }
- index++;
- }
- events.add(eventInfo);
- } else {
- events.add(eventInfo);
- index++;
- continue;
- }
- } else {
- index++;
- }
-// else if (line.matches(EVENT_NONE_PATTERN)) {
- // do nothing
-// } else
-
- }
-
- return index;
- }
-
- /**
- * Parses a line with attributes: <attribute Name>: <attribute value>
- *
- * @param line
- * - attribute line to parse
- * @return the attribute value as string
- */
- private String getAttributeValue(String line) {
- String[] temp = line.split("\\: "); //$NON-NLS-1$
- return temp[1];
- }
-
- /**
- * Parses the event information within a provider.
- *
- * @param output
- * - a command output array
- * @param currentIndex
- * - current index in command output array
- * @param events
- * - list for returning event information
- * @return the new current index in command output array
- */
- private int getProviderEventInfo(String[] output, int currentIndex, List<IBaseEventInfo> events) {
- int index = currentIndex;
- while (index < output.length) {
- String line = output[index];
- Matcher matcher = PROVIDER_EVENT_PATTERN.matcher(line);
- if (matcher.matches()) {
- // sched_kthread_stop (loglevel: TRACE_EMERG0) (type:
- // tracepoint)
- IBaseEventInfo eventInfo = new BaseEventInfo(matcher.group(1).trim());
- eventInfo.setLogLevel(matcher.group(2).trim());
- eventInfo.setEventType(matcher.group(3).trim());
- events.add(eventInfo);
- } else if (UST_PROVIDER_PATTERN.matcher(line).matches()) {
- return index;
- }
- index++;
- }
- return index;
- }
-
- /**
- * Formats a command parameter for the command execution i.e. adds quotes
- * at the beginning and end if necessary.
- * @param parameter - parameter to format
- * @return formated parameter
- */
- private String formatParameter(String parameter) {
- if (parameter != null) {
- String newString = String.valueOf(parameter);
-
- if (parameter.contains(" ")) { //$NON-NLS-1$
- newString = "\"" + newString + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- }
- return newString;
- }
- return null;
- }
-
-}
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="stubs"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.junit;bundle-version="3.8.2",
+ org.eclipse.core.resources;bundle-version="3.7.0",
+ org.eclipse.core.runtime;bundle-version="3.7.0",
+ org.eclipse.core.resources;bundle-version="3.7.0",
+ org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.linuxtools.lttng2.core;bundle-version="0.1.0",
org.eclipse.linuxtools.lttng2.ui;bundle-version="0.1.0",
- org.eclipse.core.resources;bundle-version="3.7.0",
- org.eclipse.core.runtime;bundle-version="3.7.0"
+ org.eclipse.rse.core;bundle-version="3.2.0",
+ org.eclipse.rse.services;bundle-version="3.2.100",
+ org.eclipse.rse.subsystems.files.core;bundle-version="3.2.100",
+ org.eclipse.ui;bundle-version="3.7.0",
+ org.eclipse.ui.views;bundle-version="3.6.0"
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.linuxtools.lttng2.ui.tests.Activator
Bundle-ActivationPolicy: lazy
-Import-Package: org.eclipse.ui.plugin
+Import-Package: org.eclipse.ui,
+ org.eclipse.ui.plugin
// Plug-in
suite.addTestSuite(ActivatorTest.class);
+ suite.addTest(org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl.AllTests.suite());
+ suite.addTest(org.eclipse.linuxtools.lttng2.ui.tests.control.service.AllTests.suite());
+ suite.addTest(org.eclipse.linuxtools.lttng2.ui.tests.control.model.component.AllTests.suite());
+
// $JUnit-END$
return suite;
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TraceControlComponentTest.class);
+ suite.addTestSuite(TraceControlTreeModelTest.class);
+ suite.addTestSuite(TraceControlProviderTests.class);
+ suite.addTestSuite(TraceControlPropertiesTest.class);
+ //$JUnit-END$
+ return new ModelImplTestSetup(suite);
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+/**
+ * Test setup class for one-time setUp() and tearDown() across test cases.
+ */
+public class ModelImplTestSetup extends TestSetup {
+
+ public ModelImplTestSetup(Test test) {
+ super(test);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.extensions.TestSetup#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ TraceControlTestFacility.getInstance().init();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.extensions.TestSetup#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ TraceControlTestFacility.getInstance().dispose();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+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.TargetNodeState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlRoot;
+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.lttng2.ui.tests.control.model.impl.ListenerValidator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * The class <code>TraceControlComponentTest</code> contains tests for the class <code>{@link TraceControlComponent}</code>.
+ *
+ */
+@SuppressWarnings("nls")
+public class TraceControlComponentTest extends TestCase {
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Static methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns test setup used when executing test case stand-alone.
+ * @return Test setup class
+ */
+ public static Test suite() {
+ return new ModelImplTestSetup(new TestSuite(TraceControlComponentTest.class));
+ }
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Run the TraceControlComponent(String) constructor test.
+ */
+ public void testTraceControlComponent_1()
+ throws Exception {
+
+ String name = "node";
+
+ TraceControlComponent result = new TraceControlComponent(name);
+
+ assertNotNull(result);
+ assertEquals(name, result.getName());
+ assertEquals(null, result.getParent());
+ assertEquals(false, result.hasChildren());
+ assertEquals(null, result.getImage());
+ assertEquals(null, result.getControlService());
+ assertEquals(null, result.getToolTip());
+ }
+
+ /**
+ * Run the TraceControlComponent(String,ITraceControlComponent) constructor test.
+ *
+ */
+ public void testTraceControlComponent_2()
+ throws Exception {
+ String name = "node";
+
+ ITraceControlComponent parent = new TraceControlRoot();
+ TraceControlComponent result = new TraceControlComponent(name, parent);
+
+ assertNotNull(result);
+ assertEquals(name, result.getName());
+ assertEquals(false, result.hasChildren());
+ assertEquals(null, result.getImage());
+ assertEquals(null, result.getControlService());
+ assertEquals(null, result.getToolTip());
+ }
+
+ /**
+ * Run the void addChild(ITraceControlComponent) method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testAddAndGetChild1()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("node", new TraceControlRoot());
+ fixture.setToolTip("This is the test node");
+ fixture.addChild(new TraceControlRoot());
+ ITraceControlComponent component = new TraceControlRoot();
+ fixture.addChild(component);
+
+ ITraceControlComponent child = fixture.getChild(TraceControlRoot.TRACE_CONTROL_ROOT_NAME);
+ assertNotNull(child);
+ assertEquals(TraceControlRoot.TRACE_CONTROL_ROOT_NAME, child.getName());
+ }
+
+ /**
+ * Run the void addChild(ITraceControlComponent) method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testAddAndGetChild2()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ ITraceControlComponent component = null;
+
+ fixture.addChild(component);
+ assertFalse(fixture.hasChildren());
+ }
+
+ /**
+ * Run the void addComponentListener(ITraceControlComponentChangedListener) method test.
+ *
+ * @throws Exception
+ *
+ */
+
+ public void testAddComponentListener_1()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", (ITraceControlComponent) null);
+ fixture.setToolTip("");
+
+ ListenerValidator validator = new ListenerValidator();
+ fixture.addComponentListener(validator);
+
+ TraceControlRoot root = new TraceControlRoot();
+ fixture.addChild(root);
+ assertTrue(validator.isAddedCalled());
+
+ fixture.removeChild(root);
+ assertTrue(validator.isRemovedCalled());
+
+ fixture.fireComponentChanged(fixture);
+ assertTrue(validator.isChangedCalled());
+ }
+
+ /**
+ * Run the boolean containsChild(String) method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testContainsChild_1()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ fixture.addChild(new TraceControlRoot());
+ String name = "node";
+
+ boolean result = fixture.containsChild(name);
+
+ assertEquals(false, result);
+ }
+
+ /**
+ * Run the boolean containsChild(String) method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testContainsChild_2()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("name", new TraceControlRoot());
+ fixture.setToolTip("");
+
+ boolean result = fixture.containsChild(TraceControlRoot.TRACE_CONTROL_ROOT_NAME);
+
+ assertEquals(false, result);
+ }
+
+ /**
+ * 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 {
+ ITraceControlComponent parent = new TraceControlRoot();
+
+ TraceControlComponent fixture = new TraceControlComponent("node", parent);
+ fixture.setToolTip("");
+
+ ITraceControlComponent component = new TraceControlComponent("child");
+ fixture.addChild(component);
+
+ ListenerValidator validator = new ListenerValidator();
+ fixture.addComponentListener(validator);
+
+ fixture.fireComponentAdded(parent, component);
+ assertTrue(validator.isAddedCalled());
+ assertEquals(parent.getName(), validator.getSavedParent().getName());
+ assertEquals(component.getName(), validator.getSavedChild().getName());
+
+ validator.initialize();
+
+ fixture.fireComponentRemoved(parent, component);
+ assertTrue(validator.isRemovedCalled());
+ assertEquals(parent.getName(), validator.getSavedParent().getName());
+ assertEquals(component.getName(), validator.getSavedChild().getName());
+
+ validator.initialize();
+ fixture.fireComponentChanged(fixture);
+ assertTrue(validator.isChangedCalled());
+ assertEquals(fixture.getName(), validator.getSavedComponent().getName());
+ }
+
+ /**
+ * Run the Object getAdapter(Class) method test.
+ *
+ * @throws Exception
+ *
+ */
+
+ public void testGetAdapter()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ fixture.addChild(new TraceControlRoot());
+ Class<Object> adapter = Object.class;
+
+ Object result = fixture.getAdapter(adapter);
+
+ assertEquals(null, result);
+ }
+
+ /**
+ * Run the ITraceControlComponent[] getChildren() method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testGetChildren_1()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ fixture.addChild(new TraceControlRoot());
+
+ ITraceControlComponent[] result = fixture.getChildren();
+
+ assertNotNull(result);
+ assertEquals(1, result.length);
+ assertNotNull(result[0]);
+ assertEquals("trace_control_root", result[0].getName());
+ assertEquals(null, result[0].getParent());
+ assertEquals(false, result[0].hasChildren());
+ assertEquals(null, result[0].getImage());
+ assertEquals(null, result[0].getControlService());
+ assertEquals(null, result[0].getToolTip());
+ }
+
+ /**
+ * Run the ILttngControlService getControlService()/setControlService() method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testGetAndSetControlService_1()
+ throws Exception {
+
+ TraceControlComponent parent = new TraceControlComponent("parent") {
+ ILttngControlService fService = null;
+
+ @Override
+ public void setControlService(ILttngControlService service ) {
+ fService = service;
+ }
+
+ @Override
+ public ILttngControlService getControlService() {
+ return fService;
+ }
+ };
+
+ TraceControlComponent fixture = new TraceControlComponent("", parent);
+ parent.addChild(fixture);
+ fixture.setToolTip("");
+ TraceControlComponent child = new TraceControlComponent("child", fixture);
+ fixture.addChild(child);
+
+ ILttngControlService result = fixture.getControlService();
+ assertEquals(null, result);
+
+ TestRemoteSystemProxy proxy = new TestRemoteSystemProxy();
+ ILttngControlService service = new LTTngControlService(proxy.createCommandShell());
+ fixture.setControlService(service);
+ result = fixture.getControlService();
+ assertNotNull(service);
+ assertEquals(service, result);
+
+ result = fixture.getChildren()[0].getControlService();
+ assertNotNull(service);
+ assertEquals(service, result);
+ }
+
+ /**
+ * Run the Image getImage() method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testGetImage_1()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ fixture.addChild(new TraceControlRoot());
+
+ Image result = fixture.getImage();
+ assertEquals(null, result);
+
+ fixture.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
+ assertNotNull(fixture.getImage());
+ }
+
+ /**
+ * Run the boolean hasChildren() method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testHasChildren_1()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ fixture.addChild(new TraceControlRoot());
+
+ boolean result = fixture.hasChildren();
+
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean hasChildren() method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testHasChildren_2()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+
+ boolean result = fixture.hasChildren();
+
+ assertFalse(result);
+ }
+
+ /**
+ * Run the void removeAllChildren() method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testRemoveAllChildren_2()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+
+ fixture.addChild(new TraceControlRoot());
+ fixture.addChild(new TraceControlComponent("child"));
+
+ fixture.removeAllChildren();
+ assertFalse(fixture.hasChildren());
+ }
+
+ /**
+ * Run the void removeChild(ITraceControlComponent) method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testRemoveChild_1()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ TraceControlComponent child = new TraceControlComponent("child", fixture);
+
+ fixture.addChild(child);
+ fixture.removeChild(child);
+ assertFalse(fixture.hasChildren());
+ }
+
+ /**
+ * Run the void removeChild(ITraceControlComponent) method test.
+ *
+ * @throws Exception
+ *
+ */
+
+ public void testRemoveChild_2()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ fixture.addChild(new TraceControlRoot());
+ ITraceControlComponent component = null;
+
+ fixture.removeChild(component);
+ assertTrue(fixture.hasChildren());
+ }
+
+ /**
+ * Run the void removeComponentListener(ITraceControlComponentChangedListener) method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testRemoveComponentListener_1()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", (ITraceControlComponent) null);
+ fixture.setToolTip("");
+
+ ListenerValidator validator = new ListenerValidator();
+ fixture.addComponentListener(validator);
+
+ // Remove listener and check that validator is not called anymore
+ validator.initialize();
+ fixture.removeComponentListener(validator);
+ TraceControlRoot root = new TraceControlRoot();
+ fixture.addChild(root);
+ assertFalse(validator.isAddedCalled());
+
+ fixture.removeChild(root);
+ assertFalse(validator.isRemovedCalled());
+
+ fixture.fireComponentChanged(fixture);
+ assertFalse(validator.isChangedCalled());
+ }
+
+ /**
+ * Run the void removeComponentListener(ITraceControlComponentChangedListener) method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testRemoveComponentListener_2()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ fixture.addChild(new TraceControlRoot());
+ ITraceControlComponentChangedListener listener = new ControlView();
+
+ fixture.removeComponentListener(listener);
+
+ }
+
+ /**
+ * Run the void setChildren(List<ITraceControlComponent>)/ITraceControlComponent[] getChildren() method test.
+ *
+ *
+ * @throws Exception
+ *
+ */
+ public void testGetAndSetChildren()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ List<ITraceControlComponent> children = new LinkedList<ITraceControlComponent>();
+ children.add(new TraceControlComponent("child1"));
+ children.add(new TraceControlComponent("child2"));
+
+ fixture.setChildren(children);
+
+ ITraceControlComponent[] result = fixture.getChildren();
+ assertEquals(2, result.length);
+ assertEquals("child1", result[0].getName());
+ assertEquals("child2", result[1].getName());
+ }
+
+ /**
+ * Run the void String getName()/setName(String) method tests.
+ *
+ * @throws Exception
+ *
+ */
+ public void testGetAndSetName()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ fixture.addChild(new TraceControlRoot());
+ String name = "node";
+
+ fixture.setName(name);
+ assertEquals(name,fixture.getName());
+
+ }
+
+ /**
+ * Run the void ITraceControlComponent getParent()/setParent(ITraceControlComponent) method tests.
+ *
+ * @throws Exception
+ *
+ */
+ public void testGetAndSetParent()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("");
+ fixture.addChild(new TraceControlRoot());
+ ITraceControlComponent parent = new TraceControlRoot();
+ parent.addChild(fixture);
+
+ fixture.setParent(parent);
+ ITraceControlComponent retrievedParent = fixture.getParent();
+ assertNotNull(retrievedParent);
+ assertEquals(parent.getName(), retrievedParent.getName());
+ assertEquals(TraceControlRoot.TRACE_CONTROL_ROOT_NAME, retrievedParent.getName());
+ assertEquals(null, retrievedParent.getParent());
+ assertEquals(true, retrievedParent.hasChildren());
+ }
+
+ /**
+ * Run the void TargetNodeState getTargetNodeState()/etTargetNodeState(TargetNodeState) method tests.
+ *
+ * @throws Exception
+ *
+ */
+ public void testGetAndSetTargetNodeState_1()
+ throws Exception {
+
+ TraceControlComponent parent = new TraceControlComponent("parent") {
+ private TargetNodeState fState;
+
+ @Override
+ public void setTargetNodeState(TargetNodeState state ) {
+ fState = state;
+ }
+
+ @Override
+ public TargetNodeState getTargetNodeState() {
+ return fState;
+ }
+ };
+
+ TraceControlComponent fixture = new TraceControlComponent("", parent);
+ parent.addChild(fixture);
+
+ fixture.setToolTip("");
+ TargetNodeState state = TargetNodeState.CONNECTED;
+
+ fixture.setTargetNodeState(state);
+ TargetNodeState result = fixture.getTargetNodeState();
+
+ assertNotNull(result);
+ assertEquals(state, result);
+ // Check also parent
+ assertEquals(state, fixture.getParent().getTargetNodeState());
+ assertEquals("CONNECTED", result.name());
+ assertEquals("CONNECTED", result.toString());
+ assertEquals(2, result.ordinal());
+
+ fixture.setTargetNodeState(TargetNodeState.DISCONNECTED);
+ result = fixture.getTargetNodeState();
+ assertNotNull(result);
+ assertEquals("DISCONNECTED", result.name());
+ assertEquals("DISCONNECTED", result.toString());
+ assertEquals(0, result.ordinal());
+
+ state = TargetNodeState.CONNECTING;
+
+ fixture.setTargetNodeState(state);
+ result = fixture.getTargetNodeState();
+ assertNotNull(result);
+ assertEquals("CONNECTING", result.name());
+ assertEquals("CONNECTING", result.toString());
+ assertEquals(3, result.ordinal());
+
+ fixture.setTargetNodeState(TargetNodeState.DISCONNECTING);
+ result = fixture.getTargetNodeState();
+ assertNotNull(result);
+ assertEquals("DISCONNECTING", result.name());
+ assertEquals("DISCONNECTING", result.toString());
+ assertEquals(1, result.ordinal());
+
+ }
+
+ /**
+ * Run the void setToolTip(String) method test.
+ *
+ * @throws Exception
+ *
+
+ */
+
+ public void testGetSndSetToolTip()
+ throws Exception {
+ TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot());
+ fixture.setToolTip("This is a tooltip");
+ fixture.addChild(new TraceControlRoot());
+
+ String result = fixture.getToolTip();
+
+ assertEquals("This is a tooltip", result);
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+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.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.KernelProviderComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProbeEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BaseEventPropertySource;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.KernelProviderPropertySource;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TargetNodePropertySource;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceChannelPropertySource;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceDomainPropertySource;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceEventPropertySource;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceProbeEventPropertySource;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceSessionPropertySource;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.UstProviderPropertySource;
+import org.eclipse.linuxtools.lttng2.ui.tests.Activator;
+import org.eclipse.rse.core.model.Host;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.internal.core.model.SystemProfile;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.junit.After;
+import org.junit.Before;
+
+
+/**
+ * The class <code>TraceControlPropertiesTest</code> contains tests for the all property class</code>.
+ *
+ */
+@SuppressWarnings("nls")
+public class TraceControlPropertiesTest extends TestCase {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM = "ListInfoTest.cfg";
+ private static final String SCEN_LIST_INFO_TEST = "ListInfoTest";
+
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Static methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns test setup used when executing test case stand-alone.
+ * @return Test setup class
+ */
+ public static Test suite() {
+ return new ModelImplTestSetup(new TestSuite(TraceControlPropertiesTest.class));
+ }
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Run the TraceControlComponent.
+ */
+ public void testTraceControlComponents()
+ throws Exception {
+
+ TestRemoteSystemProxy proxy = new TestRemoteSystemProxy();
+
+ URL location = FileLocator.find(Activator.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ File testfile = new File(FileLocator.toFileURL(location).toURI());
+ proxy.setTestFile(testfile.getAbsolutePath());
+ proxy.setScenario(SCEN_LIST_INFO_TEST);
+
+ ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
+
+ @SuppressWarnings("restriction")
+ IHost host = new Host(new SystemProfile("myProfile", true));
+ host.setHostName("127.0.0.1");
+
+ TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, proxy);
+
+ root.addChild(node);
+ node.connect();
+
+ TraceControlTestFacility.getInstance().waitForJobs();
+
+ // ------------------------------------------------------------------------
+ // Verify Node Properties (adapter)
+ // ------------------------------------------------------------------------
+ Object adapter = node.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof TargetNodePropertySource);
+
+ TargetNodePropertySource source = (TargetNodePropertySource)adapter;
+
+ assertNull(source.getEditableValue());
+ assertFalse(source.isPropertySet(TargetNodePropertySource.TARGET_NODE_NAME_PROPERTY_ID));
+ assertNotNull(source.getPropertyDescriptors());
+
+ assertEquals("myNode", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_NAME_PROPERTY_ID));
+ assertEquals("127.0.0.1", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_ADDRESS_PROPERTY_ID));
+ assertEquals(TargetNodeState.CONNECTED.name(), source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_STATE_PROPERTY_ID));
+ assertNull(source.getPropertyValue("test"));
+
+ adapter = node.getAdapter(IChannelInfo.class);
+ assertNull(adapter);
+
+ ITraceControlComponent[] groups = node.getChildren();
+ assertNotNull(groups);
+ assertEquals(2, groups.length);
+
+ ITraceControlComponent[] providers = groups[0].getChildren();
+
+ assertNotNull(providers);
+ assertEquals(3, providers.length);
+
+ // ------------------------------------------------------------------------
+ // Verify Kernel Provider Properties (adapter)
+ // ------------------------------------------------------------------------
+ KernelProviderComponent kernelProvider = (KernelProviderComponent) providers[0];
+
+ adapter = kernelProvider.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof KernelProviderPropertySource);
+
+ KernelProviderPropertySource kernelSource = (KernelProviderPropertySource)adapter;
+ assertNotNull(kernelSource.getPropertyDescriptors());
+
+ assertEquals("Kernel", kernelSource.getPropertyValue(KernelProviderPropertySource.KERNEL_PROVIDER_NAME_PROPERTY_ID));
+
+ // ------------------------------------------------------------------------
+ // Verify UST Provider Properties (adapter)
+ // ------------------------------------------------------------------------
+ UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
+
+ adapter = ustProvider.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof UstProviderPropertySource);
+
+ UstProviderPropertySource ustSource = (UstProviderPropertySource)adapter;
+ assertNotNull(ustSource.getPropertyDescriptors());
+
+ assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustSource.getPropertyValue(UstProviderPropertySource.UST_PROVIDER_NAME_PROPERTY_ID));
+ assertEquals(String.valueOf(9379), ustSource.getPropertyValue(UstProviderPropertySource.UST_PROVIDER_PID_PROPERTY_ID));
+
+ // ------------------------------------------------------------------------
+ // Verify Base Event Properties (adapter)
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] events = ustProvider.getChildren();
+ assertNotNull(events);
+ assertEquals(2, events.length);
+
+ BaseEventComponent baseEventInfo = (BaseEventComponent) events[0];
+ assertNotNull(baseEventInfo);
+
+ adapter = baseEventInfo.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof BaseEventPropertySource);
+
+ BaseEventPropertySource baseSource = (BaseEventPropertySource)adapter;
+ assertNotNull(baseSource.getPropertyDescriptors());
+
+ assertEquals("ust_tests_hello:tptest_sighandler", baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_NAME_PROPERTY_ID));
+ assertEquals(TraceEventType.TRACEPOINT.name(), baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_TYPE_PROPERTY_ID));
+ assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE.name(), baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_LOGLEVEL_PROPERTY_ID));
+
+ // ------------------------------------------------------------------------
+ // Verify Session Properties (adapter)
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] sessions = groups[1].getChildren();
+ assertNotNull(sessions);
+ assertEquals(2, sessions.length);
+
+ TraceSessionComponent session = (TraceSessionComponent)sessions[1];
+
+ adapter = session.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof TraceSessionPropertySource);
+
+ TraceSessionPropertySource sessionSource = (TraceSessionPropertySource)adapter;
+ assertNotNull(sessionSource.getPropertyDescriptors());
+
+ assertEquals("mysession", sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_NAME_PROPERTY_ID));
+ assertEquals("/home/user/lttng-traces/mysession-20120129-084256", sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_PATH_PROPERTY_ID));
+ assertEquals(TraceSessionState.ACTIVE.name(), sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_STATE_PROPERTY_ID));
+
+ // ------------------------------------------------------------------------
+ // Verify Domain Provider Properties (adapter)
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] domains = session.getChildren();
+ assertNotNull(domains);
+ assertEquals(2, domains.length);
+
+ TraceDomainComponent domain = (TraceDomainComponent) domains[0];
+ adapter = domain.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof TraceDomainPropertySource);
+
+ TraceDomainPropertySource domainSource = (TraceDomainPropertySource)adapter;
+ assertNotNull(domainSource.getPropertyDescriptors());
+
+ assertEquals("Kernel", domainSource.getPropertyValue(TraceDomainPropertySource.TRACE_DOMAIN_NAME_PROPERTY_ID));
+
+ ITraceControlComponent[] channels = domains[0].getChildren();
+ assertNotNull(channels);
+ assertEquals(2, channels.length);
+
+ // ------------------------------------------------------------------------
+ // Verify Channel Properties (adapter)
+ // ------------------------------------------------------------------------
+ assertTrue(channels[0] instanceof TraceChannelComponent);
+ TraceChannelComponent channel = (TraceChannelComponent) channels[0];
+
+ adapter = channel.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof TraceChannelPropertySource);
+
+ TraceChannelPropertySource channelSource = (TraceChannelPropertySource)adapter;
+ assertNotNull(channelSource.getPropertyDescriptors());
+
+ assertEquals("channel0", channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_NAME_PROPERTY_ID));
+ assertEquals(String.valueOf(4), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID));
+ assertEquals(TraceEnablement.ENABLED.name(), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_STATE_PROPERTY_ID));
+ assertEquals(String.valueOf(false), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID));
+ assertEquals("splice()", channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID));
+ assertEquals(String.valueOf(200), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_READ_TIMER_PROPERTY_ID));
+ assertEquals(String.valueOf(262144), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID));
+ assertEquals(String.valueOf(0), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID));
+
+ // ------------------------------------------------------------------------
+ // Verify Event Properties (adapter)
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] channel0Events = channel.getChildren();
+ assertNotNull(channel0Events);
+ assertEquals(5, channel0Events.length);
+ assertTrue(channel0Events[0] instanceof TraceEventComponent);
+
+ TraceEventComponent event = (TraceEventComponent) channel0Events[0];
+
+ adapter = event.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof TraceEventPropertySource);
+
+ TraceEventPropertySource eventSource = (TraceEventPropertySource)adapter;
+ assertNotNull(eventSource.getPropertyDescriptors());
+
+ assertEquals("block_rq_remap", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
+ assertEquals(TraceLogLevel.TRACE_EMERG.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
+ assertEquals(TraceEventType.TRACEPOINT.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
+ assertEquals(TraceEnablement.ENABLED.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
+
+ // ------------------------------------------------------------------------
+ // Verify Probe Event Properties (adapter)
+ // ------------------------------------------------------------------------
+ assertTrue(channel0Events[2] instanceof TraceProbeEventComponent);
+
+ TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2];
+
+ adapter = probeEvent.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof TraceProbeEventPropertySource);
+
+ TraceProbeEventPropertySource probeEventSource = (TraceProbeEventPropertySource)adapter;
+ assertNotNull(probeEventSource.getPropertyDescriptors());
+ assertEquals(4, probeEventSource.getPropertyDescriptors().length);
+
+ assertEquals("myevent2", probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
+ assertEquals(TraceEventType.PROBE.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
+ assertEquals(TraceEnablement.ENABLED.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
+ assertEquals("0xc0101340", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID));
+
+ assertTrue(channel0Events[3] instanceof TraceProbeEventComponent);
+
+ probeEvent = (TraceProbeEventComponent) channel0Events[3];
+
+ adapter = probeEvent.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof TraceProbeEventPropertySource);
+
+ probeEventSource = (TraceProbeEventPropertySource)adapter;
+ assertNotNull(probeEventSource.getPropertyDescriptors());
+ assertEquals(5, probeEventSource.getPropertyDescriptors().length);
+
+ assertEquals("myevent0", probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
+ assertEquals(TraceEventType.PROBE.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
+ assertEquals(TraceEnablement.ENABLED.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
+ assertEquals("0x0", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID));
+ assertEquals("init_post", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID));
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IConfirmDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelOnSessionDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IGetEventInfoDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+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.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.KernelProviderComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderComponent;
+import org.eclipse.linuxtools.lttng2.ui.tests.Activator;
+import org.eclipse.rse.core.model.Host;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.internal.core.model.SystemProfile;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * The class <code>TraceControlTreeModelTest</code> contains tests for the tree component classes.
+ */
+@SuppressWarnings("nls")
+public class TraceControlProviderTests extends TestCase {
+
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM = "CreateTreeTest.cfg";
+ private static final String SCEN_INIT_TEST = "Initialize";
+ private static final String SCEN_SCENARIO1_TEST = "Scenario1";
+ private static final String SCEN_SCENARIO2_TEST = "Scenario2";
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private TraceControlTestFacility fFacility;
+ private TestRemoteSystemProxy fProxy;
+ private String fTestFile;
+
+ // ------------------------------------------------------------------------
+ // Static methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns test setup used when executing test case stand-alone.
+ * @return Test setup class
+ */
+ public static Test suite() {
+ return new ModelImplTestSetup(new TestSuite(TraceControlProviderTests.class));
+ }
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ fFacility = TraceControlTestFacility.getInstance();
+ fProxy = new TestRemoteSystemProxy();
+ URL location = FileLocator.find(Activator.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ File testfile = new File(FileLocator.toFileURL(location).toURI());
+ fTestFile = testfile.getAbsolutePath();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Run the TraceControlComponent.
+ */
+ public void testTraceControlComponents()
+ throws Exception {
+
+ fProxy.setTestFile(fTestFile);
+ fProxy.setScenario(SCEN_INIT_TEST);
+
+ ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
+
+ @SuppressWarnings("restriction")
+ IHost host = new Host(new SystemProfile("myProfile", true));
+ host.setHostName("127.0.0.1");
+
+ TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy);
+
+ root.addChild(node);
+ node.connect();
+
+ fFacility.waitForJobs();
+
+ // Verify that node is connected
+ assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState());
+
+ // Get provider groups
+ ITraceControlComponent[] groups = node.getChildren();
+ assertNotNull(groups);
+ assertEquals(2, groups.length);
+
+ // Get kernel provider
+ ITraceControlComponent[] providers = groups[0].getChildren();
+ KernelProviderComponent kernelProvider = (KernelProviderComponent) providers[0];
+
+ // Get kernel provider events and select 2 events
+ ITraceControlComponent[] events = kernelProvider.getChildren();
+ assertNotNull(events);
+ assertEquals(3, events.length);
+
+ BaseEventComponent baseEventInfo0 = (BaseEventComponent) events[0];
+ BaseEventComponent baseEventInfo1 = (BaseEventComponent) events[1];
+
+ // Initialize dialog implementations for command execution
+ TraceControlDialogFactory.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
+ TraceControlDialogFactory.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
+ TraceControlDialogFactory.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
+
+ // Initialize scenario
+ fProxy.setScenario(SCEN_SCENARIO1_TEST);
+
+ // ------------------------------------------------------------------------
+ // Create session
+ // ------------------------------------------------------------------------
+ TraceSessionComponent session = createSession(groups[1]);
+
+ // Verify that session was created
+ assertNotNull(session);
+ assertEquals("mysession", session.getName());
+ assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session.getSessionPath());
+ assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
+
+ // ------------------------------------------------------------------------
+ // Enable event on default channel on created session above
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] components = { baseEventInfo0, baseEventInfo1 };
+
+ fFacility.getControlView().setSelection(components);
+ // Give GUI time to actually execute refresh
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+
+ fFacility.executeCommand("assign.event");
+ fFacility.waitForJobs();
+
+ // Verify that kernel domain was created
+ ITraceControlComponent[] domains = session.getChildren();
+ assertNotNull(domains);
+ assertEquals(1, domains.length);
+
+ assertEquals("Kernel", domains[0].getName());
+
+ // Verify that channel0 was created with default values
+ ITraceControlComponent[] channels = domains[0].getChildren();
+ assertNotNull(channels);
+ assertEquals(1, channels.length);
+
+ assertTrue(channels[0] instanceof TraceChannelComponent);
+ TraceChannelComponent channel = (TraceChannelComponent) channels[0];
+ assertEquals("channel0", channel.getName());
+ assertEquals(4, channel.getNumberOfSubBuffers());
+ assertEquals("splice()", channel.getOutputType());
+ assertEquals(false, channel.isOverwriteMode());
+ assertEquals(200, channel.getReadTimer());
+ assertEquals(TraceEnablement.ENABLED, channel.getState());
+ assertEquals(262144, channel.getSubBufferSize());
+ assertEquals(0, channel.getSwitchTimer());
+
+ // Verify that event components were created
+ ITraceControlComponent[] channel0Events = channel.getChildren();
+ assertNotNull(channel0Events);
+ assertEquals(2, channel0Events.length);
+ assertTrue(channel0Events[0] instanceof TraceEventComponent);
+ assertTrue(channel0Events[1] instanceof TraceEventComponent);
+
+ TraceEventComponent event = (TraceEventComponent) channel0Events[0];
+ assertEquals("sched_kthread_stop_ret", event.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ TraceEventComponent event1 = (TraceEventComponent) channel0Events[1];
+ assertEquals("sched_kthread_stop", event1.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, event1.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event1.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event1.getState());
+
+ // ------------------------------------------------------------------------
+ // Disable event components
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] selection = { event, event1 };
+ fFacility.getControlView().setSelection(selection);
+ // Give GUI time to actually execute the selection
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+ fFacility.executeCommand("disable.event");
+ fFacility.waitForJobs();
+
+ assertEquals(TraceEnablement.DISABLED, event.getState());
+ assertEquals(TraceEnablement.DISABLED, event1.getState());
+
+ // ------------------------------------------------------------------------
+ // Enable event component
+ // ------------------------------------------------------------------------
+ fFacility.getControlView().setSelection(event1);
+ fFacility.executeCommand("enable.event");
+ fFacility.waitForJobs();
+
+ // Verify event state
+ assertEquals(TraceEnablement.ENABLED, event1.getState());
+
+ // ------------------------------------------------------------------------
+ // Destroy session
+ // ------------------------------------------------------------------------
+ destroySession(session);
+
+ // Verify that no more session components exist
+ assertEquals(0, groups[1].getChildren().length);
+
+
+ // ------------------------------------------------------------------------
+ // Create session
+ // ------------------------------------------------------------------------
+ fProxy.setScenario(SCEN_SCENARIO2_TEST);
+
+ CreateSessionDialogStub sessionDialogStub = new CreateSessionDialogStub();
+ sessionDialogStub.setSessionPath("/home/user/temp");
+ TraceControlDialogFactory.getInstance().setCreateSessionDialog(sessionDialogStub);
+
+ session = createSession(groups[1]);
+
+ // Verify that session was created
+ assertNotNull(session);
+ assertEquals("mysession", session.getName());
+ assertEquals("/home/user/temp", session.getSessionPath());
+ assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
+
+ // ------------------------------------------------------------------------
+ // Create Channel on UST global domain
+ // ------------------------------------------------------------------------
+ TraceControlDialogFactory.getInstance().setCreateChannelOnSessionDialog(new CreateChannelOnSessionDialogStub());
+
+ fFacility.getControlView().setSelection(session);
+ // Give GUI time to actually execute refresh
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+
+ fFacility.executeCommand("createChannelOnSession");
+ fFacility.waitForJobs();
+
+ // Verify that UST domain was created
+ domains = session.getChildren();
+ assertNotNull(domains);
+ assertEquals(1, domains.length);
+
+ assertEquals("UST global", domains[0].getName());
+
+ // Verify that channel was created with correct data
+ channels = domains[0].getChildren();
+ assertNotNull(channels);
+ assertEquals(1, channels.length);
+
+ assertTrue(channels[0] instanceof TraceChannelComponent);
+ channel = (TraceChannelComponent) channels[0];
+ assertEquals("mychannel", channel.getName());
+ assertEquals(2, channel.getNumberOfSubBuffers());
+ assertEquals("mmap()", channel.getOutputType());
+ assertEquals(false, channel.isOverwriteMode());
+ assertEquals(100, channel.getReadTimer());
+ assertEquals(TraceEnablement.ENABLED, channel.getState());
+ assertEquals(16384, channel.getSubBufferSize());
+ assertEquals(200, channel.getSwitchTimer());
+
+ // ------------------------------------------------------------------------
+ // Enable event on default channel on created session above
+ // ------------------------------------------------------------------------
+ // Get first UST provider
+ UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
+ assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
+ assertEquals(9379, ustProvider.getPid());
+
+ // Get events
+ events = ustProvider.getChildren();
+ assertNotNull(events);
+ assertEquals(2, events.length);
+
+ baseEventInfo0 = (BaseEventComponent) events[0];
+ baseEventInfo1 = (BaseEventComponent) events[1];
+
+ ITraceControlComponent[] ustSelection = { baseEventInfo0, baseEventInfo1 };
+
+ fFacility.getControlView().setSelection(ustSelection);
+ // Give GUI time to actually execute refresh
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+ fFacility.executeCommand("assign.event");
+ fFacility.waitForJobs();
+
+ // verify that events were created under the channel
+ // Note that domain and channel has to be re-read because the tree is re-created
+
+ domains = session.getChildren();
+
+ // Verify that channel was created with correct data
+ channels = domains[0].getChildren();
+
+ ITraceControlComponent[] ustEvents = channels[0].getChildren();
+ assertEquals(2, ustEvents.length);
+
+ event = (TraceEventComponent) ustEvents[0];
+ assertEquals("ust_tests_hello:tptest_sighandler", event.getName());
+ assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ event = (TraceEventComponent) ustEvents[1];
+ assertEquals("ust_tests_hello:tptest", ustEvents[1].getName());
+ assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ // ------------------------------------------------------------------------
+ // Disable event components
+ // ------------------------------------------------------------------------
+ fFacility.getControlView().setSelection(event);
+ // Give GUI time to actually execute the selection
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+ fFacility.executeCommand("disable.event");
+ fFacility.waitForJobs();
+
+ assertEquals(TraceEnablement.DISABLED, event.getState());
+
+ // ------------------------------------------------------------------------
+ // Enable event component
+ // ------------------------------------------------------------------------
+ fFacility.getControlView().setSelection(event);
+ fFacility.executeCommand("enable.event");
+ fFacility.waitForJobs();
+
+ // Verify event state
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ // ------------------------------------------------------------------------
+ // Destroy session
+ // ------------------------------------------------------------------------
+ destroySession(session);
+
+ // Verify that no more session components exist
+ assertEquals(0, groups[1].getChildren().length);
+
+
+// fFacility.delay(60000);
+ }
+
+ private TraceSessionComponent createSession(ITraceControlComponent group) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
+ fFacility.getControlView().setSelection(group);
+ // Give GUI time to actually execute the selection
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+ fFacility.executeCommand("createSession");
+ fFacility.waitForJobs();
+
+ ITraceControlComponent[] sessions = group.getChildren();
+ if ((sessions == null) || (sessions.length == 0)) {
+ return null;
+ }
+ return (TraceSessionComponent)sessions[0];
+ }
+
+ private void destroySession(TraceSessionComponent session) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
+ fFacility.getControlView().setSelection(session);
+ // Give GUI time to actually execute the selection
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+ fFacility.executeCommand("destroySession");
+ fFacility.waitForJobs();
+ }
+
+// assertEquals("sched_kthread_stop_ret", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// baseEventInfo = (BaseEventComponent) events[2];
+// assertEquals("sched_wakeup_new", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// // ------------------------------------------------------------------------
+// // Verify UstProviderComponent
+// // ------------------------------------------------------------------------
+// UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
+// assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
+// assertEquals(9379, ustProvider.getPid());
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (UST provider)
+// // ------------------------------------------------------------------------
+// events = ustProvider.getChildren();
+// assertNotNull(events);
+// assertEquals(2, events.length);
+//
+// baseEventInfo = (BaseEventComponent) events[0];
+// assertNotNull(baseEventInfo);
+// assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// baseEventInfo = (BaseEventComponent) events[1];
+// assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// // ------------------------------------------------------------------------
+// // Verify UstProviderComponent
+// // ------------------------------------------------------------------------
+// ustProvider = (UstProviderComponent) providers[2];
+// assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
+// assertEquals(4852, ustProvider.getPid());
+//
+// // verify getters and setter
+// verifyUstProviderGettersSetters(ustProvider);
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (UST provider)
+// // ------------------------------------------------------------------------
+// events = ustProvider.getChildren();
+// assertNotNull(events);
+// assertEquals(2, events.length);
+//
+// baseEventInfo = (BaseEventComponent) events[0];
+// assertNotNull(baseEventInfo);
+// assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// baseEventInfo = (BaseEventComponent) events[1];
+// assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// // verify getters and setters
+// verifyBaseEventGettersSetters(baseEventInfo);
+//
+// // ------------------------------------------------------------------------
+// // Verify TraceSessionGroup
+// // ------------------------------------------------------------------------
+// ITraceControlComponent[] sessions = groups[1].getChildren();
+// assertNotNull(sessions);
+// assertEquals(2, sessions.length);
+// for (int i = 0; i < sessions.length; i++) {
+// assertTrue(sessions[i] instanceof TraceSessionComponent);
+// }
+// assertEquals("mysession1", sessions[0].getName());
+// assertEquals("mysession", sessions[1].getName());
+//
+// // ------------------------------------------------------------------------
+// // Verify TraceSessionComponent
+// // ------------------------------------------------------------------------
+// TraceSessionComponent session = (TraceSessionComponent)sessions[1];
+// assertEquals("mysession", session.getName());
+// assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
+// assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
+//
+// // Verify setters and setters
+// verifySessionGetterSetters(session);
+//
+// ITraceControlComponent[] domains = session.getChildren();
+// assertNotNull(domains);
+// assertEquals(2, domains.length);
+//
+// // ------------------------------------------------------------------------
+// // Verify Kernel domain
+// // ------------------------------------------------------------------------
+// assertEquals("Kernel", domains[0].getName());
+// ITraceControlComponent[] channels = domains[0].getChildren();
+// assertNotNull(channels);
+// assertEquals(2, channels.length);
+//
+// // ------------------------------------------------------------------------
+// // Verify Kernel's channel0
+// // ------------------------------------------------------------------------
+// assertTrue(channels[0] instanceof TraceChannelComponent);
+// TraceChannelComponent channel = (TraceChannelComponent) channels[0];
+// assertEquals("channel0", channel.getName());
+// assertEquals(4, channel.getNumberOfSubBuffers());
+// assertEquals("splice()", channel.getOutputType());
+// assertEquals(false, channel.isOverwriteMode());
+// assertEquals(200, channel.getReadTimer());
+// assertEquals(TraceEnablement.ENABLED, channel.getState());
+// assertEquals(262144, channel.getSubBufferSize());
+// assertEquals(0, channel.getSwitchTimer());
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (kernel, channel0)
+// // ------------------------------------------------------------------------
+// ITraceControlComponent[] channel0Events = channel.getChildren();
+// assertNotNull(channel0Events);
+// assertEquals(5, channel0Events.length);
+// assertTrue(channel0Events[0] instanceof TraceEventComponent);
+// assertTrue(channel0Events[1] instanceof TraceEventComponent);
+// assertTrue(channel0Events[2] instanceof TraceProbeEventComponent);
+// assertTrue(channel0Events[3] instanceof TraceProbeEventComponent);
+// assertTrue(channel0Events[4] instanceof TraceEventComponent);
+//
+// TraceEventComponent event = (TraceEventComponent) channel0Events[0];
+// assertEquals("block_rq_remap", event.getName());
+// assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+// assertEquals(TraceEnablement.ENABLED, event.getState());
+//
+// event = (TraceEventComponent) channel0Events[1];
+// assertEquals("block_bio_remap", event.getName());
+// assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+// assertEquals(TraceEnablement.DISABLED, event.getState());
+//
+// TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2];
+// assertEquals("myevent2", probeEvent.getName());
+// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
+// assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
+// assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
+// assertEquals("0xc0101340", probeEvent.getAddress());
+// assertNull(probeEvent.getOffset());
+// assertNull(probeEvent.getSymbol());
+//
+// probeEvent = (TraceProbeEventComponent) channel0Events[3];
+// assertEquals("myevent0", probeEvent.getName());
+// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
+// assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
+// assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
+// assertNull(probeEvent.getAddress());
+// assertEquals("0x0", probeEvent.getOffset());
+// assertEquals("init_post", probeEvent.getSymbol());
+//
+// event = (TraceEventComponent) channel0Events[4];
+// assertEquals("syscalls", event.getName());
+// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
+// assertEquals(TraceEventType.SYSCALL, event.getEventType());
+// assertEquals(TraceEnablement.ENABLED, event.getState());
+//
+// // ------------------------------------------------------------------------
+// // Verify Kernel's channel1
+// // ------------------------------------------------------------------------
+// assertEquals("channel1", channels[1].getName());
+// channel = (TraceChannelComponent) channels[1];
+// assertEquals(4, channel.getNumberOfSubBuffers());
+// assertEquals("splice()", channel.getOutputType());
+// assertEquals(true, channel.isOverwriteMode());
+// assertEquals(400, channel.getReadTimer());
+// assertEquals(TraceEnablement.DISABLED, channel.getState());
+// assertEquals(524288, channel.getSubBufferSize());
+// assertEquals(100, channel.getSwitchTimer());
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (kernel, channel1)
+// // ------------------------------------------------------------------------
+// ITraceControlComponent[] channel1Events = channels[1].getChildren();
+// assertEquals(0, channel1Events.length);
+//
+// // ------------------------------------------------------------------------
+// // Verify domain UST global
+// // ------------------------------------------------------------------------
+// assertEquals("UST global", domains[1].getName());
+//
+// ITraceControlComponent[] ustChannels = domains[1].getChildren();
+//
+// for (int i = 0; i < ustChannels.length; i++) {
+// assertTrue(ustChannels[i] instanceof TraceChannelComponent);
+// }
+//
+// // ------------------------------------------------------------------------
+// // Verify UST global's mychannel1
+// // ------------------------------------------------------------------------
+// channel = (TraceChannelComponent) ustChannels[0];
+// assertEquals("mychannel1", channel.getName());
+// assertEquals(8, channel.getNumberOfSubBuffers());
+// assertEquals("mmap()", channel.getOutputType());
+// assertEquals(true, channel.isOverwriteMode());
+// assertEquals(100, channel.getReadTimer());
+// assertEquals(TraceEnablement.DISABLED, channel.getState());
+// assertEquals(8192, channel.getSubBufferSize());
+// assertEquals(200, channel.getSwitchTimer());
+//
+// // verify getters and setters
+// verifyChannelGettersSetters(channel);
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (UST global, mychannel1)
+// // ------------------------------------------------------------------------
+// ITraceControlComponent[] ustEvents = channel.getChildren();
+// assertEquals(0, ustEvents.length);
+//
+// // ------------------------------------------------------------------------
+// // Verify UST global's channel0
+// // ------------------------------------------------------------------------
+// channel = (TraceChannelComponent) ustChannels[1];
+// assertEquals("channel0", channel.getName());
+// assertEquals(4, channel.getNumberOfSubBuffers());
+// assertEquals("mmap()", channel.getOutputType());
+// assertEquals(false, channel.isOverwriteMode());
+// assertEquals(200, channel.getReadTimer());
+// assertEquals(TraceEnablement.ENABLED, channel.getState());
+// assertEquals(4096, channel.getSubBufferSize());
+// assertEquals(0, channel.getSwitchTimer());
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (UST global, channel0)
+// // ------------------------------------------------------------------------
+// ustEvents = channel.getChildren();
+// assertEquals(2, ustEvents.length);
+//
+// event = (TraceEventComponent) ustEvents[0];
+// assertEquals("ust_tests_hello:tptest_sighandler", event.getName());
+// assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+// assertEquals(TraceEnablement.DISABLED, event.getState());
+//
+// event = (TraceEventComponent) ustEvents[1];
+// assertEquals("*", ustEvents[1].getName());
+// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+// assertEquals(TraceEnablement.ENABLED, event.getState());
+//
+// // verify getters and setters
+// verifyEventGettersSetters(event);
+//
+// // disconnect
+// node.disconnect();
+// assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
+// assertNotNull(node.getImage());
+// assertNotSame(connectedImage, node.getImage());
+// }
+//
+// private void verifySessionGetterSetters(TraceSessionComponent session) {
+// // save original values
+// String name = session.getName();
+// String origPath = session.getSessionPath();
+// TraceSessionState origState = session.getSessionState();
+//
+// // test cases
+// session.setName("newName");
+// assertEquals("newName", session.getName());
+//
+// session.setSessionPath("/home/user/tmp");
+// assertEquals("/home/user/tmp", session.getSessionPath());
+//
+// session.setSessionState(TraceSessionState.INACTIVE);
+// assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
+// Image inactiveImage = session.getImage();
+// assertNotNull(inactiveImage);
+//
+// session.setSessionState("active");
+// assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
+//
+// Image activeImage = session.getImage();
+// assertNotNull(activeImage);
+// assertNotSame(activeImage, inactiveImage);
+//
+//
+// // restore original values
+// session.setName(name);
+// session.setSessionPath(origPath);
+// session.setSessionState(origState);
+// }
+//
+// private void verifyBaseEventGettersSetters(BaseEventComponent event) {
+// // save original values
+// String name = event.getName();
+// TraceLogLevel level = event.getLogLevel();
+// TraceEventType type = event.getEventType();
+//
+// // test cases
+// event.setName("newName");
+// assertEquals("newName", event.getName());
+//
+// event.setLogLevel(TraceLogLevel.TRACE_INFO);
+// assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel());
+// event.setLogLevel("TRACE_ALERT");
+// assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel());
+//
+// event.setEventType(TraceEventType.UNKNOWN);
+// assertEquals(TraceEventType.UNKNOWN, event.getEventType());
+// event.setEventType("tracepoint");
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+//
+// // restore original values
+// event.setName(name);
+// event.setLogLevel(level);
+// event.setEventType(type);
+// }
+//
+// private void verifyEventGettersSetters(TraceEventComponent event) {
+// // save original values
+// String name = event.getName();
+// TraceLogLevel level = event.getLogLevel();
+// TraceEventType type = event.getEventType();
+// TraceEnablement state = event.getState();
+//
+// // test cases
+// event.setName("newName");
+// assertEquals("newName", event.getName());
+//
+// event.setLogLevel(TraceLogLevel.TRACE_INFO);
+// assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel());
+// event.setLogLevel("TRACE_ALERT");
+// assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel());
+//
+// event.setEventType(TraceEventType.UNKNOWN);
+// assertEquals(TraceEventType.UNKNOWN, event.getEventType());
+// event.setEventType("tracepoint");
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+//
+// event.setState("disabled");
+// assertEquals(TraceEnablement.DISABLED, event.getState());
+//
+// Image disabledImage = event.getImage();
+// assertNotNull(disabledImage);
+//
+// event.setState(TraceEnablement.ENABLED);
+// assertEquals(TraceEnablement.ENABLED, event.getState());
+//
+// Image enabledImage = event.getImage();
+// assertNotNull(enabledImage);
+// assertNotSame(enabledImage, disabledImage);
+//
+// // restore original values
+// event.setName(name);
+// event.setLogLevel(level);
+// event.setEventType(type);
+// event.setState(state);
+// }
+//
+// private void verifyChannelGettersSetters(TraceChannelComponent channel) {
+// // save original values
+// String name = channel.getName();
+// int nbSubBuffers = channel.getNumberOfSubBuffers();
+// String type = channel.getOutputType();
+// boolean mode = channel.isOverwriteMode();
+// long readTimer = channel.getReadTimer();
+// TraceEnablement state = channel.getState();
+// long subBufferSize = channel.getSubBufferSize();
+// long switchTimer = channel.getSwitchTimer();
+//
+// // test cases
+// channel.setName("newName");
+// assertEquals("newName", channel.getName());
+//
+// channel.setNumberOfSubBuffers(2);
+// assertEquals(2, channel.getNumberOfSubBuffers());
+//
+// channel.setOutputType("splice()");
+// assertEquals("splice()", channel.getOutputType());
+//
+// channel.setOverwriteMode(false);
+// assertEquals(false, channel.isOverwriteMode());
+//
+// channel.setReadTimer(250);
+// assertEquals(250, channel.getReadTimer());
+//
+// channel.setState("enabled");
+// assertEquals(TraceEnablement.ENABLED, channel.getState());
+//
+// Image enabledImage = channel.getImage();
+// assertNotNull(enabledImage);
+// channel.setState(TraceEnablement.DISABLED);
+// assertEquals(TraceEnablement.DISABLED, channel.getState());
+//
+// Image disabledImage = channel.getImage();
+// assertNotNull(disabledImage);
+// assertNotSame(enabledImage, disabledImage);
+//
+// channel.setSubBufferSize(1024);
+// assertEquals(1024, channel.getSubBufferSize());
+//
+// channel.setSwitchTimer(1000);
+// assertEquals(1000, channel.getSwitchTimer());
+//
+// // restore original values
+// channel.setName(name);
+// channel.setNumberOfSubBuffers(nbSubBuffers);
+// channel.setOutputType(type);
+// channel.setOverwriteMode(mode);
+// channel.setReadTimer(readTimer);
+// channel.setState(state);
+// channel.setSubBufferSize(subBufferSize);
+// channel.setSwitchTimer(switchTimer);
+// }
+//
+// private void verifyUstProviderGettersSetters(UstProviderComponent ustProvider) {
+// // save original values
+// String name = ustProvider.getName();
+// int pid = ustProvider.getPid();
+//
+// // test cases
+// ustProvider.setName("newName");
+// assertEquals("newName", ustProvider.getName());
+//
+// ustProvider.setPid(9876);
+// assertEquals(9876, ustProvider.getPid());
+//
+// // restore original values
+// ustProvider.setName(name);
+// ustProvider.setPid(pid);
+// }
+
+ public class CreateSessionDialogStub implements ICreateSessionDialog {
+ public String fPath = null;
+
+ @Override
+ public String getSessionName() {
+ return "mysession";
+ }
+
+ @Override
+ public String getSessionPath() {
+ return fPath;
+ }
+
+ @Override
+ public boolean isDefaultSessionPath() {
+ return fPath == null;
+ }
+
+ @Override
+ public void setTraceSessionGroup(TraceSessionGroup group) {
+
+ }
+
+ @Override
+ public int open() {
+ return 0;
+ }
+
+ public void setSessionPath(String path) {
+ fPath = path;
+ }
+ }
+
+ public class GetEventInfoDialogStub implements IGetEventInfoDialog {
+
+ private TraceSessionComponent[] fSessions;
+
+ @Override
+ public TraceSessionComponent getSession() {
+ return fSessions[0];
+ }
+
+ @Override
+ public TraceChannelComponent getChannel() {
+ return null;
+ }
+
+ @Override
+ public void setIsKernel(boolean isKernel) {
+ }
+
+ @Override
+ public void setSessions(TraceSessionComponent[] sessions) {
+ fSessions = sessions;
+ }
+
+ @Override
+ public int open() {
+ return 0;
+ }
+ }
+
+ public class DestroyConfirmDialogStub implements IConfirmDialog {
+
+ @Override
+ public boolean openConfirm(Shell parent, String title, String message) {
+ return true;
+ }
+ }
+
+ public class CreateChannelOnSessionDialogStub implements ICreateChannelOnSessionDialog {
+
+ @Override
+ public IChannelInfo getChannelInfo() {
+ ChannelInfo info = new ChannelInfo("mychannel");
+ info.setNumberOfSubBuffers(2);
+ info.setOverwriteMode(false);
+ info.setReadTimer(100);
+ info.setSwitchTimer(200);
+ info.setSubBufferSize(16384);
+ return info;
+ }
+
+ @Override
+ public void setDomainComponent(TraceDomainComponent domain) {
+ }
+
+ @Override
+ public int open() {
+ return 0;
+ }
+
+ @Override
+ public boolean isKernel() {
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerService;
+
+/**
+ * Singleton class to facilitate the test cases. Creates UML2SD view and loader objects as well as provides
+ * utility methods for interacting with the loader/view.
+ */
+public class TraceControlTestFacility {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ final static public int WAIT_FOR_JOBS_DELAY = 1000;
+ final static public int GUI_REFESH_DELAY = 500;
+
+ final static public String COMMAND_CATEGORY_PREFIX = "org.eclipse.linuxtools.internal.lttng2.ui.commands.control."; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ private static TraceControlTestFacility fInstance = null;
+ private ControlView fControlView = null;
+ private boolean fIsInitialized = false;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ private TraceControlTestFacility() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ public static TraceControlTestFacility getInstance() {
+ if (fInstance == null) {
+ fInstance = new TraceControlTestFacility();
+ }
+ return fInstance;
+ }
+
+ /**
+ * Initial the test facility.
+ */
+ public void init() {
+
+ if (!fIsInitialized) {
+
+ IViewPart view;
+ try {
+ view = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getActivePage()
+ .showView(ControlView.ID);
+
+ } catch (PartInitException e) {
+ throw new RuntimeException(e);
+ }
+
+ fControlView = (ControlView) view;
+
+ delay(3000);
+ fIsInitialized = true;
+ }
+ }
+
+
+ public void dispose() {
+ if (fIsInitialized) {
+ waitForJobs();
+
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(fControlView);
+ fIsInitialized = false;
+ }
+ }
+
+ public void delay(long waitTimeMillis) {
+ Display display = Display.getCurrent();
+ if (display != null) {
+ long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
+ while(System.currentTimeMillis() < endTimeMillis) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ display.update();
+ }
+ } else {
+ try {
+ Thread.sleep(waitTimeMillis);
+ } catch (InterruptedException e) {
+ // Ignored
+ }
+ }
+ }
+
+ /**
+ * Waits for all Eclipse jobs to finish
+ */
+ public void waitForJobs() {
+ while (!Job.getJobManager().isIdle()) {
+ delay(WAIT_FOR_JOBS_DELAY);
+ }
+ }
+
+
+ /**
+ * @return current control view
+ */
+ public ControlView getControlView() {
+ return fControlView;
+ }
+
+ public void executeCommand(String commandId) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
+// ICommandService commandService = (ICommandService) fControlView.getSite().getService(ICommandService.class);
+ IHandlerService handlerService = (IHandlerService) fControlView.getSite().getService(IHandlerService.class);
+ handlerService.executeCommand(COMMAND_CATEGORY_PREFIX + commandId, null);
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy;
+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.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.KernelProviderComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProbeEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderComponent;
+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.lttng2.ui.tests.Activator;
+import org.eclipse.rse.core.model.Host;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.internal.core.model.SystemProfile;
+import org.eclipse.swt.graphics.Image;
+import org.junit.After;
+import org.junit.Before;
+
+
+/**
+ * The class <code>TraceControlTreeModelTest</code> contains tests for the tree component classes.
+ */
+@SuppressWarnings("nls")
+public class TraceControlTreeModelTest extends TestCase {
+
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM = "ListInfoTest.cfg";
+ private static final String SCEN_LIST_INFO_TEST = "ListInfoTest";
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+
+ private TestRemoteSystemProxy fProxy;
+ private String fTestFile;
+
+ // ------------------------------------------------------------------------
+ // Static methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns test setup used when executing test case stand-alone.
+ * @return Test setup class
+ */
+ public static Test suite() {
+ return new ModelImplTestSetup(new TestSuite(TraceControlTreeModelTest.class));
+ }
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ fProxy = new TestRemoteSystemProxy();
+ URL location = FileLocator.find(Activator.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ File testfile = new File(FileLocator.toFileURL(location).toURI());
+ fTestFile = testfile.getAbsolutePath();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Run the TraceControlComponent.
+ */
+ public void testTraceControlComponents()
+ throws Exception {
+
+ fProxy.setTestFile(fTestFile);
+ fProxy.setScenario(SCEN_LIST_INFO_TEST);
+
+ ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
+
+ @SuppressWarnings("restriction")
+ IHost host = new Host(new SystemProfile("myProfile", true));
+ host.setHostName("127.0.0.1");
+
+ TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy);
+
+ root.addChild(node);
+ node.connect();
+
+ TraceControlTestFacility.getInstance().waitForJobs();
+
+ // ------------------------------------------------------------------------
+ // Verify Parameters of TargetNodeComponent
+ // ------------------------------------------------------------------------
+ assertEquals("127.0.0.1", node.getHostName());
+ assertEquals("127.0.0.1", node.getToolTip());
+ Image connectedImage = node.getImage();
+ assertNotNull(connectedImage);
+ assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState());
+ assertNotNull(node.getControlService());
+ ILttngControlService service = node.getControlService();
+ assertTrue(service instanceof LTTngControlService);
+ node.setControlService(service);
+ assertTrue(node.getControlService() instanceof LTTngControlService);
+
+ assertTrue(node.isPassiveCommunicationsListener());
+
+ // ------------------------------------------------------------------------
+ // Verify Children of TargetNodeComponent
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] groups = node.getChildren();
+ assertNotNull(groups);
+ assertEquals(2, groups.length);
+
+ assertTrue(groups[0] instanceof TraceProviderGroup);
+ assertTrue(groups[1] instanceof TraceSessionGroup);
+
+ assertEquals("Provider", groups[0].getName());
+ assertEquals("Sessions", groups[1].getName());
+
+ // ------------------------------------------------------------------------
+ // Verify TraceProviderGroup
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] providers = groups[0].getChildren();
+
+ assertNotNull(providers);
+ assertEquals(3, providers.length);
+
+ // ------------------------------------------------------------------------
+ // Verify UstProviderComponent
+ // ------------------------------------------------------------------------
+ KernelProviderComponent kernelProvider = (KernelProviderComponent) providers[0];
+
+ // ------------------------------------------------------------------------
+ // Verify event info (kernel provider)
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] events = kernelProvider.getChildren();
+ assertNotNull(events);
+ assertEquals(3, events.length);
+
+ BaseEventComponent baseEventInfo = (BaseEventComponent) events[0];
+ assertNotNull(baseEventInfo);
+ assertEquals("sched_kthread_stop", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ baseEventInfo = (BaseEventComponent) events[1];
+ assertEquals("sched_kthread_stop_ret", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ baseEventInfo = (BaseEventComponent) events[2];
+ assertEquals("sched_wakeup_new", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ // ------------------------------------------------------------------------
+ // Verify UstProviderComponent
+ // ------------------------------------------------------------------------
+ UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
+ assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
+ assertEquals(9379, ustProvider.getPid());
+
+ // ------------------------------------------------------------------------
+ // Verify event info (UST provider)
+ // ------------------------------------------------------------------------
+ events = ustProvider.getChildren();
+ assertNotNull(events);
+ assertEquals(2, events.length);
+
+ baseEventInfo = (BaseEventComponent) events[0];
+ assertNotNull(baseEventInfo);
+ assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ baseEventInfo = (BaseEventComponent) events[1];
+ assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ // ------------------------------------------------------------------------
+ // Verify UstProviderComponent
+ // ------------------------------------------------------------------------
+ ustProvider = (UstProviderComponent) providers[2];
+ assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
+ assertEquals(4852, ustProvider.getPid());
+
+ // verify getters and setter
+ verifyUstProviderGettersSetters(ustProvider);
+
+ // ------------------------------------------------------------------------
+ // Verify event info (UST provider)
+ // ------------------------------------------------------------------------
+ events = ustProvider.getChildren();
+ assertNotNull(events);
+ assertEquals(2, events.length);
+
+ baseEventInfo = (BaseEventComponent) events[0];
+ assertNotNull(baseEventInfo);
+ assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ baseEventInfo = (BaseEventComponent) events[1];
+ assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ // verify getters and setters
+ verifyBaseEventGettersSetters(baseEventInfo);
+
+ // ------------------------------------------------------------------------
+ // Verify TraceSessionGroup
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] sessions = groups[1].getChildren();
+ assertNotNull(sessions);
+ assertEquals(2, sessions.length);
+ for (int i = 0; i < sessions.length; i++) {
+ assertTrue(sessions[i] instanceof TraceSessionComponent);
+ }
+ assertEquals("mysession1", sessions[0].getName());
+ assertEquals("mysession", sessions[1].getName());
+
+ // ------------------------------------------------------------------------
+ // Verify TraceSessionComponent
+ // ------------------------------------------------------------------------
+ TraceSessionComponent session = (TraceSessionComponent)sessions[1];
+ assertEquals("mysession", session.getName());
+ assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
+ assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
+
+ // Verify setters and setters
+ verifySessionGetterSetters(session);
+
+ ITraceControlComponent[] domains = session.getChildren();
+ assertNotNull(domains);
+ assertEquals(2, domains.length);
+
+ // ------------------------------------------------------------------------
+ // Verify Kernel domain
+ // ------------------------------------------------------------------------
+ assertEquals("Kernel", domains[0].getName());
+ ITraceControlComponent[] channels = domains[0].getChildren();
+ assertNotNull(channels);
+ assertEquals(2, channels.length);
+
+ // ------------------------------------------------------------------------
+ // Verify Kernel's channel0
+ // ------------------------------------------------------------------------
+ assertTrue(channels[0] instanceof TraceChannelComponent);
+ TraceChannelComponent channel = (TraceChannelComponent) channels[0];
+ assertEquals("channel0", channel.getName());
+ assertEquals(4, channel.getNumberOfSubBuffers());
+ assertEquals("splice()", channel.getOutputType());
+ assertEquals(false, channel.isOverwriteMode());
+ assertEquals(200, channel.getReadTimer());
+ assertEquals(TraceEnablement.ENABLED, channel.getState());
+ assertEquals(262144, channel.getSubBufferSize());
+ assertEquals(0, channel.getSwitchTimer());
+
+ // ------------------------------------------------------------------------
+ // Verify event info (kernel, channel0)
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] channel0Events = channel.getChildren();
+ assertNotNull(channel0Events);
+ assertEquals(5, channel0Events.length);
+ assertTrue(channel0Events[0] instanceof TraceEventComponent);
+ assertTrue(channel0Events[1] instanceof TraceEventComponent);
+ assertTrue(channel0Events[2] instanceof TraceProbeEventComponent);
+ assertTrue(channel0Events[3] instanceof TraceProbeEventComponent);
+ assertTrue(channel0Events[4] instanceof TraceEventComponent);
+
+ TraceEventComponent event = (TraceEventComponent) channel0Events[0];
+ assertEquals("block_rq_remap", event.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ event = (TraceEventComponent) channel0Events[1];
+ assertEquals("block_bio_remap", event.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+ assertEquals(TraceEnablement.DISABLED, event.getState());
+
+ TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2];
+ assertEquals("myevent2", probeEvent.getName());
+ assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
+ assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
+ assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
+ assertEquals("0xc0101340", probeEvent.getAddress());
+ assertNull(probeEvent.getOffset());
+ assertNull(probeEvent.getSymbol());
+
+ probeEvent = (TraceProbeEventComponent) channel0Events[3];
+ assertEquals("myevent0", probeEvent.getName());
+ assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
+ assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
+ assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
+ assertNull(probeEvent.getAddress());
+ assertEquals("0x0", probeEvent.getOffset());
+ assertEquals("init_post", probeEvent.getSymbol());
+
+ event = (TraceEventComponent) channel0Events[4];
+ assertEquals("syscalls", event.getName());
+ assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
+ assertEquals(TraceEventType.SYSCALL, event.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ // ------------------------------------------------------------------------
+ // Verify Kernel's channel1
+ // ------------------------------------------------------------------------
+ assertEquals("channel1", channels[1].getName());
+ channel = (TraceChannelComponent) channels[1];
+ assertEquals(4, channel.getNumberOfSubBuffers());
+ assertEquals("splice()", channel.getOutputType());
+ assertEquals(true, channel.isOverwriteMode());
+ assertEquals(400, channel.getReadTimer());
+ assertEquals(TraceEnablement.DISABLED, channel.getState());
+ assertEquals(524288, channel.getSubBufferSize());
+ assertEquals(100, channel.getSwitchTimer());
+
+ // ------------------------------------------------------------------------
+ // Verify event info (kernel, channel1)
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] channel1Events = channels[1].getChildren();
+ assertEquals(0, channel1Events.length);
+
+ // ------------------------------------------------------------------------
+ // Verify domain UST global
+ // ------------------------------------------------------------------------
+ assertEquals("UST global", domains[1].getName());
+
+ ITraceControlComponent[] ustChannels = domains[1].getChildren();
+
+ for (int i = 0; i < ustChannels.length; i++) {
+ assertTrue(ustChannels[i] instanceof TraceChannelComponent);
+ }
+
+ // ------------------------------------------------------------------------
+ // Verify UST global's mychannel1
+ // ------------------------------------------------------------------------
+ channel = (TraceChannelComponent) ustChannels[0];
+ assertEquals("mychannel1", channel.getName());
+ assertEquals(8, channel.getNumberOfSubBuffers());
+ assertEquals("mmap()", channel.getOutputType());
+ assertEquals(true, channel.isOverwriteMode());
+ assertEquals(100, channel.getReadTimer());
+ assertEquals(TraceEnablement.DISABLED, channel.getState());
+ assertEquals(8192, channel.getSubBufferSize());
+ assertEquals(200, channel.getSwitchTimer());
+
+ // verify getters and setters
+ verifyChannelGettersSetters(channel);
+
+ // ------------------------------------------------------------------------
+ // Verify event info (UST global, mychannel1)
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] ustEvents = channel.getChildren();
+ assertEquals(0, ustEvents.length);
+
+ // ------------------------------------------------------------------------
+ // Verify UST global's channel0
+ // ------------------------------------------------------------------------
+ channel = (TraceChannelComponent) ustChannels[1];
+ assertEquals("channel0", channel.getName());
+ assertEquals(4, channel.getNumberOfSubBuffers());
+ assertEquals("mmap()", channel.getOutputType());
+ assertEquals(false, channel.isOverwriteMode());
+ assertEquals(200, channel.getReadTimer());
+ assertEquals(TraceEnablement.ENABLED, channel.getState());
+ assertEquals(4096, channel.getSubBufferSize());
+ assertEquals(0, channel.getSwitchTimer());
+
+ // ------------------------------------------------------------------------
+ // Verify event info (UST global, channel0)
+ // ------------------------------------------------------------------------
+ ustEvents = channel.getChildren();
+ assertEquals(2, ustEvents.length);
+
+ event = (TraceEventComponent) ustEvents[0];
+ assertEquals("ust_tests_hello:tptest_sighandler", event.getName());
+ assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+ assertEquals(TraceEnablement.DISABLED, event.getState());
+
+ event = (TraceEventComponent) ustEvents[1];
+ assertEquals("*", ustEvents[1].getName());
+ assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ // verify getters and setters
+ verifyEventGettersSetters(event);
+
+ // disconnect
+ node.disconnect();
+ assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
+ assertNotNull(node.getImage());
+ assertNotSame(connectedImage, node.getImage());
+ }
+
+ private void verifySessionGetterSetters(TraceSessionComponent session) {
+ // save original values
+ String name = session.getName();
+ String origPath = session.getSessionPath();
+ TraceSessionState origState = session.getSessionState();
+
+ // test cases
+ session.setName("newName");
+ assertEquals("newName", session.getName());
+
+ session.setSessionPath("/home/user/tmp");
+ assertEquals("/home/user/tmp", session.getSessionPath());
+
+ session.setSessionState(TraceSessionState.INACTIVE);
+ assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
+ Image inactiveImage = session.getImage();
+ assertNotNull(inactiveImage);
+
+ session.setSessionState("active");
+ assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
+
+ Image activeImage = session.getImage();
+ assertNotNull(activeImage);
+ assertNotSame(activeImage, inactiveImage);
+
+
+ // restore original values
+ session.setName(name);
+ session.setSessionPath(origPath);
+ session.setSessionState(origState);
+ }
+
+ private void verifyBaseEventGettersSetters(BaseEventComponent event) {
+ // save original values
+ String name = event.getName();
+ TraceLogLevel level = event.getLogLevel();
+ TraceEventType type = event.getEventType();
+
+ // test cases
+ event.setName("newName");
+ assertEquals("newName", event.getName());
+
+ event.setLogLevel(TraceLogLevel.TRACE_INFO);
+ assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel());
+ event.setLogLevel("TRACE_ALERT");
+ assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel());
+
+ event.setEventType(TraceEventType.UNKNOWN);
+ assertEquals(TraceEventType.UNKNOWN, event.getEventType());
+ event.setEventType("tracepoint");
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+
+ // restore original values
+ event.setName(name);
+ event.setLogLevel(level);
+ event.setEventType(type);
+ }
+
+ private void verifyEventGettersSetters(TraceEventComponent event) {
+ // save original values
+ String name = event.getName();
+ TraceLogLevel level = event.getLogLevel();
+ TraceEventType type = event.getEventType();
+ TraceEnablement state = event.getState();
+
+ // test cases
+ event.setName("newName");
+ assertEquals("newName", event.getName());
+
+ event.setLogLevel(TraceLogLevel.TRACE_INFO);
+ assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel());
+ event.setLogLevel("TRACE_ALERT");
+ assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel());
+
+ event.setEventType(TraceEventType.UNKNOWN);
+ assertEquals(TraceEventType.UNKNOWN, event.getEventType());
+ event.setEventType("tracepoint");
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+
+ event.setState("disabled");
+ assertEquals(TraceEnablement.DISABLED, event.getState());
+
+ Image disabledImage = event.getImage();
+ assertNotNull(disabledImage);
+
+ event.setState(TraceEnablement.ENABLED);
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ Image enabledImage = event.getImage();
+ assertNotNull(enabledImage);
+ assertNotSame(enabledImage, disabledImage);
+
+ // restore original values
+ event.setName(name);
+ event.setLogLevel(level);
+ event.setEventType(type);
+ event.setState(state);
+ }
+
+ private void verifyChannelGettersSetters(TraceChannelComponent channel) {
+ // save original values
+ String name = channel.getName();
+ int nbSubBuffers = channel.getNumberOfSubBuffers();
+ String type = channel.getOutputType();
+ boolean mode = channel.isOverwriteMode();
+ long readTimer = channel.getReadTimer();
+ TraceEnablement state = channel.getState();
+ long subBufferSize = channel.getSubBufferSize();
+ long switchTimer = channel.getSwitchTimer();
+
+ // test cases
+ channel.setName("newName");
+ assertEquals("newName", channel.getName());
+
+ channel.setNumberOfSubBuffers(2);
+ assertEquals(2, channel.getNumberOfSubBuffers());
+
+ channel.setOutputType("splice()");
+ assertEquals("splice()", channel.getOutputType());
+
+ channel.setOverwriteMode(false);
+ assertEquals(false, channel.isOverwriteMode());
+
+ channel.setReadTimer(250);
+ assertEquals(250, channel.getReadTimer());
+
+ channel.setState("enabled");
+ assertEquals(TraceEnablement.ENABLED, channel.getState());
+
+ Image enabledImage = channel.getImage();
+ assertNotNull(enabledImage);
+ channel.setState(TraceEnablement.DISABLED);
+ assertEquals(TraceEnablement.DISABLED, channel.getState());
+
+ Image disabledImage = channel.getImage();
+ assertNotNull(disabledImage);
+ assertNotSame(enabledImage, disabledImage);
+
+ channel.setSubBufferSize(1024);
+ assertEquals(1024, channel.getSubBufferSize());
+
+ channel.setSwitchTimer(1000);
+ assertEquals(1000, channel.getSwitchTimer());
+
+ // restore original values
+ channel.setName(name);
+ channel.setNumberOfSubBuffers(nbSubBuffers);
+ channel.setOutputType(type);
+ channel.setOverwriteMode(mode);
+ channel.setReadTimer(readTimer);
+ channel.setState(state);
+ channel.setSubBufferSize(subBufferSize);
+ channel.setSwitchTimer(switchTimer);
+ }
+
+ private void verifyUstProviderGettersSetters(UstProviderComponent ustProvider) {
+ // save original values
+ String name = ustProvider.getName();
+ int pid = ustProvider.getPid();
+
+ // test cases
+ ustProvider.setName("newName");
+ assertEquals("newName", ustProvider.getName());
+
+ ustProvider.setPid(9876);
+ assertEquals(9876, ustProvider.getPid());
+
+ // restore original values
+ ustProvider.setName(name);
+ ustProvider.setPid(pid);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ //$JUnit-BEGIN$
+ suite.addTestSuite(BaseEventInfoTest.class);
+ suite.addTestSuite(DomainInfoTest.class);
+ suite.addTestSuite(EventInfoTest.class);
+ suite.addTestSuite(ProbeEventInfoTest.class);
+ suite.addTestSuite(ChannelInfoTest.class);
+ suite.addTestSuite(SessionInfoTest.class);
+ suite.addTestSuite(TraceInfoTest.class);
+ suite.addTestSuite(UstProviderInfoTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import junit.framework.TestCase;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo;
+
+/**
+ * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>.
+ */
+@SuppressWarnings("nls")
+public class BaseEventInfoTest extends TestCase {
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private IBaseEventInfo fEventInfo1 = null;
+ private IBaseEventInfo fEventInfo2 = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ */
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ ModelImplFactory factory = new ModelImplFactory();
+ fEventInfo1 = factory.getBaseEventInfo1();
+ fEventInfo2 = factory.getBaseEventInfo2();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ */
+ @Override
+ public void tearDown() throws Exception {
+ }
+
+ // ------------------------------------------------------------------------
+ // Tests
+ // ------------------------------------------------------------------------
+
+ /**
+ * Run the BaseEventInfo() constructor test.
+ *
+ */
+ public void testBaseEventInfo() {
+ BaseEventInfo fixture = new BaseEventInfo("event");
+ assertNotNull(fixture);
+
+ TraceEventType result = fixture.getEventType();
+
+ assertEquals("event", fixture.getName());
+ assertEquals("unknown", result.getInName());
+ assertEquals("UNKNOWN", result.name());
+ assertEquals("UNKNOWN", result.toString());
+ assertEquals(3, result.ordinal());
+
+ TraceLogLevel level = fixture.getLogLevel();
+ assertEquals("TRACE_DEBUG", level.getInName());
+ assertEquals("TRACE_DEBUG", level.name());
+ assertEquals("TRACE_DEBUG", level.toString());
+ assertEquals(14, level.ordinal());
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testEventInfoCopy() {
+ BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo1);
+
+ assertEquals(fEventInfo1.getName(), info.getName());
+ assertEquals(fEventInfo1.getEventType(), info.getEventType());
+ assertEquals(fEventInfo1.getLogLevel(), info.getLogLevel());
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testEventCopy2() {
+ try {
+ BaseEventInfo info = null;
+ new BaseEventInfo(info);
+ fail("null copy");
+ }
+ catch (IllegalArgumentException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Run the TraceEventType getEventType() method test.
+ *
+ * @throws Exception
+ *
+ */
+ public void testGetEventType_1() {
+ BaseEventInfo fixture = new BaseEventInfo("event");
+ fixture.setEventType("unknown");
+
+ TraceEventType result = fixture.getEventType();
+
+ assertNotNull(result);
+ assertEquals("unknown", result.getInName());
+ assertEquals("UNKNOWN", result.name());
+ assertEquals("UNKNOWN", result.toString());
+ assertEquals(3, result.ordinal());
+
+ fixture.setEventType("");
+ result = fixture.getEventType();
+ assertEquals("unknown", result.getInName());
+ assertEquals("UNKNOWN", result.name());
+ assertEquals("UNKNOWN", result.toString());
+ assertEquals(3, result.ordinal());
+
+ fixture.setEventType("tracepoint");
+ result = fixture.getEventType();
+ assertNotNull(result);
+ assertEquals("tracepoint", result.getInName());
+ assertEquals("TRACEPOINT", result.name());
+ assertEquals("TRACEPOINT", result.toString());
+ assertEquals(0, result.ordinal());
+
+ fixture.setEventType("syscall");
+ result = fixture.getEventType();
+ assertNotNull(result);
+ assertEquals("syscall", result.getInName());
+ assertEquals("SYSCALL", result.name());
+ assertEquals("SYSCALL", result.toString());
+ assertEquals(1, result.ordinal());
+
+ fixture.setEventType("probe");
+ result = fixture.getEventType();
+ assertNotNull(result);
+ assertEquals("probe", result.getInName());
+ assertEquals("PROBE", result.name());
+ assertEquals("PROBE", result.toString());
+ assertEquals(2, result.ordinal());
+
+ }
+
+ /**
+ * Run the void setEventType(TraceEventType) method test.
+ *
+ */
+ public void testSetEventType_2() {
+ BaseEventInfo fixture = new BaseEventInfo("event");
+ fixture.setEventType(TraceEventType.TRACEPOINT);
+
+ TraceEventType result = fixture.getEventType();
+
+ assertNotNull(result);
+ assertEquals("tracepoint", result.getInName());
+ assertEquals("TRACEPOINT", result.name());
+ assertEquals("TRACEPOINT", result.toString());
+ assertEquals(0, result.ordinal());
+
+ fixture.setEventType(TraceEventType.UNKNOWN);
+ result = fixture.getEventType();
+
+ assertNotNull(result);
+ assertEquals("unknown", result.getInName());
+ assertEquals("UNKNOWN", result.name());
+ assertEquals("UNKNOWN", result.toString());
+ assertEquals(3, result.ordinal());
+
+ fixture.setEventType(TraceEventType.SYSCALL);
+ result = fixture.getEventType();
+ assertNotNull(result);
+ assertEquals("syscall", result.getInName());
+ assertEquals("SYSCALL", result.name());
+ assertEquals("SYSCALL", result.toString());
+ assertEquals(1, result.ordinal());
+
+ fixture.setEventType(TraceEventType.PROBE);
+ result = fixture.getEventType();
+ assertNotNull(result);
+ assertEquals("probe", result.getInName());
+ assertEquals("PROBE", result.name());
+ assertEquals("PROBE", result.toString());
+ assertEquals(2, result.ordinal());
+
+ }
+
+ /**
+ * Run the void setLogLevel(TraceLogLevel) method test.
+ * Run the TraceLogLevel getLogLevel() method test
+ *
+ */
+ public void testSetLogLevel1() {
+ BaseEventInfo fixture = new BaseEventInfo("event");
+ fixture.setEventType(TraceEventType.TRACEPOINT);
+ fixture.setLogLevel(TraceLogLevel.TRACE_CRIT);
+
+ // 2 set/get-operations are enough to test the method
+ TraceLogLevel result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_CRIT", result.getInName());
+ assertEquals("TRACE_CRIT", result.name());
+ assertEquals("TRACE_CRIT", result.toString());
+ assertEquals(2, result.ordinal());
+
+ fixture.setLogLevel(TraceLogLevel.TRACE_DEBUG_FUNCTION);
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_DEBUG_FUNCTION", result.getInName());
+ assertEquals("TRACE_DEBUG_FUNCTION", result.name());
+ assertEquals("TRACE_DEBUG_FUNCTION", result.toString());
+ assertEquals(12, result.ordinal());
+ }
+
+ /**
+ * Run the void setLogLevel(String) method test.
+ * Run the TraceLogLevel getLogLevel() method test
+ *
+ */
+ public void testSetLogLevel2() {
+ BaseEventInfo fixture = new BaseEventInfo("event");
+ fixture.setEventType(TraceEventType.TRACEPOINT);
+ fixture.setLogLevel("TRACE_EMERG");
+
+ TraceLogLevel result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_EMERG", result.getInName());
+ assertEquals("TRACE_EMERG", result.name());
+ assertEquals(0, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_ALERT");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_ALERT", result.getInName());
+ assertEquals("TRACE_ALERT", result.name());
+ assertEquals(1, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_CRIT");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_CRIT", result.getInName());
+ assertEquals("TRACE_CRIT", result.name());
+ assertEquals(2, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_ERR");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_ERR", result.getInName());
+ assertEquals("TRACE_ERR", result.name());
+ assertEquals(3, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_WARNING");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_WARNING", result.getInName());
+ assertEquals("TRACE_WARNING", result.name());
+ assertEquals(4, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_NOTICE");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_NOTICE", result.getInName());
+ assertEquals("TRACE_NOTICE", result.name());
+ assertEquals(5, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_INFO");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_INFO", result.getInName());
+ assertEquals("TRACE_INFO", result.name());
+ assertEquals(6, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_DEBUG_SYSTEM");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_DEBUG_SYSTEM", result.getInName());
+ assertEquals("TRACE_DEBUG_SYSTEM", result.name());
+ assertEquals(7, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_DEBUG_PROGRAM");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_DEBUG_PROGRAM", result.getInName());
+ assertEquals("TRACE_DEBUG_PROGRAM", result.name());
+ assertEquals(8, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_DEBUG_PROCESS");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_DEBUG_PROCESS", result.getInName());
+ assertEquals("TRACE_DEBUG_PROCESS", result.name());
+ assertEquals(9, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_DEBUG_MODULE");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_DEBUG_MODULE", result.getInName());
+ assertEquals("TRACE_DEBUG_MODULE", result.name());
+ assertEquals(10, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_DEBUG_UNIT");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_DEBUG_UNIT", result.getInName());
+ assertEquals("TRACE_DEBUG_UNIT", result.name());
+ assertEquals(11, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_DEBUG_FUNCTION");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_DEBUG_FUNCTION", result.getInName());
+ assertEquals("TRACE_DEBUG_FUNCTION", result.name());
+ assertEquals(12, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_DEBUG_LINE");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_DEBUG_LINE", result.getInName());
+ assertEquals("TRACE_DEBUG_LINE", result.name());
+ assertEquals(13, result.ordinal());
+
+ //------------------------
+ fixture.setLogLevel("TRACE_DEBUG");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_DEBUG", result.getInName());
+ assertEquals("TRACE_DEBUG", result.name());
+ assertEquals(14, result.ordinal());
+
+ //-------------------------
+ fixture.setLogLevel("LEVEL_UNKNOWN");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("LEVEL_UNKNOWN", result.getInName());
+ assertEquals("LEVEL_UNKNOWN", result.name());
+ assertEquals(15, result.ordinal());
+
+ fixture.setLogLevel("garbage");
+
+ result = fixture.getLogLevel();
+ assertNotNull(result);
+ assertEquals("TRACE_DEBUG", result.getInName());
+ assertEquals("TRACE_DEBUG", result.name());
+ assertEquals(14, result.ordinal());
+ }
+
+
+ /**
+ * Run the String toString() method test.
+ *
+ */
+ public void testToString_1() {
+ BaseEventInfo fixture = new BaseEventInfo("event");
+ fixture.setName("testName");
+ fixture.setEventType(TraceEventType.TRACEPOINT);
+ fixture.setLogLevel(TraceLogLevel.TRACE_ERR);
+
+ String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals("[BaseEventInfo([TraceInfo(Name=testName)],type=TRACEPOINT,level=TRACE_ERR)]", result);
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fEventInfo1.equals(fEventInfo1));
+ assertTrue("equals", fEventInfo2.equals(fEventInfo2));
+
+ assertTrue("equals", !fEventInfo1.equals(fEventInfo2));
+ assertTrue("equals", !fEventInfo2.equals(fEventInfo1));
+ }
+
+ public void testEqualsSymmetry() {
+ BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
+ BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2);
+
+ assertTrue("equals", info1.equals(fEventInfo1));
+ assertTrue("equals", fEventInfo1.equals(info1));
+
+ assertTrue("equals", info2.equals(fEventInfo2));
+ assertTrue("equals", fEventInfo2.equals(info2));
+ }
+
+ public void testEqualsTransivity() {
+ BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
+ BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
+ BaseEventInfo info3 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
+
+ assertTrue("equals", info1.equals(info2));
+ assertTrue("equals", info2.equals(info3));
+ assertTrue("equals", info1.equals(info3));
+ }
+
+ public void testEqualsNull() {
+ assertTrue("equals", !fEventInfo1.equals(null));
+ assertTrue("equals", !fEventInfo2.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ public void testHashCode() {
+ BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
+ BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2);
+
+ assertTrue("hashCode", fEventInfo1.hashCode() == info1.hashCode());
+ assertTrue("hashCode", fEventInfo2.hashCode() == info2.hashCode());
+
+ assertTrue("hashCode", fEventInfo1.hashCode() != info2.hashCode());
+ assertTrue("hashCode", fEventInfo2.hashCode() != info1.hashCode());
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.EventInfo;
+
+/**
+ * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link ChannelInfo}</code>.
+ *
+ */
+@SuppressWarnings("nls")
+public class ChannelInfoTest extends TestCase {
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private IChannelInfo fChannelInfo1 = null;
+ private IChannelInfo fChannelInfo2 = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ */
+ @Override
+ public void setUp() {
+ ModelImplFactory factory = new ModelImplFactory();
+ fChannelInfo1 = factory.getChannel1();
+ fChannelInfo2 = factory.getChannel2();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ */
+ @Override
+ public void tearDown() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Tests
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Run the ChannelInfo() constructor test.
+ *
+ */
+ public void testChannelInfo() {
+ ChannelInfo result = new ChannelInfo("test");
+ assertNotNull(result);
+
+ assertEquals("test", result.getName());
+ assertEquals(0, result.getNumberOfSubBuffers());
+ assertEquals("", result.getOutputType());
+ assertEquals(false, result.isOverwriteMode());
+ assertEquals(0, result.getReadTimer());
+ assertEquals("disabled", result.getState().getInName());
+ assertEquals(0, result.getSubBufferSize());
+ assertEquals(0, result.getSwitchTimer());
+ }
+
+ public void testChannelInfoCopy() {
+ ChannelInfo channelInfo = new ChannelInfo((ChannelInfo)fChannelInfo1);
+
+ assertEquals(fChannelInfo1.getName(), channelInfo.getName());
+ assertEquals(fChannelInfo1.getNumberOfSubBuffers(), channelInfo.getNumberOfSubBuffers());
+ assertEquals(fChannelInfo1.getOutputType(), channelInfo.getOutputType());
+ assertEquals(fChannelInfo1.isOverwriteMode(), channelInfo.isOverwriteMode());
+ assertEquals(fChannelInfo1.getReadTimer(), channelInfo.getReadTimer());
+ assertEquals(fChannelInfo1.getState(), channelInfo.getState());
+ assertEquals(fChannelInfo1.getSwitchTimer(), channelInfo.getSwitchTimer());
+ assertEquals(fChannelInfo1.getEvents().length, channelInfo.getEvents().length);
+
+ IEventInfo[] orignalEvents = fChannelInfo1.getEvents();
+ IEventInfo[] resultEvents = channelInfo.getEvents();
+ for (int i = 0; i < orignalEvents.length; i++) {
+ assertEquals(orignalEvents[i], resultEvents[i]);
+ }
+ }
+
+ public void testChannelCopy2() {
+ try {
+ ChannelInfo channel = null;
+ new ChannelInfo(channel);
+ fail("null copy");
+ }
+ catch (IllegalArgumentException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Run the IEventInfo[] getEvents() method test.
+ *
+ */
+ public void testAddAndGetEvents_1() {
+ ChannelInfo fixture = new ChannelInfo("test");
+ fixture.setSwitchTimer(1L);
+ fixture.setOverwriteMode(true);
+ fixture.setReadTimer(1L);
+ fixture.setState(TraceEnablement.DISABLED);
+ fixture.setNumberOfSubBuffers(1);
+ fixture.setOutputType("");
+ fixture.setSubBufferSize(1L);
+
+ // add an event
+ IEventInfo event = new EventInfo("event");
+ fixture.addEvent(event);
+
+ // Verify the stored events
+ IEventInfo[] result = fixture.getEvents();
+
+ assertNotNull(result);
+ assertEquals(1, result.length);
+ assertNotNull(result[0]);
+ assertTrue(event.equals(result[0]));
+ }
+
+ /**
+ * Run the long getNumberOfSubBuffers() method test.
+ *
+ */
+ public void testGetAndSetters() {
+ ChannelInfo fixture = new ChannelInfo("test");
+ fixture.setSwitchTimer(2L);
+ fixture.setOverwriteMode(true);
+ fixture.setReadTimer(3L);
+ fixture.setState(TraceEnablement.DISABLED);
+ fixture.setNumberOfSubBuffers(4);
+ fixture.setOutputType("splice()");
+ fixture.setSubBufferSize(1L);
+ fixture.addEvent(new EventInfo("event"));
+
+ long switchTimer = fixture.getSwitchTimer();
+ assertEquals(2L, switchTimer);
+
+ boolean mode = fixture.isOverwriteMode();
+ assertTrue(mode);
+
+ long readTimer = fixture.getReadTimer();
+ assertEquals(3L, readTimer);
+
+ TraceEnablement state = fixture.getState();
+ assertEquals("disabled", state.getInName());
+
+ long numSubBuffers = fixture.getNumberOfSubBuffers();
+ assertEquals(4, numSubBuffers);
+
+ String outputType = fixture.getOutputType();
+ assertEquals("splice()", outputType);
+
+ long subBufferSize = fixture.getSubBufferSize();
+ assertEquals(1L, subBufferSize);
+
+ fixture.setSwitchTimer(5L);
+ fixture.setOverwriteMode(false);
+ fixture.setReadTimer(6L);
+ fixture.setState(TraceEnablement.ENABLED);
+ fixture.setNumberOfSubBuffers(7);
+ fixture.setOutputType("mmap()");
+ fixture.setSubBufferSize(8L);
+
+ switchTimer = fixture.getSwitchTimer();
+ assertEquals(5L, switchTimer);
+
+ mode = fixture.isOverwriteMode();
+ assertFalse(mode);
+
+ readTimer = fixture.getReadTimer();
+ assertEquals(6L, readTimer);
+
+ state = fixture.getState();
+ assertEquals("enabled", state.getInName());
+
+ numSubBuffers = fixture.getNumberOfSubBuffers();
+ assertEquals(7, numSubBuffers);
+
+ outputType = fixture.getOutputType();
+ assertEquals("mmap()", outputType);
+
+ subBufferSize = fixture.getSubBufferSize();
+ assertEquals(8L, subBufferSize);
+ }
+
+ /**
+ * Run the void setEvents(List<IEventInfo>) method test.
+ *
+ */
+ public void testSetEvents_1() {
+ ChannelInfo fixture = new ChannelInfo("test");
+ fixture.setSwitchTimer(1L);
+ fixture.setOverwriteMode(true);
+ fixture.setReadTimer(1L);
+ fixture.setState(TraceEnablement.DISABLED);
+ fixture.setNumberOfSubBuffers(1);
+ fixture.setOutputType("");
+ fixture.setSubBufferSize(1L);
+ List<IEventInfo> events = new LinkedList<IEventInfo>();
+
+ for (int i = 0; i < 2; i++) {
+ IEventInfo info = new EventInfo("event" + i);
+ info.setEventType("tracepoint");
+ info.setState((i % 2 == 0 ? "enabled" : "disabled"));
+ events.add(info);
+ }
+
+ fixture.setEvents(events);
+
+ IEventInfo[] infos = fixture.getEvents();
+
+ assertEquals(events.size(), infos.length);
+
+ for (int i = 0; i < infos.length; i++) {
+ assertEquals(events.get(i), infos[i]);
+ }
+ }
+
+ public void testToString_1() {
+ ChannelInfo fixture = new ChannelInfo("channel");
+ fixture.setSwitchTimer(1L);
+ fixture.setOverwriteMode(true);
+ fixture.setReadTimer(1L);
+ fixture.setState(TraceEnablement.DISABLED);
+ fixture.setNumberOfSubBuffers(1);
+ fixture.setOutputType("splice()");
+ fixture.setSubBufferSize(1L);
+
+ String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals("[ChannelInfo([TraceInfo(Name=channel)],State=DISABLED,OverwriteMode=true,SubBuffersSize=1,NumberOfSubBuffers=1,SwitchTimer=1,ReadTimer=1,output=splice(),Events=None)]", result);
+ }
+
+ /**
+ * Run the String toString() method test.
+ *
+ */
+ public void testToString_2() {
+ String result = fChannelInfo1.toString();
+
+ // add additional test code here
+ assertEquals("[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])]", result);
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fChannelInfo1.equals(fChannelInfo1));
+ assertTrue("equals", fChannelInfo2.equals(fChannelInfo2));
+
+ assertTrue("equals", !fChannelInfo1.equals(fChannelInfo2));
+ assertTrue("equals", !fChannelInfo2.equals(fChannelInfo1));
+ }
+
+ public void testEqualsSymmetry() {
+ ChannelInfo event1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
+ ChannelInfo event2 = new ChannelInfo((ChannelInfo)fChannelInfo2);
+
+ assertTrue("equals", event1.equals(fChannelInfo1));
+ assertTrue("equals", fChannelInfo1.equals(event1));
+
+ assertTrue("equals", event2.equals(fChannelInfo2));
+ assertTrue("equals", fChannelInfo2.equals(event2));
+ }
+
+ public void testEqualsTransivity() {
+ ChannelInfo channel1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
+ ChannelInfo channel2 = new ChannelInfo((ChannelInfo)fChannelInfo1);
+ ChannelInfo channel3 = new ChannelInfo((ChannelInfo)fChannelInfo1);
+
+ assertTrue("equals", channel1.equals(channel2));
+ assertTrue("equals", channel2.equals(channel3));
+ assertTrue("equals", channel1.equals(channel3));
+ }
+
+ public void testEqualsNull() throws Exception {
+ assertTrue("equals", !fChannelInfo1.equals(null));
+ assertTrue("equals", !fChannelInfo2.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ public void testHashCode() {
+ ChannelInfo channel1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
+ ChannelInfo channel2 = new ChannelInfo((ChannelInfo)fChannelInfo2);
+
+ assertTrue("hashCode", fChannelInfo1.hashCode() == channel1.hashCode());
+ assertTrue("hashCode", fChannelInfo2.hashCode() == channel2.hashCode());
+
+ assertTrue("hashCode", fChannelInfo1.hashCode() != channel2.hashCode());
+ assertTrue("hashCode", fChannelInfo2.hashCode() != channel1.hashCode());
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.DomainInfo;
+
+/**
+ * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link DomainInfo}</code>.
+ *
+ */
+@SuppressWarnings("nls")
+public class DomainInfoTest extends TestCase {
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private IDomainInfo fDomainInfo1 = null;
+ private IDomainInfo fDomainInfo2 = null;
+ private IChannelInfo fChannelInfo1 = null;
+ private IChannelInfo fChannelInfo2 = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ */
+ @Override
+ public void setUp() {
+ // Get test instances from the factory
+ ModelImplFactory factory = new ModelImplFactory();
+ fChannelInfo1 = factory.getChannel1();
+ fChannelInfo2 = factory.getChannel2();
+ fDomainInfo1 = factory.getDomainInfo1();
+ fDomainInfo2 = factory.getDomainInfo2();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ */
+ @Override
+ public void tearDown() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Tests
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Run the ChannelInfo() constructor test.
+ *
+ */
+ public void testDomainInfo() {
+ DomainInfo result = new DomainInfo("test");
+ assertNotNull(result);
+
+ assertEquals("test", result.getName());
+ assertEquals(0, result.getChannels().length);
+ }
+
+ public void testDomainInfoCopy() {
+ DomainInfo channelInfo = new DomainInfo((DomainInfo)fDomainInfo1);
+ IChannelInfo[] orignalEvents = fDomainInfo1.getChannels();
+ IChannelInfo[] resultEvents = channelInfo.getChannels();
+ for (int i = 0; i < orignalEvents.length; i++) {
+ assertEquals(orignalEvents[i], resultEvents[i]);
+ }
+ }
+
+ public void testDomainlCopy2() {
+ try {
+ DomainInfo domain = null;
+ new DomainInfo(domain);
+ fail("null copy");
+ }
+ catch (IllegalArgumentException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Run the long getNumberOfSubBuffers() method test.
+ *
+ */
+ public void testGetAndSetters() {
+
+ // Note that addChannel() has been executed in setUp()
+ // check get method here
+ assertEquals(1, fDomainInfo1.getChannels().length);
+ assertNotNull(fDomainInfo1.getChannels()[0]);
+ assertEquals(fChannelInfo1, fDomainInfo1.getChannels()[0]);
+
+ IDomainInfo domain = new DomainInfo("domain");
+ List<IChannelInfo> list = new LinkedList<IChannelInfo>();
+ list.add(fChannelInfo1);
+ list.add(fChannelInfo2);
+ domain.setChannels(list);
+
+ IChannelInfo[] result = domain.getChannels();
+ assertEquals(2, result.length);
+ assertEquals(fChannelInfo1, result[0]);
+ assertEquals(fChannelInfo2, result[1]);
+ }
+
+ public void testToString_1() {
+ DomainInfo fixture = new DomainInfo("domain");
+
+ String result = fixture.toString();
+
+ assertEquals("[DomainInfo([TraceInfo(Name=domain)],Channels=None,isKernel=false)]", result);
+ }
+
+ /**
+ * Run the String toString() method test.
+ *
+ */
+ public void testToString_2() {
+ String result = fDomainInfo1.toString();
+
+ assertEquals("[DomainInfo([TraceInfo(Name=test1)],Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],isKernel=false)]", result);
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fDomainInfo1.equals(fDomainInfo1));
+ assertTrue("equals", fDomainInfo2.equals(fDomainInfo2));
+
+ assertTrue("equals", !fDomainInfo1.equals(fDomainInfo2));
+ assertTrue("equals", !fDomainInfo2.equals(fDomainInfo1));
+ }
+
+ public void testEqualsSymmetry() {
+ DomainInfo event1 = new DomainInfo((DomainInfo)fDomainInfo1);
+ DomainInfo event2 = new DomainInfo((DomainInfo)fDomainInfo2);
+
+ assertTrue("equals", event1.equals(fDomainInfo1));
+ assertTrue("equals", fDomainInfo1.equals(event1));
+
+ assertTrue("equals", event2.equals(fDomainInfo2));
+ assertTrue("equals", fDomainInfo2.equals(event2));
+ }
+
+ public void testEqualsTransivity() {
+ DomainInfo channel1 = new DomainInfo((DomainInfo)fDomainInfo1);
+ DomainInfo channel2 = new DomainInfo((DomainInfo)fDomainInfo1);
+ DomainInfo channel3 = new DomainInfo((DomainInfo)fDomainInfo1);
+
+ assertTrue("equals", channel1.equals(channel2));
+ assertTrue("equals", channel2.equals(channel3));
+ assertTrue("equals", channel1.equals(channel3));
+ }
+
+ public void testEqualsNull() throws Exception {
+ assertTrue("equals", !fDomainInfo1.equals(null));
+ assertTrue("equals", !fDomainInfo2.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ public void testHashCode() {
+ DomainInfo channel1 = new DomainInfo((DomainInfo)fDomainInfo1);
+ DomainInfo channel2 = new DomainInfo((DomainInfo)fDomainInfo2);
+
+ assertTrue("hashCode", fDomainInfo1.hashCode() == channel1.hashCode());
+ assertTrue("hashCode", fDomainInfo2.hashCode() == channel2.hashCode());
+
+ assertTrue("hashCode", fDomainInfo1.hashCode() != channel2.hashCode());
+ assertTrue("hashCode", fDomainInfo2.hashCode() != channel1.hashCode());
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import junit.framework.TestCase;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.EventInfo;
+
+/**
+ * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>.
+ */
+@SuppressWarnings("nls")
+public class EventInfoTest extends TestCase {
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private IEventInfo fEventInfo1 = null;
+ private IEventInfo fEventInfo2 = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ */
+ @Override
+ public void setUp() throws Exception {
+ ModelImplFactory factory = new ModelImplFactory();
+ fEventInfo1 = factory.getEventInfo1();
+ fEventInfo2 = factory.getEventInfo2();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ */
+ @Override
+ public void tearDown() throws Exception {
+ }
+
+ // ------------------------------------------------------------------------
+ // Tests
+ // ------------------------------------------------------------------------
+
+ /**
+ * Run the BaseEventInfo() constructor test.
+ *
+ */
+ public void testBaseEventInfo() {
+ EventInfo fixture = new EventInfo("event");
+ assertNotNull(fixture);
+
+ TraceEventType result = fixture.getEventType();
+
+ assertEquals("event", fixture.getName());
+ assertEquals("unknown", result.getInName());
+ assertEquals("UNKNOWN", result.name());
+ assertEquals("UNKNOWN", result.toString());
+ assertEquals(3, result.ordinal());
+
+ TraceEnablement state = fixture.getState();
+ assertEquals("disabled", state.getInName());
+ assertEquals("DISABLED", state.name());
+ assertEquals("DISABLED", state.toString());
+ assertEquals(0, state.ordinal());
+
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testEventInfoCopy() {
+ EventInfo info = new EventInfo((EventInfo)fEventInfo1);
+
+ assertEquals(fEventInfo1.getName(), info.getName());
+ assertEquals(fEventInfo1.getEventType(), info.getEventType());
+ assertEquals(fEventInfo1.getState(), info.getState());
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testEventCopy2() {
+ try {
+ EventInfo info = null;
+ new EventInfo(info);
+ fail("null copy");
+ }
+ catch (IllegalArgumentException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Getter/Setter tests
+ */
+ public void testGetAndSetter() {
+ EventInfo fixture = new EventInfo("event");
+
+ fixture.setEventType(TraceEventType.TRACEPOINT);
+ TraceEventType result = fixture.getEventType();
+
+ // setEventType(TraceEventType type)
+ assertNotNull(result);
+ assertEquals("tracepoint", result.getInName());
+ assertEquals("TRACEPOINT", result.name());
+ assertEquals("TRACEPOINT", result.toString());
+ assertEquals(0, result.ordinal());
+
+ fixture.setEventType(TraceEventType.UNKNOWN);
+ result = fixture.getEventType();
+ assertEquals("unknown", result.getInName());
+ assertEquals("UNKNOWN", result.name());
+ assertEquals("UNKNOWN", result.toString());
+ assertEquals(3, result.ordinal());
+
+ // setEventType(String typeName)
+ String typeName = "";
+ fixture.setEventType(typeName);
+ result = fixture.getEventType();
+
+ assertEquals("unknown", result.getInName());
+ assertEquals("UNKNOWN", result.name());
+ assertEquals("UNKNOWN", result.toString());
+ assertEquals(3, result.ordinal());
+
+ typeName = "unknown";
+
+ fixture.setEventType(typeName);
+ result = fixture.getEventType();
+
+ assertEquals("unknown", result.getInName());
+ assertEquals("UNKNOWN", result.name());
+ assertEquals("UNKNOWN", result.toString());
+ assertEquals(3, result.ordinal());
+
+ // setState(String stateName)
+ fixture.setState("disabled");
+ TraceEnablement state = fixture.getState();
+ assertEquals("disabled", state.getInName());
+ assertEquals("DISABLED", state.name());
+ assertEquals("DISABLED", state.toString());
+ assertEquals(0, state.ordinal());
+
+ fixture.setState("bla");
+ state = fixture.getState();
+ assertEquals("disabled", state.getInName());
+ assertEquals("DISABLED", state.name());
+ assertEquals("DISABLED", state.toString());
+ assertEquals(0, state.ordinal());
+
+ fixture.setState("enabled");
+ state = fixture.getState();
+ assertEquals("enabled", state.getInName());
+ assertEquals("ENABLED", state.name());
+ assertEquals("ENABLED", state.toString());
+ assertEquals(1, state.ordinal());
+
+ // setState(TraceEnablement state)
+ fixture.setState(TraceEnablement.DISABLED);
+ state = fixture.getState();
+ assertEquals("disabled", state.getInName());
+ assertEquals("DISABLED", state.name());
+ assertEquals("DISABLED", state.toString());
+ assertEquals(0, state.ordinal());
+
+ fixture.setState(TraceEnablement.ENABLED);
+ state = fixture.getState();
+ assertEquals("enabled", state.getInName());
+ assertEquals("ENABLED", state.name());
+ assertEquals("ENABLED", state.toString());
+ assertEquals(1, state.ordinal());
+ }
+
+ /**
+ * Run the String toString() method test.
+ */
+ public void testToString_1() {
+ EventInfo fixture = new EventInfo("event");
+ fixture.setName("testName");
+ fixture.setEventType(TraceEventType.TRACEPOINT);
+
+ String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals("[EventInfo([BaseEventInfo([TraceInfo(Name=testName)],type=TRACEPOINT,level=TRACE_DEBUG)],State=DISABLED)]", result);
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fEventInfo1.equals(fEventInfo1));
+ assertTrue("equals", fEventInfo2.equals(fEventInfo2));
+
+ assertTrue("equals", !fEventInfo1.equals(fEventInfo2));
+ assertTrue("equals", !fEventInfo2.equals(fEventInfo1));
+ }
+
+ public void testEqualsSymmetry() {
+ EventInfo info1 = new EventInfo((EventInfo)fEventInfo1);
+ EventInfo info2 = new EventInfo((EventInfo)fEventInfo2);
+
+ assertTrue("equals", info1.equals(fEventInfo1));
+ assertTrue("equals", fEventInfo1.equals(info1));
+
+ assertTrue("equals", info2.equals(fEventInfo2));
+ assertTrue("equals", fEventInfo2.equals(info2));
+ }
+
+ public void testEqualsTransivity() {
+ EventInfo info1 = new EventInfo((EventInfo)fEventInfo1);
+ EventInfo info2 = new EventInfo((EventInfo)fEventInfo1);
+ EventInfo info3 = new EventInfo((EventInfo)fEventInfo1);
+
+ assertTrue("equals", info1.equals(info2));
+ assertTrue("equals", info2.equals(info3));
+ assertTrue("equals", info1.equals(info3));
+ }
+
+ public void testEqualsNull() {
+ assertTrue("equals", !fEventInfo1.equals(null));
+ assertTrue("equals", !fEventInfo2.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ public void testHashCode() {
+ EventInfo info1 = new EventInfo((EventInfo)fEventInfo1);
+ EventInfo info2 = new EventInfo((EventInfo)fEventInfo2);
+
+ assertTrue("hashCode", fEventInfo1.hashCode() == info1.hashCode());
+ assertTrue("hashCode", fEventInfo2.hashCode() == info2.hashCode());
+
+ assertTrue("hashCode", fEventInfo1.hashCode() != info2.hashCode());
+ assertTrue("hashCode", fEventInfo2.hashCode() != info1.hashCode());
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponentChangedListener;
+
+/**
+ * The class can be used to validate the listener interface.
+ *
+ */
+public class ListenerValidator implements ITraceControlComponentChangedListener {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ private boolean fisAddedCalled = false;
+ private boolean fisRemoveCalled = false;
+ private boolean fisChangedCalled = false;
+
+ private ITraceControlComponent fParent = null;
+ private ITraceControlComponent fChild = null;
+ private ITraceControlComponent fChangedComponent = null;
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ public boolean isAddedCalled() {
+ return fisAddedCalled;
+ }
+
+ public boolean isRemovedCalled() {
+ return fisRemoveCalled;
+ }
+
+ public boolean isChangedCalled() {
+ return fisChangedCalled;
+ }
+
+ public ITraceControlComponent getSavedParent() {
+ return fParent;
+ }
+
+ public ITraceControlComponent getSavedChild() {
+ return fChild;
+ }
+
+ public ITraceControlComponent getSavedComponent() {
+ return fChangedComponent;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ public void initialize() {
+ fisAddedCalled = false;
+ fisRemoveCalled = false;
+ fisChangedCalled = false;
+ fParent = null;
+ fChild = null;
+ fChangedComponent = null;
+ }
+
+ @Override
+ public void componentAdded(ITraceControlComponent parent, ITraceControlComponent component) {
+ fisAddedCalled = true;
+ fParent = parent;
+ fChild = component;
+ }
+
+ @Override
+ public void componentRemoved(ITraceControlComponent parent, ITraceControlComponent component) {
+ fisRemoveCalled = true;
+ fParent = parent;
+ fChild = component;
+ }
+
+ @Override
+ public void componentChanged(ITraceControlComponent component) {
+ fisChangedCalled = true;
+ fParent = null;
+ fChangedComponent = component;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IProbeEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.DomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.EventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ProbeEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.SessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderInfo;
+
+/**
+ * Test facility to constants across test case
+ */
+@SuppressWarnings("nls")
+public class ModelImplFactory {
+
+ private ISessionInfo fSessionInfo1 = null;
+ private ISessionInfo fSessionInfo2 = null;
+ private IDomainInfo fDomainInfo1 = null;
+ private IDomainInfo fDomainInfo2 = null;
+ private IChannelInfo fChannelInfo1 = null;
+ private IChannelInfo fChannelInfo2 = null;
+ private IEventInfo fEventInfo1 = null;
+ private IEventInfo fEventInfo2 = null;
+ private IEventInfo fEventInfo3 = null;
+ private IBaseEventInfo fBaseEventInfo1 = null;
+ private IBaseEventInfo fBaseEventInfo2 = null;
+ private IUstProviderInfo fUstProviderInfo1 = null;
+ private IUstProviderInfo fUstProviderInfo2 = null;
+ private IProbeEventInfo fProbeEventInfo1 = null;
+ private IProbeEventInfo fProbeEventInfo2 = null;
+
+ public ModelImplFactory() {
+ fBaseEventInfo1 = new BaseEventInfo("event1");
+ fBaseEventInfo1.setEventType(TraceEventType.UNKNOWN);
+ fBaseEventInfo1.setLogLevel(TraceLogLevel.TRACE_ERR);
+ fBaseEventInfo2 = new BaseEventInfo("event2");
+ fBaseEventInfo2.setEventType(TraceEventType.TRACEPOINT);
+ fBaseEventInfo1.setLogLevel(TraceLogLevel.TRACE_DEBUG);
+
+ fEventInfo1 = new EventInfo("event1");
+ fEventInfo1.setEventType(TraceEventType.TRACEPOINT);
+ fEventInfo1.setState(TraceEnablement.ENABLED);
+
+ fEventInfo2 = new EventInfo("event2");
+ fEventInfo2.setEventType(TraceEventType.UNKNOWN);
+ fEventInfo2.setState(TraceEnablement.DISABLED);
+
+ fEventInfo3 = new EventInfo("event3");
+ fEventInfo3.setEventType(TraceEventType.TRACEPOINT);
+ fEventInfo3.setState(TraceEnablement.DISABLED);
+
+ fUstProviderInfo1 = new UstProviderInfo("myUST1");
+ fUstProviderInfo1.setPid(1234);
+ fUstProviderInfo1.addEvent(fBaseEventInfo1);
+
+ fUstProviderInfo2 = new UstProviderInfo("myUST2");
+ fUstProviderInfo2.setPid(2345);
+ fUstProviderInfo2.addEvent(fBaseEventInfo1);
+ fUstProviderInfo2.addEvent(fBaseEventInfo2);
+
+ fChannelInfo1 = new ChannelInfo("channel1");
+ fChannelInfo1.setSwitchTimer(10L);
+ fChannelInfo1.setOverwriteMode(true);
+ fChannelInfo1.setReadTimer(11L);
+ fChannelInfo1.setState(TraceEnablement.DISABLED);
+ fChannelInfo1.setNumberOfSubBuffers(12);
+ fChannelInfo1.setOutputType("splice()");
+ fChannelInfo1.setSubBufferSize(13L);
+ fChannelInfo1.addEvent(fEventInfo1);
+
+ fChannelInfo2 = new ChannelInfo("channel2");
+ fChannelInfo2.setSwitchTimer(1L);
+ fChannelInfo2.setOverwriteMode(false);
+ fChannelInfo2.setReadTimer(2L);
+ fChannelInfo2.setState(TraceEnablement.ENABLED);
+ fChannelInfo2.setNumberOfSubBuffers(3);
+ fChannelInfo2.setOutputType("mmap()");
+ fChannelInfo2.setSubBufferSize(4L);
+ fChannelInfo2.addEvent(fEventInfo2);
+ fChannelInfo2.addEvent(fEventInfo3);
+
+ fDomainInfo1 = new DomainInfo("test1");
+ fDomainInfo1.addChannel(fChannelInfo1);
+
+ fDomainInfo2 = new DomainInfo("test2");
+ fDomainInfo2.addChannel(fChannelInfo1);
+ fDomainInfo2.addChannel(fChannelInfo2);
+
+ fSessionInfo1 = new SessionInfo("session1");
+ fSessionInfo1.setSessionPath("/home/user");
+ fSessionInfo1.setSessionState(TraceSessionState.ACTIVE);
+ fSessionInfo1.addDomain(fDomainInfo1);
+
+ fSessionInfo2 = new SessionInfo("session2");
+ fSessionInfo2.setSessionPath("/home/user1");
+ fSessionInfo2.setSessionState(TraceSessionState.INACTIVE);
+ fSessionInfo2.addDomain(fDomainInfo1);
+ fSessionInfo2.addDomain(fDomainInfo2);
+
+ fProbeEventInfo1 = new ProbeEventInfo("probeEvent1");
+ fProbeEventInfo1.setEventType(TraceEventType.TRACEPOINT);
+ fProbeEventInfo1.setState(TraceEnablement.ENABLED);
+ fProbeEventInfo1.setAddress("0xc1231234");
+
+ fProbeEventInfo2 = new ProbeEventInfo("probeEvent2");
+ fProbeEventInfo2.setEventType(TraceEventType.UNKNOWN);
+ fProbeEventInfo2.setState(TraceEnablement.DISABLED);
+ fProbeEventInfo2.setOffset("0x100");
+ fProbeEventInfo2.setSymbol("init_post");
+ }
+
+ public ISessionInfo getSessionInfo1() {
+ return fSessionInfo1;
+ }
+
+ public ISessionInfo getSessionInfo2() {
+ return fSessionInfo2;
+ }
+
+ public IDomainInfo getDomainInfo1() {
+ return fDomainInfo1;
+ }
+
+ public IDomainInfo getDomainInfo2() {
+ return fDomainInfo2;
+ }
+
+ public IChannelInfo getChannel1() {
+ return fChannelInfo1;
+ }
+
+ public IChannelInfo getChannel2() {
+ return fChannelInfo2;
+ }
+
+ public IEventInfo getEventInfo1() {
+ return fEventInfo1;
+ }
+
+ public IEventInfo getEventInfo2() {
+ return fEventInfo2;
+ }
+
+ public IEventInfo getEventInfo3() {
+ return fEventInfo3;
+ }
+
+ public IBaseEventInfo getBaseEventInfo1() {
+ return fBaseEventInfo1;
+ }
+
+ public IBaseEventInfo getBaseEventInfo2() {
+ return fBaseEventInfo2;
+ }
+
+ public IUstProviderInfo getUstProviderInfo1() {
+ return fUstProviderInfo1;
+ }
+
+ public IUstProviderInfo getUstProviderInfo2() {
+ return fUstProviderInfo2;
+ }
+
+ public IProbeEventInfo getProbeEventInfo1() {
+ return fProbeEventInfo1;
+ }
+
+ public IProbeEventInfo getProbeEventInfo2() {
+ return fProbeEventInfo2;
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import junit.framework.TestCase;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IProbeEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.EventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ProbeEventInfo;
+
+/**
+ * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>.
+ */
+@SuppressWarnings("nls")
+public class ProbeEventInfoTest extends TestCase {
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private IProbeEventInfo fEventInfo1 = null;
+ private IProbeEventInfo fEventInfo2 = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ */
+ @Override
+ public void setUp() throws Exception {
+ ModelImplFactory factory = new ModelImplFactory();
+ fEventInfo1 = factory.getProbeEventInfo1();
+ fEventInfo2 = factory.getProbeEventInfo2();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ */
+ @Override
+ public void tearDown() throws Exception {
+ }
+
+ // ------------------------------------------------------------------------
+ // Tests
+ // ------------------------------------------------------------------------
+
+ /**
+ * Run the BaseEventInfo() constructor test.
+ *
+ */
+ public void testBaseEventInfo() {
+ ProbeEventInfo fixture = new ProbeEventInfo("event");
+ assertNotNull(fixture);
+
+ TraceEventType result = fixture.getEventType();
+
+ assertEquals("event", fixture.getName());
+ assertEquals("unknown", result.getInName());
+ assertEquals("UNKNOWN", result.name());
+ assertEquals("UNKNOWN", result.toString());
+ assertEquals(3, result.ordinal());
+
+ TraceEnablement state = fixture.getState();
+ assertEquals("disabled", state.getInName());
+ assertEquals("DISABLED", state.name());
+ assertEquals("DISABLED", state.toString());
+ assertEquals(0, state.ordinal());
+
+ assertNull(fixture.getAddress());
+ assertNull(fixture.getOffset());
+ assertNull(fixture.getSymbol());
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testEventInfoCopy() {
+ ProbeEventInfo info = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+
+ assertEquals(fEventInfo1.getName(), info.getName());
+ assertEquals(fEventInfo1.getEventType(), info.getEventType());
+ assertEquals(fEventInfo1.getState(), info.getState());
+ assertEquals(fEventInfo1.getAddress(), info.getAddress());
+ assertEquals(fEventInfo1.getOffset(), info.getOffset());
+ assertEquals(fEventInfo1.getSymbol(), info.getSymbol());
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testEventCopy2() {
+ try {
+ ProbeEventInfo info = null;
+ new ProbeEventInfo(info);
+ fail("null copy");
+ }
+ catch (IllegalArgumentException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Getter/Setter tests
+ */
+ public void testGetAndSetter() {
+ ProbeEventInfo fixture = new ProbeEventInfo("event");
+
+ // Make sure that ProbeEventInfo extends EventInfo
+ // -> so we don't need to re-test common parts
+ assertTrue(fixture instanceof EventInfo);
+
+ fixture.setAddress("0xc12344321");
+ String result = fixture.getAddress();
+
+ assertNotNull(result);
+ assertEquals("0xc12344321", result);
+
+ fixture.setOffset("0x1000");
+ result = fixture.getOffset();
+
+ assertNotNull(result);
+ assertEquals("0x1000", result);
+
+ fixture.setSymbol("cpu_idle");
+ result = fixture.getSymbol();
+
+ assertNotNull(result);
+ assertEquals("cpu_idle", result);
+ }
+
+ /**
+ * Run the String toString() method test.
+ */
+ public void testToString_1() {
+ assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)],fAddress=0xc1231234)]", fEventInfo1.toString());
+ assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent2)],type=UNKNOWN,level=TRACE_DEBUG)],State=DISABLED)],fOffset=0x100,fSymbol=init_post)]", fEventInfo2.toString());
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fEventInfo1.equals(fEventInfo1));
+ assertTrue("equals", fEventInfo2.equals(fEventInfo2));
+
+ assertTrue("equals", !fEventInfo1.equals(fEventInfo2));
+ assertTrue("equals", !fEventInfo2.equals(fEventInfo1));
+ }
+
+ public void testEqualsSymmetry() {
+ ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+ ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo2);
+
+ assertTrue("equals", info1.equals(fEventInfo1));
+ assertTrue("equals", fEventInfo1.equals(info1));
+
+ assertTrue("equals", info2.equals(fEventInfo2));
+ assertTrue("equals", fEventInfo2.equals(info2));
+ }
+
+ public void testEqualsTransivity() {
+ ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+ ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+ ProbeEventInfo info3 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+
+ assertTrue("equals", info1.equals(info2));
+ assertTrue("equals", info2.equals(info3));
+ assertTrue("equals", info1.equals(info3));
+ }
+
+ public void testEqualsNull() {
+ assertTrue("equals", !fEventInfo1.equals(null));
+ assertTrue("equals", !fEventInfo2.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ public void testHashCode() {
+ ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+ ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo2);
+
+ assertTrue("hashCode", fEventInfo1.hashCode() == info1.hashCode());
+ assertTrue("hashCode", fEventInfo2.hashCode() == info2.hashCode());
+
+ assertTrue("hashCode", fEventInfo1.hashCode() != info2.hashCode());
+ assertTrue("hashCode", fEventInfo2.hashCode() != info1.hashCode());
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.SessionInfo;
+
+/**
+ * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link SessionInfo}</code>.
+ *
+ */
+@SuppressWarnings("nls")
+public class SessionInfoTest extends TestCase {
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private ISessionInfo fSessionInfo1 = null;
+ private ISessionInfo fSessionInfo2 = null;
+
+ private IDomainInfo fDomainInfo1 = null;
+ private IDomainInfo fDomainInfo2 = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ */
+ @Override
+ public void setUp() {
+ ModelImplFactory factory = new ModelImplFactory();
+ fSessionInfo1 = factory.getSessionInfo1();
+ fDomainInfo1 = factory.getDomainInfo1();
+ fSessionInfo2 = factory.getSessionInfo2();
+ fDomainInfo2 = factory.getDomainInfo2();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ */
+ @Override
+ public void tearDown() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Tests
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Run the ChannelInfo() constructor test.
+ *
+ */
+ public void testSessionInfo() {
+ ISessionInfo result = new SessionInfo("test");
+ assertNotNull(result);
+
+ assertEquals("test", result.getName());
+ assertEquals("", result.getSessionPath());
+ TraceSessionState state = result.getSessionState();
+ assertEquals("inactive", state.getInName());
+ assertEquals("INACTIVE", state.name());
+ assertEquals("INACTIVE", state.toString());
+ assertEquals(0, state.ordinal());
+ assertEquals(0, result.getDomains().length);
+ }
+
+ public void testSessionInfoCopy() {
+ SessionInfo sessionInfo = new SessionInfo((SessionInfo)fSessionInfo1);
+
+ assertEquals(sessionInfo.getName(), fSessionInfo1.getName());
+ assertEquals(sessionInfo.getSessionPath(), fSessionInfo1.getSessionPath());
+ assertEquals(sessionInfo.getSessionState(), fSessionInfo1.getSessionState());
+
+ IDomainInfo[] orignalDomains = fSessionInfo1.getDomains();
+ IDomainInfo[] resultDomains = sessionInfo.getDomains();
+ for (int i = 0; i < orignalDomains.length; i++) {
+ assertEquals(orignalDomains[i], resultDomains[i]);
+ }
+ }
+
+ public void testSessionCopy2() {
+ try {
+ SessionInfo session = null;
+ new SessionInfo(session);
+ fail("null copy");
+ }
+ catch (IllegalArgumentException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Run the long getNumberOfSubBuffers() method test.
+ *
+ */
+ public void testGetAndSetters() {
+
+ // Note that addDomain() has been executed in setUp()
+ // check get method here
+ assertEquals(1, fSessionInfo1.getDomains().length);
+ assertNotNull(fSessionInfo1.getDomains()[0]);
+ assertEquals(fDomainInfo1, fSessionInfo1.getDomains()[0]);
+
+ ISessionInfo session = new SessionInfo("session");
+ List<IDomainInfo> list = new LinkedList<IDomainInfo>();
+ list.add(fDomainInfo1);
+ list.add(fDomainInfo2);
+ session.setDomains(list);
+
+ IDomainInfo[] result = session.getDomains();
+ assertEquals(2, result.length);
+ assertEquals(fDomainInfo1, result[0]);
+ assertEquals(fDomainInfo2, result[1]);
+
+ session.setSessionPath("/home/user");
+ assertEquals("/home/user", session.getSessionPath());
+
+ session.setSessionState("active");
+ TraceSessionState state = session.getSessionState();
+ state = session.getSessionState();
+ assertEquals("active", state.getInName());
+ assertEquals("ACTIVE", state.name());
+ assertEquals("ACTIVE", state.toString());
+ assertEquals(1, state.ordinal());
+
+ session.setSessionState("inactive");
+ state = session.getSessionState();
+ assertEquals("inactive", state.getInName());
+ assertEquals("INACTIVE", state.name());
+ assertEquals("INACTIVE", state.toString());
+ assertEquals(0, state.ordinal());
+
+ session.setSessionState("test");
+ state = session.getSessionState();
+ assertEquals("inactive", state.getInName());
+ assertEquals("INACTIVE", state.name());
+ assertEquals("INACTIVE", state.toString());
+ assertEquals(0, state.ordinal());
+
+ session.setSessionState(TraceSessionState.ACTIVE);
+ state = session.getSessionState();
+ assertEquals("active", state.getInName());
+ assertEquals("ACTIVE", state.name());
+ assertEquals("ACTIVE", state.toString());
+ assertEquals(1, state.ordinal());
+
+ session.setSessionState(TraceSessionState.INACTIVE);
+ state = session.getSessionState();
+ assertEquals("inactive", state.getInName());
+ assertEquals("INACTIVE", state.name());
+ assertEquals("INACTIVE", state.toString());
+ assertEquals(0, state.ordinal());
+ }
+
+ public void testToString_1() {
+ ISessionInfo fixture = new SessionInfo("sessionName");
+
+ String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals("[SessionInfo([TraceInfo(Name=sessionName)],State=INACTIVE,Domains=)]", result);
+ }
+
+ /**
+ * Run the String toString() method test.
+ *
+ */
+ public void testToString_2() {
+ String result = fSessionInfo1.toString();
+
+ // add additional test code here
+ assertEquals("[SessionInfo([TraceInfo(Name=session1)],State=ACTIVE,Domains=[DomainInfo([TraceInfo(Name=test1)],Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],isKernel=false)])]", result);
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fSessionInfo1.equals(fSessionInfo1));
+ assertTrue("equals", fSessionInfo2.equals(fSessionInfo2));
+
+ assertTrue("equals", !fSessionInfo1.equals(fSessionInfo2));
+ assertTrue("equals", !fSessionInfo2.equals(fSessionInfo1));
+ }
+
+ public void testEqualsSymmetry() {
+ SessionInfo event1 = new SessionInfo((SessionInfo)fSessionInfo1);
+ SessionInfo event2 = new SessionInfo((SessionInfo)fSessionInfo2);
+
+ assertTrue("equals", event1.equals(fSessionInfo1));
+ assertTrue("equals", fSessionInfo1.equals(event1));
+
+ assertTrue("equals", event2.equals(fSessionInfo2));
+ assertTrue("equals", fSessionInfo2.equals(event2));
+ }
+
+ public void testEqualsTransivity() {
+ SessionInfo channel1 = new SessionInfo((SessionInfo)fSessionInfo1);
+ SessionInfo channel2 = new SessionInfo((SessionInfo)fSessionInfo1);
+ SessionInfo channel3 = new SessionInfo((SessionInfo)fSessionInfo1);
+
+ assertTrue("equals", channel1.equals(channel2));
+ assertTrue("equals", channel2.equals(channel3));
+ assertTrue("equals", channel1.equals(channel3));
+ }
+
+ public void testEqualsNull() throws Exception {
+ assertTrue("equals", !fSessionInfo1.equals(null));
+ assertTrue("equals", !fSessionInfo2.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ public void testHashCode() {
+ SessionInfo channel1 = new SessionInfo((SessionInfo)fSessionInfo1);
+ SessionInfo channel2 = new SessionInfo((SessionInfo)fSessionInfo2);
+
+ assertTrue("hashCode", fSessionInfo1.hashCode() == channel1.hashCode());
+ assertTrue("hashCode", fSessionInfo2.hashCode() == channel2.hashCode());
+
+ assertTrue("hashCode", fSessionInfo1.hashCode() != channel2.hashCode());
+ assertTrue("hashCode", fSessionInfo2.hashCode() != channel1.hashCode());
+ }}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import junit.framework.TestCase;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo;
+
+/**
+ * The class <code>TraceInfoTest</code> contains test for the class <code>{@link TraceInfo}</code>.
+ */
+@SuppressWarnings("nls")
+public class TraceInfoTest extends TestCase {
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private ITraceInfo fTraceInfo1 = null;
+ private ITraceInfo fTraceInfo2 = null;
+
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ */
+ @Override
+ public void setUp() throws Exception {
+ fTraceInfo1 = new TraceInfo("event1");
+ fTraceInfo2 = new TraceInfo("event2");
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ */
+ @Override
+ public void tearDown() throws Exception {
+ }
+
+ // ------------------------------------------------------------------------
+ // Tests
+ // ------------------------------------------------------------------------
+
+ /**
+ * Run the BaseEventInfo() constructor test.
+ *
+ */
+ public void testTraceInfo() {
+ TraceInfo fixture = new TraceInfo("event");
+ assertNotNull(fixture);
+
+ assertEquals("event", fixture.getName());
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testTraceInfo2() {
+ try {
+ String name = null;
+ new TraceInfo(name);
+ fail("null name in custructor");
+ }
+ catch (IllegalArgumentException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testTraceInfoCopy() {
+ TraceInfo info = new TraceInfo((TraceInfo)fTraceInfo1);
+
+ assertEquals(fTraceInfo1.getName(), info.getName());
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testTraceCopy2() {
+ try {
+ TraceInfo info = null;
+ new TraceInfo(info);
+ fail("null copy");
+ }
+ catch (IllegalArgumentException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Run the void setEventType(String) method test.
+ *
+ */
+ public void testSetName() {
+ TraceInfo fixture = new TraceInfo("event");
+ fixture.setName("newName");
+ assertEquals("newName", fixture.getName());
+ }
+
+ /**
+ * Run the String toString() method test.
+ *
+ */
+ public void testToString_1() {
+ String result = fTraceInfo1.toString();
+
+ // add additional test code here
+ assertEquals("[TraceInfo(Name=event1)]", result);
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fTraceInfo1.equals(fTraceInfo1));
+ assertTrue("equals", fTraceInfo2.equals(fTraceInfo2));
+
+ assertTrue("equals", !fTraceInfo1.equals(fTraceInfo2));
+ assertTrue("equals", !fTraceInfo2.equals(fTraceInfo1));
+ }
+
+ public void testEqualsSymmetry() {
+ TraceInfo info1 = new TraceInfo((TraceInfo)fTraceInfo1);
+ TraceInfo info2 = new TraceInfo((TraceInfo)fTraceInfo2);
+
+ assertTrue("equals", info1.equals(fTraceInfo1));
+ assertTrue("equals", fTraceInfo1.equals(info1));
+
+ assertTrue("equals", info2.equals(fTraceInfo2));
+ assertTrue("equals", fTraceInfo2.equals(info2));
+ }
+
+ public void testEqualsTransivity() {
+ TraceInfo info1 = new TraceInfo((TraceInfo)fTraceInfo1);
+ TraceInfo info2 = new TraceInfo((TraceInfo)fTraceInfo1);
+ TraceInfo info3 = new TraceInfo((TraceInfo)fTraceInfo1);
+
+ assertTrue("equals", info1.equals(info2));
+ assertTrue("equals", info2.equals(info3));
+ assertTrue("equals", info1.equals(info3));
+ }
+
+ public void testEqualsNull() {
+ assertTrue("equals", !fTraceInfo1.equals(null));
+ assertTrue("equals", !fTraceInfo2.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ public void testHashCode() {
+ TraceInfo info1 = new TraceInfo((TraceInfo)fTraceInfo1);
+ TraceInfo info2 = new TraceInfo((TraceInfo)fTraceInfo2);
+
+ assertTrue("hashCode", fTraceInfo1.hashCode() == info1.hashCode());
+ assertTrue("hashCode", fTraceInfo2.hashCode() == info2.hashCode());
+
+ assertTrue("hashCode", fTraceInfo1.hashCode() != info2.hashCode());
+ assertTrue("hashCode", fTraceInfo2.hashCode() != info1.hashCode());
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.impl;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderInfo;
+
+/**
+ * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link UstProviderInfo}</code>.
+ *
+ */
+@SuppressWarnings("nls")
+public class UstProviderInfoTest extends TestCase {
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private IUstProviderInfo fUstProviderInfo1 = null;
+ private IUstProviderInfo fUstProviderInfo2 = null;
+
+ private IBaseEventInfo fEventInfo1 = null;
+ private IBaseEventInfo fEventInfo2 = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ */
+ @Override
+ public void setUp() {
+ ModelImplFactory factory = new ModelImplFactory();
+ fUstProviderInfo1 = factory.getUstProviderInfo1();
+ fUstProviderInfo2 = factory.getUstProviderInfo2();
+ fEventInfo1 = factory.getBaseEventInfo1();
+ fEventInfo1 = factory.getBaseEventInfo2();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ */
+ @Override
+ public void tearDown() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Tests
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Run the UstProviderInfo() constructor test.
+ *
+ */
+ public void testUstProviderInfo() {
+ IUstProviderInfo result = new UstProviderInfo("test");
+ assertNotNull(result);
+
+ assertEquals("test", result.getName());
+ assertEquals(0, result.getPid());
+ assertEquals(0, result.getEvents().length);
+ }
+
+ public void testUstProviderInfoCopy() {
+ IUstProviderInfo providerInf = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
+
+ assertEquals(fUstProviderInfo1.getName(), providerInf.getName());
+ assertEquals(fUstProviderInfo1.getPid(), providerInf.getPid());
+ assertEquals(fUstProviderInfo1.getEvents().length, providerInf.getEvents().length);
+
+ IBaseEventInfo[] orignalEvents = fUstProviderInfo1.getEvents();
+ IBaseEventInfo[] resultEvents = providerInf.getEvents();
+ for (int i = 0; i < orignalEvents.length; i++) {
+ assertEquals(orignalEvents[i], resultEvents[i]);
+ }
+ }
+
+ public void testUstProviderCopy2() {
+ try {
+ UstProviderInfo providerInfo = null;
+ new UstProviderInfo(providerInfo);
+ fail("null copy");
+ }
+ catch (IllegalArgumentException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Run the IEventInfo[] getEvents() method test.
+ *
+ */
+ public void testGetAndSetters() {
+ IUstProviderInfo fixture = new UstProviderInfo("test");
+ fixture.setPid(2468);
+
+ // add an event
+ IBaseEventInfo event = new BaseEventInfo("event");
+ fixture.addEvent(event);
+
+ // Verify the stored events
+ IBaseEventInfo[] result = fixture.getEvents();
+
+ assertNotNull(result);
+ assertEquals(1, result.length);
+ assertNotNull(result[0]);
+ assertTrue(event.equals(result[0]));
+
+ assertEquals(2468, fixture.getPid());
+ }
+
+ /**
+ * Run the void setEvents(List<IBaseEventInfo>) method test.
+ *
+ */
+ public void testSetEvents_1() {
+ UstProviderInfo fixture = new UstProviderInfo("test");
+ fixture.setPid(2468);
+ List<IBaseEventInfo> events = new LinkedList<IBaseEventInfo>();
+ events.add(fEventInfo1);
+ events.add(fEventInfo2);
+ fixture.setEvents(events);
+
+ IBaseEventInfo[] infos = fixture.getEvents();
+
+ assertEquals(events.size(), infos.length);
+
+ for (int i = 0; i < infos.length; i++) {
+ assertEquals(events.get(i), infos[i]);
+ }
+ }
+
+ public void testToString_1() {
+ UstProviderInfo fixture = new UstProviderInfo("test");
+ fixture.setPid(2468);
+ String result = fixture.toString();
+
+ assertEquals("[EventInfo([TraceInfo(Name=test)],PID=2468,Events=None)]", result);
+ }
+
+ /**
+ * Run the String toString() method test.
+ *
+ */
+ public void testToString_2() {
+ String result = fUstProviderInfo2.toString();
+ assertEquals("[EventInfo([TraceInfo(Name=myUST2)],PID=2345,Events=[BaseEventInfo([TraceInfo(Name=event1)],type=UNKNOWN,level=TRACE_DEBUG)][BaseEventInfo([TraceInfo(Name=event2)],type=TRACEPOINT,level=TRACE_DEBUG)])]", result);
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fUstProviderInfo1.equals(fUstProviderInfo1));
+ assertTrue("equals", fUstProviderInfo2.equals(fUstProviderInfo2));
+
+ assertTrue("equals", !fUstProviderInfo1.equals(fUstProviderInfo2));
+ assertTrue("equals", !fUstProviderInfo2.equals(fUstProviderInfo1));
+ }
+
+ public void testEqualsSymmetry() {
+ UstProviderInfo event1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
+ UstProviderInfo event2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo2);
+
+ assertTrue("equals", event1.equals(fUstProviderInfo1));
+ assertTrue("equals", fUstProviderInfo1.equals(event1));
+
+ assertTrue("equals", event2.equals(fUstProviderInfo2));
+ assertTrue("equals", fUstProviderInfo2.equals(event2));
+ }
+
+ public void testEqualsTransivity() {
+ UstProviderInfo UstProvider1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
+ UstProviderInfo UstProvider2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
+ UstProviderInfo UstProvider3 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
+
+ assertTrue("equals", UstProvider1.equals(UstProvider2));
+ assertTrue("equals", UstProvider2.equals(UstProvider3));
+ assertTrue("equals", UstProvider1.equals(UstProvider3));
+ }
+
+ public void testEqualsNull() throws Exception {
+ assertTrue("equals", !fUstProviderInfo1.equals(null));
+ assertTrue("equals", !fUstProviderInfo2.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ public void testHashCode() {
+ UstProviderInfo UstProvider1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
+ UstProviderInfo UstProvider2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo2);
+
+ assertTrue("hashCode", fUstProviderInfo1.hashCode() == UstProvider1.hashCode());
+ assertTrue("hashCode", fUstProviderInfo2.hashCode() == UstProvider2.hashCode());
+
+ assertTrue("hashCode", fUstProviderInfo1.hashCode() != UstProvider2.hashCode());
+ assertTrue("hashCode", fUstProviderInfo2.hashCode() != UstProvider1.hashCode());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.service;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ //$JUnit-BEGIN$
+ suite.addTestSuite(LTTngControlServiceTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.ui.tests.control.service;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.internal.lttng2.stubs.service.CommandShellFactory;
+import org.eclipse.linuxtools.internal.lttng2.stubs.shells.LTTngToolsFileShell;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
+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.lttng2.ui.tests.Activator;
+/**
+ * The class <code>LTTngControlServiceTest</code> contains test for the class <code>{@link LTTngControlService}</code>.
+ */
+@SuppressWarnings("nls")
+public class LTTngControlServiceTest extends TestCase {
+
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM = "LTTngServiceTest.cfg";
+
+ private static final String SCEN_LTTNG_NOT_INSTALLED = "LttngNotInstalled";
+ private static final String SCEN_NO_SESSION_AVAILABLE = "NoSessionAvailable";
+ private static final String SCEN_GET_SESSION_NAMES1 = "GetSessionNames1";
+ private static final String SCEN_GET_SESSION_NAME_NOT_EXIST = "GetSessionNameNotExist";
+ private static final String SCEN_GET_SESSION_GARBAGE_OUT = "GetSessionGarbageOut";
+ private static final String SCEN_GET_SESSION1 = "GetSession1";
+ private static final String SCEN_GET_KERNEL_PROVIDER1 = "GetKernelProvider1";
+ private static final String SCEN_GET_UST_PROVIDER1 = "GetUstProvider1";
+ private static final String SCEN_GET_UST_PROVIDER2 = "GetUstProvider2";
+ private static final String SCEN_CREATE_SESSION1 = "CreateSession1";
+ private static final String SCEN_CREATE_SESSION_VARIANTS = "CreateSessionVariants";
+ private static final String SCEN_DESTROY_SESSION1 = "DestroySession1";
+ private static final String SCEN_CHANNEL_HANDLING = "ChannelHandling";
+ private static final String SCEN_EVENT_HANDLING = "EventHandling";
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private CommandShellFactory fShellFactory;
+ private String fTestfile;
+ private LTTngToolsFileShell fShell;
+ private ILttngControlService fService;
+
+
+ // ------------------------------------------------------------------------
+ // Static methods
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ */
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ fShellFactory = CommandShellFactory.getInstance();
+
+ URL location = FileLocator.find(Activator.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ File testfile = new File(FileLocator.toFileURL(location).toURI());
+ fTestfile = testfile.getAbsolutePath();
+
+ fShell = fShellFactory.getFileShell();
+ fShell.loadScenarioFile(fTestfile);
+ fService = new LTTngControlService(fShell);
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ */
+ @Override
+ public void tearDown() throws Exception {
+ }
+
+ // ------------------------------------------------------------------------
+ // Test Cases
+ // ------------------------------------------------------------------------
+
+ public void testGetSessionNames() {
+ try {
+ fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED);
+ fService.getSessionNames(new NullProgressMonitor());
+ fail("No exeption thrown");
+ } catch (ExecutionException e) {
+ // success
+ }
+ }
+
+ public void testGetSessionNames1() {
+ try {
+ fShell.setScenario(SCEN_NO_SESSION_AVAILABLE);
+ String[] result = fService.getSessionNames(new NullProgressMonitor());
+
+ assertNotNull(result);
+ assertEquals(0, result.length);
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testGetSessionNames2() {
+ try {
+ fShell.setScenario(SCEN_GET_SESSION_NAMES1);
+ String[] result = fService.getSessionNames(new NullProgressMonitor());
+
+ assertNotNull(result);
+ assertEquals(2, result.length);
+ assertEquals("mysession1", result[0]);
+ assertEquals("mysession", result[1]);
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testGetSessionNotExist() {
+ try {
+ fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST);
+ fService.getSessionNames(new NullProgressMonitor());
+ fail("No exeption thrown");
+
+ } catch (ExecutionException e) {
+ // success
+ }
+ }
+
+ public void testGetSessionNameGarbage() {
+ try {
+ fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT);
+ String[] result = fService.getSessionNames(new NullProgressMonitor());
+
+ assertNotNull(result);
+ assertEquals(0, result.length);
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testGetSession1() {
+ try {
+ fShell.setScenario(SCEN_GET_SESSION1);
+ ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor());
+
+ // Verify Session
+ assertNotNull(session);
+ assertEquals("mysession", session.getName());
+ assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
+ assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
+
+ IDomainInfo[] domains = session.getDomains();
+ assertNotNull(domains);
+ assertEquals(2, domains.length);
+
+ // Verify Kernel domain
+ assertEquals("Kernel", domains[0].getName());
+ IChannelInfo[] channels = domains[0].getChannels();
+ assertNotNull(channels);
+ assertEquals(2, channels.length);
+
+ // Verify Kernel's channel0
+ assertEquals("channel0", channels[0].getName());
+ assertEquals(4, channels[0].getNumberOfSubBuffers());
+ assertEquals("splice()", channels[0].getOutputType());
+ assertEquals(false, channels[0].isOverwriteMode());
+ assertEquals(200, channels[0].getReadTimer());
+ assertEquals(TraceEnablement.ENABLED, channels[0].getState());
+ assertEquals(262144, channels[0].getSubBufferSize());
+ assertEquals(0, channels[0].getSwitchTimer());
+
+ // Verify event info
+ IEventInfo[] channel0Events = channels[0].getEvents();
+ assertNotNull(channel0Events);
+ assertEquals(2, channel0Events.length);
+ assertEquals("block_rq_remap", channel0Events[0].getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType());
+ assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState());
+
+ assertEquals("block_bio_remap", channel0Events[1].getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[1].getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, channel0Events[1].getEventType());
+ assertEquals(TraceEnablement.DISABLED, channel0Events[1].getState());
+
+ // Verify Kernel's channel1
+ assertEquals("channel1", channels[1].getName());
+ assertEquals(4, channels[1].getNumberOfSubBuffers());
+ assertEquals("splice()", channels[1].getOutputType());
+ assertEquals(true, channels[1].isOverwriteMode());
+ assertEquals(400, channels[1].getReadTimer());
+ assertEquals(TraceEnablement.DISABLED, channels[1].getState());
+ assertEquals(524288, channels[1].getSubBufferSize());
+ assertEquals(100, channels[1].getSwitchTimer());
+
+ // Verify event info
+ IEventInfo[] channel1Events = channels[1].getEvents();
+ assertEquals(0, channel1Events.length);
+
+ // Verify domain UST global
+ assertEquals("UST global", domains[1].getName());
+
+ IChannelInfo[] ustChannels = domains[1].getChannels();
+
+ // Verify UST global's mychannel1
+ assertEquals("mychannel1", ustChannels[0].getName());
+ assertEquals(8, ustChannels[0].getNumberOfSubBuffers());
+ assertEquals("mmap()", ustChannels[0].getOutputType());
+ assertEquals(true, ustChannels[0].isOverwriteMode());
+ assertEquals(100, ustChannels[0].getReadTimer());
+ assertEquals(TraceEnablement.DISABLED, ustChannels[0].getState());
+ assertEquals(8192, ustChannels[0].getSubBufferSize());
+ assertEquals(200, ustChannels[0].getSwitchTimer());
+
+ // Verify event info
+ IEventInfo[] ustEvents = ustChannels[0].getEvents();
+ assertEquals(0, ustEvents.length);
+
+ // Verify UST global's channel0
+ assertEquals("channel0", ustChannels[1].getName());
+ assertEquals(4, ustChannels[1].getNumberOfSubBuffers());
+ assertEquals("mmap()", ustChannels[1].getOutputType());
+ assertEquals(false, ustChannels[1].isOverwriteMode());
+ assertEquals(200, ustChannels[1].getReadTimer());
+ assertEquals(TraceEnablement.ENABLED, ustChannels[1].getState());
+ assertEquals(4096, ustChannels[1].getSubBufferSize());
+ assertEquals(0, ustChannels[1].getSwitchTimer());
+
+ // Verify event info
+ ustEvents = ustChannels[1].getEvents();
+ assertEquals(2, ustEvents.length);
+
+ assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName());
+ assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType());
+ assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState());
+
+ assertEquals("*", ustEvents[1].getName());
+ assertEquals(TraceLogLevel.LEVEL_UNKNOWN, ustEvents[1].getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, ustEvents[1].getEventType());
+ assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState());
+
+ // next session (no detailed information available)
+ session = fService.getSession("mysession1", new NullProgressMonitor());
+ assertNotNull(session);
+ assertEquals("mysession1", session.getName());
+ assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session.getSessionPath());
+ assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
+
+ domains = session.getDomains();
+ assertNotNull(domains);
+ assertEquals(0, domains.length);
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testGetKernelProvider() {
+ try {
+ fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1);
+ List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor());
+
+ // Verify event info
+ assertNotNull(events);
+ assertEquals(3, events.size());
+
+ IBaseEventInfo baseEventInfo = (IBaseEventInfo) events.get(0);
+ assertNotNull(baseEventInfo);
+ assertEquals("sched_kthread_stop", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ baseEventInfo = (IBaseEventInfo) events.get(1);
+ assertEquals("sched_kthread_stop_ret", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ baseEventInfo = (IBaseEventInfo) events.get(2);
+ assertEquals("sched_wakeup_new", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testGetUstProvider() {
+ try {
+ fShell.setScenario(SCEN_GET_UST_PROVIDER1);
+ List<IUstProviderInfo> providers = fService.getUstProvider();
+
+ // Check all providers
+ assertNotNull(providers);
+ assertEquals(2, providers.size());
+
+ //Verify first provider
+ assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName());
+ assertEquals(9379, providers.get(0).getPid());
+
+ // Verify event info
+ IBaseEventInfo[] events = providers.get(0).getEvents();
+ assertNotNull(events);
+ assertEquals(2, events.length);
+
+ IBaseEventInfo baseEventInfo = (IBaseEventInfo) events[0];
+ assertNotNull(baseEventInfo);
+ assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ baseEventInfo = (IBaseEventInfo) events[1];
+ assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ //Verify second provider
+ assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName());
+ assertEquals(4852, providers.get(1).getPid());
+
+ // Verify event info
+ events = providers.get(1).getEvents();
+ assertNotNull(events);
+ assertEquals(2, events.length);
+
+ baseEventInfo = (IBaseEventInfo) events[0];
+ assertNotNull(baseEventInfo);
+ assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ baseEventInfo = (IBaseEventInfo) events[1];
+ assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
+ assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testUstProvider2() {
+ try {
+ fShell.setScenario(SCEN_GET_UST_PROVIDER2);
+ List<IUstProviderInfo> providers = fService.getUstProvider();
+
+ assertNotNull(providers);
+ assertEquals(0, providers.size());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testCreateSession() {
+ try {
+ fShell.setScenario(SCEN_CREATE_SESSION1);
+
+ ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor());
+ assertNotNull(info);
+ assertEquals("mysession2", info.getName());
+ assertNotNull(info.getSessionPath());
+ assertTrue(info.getSessionPath().contains("mysession2"));
+ assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testCreateSessionVariants() {
+
+ fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS);
+
+ try {
+ fService.createSession("alreadyExist", null, new NullProgressMonitor());
+ fail("No exeption thrown");
+ } catch (ExecutionException e) {
+ // success
+ }
+
+ try {
+ fService.createSession("wrongName", null, new NullProgressMonitor());
+ fail("No exeption thrown");
+ } catch (ExecutionException e) {
+ // success
+ }
+
+ try {
+ fService.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
+ fail("No exeption thrown");
+ } catch (ExecutionException e) {
+ // success
+ }
+
+ try {
+ ISessionInfo info = fService.createSession("session with spaces", null, new NullProgressMonitor());
+ assertNotNull(info);
+ assertEquals("session with spaces", info.getName());
+ assertNotNull(info.getSessionPath());
+ assertTrue(info.getSessionPath().contains("session with spaces"));
+ assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+
+ try {
+ ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
+ assertNotNull(info);
+ assertEquals("pathWithSpaces", info.getName());
+ assertNotNull(info.getSessionPath());
+ assertTrue(info.getSessionPath().contains("/home/user/hallo user/here"));
+ assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testDestroySession() {
+ try {
+ fShell.setScenario(SCEN_DESTROY_SESSION1);
+ fService.destroySession("mysession2", new NullProgressMonitor());
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testCreateChannel() {
+ try {
+
+ String sessionName = "mysession2";
+ List<String> list = new ArrayList<String>();
+ String kernelChannel0 = "mychannel0";
+ String kernelChannel1 = "mychannel1";
+ list.add(kernelChannel0);
+ list.add(kernelChannel1);
+
+ fShell.setScenario(SCEN_CHANNEL_HANDLING);
+
+ // Create/enable/configure 2 kernel channels
+ ChannelInfo chanInfo = new ChannelInfo("");
+ chanInfo.setOverwriteMode(true);
+ chanInfo.setSubBufferSize(16384);
+ chanInfo.setReadTimer(100);
+ chanInfo.setSwitchTimer(200);
+ chanInfo.setNumberOfSubBuffers(2);
+ fService.enableChannels(sessionName, list, true, chanInfo, new NullProgressMonitor());
+
+ // Create/enable/configure 1 UST channel
+ list.clear();
+ list.add("ustChannel");
+
+ chanInfo = new ChannelInfo("");
+ chanInfo.setOverwriteMode(true);
+ chanInfo.setSubBufferSize(32768);
+ chanInfo.setReadTimer(200);
+ chanInfo.setSwitchTimer(100);
+ chanInfo.setNumberOfSubBuffers(1);
+ fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testDisableChannel() {
+ try {
+
+ String sessionName = "mysession2";
+ List<String> list = new ArrayList<String>();
+ String kernelChannel0 = "mychannel0";
+ String kernelChannel1 = "mychannel1";
+ list.add(kernelChannel0);
+ list.add(kernelChannel1);
+
+ fShell.setScenario(SCEN_CHANNEL_HANDLING);
+ fService.disableChannels(sessionName, list, true, new NullProgressMonitor());
+
+ list.clear();
+ list.add("ustChannel");
+ fService.disableChannels(sessionName, list, false, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testEnableChannel() {
+ try {
+
+ String sessionName = "mysession2";
+ List<String> list = new ArrayList<String>();
+ String kernelChannel0 = "mychannel0";
+ String kernelChannel1 = "mychannel1";
+ list.add(kernelChannel0);
+ list.add(kernelChannel1);
+
+ fShell.setScenario(SCEN_CHANNEL_HANDLING);
+ fService.enableChannels(sessionName, list, true, null, new NullProgressMonitor());
+
+ // Create/enable/configure 1 UST channel
+ list.clear();
+ list.add("ustChannel");
+
+ fService.enableChannels(sessionName, list, false, null, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+// public void tesEnableChannelNoTracer() {
+// try {
+// ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer());
+// service.getSessionNames(new NullProgressMonitor());
+// fail("No exeption thrown");
+//
+// } catch (ExecutionException e) {
+// // success
+// }
+// }
+
+ public void testEnableEvents() {
+ try {
+ // 1) session name, channel = null, 3 event names, kernel
+ String sessionName = "mysession2";
+ List<String> list = new ArrayList<String>();
+ String eventName0 = "block_rq_remap";
+ String eventName1 = "block_bio_remap";
+ String eventName2 = "softirq_entry";
+ list.add(eventName0);
+ list.add(eventName1);
+ list.add(eventName2);
+ fShell.setScenario(SCEN_EVENT_HANDLING);
+ fService.enableEvents(sessionName, null, list, true, new NullProgressMonitor());
+
+ // 2) session name, channel=mychannel, event name= null, kernel
+ String channelName = "mychannel";
+ fService.enableEvents(sessionName, channelName, null, true, new NullProgressMonitor());
+
+ // 3) session name, channel=mychannel, 1 event name, ust
+ String ustEventName = "ust_tests_hello:tptest_sighandler";
+ list.clear();
+ list.add(ustEventName);
+ fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
+
+ // 4) session name, channel = mychannel, no event name, ust
+ list.clear();
+ fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testEnableSyscalls() {
+ try {
+ // 1) session name, channel = null, 3 event names, kernel
+ String sessionName = "mysession2";
+ String channelName = "mychannel";
+
+ fShell.setScenario(SCEN_EVENT_HANDLING);
+
+ // 1) session name, channel = null
+ fService.enableSyscalls(sessionName, null, new NullProgressMonitor());
+
+ // 2) session name, channel = mychannel
+ fService.enableSyscalls(sessionName, channelName, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testDynamicProbe() {
+ try {
+ // 1) session name, channel = null, 3 event names, kernel
+ String sessionName = "mysession2";
+ String channelName = "mychannel";
+ String eventName0 = "myevent0";
+ String eventName1 = "myevent1";
+ String functionProbe = "0xc0101340";
+ String dynProbe = "init_post";
+
+ fShell.setScenario(SCEN_EVENT_HANDLING);
+
+ // 1) session name, channel = null, event name, function probe, probe
+ fService.enableProbe(sessionName, null, eventName0, true, functionProbe, new NullProgressMonitor());
+
+ // 2) session name, channel = mychannel
+ fService.enableProbe(sessionName, channelName, eventName1, false, dynProbe, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testEnableLogLevel() {
+ try {
+ // 1) session name, channel = null, 3 event names, kernel
+ String sessionName = "mysession2";
+ String channelName = "mychannel";
+ String eventName4 = "myevent4";
+ String eventName5 = "myevent5";
+
+ fShell.setScenario(SCEN_EVENT_HANDLING);
+
+ // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
+ fService.enableLogLevel(sessionName, null, eventName4, LogLevelType.LOGLEVEL_ONLY, TraceLogLevel.TRACE_DEBUG, new NullProgressMonitor());
+
+ // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
+ fService.enableLogLevel(sessionName, channelName, eventName5, LogLevelType.LOGLEVEL, TraceLogLevel.TRACE_DEBUG_FUNCTION, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.stubs.service;
+
+import org.eclipse.linuxtools.internal.lttng2.stubs.shells.LTTngToolsFileShell;
+
+public class CommandShellFactory {
+
+ public static final int GET_SESSION_NAMES_COMMAND_SHELL = 0;
+
+ private static CommandShellFactory fInstance = null;
+
+ public static CommandShellFactory getInstance() {
+ if (fInstance == null) {
+ fInstance = new CommandShellFactory();
+ }
+ return fInstance;
+ }
+
+// public ICommandShell getRealShell() {
+// ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
+// IHost host = registry.getLocalHost();
+// RemoteSystemProxy proxy = new RemoteSystemProxy(host);
+// ICommandShell shell = new LTTngToolsSimulatorShell(proxy);
+// return shell;
+// }
+
+ public LTTngToolsFileShell getFileShell() {
+ return new LTTngToolsFileShell();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.stubs.service;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.internal.lttng2.stubs.shells.LTTngToolsFileShell;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandShell;
+import org.eclipse.rse.core.model.IRSECallback;
+import org.eclipse.rse.core.subsystems.ICommunicationsListener;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.services.shells.IShellService;
+import org.eclipse.rse.services.terminals.ITerminalService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+
+
+public class TestRemoteSystemProxy implements IRemoteSystemProxy {
+
+ private LTTngToolsFileShell fShell = null;
+ private String fTestFile = null;
+ private String fScenario = null;
+
+ @Override
+ public IShellService getShellService() {
+ return null;
+ }
+
+ @Override
+ public ITerminalService getTerminalService() {
+ return null;
+ }
+
+ @Override
+ public ISubSystem getShellServiceSubSystem() {
+ return null;
+ }
+
+ @Override
+ public ISubSystem getTerminalServiceSubSystem() {
+ return null;
+ }
+ @Override
+ public IFileServiceSubSystem getFileServiceSubSystem() {
+ return null;
+ }
+
+ @Override
+ public void connect(IRSECallback callback) throws ExecutionException {
+ if (callback != null) {
+ callback.done(Status.OK_STATUS, null);
+ }
+ }
+
+ @Override
+ public void disconnect() throws ExecutionException {
+ fShell = null;
+ }
+
+ @Override
+ public ICommandShell createCommandShell() throws ExecutionException {
+ if (fShell == null) {
+ fShell = CommandShellFactory.getInstance().getFileShell();
+ if ((fTestFile != null) && (fScenario != null)) {
+ try {
+ fShell.loadScenarioFile(fTestFile);
+ } catch (Exception e) {
+ throw new ExecutionException(e.toString());
+ }
+ fShell.setScenario(fScenario);
+ }
+ }
+ return fShell;
+ }
+
+ @Override
+ public void addCommunicationListener(ICommunicationsListener listener) {
+ }
+
+ @Override
+ public void removeCommunicationListener(ICommunicationsListener listener) {
+ }
+
+ public void setTestFile(String testFile) {
+ fTestFile = testFile;
+ }
+
+ public void setScenario(String scenario) {
+ fScenario = scenario;
+ if (fShell != null) {
+ fShell.setScenario(fScenario);
+ }
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.stubs.shells;
+
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.CommandResult;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandResult;
+
+public class LTTngToolsFileShell extends TestCommandShell {
+
+ // ------------------------------------------------------------------------
+ // CONSTANTS
+ // ------------------------------------------------------------------------
+ private final static String SCENARIO_KEY = "<SCENARIO>"; //$NON-NLS-1$
+ private final static String SCENARIO_END_KEY = "</SCENARIO>"; //$NON-NLS-1$
+ private final static String INPUT_KEY = "<COMMAND_INPUT>"; //$NON-NLS-1$
+ private final static String INPUT_END_KEY = "</COMMAND_INPUT>"; //$NON-NLS-1$
+ private final static String RESULT_KEY = "<COMMAND_RESULT>"; //$NON-NLS-1$
+ @SuppressWarnings("unused")
+ private final static String RESULT_END_KEY = "</COMMAND_RESULT>"; //$NON-NLS-1$
+ private final static String OUTPUT_KEY = "<COMMAND_OUTPUT>"; //$NON-NLS-1$
+ private final static String OUTPUT_END_KEY = "</COMMAND_OUTPUT>"; //$NON-NLS-1$
+ private final static String COMMENT_KEY = "#.*"; //$NON-NLS-1$
+
+ private final static Pattern LTTNG_LIST_SESSION_PATTERN = Pattern.compile("lttng\\s+list\\s+(.+)"); //$NON-NLS-1$
+ private final static String LTTNG_LIST_PROVIDER_PATTERN = "lttng\\s+list\\s+(-u|-k)"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ private String fScenariofile;
+ private String fScenario;
+
+ private Map<String, Map<String, ICommandResult>> fScenarioMap = new HashMap<String, Map<String, ICommandResult>>();
+ private Map<String, Integer> fSessionNameMap = new HashMap<String, Integer>();
+
+ /**
+ * Parse a scenario file with the format:
+ * <SCENARIO>
+ * ScenarioName
+ *
+ * <COMMAND_INPUT>
+ * Command
+ * </COMAND_INPUT>
+ *
+ * <COMMAND_RESULT>
+ * CommandResult
+ * </COMMAND_RESULT>
+ *
+ * <COMMAND_OUTPUT>
+ * CommandOutput
+ * </COMMAND_OUTPUT>
+ *
+ * </SCENARIO>
+ *
+ * Where: ScenarioName - is the scenario name
+ * Command - the command line string
+ * CommandResult - the result integer of the command (0 for success, 1 for failure)
+ * ComandOutput - the command output string (multi-line possible)
+ *
+ * Note: 1) There can be many scenarios per file
+ * 2) There can be many (Command-CommandResult-CommandOutput) triples per scenario
+ * 3) Lines starting with # will be ignored (comments)
+ *
+ * @param scenariofile - path to scenario file
+ * @throws Exception
+ */
+ public void loadScenarioFile(String scenariofile) throws Exception {
+ fScenariofile = scenariofile;
+
+ // clean up map
+ Collection<Map<String, ICommandResult>> values = fScenarioMap.values();
+ for (Iterator<Map<String, ICommandResult>> iterator = values.iterator(); iterator.hasNext();) {
+ Map<String, ICommandResult> map = (Map<String, ICommandResult>) iterator.next();
+ map.clear();
+ }
+ fScenarioMap.clear();
+
+ // load from file
+
+ // Open the file
+ FileInputStream fstream = new FileInputStream(fScenariofile);
+
+ // Get the object of DataInputStream
+ DataInputStream in = new DataInputStream(fstream);
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String strLine;
+
+ // Read File Line by Line
+
+ // Temporary map for generating instance numbers for lttng list <session> commands.
+ // The numbers are per scenario.
+ Map<String, Integer> tmpSessionNameMap = new HashMap<String, Integer>();
+ while ((strLine = br.readLine()) != null) {
+
+ // Ignore comments
+ if(isComment(strLine)) {
+ continue;
+ }
+
+ if (SCENARIO_KEY.equals(strLine)) {
+ // scenario start
+
+ // Ignore comments
+ strLine = br.readLine();
+ while (isComment(strLine)) {
+ strLine = br.readLine();
+ }
+
+ String scenario = strLine;
+ Map<String, ICommandResult> commandMap = new HashMap<String, ICommandResult>();
+ fScenarioMap.put(scenario, commandMap);
+ List<String> output = null;
+ String input = null;
+ boolean inOutput = false;
+ int result = 0;
+ tmpSessionNameMap.clear();
+ while ((strLine = br.readLine()) != null) {
+ // Ignore comments
+ if(isComment(strLine)) {
+ continue;
+ }
+
+ if (SCENARIO_END_KEY.equals(strLine)) {
+ // Scenario is finished
+ break;
+ }
+ if (INPUT_KEY.equals(strLine)) {
+ strLine = br.readLine();
+ // Ignore comments
+ while (isComment(strLine)) {
+ strLine = br.readLine();
+ }
+ // Read command
+ input = strLine;
+
+ // Handle instances of 'lttng list <session"-comamand
+ Matcher matcher = LTTNG_LIST_SESSION_PATTERN.matcher(strLine);
+ if (matcher.matches() && !input.matches(LTTNG_LIST_PROVIDER_PATTERN)) {
+ String sessionName = matcher.group(1).trim();
+ Integer i = tmpSessionNameMap.get(sessionName);
+ if (i != null) {
+ i++;
+ } else {
+ i = 0;
+ }
+ tmpSessionNameMap.put(sessionName, i);
+ input += String.valueOf(i);
+ }
+ } else if (INPUT_END_KEY.equals(strLine)) {
+ // Initialize output array
+ output = new ArrayList<String>();
+ } else if (RESULT_KEY.equals(strLine)) {
+ strLine = br.readLine();
+ // Ignore comments
+ while (isComment(strLine)) {
+ strLine = br.readLine();
+ }
+ // Save result value
+ result = Integer.parseInt(strLine);
+ } else if (OUTPUT_END_KEY.equals(strLine)) {
+ // Save output/result in command map
+ commandMap.put(input, new CommandResult(result, output.toArray(new String[output.size()])));
+ inOutput = false;
+ } else if (OUTPUT_KEY.equals(strLine)) {
+ // first line of output
+ inOutput = true;
+ strLine = br.readLine();
+
+ // Ignore comments
+ while (isComment(strLine)) {
+ strLine = br.readLine();
+ }
+ output.add(strLine);
+ } else if (inOutput) {
+ // subsequent lines of output
+ output.add(strLine);
+ }
+// else {
+// if (RESULT_END_KEY.equals(strLine)) {
+ // nothing to do
+// }
+ }
+ }
+ }
+ //Close the input stream
+ in.close();
+ }
+
+ // Set the scenario to consider in executeCommand()
+ public synchronized void setScenario(String scenario) {
+ fScenario = scenario;
+ fSessionNameMap.clear();
+ if (!fScenarioMap.containsKey(fScenario)) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.stubs.service.shells.TestCommandShell#executeCommand(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean)
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
+ Map<String, ICommandResult> commands = fScenarioMap.get(fScenario);
+
+ Matcher matcher = LTTNG_LIST_SESSION_PATTERN.matcher(command);
+ if (matcher.matches() && !command.matches(LTTNG_LIST_PROVIDER_PATTERN)) {
+ String sessionName = matcher.group(1).trim();
+ Integer i = fSessionNameMap.get(sessionName);
+ if (i != null) {
+ i++;
+ } else {
+ i = 0;
+ }
+ fSessionNameMap.put(sessionName, i);
+ command += String.valueOf(i);
+ }
+
+ if (commands.containsKey(command)) {
+ return commands.get(command);
+ }
+
+ String[] output = new String[1];
+ output[0] = String.valueOf("Command not found");
+ return new CommandResult(1, output);
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ private boolean isComment(String line) {
+ return line.matches(COMMENT_KEY);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.stubs.shells;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.CommandResult;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandResult;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandShell;
+
+public class TestCommandShell implements ICommandShell {
+
+ protected boolean fIsConnected = false;
+
+ @Override
+ public void connect() throws ExecutionException {
+ fIsConnected = true;
+ }
+
+ @Override
+ public void disconnect() {
+ fIsConnected = false;
+ }
+
+ @Override
+ public ICommandResult executeCommand(String command, IProgressMonitor monitor) throws ExecutionException {
+ return executeCommand(command, monitor, true);
+ }
+
+ @Override
+ public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
+ if (fIsConnected) {
+
+ }
+ return new CommandResult(0, new String[0]);
+ }
+}
--- /dev/null
+####################################################################
+# 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:
+# Bernd Hufmann - Initial API and implementation
+####################################################################
+####################################################################
+# Scenario: Test no sessions available
+####################################################################
+<SCENARIO>
+Initialize
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Currently no available tracing session
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list -k
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel events
+-------------
+ sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list -u
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST events:
+-------------
+
+PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
+
+PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Enable events from kernel provider events
+####################################################################
+<SCENARIO>
+Scenario1
+<COMMAND_INPUT>
+lttng create mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession created.
+Traces will be written in /home/user/lttng-traces/mysession-20120314-132824
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+ Trace path: /home/user/lttng-traces/mysession-20120314-132824
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event sched_kthread_stop,sched_kthread_stop_ret -k -s mysession --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event sched_kthread_stop created in channel channel0
+kernel sched_kthread_stop_ret created in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+ Trace path: /home/user/lttng-traces/mysession-20120314-132824
+
+=== Domain: Kernel ===
+
+Channels:
+-------------
+- channel0: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 262144
+ number of subbufers: 4
+ switch timer interval: 0
+ read timer interval: 200
+ output: splice()
+
+ Events:
+ sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
+ sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng disable-event sched_kthread_stop_ret,sched_kthread_stop -k -s mysession -c channel0
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event sched_kthread_stop_ret disabled in channel channel0
+kernel event sched_kthread_stop disabled in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event sched_kthread_stop -k -s mysession -c channel0 --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event sched_kthread_stop enabled in channel channel0
+</COMMAND_OUTPUT>
+
+
+<COMMAND_INPUT>
+lttng destroy mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession destroyed.
+</COMMAND_OUTPUT>
+
+</SCENARIO>
+
+####################################################################
+# Scenario: Enable events from UST provider events
+####################################################################
+<SCENARIO>
+Scenario2
+<COMMAND_INPUT>
+lttng create mysession -o /home/user/temp
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession created.
+Traces will be written in /home/user/temp
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+ Trace path: /home/user/temp
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-channel mychannel -u -s mysession --subbuf-size 16384 --num-subbuf 2 --switch-timer 200 --read-timer 100
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST channel mychannel enabled for session mysession
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+ Trace path: /home/user/temp
+
+=== Domain: UST global ===
+
+Channels:
+-------------
+- mychannel: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 16384
+ number of subbufers: 2
+ switch timer interval: 200
+ read timer interval: 100
+ output: mmap()
+
+ Events:
+ None
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event ust_tests_hello:tptest_sighandler,ust_tests_hello:tptest -u -s mysession --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event ust_tests_hello:tptest_sighandler in channel channel0
+UST sched_ust_tests_hello:tptest created in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+ Trace path: /home/user/temp
+
+=== Domain: UST global ===
+
+Channels:
+-------------
+- mychannel: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 16384
+ number of subbufers: 2
+ switch timer interval: 200
+ read timer interval: 100
+ output: mmap()
+
+ Events:
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [enabled]
+ ust_tests_hello:tptest (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [enabled]
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng disable-event ust_tests_hello:tptest -u -s mysession -c mychannel
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event ust_tests_hello:tptest in channel mychannel
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event ust_tests_hello:tptest -u -s mysession -c mychannel --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event ust_tests_hello:tptest enabled in channel mychannel
+</COMMAND_OUTPUT>
+
+
+<COMMAND_INPUT>
+lttng destroy mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession destroyed.
+</COMMAND_OUTPUT>
+
+</SCENARIO>
+
--- /dev/null
+####################################################################
+# 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:
+# Bernd Hufmann - Initial API and implementation
+####################################################################
+####################################################################
+# Scenario: Test lttng not installed
+####################################################################
+<SCENARIO>
+LttngNotInstalled
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+1
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Command not found
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test no sessions available
+####################################################################
+<SCENARIO>
+NoSessionAvailable
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Currently no available tracing session
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test get sessions
+####################################################################
+<SCENARIO>
+GetSessionNames1
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Available tracing sessions:
+ 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive]
+ 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive]
+
+ Use lttng list <session_name> for more details
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test lttng list <name> where session doesn't exist
+####################################################################
+<SCENARIO>
+GetSessionNameNotExist
+<COMMAND_INPUT>
+lttng list test
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+1
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session test not found
+Error: Session name not found
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test lttng list with garbage output
+####################################################################
+<SCENARIO>
+GetSessionGarbageOut
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+asdfaereafsdcv 12333456434&*89**(())(^%$*
+@#$%^&*()@#$%^&*()0834523094578kj;djkfs
+a;sdf094v5u dsafj;sd9
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test lttng list <name> with sample outputs
+####################################################################
+<SCENARIO>
+GetSession1
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [active]
+ Trace path: /home/user/lttng-traces/mysession-20120129-084256
+
+=== Domain: Kernel ===
+
+Channels:
+-------------
+- channel0: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 262144
+ number of subbufers: 4
+ switch timer interval: 0
+ read timer interval: 200
+ output: splice()
+
+ Events:
+ block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
+ block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [disabled]
+
+- channel1: [disabled]
+
+ Attributes:
+ overwrite mode: 1
+ subbufers size: 524288
+ number of subbufers: 4
+ switch timer interval: 100
+ read timer interval: 400
+ output: splice()
+
+ Events:
+ None
+
+=== Domain: UST global ===
+
+Channels:
+-------------
+- mychannel1: [disabled]
+
+ Attributes:
+ overwrite mode: 1
+ subbufers size: 8192
+ number of subbufers: 8
+ switch timer interval: 200
+ read timer interval: 100
+ output: mmap()
+
+ Events:
+ None
+
+- channel0: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 4096
+ number of subbufers: 4
+ switch timer interval: 0
+ read timer interval: 200
+ output: mmap()
+
+ Events:
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled]
+ * (type: tracepoint) [enabled]
+
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng list mysession1
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession1: [inactive]
+ Trace path: /home/user/lttng-traces/mysession1-20120203-133225
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+
+####################################################################
+# Scenario: Test "lttng list -k" with sample output
+####################################################################
+<SCENARIO>
+GetKernelProvider1
+<COMMAND_INPUT>
+lttng list -k
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel events
+-------------
+ sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng list -u" with sample output
+####################################################################
+<SCENARIO>
+GetUstProvider1
+<COMMAND_INPUT>
+lttng list -u
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST events:
+-------------
+
+PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
+
+PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng list -u" with no UST provider available
+####################################################################
+<SCENARIO>
+GetUstProvider2
+<COMMAND_INPUT>
+lttng list -u
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST events:
+-------------
+None
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng create <session>
+####################################################################
+<SCENARIO>
+CreateSession1
+<COMMAND_INPUT>
+lttng create mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession2 created.
+Traces will be written in /home/user/lttng-traces/mysession2-20120209-095418
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng create <session> with different variants
+# and errors
+####################################################################
+<SCENARIO>
+CreateSessionVariants
+<COMMAND_INPUT>
+lttng create alreadyExist
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+1
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Error: Session name already exist
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng create "session with spaces"
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session session with spaces created.
+Traces will be written in /home/user/lttng-traces/session with spaces-20120209-095418
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng create wrongName
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session auto created.
+Traces will be written in /home/user/lttng-traces/auto-20120209-095418
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng create wrongPath -o /home/user/hallo
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session wrongPath created.
+Traces will be written in /home/user/lttng-traces/wrongPath-20120209-095418
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng create pathWithSpaces -o "/home/user/hallo user/here"
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session pathWithSpaces created.
+Traces will be written in /home/user/hallo user/here/pathWithSpaces-20120209-095418
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng destroy <session>
+####################################################################
+
+<SCENARIO>
+DestroySession1
+<COMMAND_INPUT>
+lttng destroy mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession2 destroyed.
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng enable-channel ..." with different inputs
+####################################################################
+
+<SCENARIO>
+ChannelHandling
+<COMMAND_INPUT>
+lttng enable-channel mychannel0,mychannel1 -k -s mysession2 --overwrite --subbuf-size 16384 --num-subbuf 2 --switch-timer 200 --read-timer 100
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel channel mychannel0 enabled for session mysession2
+Kernel channel mychannel1 enabled for session mysession2
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-channel ustChannel -u -s mysession2 --overwrite --subbuf-size 32768 --num-subbuf 1 --switch-timer 100 --read-timer 200
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST channel channel0 enabled for session mysession2
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-channel mychannel0,mychannel1 -k -s mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel channel mychannel0 enabled for session mysession2
+Kernel channel mychannel1 enabled for session mysession2
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-channel ustChannel -u -s mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST channel mychannel0 enabled for session mysession2
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng disable-channel mychannel0,mychannel1 -k -s mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel channel mychannel0 disabled for session mysession2
+Kernel channel mychannel1 disabled for session mysession2
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng disable-channel ustChannel -u -s mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST channel mychannel0 enabled for session mysession2
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+
+####################################################################
+# Scenario: Test "lttng enable-events ..." with different inputs
+####################################################################
+<SCENARIO>
+EventHandling
+
+# Tracepoint test cases
+
+<COMMAND_INPUT>
+lttng enable-event block_rq_remap,block_bio_remap,softirq_entry -k -s mysession2 --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event block_rq_remap created in channel channel0
+kernel event block_bio_remap created in channel channel0
+kernel event softirq_entry created in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event -a -k -s mysession2 -c mychannel --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+All kernel tracepoints are enabled in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event ust_tests_hello:tptest_sighandler -u -s mysession2 -c mychannel --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event ust_tests_hello:tptest_sighandler created in channel mychannel
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event -a -u -s mysession2 -c mychannel --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+All UST tracepoints are enabled in channel mychannel
+</COMMAND_OUTPUT>
+
+# Syscall test cases
+
+<COMMAND_INPUT>
+lttng enable-event -a -k -s mysession2 --syscall
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+All kernel system calls are enabled in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event -a -k -s mysession2 -c mychannel --syscall
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+All kernel system calls are enabled in channel mychannel
+</COMMAND_OUTPUT>
+
+# dynamic probe/function probe test cases
+
+<COMMAND_INPUT>
+lttng enable-event myevent0 -k -s mysession2 --function 0xc0101340
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event myevent0 created in channel mychannel
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event myevent1 -k -s mysession2 -c mychannel --probe init_post
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event myevent1 created in channel mychannel
+</COMMAND_OUTPUT>
+
+# log level test cases
+
+<COMMAND_INPUT>
+lttng enable-event myevent4 -u -s mysession2 --loglevel-only TRACE_DEBUG
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event myevent4 created in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event myevent5 -u -s mysession2 -c mychannel --loglevel TRACE_DEBUG_FUNCTION
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event myevent5 created in channel mychannel
+</COMMAND_OUTPUT>
+
+</SCENARIO>
+
+
--- /dev/null
+####################################################################
+# 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:
+# Bernd Hufmann - Initial API and implementation
+####################################################################
+####################################################################
+# Scenario: Test lttng list <name> with sample outputs
+####################################################################
+<SCENARIO>
+ListInfoTest
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Available tracing sessions:
+ 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive]
+ 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive]
+
+ Use lttng list <session_name> for more details
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [active]
+ Trace path: /home/user/lttng-traces/mysession-20120129-084256
+
+=== Domain: Kernel ===
+
+Channels:
+-------------
+- channel0: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 262144
+ number of subbufers: 4
+ switch timer interval: 0
+ read timer interval: 200
+ output: splice()
+
+ Events:
+ block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
+ block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [disabled]
+ myevent2 (type: probe) [enabled]
+ addr: 0xc0101340
+ myevent0 (type: probe) [enabled]
+ offset: 0x0
+ symbol: init_post
+ syscalls (type: syscall) [enabled]
+
+- channel1: [disabled]
+
+ Attributes:
+ overwrite mode: 1
+ subbufers size: 524288
+ number of subbufers: 4
+ switch timer interval: 100
+ read timer interval: 400
+ output: splice()
+
+ Events:
+ None
+
+=== Domain: UST global ===
+
+Channels:
+-------------
+- mychannel1: [disabled]
+
+ Attributes:
+ overwrite mode: 1
+ subbufers size: 8192
+ number of subbufers: 8
+ switch timer interval: 200
+ read timer interval: 100
+ output: mmap()
+
+ Events:
+ None
+
+- channel0: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 4096
+ number of subbufers: 4
+ switch timer interval: 0
+ read timer interval: 200
+ output: mmap()
+
+ Events:
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled]
+ * (type: tracepoint) [enabled]
+
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng list mysession1
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession1: [inactive]
+ Trace path: /home/user/lttng-traces/mysession1-20120203-133225
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list -k
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel events
+-------------
+ sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list -u
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST events:
+-------------
+
+PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
+
+PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+
+</SCENARIO>
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
org.eclipse.ui.ide;bundle-version="3.7.0",
+ org.eclipse.core.resources;bundle-version="3.7.100",
+ org.eclipse.core.filesystem;bundle-version="1.3.100",
org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.linuxtools.lttng2.core;bundle-version="0.1.0",
- org.eclipse.linuxtools.tmf.ui;bundle-version="0.5.0"
+ org.eclipse.linuxtools.tmf.ui;bundle-version="0.5.0",
+ org.eclipse.rse.core;bundle-version="3.2.0",
+ org.eclipse.rse.services;bundle-version="3.2.100",
+ org.eclipse.rse.subsystems.files.core;bundle-version="3.2.100",
+ org.eclipse.rse.ui;bundle-version="3.2.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
-Export-Package: org.eclipse.linuxtools.internal.lttng2.ui;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests"
+Export-Package: org.eclipse.linuxtools.internal.lttng2.ui;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests",
+ org.eclipse.linuxtools.internal.lttng2.ui.views.control;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests",
+ org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests",
+ org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests",
+ org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests",
+ org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests",
+ org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests",
+ org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests",
+ org.eclipse.linuxtools.internal.lttng2.ui.views.control.service;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests"
action.import.label = Import To Project
action.import.tooltip = Import selected trace to a project
+
+# LTTng 2.0 trace control commands
+trace.control.rse.system.type.name=LTTng (v2.0 or later)
+trace.control.rse.system.type.description=LTTng Trace Control (v2.0 or later)
+
+commands.control.category=LTTng Trace Control Commands
+commands.control.category.description=LTTng Trace Control Commands
+
+commands.control.new=New Connection
+commands.control.new.description=New Connection to Target Node
+
+commands.control.connect=Connect
+commands.control.connect.description=Connect to Target Node
+
+commands.control.disconnect=Disconnect
+commands.control.discconnect.description=Disconnect to Target Node
+
+commands.control.refresh=Refresh
+commands.control.refresh.description=Refresh Node Configuration
+
+
+commands.control.delete=Delete
+commands.control.deleete.description=Delete Target Node
+
+commands.control.create.session=Create Session
+commands.control.create.session.description=Create a Trace Session
+
+commands.control.destroy.session=Destroy Session
+commands.control.destroy.session.description=Destroy a Trace Session
+
+commands.control.create.channel=Create Channel
+commands.control.create.channel.description=Create a Trace Channel
+
+commands.control.enable.channel=Enable Channel
+commands.control.enable.channel.description=Enable a Trace Channel
+
+commands.control.disable.channel=Disable Channel
+commands.control.disable.channel.description=Disable a Trace Channel
+
+commands.control.start=Start
+commands.control.start.description=Start Trace Session
+
+commands.control.stop=Stop
+commands.control.stop.description=Stop Trace Session
+
+#commands.control.enable.event=Enable
+commands.control.enable.assign.description=Assign Event to Session and Channel and Enable Event
+
+commands.control.enable.event=Enable Event
+commands.control.enable.event.description=Enable Event
+
+commands.control.enable.eventOnDomain=Enable Event (default channel)
+commands.control.enable.eventOnDomain.description=Enable Event on Default Channel
+
+commands.control.disable.event=Disable Event
+commands.control.disable.event.description=Disable Event
<perspective
class="org.eclipse.linuxtools.internal.lttng2.ui.views.PerspectiveFactory"
icon="icons/obj16/garland16.png"
- id="org.eclipse.linuxtools.lttng.ui.perspective"
+ id="org.eclipse.linuxtools.lttng2.ui.perspective"
name="%perspective.category.name">
</perspective>
</extension>
+ <extension
+ id="org.eclipse.linuxtools.lttng2.ui.views"
+ point="org.eclipse.ui.views">
+ <category
+ id="org.eclipse.linuxtools.lttng2.ui.views.category"
+ name="%views.category.name">
+ </category>
+ <view
+ allowMultiple="false"
+ category="org.eclipse.linuxtools.lttng2.ui.views.category"
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView"
+ icon="icons/eview16/control_view.gif"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.views.control"
+ name="%control.view.name"
+ restorable="true">
+ </view>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ description="%commands.control.category.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ name="%commands.control.category">
+ </category>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.new.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.newConnection"
+ name="%commands.control.new">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.connect.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.connect"
+ name="%commands.control.connect">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.disconnect.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disconnect"
+ name="%commands.control.disconnect">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.refresh.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.refresh"
+ name="%commands.control.refresh">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.delete.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.delete"
+ name="%commands.control.delete">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.create.session.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createSession"
+ name="%commands.control.create.session">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.destroy.session.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.destroySession"
+ name="%commands.control.destroy.session">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.create.channel.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnSession"
+ name="%commands.control.create.channel">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.create.channel.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnDomain"
+ name="%commands.control.create.channel">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.enable.channel.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannel"
+ name="%commands.control.enable.channel">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.disable.channel.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disableChannel"
+ name="%commands.control.disable.channel">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.start.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.start"
+ name="%commands.control.start">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.stop.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.stop"
+ name="%commands.control.stop">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.enable.assign.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.assign.event"
+ name="%commands.control.enable.event">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.enable.event.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.event"
+ name="%commands.control.enable.event">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.disable.event.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disable.event"
+ name="%commands.control.disable.event">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.enable.event.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.eventOnChannel"
+ name="%commands.control.enable.event">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.enable.eventOnDomain.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.eventOnDomain"
+ name="%commands.control.enable.eventOnDomain">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.enable.eventOnDomain.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.eventOnSession"
+ name="%commands.control.enable.eventOnDomain">
+ </command>
+
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="toolbar:org.eclipse.linuxtools.internal.lttng2.ui.views.control">
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.newConnection"
+ icon="icons/elcl16/target_add.gif"
+ label="%commands.control.new"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.connect"
+ icon="icons/elcl16/connect.gif"
+ label="%commands.control.connect"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disconnect"
+ icon="icons/elcl16/disconnect.gif"
+ label="%commands.control.disconnect"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.refresh"
+ icon="icons/elcl16/refresh.gif"
+ label="%commands.control.refresh"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.delete"
+ icon="icons/elcl16/target_delete.gif"
+ label="%commands.control.delete"
+ style="push">
+ </command>
+ <separator
+ name="org.eclipse.linuxtools.internal.lttng2.ui.views.control.toolbar.separator1"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.start"
+ icon="icons/elcl16/start_trace.gif"
+ label="%commands.control.start"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.stop"
+ icon="icons/elcl16/pause_trace.gif"
+ label="%commands.control.stop"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.destroySession"
+ icon="icons/elcl16/delete_trace.gif"
+ label="%commands.control.destroy.session"
+ style="push">
+ </command>
+
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.linuxtools.internal.lttng2.ui.views.control">
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.connect"
+ icon="icons/elcl16/connect.gif"
+ label="%commands.control.connect"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disconnect"
+ icon="icons/elcl16/disconnect.gif"
+ label="%commands.control.disconnect"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.refresh"
+ icon="icons/elcl16/refresh.gif"
+ label="%commands.control.refresh"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.delete"
+ icon="icons/elcl16/target_delete.gif"
+ label="%commands.control.delete"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createSession"
+ icon="icons/elcl16/add_button.gif"
+ label="%commands.control.create.session"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.start"
+ icon="icons/elcl16/start_trace.gif"
+ label="%commands.control.start"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.stop"
+ icon="icons/elcl16/pause_trace.gif"
+ label="%commands.control.stop"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.destroySession"
+ icon="icons/elcl16/delete_trace.gif"
+ label="%commands.control.destroy.session"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <separator
+ name="org.eclipse.linuxtools.internal.lttng2.ui.views.control.popup.separator1"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnSession"
+ icon="icons/elcl16/add_button.gif"
+ label="%commands.control.create.channel"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ <not>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent">
+ </instanceof>
+ </iterate>
+ </not>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.eventOnSession"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.enable.eventOnDomain"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnDomain"
+ icon="icons/elcl16/add_button.gif"
+ label="%commands.control.create.channel"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent">
+ </instanceof>
+ </iterate>
+ <not>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </not>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.eventOnDomain"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.enable.eventOnDomain"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent">
+ </instanceof>
+ </iterate>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannel"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.enable.channel"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disableChannel"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.disable.channel"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.assign.event"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.enable.event"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.event"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.enable.event"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disable.event"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.disable.event"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.eventOnChannel"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.enable.event"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+
+
+
+ </menuContribution>
+
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.NewConnectionHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.newConnection">
+ <activeWhen>
+ <with
+ variable="activePart">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView">
+ </instanceof>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.ConnectHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.connect">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.DisconnectHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disconnect">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.RefreshHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.refresh">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.DeleteHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.delete">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CreateSessionHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createSession">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.DestroySessionHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.destroySession">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CreateChannelOnSessionHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnSession">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CreateChannelOnDomainHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnDomain">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.EnableChannelHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannel">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.DisableChannelHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disableChannel">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.StartHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.start">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.StopHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.stop">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.AssignEventHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.assign.event">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.EnableEventHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.event">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.DisableEventHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disable.event">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.EnableEventOnChannelHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.eventOnChannel">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.EnableEventOnDomainHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.eventOnDomain">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.EnableEventOnSessionHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enable.eventOnSession">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ </extension>
+
+ <extension
+ point="org.eclipse.rse.core.systemTypes">
+ <systemType
+ description="%trace.control.rse.system.type.description"
+ icon="icons/obj16/systemlttng2.gif"
+ iconLive="icons/obj16/systemlttng2-live.gif"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.control.systemType"
+ label="%trace.control.rse.system.type.name"
+ name="org.eclipse.linuxtools.internal.lttng2.ui.control.systemType"
+ subsystemConfigurationIds="ssh.shells;ssh.files;ssh.terminals;processes.shell.linux">
+ </systemType>
+ </extension>
+
+
</plugin>
package org.eclipse.linuxtools.internal.lttng2.ui;
+import java.net.URL;
+
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
}
return icon;
}
+
+ /**
+ * Loads the image in the plug-ins image registry (if necessary) and returns the image
+ * @param url - URL relative to the Bundle
+ * @return the image
+ */
+ public Image loadIcon(String url) {
+ String key = plugin.getBundle().getSymbolicName() + "/" + url; //$NON-NLS-1$
+ Image icon = plugin.getImageRegistry().get(key);
+ if (icon == null) {
+ URL imageURL = plugin.getBundle().getResource(url);
+ ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
+ icon = descriptor.createImage();
+ plugin.getImageRegistry().put(key, icon);
+ }
+ return icon;
+ }
}
package org.eclipse.linuxtools.internal.lttng2.ui.views;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
import org.eclipse.linuxtools.tmf.ui.views.events.TmfEventsView;
import org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramView;
import org.eclipse.ui.IFolderLayout;
// LTTng views
private static final String EVENTS_VIEW_ID = TmfEventsView.ID;
private static final String HISTOGRAM_VIEW_ID = HistogramView.ID;
+ private static final String CONTROL_VIEW_ID = ControlView.ID;
// Standard Eclipse views
private static final String PROJECT_VIEW_ID = IPageLayout.ID_PROJECT_EXPLORER;
IFolderLayout topLeftFolder = layout.createFolder(
"topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
topLeftFolder.addView(PROJECT_VIEW_ID);
+ topLeftFolder.addView(CONTROL_VIEW_ID);
// // Create the top right folder
// IFolderLayout topRightFolder = layout.createFolder(
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 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:
+ * Francois Chouinard - Initial API and implementation
+ * Bernd Hufmann - Filled with content
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control;
+
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.ISelection;
+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.TraceControlRoot;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * <b><u>ControlView</u></b>
+ * <p>
+ * View implementation for Trace Control.
+ * </p>
+ */
+public class ControlView extends ViewPart implements ITraceControlComponentChangedListener {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * View ID.
+ */
+ public static final String ID = "org.eclipse.linuxtools.internal.lttng2.ui.views.control"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The tree viewer.
+ */
+ private TreeViewer fTreeViewer = null;
+
+ /**
+ * The trace control root node. This provides access to the whole model.
+ */
+ private ITraceControlComponent fRoot = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return returns the trace control tree node (model).
+ */
+ public ITraceControlComponent getTraceControlRoot() {
+ return fRoot;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ // Create tree viewer
+ fTreeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ ColumnViewerToolTipSupport.enableFor(fTreeViewer);
+
+ fTreeViewer.setContentProvider(new TraceControlContentProvider());
+ fTreeViewer.setLabelProvider(new TraceControlLabelProvider());
+
+ // Create model root
+ fRoot = new TraceControlRoot();
+ fRoot.addComponentListener(this);
+ fTreeViewer.setInput(fRoot);
+
+ // Create context menu for the tree viewer
+ createContextMenu();
+
+ getSite().setSelectionProvider(fTreeViewer);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ fTreeViewer.getControl().setFocus();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponentChangedListener#componentAdded(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent)
+ */
+ @Override
+ public void componentAdded(ITraceControlComponent parent, ITraceControlComponent component) {
+ componentChanged(component);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponentChangedListener#componentRemoved(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent)
+ */
+ @Override
+ public void componentRemoved(ITraceControlComponent parent, ITraceControlComponent component) {
+ componentChanged(component);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @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) {
+ if (fTreeViewer.getTree().isDisposed()) {
+ return;
+ }
+
+ fTreeViewer.getTree().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (fTreeViewer.getTree().isDisposed()) {
+ return;
+ }
+ fTreeViewer.refresh();
+ // Change selection needed
+ final ISelection sel = fTreeViewer.getSelection();
+ fTreeViewer.setSelection(null);
+ fTreeViewer.setSelection(sel);
+ }
+ });
+ }
+
+ /**
+ * Sets the selected component in the tree
+ * @param component - component to select
+ */
+ public void setSelection(ITraceControlComponent component) {
+ StructuredSelection selection = new StructuredSelection(component);
+ fTreeViewer.setSelection(selection);
+ }
+
+ /**
+ * Sets the selected components in the tree
+ * @param component - array of components to select
+ */
+ public void setSelection(ITraceControlComponent[] components) {
+ StructuredSelection selection = new StructuredSelection(components);
+ fTreeViewer.setSelection(selection);
+ }
+
+// public ITraceControlComponent getSelection() {
+// ISelection selection = fTreeViewer.getSelection();
+//
+// }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ private void createContextMenu() {
+ // First we create a menu Manager
+ final MenuManager menuManager = new MenuManager();
+ final Menu menu = menuManager.createContextMenu(fTreeViewer.getTree());
+ // Set the MenuManager
+ fTreeViewer.getTree().setMenu(menu);
+ getSite().registerContextMenu(menuManager, fTreeViewer);
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Bernd Hufmann - Initial API and implementation
+ *
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * <b><u>Messages</u></b>
+ * <p>
+ * Messages file for the trace control package.
+ * </p>
+ */
+final public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages"; //$NON-NLS-1$
+
+ // Failures
+ public static String TraceControl_ConnectionFailure;
+ public static String TraceControl_DisconnectionFailure;
+ public static String TraceControl_ExecutionCancelled;
+ public static String TraceControl_ExecutionFailure;
+ public static String TraceControl_ExecutionTimeout;
+ public static String TraceControl_ShellNotConnected;
+
+ public static String TraceControl_CommandShellError;
+ public static String TraceControl_CommandError;
+ public static String TraceControl_UnexpectedCommnadOutputFormat;
+ public static String TraceControl_UnexpectedNameError;
+ public static String TraceControl_UnexpectedPathError;
+
+ // Commands
+ public static String TraceControl_RetrieveNodeConfigurationJob;
+ public static String TraceControl_ListSessionFailure;
+ public static String TraceControl_EclipseCommandFailure;
+ public static String TraceControl_NewNodeCreationFailure;
+ public static String TraceControl_CreateSessionJob;
+
+ public static String TraceControl_DestroySessionJob;
+ public static String TraceControl_DestroyConfirmationTitle;
+ public static String TraceControl_DestroyConfirmationMessage;
+
+ public static String TraceControl_StartSessionJob;
+ public static String TraceControl_StopSessionJob;
+
+ public static String TraceControl_ChangeChannelStateJob;
+ public static String TraceControl_ChangeEventStateJob;
+
+ public static String TraceControl_EnableEventsJob;
+ public static String TraceControl_EnableEventsFailure;
+ public static String TraceControl_DisableEventsJob;
+
+ // Dialogs
+ public static String TraceControl_NewDialogTitle;
+ public static String TraceControl_NewNodeExistingConnectionGroupName;
+ public static String TraceControl_NewNodeEditButtonName;
+ public static String TraceControl_NewNodeComboToolTip;
+ public static String TraceControl_NewNodeConnectionNameLabel;
+ public static String TraceControl_NewNodeConnectionNameTooltip;
+ public static String TraceControl_NewNodeHostNameLabel;
+ public static String TraceControl_NewNodeHostNameTooltip;
+ public static String TraceControl_AlreadyExistsError;
+
+ public static String TraceControl_CreateSessionDialogTitle;
+ public static String TraceControl_CreateSessionNameLabel;
+ public static String TraceControl_CreateSessionNameTooltip;
+ public static String TraceControl_CreateSessionPathLabel;
+ public static String TraceControl_CreateSessionPathTooltip;
+ public static String TraceControl_InvalidSessionNameError;
+ public static String TraceControl_SessionAlreadyExistsError;
+ public static String TraceControl_SessionPathAlreadyExistsError;
+ public static String TraceControl_InvalidSessionPathError;
+ public static String TraceControl_FileSubSystemError;
+
+ public static String TraceControl_EnableChannelDialogTitle;
+ public static String TraceControl_EnableChannelNameLabel;
+ public static String TraceControl_EnableChannelNameTooltip;
+ public static String TraceControl_EnableChannelSubBufferSizeTooltip;
+ public static String TraceControl_EnableChannelNbSubBuffersTooltip;
+ public static String TraceControl_EnableChannelSwitchTimerTooltip;
+ public static String TraceControl_EnableChannelReadTimerTooltip;
+ public static String TraceControl_EnableChannelOutputTypeTooltip;
+ public static String TraceControl_EnableChannelOverwriteModeTooltip;
+
+ public static String TraceControl_InvalidChannelNameError;
+ public static String TraceControl_ChannelAlreadyExistsError;
+
+ public static String TraceControl_EnableEventsDialogTitle;
+ public static String TraceControl_EnableEventsSessionGroupName;
+ public static String TraceControl_EnableEventsChannelGroupName;
+ public static String TraceControl_EnableEventsSessionsTooltip;
+ public static String TraceControl_EnableEventsChannelsTooltip;
+ public static String TraceControl_EnableEventsNoSessionError;
+ public static String TraceControl_EnableEventsNoChannelError;
+
+ public static String TraceControl_EnableGroupSelectionName;
+ public static String TraceControl_EnableEventsTracepointGroupName;
+ public static String TraceControl_EnableEventsTracepointTreeTooltip;
+ public static String TraceControl_EnableEventsTracepointTreeAllLabel;
+ public static String TraceControl_EnableEventsSyscallName;
+ public static String TraceControl_EnableEventsSyscallTooltip;
+ public static String TraceControl_EnableEventsProbeGroupName;
+ public static String TraceControl_EnableEventsEventNameLabel;
+ public static String TraceControl_EnableEventsProbeEventNameTooltip;
+ public static String TraceControl_EnableEventsProbeNameLabel;
+ public static String TraceControl_EnableEventsProbeNameTooltip;
+ public static String TraceControl_EnableEventsFucntionGroupName;
+ public static String TraceControl_EnableEventsFunctionEventNameTooltip;
+ public static String TraceControl_EnableEventsFunctionNameLabel;
+
+ public static String TraceControl_EnableEventsWildcardGroupName;
+ public static String TraceControl_EnableEventsWildcardLabel;
+ public static String TraceControl_EnableEventsWildcardTooltip;
+ public static String TraceControl_EnableEventsLogLevelGroupName;
+ public static String TraceControl_EnableEventsLogLevelTypeName;
+ public static String TraceControl_EnableEventsLogLevelTypeTooltip;
+ public static String TraceControl_EnableEventsLogLevelOnlyTypeName;
+ public static String TraceControl_EnableEventsLogLevelOnlyTypeTooltip;
+ public static String TraceControl_EnableEventsLogLevelTooltip;
+ public static String TraceControl_EnableEventsLoglevelEventNameTooltip;
+
+ public static String TraceControl_InvalidProbeNameError;
+ public static String TraceControl_InvalidWildcardError;
+ public static String TraceControl_InvalidLogLevelEventNameError;
+
+
+ // Tree structure strings
+ public static String TraceControl_KernelDomainDisplayName;
+ public static String TraceControl_UstDisplayName;
+ public static String TraceControl_UstGlobalDomainDisplayName;
+ public static String TraceControl_AllSessionsDisplayName;
+ public static String TraceControl_SessionDisplayName;
+ public static String TraceControl_DomainDisplayName;
+ public static String TraceControl_ChannelDisplayName;
+ public static String TraceControl_EventDisplayName;
+ public static String TraceControl_ProviderDisplayName;
+ public static String TraceControl_KernelProviderDisplayName;
+
+ // Property names
+ public static String TraceControl_SessionNamePropertyName;
+ public static String TraceControl_EventNamePropertyName;
+ public static String TraceControl_EventTypePropertyName;
+ public static String TraceControl_LogLevelPropertyName;
+ public static String TraceControl_StatePropertyName;
+ public static String TraceControl_DomainNamePropertyName;
+ public static String TraceControl_ChannelNamePropertyName;
+ public static String TraceControl_OverwriteModePropertyName;
+ public static String TraceControl_SubBufferSizePropertyName;
+ public static String TraceControl_NbSubBuffersPropertyName;
+ public static String TraceControl_SwitchTimerPropertyName;
+ public static String TraceControl_ReadTimerPropertyName;
+ public static String TraceControl_OutputTypePropertyName;
+ public static String TraceControl_HostNamePropertyName;
+ public static String TraceControl_HostAddressPropertyName;
+ public static String TraceControl_SessionPathPropertyName;
+ public static String TraceControl_ProviderNamePropertyName;
+ public static String TraceControl_ProcessIdPropertyName;
+ public static String TraceControl_ProbeAddressPropertyName;
+ public static String TraceControl_ProbeOffsetPropertyName;
+ public static String TraceControl_ProbeSymbolPropertyName;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+
+/**
+ * <b><u>TraceControlContentProvider</u></b>
+ * <p>
+ * Tree content provider implementation for trace control view.
+ * </p>
+ */
+public class TraceControlContentProvider implements ITreeContentProvider {
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ @Override
+ public Object[] getChildren(Object parentElement) {
+
+ if (parentElement instanceof ITraceControlComponent) {
+ return ((ITraceControlComponent)parentElement).getChildren();
+ }
+ return new Object[0];
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof ITraceControlComponent) {
+ return ((ITraceControlComponent)element).getParent();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ if (element instanceof ITraceControlComponent) {
+ return ((ITraceControlComponent)element).hasChildren();
+ }
+ return false;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control;
+
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * <b><u>TraceControlLabelProvider</u></b>
+ * <p>
+ * Label provider for trace control tree viewer.
+ * </p>
+ */
+public class TraceControlLabelProvider extends ColumnLabelProvider {
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage(Object element) {
+ if ((element != null) && (element instanceof ITraceControlComponent)) {
+ return ((ITraceControlComponent) element).getImage();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object element) {
+ if ((element != null) && (element instanceof ITraceControlComponent)) {
+ return ((ITraceControlComponent) element).getName();
+ }
+ return "";//$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText(Object element) {
+ if ((element != null) && (element instanceof ITraceControlComponent)) {
+ return ((ITraceControlComponent) element).getToolTip();
+ }
+ return null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * <b><u>ConfirmDialog</u></b>
+ * <p>
+ * Confirmation dialog implementation.
+ * </p>
+ */
+
+public class ConfirmDialog implements IConfirmDialog {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IConfirmDialog#openConfirm(org.eclipse.swt.widgets.Shell, java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean openConfirm(Shell parent, String title, String message) {
+ return MessageDialog.openConfirm(parent,
+ Messages.TraceControl_DestroyConfirmationTitle,
+ Messages.TraceControl_DestroyConfirmationMessage);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+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.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * <b><u>CreateChannelDialog</u></b>
+ * <p>
+ * Dialog box for collecting channel creation information.
+ * </p>
+ */
+public class CreateChannelDialog extends Dialog implements ICreateChannelOnSessionDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The icon file for this dialog box.
+ */
+ public static final String ENABLE_CHANNEL_ICON_FILE = "icons/elcl16/edit.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite = null;
+ /**
+ * The text widget for the channel name
+ */
+ private Text fChannelNameText = null;
+ /**
+ * The overwrite mode of the channel.
+ */
+ private Button fOverwriteModeButton;
+ /**
+ * The sub-buffer size of the channel.
+ */
+ private Text fSubBufferSizeText;
+ /**
+ * The number of sub-buffers of the channel.
+ */
+ private Text fNumberOfSubBuffersText;
+ /**
+ * The switch timer interval of the channel.
+ */
+ private Text fSwitchTimerText;
+ /**
+ * The read timer interval of the channel.
+ */
+ private Text fReadTimerText;
+ /**
+ * Group composite for domain selection.
+ */
+ private Group fDomainGroup = null;
+ /**
+ * Radio button for selecting kernel domain.
+ */
+ private Button fKernelButton;
+ /**
+ * Radio button for selecting UST domain.
+ */
+ private Button fUstButton;
+ /**
+ * The parent domain component where the channel node should be added.
+ * Null in case of creation on session level.
+ */
+ private TraceDomainComponent fDomain;
+ /**
+ * Common verify listener for numeric text input.
+ */
+ private VerifyListener fVerifyListener;
+ /**
+ * Output channel information.
+ */
+ private IChannelInfo fChannelInfo;
+ /**
+ * Output domain information. True in case of Kernel domain. False for UST.
+ */
+ private boolean fIsKernel;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ * @param shell - a shell for the display of the dialog
+ */
+ public CreateChannelDialog(Shell shell) {
+ super(shell);
+ fIsKernel = true;
+
+ // Common verify listener
+ fVerifyListener = new VerifyListener() {
+ @Override
+ public void verifyText(VerifyEvent e) {
+ // only numbers are allowed.
+ e.doit = e.text.matches("[0-9]*"); //$NON-NLS-1$
+ }
+ };
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog#getChannelInfo()
+ */
+ @Override
+ public IChannelInfo getChannelInfo() {
+ return fChannelInfo;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog#setDomainComponent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent)
+ */
+ @Override
+ public void setDomainComponent(TraceDomainComponent domain) {
+ fDomain = domain;
+ if (fDomain != null) {
+ fIsKernel = fDomain.isKernel();
+ } else {
+ fIsKernel = true;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelOnSessionDialog#isKernel()
+ */
+ @Override
+ public boolean isKernel() {
+ return fIsKernel;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.TraceControl_EnableChannelDialogTitle);
+ newShell.setImage(Activator.getDefault().loadIcon(ENABLE_CHANNEL_ICON_FILE));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ // Main dialog panel
+ fDialogComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(2, true);
+ fDialogComposite.setLayout(layout);
+
+ Label channelNameLabel = new Label(fDialogComposite, SWT.RIGHT);
+ channelNameLabel.setText(Messages.TraceControl_EnableChannelNameLabel);
+ fChannelNameText = new Text(fDialogComposite, SWT.NONE);
+ fChannelNameText.setToolTipText(Messages.TraceControl_EnableChannelNameTooltip);
+
+ Label subBufferSizeLabel = new Label(fDialogComposite, SWT.RIGHT);
+ subBufferSizeLabel.setText(Messages.TraceControl_SubBufferSizePropertyName);
+ fSubBufferSizeText = new Text(fDialogComposite, SWT.NONE);
+ fSubBufferSizeText.setToolTipText(Messages.TraceControl_EnableChannelSubBufferSizeTooltip);
+ fSubBufferSizeText.addVerifyListener(fVerifyListener);
+
+ Label numSubBufferLabel = new Label(fDialogComposite, SWT.RIGHT);
+ numSubBufferLabel.setText(Messages.TraceControl_NbSubBuffersPropertyName);
+ fNumberOfSubBuffersText = new Text(fDialogComposite, SWT.NONE);
+ fNumberOfSubBuffersText.setToolTipText(Messages.TraceControl_EnableChannelNbSubBuffersTooltip);
+ fNumberOfSubBuffersText.addVerifyListener(fVerifyListener);
+
+ Label switchTimerLabel = new Label(fDialogComposite, SWT.RIGHT);
+ switchTimerLabel.setText(Messages.TraceControl_SwitchTimerPropertyName);
+ fSwitchTimerText = new Text(fDialogComposite, SWT.NONE);
+ fSwitchTimerText.setToolTipText(Messages.TraceControl_EnableChannelSwitchTimerTooltip);
+ fSwitchTimerText.addVerifyListener(fVerifyListener);
+
+ Label readTimerLabel = new Label(fDialogComposite, SWT.RIGHT);
+ readTimerLabel.setText(Messages.TraceControl_ReadTimerPropertyName);
+ fReadTimerText = new Text(fDialogComposite, SWT.NONE);
+ fReadTimerText.setToolTipText(Messages.TraceControl_EnableChannelReadTimerTooltip);
+ fReadTimerText.addVerifyListener(fVerifyListener);
+
+ fOverwriteModeButton = new Button(fDialogComposite, SWT.CHECK);
+ fOverwriteModeButton.setText(Messages.TraceControl_OverwriteModePropertyName);
+ fOverwriteModeButton.setToolTipText(Messages.TraceControl_EnableChannelOverwriteModeTooltip);
+ new Label(fDialogComposite, SWT.RIGHT);
+
+ fDomainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ fDomainGroup.setText(Messages.TraceControl_DomainDisplayName);
+ layout = new GridLayout(2, true);
+ fDomainGroup.setLayout(layout);
+
+ fKernelButton = new Button(fDomainGroup, SWT.RADIO);
+ fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName);
+ fKernelButton.setSelection(fIsKernel);
+ fUstButton = new Button(fDomainGroup, SWT.RADIO);
+ fUstButton.setText(Messages.TraceControl_UstDisplayName);
+ fUstButton.setSelection(!fIsKernel);
+
+ if (fDomain != null) {
+ fKernelButton.setEnabled(false);
+ fUstButton.setEnabled(false);
+ }
+
+ // layout widgets
+ GridData data = new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1);
+ fDomainGroup.setLayoutData(data);
+
+ data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ fKernelButton.setLayoutData(data);
+ data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ fUstButton.setLayoutData(data);
+
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ fSubBufferSizeText.setText("666.666.666.666"); //$NON-NLS-1$
+ Point minSize = fSubBufferSizeText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ data.widthHint = minSize.x + 5;
+
+ fChannelNameText.setLayoutData(data);
+ fSubBufferSizeText.setLayoutData(data);
+ fNumberOfSubBuffersText.setLayoutData(data);
+ fSwitchTimerText.setLayoutData(data);
+ fReadTimerText.setLayoutData(data);
+
+ fSubBufferSizeText.setText(""); //$NON-NLS-1$
+
+ setDefaults();
+
+ return fDialogComposite;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.DETAILS_ID, "Default", true); //$NON-NLS-1$
+ createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ // Set channel information
+ fChannelInfo = new ChannelInfo(fChannelNameText.getText());
+ fChannelInfo.setSubBufferSize(Long.parseLong(fSubBufferSizeText.getText()));
+ fChannelInfo.setNumberOfSubBuffers(Integer.parseInt(fNumberOfSubBuffersText.getText()));
+ fChannelInfo.setSwitchTimer(Long.parseLong(fSwitchTimerText.getText()));
+ fChannelInfo.setReadTimer(Long.parseLong(fReadTimerText.getText()));
+ fChannelInfo.setOverwriteMode(fOverwriteModeButton.getSelection());
+
+ if (fKernelButton.getSelection() == true) {
+ fIsKernel = true;
+ } else {
+ fIsKernel = false;
+ }
+
+ // Check for invalid names
+ if (!fChannelInfo.getName().matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableChannelDialogTitle,
+ Messages.TraceControl_InvalidChannelNameError + " (" + fChannelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // Check for duplicate names
+ if (fDomain != null && fDomain.containsChild(fChannelInfo.getName())) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableChannelDialogTitle,
+ Messages.TraceControl_ChannelAlreadyExistsError + " (" + fChannelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // validation successful -> call super.okPressed()
+ super.okPressed();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.DETAILS_ID) {
+ setDefaults();
+ return;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ /**
+ * Sets default value depending on Kernel or UST
+ */
+ private void setDefaults() {
+ fSwitchTimerText.setText(String.valueOf(IChannelInfo.DEFAULT_SWITCH_TIMER));
+ fReadTimerText.setText(String.valueOf(IChannelInfo.DEFAULT_READ_TIMER));
+ fOverwriteModeButton.setSelection(IChannelInfo.DEFAULT_OVERWRITE_MODE);
+ if (fKernelButton.getSelection()) {
+ fSubBufferSizeText.setText(String.valueOf(IChannelInfo.DEFAULT_SUB_BUFFER_SIZE_KERNEL));
+ fNumberOfSubBuffersText.setText(String.valueOf(IChannelInfo.DEFAULT_NUMBER_OF_SUB_BUFFERS_KERNEL));
+ } else {
+ fSubBufferSizeText.setText(String.valueOf(IChannelInfo.DEFAULT_SUB_BUFFER_SIZE_UST));
+ fNumberOfSubBuffersText.setText(String.valueOf(IChannelInfo.DEFAULT_NUMBER_OF_SUB_BUFFERS_UST));
+ }
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+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.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * <b><u>CreateSessionDialog</u></b>
+ * <p>
+ * Dialog box for collecting session creation information.
+ * </p>
+ */
+public class CreateSessionDialog extends Dialog implements ICreateSessionDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The icon file for this dialog box.
+ */
+ public static final String CREATE_SESSION_ICON_FILE = "icons/elcl16/add_button.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite = null;
+ /**
+ * The text widget for the session name
+ */
+ private Text fSessionNameText = null;
+ /**
+ * The text widget for the session path
+ */
+ private Text fSessionPathText = null;
+ /**
+ * The parent where the new node should be added.
+ */
+ private TraceSessionGroup fParent;
+ /**
+ * The session name string.
+ */
+ private String fSessionName = null;
+ /**
+ * The session path string.
+ */
+ private String fSessionPath = null;
+ /**
+ * Flag whether default location (path) shall be used or not
+ */
+ private boolean fIsDefaultPath = true;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param shell - a shell for the display of the dialog
+ */
+ public CreateSessionDialog(Shell shell) {
+ super(shell);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#getSessionName()
+ */
+ @Override
+ public String getSessionName() {
+ return fSessionName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#getSessionPath()
+ */
+ @Override
+ public String getSessionPath() {
+ return fSessionPath;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#isDefaultSessionPath()
+ */
+ @Override
+ public boolean isDefaultSessionPath() {
+ return fIsDefaultPath;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#setTraceSessionGroup(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup)
+ */
+ @Override
+ public void setTraceSessionGroup(TraceSessionGroup group) {
+ fParent = group;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.TraceControl_CreateSessionDialogTitle);
+ newShell.setImage(Activator.getDefault().loadIcon(CREATE_SESSION_ICON_FILE));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ // Main dialog panel
+ fDialogComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(2, true);
+ fDialogComposite.setLayout(layout);
+
+ Label sessionNameLabel = new Label(fDialogComposite, SWT.RIGHT);
+ sessionNameLabel.setText(Messages.TraceControl_CreateSessionNameLabel);
+ fSessionNameText = new Text(fDialogComposite, SWT.NONE);
+ fSessionNameText.setToolTipText(Messages.TraceControl_CreateSessionNameTooltip);
+
+ Label sessionPath = new Label(fDialogComposite, SWT.RIGHT);
+ sessionPath.setText(Messages.TraceControl_CreateSessionPathLabel);
+ fSessionPathText = new Text(fDialogComposite, SWT.NONE);
+ fSessionPathText.setToolTipText(Messages.TraceControl_CreateSessionPathTooltip);
+
+ // layout widgets
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ fSessionPathText.setText("666.666.666.666"); //$NON-NLS-1$
+ Point minSize = fSessionPathText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ data.widthHint = minSize.x + 5;
+
+ fSessionNameText.setLayoutData(data);
+ fSessionPathText.setLayoutData(data);
+
+ fSessionPathText.setText(""); //$NON-NLS-1$
+
+ return fDialogComposite;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ // Validate input data
+ fSessionName = fSessionNameText.getText();
+ fSessionPath = fSessionPathText.getText();
+
+ if (!"".equals(fSessionPath)) { //$NON-NLS-1$
+ // validate sessionPath
+
+ TargetNodeComponent node = (TargetNodeComponent)fParent.getParent();
+ IRemoteSystemProxy proxy = node.getRemoteSystemProxy();
+ IFileServiceSubSystem fsss = proxy.getFileServiceSubSystem();
+ if (fsss != null) {
+ try {
+ IRemoteFile remoteFolder = fsss.getRemoteFileObject(fSessionPath, new NullProgressMonitor());
+ if (remoteFolder.exists()) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_CreateSessionDialogTitle,
+ Messages.TraceControl_SessionPathAlreadyExistsError + " (" + fSessionPath + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+ } catch (SystemMessageException e) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_CreateSessionDialogTitle,
+ Messages.TraceControl_FileSubSystemError + "\n" + e); //$NON-NLS-1$
+ return;
+ }
+ }
+ fIsDefaultPath = false;
+ }
+
+ // If no session name is specified use default name auto
+ if ("".equals(fSessionName)) { //$NON-NLS-1$
+ fSessionName = "auto"; //$NON-NLS-1$
+ }
+
+ // Check for invalid names
+ if (!fSessionName.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_CreateSessionDialogTitle,
+ Messages.TraceControl_InvalidSessionNameError + " (" + fSessionName + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // Check if node with name already exists in parent
+ if(fParent.containsChild(fSessionName)) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_CreateSessionDialogTitle,
+ Messages.TraceControl_SessionAlreadyExistsError + " (" + fSessionName + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // validation successful -> call super.okPressed()
+ super.okPressed();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+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.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * <b><u>EnableEventsDialog</u></b>
+ * <p>
+ * Dialog box for collecting information events to be enabled.
+ * </p>
+ */
+public class EnableEventsDialog extends Dialog implements IEnableEventsDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * The icon file for this dialog box.
+ */
+ public static final String ENABLE_EVENT_ICON_FILE = "icons/elcl16/edit.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite;
+ /**
+ * The composite with widgets for collecting information about kernel events.
+ */
+ private EnableKernelEventComposite fKernelComposite;
+ /**
+ * The composite with widgets for collecting information about UST events.
+ */
+ private EnableUstEventsComposite fUstComposite;
+ /**
+ * Radio button for selecting kernel domain.
+ */
+ private Button fKernelButton;
+ /**
+ * Radio button for selecting UST domain.
+ */
+ private Button fUstButton;
+ /**
+ * The referenced trace provider group containing the kernel provider and UST
+ * provider component which contains a list of available tracepoints.
+ */
+ private TraceProviderGroup fProviderGroup;
+ /**
+ * The parent domain component where the channel node should be added.
+ * Null in case the domain is not known (i.e. on session level).
+ */
+ private TraceDomainComponent fDomain;
+ /**
+ * Output domain information. True in case of Kernel domain. False for UST.
+ */
+ private boolean fIsKernel;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param shell - a shell for the display of the dialog
+ * @param providerGroup - the trace provider group
+ */
+ public EnableEventsDialog(Shell shell) {
+ super(shell);
+ setShellStyle(SWT.RESIZE);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isTracpoints()
+ */
+ @Override
+ public boolean isTracepoints() {
+ if (fIsKernel) {
+ return fKernelComposite.isTracepoints();
+ }
+ return fUstComposite.isTracepoints();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllTracePoints()
+ */
+ @Override
+ public boolean isAllTracePoints() {
+ if (fIsKernel) {
+ return fKernelComposite.isAllTracePoints();
+ }
+ return fUstComposite.isAllTracePoints();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isSysCalls()
+ */
+ @Override
+ public boolean isSysCalls() {
+ if (fIsKernel) {
+ return fKernelComposite.isSysCalls();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllSysCalls()
+ */
+ @Override
+ public boolean isAllSysCalls() {
+ if (fIsKernel) {
+ return fKernelComposite.isSysCalls();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getEventNames()
+ */
+ @Override
+ public List<String> getEventNames() {
+ if (fIsKernel) {
+ return fKernelComposite.getEventNames();
+ }
+ return fUstComposite.getEventNames();
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicProbe()
+ */
+ @Override
+ public boolean isDynamicProbe() {
+ if (fIsKernel) {
+ return fKernelComposite.isDynamicProbe();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeName()
+ */
+ @Override
+ public String getProbeName() {
+ if (fIsKernel) {
+ return fKernelComposite.getProbeName();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeEventName()
+ */
+ @Override
+ public String getProbeEventName() {
+ if (fIsKernel) {
+ return fKernelComposite.getProbeEventName();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicFunctionProbe()
+ */
+ @Override
+ public boolean isDynamicFunctionProbe() {
+ if (fIsKernel) {
+ return fKernelComposite.isDynamicFunctionProbe();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunctionEventName()
+ */
+ @Override
+ public String getFunctionEventName() {
+ if (fIsKernel) {
+ return fKernelComposite.getFunctionEventName();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunction()
+ */
+ @Override
+ public String getFunction() {
+ if (fIsKernel) {
+ return fKernelComposite.getFunction();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isWildcard()
+ */
+ @Override
+ public boolean isWildcard() {
+ if (!fIsKernel) {
+ return fUstComposite.isWildcard();
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getWildcard()
+ */
+ @Override
+ public String getWildcard() {
+ if (!fIsKernel) {
+ return fUstComposite.getWildcard();
+ }
+ return null;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isLogLevel()
+ */
+ @Override
+ public boolean isLogLevel() {
+ if (!fIsKernel) {
+ return fUstComposite.isLogLevel();
+ }
+ return false;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevelType()
+ */
+ @Override
+ public LogLevelType getLogLevelType() {
+ if (!fIsKernel) {
+ return fUstComposite.getLogLevelType();
+ }
+ return null;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevel()
+ */
+ @Override
+ public TraceLogLevel getLogLevel() {
+ if (!fIsKernel) {
+ return fUstComposite.getLogLevel();
+ }
+ return null;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevelEventName()
+ */
+ @Override
+ public String getLogLevelEventName() {
+ if (!fIsKernel) {
+ return fUstComposite.getLogLevelEventName();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#isKernel()
+ */
+ @Override
+ public boolean isKernel() {
+ return fIsKernel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#setTraceProviderGroup(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup)
+ */
+ @Override
+ public void setTraceProviderGroup(TraceProviderGroup providerGroup) {
+ fProviderGroup = providerGroup;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#setTraceDomainComponent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent)
+ */
+ @Override
+ public void setTraceDomainComponent(TraceDomainComponent domain) {
+ fDomain = domain;
+ if (fDomain != null) {
+ fIsKernel = fDomain.isKernel();
+ } else {
+ fIsKernel = true;
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.TraceControl_EnableEventsDialogTitle);
+ newShell.setImage(Activator.getDefault().loadIcon(ENABLE_EVENT_ICON_FILE));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ // Main dialog panel
+ fDialogComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, true);
+ fDialogComposite.setLayout(layout);
+ fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ // ------------------------------------------------------------------------
+ // Domain Group
+ // ------------------------------------------------------------------------
+ Group domainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ domainGroup.setText(Messages.TraceControl_DomainDisplayName);
+ layout = new GridLayout(2, true);
+ domainGroup.setLayout(layout);
+
+ fKernelButton = new Button(domainGroup, SWT.RADIO);
+ fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName);
+ fKernelButton.setSelection(fIsKernel);
+ fUstButton = new Button(domainGroup, SWT.RADIO);
+ fUstButton.setText(Messages.TraceControl_UstDisplayName);
+ fUstButton.setSelection(!fIsKernel);
+
+ if (fDomain != null) {
+ fKernelButton.setEnabled(false);
+ fUstButton.setEnabled(false);
+ }
+
+ // layout widgets
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ domainGroup.setLayoutData(data);
+
+ data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ fKernelButton.setLayoutData(data);
+ data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ fUstButton.setLayoutData(data);
+
+ // ------------------------------------------------------------------------
+ // Kernel or UST event data group
+ // ------------------------------------------------------------------------
+ fUstComposite = null;
+ fKernelComposite = null;
+ if (fIsKernel) {
+ createKernelComposite();
+ fUstComposite = null;
+ } else {
+ createUstComposite();
+ }
+
+ fKernelButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (fKernelButton.getSelection()) {
+ disposeUstComposite();
+ createKernelComposite();
+ fDialogComposite.layout();
+ }
+ }
+ });
+
+ fUstButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (fUstButton.getSelection()) {
+ disposeKernelComposite();
+ createUstComposite();
+ fDialogComposite.layout();
+ }
+ }
+ });
+
+ fDialogComposite.layout();
+
+ getShell().setMinimumSize(new Point(500, 650));
+
+ return fDialogComposite;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ if (fKernelButton.getSelection() == true) {
+ fIsKernel = true;
+ } else {
+ fIsKernel = false;
+ }
+
+ // Validate kernel composite in case of kernel domain
+ if (fKernelComposite != null && !fKernelComposite.isValid()) {
+ return;
+ }
+
+ // Validate UST composite in case of UST domain
+ if (fUstComposite != null && !fUstComposite.isValid()) {
+ return;
+ }
+
+ // validation successful -> call super.okPressed()
+ super.okPressed();
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ /**
+ * Creates the kernel composite (if not existing)
+ */
+ private void createKernelComposite() {
+ if (fKernelComposite == null) {
+ fKernelComposite = new EnableKernelEventComposite(fDialogComposite, SWT.NONE, fProviderGroup);
+ GridLayout layout = new GridLayout(1, true);
+ fKernelComposite.setLayout(layout);
+ fKernelComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fKernelComposite.createContent();
+ }
+ }
+
+ /**
+ * Disposes the kernel composite (if existing)
+ */
+ private void disposeKernelComposite() {
+ if (fKernelComposite != null) {
+ fKernelComposite.dispose();
+ fKernelComposite = null;
+ }
+ }
+
+ /**
+ * Creates the UST composite (if not existing)
+ */
+ private void createUstComposite() {
+ if (fUstComposite == null) {
+ fUstComposite = new EnableUstEventsComposite(fDialogComposite, SWT.NONE, fProviderGroup);
+ GridLayout layout = new GridLayout(1, true);
+ fUstComposite.setLayout(layout);
+ fUstComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fUstComposite.createContent();
+ }
+ }
+
+ /**
+ * Disposes the UST composite (if existing)
+ */
+ private void disposeUstComposite() {
+ if (fUstComposite != null) {
+ fUstComposite.dispose();
+ fUstComposite = null;
+ }
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.TraceControlContentProvider;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.TraceControlLabelProvider;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.KernelProviderComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * <b><u>EnableKernelEventsComposite</u></b>
+ * <p>
+ * A composite for collecting information about kernel events to be enabled.
+ * </p>
+ */
+public class EnableKernelEventComposite extends Composite implements IEnableKernelEvents {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ private enum KernelGroupEnum { TRACEPOINTS, SYSCALLS, PROBE, FUNCTION };
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * A button to enable/disable the tracepoints group
+ */
+ private Button fTracepointsActivateButton;
+ /**
+ * A tree viewer for displaying and selection of available tracepoints.
+ */
+ private CheckboxTreeViewer fTracepointsViewer;
+ /**
+ * A button to enable/disable the syscalls group
+ */
+ private Button fSysCallsActivateButton;
+ /**
+ * A button to enable or disable the dynamic probe group.
+ */
+ private Button fProbeActivateButton;
+ /**
+ * The text field for the event name for the dynamic probe.
+ */
+ private Text fProbeEventNameText;
+ /**
+ * The text field for the dynamic probe.
+ */
+ private Text fProbeText;
+ /**
+ * A button to enable or disable the dynamic function probe group.
+ */
+ private Button fFunctionActivateButton;
+ /**
+ * The text field for the event name for the dynamic probe.
+ */
+ private Text fFunctionEventNameText;
+ /**
+ * The text field for the dynamic function entry/return probe.
+ */
+ private Text fFunctionText;
+ /**
+ * The referenced trace provider group containing the kernel provider
+ * component which contains a list of available tracepoints.
+ */
+ private TraceProviderGroup fProviderGroup;
+ /**
+ * The flag indicating that tracepoints are selected.
+ */
+ private boolean fIsTracepoints;
+ /**
+ * The flag indicating that all tracepoints are selected.
+ */
+ private boolean fIsAllTracepoints;
+ /**
+ * The flag indicating that syscalls are selected.
+ */
+ private boolean fIsSysCalls;
+ /**
+ * The list of tracepoints to be enabled.
+ */
+ private List<String> fSelectedEvents;
+ /**
+ * The flag indicating that dynamic probe is selected.
+ */
+ private boolean fIsDynamicProbe;
+ /**
+ * The event name of the dynamic probe.
+ */
+ private String fProbeEventName;
+ /**
+ * The dynamic probe.
+ */
+ private String fProbeString;
+ /**
+ * The flag indicating that the dynamic function probe is selected.
+ */
+ private boolean fIsDynamicFunctionProbe;
+ /**
+ * The event name of the dynamic function entry/return probe.
+ */
+ private String fFunctionEventName;
+ /**
+ * The dynamic function entry/return probe.
+ */
+ private String fFunctionString;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ public EnableKernelEventComposite(Composite parent, int style, TraceProviderGroup providerGroup) {
+ super(parent, style);
+ fProviderGroup = providerGroup;
+ }
+
+ // ------------------------------------------------------------------------
+ // Acessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isTracpoints()
+ */
+ @Override
+ public boolean isTracepoints() {
+ return fIsTracepoints;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllTracePoints()
+ */
+ @Override
+ public boolean isAllTracePoints() {
+ return fIsAllTracepoints;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isSysCalls()
+ */
+ @Override
+ public boolean isSysCalls() {
+ return fIsSysCalls;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllSysCalls()
+ */
+ @Override
+ public boolean isAllSysCalls() {
+ return fIsSysCalls;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getEventNames()
+ */
+ @Override
+ public List<String> getEventNames() {
+ return new ArrayList<String>(fSelectedEvents);
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicProbe()
+ */
+ @Override
+ public boolean isDynamicProbe() {
+ return fIsDynamicProbe;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeName()
+ */
+ @Override
+ public String getProbeName() {
+ return fProbeString;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeEventName()
+ */
+ @Override
+ public String getProbeEventName() {
+ return fProbeEventName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicFunctionProbe()
+ */
+ @Override
+ public boolean isDynamicFunctionProbe() {
+ return fIsDynamicFunctionProbe;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunctionEventName()
+ */
+ @Override
+ public String getFunctionEventName() {
+ return fFunctionEventName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunction()
+ */
+ @Override
+ public String getFunction() {
+ return fFunctionString;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Creates the composite content
+ */
+ public void createContent() {
+
+ // Tracepoints Group
+ createTracepointsGroup();
+
+ // Syscalls Group
+ createSysCallsGroup();
+
+ // Dynamic Probe Group
+ createDynamicProbeGroup();
+
+ // Dynamic Function Probe Group
+ createDynamicFunctionPropeGroup();
+
+ // Set default enablements
+ setKernelEnablements(KernelGroupEnum.TRACEPOINTS);
+ }
+
+ /**
+ * Validates the kernel composite input data.
+ * @return true if configured data is valid and can be retrieved.
+ */
+ public boolean isValid() {
+ fIsTracepoints = fTracepointsActivateButton.getSelection();
+ fIsSysCalls = fSysCallsActivateButton.getSelection();
+ fIsDynamicProbe = fProbeActivateButton.getSelection();
+ fIsDynamicFunctionProbe = fFunctionActivateButton.getSelection();
+
+ List<ITraceControlComponent> comps = fProviderGroup.getChildren(KernelProviderComponent.class);
+ fIsAllTracepoints = fTracepointsViewer.getChecked(comps.get(0));
+
+ Object[] checkedElements = fTracepointsViewer.getCheckedElements();
+ fSelectedEvents = new ArrayList<String>();
+ for (int i = 0; i < checkedElements.length; i++) {
+ ITraceControlComponent component = (ITraceControlComponent)checkedElements[i];
+ if (component instanceof BaseEventComponent) {
+ fSelectedEvents.add(component.getName());
+ }
+ }
+
+ // initialize probe string
+ fProbeEventName = null;
+ fProbeString = null;
+ String temp = fProbeEventNameText.getText();
+ if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ return false;
+ }
+
+ if(!fProbeText.getText().matches("\\s*")) { //$NON-NLS-1$
+ fProbeEventName = temp;
+ // fProbeString will be validated by lttng-tools
+ fProbeString = fProbeText.getText();
+ }
+
+ // initialize function string
+ fFunctionEventName = null;
+ fFunctionString = null;
+
+ temp = fFunctionEventNameText.getText();
+ if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ return false;
+ }
+
+ if(!fFunctionText.getText().matches("\\s*")) { //$NON-NLS-1$
+ fFunctionEventName = temp;
+ // fFunctionString will be validated by lttng-tools
+ fFunctionString = fFunctionText.getText();
+ }
+
+ return true;
+ }
+
+ /**
+ * Creates tracepoints group.
+ */
+ private void createTracepointsGroup() {
+
+ GridLayout layout;
+ GridData data;
+ Group tpMainGroup = new Group(this, SWT.SHADOW_NONE);
+ tpMainGroup.setText(Messages.TraceControl_EnableEventsTracepointGroupName);
+ layout = new GridLayout(2, false);
+ tpMainGroup.setLayout(layout);
+ data = new GridData(GridData.FILL_BOTH);
+ tpMainGroup.setLayoutData(data);
+
+ Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE);
+ layout = new GridLayout(1, true);
+ buttonComposite.setLayout(layout);
+ data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
+ buttonComposite.setLayoutData(data);
+
+ fTracepointsActivateButton = new Button(buttonComposite, SWT.RADIO);
+ fTracepointsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fTracepointsActivateButton.setLayoutData(data);
+ fTracepointsActivateButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setKernelEnablements(KernelGroupEnum.TRACEPOINTS);
+ }
+ });
+
+ Group tracepointsGroup = new Group(tpMainGroup, SWT.SHADOW_NONE);
+ layout = new GridLayout(1, true);
+ tracepointsGroup.setLayout(layout);
+ data = new GridData(GridData.FILL_BOTH);
+ tracepointsGroup.setLayoutData(data);
+
+ fTracepointsViewer = new CheckboxTreeViewer(tracepointsGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip);
+
+ fTracepointsViewer.setContentProvider(new KernelContentProvider());
+ fTracepointsViewer.setLabelProvider(new KernelLabelProvider());
+ fTracepointsViewer.addCheckStateListener(new KernelCheckListener());
+ fTracepointsViewer.setInput(fProviderGroup);
+
+ fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+
+ /**
+ * Creates syscalls group.
+ */
+ private void createSysCallsGroup() {
+ GridLayout layout;
+ GridData data;
+ Group sysCallsMainGroup = new Group(this, SWT.SHADOW_NONE);
+ sysCallsMainGroup.setText(Messages.TraceControl_EnableEventsSyscallName);
+ sysCallsMainGroup.setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip);
+ layout = new GridLayout(2, false);
+ sysCallsMainGroup.setLayout(layout);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ sysCallsMainGroup.setLayoutData(data);
+
+ Composite buttonComposite = new Composite(sysCallsMainGroup, SWT.NONE);
+ layout = new GridLayout(1, false);
+ buttonComposite.setLayout(layout);
+ data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
+ buttonComposite.setLayoutData(data);
+
+ fSysCallsActivateButton = new Button(buttonComposite, SWT.RADIO);
+ fSysCallsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
+ fSysCallsActivateButton.setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip);
+ fSysCallsActivateButton.setSelection(false);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fSysCallsActivateButton.setLayoutData(data);
+ fSysCallsActivateButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setKernelEnablements(KernelGroupEnum.SYSCALLS);
+ }
+ });
+ }
+
+ /**
+ * Creates dynamic probe group.
+ */
+ private void createDynamicProbeGroup() {
+ GridLayout layout;
+ GridData data;
+ Group probeMainGroup = new Group(this, SWT.SHADOW_NONE);
+ probeMainGroup.setText(Messages.TraceControl_EnableEventsProbeGroupName);
+ layout = new GridLayout(2, false);
+ probeMainGroup.setLayout(layout);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ probeMainGroup.setLayoutData(data);
+
+ Composite buttonComposite = new Composite(probeMainGroup, SWT.NONE);
+ layout = new GridLayout(1, false);
+ buttonComposite.setLayout(layout);
+ data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
+ buttonComposite.setLayoutData(data);
+
+ fProbeActivateButton = new Button(buttonComposite, SWT.RADIO);
+ fProbeActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
+ fProbeActivateButton.setSelection(false);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fProbeActivateButton.setLayoutData(data);
+ fProbeActivateButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setKernelEnablements(KernelGroupEnum.PROBE);
+ }
+ });
+
+ Group probeGroup = new Group(probeMainGroup, SWT.SHADOW_NONE);
+ layout = new GridLayout(4, true);
+ probeGroup.setLayout(layout);
+ probeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label probeNameLabel = new Label(probeGroup, SWT.LEFT);
+ probeNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel);
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 1;
+ probeNameLabel.setLayoutData(data);
+
+ fProbeEventNameText = new Text(probeGroup, SWT.LEFT);
+ fProbeEventNameText.setToolTipText(Messages.TraceControl_EnableEventsProbeEventNameTooltip);
+
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 3;
+ fProbeEventNameText.setLayoutData(data);
+
+ Label probeLabel = new Label(probeGroup, SWT.LEFT);
+ probeLabel.setText(Messages.TraceControl_EnableEventsProbeNameLabel);
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 1;
+ probeLabel.setLayoutData(data);
+
+ fProbeText = new Text(probeGroup, SWT.LEFT);
+ fProbeText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip);
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 3;
+ fProbeText.setLayoutData(data);
+ }
+
+ /**
+ * Creates dynamic function entry/return probe group.
+ */
+ private void createDynamicFunctionPropeGroup() {
+ GridLayout layout;
+ GridData data;
+ Group functionMainGroup = new Group(this, SWT.SHADOW_NONE);
+ functionMainGroup.setText(Messages.TraceControl_EnableEventsFucntionGroupName);
+ layout = new GridLayout(2, false);
+ functionMainGroup.setLayout(layout);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ functionMainGroup.setLayoutData(data);
+
+ Composite buttonComposite = new Composite(functionMainGroup, SWT.NONE);
+ layout = new GridLayout(1, false);
+ buttonComposite.setLayout(layout);
+ data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
+ buttonComposite.setLayoutData(data);
+
+ fFunctionActivateButton = new Button(buttonComposite, SWT.RADIO);
+ fFunctionActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
+ fFunctionActivateButton.setSelection(false);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fFunctionActivateButton.setLayoutData(data);
+ fFunctionActivateButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setKernelEnablements(KernelGroupEnum.FUNCTION);
+ }
+ });
+
+ Group functionGroup = new Group(functionMainGroup, SWT.SHADOW_NONE);
+ layout = new GridLayout(4, true);
+ functionGroup.setLayout(layout);
+ functionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label functionNameLabel = new Label(functionGroup, SWT.LEFT);
+ functionNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel);
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 1;
+ functionNameLabel.setLayoutData(data);
+
+ fFunctionEventNameText = new Text(functionGroup, SWT.LEFT);
+ fFunctionEventNameText.setToolTipText(Messages.TraceControl_EnableEventsFunctionEventNameTooltip);
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 3;
+ fFunctionEventNameText.setLayoutData(data);
+
+ Label functionLabel = new Label(functionGroup, SWT.LEFT);
+ functionLabel.setText(Messages.TraceControl_EnableEventsFunctionNameLabel);
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 1;
+ functionLabel.setLayoutData(data);
+
+ fFunctionText = new Text(functionGroup, SWT.LEFT);
+ fFunctionText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip);
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 3;
+ fFunctionText.setLayoutData(data);
+ }
+
+ /**
+ * Enable/selects widgets depending on the group specified.
+ * @param group - group to enable.
+ */
+ private void setKernelEnablements(KernelGroupEnum group) {
+ fTracepointsActivateButton.setSelection(group == KernelGroupEnum.TRACEPOINTS);
+ fTracepointsViewer.getTree().setEnabled(group == KernelGroupEnum.TRACEPOINTS);
+
+ fSysCallsActivateButton.setSelection(group == KernelGroupEnum.SYSCALLS);
+
+ fProbeActivateButton.setSelection(group == KernelGroupEnum.PROBE);
+ fProbeEventNameText.setEnabled(group == KernelGroupEnum.PROBE);
+ fProbeText.setEnabled(group == KernelGroupEnum.PROBE);
+
+ fFunctionActivateButton.setSelection(group == KernelGroupEnum.FUNCTION);
+ fFunctionEventNameText.setEnabled(group == KernelGroupEnum.FUNCTION);
+ fFunctionText.setEnabled(group == KernelGroupEnum.FUNCTION);
+ }
+
+ // ------------------------------------------------------------------------
+ // Local classes
+ // ------------------------------------------------------------------------
+ /**
+ * Content provider for the tracepoints tree.
+ */
+ final public class KernelContentProvider extends TraceControlContentProvider {
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof TraceProviderGroup) {
+ List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(KernelProviderComponent.class);
+ return (ITraceControlComponent[]) children.toArray(new ITraceControlComponent[children.size()]);
+ }
+ if (parentElement instanceof ITraceControlComponent) {
+ return ((ITraceControlComponent)parentElement).getChildren();
+ }
+ return new Object[0];
+ }
+ }
+
+ /**
+ * Content label for the tracepoints tree.
+ */
+ final public class KernelLabelProvider extends TraceControlLabelProvider {
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+ @Override
+ public String getText(Object element) {
+ if ((element != null) && (element instanceof KernelProviderComponent)) {
+ return Messages.TraceControl_EnableEventsTracepointTreeAllLabel;
+ }
+ return super.getText(element);
+ }
+ }
+
+ /**
+ * Check state listener for the tracepoints tree.
+ */
+ final public class KernelCheckListener implements ICheckStateListener {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (event.getChecked()) {
+ if (event.getElement() instanceof KernelProviderComponent) {
+ fTracepointsViewer.setSubtreeChecked(event.getElement(), true);
+ }
+ } else {
+ if (event.getElement() instanceof KernelProviderComponent) {
+ fTracepointsViewer.setSubtreeChecked(event.getElement(), false);
+ } else {
+ ITraceControlComponent component = (ITraceControlComponent) event.getElement();
+ fTracepointsViewer.setChecked(component.getParent(), false);
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.TraceControlContentProvider;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.TraceControlLabelProvider;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderComponent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * <b><u>EnableUstEventsComposite</u></b>
+ * <p>
+ * A composite for collecting information about UST events to be enabled.
+ * </p>
+ */
+public class EnableUstEventsComposite extends Composite implements IEnableUstEvents {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ private enum GroupEnum { TRACEPOINTS, WILDCARD, LOGLEVEL };
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * A button to enable/disable the tracepoints group
+ */
+ private Button fTracepointsActivateButton;
+ /**
+ * A tree viewer for diplaying and selection of available tracepoints.
+ */
+ private CheckboxTreeViewer fTracepointsViewer;
+ /**
+ * A button to enable/disable the wildcard group
+ */
+ private Button fWildcardActivateButton;
+ /**
+ * A Text field for the event's wildcard.
+ */
+ private Text fWildcardText;
+ /**
+ * A button to enable/disable the log level group
+ */
+ private Button fLogLevelActivateButton;
+ /**
+ * A Text field for the event name for the log level enablement.
+ */
+ private Text fLogLevelEventNameText;
+ /**
+ * A Combo box for selecting the log level.
+ */
+ private CCombo fLogLevelCombo;
+ /**
+ * A button for selecting the log level (range 0 to level).
+ */
+ private Button fLogLevelButton;
+ /**
+ * A button for selecting the specified log level only.
+ */
+ private Button fLogLevelOnlyButton;
+ /**
+ * The referenced trace provider group containing the UST providers
+ * component which contains a list of available tracepoints.
+ */
+ private TraceProviderGroup fProviderGroup;
+ /**
+ * The flag indicating that tracepoints are selected.
+ */
+ private boolean fIsTracepoints;
+ /**
+ * The flag indicating that all tracepoints (across providers) are selected.
+ */
+ private boolean fIsAllTracepoints;
+ /**
+ * The list of tracepoints to be enabled.
+ */
+ private List<String> fSelectedEvents;
+ /**
+ * The flag indicating that all wildcard are selected..
+ */
+ private boolean fIsWildcard;
+ /**
+ * The wildcard if wildcard is selected.
+ */
+ private String fWildcard;
+ /**
+ *The flag indicating that all log level are selected.
+ */
+ private boolean fIsLogLevel;
+ /**
+ * The event name for the log level enablement.
+ */
+ private String fLogLevelEventName;
+ /**
+ * The type of the log level (loglevel or loglevel-only)
+ */
+ private LogLevelType fLogLevelType;
+ /**
+ * The actual selected log level.
+ */
+ private TraceLogLevel fLogLevel;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param parent - a parent composite
+ * @Param style - a compsite style
+ * @param providerGroup - the trace provider group
+ */
+ public EnableUstEventsComposite(Composite parent, int style, TraceProviderGroup providerGroup) {
+ super(parent, style);
+ fProviderGroup = providerGroup;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isTracepoints()
+ */
+ @Override
+ public boolean isTracepoints() {
+ return fIsTracepoints;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isAllTracePoints()
+ */
+ @Override
+ public boolean isAllTracePoints() {
+ return fIsAllTracepoints;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getEventNames()
+ */
+ @Override
+ public List<String> getEventNames() {
+ return new ArrayList<String>(fSelectedEvents);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isWildcard()
+ */
+ @Override
+ public boolean isWildcard() {
+ return fIsWildcard;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getWildcard()
+ */
+ @Override
+ public String getWildcard() {
+ return "\"" + fWildcard + "\""; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isLogLevel()
+ */
+ @Override
+ public boolean isLogLevel() {
+ return fIsLogLevel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevelType()
+ */
+ @Override
+ public LogLevelType getLogLevelType() {
+ return fLogLevelType;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevel()
+ */
+ @Override
+ public TraceLogLevel getLogLevel() {
+ return fLogLevel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevelEventName()
+ */
+ @Override
+ public String getLogLevelEventName() {
+ return fLogLevelEventName;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ public void createContent() {
+
+ // Tracepoints Group
+ createTracepointsGroup();
+
+ // Wildcard Group
+ createWildCardGroup();
+
+ // Log Level Group
+ createLogLevelGroup();
+
+ // Set default enablements
+ setEnablements(GroupEnum.TRACEPOINTS);
+ }
+
+ /**
+ * Validates the kernel composite input data.
+ * @return true if configured data is valid and can be retrieved.
+ */
+ public boolean isValid() {
+
+ fIsTracepoints = fTracepointsActivateButton.getSelection();
+ fIsWildcard = fWildcardActivateButton.getSelection();
+ fIsLogLevel = fLogLevelActivateButton.getSelection();
+
+ fIsAllTracepoints = fTracepointsViewer.getChecked(fProviderGroup);
+
+ Set<String> set = new HashSet<String>();
+ Object[] checkedElements = fTracepointsViewer.getCheckedElements();
+ fSelectedEvents = new ArrayList<String>();
+ for (int i = 0; i < checkedElements.length; i++) {
+ ITraceControlComponent component = (ITraceControlComponent)checkedElements[i];
+ if (!set.contains(component.getName()) && (component instanceof BaseEventComponent)) {
+ set.add(component.getName());
+ fSelectedEvents.add(component.getName());
+ }
+ }
+
+ if (fLogLevelButton.getSelection()) {
+ fLogLevelType = LogLevelType.LOGLEVEL;
+ } else if (fLogLevelOnlyButton.getSelection()) {
+ fLogLevelType = LogLevelType.LOGLEVEL_ONLY;
+ } else {
+ fLogLevelType = LogLevelType.LOGLEVEL_NONE;
+ }
+
+ // initialize log level event name string
+ fLogLevelEventName = null;
+ String temp = fLogLevelEventNameText.getText();
+ if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_InvalidLogLevelEventNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ return false;
+ }
+
+ if(!temp.matches("\\s*")) { //$NON-NLS-1$
+ fLogLevelEventName = temp;
+ }
+
+ // initialize log level event name string
+ fWildcard = null;
+ temp = fWildcardText.getText();
+ if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_\\*]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_InvalidWildcardError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ return false;
+ }
+
+ if(!temp.matches("\\s*")) { //$NON-NLS-1$
+ fWildcard = temp;
+ }
+
+ // validation successful -> call super.okPressed()
+ return true;
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Creates tracepoints group.
+ */
+ private void createTracepointsGroup() {
+ Group tpMainGroup = new Group(this, SWT.SHADOW_NONE);
+ tpMainGroup.setText(Messages.TraceControl_EnableEventsTracepointGroupName);
+ GridLayout layout = new GridLayout(2, false);
+ tpMainGroup.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ tpMainGroup.setLayoutData(data);
+
+ Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE);
+ layout = new GridLayout(1, true);
+ buttonComposite.setLayout(layout);
+ data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
+ buttonComposite.setLayoutData(data);
+
+ fTracepointsActivateButton = new Button(buttonComposite, SWT.RADIO);
+ fTracepointsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fTracepointsActivateButton.setLayoutData(data);
+ fTracepointsActivateButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setEnablements(GroupEnum.TRACEPOINTS);
+ }
+ });
+
+ Group tpGroup = new Group(tpMainGroup, SWT.SHADOW_NONE);
+ layout = new GridLayout(1, true);
+ tpGroup.setLayout(layout);
+ data = new GridData(GridData.FILL_BOTH);
+ tpGroup.setLayoutData(data);
+
+ fTracepointsViewer = new CheckboxTreeViewer(tpGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip);
+ fTracepointsViewer.setContentProvider(new UstContentProvider());
+
+ fTracepointsViewer.setLabelProvider(new UstLabelProvider());
+ fTracepointsViewer.addCheckStateListener(new UstCheckStateListener());
+
+ fTracepointsViewer.setInput(fProviderGroup.getParent());
+ fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+
+ /**
+ * Creates wildcard group.
+ */
+ private void createWildCardGroup() {
+ Group wildcardMainGroup = new Group(this, SWT.SHADOW_NONE);
+ wildcardMainGroup.setText(Messages.TraceControl_EnableEventsWildcardGroupName);
+ GridLayout layout = new GridLayout(2, false);
+ wildcardMainGroup.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ wildcardMainGroup.setLayoutData(data);
+
+ Composite buttonComposite = new Composite(wildcardMainGroup, SWT.NONE);
+ layout = new GridLayout(1, false);
+ buttonComposite.setLayout(layout);
+ data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
+ buttonComposite.setLayoutData(data);
+
+ fWildcardActivateButton = new Button(buttonComposite, SWT.RADIO);
+ fWildcardActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
+ fWildcardActivateButton.setSelection(false);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fWildcardActivateButton.setLayoutData(data);
+ fWildcardActivateButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setEnablements(GroupEnum.WILDCARD);
+ }
+ });
+
+ Group wildcardGroup = new Group(wildcardMainGroup, SWT.SHADOW_NONE);
+ layout = new GridLayout(3, true);
+ wildcardGroup.setLayout(layout);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ wildcardGroup.setLayoutData(data);
+
+ Label wildcardLabel = new Label(wildcardGroup, SWT.LEFT);
+ wildcardLabel.setText(Messages.TraceControl_EnableEventsWildcardLabel);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 1;
+ wildcardLabel.setLayoutData(data);
+
+ fWildcardText = new Text(wildcardGroup, SWT.LEFT);
+ fWildcardText.setToolTipText(Messages.TraceControl_EnableEventsWildcardTooltip);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ fWildcardText.setLayoutData(data);
+ }
+
+ /**
+ * Creates log level group.
+ */
+ private void createLogLevelGroup() {
+ Group logLevelMainGroup = new Group(this, SWT.SHADOW_NONE);
+ logLevelMainGroup.setText(Messages.TraceControl_EnableEventsLogLevelGroupName);
+ GridLayout layout = new GridLayout(2, false);
+ logLevelMainGroup.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ logLevelMainGroup.setLayoutData(data);
+
+ Composite buttonComposite = new Composite(logLevelMainGroup, SWT.NONE);
+ layout = new GridLayout(1, false);
+ buttonComposite.setLayout(layout);
+ data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
+ buttonComposite.setLayoutData(data);
+
+ fLogLevelActivateButton = new Button(buttonComposite, SWT.RADIO);
+ fLogLevelActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
+ fLogLevelActivateButton.setSelection(false);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fLogLevelActivateButton.setLayoutData(data);
+ fLogLevelActivateButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setEnablements(GroupEnum.LOGLEVEL);
+ }
+ });
+
+ Group logLevelGroup = new Group(logLevelMainGroup, SWT.SHADOW_NONE);
+ layout = new GridLayout(3, true);
+ logLevelGroup.setLayout(layout);
+ logLevelGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label logLevelEventNameLabel = new Label(logLevelGroup, SWT.LEFT);
+ logLevelEventNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel);
+
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 1;
+ logLevelEventNameLabel.setLayoutData(data);
+
+ fLogLevelEventNameText = new Text(logLevelGroup, SWT.LEFT);
+ fLogLevelEventNameText.setToolTipText(Messages.TraceControl_EnableEventsLoglevelEventNameTooltip);
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 2;
+ fLogLevelEventNameText.setLayoutData(data);
+
+ TraceLogLevel[] levels = TraceLogLevel.values();
+
+ String[] levelNames = new String[levels.length - 1];
+ int k = 0;
+ for (int i = 0; i < levels.length; i++) {
+ if (levels[i] != TraceLogLevel.LEVEL_UNKNOWN) {
+ levelNames[k++] = levels[i].getInName();
+ }
+ }
+
+ fLogLevelCombo = new CCombo(logLevelGroup, SWT.READ_ONLY);
+ fLogLevelCombo.setItems(levelNames);
+ fLogLevelCombo.setToolTipText(Messages.TraceControl_EnableEventsLogLevelTooltip);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 4;
+ fLogLevelCombo.setLayoutData(data);
+
+ fLogLevelButton = new Button(logLevelGroup, SWT.RADIO);
+ fLogLevelButton.setText(Messages.TraceControl_EnableEventsLogLevelTypeName);
+ fLogLevelButton.setToolTipText(Messages.TraceControl_EnableEventsLogLevelTypeTooltip);
+ data = new GridData(GridData.FILL_BOTH);
+ fLogLevelButton.setLayoutData(data);
+
+ fLogLevelOnlyButton = new Button(logLevelGroup, SWT.RADIO);
+ fLogLevelOnlyButton.setText(Messages.TraceControl_EnableEventsLogLevelOnlyTypeName);
+ fLogLevelOnlyButton.setToolTipText(Messages.TraceControl_EnableEventsLogLevelOnlyTypeTooltip);
+ data = new GridData(GridData.FILL_BOTH);
+ fLogLevelButton.setLayoutData(data);
+ }
+
+ /**
+ * Enable/selects widgets depending on the group specified.
+ * @param group - group to enable.
+ */
+ private void setEnablements(GroupEnum group) {
+
+ // Enable/disable trace point items
+ fTracepointsActivateButton.setSelection(group == GroupEnum.TRACEPOINTS);
+ fTracepointsViewer.getTree().setEnabled(group == GroupEnum.TRACEPOINTS);
+
+ // Enable/disable wildcard items
+ fWildcardActivateButton.setSelection(group == GroupEnum.WILDCARD);
+ fWildcardText.setEnabled(group == GroupEnum.WILDCARD);
+
+ // Enable/disable log level items
+ fLogLevelActivateButton.setSelection(group == GroupEnum.LOGLEVEL);
+ fLogLevelEventNameText.setEnabled(group == GroupEnum.LOGLEVEL);
+ fLogLevelCombo.setEnabled(group == GroupEnum.LOGLEVEL);
+ fLogLevelButton.setEnabled(group == GroupEnum.LOGLEVEL);
+ fLogLevelOnlyButton.setEnabled(group == GroupEnum.LOGLEVEL);
+ }
+
+ // ------------------------------------------------------------------------
+ // Local classes
+ // ------------------------------------------------------------------------
+ /**
+ * Content provider for the tracepoints tree.
+ */
+ final public class UstContentProvider extends TraceControlContentProvider {
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof TargetNodeComponent) {
+ List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(TraceProviderGroup.class);
+ return (ITraceControlComponent[]) children.toArray(new ITraceControlComponent[children.size()]);
+ }
+ if (parentElement instanceof TraceProviderGroup) {
+ List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(UstProviderComponent.class);
+ return (ITraceControlComponent[]) children.toArray(new ITraceControlComponent[children.size()]);
+ }
+ if (parentElement instanceof ITraceControlComponent) {
+ return ((ITraceControlComponent)parentElement).getChildren();
+ }
+ return new Object[0];
+ }
+ }
+
+ /**
+ * Content label for the tracepoints tree.
+ */
+ final public class UstLabelProvider extends TraceControlLabelProvider {
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+ @Override
+ public String getText(Object element) {
+ if ((element != null) && (element instanceof TraceProviderGroup)) {
+ return Messages.TraceControl_EnableEventsTracepointTreeAllLabel;
+ }
+
+ if ((element != null) && (element instanceof UstProviderComponent)) {
+ return Messages.TraceControl_EnableEventsTracepointTreeAllLabel + " - " + ((UstProviderComponent)element).getName(); //$NON-NLS-1$
+ }
+ return super.getText(element);
+ }
+ }
+
+ /**
+ * Check state listener for the tracepoints tree.
+ */
+ final public class UstCheckStateListener implements ICheckStateListener {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (event.getChecked()) {
+ if (event.getElement() instanceof TraceProviderGroup) {
+ fTracepointsViewer.setSubtreeChecked(event.getElement(), true);
+ }
+ if (event.getElement() instanceof UstProviderComponent) {
+ fTracepointsViewer.setSubtreeChecked(event.getElement(), true);
+ }
+ } else {
+ if (event.getElement() instanceof TraceProviderGroup) {
+ fTracepointsViewer.setSubtreeChecked(event.getElement(), true);
+ }
+ if (event.getElement() instanceof UstProviderComponent) {
+ ITraceControlComponent component = (ITraceControlComponent) event.getElement();
+ fTracepointsViewer.setSubtreeChecked(event.getElement(), false);
+ fTracepointsViewer.setChecked(component.getParent(), false);
+ } else {
+ ITraceControlComponent component = (ITraceControlComponent) event.getElement();
+ fTracepointsViewer.setChecked(component.getParent(), false);
+ fTracepointsViewer.setChecked(component.getParent().getParent(), false);
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import java.util.Arrays;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+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.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * <b><u>EnableEventsDialog</u></b>
+ * <p>
+ * Dialog box for collecting information about the events to enable.
+ * </p>
+ */
+public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The icon file for this dialog box.
+ */
+ public static final String TARGET_NEW_CONNECTION_ICON_FILE = "icons/elcl16/edit.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite = null;
+ /**
+ * The Group for the session combo box.
+ */
+ private Group fSessionsGroup = null;
+ /**
+ * The Group for the channel combo box.
+ */
+ private Group fChannelsGroup = null;
+ /**
+ * The session combo box.
+ */
+ private CCombo fSessionsCombo = null;
+ /**
+ * The channel combo box.
+ */
+ private CCombo fChannelsCombo = null;
+ /**
+ * The list of available sessions.
+ */
+ private TraceSessionComponent[] fSessions;
+ /**
+ * True for kernel, false for UST.
+ */
+ private boolean fIsKernel;
+ /**
+ * Index in session array (selected session).
+ */
+ private int fSessionIndex = 0;
+ /**
+ * The Channel where the events should be enabled.
+ */
+ private TraceChannelComponent fChannel;
+ /**
+ * List of available channels of the selected session.
+ */
+ private TraceChannelComponent[] fChannels;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor of dialog box.
+ * @param shell - the shell for the dialog box
+ */
+ public GetEventInfoDialog(Shell shell) {
+ super(shell);
+ setShellStyle(SWT.RESIZE);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#getSession()
+ */
+ @Override
+ public TraceSessionComponent getSession() {
+ return fSessions[fSessionIndex];
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#getChannel()
+ */
+ @Override
+ public TraceChannelComponent getChannel() {
+ return fChannel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IGetEventInfoDialog#setIsKernel(boolean)
+ */
+ @Override
+ public void setIsKernel(boolean isKernel) {
+ fIsKernel = isKernel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IGetEventInfoDialog#setSessions(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent[])
+ */
+ @Override
+ public void setSessions(TraceSessionComponent[] sessions) {
+ fSessions = Arrays.copyOf(sessions, sessions.length);
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.TraceControl_EnableEventsDialogTitle);
+ newShell.setImage(Activator.getDefault().loadIcon(TARGET_NEW_CONNECTION_ICON_FILE));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ // Main dialog panel
+ fDialogComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, true);
+ fDialogComposite.setLayout(layout);
+ fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fSessionsGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ fSessionsGroup.setText(Messages.TraceControl_EnableEventsSessionGroupName);
+ layout = new GridLayout(1, true);
+ fSessionsGroup.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ fSessionsGroup.setLayoutData(data);
+
+ fSessionsCombo = new CCombo(fSessionsGroup, SWT.READ_ONLY);
+ fSessionsCombo.setToolTipText(Messages.TraceControl_EnableEventsSessionsTooltip);
+ fSessionsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ String items[] = new String[fSessions.length];
+ for (int i = 0; i < items.length; i++) {
+ items[i] = String.valueOf(fSessions[i].getName());
+ }
+
+ fSessionsCombo.setItems(items);
+ fSessionsCombo.setEnabled(fSessions.length > 0);
+
+ fChannelsGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ fChannelsGroup.setText(Messages.TraceControl_EnableEventsChannelGroupName);
+ layout = new GridLayout(1, true);
+ fChannelsGroup.setLayout(layout);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fChannelsGroup.setLayoutData(data);
+
+ fChannelsCombo = new CCombo(fChannelsGroup, SWT.READ_ONLY);
+ fChannelsCombo.setToolTipText(Messages.TraceControl_EnableEventsChannelsTooltip);
+ fChannelsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fChannelsCombo.setEnabled(false);
+
+ fSessionsCombo.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ fSessionIndex = fSessionsCombo.getSelectionIndex();
+
+ if (fSessionIndex >= 0) {
+ TraceDomainComponent domain = null;
+ TraceDomainComponent[] domains = fSessions[fSessionIndex].getDomains();
+ for (int i = 0; i < domains.length; i++) {
+
+ if (domains[i].isKernel() == fIsKernel) {
+ domain = domains[i];
+ break;
+ }
+ }
+
+ 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());
+ }
+ fChannelsCombo.setItems(items);
+ fChannelsCombo.setEnabled(fChannels.length > 0);
+ } else {
+ fChannelsCombo.setItems(new String[0]);
+ fChannelsCombo.setEnabled(false);
+ fChannels = null;
+ }
+ fChannelsCombo.getParent().getParent().layout();
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ return fDialogComposite;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+
+ if (fSessionsCombo.getSelectionIndex() < 0) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_EnableEventsNoSessionError);
+ return;
+ }
+
+ fSessionIndex = fSessionsCombo.getSelectionIndex();
+
+ if ((fChannels != null) && (fChannels.length > 0) && (fChannelsCombo.getSelectionIndex() < 0)) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_EnableEventsNoChannelError);
+ return;
+ }
+
+ if ((fChannels != null) && (fChannels.length > 0)) {
+ fChannel = fChannels[fChannelsCombo.getSelectionIndex()];
+ }
+
+ super.okPressed();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * <b><u>IConfirmDialog</u></b>
+ * <p>
+ * Interface for a confirmation dialog.
+ * </p>
+ */
+public interface IConfirmDialog {
+
+ public boolean openConfirm(Shell parent, String title, String message);
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+
+/**
+ * <b><u>ICreateChannelDialog</u></b>
+ * <p>
+ * Interface for the create channel dialog when domain is known.
+ * </p>
+ */
+public interface ICreateChannelDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the configuration info for the new channel.
+ */
+ public IChannelInfo getChannelInfo();
+
+ /**
+ * Sets the domain component
+ * @param domain - the trace domain component
+ */
+ public void setDomainComponent(TraceDomainComponent domain);
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return the open return value
+ */
+ int open();
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+
+/**
+ * <b><u>ICreateChannelOnSessionDialog</u></b>
+ * <p>
+ * Interface for the create channel dialog when domain is known, i.e. dialog
+ * was opened on session level.
+ * </p>
+ */
+public interface ICreateChannelOnSessionDialog extends ICreateChannelDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return true for Kernel domain. False for UST.
+ */
+ public boolean isKernel();
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup;
+
+/**
+ * <b><u>ICreateSessionDialog</u></b>
+ * <p>
+ * Interface for create session dialog.
+ * </p>
+ */
+public interface ICreateSessionDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the session name.
+ */
+ public String getSessionName();
+
+ /**
+ * @return the session path (null for default path)
+ */
+ public String getSessionPath();
+
+ /**
+ * @return true for default location else false
+ */
+ public boolean isDefaultSessionPath();
+
+ /**
+ * Set trace session group.
+ * @param group - the session group
+ */
+ public void setTraceSessionGroup(TraceSessionGroup group);
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return the open return value
+ */
+ int open();
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup;
+
+/**
+ * <b><u>IEnableKernelEvents</u></b>
+ * <p>
+ * Interface for providing information about Kernel or UST events to be enabled.
+ * </p>
+ */
+public interface IEnableEventsDialog extends IEnableKernelEvents, IEnableUstEvents {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the session the events shall be enabled.
+ */
+ public boolean isKernel();
+
+ /**
+ * Sets the trace provider group.
+ * @param providerGroup - a trace provider group
+ */
+ public void setTraceProviderGroup(TraceProviderGroup providerGroup);
+
+ /**
+ * Sets the trace domain component.
+ * @param domain - a domain of the events (null if not known)
+ */
+ public void setTraceDomainComponent(TraceDomainComponent domain);
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return returns the open return value
+ */
+ int open();
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import java.util.List;
+
+/**
+ * <b><u>IEnableKernelEvents</u></b>
+ * <p>
+ * Interface for providing information about kernel events to be enabled.
+ * </p>
+ */
+public interface IEnableKernelEvents {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return a flag whether the tracepoints shall be configured.
+ */
+ public boolean isTracepoints();
+
+ /**
+ * @return a flag indicating whether all tracepoints shall be enabled or not.
+ */
+ public boolean isAllTracePoints();
+
+ /**
+ * @return a flag whether the syscalls shall be configured.
+ */
+ public boolean isSysCalls();
+
+ /**
+ * @return a flag indicating whether syscalls shall be enabled or not.
+ */
+ public boolean isAllSysCalls();
+
+ /**
+ * @return a list of event names to be enabled.
+ */
+ public List<String> getEventNames();
+
+ /**
+ * @return a flag whether the dynamic probe shall be configured.
+ */
+ public boolean isDynamicProbe();
+
+ /**
+ * @return event name of the dynamic probe (or null if no dynamic probe).
+ */
+ public String getProbeEventName();
+
+ /**
+ * @return the dynamic probe (or null if no dynamic probe).
+ */
+ public String getProbeName();
+
+ /**
+ * @return a flag whether the dynamic function entry/return probe shall be configured.
+ */
+ public boolean isDynamicFunctionProbe();
+
+ /**
+ * @return event name of the dynamic function entry/exit probe (or null if no dynamic probe).
+ */
+ public String getFunctionEventName();
+
+ /**
+ * @return the dynamic function entry/exit probe (or null if no dynamic probe).
+ */
+ public String getFunction();
+
+// /**
+// * @return a flag whether events using wildcards should be enabled
+// */
+// public boolean isWildcard();
+//
+// /**
+// * @return a wildcard
+// */
+// public String getWildcard();
+//
+// /**
+// * @return a flag whether events using log levels should be enabled
+// */
+// public boolean isLogLevel();
+//
+// /**
+// * @return a log level type (loglevel or loglevel-only)
+// */
+// public LogLevelType getLogLevelType();
+//
+// /**
+// * @return a log level
+// */
+// public TraceLogLevel getLogLevel();
+//
+// /**
+// * @return a event name for the log level enable action
+// */
+// public String getLogLevelEventName();
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+
+/**
+ * <b><u>IEnableKernelEvents</u></b>
+ * <p>
+ * Interface for providing information about UST events to be enabled.
+ * </p>
+ */
+public interface IEnableUstEvents {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return a flag whether the tracepoints shall be configured.
+ */
+ public boolean isTracepoints();
+
+ /**
+ * @return a flag indicating whether all tracepoints shall be enabled or not.
+ */
+ public boolean isAllTracePoints();
+
+ /**
+ * @return a list of event names to be enabled.
+ */
+ public List<String> getEventNames();
+
+ /**
+ * @return a flag whether events using wildcards should be enabled
+ */
+ public boolean isWildcard();
+
+ /**
+ * @return a wildcard
+ */
+ public String getWildcard();
+
+ /**
+ * @return a flag whether events using log levels should be enabled
+ */
+ public boolean isLogLevel();
+
+ /**
+ * @return a log level type (loglevel or loglevel-only)
+ */
+ public LogLevelType getLogLevelType();
+
+ /**
+ * @return a log level
+ */
+ public TraceLogLevel getLogLevel();
+
+ /**
+ * @return a event name for the log level enable action
+ */
+ public String getLogLevelEventName();
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * <b><u>IEnableEventsDialog</u></b>
+ * <p>
+ * Interface for a dialog box for collecting information about the events to enable.
+ * </p>
+ */
+public interface IGetEventInfoDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the session the events shall be enabled.
+ */
+ public TraceSessionComponent getSession();
+
+ /**
+ * @return the channel the events shall be enabled. Null for default channel.
+ */
+ public TraceChannelComponent getChannel();
+
+ /**
+ * Sets flag about domain.
+ * @param isKernel - true for kernel, false for UST
+ */
+ public void setIsKernel(boolean isKernel);
+
+ /**
+ * Sets available session.
+ * @param sessions - a array of available sessions.
+ */
+ public void setSessions(TraceSessionComponent[] sessions);
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return returns the open return value
+ */
+ int open();
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.rse.core.model.IHost;
+
+/**
+ * <b><u>INewConnectionDialog</u></b>
+ * <p>
+ * Interface for connection information dialog.
+ * </p>
+ */
+public interface INewConnectionDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the connection name (alias).
+ */
+ public String getConnectionName();
+
+ /**
+ * @return the host name (IP address or DNS name)
+ */
+ public String getHostName();
+
+ /**
+ * Sets the trace control root
+ * @param parent - the trace control parent
+ */
+ public void setTraceControlParent(ITraceControlComponent parent);
+
+ /**
+ * Sets the available hosts to select.
+ * @param hosts - the available hosts
+ */
+ public void setHosts(IHost[] hosts);
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return returns the open return value
+ */
+ int open();
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import java.util.Arrays;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+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.model.ITraceControlComponent;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * <b><u>NewConnectionDialog</u></b>
+ * <p>
+ * Dialog box for connection information.
+ * </p>
+ */
+public class NewConnectionDialog extends Dialog implements INewConnectionDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The icon file for this dialog box.
+ */
+ public static final String TARGET_NEW_CONNECTION_ICON_FILE = "icons/elcl16/target_add.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite = null;
+ /**
+ * The Group for the host combo box.
+ */
+ private Group fComboGroup = null;
+ /**
+ * The Group for the text input.
+ */
+ private Group fTextGroup = null;
+ /**
+ * The host combo box.
+ */
+ private CCombo fExistingHostsCombo = null;
+ /**
+ * The check box button for enabling/disabling the text input.
+ */
+ private Button fButton = null;
+ /**
+ * The text widget for the node name (alias)
+ */
+ private Text fConnectionNameText = null;
+ /**
+ * The text widget for the node address (IP or DNS name)
+ */
+ private Text fHostNameText = null;
+ /**
+ * The parent where the new node should be added.
+ */
+ private ITraceControlComponent fParent;
+ /**
+ * The node name (alias) string.
+ */
+ private String fConnectionName = null;
+ /**
+ * The node address (IP or DNS name) string.
+ */
+ private String fHostName = null;
+
+ /**
+ * Input list of existing RSE hosts available for selection.
+ */
+ private IHost[] fExistingHosts = new IHost[0];
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ public NewConnectionDialog(Shell shell) {
+ super(shell);
+ setShellStyle(SWT.RESIZE);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.INewConnectionDialog#getConnectionName()
+ */
+ @Override
+ public String getConnectionName() {
+ return fConnectionName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.INewConnectionDialog#getHostName()
+ */
+ @Override
+ public String getHostName() {
+ return fHostName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.INewConnectionDialog#setTraceControlParent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent)
+ */
+ @Override
+ public void setTraceControlParent(ITraceControlComponent parent) {
+ fParent = parent;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.INewConnectionDialog#setHosts(org.eclipse.rse.core.model.IHost[])
+ */
+ @Override
+ public void setHosts(IHost[] hosts) {
+ if (hosts != null) {
+ fExistingHosts = Arrays.copyOf(hosts, hosts.length);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.TraceControl_NewDialogTitle);
+ newShell.setImage(Activator.getDefault().loadIcon(TARGET_NEW_CONNECTION_ICON_FILE));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ // Main dialog panel
+ fDialogComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, true);
+ fDialogComposite.setLayout(layout);
+ fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ // Existing connections group
+ fComboGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ fComboGroup.setText(Messages.TraceControl_NewNodeExistingConnectionGroupName);
+ layout = new GridLayout(2, true);
+ fComboGroup.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ fComboGroup.setLayoutData(data);
+
+ fExistingHostsCombo = new CCombo(fComboGroup, SWT.READ_ONLY);
+ fExistingHostsCombo.setToolTipText(Messages.TraceControl_NewNodeComboToolTip);
+ fExistingHostsCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
+
+ String items[] = new String[fExistingHosts.length];
+ for (int i = 0; i < items.length; i++) {
+ items[i] = String.valueOf(fExistingHosts[i].getAliasName() + " - " + fExistingHosts[i].getHostName()); //$NON-NLS-1$
+ }
+
+ fExistingHostsCombo.setItems(items);
+ fExistingHostsCombo.setEnabled(fExistingHosts.length > 0);
+
+ // Node information grop
+ fTextGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ layout = new GridLayout(3, true);
+ fTextGroup.setLayout(layout);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fTextGroup.setLayoutData(data);
+
+ fButton = new Button(fTextGroup, SWT.CHECK);
+ fButton.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
+ fButton.setText(Messages.TraceControl_NewNodeEditButtonName);
+ fButton.setEnabled(fExistingHosts.length > 0);
+
+ Label connectionNameLabel = new Label(fTextGroup, SWT.RIGHT);
+ connectionNameLabel.setText(Messages.TraceControl_NewNodeConnectionNameLabel);
+ fConnectionNameText = new Text(fTextGroup, SWT.NONE);
+ fConnectionNameText.setToolTipText(Messages.TraceControl_NewNodeConnectionNameTooltip);
+ fConnectionNameText.setEnabled(fExistingHosts.length == 0);
+
+ Label hostNameLabel = new Label(fTextGroup, SWT.RIGHT);
+ hostNameLabel.setText(Messages.TraceControl_NewNodeHostNameLabel);
+ fHostNameText = new Text(fTextGroup, SWT.NONE);
+ fHostNameText.setToolTipText(Messages.TraceControl_NewNodeHostNameTooltip);
+ fHostNameText.setEnabled(fExistingHosts.length == 0);
+
+ fButton.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (fButton.getSelection()) {
+ fExistingHostsCombo.deselectAll();
+ fExistingHostsCombo.setEnabled(false);
+ fConnectionNameText.setEnabled(true);
+ fHostNameText.setEnabled(true);
+ } else {
+ fExistingHostsCombo.setEnabled(true);
+ fConnectionNameText.setEnabled(false);
+ fHostNameText.setEnabled(false);
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ fExistingHostsCombo.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ int index = fExistingHostsCombo.getSelectionIndex();
+ fConnectionNameText.setText(fExistingHosts[index].getAliasName());
+ fHostNameText.setText(fExistingHosts[index].getHostName());
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ // layout widgets
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fHostNameText.setText("666.666.666.666"); //$NON-NLS-1$
+ Point minSize = fHostNameText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ data.widthHint = minSize.x + 5;
+ data.horizontalSpan = 2;
+
+ fConnectionNameText.setLayoutData(data);
+ fHostNameText.setLayoutData(data);
+
+ fHostNameText.setText(""); //$NON-NLS-1$
+
+ return fDialogComposite;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ // Validate input data
+ fConnectionName = fConnectionNameText.getText();
+ fHostName = fHostNameText.getText();
+
+ if (!"".equals(fHostName)) { //$NON-NLS-1$
+ // If no node name is specified use the node address as name
+ if ("".equals(fConnectionName)) { //$NON-NLS-1$
+ fConnectionName = fHostName;
+ }
+ // Check if node with name already exists in parent
+ if(fParent.containsChild(fConnectionName)) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_NewDialogTitle,
+ Messages.TraceControl_AlreadyExistsError + " (" + fConnectionName + ")"); //$NON-NLS-1$//$NON-NLS-2$
+ return;
+ }
+ }
+ else {
+ return;
+ }
+ // validation successful -> call super.okPressed()
+ super.okPressed();
+ }
+}
--- /dev/null
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.ui.PlatformUI;
+
+
+public class TraceControlDialogFactory {
+
+ // ------------------------------------------------------------------------
+ // Members
+ // ------------------------------------------------------------------------
+
+ /**
+ * The factory instance.
+ */
+ private static TraceControlDialogFactory fInstance;
+
+ /**
+ * The new connection dialog reference.
+ */
+ private INewConnectionDialog fNewConnectionDialog;
+
+ /**
+ * The create channel dialog (on domain level)
+ */
+ private ICreateChannelDialog fCreateChannelDialog;
+
+ /**
+ * The create channel dialog (on session level)
+ */
+ private ICreateChannelOnSessionDialog fCreateChannelOnSessionDialog;
+
+ /**
+ * The create session dialog.
+ */
+ private ICreateSessionDialog fCreateSessionDialog;
+
+ /**
+ * The enable events dialog.
+ */
+ private IEnableEventsDialog fEnableEventsDialog;
+
+ /**
+ * The get event info dialog.
+ */
+ private IGetEventInfoDialog fGetEventInfoDialog;
+
+ /**
+ * The confirmation dialog implementation
+ */
+ private IConfirmDialog fConfirmDialog;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for R4EUIDialogFactory.
+ */
+ private TraceControlDialogFactory() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return TraceControlDialogFactory instance
+ */
+ public static TraceControlDialogFactory getInstance() {
+ if (null == fInstance) {
+ fInstance = new TraceControlDialogFactory();
+ }
+ return fInstance;
+ }
+
+ /**
+ * @return new connection dialog
+ */
+ public INewConnectionDialog getNewConnectionDialog() {
+ if (null == fNewConnectionDialog) {
+ fNewConnectionDialog = new NewConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fNewConnectionDialog;
+ }
+
+ /**
+ * Sets a new connection dialog implementation.
+ * @param newConnectionDialog - new connection dialog implementation
+ */
+ public void setNewConnectionDialog(INewConnectionDialog newConnectionDialog) {
+ fNewConnectionDialog = newConnectionDialog;
+ }
+
+ /**
+ * @return create channel dialog (on domain level)
+ */
+ public ICreateChannelDialog getCreateChannelDialog() {
+ if (null == fCreateChannelDialog) {
+ fCreateChannelDialog = new CreateChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fCreateChannelDialog;
+ }
+
+ /**
+ * Sets a create channel dialog implementation (on domain level).
+ * @param createChannelDialog - a create channel dialog implementation
+ */
+ public void setCreateChannelDialog(ICreateChannelDialog createChannelDialog) {
+ fCreateChannelDialog = createChannelDialog;
+ }
+
+ /**
+ * @return create channel dialog (on session level)
+ */
+ public ICreateChannelOnSessionDialog getCreateChannelOnSessionDialog() {
+ if (null == fCreateChannelOnSessionDialog) {
+ fCreateChannelOnSessionDialog = new CreateChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fCreateChannelOnSessionDialog;
+ }
+
+ /**
+ * Sets a create channel dialog implementation (on domain level).
+ * @param createChannelDialog - a create channel dialog implementation
+ */
+ public void setCreateChannelOnSessionDialog(ICreateChannelOnSessionDialog createChannelDialog) {
+ fCreateChannelOnSessionDialog = createChannelDialog;
+ }
+
+ /**
+ * @return create session dialog implementation
+ */
+ public ICreateSessionDialog getCreateSessionDialog() {
+ if (null == fCreateSessionDialog) {
+ fCreateSessionDialog = new CreateSessionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fCreateSessionDialog;
+ }
+
+ /**
+ * Sets a create session dialog implementation.
+ * @param createSessionDialog - a create session implementation.
+ */
+ public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog) {
+ fCreateSessionDialog = createSessionDialog;
+ }
+
+ /**
+ * @return enable events dialog implementation.
+ */
+ public IEnableEventsDialog getEnableEventsDialog() {
+ if (null == fEnableEventsDialog) {
+ fEnableEventsDialog = new EnableEventsDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fEnableEventsDialog;
+ }
+
+ /**
+ * Sets a enable events dialog implementation.
+ * @param enableEventsDialog - a enable events dialog implementation.
+ */
+ public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog) {
+ fEnableEventsDialog = enableEventsDialog;
+ }
+
+ /**
+ * @return get events info dialog implementation.
+ */
+ public IGetEventInfoDialog getGetEventInfoDialog() {
+ if (null == fGetEventInfoDialog) {
+ fGetEventInfoDialog = new GetEventInfoDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fGetEventInfoDialog;
+ }
+
+ /**
+ * Sets a get events info dialog implementation.
+ * @param getEventInfoDialog - a get events info dialog implementation
+ */
+ public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog) {
+ fGetEventInfoDialog = getEventInfoDialog;
+ }
+
+ /**
+ * @return the confirmation dialog implementation
+ */
+ public IConfirmDialog getConfirmDialog() {
+ if (null == fConfirmDialog) {
+ fConfirmDialog = new ConfirmDialog();
+ }
+ return fConfirmDialog;
+ }
+
+ /**
+ * Sets the confirmation dialog implementation
+ * @param confirmDialog
+ */
+ public void setConfirmDialog(IConfirmDialog confirmDialog) {
+ fConfirmDialog = confirmDialog;
+ }
+}
+
+
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IGetEventInfoDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.KernelProviderComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>EnableEventHandler</u></b>
+ * <p>
+ * Command handler implementation to assign events to a session and channel and enable/configure them.
+ * This is done on the trace provider level.
+ * </p>
+ */
+public class AssignEventHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The list of event components the command is to be executed on.
+ */
+ private List<BaseEventComponent> fEvents = new ArrayList<BaseEventComponent>();
+
+ /**
+ * The list of available sessions.
+ */
+ private TraceSessionComponent[] fSessions;
+
+ /**
+ * Flag for indicating Kernel or UST.
+ */
+ Boolean fIsKernel = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ // Open dialog box to retrieve the session and channel where the events should be enabled in.
+ final IGetEventInfoDialog dialog = TraceControlDialogFactory.getInstance().getGetEventInfoDialog();
+ dialog.setIsKernel(fIsKernel);
+ dialog.setSessions(fSessions);
+
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_EnableEventsJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ String errorString = null;
+ try {
+ List<String> eventNames = new ArrayList<String>();
+ // Create list of event names
+ for (Iterator<BaseEventComponent> iterator = fEvents.iterator(); iterator.hasNext();) {
+ BaseEventComponent event = (BaseEventComponent) iterator.next();
+ eventNames.add(event.getName());
+ }
+
+ TraceChannelComponent channel = dialog.getChannel();
+ if (channel == null) {
+ // enable events on default channel (which will be created by lttng-tools)
+ dialog.getSession().enableEvents(eventNames, fIsKernel, monitor);
+ } else {
+ channel.enableEvents(eventNames, monitor);
+ }
+
+ } catch (ExecutionException e) {
+ errorString = e.toString() + "\n"; //$NON-NLS-1$
+ }
+
+ // get session configuration in all cases
+ try {
+ dialog.getSession().getConfigurationFromNode(monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
+ }
+ errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
+ }
+
+ if (errorString != null) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ fEvents.clear();
+ fSessions = null;
+ fIsKernel = null;
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ // Check if one or more session are selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof BaseEventComponent) {
+ BaseEventComponent event = (BaseEventComponent) element;
+ ITraceControlComponent provider = event.getParent();
+
+ // check for kernel or UST provider
+ boolean temp = false;
+ if (provider instanceof KernelProviderComponent) {
+ temp = true;
+ } else if (provider instanceof UstProviderComponent) {
+ temp = false;
+ } else {
+ return false;
+ }
+ if (fIsKernel == null) {
+ fIsKernel = Boolean.valueOf(temp);
+ } else {
+ // don't mix events from Kernel and UST provider
+ if (fIsKernel.booleanValue() != temp) {
+ return false;
+ }
+ }
+
+ // Add BaseEventComponents
+ fEvents.add(event);
+
+ if (fSessions == null) {
+ TargetNodeComponent root = (TargetNodeComponent)event.getParent().getParent().getParent();
+ fSessions = root.getSessions();
+ }
+ }
+ }
+ }
+ return ((fEvents.size() > 0) && (fSessions != null) && (fSessions.length > 0));
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <b><u>BaseControlViewHandler</u></b>
+ * <p>
+ * Abstract Command handler implementation for all control view handlers.
+ * </p>
+ */
+abstract public class BaseControlViewHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return returns the workbench page for the Control View
+ */
+ protected IWorkbenchPage getWorkbenchPage() {
+ // Check if we are closing down
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ return null;
+ }
+
+ // Check if we are in the Project View
+ IWorkbenchPage page = window.getActivePage();
+ if (page == null) {
+ return null;
+ }
+
+ IWorkbenchPart part = page.getActivePart();
+ if (!(part instanceof ControlView)) {
+ return null;
+ }
+ return page;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.window.Window;
+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.dialogs.IEnableEventsDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <b><u>EnableEventOnSessionHandler</u></b>
+ * <p>
+ * Base command handler implementation to enable events.
+ * </p>
+ */
+abstract public class BaseEnableEventHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The session component the command is to be executed on.
+ */
+ protected TraceSessionComponent fSession = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Enables a list of events for given parameters.
+ * @param eventNames - list of event names
+ * @param isKernel - true if kernel domain else false
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ abstract public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+ /**
+ * Enables all syscall events.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ abstract public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Enables a dynamic probe.
+ * @param eventName - a event name
+ * @param isFunction - true for dynamic function entry/return probe else false
+ * @param probe - a dynamic probe information
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ abstract public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Enables events using log level
+ * @param eventName - a event name
+ * @param logLevelType - a log level type
+ * @param level - a log level
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ abstract public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * @return returns the relevant domain (null if domain is not known)
+ */
+ abstract TraceDomainComponent getDomain();
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ if (window == null) {
+ return false;
+ }
+
+ TargetNodeComponent node = fSession.getTargetNode();
+ List<ITraceControlComponent> providers = node.getChildren(TraceProviderGroup.class);
+
+ final IEnableEventsDialog dialog = TraceControlDialogFactory.getInstance().getEnableEventsDialog();
+ dialog.setTraceProviderGroup((TraceProviderGroup)providers.get(0));
+ dialog.setTraceDomainComponent(getDomain());
+
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_ChangeEventStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String errorString = null;
+
+ try {
+ // Enable tracepoint events
+ if (dialog.isTracepoints()) {
+ if (dialog.isAllTracePoints()) {
+ enableEvents(null, dialog.isKernel(), monitor);
+ } else {
+ List<String> eventNames = dialog.getEventNames();
+ if (eventNames.size() > 0) {
+ enableEvents(eventNames, dialog.isKernel(), monitor);
+ }
+ }
+ }
+
+ // Enable syscall events
+ if (dialog.isAllSysCalls()) {
+ if (dialog.isAllSysCalls()) {
+ enableSyscalls(monitor);
+ }
+ }
+
+ // Enable dynamic probe
+ if (dialog.isDynamicProbe()) {
+ if ((dialog.getProbeEventName() != null && dialog.getProbeName() != null)) {
+ enableProbe(dialog.getProbeEventName(), false, dialog.getProbeName(), monitor);
+ }
+ }
+
+ // Enable dynamic function probe
+ if (dialog.isDynamicFunctionProbe()) {
+ if ((dialog.getFunctionEventName() != null) && (dialog.getFunction() != null)) {
+ enableProbe(dialog.getFunctionEventName(), true, dialog.getFunction(), monitor);
+ }
+ }
+
+ // Enable event using a wildcard
+ if (dialog.isWildcard()) {
+ List<String> eventNames = dialog.getEventNames();
+ eventNames.add(dialog.getWildcard());
+
+ if (eventNames.size() > 0) {
+ enableEvents(eventNames, dialog.isKernel(), monitor);
+ }
+ }
+
+ // Enable events using log level
+ if (dialog.isLogLevel()) {
+ enableLogLevel(dialog.getLogLevelEventName(), dialog.getLogLevelType(), dialog.getLogLevel(), monitor);
+ }
+
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
+ }
+ errorString += e.toString() + "\n"; //$NON-NLS-1$
+ }
+
+ // get session configuration in all cases
+ try {
+ fSession.getConfigurationFromNode(monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
+ }
+ errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
+ }
+
+ if (errorString != null) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+
+ return null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>BaseNodeHandler</u></b>
+ * <p>
+ * Command handler implementation to delete a target host.
+ * </p>
+ */
+abstract public class BaseNodeHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The target node component the command is to be executed on.
+ */
+ protected TargetNodeComponent fTargetNode = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ fTargetNode = null;
+
+ // Check if the node component is selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ Object element = ((StructuredSelection) selection).getFirstElement();
+ fTargetNode = (element instanceof TargetNodeComponent) ? (TargetNodeComponent) element : null;
+ }
+ return fTargetNode != null;
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <b><u>ChangeChannelStateHandler</u></b>
+ * <p>
+ * Abstract command handler implementation to enable or disabling a trace channel.
+ * </p>
+ */
+abstract public class ChangeChannelStateHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Kernel domain component reference.
+ */
+ protected TraceDomainComponent fKernelDomain = null;
+ /**
+ * UST domain component reference.
+ */
+ protected TraceDomainComponent fUstDomain = null;
+ /**
+ * The list of kernel channel components the command is to be executed on.
+ */
+ protected List<TraceChannelComponent> fKernelChannels = new ArrayList<TraceChannelComponent>();
+ /**
+ * The list of UST channel components the command is to be executed on.
+ */
+ protected List<TraceChannelComponent> fUstChannels = new ArrayList<TraceChannelComponent>();
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the new state to set
+ */
+ abstract protected TraceEnablement getNewState();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Changes the state of the given channels.
+ * @param domain - the domain of the channels.
+ * @param channelNames - a list of channel names
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ abstract protected void changeState(TraceDomainComponent domain, List<String> channelNames, IProgressMonitor monitor) throws ExecutionException;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ if (window == null) {
+ return false;
+ }
+
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String errorString = null;
+
+ TraceSessionComponent session = null;
+
+ try {
+ if (fKernelDomain != null) {
+ session = (TraceSessionComponent)fKernelDomain.getParent();
+ List<String> channelNames = new ArrayList<String>();
+ for (Iterator<TraceChannelComponent> iterator = fKernelChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channelNames.add(channel.getName());
+ }
+
+ changeState(fKernelDomain, channelNames, monitor);
+
+ for (Iterator<TraceChannelComponent> iterator = fKernelChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channel.setState(getNewState());
+ }
+ }
+
+ if (fUstDomain != null) {
+ if (session == null) {
+ session = (TraceSessionComponent)fUstDomain.getParent();
+ }
+
+ List<String> channelNames = new ArrayList<String>();
+ for (Iterator<TraceChannelComponent> iterator = fUstChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channelNames.add(channel.getName());
+ }
+
+ changeState(fUstDomain, channelNames, monitor);
+
+ for (Iterator<TraceChannelComponent> iterator = fUstChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channel.setState(getNewState());
+ }
+ }
+ } catch (ExecutionException e) {
+ errorString = e.toString() + "\n"; //$NON-NLS-1$
+ }
+
+ // In all cases notify listeners
+ session.fireComponentChanged(session);
+
+ if (errorString != null) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
+ }
+
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ reset();
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ // Check if one or more session are selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ String sessionName = null;
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+
+ if (element instanceof TraceChannelComponent) {
+
+ // Add only TraceChannelComponents that are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) element;
+ if (sessionName == null) {
+ sessionName = String.valueOf(channel.getSessionName());
+ }
+
+ // Enable command only for channels of same session
+ if (!sessionName.equals(channel.getSessionName())) {
+ reset();
+ break;
+ }
+
+ if ((channel.getState() != getNewState())) {
+ if (channel.isKernel()) {
+ fKernelChannels.add(channel);
+ if (fKernelDomain == null) {
+ fKernelDomain = (TraceDomainComponent) channel.getParent();
+ }
+ } else {
+ fUstChannels.add(channel);
+ if (fUstDomain == null) {
+ fUstDomain = (TraceDomainComponent) channel.getParent();
+ }
+ }
+ }
+ }
+ }
+ }
+ return fKernelChannels.size() + fUstChannels.size() > 0;
+ }
+
+ /**
+ * Reset members
+ */
+ private void reset() {
+ fKernelDomain = null;
+ fUstDomain = null;
+ fKernelChannels.clear();
+ fUstChannels.clear();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <b><u>EnableChannelHandler</u></b>
+ * <p>
+ * Base Command handler implementation to enable or disabling a trace channel.
+ * </p>
+ */
+abstract public class ChangeEventStateHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Channel component reference.
+ */
+ protected TraceChannelComponent fChannel = null;
+ /**
+ * The list of kernel channel components the command is to be executed on.
+ */
+ protected List<TraceEventComponent> fEvents = new ArrayList<TraceEventComponent>();
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the new state to set
+ */
+ abstract protected TraceEnablement getNewState();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Change the state
+ * @param channel - channel of events to be enabled
+ * @param eventNames - list event names
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ abstract protected void changeState(TraceChannelComponent channel, List<String> eventNames, IProgressMonitor monitor) throws ExecutionException;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ if (window == null) {
+ return false;
+ }
+
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String errorString = null;
+
+ TraceSessionComponent session = null;
+
+ try {
+ boolean isAll = false;
+ if (fChannel != null) {
+ session = fChannel.getSession();
+ List<String> eventNames = new ArrayList<String>();
+ for (Iterator<TraceEventComponent> iterator = fEvents.iterator(); iterator.hasNext();) {
+ // Enable/disable all selected channels which are disabled
+ TraceEventComponent event = (TraceEventComponent) iterator.next();
+
+ // Workaround for wildcard handling in lttng-tools
+ if ("*".equals(event.getName())) { //$NON-NLS-1$
+ isAll = true;
+ } else {
+ eventNames.add(event.getName());
+ }
+ }
+ if (isAll) {
+ changeState(fChannel, null, monitor);
+ }
+
+ if (eventNames.size() > 0) {
+ changeState(fChannel, eventNames, monitor);
+ }
+
+ for (Iterator<TraceEventComponent> iterator = fEvents.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceEventComponent ev = (TraceEventComponent) iterator.next();
+ ev.setState(getNewState());
+ }
+ }
+ } catch (ExecutionException e) {
+ errorString = e.toString() + "\n"; //$NON-NLS-1$
+ }
+
+ // In all cases notify listeners
+ session.fireComponentChanged(session);
+
+ if (errorString != null) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
+ }
+
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ reset();
+
+ // Check if one or more session are selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ String sessionName = null;
+ String channelName = null;
+
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+
+ if (element instanceof TraceEventComponent) {
+
+ TraceEventComponent event = (TraceEventComponent) element;
+ if (sessionName == null) {
+ sessionName = String.valueOf(event.getSessionName());
+ }
+
+ if (fChannel == null) {
+ fChannel = (TraceChannelComponent)event.getParent();
+ }
+
+ if (channelName == null) {
+ channelName = event.getChannelName();
+ }
+
+ // Enable command only for events of same session, same channel and domain
+ if ((!sessionName.equals(event.getSessionName())) ||
+ (!channelName.equals(event.getChannelName())) ||
+ (fChannel.isKernel() != event.isKernel())) {
+ reset();
+ break;
+ }
+
+ if ((event.getState() != getNewState())) {
+ fEvents.add(event);
+ }
+ }
+ }
+ }
+ return fEvents.size() > 0;
+ }
+
+ /**
+ * Reset members
+ */
+ private void reset() {
+ fChannel = null;
+ fEvents.clear();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <b><u>ChangeSessionStateHandler</u></b>
+ * <p>
+ * Abstract command handler implementation to start or stop one or more trace sessions.
+ * </p>
+ */
+abstract public class ChangeSessionStateHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The list of session components the command is to be executed on.
+ */
+ protected List<TraceSessionComponent> fSessions = new ArrayList<TraceSessionComponent>();
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return new required state.
+ */
+ abstract TraceSessionState getNewState();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /**
+ * Performs the state change on given session.
+ * @param session - a session which state is to be changed
+ * @param monitor - a progress monitor
+ */
+ abstract public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ if (window == null) {
+ return false;
+ }
+
+ Job job = new Job(Messages.TraceControl_StartSessionJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ for (Iterator<TraceSessionComponent> iterator = fSessions.iterator(); iterator.hasNext();) {
+
+ // Start all selected sessions
+ TraceSessionComponent session = (TraceSessionComponent) iterator.next();
+ changeState(session, monitor);
+
+ // Set Session state
+ session.setSessionState(getNewState());
+ session.fireComponentChanged(session);
+ }
+ } catch (ExecutionException e) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ fSessions.clear();
+
+ // Check if one or more session are selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceSessionComponent) {
+ // Add only TraceSessionComponents that are inactive and not destroyed
+ TraceSessionComponent session = (TraceSessionComponent) element;
+ if ((session.getSessionState() != getNewState()) && (!session.isDestroyed())) {
+ fSessions.add((TraceSessionComponent)element);
+ }
+ }
+ }
+ }
+ return fSessions.size() > 0;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TargetNodeState;
+
+/**
+ * <b><u>ConnectHandler</u></b>
+ * <p>
+ * Command handler implementation to connect to a target host.
+ * </p>
+ */
+public class ConnectHandler extends BaseNodeHandler {
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ fTargetNode.connect();
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ return (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED));
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>CreateChannelOnDomainHandler</u></b>
+ * <p>
+ * Command handler implementation to create a trace channel for known domain.
+ * </p>
+ */
+public class CreateChannelOnDomainHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The the domain component the command is to be executed on.
+ */
+ private TraceDomainComponent fDomain;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ // Get channel information from user
+ final ICreateChannelDialog dialog = TraceControlDialogFactory.getInstance().getCreateChannelDialog();
+ dialog.setDomainComponent(fDomain);
+
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String errorString = null;
+
+ List<String> channelNames = new ArrayList<String>();
+ channelNames.add(dialog.getChannelInfo().getName());
+
+ try {
+ fDomain.enableChannels(channelNames, dialog.getChannelInfo(), monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
+ }
+ errorString += e.toString() + "\n"; //$NON-NLS-1$
+ }
+
+ // get session configuration in all cases
+ try {
+ fDomain.getConfigurationFromNode(monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
+ }
+ errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
+ }
+
+ if (errorString != null) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ job.setUser(true);
+ job.schedule();
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+ fDomain = null;
+
+ // Check if one domain is selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceDomainComponent) {
+ TraceDomainComponent domain = (TraceDomainComponent) element;
+ TraceSessionComponent session = (TraceSessionComponent) domain.getParent();
+ // Add only TraceDomainComponent whose TraceSessionComponent parent is inactive and not destroyed
+ if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
+ fDomain = domain;
+ }
+ }
+ }
+ }
+ return fDomain != null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelOnSessionDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>CreateChannelOnSessionHandler</u></b>
+ * <p>
+ * Command handler implementation to create a trace channel for unknown domain
+ * (on session level).
+ * </p>
+ */
+public class CreateChannelOnSessionHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The session component the command is to be executed on.
+ */
+ private TraceSessionComponent fSession = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ final ICreateChannelOnSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateChannelOnSessionDialog();
+
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String errorString = null;
+
+ List<String> channelNames = new ArrayList<String>();
+ TraceDomainComponent newDomain = new TraceDomainComponent("dummy", fSession); //$NON-NLS-1$
+ channelNames.add(dialog.getChannelInfo().getName());
+ newDomain.setIsKernel(dialog.isKernel());
+
+ try {
+ newDomain.enableChannels(channelNames, dialog.getChannelInfo(), monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
+ }
+ errorString += e.toString() + "\n"; //$NON-NLS-1$
+ }
+
+ // get session configuration in all cases
+ try {
+ fSession.getConfigurationFromNode(monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
+ }
+ errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
+ }
+
+ if (errorString != null) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ fSession = null;
+
+ // Check if one session is selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceSessionComponent) {
+ // Add only TraceSessionComponents that are inactive and not destroyed
+ TraceSessionComponent session = (TraceSessionComponent) element;
+ if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
+ fSession = session;
+ }
+ }
+ }
+ }
+ return fSession != null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>CreateSessionHandler</u></b>
+ * <p>
+ * Command handler implementation to create a trace session.
+ * </p>
+ */
+public class CreateSessionHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The trace session group the command is to be executed on.
+ */
+ private TraceSessionGroup fSessionGroup = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ // Open dialog box for the node name and address
+ ICreateSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateSessionDialog();
+ dialog.setTraceSessionGroup(fSessionGroup);
+
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ final String sessionName = dialog.getSessionName();
+ final String sessionPath = dialog.isDefaultSessionPath() ? null : dialog.getSessionPath();
+
+ Job job = new Job(Messages.TraceControl_CreateSessionJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ fSessionGroup.createSession(sessionName, sessionPath, monitor);
+ } catch (ExecutionException e) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ fSessionGroup = null;
+
+ // Check if the session group project is selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ Object element = ((StructuredSelection) selection).getFirstElement();
+ fSessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
+ }
+ return fSessionGroup != null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TargetNodeState;
+
+/**
+ * <b><u>DeleteHandler</u></b>
+ * <p>
+ * Command handler implementation to delete a target host.
+ * </p>
+ */
+public class DeleteHandler extends BaseNodeHandler {
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ITraceControlComponent root = fTargetNode.getParent();
+ fTargetNode.removeAllChildren();
+ root.removeChild(fTargetNode);
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ return (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED));
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IConfirmDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <b><u>DestroySessionHandler</u></b>
+ * <p>
+ * Command handler implementation to destroy one or more trace sessions.
+ * </p>
+ */
+public class DestroySessionHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The list of session components the command is to be executed on.
+ */
+ private List<TraceSessionComponent> fSessions = new ArrayList<TraceSessionComponent>();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ if (window == null) {
+ return false;
+ }
+ // Get user confirmation
+ IConfirmDialog dialog = TraceControlDialogFactory.getInstance().getConfirmDialog();
+ if (!dialog.openConfirm(window.getShell(),
+ Messages.TraceControl_DestroyConfirmationTitle,
+ Messages.TraceControl_DestroyConfirmationMessage)) {
+
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_DestroySessionJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ // Make a copy of the list of sessions to avoid ConcurrentModificationException when iterating
+ // over fSessions, since fSessions is modified in another thread triggered by the tree viewer refresh
+ // after removing a session.
+ TraceSessionComponent[] sessions = (TraceSessionComponent[])fSessions.toArray(new TraceSessionComponent[fSessions.size()]);
+
+ for (int i = 0; i < sessions.length; i++) {
+ // Destroy all selected sessions
+ TraceSessionComponent session = sessions[i];
+ TraceSessionGroup sessionGroup = (TraceSessionGroup)session.getParent();
+ sessionGroup.destroySession(session, monitor);
+ }
+ } catch (ExecutionException e) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+ fSessions.clear();
+
+ // Check if one or more session are selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceSessionComponent) {
+ // Add only TraceSessionComponents that are inactive and not destroyed
+ TraceSessionComponent session = (TraceSessionComponent) element;
+ if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
+ fSessions.add((TraceSessionComponent)element);
+ }
+ }
+ }
+ }
+ return fSessions.size() > 0;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+
+/**
+ * <b><u>DisableChannelHandler</u></b>
+ * <p>
+ * Command handler implementation to disable one or more trace channels per session and domain.
+ * </p>
+ */
+public class DisableChannelHandler extends ChangeChannelStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseChangeChannelStateHandler#getNewState()
+ */
+ @Override
+ protected TraceEnablement getNewState() {
+ return TraceEnablement.DISABLED;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseChangeChannelStateHandler#changeState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void changeState(TraceDomainComponent domain, List<String> channelNames, IProgressMonitor monitor) throws ExecutionException {
+ domain.disableChannels(channelNames, monitor);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+
+/**
+ * <b><u>DisableEventHandler</u></b>
+ * <p>
+ * Command handler implementation to disable one or more events session, domain and channel.
+ * </p>
+ */
+public class DisableEventHandler extends ChangeEventStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.ChangeEventStateHandler#getNewState()
+ */
+ @Override
+ protected TraceEnablement getNewState() {
+ return TraceEnablement.DISABLED;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.ChangeEventStateHandler#changeState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void changeState(TraceChannelComponent channel, List<String> eventNames, IProgressMonitor monitor) throws ExecutionException{
+ channel.disableEvent(eventNames, monitor);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TargetNodeState;
+
+/**
+ * <b><u>DisconnectHandler</u></b>
+ * <p>
+ * Command handler implementation to disconnect from a target host.
+ * </p>
+ */
+public class DisconnectHandler extends BaseNodeHandler {
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ fTargetNode.disconnect();
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ return super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.CONNECTED);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+
+/**
+ * <b><u>EnableChannelHandler</u></b>
+ * <p>
+ * Command handler implementation to enable one or more trace channels per session and domain.
+ * </p>
+ */
+public class EnableChannelHandler extends ChangeChannelStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseChangeChannelStateHandler#getNewState()
+ */
+ @Override
+ protected TraceEnablement getNewState() {
+ return TraceEnablement.ENABLED;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseChangeChannelStateHandler#changeState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void changeState(TraceDomainComponent domain, List<String> channelNames, IProgressMonitor monitor) throws ExecutionException {
+ domain.enableChannels(channelNames, null, monitor);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+
+/**
+ * <b><u>EnableEventHandler</u></b>
+ * <p>
+ * Command handler implementation to enable one or more events session, domain and channel.
+ * </p>
+ */
+public class EnableEventHandler extends ChangeEventStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.ChangeEventStateHandler#getNewState()
+ */
+ @Override
+ protected TraceEnablement getNewState() {
+ return TraceEnablement.ENABLED;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.ChangeEventStateHandler#changeState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void changeState(TraceChannelComponent channel, List<String> eventNames, IProgressMonitor monitor) throws ExecutionException{
+ channel.enableEvents(eventNames, monitor);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>EnableEventOnChannelHandler</u></b>
+ * <p>
+ * Command handler implementation to enable events for a known channel.
+ * </p>
+ */
+public class EnableEventOnChannelHandler extends BaseEnableEventHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The channel component the command is to be executed on.
+ */
+ private TraceChannelComponent fChannel = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ fChannel.enableEvents(eventNames, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
+ fChannel.enableSyscalls(monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ fChannel.enableProbe(eventName, isFunction, probe, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ fChannel.enableLogLevel(eventName, logLevelType, level, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
+ */
+ @Override
+ public TraceDomainComponent getDomain() {
+ return (TraceDomainComponent) fChannel.getParent();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ fChannel = null;
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceChannelComponent) {
+ // Add only if corresponding TraceSessionComponents is inactive and not destroyed
+ TraceChannelComponent channel = (TraceChannelComponent) element;
+ TraceSessionComponent session = channel.getSession();
+ if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
+ fChannel = channel;
+ fSession = session;
+ }
+ }
+ }
+ }
+ return fChannel != null;
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>EnableEventOnDomainHandler</u></b>
+ * <p>
+ * Command handler implementation to enable events for a known domain and default channel 'channel0'
+ * (which will be created if doesn't exist).
+ * </p>
+ */
+public class EnableEventOnDomainHandler extends BaseEnableEventHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The domain component the command is to be executed on.
+ */
+ private TraceDomainComponent fDomain = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ fDomain.enableEvents(eventNames, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
+ fDomain.enableSyscalls(monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ fDomain.enableProbe(eventName, isFunction, probe, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ fDomain.enableLogLevel(eventName, logLevelType, level, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
+ */
+ @Override
+ public TraceDomainComponent getDomain() {
+ return fDomain;
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ fDomain = null;
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceDomainComponent) {
+ // Add only if corresponding TraceSessionComponents is inactive and not destroyed
+ TraceDomainComponent domain = (TraceDomainComponent) element;
+ TraceSessionComponent session = domain.getSession();
+ if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
+ fDomain = domain;
+ fSession = session;
+ }
+ }
+ }
+ }
+ return fDomain != null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>EnableEventOnSessionHandler</u></b>
+ * <p>
+ * Command handler implementation to enable events for a known session and default channel 'channel0'
+ * (which will be created if doesn't exist).
+ * </p>
+ */
+public class EnableEventOnSessionHandler extends BaseEnableEventHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ //-------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ fSession.enableEvents(eventNames, isKernel, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
+ fSession.enableSyscalls(monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ fSession.enableProbe(eventName, isFunction, probe, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ fSession.enableLogLevel(eventName, logLevelType, level, monitor);
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
+ */
+ @Override
+ public TraceDomainComponent getDomain() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ fSession = null;
+
+ // Check if one session is selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceSessionComponent) {
+ // Add only if corresponding TraceSessionComponents is inactive and not destroyed
+ TraceSessionComponent session = (TraceSessionComponent) element;
+ if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
+ fSession = session;
+ }
+ }
+ }
+ }
+ return fSession != null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.INewConnectionDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <b><u>NewConnectionHandler</u></b>
+ * <p>
+ * Command handler for creation new connection for trace control.
+ * </p>
+ */
+public class NewConnectionHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * 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.
+ */
+ private ITraceControlComponent fRoot = null;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ assert (fRoot != null);
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ return false;
+ }
+
+ 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 = registry.getHostsBySystemType(sysType);
+
+ // Open dialog box for the node name and address
+ final INewConnectionDialog dialog = TraceControlDialogFactory.getInstance().getNewConnectionDialog();
+ dialog.setTraceControlParent(fRoot);
+ dialog.setHosts(hosts);
+
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ String hostName = dialog.getConnectionName();
+ String hostAddress = dialog.getHostName();
+
+ // get the singleton RSE registry
+ IHost host = null;
+
+ for (int i = 0; i < hosts.length; i++) {
+ if (hosts[i].getAliasName().equals(hostName)) {
+ host = hosts[i];
+ break;
+ }
+ }
+
+ if (host == null) {
+ // if there's no host then we will create it
+ try {
+ // create the host object as an SSH Only connection
+ host = registry.createHost(
+ sysType, //System Type Name
+ hostName, //Connection name
+ hostAddress, //IP Address
+ "Connection to Host"); //description //$NON-NLS-1$
+ }
+ catch (Exception e) {
+ MessageDialog.openError(window.getShell(),
+ Messages.TraceControl_EclipseCommandFailure,
+ Messages.TraceControl_NewNodeCreationFailure + " (" + hostName + ", " + hostAddress + ")" + ":\n" + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ return null;
+ }
+ }
+
+ if (host != null) {
+ // successful creation of host
+ TargetNodeComponent node = null;
+ if (!fRoot.containsChild(hostName)) {
+ node = new TargetNodeComponent(hostName, fRoot, host);
+ fRoot.addChild(node);
+ }
+ else {
+ node = (TargetNodeComponent)fRoot.getChild(hostName);
+ }
+
+ node.connect();
+ }
+ return null;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ fRoot = null;
+
+ // no need to verify part because it has been already done in getWorkbenchPage()
+ IWorkbenchPart part = page.getActivePart();
+ fRoot = ((ControlView) part).getTraceControlRoot();
+
+ return (fRoot != null);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.Iterator;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TargetNodeState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>RefreshHandler</u></b>
+ * <p>
+ * Command handler implementation to refresh node configuration.
+ * </p>
+ */
+public class RefreshHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The node component reference.
+ */
+ private TargetNodeComponent fNode;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ fNode.refresh();
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ fNode = null;
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ // Check if one or more session are selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceControlComponent) {
+ TraceControlComponent component = (TraceControlComponent) element;
+ boolean isConnected = component.getTargetNodeState() == TargetNodeState.CONNECTED;
+ if (isConnected) {
+ while ((component != null) && component.getClass() != TargetNodeComponent.class) {
+ component = (TraceControlComponent) component.getParent();
+ }
+ if (component != null) {
+ fNode = (TargetNodeComponent) component;
+ }
+ }
+ }
+ }
+ }
+ return fNode != null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * <b><u>StartHandler</u></b>
+ * <p>
+ * Command handler implementation to start one or more trace sessions.
+ * </p>
+ */
+public class StartHandler extends ChangeSessionStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.ChangeSessionStateHandler#getNewState()
+ */
+ @Override
+ public TraceSessionState getNewState() {
+ return TraceSessionState.ACTIVE;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.ChangeSessionStateHandler#changeState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
+ session.startSession(monitor);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * <b><u>StopHandler</u></b>
+ * <p>
+ * Command handler implementation to stop one or more trace sessions.
+ * </p>
+ */
+public class StopHandler extends ChangeSessionStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.ChangeSessionStateHandler#getNewState()
+ */
+ @Override
+ public TraceSessionState getNewState() {
+ return TraceSessionState.INACTIVE;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.ChangeSessionStateHandler#changeState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
+ session.stopSession(monitor);
+ }
+}
--- /dev/null
+TraceControl_ConnectionFailure=Connecting to host failed
+TraceControl_DisconnectionFailure=Disconnection to host failed
+TraceControl_ExecutionCancelled=Command Execution cancelled
+TraceControl_ExecutionFailure=Command Execution failed
+TraceControl_ExecutionTimeout=Command Execution timed-out
+TraceControl_ShellNotConnected=Command shell not connected
+TraceControl_CommandShellError=Could not create HostShellProcessAdapter
+TraceControl_CommandError=Command failed! Command:
+TraceControl_UnexpectedCommnadOutputFormat=Unexpected command output
+TraceControl_UnexpectedNameError=Unexpected session name returned
+TraceControl_UnexpectedPathError=Unexpected session path returned
+
+# Commands
+TraceControl_ListSessionFailure=List sessions failed
+TraceControl_RetrieveNodeConfigurationJob=Retrieving Target Node Configuration...
+TraceControl_EclipseCommandFailure=Command failed
+TraceControl_NewNodeCreationFailure=Creation of new connection failed
+TraceControl_CreateSessionJob=Creating Session...
+
+TraceControl_DestroySessionJob=Destroying Session...
+TraceControl_DestroyConfirmationTitle=Destroy Confirmation
+TraceControl_DestroyConfirmationMessage=Do you want to delete all selected sessions?
+
+TraceControl_StartSessionJob=Starting Session...
+TraceControl_StopSessionJob=Stopping Session...
+
+TraceControl_ChangeChannelStateJob=Changing State of Channels...
+TraceControl_ChangeEventStateJob=Changing State of Events...
+
+TraceControl_EnableEventsJob=Enabling Events...
+TraceControl_EnableEventsFailure=Enable Events failed
+TraceControl_DisableEventsJob=Disabling Events...
+
+# Dialogs
+TraceControl_NewDialogTitle=New Connection
+TraceControl_NewNodeExistingConnectionGroupName=Existing Connections
+TraceControl_NewNodeEditButtonName=Edit connection information
+TraceControl_NewNodeComboToolTip=List of existing connections (connection name - host name)
+TraceControl_NewNodeConnectionNameLabel=Connection Name
+TraceControl_NewNodeConnectionNameTooltip=Alias to be displayed for node to connect to.
+TraceControl_NewNodeHostNameLabel=Host Name
+TraceControl_NewNodeHostNameTooltip=IP Address or DNS name of node to connect to.
+TraceControl_AlreadyExistsError=Node name already exists in Control View
+
+TraceControl_CreateSessionDialogTitle=Create Session
+TraceControl_CreateSessionNameLabel=Session Name
+TraceControl_CreateSessionNameTooltip=The name of the session to be created.
+TraceControl_CreateSessionPathLabel=Session Path
+TraceControl_CreateSessionPathTooltip=The session path (keep empty for default location)
+TraceControl_InvalidSessionNameError=The session name is invalid
+TraceControl_SessionAlreadyExistsError=The session name already exists
+TraceControl_SessionPathAlreadyExistsError=Session path already exists
+TraceControl_InvalidSessionPathError=The session path is invalid
+TraceControl_FileSubSystemError=File subsystem error in session creation dialog.
+
+TraceControl_EnableChannelDialogTitle=Enable Channel
+TraceControl_EnableChannelNameLabel=Channel Name
+TraceControl_EnableChannelNameTooltip=The name of the channel to be enabled.
+TraceControl_EnableChannelSubBufferSizeTooltip=The sub-buffers size of the channel.
+TraceControl_EnableChannelNbSubBuffersTooltip=The number of sub-buffers of the channel.
+TraceControl_EnableChannelSwitchTimerTooltip=The switch timer interval in usec.
+TraceControl_EnableChannelReadTimerTooltip=The switch timer interval in usec.
+TraceControl_EnableChannelOutputTypeTooltip=The output type of the channel.
+TraceControl_EnableChannelOverwriteModeTooltip=Select for overwrite mode (Flight recorder mode).
+
+TraceControl_InvalidChannelNameError=The channel name is invalid or empty
+TraceControl_ChannelAlreadyExistsError=Channel already exists
+
+TraceControl_EnableEventsDialogTitle=Enable Events
+TraceControl_EnableEventsSessionGroupName=Session List
+TraceControl_EnableEventsChannelGroupName=Channel List
+TraceControl_EnableEventsSessionsTooltip=List of available sessions.
+TraceControl_EnableEventsChannelsTooltip=List of available channels of selected session.\nIf no channel is available default channel will be created.
+TraceControl_EnableEventsNoSessionError=No session from session list is selected.
+TraceControl_EnableEventsNoChannelError=No channel from channel list is selected.
+
+TraceControl_EnableGroupSelectionName=Select
+TraceControl_EnableEventsTracepointGroupName=Tracepoint Events
+TraceControl_EnableEventsTracepointTreeTooltip=List of available kernel tracepoint events
+TraceControl_EnableEventsTracepointTreeAllLabel=All
+TraceControl_EnableEventsSyscallName=All Syscalls
+TraceControl_EnableEventsSyscallTooltip=Enable all Syscalls
+TraceControl_EnableEventsProbeGroupName=Dynamic Probe
+TraceControl_EnableEventsEventNameLabel=Event Name
+TraceControl_EnableEventsProbeEventNameTooltip=The name of the event for enabling a dynamic probe
+TraceControl_EnableEventsProbeNameLabel=Probe
+TraceControl_EnableEventsProbeNameTooltip=[addr | symbol | symbol+offset]\nAddr and offset can be octal (0NNN...),\ndecimal (NNN...) or hexadecimal (0xNNN...)
+TraceControl_EnableEventsFucntionGroupName=Dynamic Function Entry/Return Probe
+TraceControl_EnableEventsFunctionEventNameTooltip=The name of the event for enabling a dynamic function entry/return probe
+TraceControl_EnableEventsFunctionNameLabel=Function
+
+TraceControl_EnableEventsWildcardGroupName=Wildcard
+TraceControl_EnableEventsWildcardLabel=Wildcard
+TraceControl_EnableEventsWildcardTooltip=The wild card string of event names
+TraceControl_EnableEventsLogLevelGroupName=Log Level
+TraceControl_EnableEventsLogLevelTypeName=loglevel
+TraceControl_EnableEventsLogLevelTypeTooltip=The tracepoint log level range from 0 to loglevel
+TraceControl_EnableEventsLogLevelOnlyTypeName=loglevel-only
+TraceControl_EnableEventsLogLevelOnlyTypeTooltip=The tracepoint log level (only this loglevel)
+TraceControl_EnableEventsLogLevelTooltip=The available log levels
+TraceControl_EnableEventsLoglevelEventNameTooltip=Event name for enabling log levels
+
+TraceControl_InvalidProbeNameError=The probe name is invalid
+TraceControl_InvalidWildcardError=The wild card name is invalid
+TraceControl_InvalidLogLevelEventNameError=The event name for log level is invalid
+
+# Tree structure strings
+TraceControl_KernelDomainDisplayName=Kernel
+TraceControl_UstGlobalDomainDisplayName=UST global
+TraceControl_UstDisplayName=UST
+TraceControl_AllSessionsDisplayName=Sessions
+TraceControl_SessionDisplayName=Session
+TraceControl_DomainDisplayName=Domain
+TraceControl_ChannelDisplayName=Channel
+TraceControl_EventDisplayName=Event
+TraceControl_ProviderDisplayName=Provider
+TraceControl_KernelProviderDisplayName=Kernel
+
+# Property names
+TraceControl_SessionNamePropertyName=Session Name
+TraceControl_EventNamePropertyName=Event Name
+TraceControl_EventTypePropertyName=Event Type
+TraceControl_LogLevelPropertyName=Log Level
+TraceControl_StatePropertyName=State
+TraceControl_DomainNamePropertyName=Domain Name
+TraceControl_ChannelNamePropertyName=Channel Name
+TraceControl_OverwriteModePropertyName=Overwrite Mode
+TraceControl_SubBufferSizePropertyName=Sub Buffer Size
+TraceControl_NbSubBuffersPropertyName=Number of Sub Buffers
+TraceControl_SwitchTimerPropertyName=Switch Timer Interval
+TraceControl_ReadTimerPropertyName=Read Timer Interval
+TraceControl_OutputTypePropertyName=Output Type
+TraceControl_HostNamePropertyName=Connection Name
+TraceControl_HostAddressPropertyName=Host Name
+TraceControl_SessionPathPropertyName=Session Path
+TraceControl_ProviderNamePropertyName=Provider Name
+TraceControl_ProcessIdPropertyName=Process ID
+TraceControl_ProbeAddressPropertyName=Address
+TraceControl_ProbeOffsetPropertyName=Offset
+TraceControl_ProbeSymbolPropertyName=Symbol
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>IBaseEventInfo</u></b>
+ * <p>
+ * Interface for retrieval of basic trace event information.
+ * </p>
+ */
+public interface IBaseEventInfo extends ITraceInfo {
+
+ /**
+ * @return the trace event type
+ */
+ public TraceEventType getEventType();
+
+ /**
+ * Sets the trace event type to the given type
+ * @param type - type to set
+ */
+ public void setEventType(TraceEventType type);
+
+ /**
+ * Sets the trace event type to the type specified by the given name.
+ * @param typeName - event type name
+ */
+ public void setEventType(String typeName);
+
+ /**
+ * @return the trace event log level
+ */
+ public TraceLogLevel getLogLevel();
+
+ /**
+ * Sets the trace event log level to the given level
+ * @param level - event log level to set
+ */
+ public void setLogLevel(TraceLogLevel level);
+
+ /**
+ * Sets the trace event log level to the level specified by the given name.
+ * @param levelName - event log level name
+ */
+ public void setLogLevel(String levelName);
+
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+import java.util.List;
+
+/**
+ * <b><u>IChannelInfo</u></b>
+ * <p>
+ * Interface for retrieval of trace channel information.
+ * </p>
+ */
+public interface IChannelInfo extends ITraceInfo {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Default value for overwrite mode.
+ */
+ public final static boolean DEFAULT_OVERWRITE_MODE = false;
+ /**
+ * Default value for sub-buffer size for a UST channel.
+ */
+ public final static long DEFAULT_SUB_BUFFER_SIZE_UST = 4096L;
+ /**
+ * Default value for sub-buffer size for a Kernel channel.
+ */
+ public final static long DEFAULT_SUB_BUFFER_SIZE_KERNEL = 262144L;
+ /**
+ * Default value for number of sub-buffer a UST channel.
+ */
+ public final static int DEFAULT_NUMBER_OF_SUB_BUFFERS_UST = 8;
+ /**
+ * Default value for number of sub-buffer a Kernel channel.
+ */
+ public final static int DEFAULT_NUMBER_OF_SUB_BUFFERS_KERNEL = 4;
+ /**
+ * Default value for number of the switch timer interval.
+ */
+ public final static long DEFAULT_SWITCH_TIMER = 0;
+ /**
+ * Default value for number of the read timer interval.
+ */
+ public final static long DEFAULT_READ_TIMER = 200;
+
+ /**
+ * @return the overwrite mode value.
+ */
+ public boolean isOverwriteMode();
+ /**
+ * Sets the overwrite mode value to the given mode.
+ * @param mode - mode to set.
+ */
+ public void setOverwriteMode(boolean mode);
+
+ /**
+ * @return the sub-buffer size.
+ */
+ public long getSubBufferSize();
+ /**
+ * Sets the sub-buffer size to the given value.
+ * @param bufferSize - size to set to set.
+ */
+ public void setSubBufferSize(long bufferSize);
+
+ /**
+ * @return the number of sub-buffers.
+ */
+ public int getNumberOfSubBuffers();
+ /**
+ * Sets the number of sub-buffers to the given value.
+ * @param numberOfSubBuffers - value to set.
+ */
+ public void setNumberOfSubBuffers(int numberOfSubBuffers);
+
+ /**
+ * @return the switch timer interval.
+ */
+ public long getSwitchTimer();
+ /**
+ * Sets the switch timer interval to the given value.
+ * @param timer - timer value to set.
+ */
+ public void setSwitchTimer(long timer);
+
+ /**
+ * @return the read timer interval.
+ */
+ public long getReadTimer();
+ /**
+ * Sets the read timer interval to the given value.
+ * @param timer - timer value to set..
+ */
+ public void setReadTimer(long timer);
+
+ /**
+ * @return the output type.
+ */
+ public String getOutputType();
+ /**
+ * Sets the output type to the given value.
+ * @param type - type to set.
+ */
+ public void setOutputType(String type);
+
+ /**
+ * @return the channel state (enabled or disabled).
+ */
+ public TraceEnablement getState();
+ /**
+ * Sets the channel state (enablement) to the given value.
+ * @param state - state to set.
+ */
+ public void setState(TraceEnablement state);
+ /**
+ * Sets the channel state (enablement) to the value specified by the given name.
+ * @param stateName - state to set.
+ */
+ public void setState(String stateName);
+
+ /**
+ * @return all event information as array.
+ */
+ public IEventInfo[] getEvents();
+ /**
+ * Sets the event information specified by given list.
+ * @param events - all event information to set.
+ */
+ public void setEvents(List<IEventInfo> events);
+ /**
+ * Adds a single event information.
+ * @param event - event information to add.
+ */
+ public void addEvent(IEventInfo event);
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+import java.util.List;
+
+/**
+ * <b><u>IDomainInfo</u></b>
+ * <p>
+ * Interface for retrieval of trace domain information.
+ * </p>
+ */
+
+public interface IDomainInfo extends ITraceInfo {
+
+ /**
+ * @return information about all channels
+ */
+ public IChannelInfo[] getChannels();
+
+ /**
+ * Sets the channel information specified by given list.
+ * @param channels - all channel information to set.
+ */
+ public void setChannels(List<IChannelInfo> channels);
+
+ /**
+ * Adds a single channel information.
+ * @param channel - channel information to add.
+ */
+ public void addChannel(IChannelInfo channel);
+
+ /**
+ * @return true if domain is kernel, false for UST
+ */
+ public boolean isKernel();
+
+ /**
+ * Sets whether domain is Kernel domain or UST
+ * @param isKernel true for kernel, false for UST
+ */
+ public void setIsKernel(boolean isKernel);
+
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>IEventInfo</u></b>
+ * <p>
+ * Interface for retrieval of trace event information.
+ * </p>
+ */
+public interface IEventInfo extends IBaseEventInfo {
+
+ /**
+ * @return the event state (enabled or disabled).
+ */
+ public TraceEnablement getState();
+
+ /**
+ * Sets the event state (enablement) to the given value.
+ * @param state - state to set.
+ */
+ public void setState(TraceEnablement state);
+
+ /**
+ * Sets the event state (enablement) to the value specified by the given name.
+ * @param stateName - state to set.
+ */
+ public void setState(String stateName);
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>IProbeEventInfo</u></b>
+ * <p>
+ * Interface for retrieval of probe event information.
+ * </p>
+ */
+public interface IProbeEventInfo extends IEventInfo {
+
+ /**
+ * @return the address of the probe. (null if not used)
+ */
+ public String getAddress();
+
+ /**
+ * Sets the address of the probe.
+ * @param address - a address (null if not used)
+ */
+ public void setAddress(String address);
+
+ /**
+ * @return the offset applied to the symbol (null if not used).
+ */
+ public String getOffset();
+
+ /**
+ * Sets the offset applied to the symbol.
+ * @param offset - a offset ((null if not used)
+ */
+ public void setOffset(String offset);
+
+ /**
+ * @return the symbol name. ((null if not used))
+ */
+ public String getSymbol();
+
+ /**
+ * Sets the symbol name.
+ * @param symbol - a symbol name ((null if not used))
+ */
+ public void setSymbol(String symbol);
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+import java.util.List;
+
+/**
+ * <b><u>ISessionInfo</u></b>
+ * <p>
+ * Interface for retrieval of trace session information.
+ * </p>
+ */
+public interface ISessionInfo extends ITraceInfo {
+
+ /**
+ * @return the session state state (active or inactive).
+ */
+ public TraceSessionState getSessionState();
+ /**
+ * Sets the session state to the given value.
+ * @param state - state to set.
+ */
+ public void setSessionState(TraceSessionState state);
+
+ /**
+ * Sets the event state to the value specified by the given name.
+ * @param stateName - state to set.
+ */
+ public void setSessionState(String stateName);
+
+ /**
+ * @return path string where session is located.
+ */
+ public String getSessionPath();
+
+ /**
+ * Sets the path string (where session is located) to the given value.
+ * @param path - session path to set.
+ */
+ public void setSessionPath(String path);
+
+ /**
+ * @return all domain information as array.
+ */
+ public IDomainInfo[] getDomains();
+
+ /**
+ * Sets all domain information specified by given list.
+ * @param domains - all domain information to set.
+ */
+ public void setDomains(List<IDomainInfo> domains);
+
+ /**
+ * Adds a single domain information.
+ * @param domain - domain information to add.
+ */
+ public void addDomain(IDomainInfo domainInfo);
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * <b><u>ITraceControlComponent</u></b>
+ * <p>
+ * Interface for trace control components that can be displayed in the
+ * trace control tree viewer.
+ * </p>
+ */
+public interface ITraceControlComponent extends IAdaptable {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the name of the component
+ */
+ public String getName();
+ /**
+ * Sets the name of the component to the given value.
+ * @param name - name to set
+ */
+ public void setName(String name);
+
+ /**
+ * @return the image representing the component.
+ */
+ public Image getImage();
+ /**
+ * Sets the image path of the component.
+ * @param path - path to the image location
+ */
+ public void setImage(String path);
+ /**
+ * Sets the image the component.
+ * @param image - image to the image location
+ */
+ public void setImage(Image image);
+
+ /**
+ * @return tool tip with information about the component.
+ */
+ public String getToolTip();
+ /**
+ * Sets the tool tip with information about the component.
+ * @param toolTip - the tool tip to set.
+ */
+ public void setToolTip(String toolTip);
+
+ /**
+ * @return the node's connection state
+ */
+ public TargetNodeState getTargetNodeState();
+ /**
+ * Sets the node's connection state.
+ * @param state - the state to set
+ */
+ public void setTargetNodeState(TargetNodeState state);
+
+ /**
+ * @return returns the parent component.
+ */
+ public ITraceControlComponent getParent();
+ /**
+ * Sets the parent component.
+ * @param parent - the parent to set.
+ */
+ public void setParent(ITraceControlComponent parent);
+
+ /**
+ * @return the children components
+ */
+ public ITraceControlComponent[] getChildren();
+ /**
+ * Sets the children components.
+ * @param children - the children to set.
+ */
+ public void setChildren(List<ITraceControlComponent> children);
+ /**
+ * Returns the child component with given name.
+ * @param name - name of child to find.
+ * @return child component or null.
+ */
+ public ITraceControlComponent getChild(String name);
+ /**
+ * Gets children for given class type.
+ * @param clazz - a class type to get
+ * @return list of trace control components matching given class type.
+ */
+ public List<ITraceControlComponent> getChildren(Class<? extends ITraceControlComponent> clazz);
+
+ /**
+ * @return the LTTng control service implementation.
+ */
+ public ILttngControlService getControlService();
+
+ /**
+ * Sets the LTTng control service implementation.
+ * @param service - the service to set.
+ */
+ public void setControlService(ILttngControlService service);
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Dispose any resource.
+ */
+ public void dispose();
+
+ /**
+ * Adds a child component.
+ * @param component - child to add.
+ */
+ public void addChild(ITraceControlComponent component);
+
+ /**
+ * Removes the given child component.
+ * @param component - the child to remove.
+ */
+ public void removeChild(ITraceControlComponent component);
+
+ /**
+ * Removes all children.
+ */
+ public void removeAllChildren();
+
+ /**
+ * Checks if child with given name exists.
+ * @param name - child name to search for.
+ * @return - true if exists else false.
+ */
+ public boolean containsChild(String name);
+
+ /**
+ * Checks for children.
+ * @return true if one or more children exist else false
+ */
+ public boolean hasChildren();
+
+ /**
+ * Adds a component listener for notification of component changes.
+ * @param listener - listener interface implementation to add.
+ */
+ public void addComponentListener(ITraceControlComponentChangedListener listener);
+
+ /**
+ * Removes a component listener for notification of component changes.
+ * @param listener - listener interface implementation to remove.
+ */
+ public void removeComponentListener(ITraceControlComponentChangedListener listener);
+
+ /**
+ * Notifies listeners about the addition of a child.
+ * @param parent - the parent where the child was added.
+ * @param component - the child that was added.
+ */
+ public void fireComponentAdded(ITraceControlComponent parent, ITraceControlComponent component);
+
+ /**
+ * Notifies listeners about the removal of a child.
+ * @param parent - the parent where the child was removed.
+ * @param component - the child that was removed.
+ */
+ public void fireComponentRemoved(ITraceControlComponent parent, ITraceControlComponent component);
+
+ /**
+ * Notifies listeners about the change of a component.
+ * @param component - the component that was changed.
+ */
+ public void fireComponentChanged(ITraceControlComponent component);
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>ITraceControlComponentChangedListener</u></b>
+ * <p>
+ * Listener interface a class can implement to be notified about changes
+ * of components
+ * </p>
+ */
+public interface ITraceControlComponentChangedListener {
+ /**
+ * Interface for notifications about the addition of a component.
+ * @param parent - the parent where the child was added.
+ * @param component - the child that was added.
+ */
+ public void componentAdded(ITraceControlComponent parent, ITraceControlComponent component);
+
+ /**
+ * Interface for notifications about the removal of a child.
+ * @param parent - the parent where the child was removed.
+ * @param component - the child that was removed.
+ */
+ public void componentRemoved(ITraceControlComponent parent, ITraceControlComponent component);
+ /**
+ * NInterface for notifications about the change of a component.
+ * @param component - the component that was changed.
+ */
+ public void componentChanged(ITraceControlComponent component);
+}
+
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>ITraceInfo</u></b>
+ * <p>
+ * Interface for retrieve trace comon information.
+ * </p>
+ */
+
+public interface ITraceInfo {
+ /**
+ * @return the name of the information element.
+ */
+ public String getName();
+
+ /**
+ * Sets the name of the information element.
+ * @param name
+ */
+ public void setName(String name);
+
+ /**
+ * @return a formated (readable) String with content.
+ */
+ public String formatString();
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+import java.util.List;
+
+/**
+ * <b><u>IUstProviderInfo</u></b>
+ * <p>
+ * Interface for retrieval of UST provider information.
+ * </p>
+ */
+public interface IUstProviderInfo extends ITraceInfo {
+
+ /**
+ * @return the process ID of the UST provider.
+ */
+ public int getPid();
+
+ /**
+ * Sets the process ID of the UST provider to the given value.
+ * @param pid - process ID to set
+ */
+ public void setPid(int pid);
+
+ /**
+ * @return all event information as array.
+ */
+ public IBaseEventInfo[] getEvents();
+
+ /**
+ * Sets the event information specified by given list.
+ * @param events - all event information to set.
+ */
+ public void setEvents(List<IBaseEventInfo> events);
+
+ /**
+ * Adds a single event information.
+ * @param event - event information to add.
+ */
+ public void addEvent(IBaseEventInfo event);
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ *********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>LogLevelType</u></b>
+ * <p>
+ * Type of log Level enumeration.
+ * </p>
+ */
+public enum LogLevelType {
+
+ // ------------------------------------------------------------------------
+ // Enum definition
+ // ------------------------------------------------------------------------
+ LOGLEVEL, // range of log levels [0,logLevel]
+ LOGLEVEL_ONLY, // single log level
+ LOGLEVEL_NONE; // no log level
+};
+
+
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>TargetNodeState</u></b>
+ * <p>
+ * Enumeration for the node connection state.
+ * </p>
+ */
+public enum TargetNodeState {
+ DISCONNECTED,
+ DISCONNECTING,
+ CONNECTED,
+ CONNECTING;
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>TraceEnablement</u></b>
+ * <p>
+ * Enumeration for enabled/disabled states.
+ * </p>
+ */
+public enum TraceEnablement {
+
+ // ------------------------------------------------------------------------
+ // Enum definition
+ // ------------------------------------------------------------------------
+ DISABLED("disabled"), //$NON-NLS-1$
+ ENABLED("enabled"); //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Name of enum
+ */
+ private final String fInName;
+
+ // ------------------------------------------------------------------------
+ // Constuctors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Private constructor
+ * @param name the name of state
+ */
+ private TraceEnablement(String name) {
+ fInName = name;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return state name
+ */
+ public String getInName() {
+ return fInName;
+ }
+};
+
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>TraceEventType</u></b>
+ * <p>
+ * Trace event type enumeration.
+ * </p>
+ */
+public enum TraceEventType {
+ TRACEPOINT("tracepoint"), //$NON-NLS-1$
+ SYSCALL("syscall"), //$NON-NLS-1$
+ PROBE("probe"), //$NON-NLS-1$
+ UNKNOWN("unknown"); //$NON-NLS-1$
+
+ private final String fInName;
+
+ private TraceEventType(String name) {
+ fInName = name;
+ }
+
+ public String getInName() {
+ return fInName;
+ }
+};
+
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ *********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>TraceLogLevels</u></b>
+ * <p>
+ * Log Level enumeration.
+ * </p>
+ */
+@SuppressWarnings("nls")
+public enum TraceLogLevel {
+
+ // ------------------------------------------------------------------------
+ // Enum definition
+ // ------------------------------------------------------------------------
+ TRACE_EMERG("TRACE_EMERG"), // 0
+ TRACE_ALERT("TRACE_ALERT"), // 1
+ TRACE_CRIT("TRACE_CRIT"), // 2
+ TRACE_ERR("TRACE_ERR"), // 3
+ TRACE_WARNING("TRACE_WARNING"), // 4
+ TRACE_NOTICE("TRACE_NOTICE"), // 5
+ TRACE_INFO("TRACE_INFO"), // 6
+ TRACE_DEBUG_SYSTEM("TRACE_DEBUG_SYSTEM"), // 7
+ TRACE_DEBUG_PROGRAM("TRACE_DEBUG_PROGRAM"), // 8
+ TRACE_DEBUG_PROCESS("TRACE_DEBUG_PROCESS"), // 9
+ TRACE_DEBUG_MODULE("TRACE_DEBUG_MODULE"), // 10
+ TRACE_DEBUG_UNIT("TRACE_DEBUG_UNIT"), // 11
+ TRACE_DEBUG_FUNCTION("TRACE_DEBUG_FUNCTION"), //12
+ TRACE_DEBUG_LINE("TRACE_DEBUG_LINE"), //13
+ TRACE_DEBUG("TRACE_DEBUG"), // 14
+ LEVEL_UNKNOWN("LEVEL_UNKNOWN"); // 15
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Name of enum.
+ */
+ private final String fInName;
+
+ // ------------------------------------------------------------------------
+ // Constuctors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Private constructor
+ * @param name the name of state
+ */
+ private TraceLogLevel(String name) {
+ fInName = name;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return state name
+ */
+ public String getInName() {
+ return fInName;
+ }
+};
+
+
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ *********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model;
+
+/**
+ * <b><u>TraceSessionState</u></b>
+ * <p>
+ * Session state enumeration.
+ * </p>
+ */
+public enum TraceSessionState {
+
+ // ------------------------------------------------------------------------
+ // Enum definition
+ // ------------------------------------------------------------------------
+ INACTIVE("inactive"), //$NON-NLS-1$
+ ACTIVE("active"); //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Name of enum.
+ */
+ private final String fInName;
+
+ // ------------------------------------------------------------------------
+ // Constuctors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Private constructor
+ * @param name the name of state
+ */
+ private TraceSessionState(String name) {
+ fInName = name;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return state name
+ */
+ public String getInName() {
+ return fInName;
+ }
+};
+
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BaseEventPropertySource;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * <b><u>BaseEventComponent</u></b>
+ * <p>
+ * Implementation of the base trace event component.
+ * </p>
+ */
+public class BaseEventComponent extends TraceControlComponent {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * 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.
+ */
+ private IBaseEventInfo fEventInfo;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ * @param parent - the parent of this component.
+ */
+ public BaseEventComponent(String name, ITraceControlComponent parent) {
+ super(name, parent);
+ setImage(TRACE_EVENT_ICON_FILE_ENABLED);
+ fEventInfo = new EventInfo(name);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * Sets the event information.
+ * @param eventInfo - the event info to set.
+ */
+ 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 void setEventType(String typeName) {
+ fEventInfo.setEventType(typeName);
+ }
+
+ /**
+ * @return the trace event log level
+ */
+ public TraceLogLevel getLogLevel() {
+ return fEventInfo.getLogLevel();
+ }
+
+ /**
+ * 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
+ */
+ public void setLogLevel(String levelName) {
+ fEventInfo.setLogLevel(levelName);
+ }
+
+ /*
+ * (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.
+ */
+ public TargetNodeComponent getTargetNode() {
+ return (TargetNodeComponent) getParent().getParent();
+ }
+
+ /**
+ * @return if provider kernel or UST
+ */
+ public boolean isKernel() {
+ return getParent() instanceof KernelProviderComponent;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+
+/**
+* <b><u>BaseEventInfo</u></b>
+* <p>
+* Implementation of the basic trace event interface (IEventInfo) to store event
+* related data.
+* </p>
+*/
+public class BaseEventInfo extends TraceInfo implements IBaseEventInfo {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The trace event type.
+ */
+ private TraceEventType fEventType = TraceEventType.UNKNOWN;
+ /**
+ * The trace log level.
+ */
+ private TraceLogLevel fLogLevel = TraceLogLevel.TRACE_DEBUG;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - name of base event
+ */
+ public BaseEventInfo(String name) {
+ super(name);
+ }
+
+ /**
+ * Copy constructor
+ * @param other - the instance to copy
+ */
+ public BaseEventInfo(BaseEventInfo other) {
+ super(other);
+ fEventType = other.fEventType;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#getEventType()
+ */
+ @Override
+ public TraceEventType getEventType() {
+ return fEventType;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#setEventType(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType)
+ */
+ @Override
+ public void setEventType(TraceEventType type) {
+ fEventType = type;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#setEventType(java.lang.String)
+ */
+ @Override
+ public void setEventType(String typeName) {
+ if(TraceEventType.TRACEPOINT.getInName().equals(typeName)) {
+ fEventType = TraceEventType.TRACEPOINT;
+ } else if(TraceEventType.SYSCALL.getInName().equals(typeName)) {
+ fEventType = TraceEventType.SYSCALL;
+ } else if (TraceEventType.PROBE.getInName().equals(typeName)) {
+ fEventType = TraceEventType.PROBE;
+ } else {
+ fEventType = TraceEventType.UNKNOWN;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#getLogLevel()
+ */
+ @Override
+ public TraceLogLevel getLogLevel() {
+ return fLogLevel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#setLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel)
+ */
+ @Override
+ public void setLogLevel(TraceLogLevel level) {
+ fLogLevel = level;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#setLogLevel(java.lang.String)
+ */
+ @Override
+ public void setLogLevel(String levelName) {
+ if(TraceLogLevel.TRACE_EMERG.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_EMERG;
+ } else if(TraceLogLevel.TRACE_ALERT.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_ALERT;
+ } else if(TraceLogLevel.TRACE_CRIT.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_CRIT;
+ } else if(TraceLogLevel.TRACE_ERR.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_ERR;
+ } else if(TraceLogLevel.TRACE_WARNING.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_WARNING;
+ } else if(TraceLogLevel.TRACE_NOTICE.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_NOTICE;
+ } else if(TraceLogLevel.TRACE_INFO.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_INFO;
+ } else if(TraceLogLevel.TRACE_DEBUG_SYSTEM.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_DEBUG_SYSTEM;
+ } else if(TraceLogLevel.TRACE_DEBUG_PROGRAM.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_DEBUG_PROGRAM;
+ } else if(TraceLogLevel.TRACE_DEBUG_PROCESS.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_DEBUG_PROCESS;
+ } else if(TraceLogLevel.TRACE_DEBUG_MODULE.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_DEBUG_MODULE;
+ } else if(TraceLogLevel.TRACE_DEBUG_UNIT.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_DEBUG_UNIT;
+ } else if(TraceLogLevel.TRACE_DEBUG_FUNCTION.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_DEBUG_FUNCTION;
+ } else if(TraceLogLevel.TRACE_DEBUG_LINE.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_DEBUG_LINE;
+ } else if(TraceLogLevel.TRACE_DEBUG.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.TRACE_DEBUG;
+ } else if(TraceLogLevel.LEVEL_UNKNOWN.getInName().equals(levelName)) {
+ fLogLevel = TraceLogLevel.LEVEL_UNKNOWN;
+ } else {
+ fLogLevel = TraceLogLevel.TRACE_DEBUG;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ // ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)");
+ output.append("\n ");
+ output.append(getName());
+ if (fLogLevel != TraceLogLevel.LEVEL_UNKNOWN) {
+ output.append(" (loglevel: ");
+ output.append(fLogLevel.getInName());
+ output.append(" (");
+ output.append(fLogLevel.ordinal());
+ output.append("))");
+ }
+ output.append(" (type: ");
+ output.append(fEventType.getInName());
+ output.append(")");
+ return output.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fEventType == null) ? 0 : (fEventType.ordinal() + 1));
+ result = prime * result + ((fLogLevel == null) ? 0 : (fLogLevel.ordinal() + 1));
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ BaseEventInfo other = (BaseEventInfo) obj;
+ if (fEventType != other.fEventType) {
+ return false;
+ }
+ if (fLogLevel != other.fLogLevel) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuffer output = new StringBuffer();
+ output.append("[BaseEventInfo(");
+ output.append(super.toString());
+ output.append(",type=");
+ output.append(fEventType);
+ output.append(",level=");
+ output.append(fLogLevel);
+ output.append(")]");
+ return output.toString();
+ }
+
+
+
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+
+/**
+ * <b><u>ChannelInfo</u></b>
+ * <p>
+ * Implementation of the trace channel interface (IChannelInfo) to store channel
+ * related data.
+ * </p>
+ */
+public class ChannelInfo extends TraceInfo implements IChannelInfo {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The overwrite mode of the channel.
+ */
+ private boolean fOverwriteMode;
+ /**
+ * The sub-buffer size of the channel.
+ */
+ private long fSubBufferSize;
+ /**
+ * The number of sub-buffers of the channel.
+ */
+ private int fNumberOfSubBuffers;
+ /**
+ * The switch timer interval of the channel.
+ */
+ private long fSwitchTimer;
+ /**
+ * The read timer interval of the channel.
+ */
+ private long fReadTimer;
+ /**
+ * The Output type of the channel.
+ */
+ private String fOutputType = ""; //$NON-NLS-1$
+ /**
+ * The channel enable state.
+ */
+ private TraceEnablement fState = TraceEnablement.DISABLED;
+ /**
+ * The events information of the channel.
+ */
+ private List<IEventInfo> fEvents = new ArrayList<IEventInfo>();
+
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - name channel
+ */
+ public ChannelInfo(String name) {
+ super(name);
+ }
+
+ /**
+ * Copy constructor
+ * @param other - the instance to copy
+ */
+ public ChannelInfo(ChannelInfo other) {
+ super(other);
+ fOverwriteMode = other.fOverwriteMode;
+ fSubBufferSize = other.fSubBufferSize;
+ fNumberOfSubBuffers = other.fNumberOfSubBuffers;
+ fSwitchTimer = other.fSwitchTimer;
+ fReadTimer = other.fReadTimer;
+ fOutputType = (other.fOutputType == null ? null : String.valueOf(other.fOutputType));
+ fState = other.fState;
+ for (Iterator<IEventInfo> iterator = other.fEvents.iterator(); iterator.hasNext();) {
+ IEventInfo event = iterator.next();
+ if (event instanceof EventInfo) {
+ fEvents.add(new EventInfo((EventInfo)event));
+ } else {
+ fEvents.add(event);
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getOverwriteMode()
+ */
+ @Override
+ public boolean isOverwriteMode() {
+ return fOverwriteMode;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setOverwriteMode(boolean)
+ */
+ @Override
+ public void setOverwriteMode(boolean mode) {
+ fOverwriteMode = mode;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getSubBufferSize()
+ */
+ @Override
+ public long getSubBufferSize() {
+ return fSubBufferSize;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setSubBufferSize(long)
+ */
+ @Override
+ public void setSubBufferSize(long bufferSize) {
+ fSubBufferSize = bufferSize;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getNumberOfSubBuffers()
+ */
+ @Override
+ public int getNumberOfSubBuffers() {
+ return fNumberOfSubBuffers;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setNumberOfSubBuffers(int)
+ */
+ @Override
+ public void setNumberOfSubBuffers(int numberOfSubBuffers) {
+ fNumberOfSubBuffers = numberOfSubBuffers;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getSwitchTimer()
+ */
+ @Override
+ public long getSwitchTimer() {
+ return fSwitchTimer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setSwitchTimer(long)
+ */
+ @Override
+ public void setSwitchTimer(long timer) {
+ fSwitchTimer = timer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getReadTimer()
+ */
+ @Override
+ public long getReadTimer() {
+ return fReadTimer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setReadTimer(long)
+ */
+ @Override
+ public void setReadTimer(long timer) {
+ fReadTimer = timer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getOutputType()
+ */
+ @Override
+ public String getOutputType() {
+ return fOutputType;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setOutputType(java.lang.String)
+ */
+ @Override
+ public void setOutputType(String type) {
+ fOutputType = type;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getState()
+ */
+ @Override
+ public TraceEnablement getState() {
+ return fState;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement)
+ */
+ @Override
+ public void setState(TraceEnablement state) {
+ fState = state;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setState(java.lang.String)
+ */
+ @Override
+ public void setState(String stateName) {
+ fState = TraceEnablement.ENABLED;
+ if (TraceEnablement.DISABLED.getInName().equals(stateName)) {
+ fState = TraceEnablement.DISABLED;
+ } else if (TraceEnablement.ENABLED.getInName().equals(stateName)) {
+ fState = TraceEnablement.ENABLED;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getEvents()
+ */
+ @Override
+ public IEventInfo[] getEvents() {
+ return fEvents.toArray(new IEventInfo[fEvents.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setEvents(java.util.List)
+ */
+ @Override
+ public void setEvents(List<IEventInfo> events) {
+ for (Iterator<IEventInfo> iterator = events.iterator(); iterator.hasNext();) {
+ IEventInfo eventInfo = (IEventInfo) iterator.next();
+ fEvents.add(eventInfo);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#addEvent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo)
+ */
+ @Override
+ public void addEvent(IEventInfo channel) {
+ fEvents.add(channel);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ //- channel0: [enabled]
+ output.append("\n- ");
+ output.append(getName());
+ output.append(": [");
+ output.append(getState().getInName());
+ output.append("]\n");
+ // Attributes:
+ output.append("\n Attributes:\n");
+ // overwrite mode: 0
+ output.append(" overwrite mode: ");
+ output.append(isOverwriteMode() ? "1" : "0");
+ // subbufers size: 262144
+ output.append("\n subbufers size: ");
+ output.append(getSubBufferSize());
+ // number of subbufers: 4
+ output.append("\n number of subbufers: ");
+ output.append(getNumberOfSubBuffers());
+ // switch timer interval: 0
+ output.append("\n switch timer interval: ");
+ output.append(getSwitchTimer());
+ // read timer interval: 200
+ output.append("\n read timer interval: ");
+ output.append(getReadTimer());
+ // output: splice()
+ output.append("\n output: ");
+ output.append(getOutputType());
+ output.append("\n\n");
+
+ output.append(" Events:");
+ if (fEvents.isEmpty()) {
+ output.append("\n None");
+ } else {
+ for (Iterator<IEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
+ IEventInfo event = (IEventInfo) iterator.next();
+ output.append(event.formatString());
+ }
+ }
+ output.append("\n");
+
+ return output.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fEvents == null) ? 0 : fEvents.hashCode());
+ result = prime * result + fNumberOfSubBuffers;
+ result = prime * result + ((fOutputType == null) ? 0 : fOutputType.hashCode());
+ result = prime * result + (fOverwriteMode ? 1231 : 1237);
+ result = prime * result + (int) (fReadTimer ^ (fReadTimer >>> 32));
+ result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
+ result = prime * result + (int) (fSubBufferSize ^ (fSubBufferSize >>> 32));
+ result = prime * result + (int) (fSwitchTimer ^ (fSwitchTimer >>> 32));
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ChannelInfo other = (ChannelInfo) obj;
+ if (fEvents == null) {
+ if (other.fEvents != null) {
+ return false;
+ }
+ } else if (!fEvents.equals(other.fEvents)) {
+ return false;
+ }
+ if (fNumberOfSubBuffers != other.fNumberOfSubBuffers) {
+ return false;
+ }
+ if (fOutputType == null) {
+ if (other.fOutputType != null) {
+ return false;
+ }
+ } else if (!fOutputType.equals(other.fOutputType)) {
+ return false;
+ }
+ if (fOverwriteMode != other.fOverwriteMode) {
+ return false;
+ }
+ if (fReadTimer != other.fReadTimer) {
+ return false;
+ }
+ if (fState != other.fState) {
+ return false;
+ }
+ if (fSubBufferSize != other.fSubBufferSize) {
+ return false;
+ }
+ if (fSwitchTimer != other.fSwitchTimer) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuffer output = new StringBuffer();
+ output.append("[ChannelInfo(");
+ output.append(super.toString());
+ output.append(",State=");
+ output.append(fState);
+ output.append(",OverwriteMode=");
+ output.append(fOverwriteMode);
+ output.append(",SubBuffersSize=");
+ output.append(fSubBufferSize);
+ output.append(",NumberOfSubBuffers=");
+ output.append(fNumberOfSubBuffers);
+ output.append(",SwitchTimer=");
+ output.append(fSwitchTimer);
+ output.append(",ReadTimer=");
+ output.append(fReadTimer);
+ output.append(",output=");
+ output.append(fOutputType);
+ output.append(",Events=");
+ if (fEvents.isEmpty()) {
+ output.append("None");
+ } else {
+ for (Iterator<IEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
+ IEventInfo event = (IEventInfo) iterator.next();
+ output.append(event.toString());
+ }
+ }
+ output.append(")]");
+ return output.toString();
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
+
+/**
+ * <b><u>DomainInfo</u></b>
+ * <p>
+ * Implementation of the trace domain interface (IDomainInfo) to store domain
+ * related data.
+ * </p>
+ */
+public class DomainInfo extends TraceInfo implements IDomainInfo {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The channels information of the domain.
+ */
+ private List<IChannelInfo> fChannels = new ArrayList<IChannelInfo>();
+ private boolean fIsKernel = false;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - name of domain
+ */
+ public DomainInfo(String name) {
+ super(name);
+ }
+
+ /**
+ * Copy constructor
+ * @param other - the instance to copy
+ */
+ public DomainInfo(DomainInfo other) {
+ super(other);
+ for (int i = 0; i < other.fChannels.size(); i++) {
+ if (other.fChannels.get(i) instanceof ChannelInfo) {
+ fChannels.add(new ChannelInfo((ChannelInfo)other.fChannels.get(i)));
+ } else {
+ fChannels.add(other.fChannels.get(i));
+ }
+ }
+ fIsKernel = other.fIsKernel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#isKernel()
+ */
+ @Override
+ public boolean isKernel() {
+ return fIsKernel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#setIsKernel(boolean)
+ */
+ @Override
+ public void setIsKernel(boolean isKernel) {
+ fIsKernel = isKernel;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#getChannels()
+ */
+ @Override
+ public IChannelInfo[] getChannels() {
+ return fChannels.toArray(new IChannelInfo[fChannels.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#setChannels(java.util.List)
+ */
+ @Override
+ public void setChannels(List<IChannelInfo> channels) {
+ for (Iterator<IChannelInfo> iterator = channels.iterator(); iterator.hasNext();) {
+ IChannelInfo channelInfo = (IChannelInfo) iterator.next();
+ fChannels.add(channelInfo);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#addChannel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo)
+ */
+ @Override
+ public void addChannel(IChannelInfo channel) {
+ fChannels.add(channel);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ //=== Domain: Kernel ===
+ output.append("\n=== Domain: ");
+ output.append(getName());
+ output.append(" ===\n");
+ output.append("\n");
+ // Channels:
+ output.append("Channels:\n");
+ // -------------
+ output.append("-------------");
+ if (fChannels.isEmpty()) {
+ output.append("\nNone");
+ } else {
+ for (Iterator<IChannelInfo> iterator = fChannels.iterator(); iterator.hasNext();) {
+ IChannelInfo channel = (IChannelInfo) iterator.next();
+ output.append(channel.formatString());
+ }
+ }
+ output.append("\n");
+ return output.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fChannels == null) ? 0 : fChannels.hashCode());
+ result = prime * result + (fIsKernel ? 1231 : 1237);
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ DomainInfo other = (DomainInfo) obj;
+ if (fChannels == null) {
+ if (other.fChannels != null) {
+ return false;
+ }
+ } else if (!fChannels.equals(other.fChannels)) {
+ return false;
+ }
+ if (fIsKernel != other.fIsKernel) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuffer output = new StringBuffer();
+ output.append("[DomainInfo(");
+ output.append(super.toString());
+ output.append(",Channels=");
+ if (fChannels.isEmpty()) {
+ output.append("None");
+ } else {
+ for (Iterator<IChannelInfo> iterator = fChannels.iterator(); iterator.hasNext();) {
+ IChannelInfo channel = (IChannelInfo) iterator.next();
+ output.append(channel.toString());
+ }
+ }
+ output.append(",isKernel=");
+ output.append(String.valueOf(fIsKernel));
+ output.append(")]");
+ return output.toString();
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+
+/**
+* <b><u>EventInfo</u></b>
+* <p>
+* Implementation of the trace event interface (IEventInfo) to store event
+* related data.
+* </p>
+*/
+public class EventInfo extends BaseEventInfo implements IEventInfo {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The enable state of the event.
+ */
+ private TraceEnablement fState = TraceEnablement.DISABLED;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - name of event
+ */
+ public EventInfo(String name) {
+ super(name);
+ }
+
+ /**
+ * Copy constructor
+ * @param other - the instance to copy
+ */
+ public EventInfo(EventInfo other) {
+ super(other);
+ fState = other.fState;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo#getState()
+ */
+ @Override
+ public TraceEnablement getState() {
+ return fState;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo#setState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement)
+ */
+ @Override
+ public void setState(TraceEnablement state) {
+ fState = state;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ // ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint) [enabled]");
+ output.append(super.formatString());
+ output.append(" [");
+ output.append(fState.getInName());
+ output.append("]");
+ return output.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo#setState(java.lang.String)
+ */
+ @Override
+ public void setState(String stateName) {
+ fState = TraceEnablement.DISABLED;
+ if (TraceEnablement.DISABLED.getInName().equals(stateName)) {
+ fState = TraceEnablement.DISABLED;
+ } else if (TraceEnablement.ENABLED.getInName().equals(stateName)) {
+ fState = TraceEnablement.ENABLED;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ EventInfo other = (EventInfo) obj;
+ if (fState != other.fState) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#toString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuffer output = new StringBuffer();
+ output.append("[EventInfo(");
+ output.append(super.toString());
+ output.append(",State=");
+ output.append(fState);
+ output.append(")]");
+ return output.toString();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.KernelProviderPropertySource;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * <b><u>KernelProviderComponent</u></b>
+ * <p>
+ * TODO
+ * </p>
+ */
+public class KernelProviderComponent extends TraceControlComponent {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Path to icon file for this component.
+ */
+ public static final String KERNEL_PROVIDER_ICON_FILE = "icons/obj16/targets.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ * @param parent - the parent of this component.
+ */
+ public KernelProviderComponent(String name, ITraceControlComponent parent) {
+ super(name, parent);
+ setImage(KERNEL_PROVIDER_ICON_FILE);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * Sets the events information for this component.
+ * @param eventInfos - events information to set.
+ */
+ public void setEventInfo(List<IBaseEventInfo> eventInfos) {
+ for (Iterator<IBaseEventInfo> iterator = eventInfos.iterator(); iterator.hasNext();) {
+ IBaseEventInfo baseEventInfo = (IBaseEventInfo) iterator.next();
+ BaseEventComponent component = new BaseEventComponent(baseEventInfo.getName(), this);
+ component.setEventInfo(baseEventInfo);
+ addChild(component);
+ }
+ }
+
+ /*
+ * (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 KernelProviderPropertySource(this);
+ }
+ return null;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IProbeEventInfo;
+
+/**
+* <b><u>ProbleEventInfo</u></b>
+* <p>
+* Implementation of the trace event interface (IProbeEventInfo) to store probe event
+* related data.
+* </p>
+*/
+public class ProbeEventInfo extends EventInfo implements IProbeEventInfo {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dynamic probe address (null if symbol is used).
+ */
+ private String fAddress;
+ /**
+ * The dynamic probe offset (if symbol is used).
+ */
+ private String fOffset;
+
+ /**
+ * The symbol name (null if address is used)
+ */
+ private String fSymbol;
+
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - name of event
+ */
+ public ProbeEventInfo(String name) {
+ super(name);
+ }
+
+ /**
+ * Copy constructor
+ * @param other - the instance to copy
+ */
+ public ProbeEventInfo(ProbeEventInfo other) {
+ super(other);
+ fAddress = other.fAddress;
+ fOffset = other.fOffset;
+ fSymbol = other.fSymbol;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IProbeEventInfo#getAddress()
+ */
+ @Override
+ public String getAddress() {
+ return fAddress;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IProbeEventInfo#setAddress(java.lang.String)
+ */
+ @Override
+ public void setAddress(String address) {
+ fAddress = address;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IProbeEventInfo#getOffset()
+ */
+ @Override
+ public String getOffset() {
+ return fOffset;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IProbeEventInfo#setOffset(java.lang.String)
+ */
+ @Override
+ public void setOffset(String offset) {
+ fOffset = offset;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IProbeEventInfo#getSymbol()
+ */
+ @Override
+ public String getSymbol() {
+ return fSymbol;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IProbeEventInfo#setSymbol(java.lang.String)
+ */
+ @Override
+ public void setSymbol(String symbol) {
+ fSymbol = symbol;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operation
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ // name (type: probe) [enabled]");
+ // address:
+ output.append(super.formatString());
+ if (fAddress != null) {
+ output.append("\n addr: ");
+ output.append(fAddress);
+ } else {
+ output.append("\n offset: ");
+ output.append(fOffset);
+ output.append("\n");
+ output.append(" symbol: ");
+ output.append(fSymbol);
+ }
+ return output.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fAddress == null) ? 0 : fAddress.hashCode());
+ result = prime * result + ((fOffset == null) ? 0 : fOffset.hashCode());
+ result = prime * result + ((fSymbol == null) ? 0 : fSymbol.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ProbeEventInfo other = (ProbeEventInfo) obj;
+ if (fAddress == null) {
+ if (other.fAddress != null) {
+ return false;
+ }
+ } else if (!fAddress.equals(other.fAddress)) {
+ return false;
+ }
+ if (fOffset == null) {
+ if (other.fOffset != null) {
+ return false;
+ }
+ } else if (!fOffset.equals(other.fOffset)) {
+ return false;
+ }
+ if (fSymbol == null) {
+ if (other.fSymbol != null) {
+ return false;
+ }
+ } else if (!fSymbol.equals(other.fSymbol)) {
+ return false;
+ }
+ return true;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.EventInfo#toString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuffer output = new StringBuffer();
+ output.append("[ProbeEventInfo(");
+ output.append(super.toString());
+ if (fAddress != null) {
+ output.append(",fAddress=");
+ output.append(fAddress);
+ } else {
+ output.append(",fOffset=");
+ output.append(fOffset);
+ output.append(",fSymbol=");
+ output.append(fSymbol);
+ }
+ output.append(")]");
+ return output.toString();
+ }
+
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+
+/**
+ * <b><u>SessionInfo</u></b>
+ * <p>
+ * Implementation of the trace session interface (ISessionInfo) to store session
+ * related data.
+ * </p>
+ */
+public class SessionInfo extends TraceInfo implements ISessionInfo {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The trace session state.
+ */
+ private TraceSessionState fState = TraceSessionState.INACTIVE;
+ /**
+ * The trace session path for storing traces.
+ */
+ private String fSessionPath = ""; //$NON-NLS-1$
+ /**
+ * The domains information of this session.
+ */
+ private List<IDomainInfo> fDomains = new ArrayList<IDomainInfo>();
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - name of base event
+ */
+ public SessionInfo(String name) {
+ super(name);
+ }
+
+ /**
+ * Copy constructor
+ * @param other - the instance to copy
+ */
+ public SessionInfo(SessionInfo other) {
+ super(other);
+ fState = other.fState;
+ fSessionPath = other.fSessionPath;
+
+ for (Iterator<IDomainInfo> iterator = other.fDomains.iterator(); iterator.hasNext();) {
+ IDomainInfo domain = iterator.next();
+ if (domain instanceof DomainInfo) {
+ fDomains.add(new DomainInfo((DomainInfo)domain));
+ } else {
+ fDomains.add(domain);
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#getSessionState()
+ */
+ @Override
+ public TraceSessionState getSessionState() {
+ return fState;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState)
+ */
+ @Override
+ public void setSessionState(TraceSessionState state) {
+ fState = state;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionState(java.lang.String)
+ */
+ @Override
+ public void setSessionState(String stateName) {
+ if (TraceSessionState.INACTIVE.getInName().equals(stateName)) {
+ fState = TraceSessionState.INACTIVE;
+ } else if (TraceSessionState.ACTIVE.getInName().equals(stateName)) {
+ fState = TraceSessionState.ACTIVE;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#getSessionPath()
+ */
+ @Override
+ public String getSessionPath() {
+ return fSessionPath;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionPath(java.lang.String)
+ */
+ @Override
+ public void setSessionPath(String path) {
+ fSessionPath = path;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#getDomains()
+ */
+ @Override
+ public IDomainInfo[] getDomains() {
+ return fDomains.toArray(new IDomainInfo[fDomains.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setDomains(java.util.List)
+ */
+ @Override
+ public void setDomains(List<IDomainInfo> domains) {
+ for (Iterator<IDomainInfo> iterator = domains.iterator(); iterator.hasNext();) {
+ IDomainInfo domainInfo = (IDomainInfo) iterator.next();
+ fDomains.add(domainInfo);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#addDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo)
+ */
+ @Override
+ public void addDomain(IDomainInfo domainInfo) {
+ fDomains.add(domainInfo);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @Override
+ @SuppressWarnings("nls")
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ // Tracing session mysession: [active]
+ output.append("Tracing session ");
+ output.append(getName());
+ output.append(": [");
+ output.append(getSessionState().getInName());
+ output.append("]\n");
+
+ // Trace path: /home/user/lttng-traces/mysession-20120129-084256
+ output.append(" Trace path: ");
+ output.append(getSessionPath());
+ output.append("\n");
+
+ for (Iterator<IDomainInfo> iterator = fDomains.iterator(); iterator.hasNext();) {
+ IDomainInfo domain = (IDomainInfo) iterator.next();
+ output.append(domain.formatString());
+ }
+ return output.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fDomains == null) ? 0 : fDomains.hashCode());
+ result = prime * result + ((fSessionPath == null) ? 0 : fSessionPath.hashCode());
+ result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ SessionInfo other = (SessionInfo) obj;
+ if (fDomains == null) {
+ if (other.fDomains != null) {
+ return false;
+ }
+ } else if (!fDomains.equals(other.fDomains)) {
+ return false;
+ }
+ if (fSessionPath == null) {
+ if (other.fSessionPath != null) {
+ return false;
+ }
+ } else if (!fSessionPath.equals(other.fSessionPath)) {
+ return false;
+ }
+ if (fState != other.fState) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuffer output = new StringBuffer();
+ output.append("[SessionInfo(");
+ output.append(super.toString());
+ output.append(",State=");
+ output.append(fState);
+ output.append(",Domains=");
+ for (Iterator<IDomainInfo> iterator = fDomains.iterator(); iterator.hasNext();) {
+ IDomainInfo domain = (IDomainInfo) iterator.next();
+ output.append(domain.toString());
+ }
+ output.append(")]");
+ return output.toString();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+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.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.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.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.rse.core.model.IHost;
+import org.eclipse.rse.core.model.IRSECallback;
+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>
+ */
+public class TargetNodeComponent extends TraceControlComponent implements ICommunicationsListener {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Path to icon file for this component (state connected).
+ */
+ public static final String TARGET_NODE_CONNECTED_ICON_FILE = "icons/obj16/target_connected.gif"; //$NON-NLS-1$
+ /**
+ * Path to icon file for this component (state disconnected).
+ */
+ public static final String TARGET_NODE_DISCONNECTED_ICON_FILE = "icons/obj16/target_disconnected.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The node connection state.
+ */
+ private TargetNodeState fState = TargetNodeState.DISCONNECTED;
+ /**
+ * The image to be displayed in state disconnected.
+ */
+ private Image fDisconnectedImage = null;
+ /**
+ * The connection implementation.
+ */
+ private IHost fHost = null;
+ /**
+ * The remote proxy implementation.
+ */
+ private IRemoteSystemProxy fRemoteProxy = null;
+ /**
+ * The control service for LTTng specific commands.
+ */
+ private ILttngControlService fService = null;
+ /**
+ * The command shell for issuing commands.
+ */
+ private ICommandShell fShell = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * 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
+ */
+ public TargetNodeComponent(String name, ITraceControlComponent parent, IHost host, IRemoteSystemProxy proxy) {
+ super(name, parent);
+ setImage(TARGET_NODE_CONNECTED_ICON_FILE);
+ fDisconnectedImage = Activator.getDefault().loadIcon(TARGET_NODE_DISCONNECTED_ICON_FILE);
+ fHost = host;
+ fRemoteProxy = proxy;
+ setToolTip(fHost.getHostName());
+ }
+
+ /**
+ * Constructor (using default proxy)
+ * @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, IHost host) {
+ this(name, parent, host, new RemoteSystemProxy(host));
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
+ */
+ @Override
+ public Image getImage() {
+ if (fState == TargetNodeState.CONNECTED) {
+ return super.getImage();
+ }
+ return fDisconnectedImage;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getTargetNodeState()
+ */
+ @Override
+ 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)
+ */
+ @Override
+ public void setTargetNodeState(TargetNodeState state) {
+ fState = state;
+ fireComponentChanged(TargetNodeComponent.this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getControlService()
+ */
+ @Override
+ public ILttngControlService getControlService() {
+ return fService;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#setControlService(org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService)
+ */
+ @Override
+ public void setControlService(ILttngControlService service) {
+ fService = (ILttngControlService)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 String getHostName() {
+ return fHost.getHostName();
+ }
+
+ /**
+ * @return remote system proxy implementation
+ */
+ public IRemoteSystemProxy getRemoteSystemProxy() {
+ return fRemoteProxy;
+ }
+
+ /**
+ * @return all available sessions.
+ */
+ public TraceSessionComponent[] getSessions() {
+ List<ITraceControlComponent> compenents = getChildren(TraceSessionGroup.class);
+ if (compenents.size() > 0) {
+ TraceSessionGroup group = (TraceSessionGroup)compenents.get(0);
+ List<ITraceControlComponent> sessions = group.getChildren(TraceSessionComponent.class);
+ return (TraceSessionComponent[])sessions.toArray(new TraceSessionComponent[sessions.size()]);
+ }
+ return new TraceSessionComponent[0];
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * @see org.eclipse.rse.core.subsystems.ICommunicationsListener#communicationsStateChange(org.eclipse.rse.core.subsystems.CommunicationsEvent)
+ */
+ @Override
+ public void communicationsStateChange(CommunicationsEvent e) {
+ if (e.getState() == CommunicationsEvent.AFTER_DISCONNECT ||
+ e.getState() == CommunicationsEvent.CONNECTION_ERROR) {
+ handleDisconnected();
+ } if ((e.getState() == CommunicationsEvent.AFTER_CONNECT) && (fState != TargetNodeState.CONNECTING)) {
+ handleConnected();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.subsystems.ICommunicationsListener#isPassiveCommunicationsListener()
+ */
+ @Override
+ public boolean isPassiveCommunicationsListener() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceControlComponent#dispose()
+ */
+ @Override
+ public void dispose() {
+ fRemoteProxy.removeCommunicationListener(this);
+ }
+
+ /**
+ * Method to connect this node component to the remote target node.
+ */
+ public void connect() {
+ if (fState == TargetNodeState.DISCONNECTED) {
+ try {
+ setTargetNodeState(TargetNodeState.CONNECTING);
+ fRemoteProxy.connect(new IRSECallback() {
+ @Override
+ public void done(IStatus status, Object result) {
+ // Note: result might be null!
+ if(status.isOK()) {
+ handleConnected();
+ } else {
+ handleDisconnected();
+ }
+ }
+ });
+ } 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$
+ }
+ }
+ }
+
+ /**
+ * Method to disconnect this node component to the remote target node.
+ */
+ public void disconnect() {
+ if (fState == TargetNodeState.CONNECTED) {
+ try {
+ 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$
+ } finally {
+ 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
+ */
+ public void getConfigurationFromNode() {
+ Job job = new Job(Messages.TraceControl_RetrieveNodeConfigurationJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ try {
+ // Get provider information from node
+ 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 Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ }
+
+ public void refresh() {
+ removeAllChildren();
+ getConfigurationFromNode();
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper function
+ // ------------------------------------------------------------------------
+ /**
+ * @return returns the control service for LTTng specific commands.
+ * @throws ExecutionException
+ */
+ private ILttngControlService createControlService() throws ExecutionException {
+ if (fShell == null) {
+ fShell = fRemoteProxy.createCommandShell();
+ fRemoteProxy.addCommunicationListener(this);
+ }
+ fService = new LTTngControlService(fShell);
+ return fService;
+ }
+
+ /**
+ * Handles the connected event.
+ */
+ private void handleConnected() {
+ setTargetNodeState(TargetNodeState.CONNECTED);
+ try {
+ 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$
+ }
+ }
+
+ /**
+ * Handles the disconnected event.
+ */
+ private void handleDisconnected() {
+ removeAllChildren();
+ setTargetNodeState(TargetNodeState.DISCONNECTED);
+ fShell = null;
+ fService = null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+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.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceChannelPropertySource;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+
+/**
+ * <b><u>TraceChannelComponent</u></b>
+ * <p>
+ * Implementation of the trace channel component.
+ * </p>
+ */
+public class TraceChannelComponent extends TraceControlComponent {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Path to icon file for this component (state enabled).
+ */
+ public static final String TRACE_CHANNEL_ICON_FILE_ENABLED = "icons/obj16/channel.gif"; //$NON-NLS-1$
+ /**
+ * Path to icon file for this component (state disabled).
+ */
+ public static final String TRACE_CHANNEL_ICON_FILE_DISABLED = "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The channel information.
+ */
+ private IChannelInfo fChannelInfo = null;
+ /**
+ * The image to be displayed in disabled state.
+ */
+ private Image fDisabledImage = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ * @param parent - the parent of this component.
+ */
+ public TraceChannelComponent(String name, ITraceControlComponent parent) {
+ super(name, parent);
+ setImage(TRACE_CHANNEL_ICON_FILE_ENABLED);
+ setToolTip(Messages.TraceControl_ChannelDisplayName);
+ fChannelInfo = new ChannelInfo(name);
+ fDisabledImage = Activator.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
+ */
+ @Override
+ public Image getImage() {
+ if (fChannelInfo.getState() == TraceEnablement.DISABLED) {
+ return fDisabledImage;
+ }
+ return super.getImage();
+ }
+
+ /**
+ * Sets the channel information.
+ * @param channelInfo
+ */
+ public void setChannelInfo(IChannelInfo channelInfo) {
+ fChannelInfo = channelInfo;
+ IEventInfo[] events = fChannelInfo.getEvents();
+ for (int i = 0; i < events.length; i++) {
+ TraceEventComponent event = null;
+ if (events[i].getClass() == ProbeEventInfo.class) {
+ event = new TraceProbeEventComponent(events[i].getName(), this);
+ } else {
+ event = new TraceEventComponent(events[i].getName(), this);
+ }
+
+ event.setEventInfo(events[i]);
+ addChild(event);
+ }
+ }
+
+ /**
+ * @return the overwrite mode value.
+ */
+ public boolean isOverwriteMode() {
+ return fChannelInfo.isOverwriteMode();
+ }
+ /**
+ * Sets the overwrite mode value to the given mode.
+ * @param mode - mode to set.
+ */
+ public void setOverwriteMode(boolean mode){
+ fChannelInfo.setOverwriteMode(mode);
+ }
+ /**
+ * @return the sub-buffer size.
+ */
+ public long getSubBufferSize() {
+ return fChannelInfo.getSubBufferSize();
+ }
+ /**
+ * Sets the sub-buffer size to the given value.
+ * @param bufferSize - size to set to set.
+ */
+ public void setSubBufferSize(long bufferSize) {
+ fChannelInfo.setSubBufferSize(bufferSize);
+ }
+ /**
+ * @return the number of sub-buffers.
+ */
+ public int getNumberOfSubBuffers() {
+ return fChannelInfo.getNumberOfSubBuffers();
+ }
+ /**
+ * Sets the number of sub-buffers to the given value.
+ * @param numberOfSubBuffers - value to set.
+ */
+ public void setNumberOfSubBuffers(int numberOfSubBuffers) {
+ fChannelInfo.setNumberOfSubBuffers(numberOfSubBuffers);
+ }
+ /**
+ * @return the switch timer interval.
+ */
+ public long getSwitchTimer() {
+ return fChannelInfo.getSwitchTimer();
+ }
+ /**
+ * Sets the switch timer interval to the given value.
+ * @param timer - timer value to set.
+ */
+ public void setSwitchTimer(long timer) {
+ fChannelInfo.setSwitchTimer(timer);
+ }
+ /**
+ * @return the read timer interval.
+ */
+ public long getReadTimer() {
+ return fChannelInfo.getReadTimer();
+ }
+ /**
+ * Sets the read timer interval to the given value.
+ * @param timer - timer value to set..
+ */
+ public void setReadTimer(long timer) {
+ fChannelInfo.setReadTimer(timer);
+ }
+ /**
+ * @return the output type.
+ */
+ public String getOutputType() {
+ return fChannelInfo.getOutputType();
+ }
+ /**
+ * Sets the output type to the given value.
+ * @param type - type to set.
+ */
+ public void setOutputType(String type) {
+ fChannelInfo.setOutputType(type);
+ }
+ /**
+ * @return the channel state (enabled or disabled).
+ */
+ public TraceEnablement getState() {
+ return fChannelInfo.getState();
+ }
+ /**
+ * Sets the channel state (enablement) to the given value.
+ * @param state - state to set.
+ */
+ public void setState(TraceEnablement state) {
+ fChannelInfo.setState(state);
+ }
+ /**
+ * Sets the channel state (enablement) to the value specified by the given name.
+ * @param stateName - state to set.
+ */
+ public void setState(String stateName) {
+ fChannelInfo.setState(stateName);
+ }
+ /*
+ * (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 TraceChannelPropertySource(this);
+ }
+ return null;
+ }
+
+ /**
+ * @return session name from parent
+ */
+ public String getSessionName() {
+ return ((TraceDomainComponent)getParent()).getSessionName();
+ }
+
+ /**
+ * @return session from parent
+ */
+ public TraceSessionComponent getSession() {
+ return ((TraceDomainComponent)getParent()).getSession();
+ }
+
+ /**
+ * @return if domain is kernel or UST
+ */
+ public boolean isKernel() {
+ return ((TraceDomainComponent)getParent()).isKernel();
+ }
+
+ /**
+ * @return the parent target node
+ */
+ public TargetNodeComponent getTargetNode() {
+ return ((TraceDomainComponent)getParent()).getTargetNode();
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @throws ExecutionException
+ */
+ public void enableEvents(List<String> eventNames) throws ExecutionException {
+ enableEvents(eventNames, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableEvents(getSessionName(), getName(), eventNames, isKernel(), monitor);
+ }
+
+ /**
+ * Enables all syscalls (for kernel domain)
+ * @throws ExecutionException
+ */
+ public void enableSyscalls() throws ExecutionException {
+ enableSyscalls(new NullProgressMonitor());
+ }
+
+ /**
+ * Enables all syscalls (for kernel domain)
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableSyscalls(getSessionName(), getName(), monitor);
+ }
+
+ /**
+ * Enables a dynamic probe (for kernel domain)
+ * @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
+ * @param probe - the actual probe
+ * @throws ExecutionException
+ */
+ public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException {
+ enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables a dynamic probe (for kernel domain)
+ * @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
+ * @param probe - the actual probe
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableProbe(getSessionName(), getName(), eventName, isFunction, probe, monitor);
+ }
+
+ /**
+ * Enables events using log level.
+ * @param eventName - a event name
+ * @param logLevelType - a log level type
+ * @param level - a log level
+ * @throws ExecutionException
+ */
+ public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level) throws ExecutionException {
+ enableLogLevel(eventName, logLevelType, level, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables events using log level.
+ * @param eventName - a event name
+ * @param logLevelType - a log level type
+ * @param level - a log level
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableLogLevel(getSessionName(), getName(), eventName, logLevelType, level, monitor);
+ }
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @throws ExecutionException
+ */
+ public void disableEvent(List<String> eventNames) throws ExecutionException {
+ disableEvent(eventNames, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void disableEvent(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().disableEvent(getParent().getParent().getName(), getName(), eventNames, isKernel(), monitor);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+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.TargetNodeState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * <b><u>TraceControlComponent</u></b>
+ * <p>
+ * Base implementation for trace control component.
+ * </p>
+ */
+public class TraceControlComponent implements ITraceControlComponent {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The name of the component
+ */
+ private String fName = ""; //$NON-NLS-1$
+ /**
+ * The image to be displayed for the component.
+ */
+ private Image fImage = null;
+ /**
+ * The tool tip to be displayed for the component.
+ */
+ private String fToolTip = null;
+ /**
+ * The parent component.
+ */
+ private ITraceControlComponent fParent = null;
+ /**
+ * The list if children components.
+ */
+ private List<ITraceControlComponent> fChildren = new ArrayList<ITraceControlComponent>();
+ /**
+ * The list of listeners to be notified about changes.
+ */
+ private ListenerList fListeners = new ListenerList();
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ */
+ public TraceControlComponent(String name) {
+ this(name, null);
+ }
+
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ * @param parent - the parent component.
+ */
+ public TraceControlComponent(String name, ITraceControlComponent parent) {
+ fName = name;
+ fParent = parent;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#getName()
+ */
+ @Override
+ public String getName() {
+ return fName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#setName(java.lang.String)
+ */
+ @Override
+ public void setName(String name) {
+ fName = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#getImage()
+ */
+ @Override
+ public Image getImage() {
+ return fImage;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#setImage(java.lang.String)
+ */
+ @Override
+ public void setImage(String path) {
+ fImage = Activator.getDefault().loadIcon(path);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#setImage(org.eclipse.swt.graphics.Image)
+ */
+ @Override
+ public void setImage(Image image) {
+ fImage = image;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#getToolTip()
+ */
+ @Override
+ public String getToolTip() {
+ return fToolTip;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#setToolTip(java.lang.String)
+ */
+ @Override
+ public void setToolTip(String toolTip) {
+ fToolTip = toolTip;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#getTargetNodeState()
+ */
+ @Override
+ public TargetNodeState getTargetNodeState() {
+ if (getParent() != null) {
+ return getParent().getTargetNodeState();
+ }
+ return TargetNodeState.DISCONNECTED;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#setTargetNodeState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent.TargetNodeState)
+ */
+ @Override
+ public void setTargetNodeState(TargetNodeState state) {
+ if (getParent() != null) {
+ getParent().setTargetNodeState(state);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#getParent()
+ */
+ @Override
+ public ITraceControlComponent getParent() {
+ return fParent;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#setParent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent)
+ */
+ @Override
+ public void setParent(ITraceControlComponent parent) {
+ fParent = parent;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#getChildren()
+ */
+ @Override
+ public ITraceControlComponent[] getChildren() {
+ return (ITraceControlComponent [])fChildren.toArray(new ITraceControlComponent[fChildren.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#setChildren(java.util.List)
+ */
+ @Override
+ public void setChildren(List<ITraceControlComponent> children) {
+ for (Iterator<ITraceControlComponent> iterator = children.iterator(); iterator.hasNext();) {
+ ITraceControlComponent traceControlComponent = (ITraceControlComponent) iterator.next();
+ fChildren.add(traceControlComponent);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#getChild(java.lang.String)
+ */
+ @Override
+ public ITraceControlComponent getChild(String name) {
+ ITraceControlComponent child = null;
+ for (int i = 0; i < fChildren.size(); i++) {
+ if (fChildren.get(i).getName().equals(name)) {
+ child = fChildren.get(i);
+ break;
+ }
+ }
+ return child;
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#getChildren(java.lang.Class)
+ */
+ @Override
+ public List<ITraceControlComponent> getChildren(Class<? extends ITraceControlComponent> clazz) {
+ List<ITraceControlComponent> list = new ArrayList<ITraceControlComponent>();
+
+ for (Iterator<ITraceControlComponent> iterator = fChildren.iterator(); iterator.hasNext();) {
+ ITraceControlComponent child = (ITraceControlComponent) iterator.next();
+ if (child.getClass() == clazz) {
+ list.add(child);
+ }
+ }
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#getControlService()
+ */
+ @Override
+ public ILttngControlService getControlService() {
+ if (getParent() != null) {
+ return getParent().getControlService();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#setControlService(org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService)
+ */
+ @Override
+ public void setControlService(ILttngControlService service) {
+ if (getParent() != null) {
+ getParent().setControlService(service);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#dispose()
+ */
+ @Override
+ public void dispose() {
+ // default implementation
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#addChild(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent)
+ */
+ @Override
+ public void addChild(ITraceControlComponent component) {
+ if (component != null) {
+ fChildren.add(component);
+ }
+ fireComponentAdded(this, component);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#removeChild(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent)
+ */
+ @Override
+ public void removeChild(ITraceControlComponent component) {
+ if (component != null) {
+ fChildren.remove(component);
+ component.dispose();
+ }
+ fireComponentRemoved(this, component);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#removeAllChildren()
+ */
+ @Override
+ public void removeAllChildren() {
+ for (Iterator<ITraceControlComponent> iterator = fChildren.iterator(); iterator.hasNext();) {
+ ITraceControlComponent child = (ITraceControlComponent) iterator.next();
+ child.removeAllChildren();
+ }
+ fChildren.clear();
+// fireCompenentChanged(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#containsChild(java.lang.String)
+ */
+ @Override
+ public boolean containsChild(String name) {
+ boolean retValue = false;
+ for (int i = 0; i < fChildren.size(); i++) {
+ if (fChildren.get(i).getName().equals(name)) {
+ retValue = true;
+ break;
+ }
+ }
+ return retValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#hasChildren()
+ */
+ @Override
+ public boolean hasChildren() {
+ return !fChildren.isEmpty();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#addComponentListener(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponentChangedListener)
+ */
+ @Override
+ public void addComponentListener(ITraceControlComponentChangedListener listener) {
+ if (fParent != null)
+ fParent.addComponentListener(listener);
+ else {
+ fListeners.add(listener);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#removeComponentListener(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponentChangedListener)
+ */
+ @Override
+ public void removeComponentListener(ITraceControlComponentChangedListener listener) {
+ if (fParent != null)
+ fParent.removeComponentListener(listener);
+ else {
+ fListeners.remove(listener);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#fireCompenentAdded(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent)
+ */
+ @Override
+ public void fireComponentAdded(ITraceControlComponent parent, ITraceControlComponent component) {
+ if (component == null) {
+ return;
+ }
+
+ if (fParent != null) {
+ fParent.fireComponentAdded(parent, component);
+ } else {
+ Object[] listeners = fListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ ITraceControlComponentChangedListener listener = (ITraceControlComponentChangedListener) listeners[i];
+ listener.componentAdded(parent, component);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#fireCompenentRemoved(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent)
+ */
+ @Override
+ public void fireComponentRemoved(ITraceControlComponent parent, ITraceControlComponent component) {
+ if (component == null) {
+ return;
+ }
+
+ if (fParent != null) {
+ fParent.fireComponentRemoved(parent, component);
+ } else {
+ Object[] listeners = fListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ ITraceControlComponentChangedListener listener = (ITraceControlComponentChangedListener) listeners[i];
+ listener.componentRemoved(parent, component);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent#fireCompenentChanged(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent)
+ */
+ @Override
+ public void fireComponentChanged(ITraceControlComponent component) {
+ if (component == null) {
+ return;
+ }
+
+ if (fParent != null) {
+ fParent.fireComponentChanged(component);
+ } else {
+ Object[] listeners = fListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ ITraceControlComponentChangedListener listener = (ITraceControlComponentChangedListener) listeners[i];
+ listener.componentChanged(component);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+
+/**
+ * <b><u>TraceControlRoot</u></b>
+ * <p>
+ * Root element in trace control tree.
+ * </p>
+ */
+public class TraceControlRoot extends TraceControlComponent {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The name of the root component
+ */
+ public final static String TRACE_CONTROL_ROOT_NAME = "trace_control_root"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
+ public TraceControlRoot() {
+ super(TRACE_CONTROL_ROOT_NAME);
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceDomainPropertySource;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * <b><u>TraceDomainComponent</u></b>
+ * <p>
+ * Implementation of the trace domain component.
+ * </p>
+ */
+public class TraceDomainComponent extends TraceControlComponent {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Path to icon file for this component.
+ */
+ public static final String TRACE_DOMAIN_ICON_FILE = "icons/obj16/domain.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The domain information.
+ */
+ private IDomainInfo fDomainInfo = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ * @param parent - the parent of this component.
+ */
+ public TraceDomainComponent(String name, ITraceControlComponent parent) {
+ super(name, parent);
+ setImage(TRACE_DOMAIN_ICON_FILE);
+ setToolTip(Messages.TraceControl_DomainDisplayName);
+ fDomainInfo = new DomainInfo(name);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * Sets the domain information.
+ * @param domainInfo - the domain information to set.
+ */
+ public void setDomainInfo(IDomainInfo domainInfo) {
+ fDomainInfo = domainInfo;
+ IChannelInfo[] channels = fDomainInfo.getChannels();
+ for (int i = 0; i < channels.length; i++) {
+ TraceChannelComponent channel = new TraceChannelComponent(channels[i].getName(), this);
+ channel.setChannelInfo(channels[i]);
+ addChild(channel);
+ }
+ }
+
+ /*
+ * (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 TraceDomainPropertySource(this);
+ }
+ return null;
+ }
+
+ /**
+ * @return session name from parent
+ */
+ public String getSessionName() {
+ return ((TraceSessionComponent)getParent()).getName();
+ }
+
+ /**
+ * @return session from parent
+ */
+ public TraceSessionComponent getSession() {
+ return (TraceSessionComponent)getParent();
+ }
+
+ /**
+ * @return true if domain is kernel, false for UST
+ */
+ public boolean isKernel() {
+ return fDomainInfo.isKernel();
+ }
+
+ /**
+ * Sets whether domain is Kernel domain or UST
+ * @param isKernel true for kernel, false for UST
+ */
+ public void setIsKernel(boolean isKernel) {
+ fDomainInfo.setIsKernel(isKernel);
+ }
+
+ /**
+ * @return returns all available channels for this domain.
+ */
+ public TraceChannelComponent[] getChannels() {
+ List<ITraceControlComponent> channels = getChildren(TraceChannelComponent.class);
+ return (TraceChannelComponent[])channels.toArray(new TraceChannelComponent[channels.size()]);
+ }
+
+ /**
+ * @return the parent target node
+ */
+ public TargetNodeComponent getTargetNode() {
+ return ((TraceSessionComponent)getParent()).getTargetNode();
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Retrieves the session configuration from the node.
+ * @throws ExecutionException
+ */
+ public void getConfigurationFromNode() throws ExecutionException {
+ getConfigurationFromNode(new NullProgressMonitor());
+ }
+ /**
+ * Retrieves the session configuration from the node.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
+ TraceSessionComponent session = (TraceSessionComponent) getParent();
+ session.getConfigurationFromNode(monitor);
+ }
+ /**
+ * Enables channels with given names which are part of this domain. If a given channel
+ * doesn't exists it creates a new channel with the given parameters (or default values
+ * if given parameter is null).
+ * @param channelNames - a list of channel names to enable on this domain
+ * @param info - channel information to set for the channel (use null for default)
+ * @throws ExecutionException
+ */
+ public void enableChannels(List<String> channelNames, IChannelInfo info) throws ExecutionException {
+ enableChannels(channelNames, info, new NullProgressMonitor());
+ }
+ /**
+ * Enables channels with given names which are part of this domain. If a given channel
+ * doesn't exists it creates a new channel with the given parameters (or default values
+ * if given parameter is null).
+ * @param channelNames - a list of channel names to enable on this domain
+ * @param info - channel information to set for the channel (use null for default)
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableChannels(List<String> channelNames, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableChannels(getParent().getName(), channelNames, isKernel(), info, monitor);
+ }
+ /**
+ * Disables channels with given names which are part of this domain.
+ * @param channelNames - a list of channel names to enable on this domain
+ * @throws ExecutionException
+ */
+ public void disableChannels(List<String> channelNames) throws ExecutionException {
+ disableChannels(channelNames, new NullProgressMonitor());
+ }
+ /**
+ * Disables channels with given names which are part of this domain.
+ * @param channelNames - a list of channel names to enable on this domain
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void disableChannels(List<String> channelNames, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().disableChannels(getParent().getName(), channelNames, isKernel(), monitor);
+ }
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableEvents(getSessionName(), null, eventNames, isKernel(), monitor);
+ }
+
+ /**
+ * Enables all syscalls (for kernel domain)
+ * @throws ExecutionException
+ */
+ public void enableSyscalls() throws ExecutionException {
+ enableSyscalls(new NullProgressMonitor());
+ }
+
+ /**
+ * Enables all syscalls (for kernel domain)
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+
+ public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableSyscalls(getSessionName(), null, monitor);
+ }
+
+ /**
+ * Enables a dynamic probe (for kernel domain)
+ * @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
+ * @param probe - the actual probe
+ * @throws ExecutionException
+ */
+ public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException {
+ enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables a dynamic probe (for kernel domain)
+ * @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
+ * @param probe - the actual probe
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableProbe(getSessionName(), null, eventName, isFunction, probe, monitor);
+ }
+
+ /**
+ * Enables events using log level.
+ * @param eventName - a event name
+ * @param logLevelType - a log level type
+ * @param level - a log level
+ * @throws ExecutionException
+ */
+ public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level) throws ExecutionException {
+ enableLogLevel(eventName, logLevelType, level, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables events using log level.
+ * @param eventName - a event name
+ * @param logLevelType - a log level type
+ * @param level - a log level
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableLogLevel(getSessionName(), null, eventName, logLevelType, level, monitor);
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+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.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceEventPropertySource;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+
+/**
+ * <b><u>TraceEventComponent</u></b>
+ * <p>
+ * Implementation of the trace channel component.
+ * </p>
+ */
+public class TraceEventComponent extends TraceControlComponent {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Path to icon file for this component (enabled state).
+ */
+ public static final String TRACE_EVENT_ICON_FILE_ENABLED = "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
+ /**
+ * Path to icon file for this component (disabled state).
+ */
+ public static final String TRACE_EVENT_ICON_FILE_DISABLED = "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The event information.
+ */
+ protected IEventInfo fEventInfo = null;
+ /**
+ * The image to be displayed when in disabled state.
+ */
+ private Image fDisabledImage = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ * @param parent - the parent of this component.
+ */
+ public TraceEventComponent(String name, ITraceControlComponent parent) {
+ super(name, parent);
+ setImage(TRACE_EVENT_ICON_FILE_ENABLED);
+ setToolTip(Messages.TraceControl_EventDisplayName);
+ fEventInfo = new EventInfo(name);
+ fDisabledImage = Activator.getDefault().loadIcon(TRACE_EVENT_ICON_FILE_DISABLED);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
+ */
+ @Override
+ public Image getImage() {
+ if (fEventInfo.getState() == TraceEnablement.DISABLED) {
+ return fDisabledImage;
+ }
+ return super.getImage();
+ }
+
+ /**
+ * Sets the event information.
+ * @param eventInfo - the event information to set.
+ */
+ public void setEventInfo(IEventInfo eventInfo) {
+ fEventInfo = eventInfo;
+ }
+
+ /**
+ * @return the trace event type
+ */
+ public TraceEventType getEventType() {
+ return fEventInfo.getEventType();
+ }
+
+ /**
+ * Sets the trace event type to the given type
+ * @param type - type to set
+ */
+ public void setEventType(TraceEventType type) {
+ fEventInfo.setEventType(type);
+ }
+
+ /**
+ * Sets the trace event type to the type specified by the given name.
+ * @param type - event type name
+ */
+ public void setEventType(String typeName) {
+ fEventInfo.setEventType(typeName);
+ }
+
+ /**
+ * @return the event state (enabled or disabled).
+ */
+ public TraceEnablement getState() {
+ return fEventInfo.getState();
+ }
+
+ /**
+ * Sets the event state (enablement) to the given value.
+ * @param state - state to set.
+ */
+ public void setState(TraceEnablement state) {
+ fEventInfo.setState(state);
+ }
+
+ /**
+ * Sets the event state (enablement) to the value specified by the given name.
+ * @param stateName - state to set.
+ */
+ public void setState(String stateName) {
+ fEventInfo.setState(stateName);
+ }
+
+ /**
+ * @return the trace event log level
+ */
+ public TraceLogLevel getLogLevel() {
+ return fEventInfo.getLogLevel();
+ }
+
+ /**
+ * 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
+ */
+ public void setLogLevel(String levelName) {
+ fEventInfo.setLogLevel(levelName);
+ }
+
+ /*
+ * (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 TraceEventPropertySource(this);
+ }
+ return null;
+ }
+
+ /**
+ * @return session name from parent
+ */
+ public String getSessionName() {
+ return ((TraceChannelComponent)getParent()).getSessionName();
+ }
+
+ /**
+ * @return channel name from parent
+ */
+ public String getChannelName() {
+ return getParent().getName();
+ }
+
+ /**
+ * @return if domain is kernel or UST
+ */
+ public boolean isKernel() {
+ return ((TraceChannelComponent)getParent()).isKernel();
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo;
+
+/**
+ * <b><u>TraceInfo</u></b>
+ * <p>
+ * Implementation of the base trace information interface (ITraceInfo) to
+ * store common data.
+ * </p>
+ */
+public class TraceInfo implements ITraceInfo {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The name of the element.
+ */
+ private String fName = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - name of trace element
+ */
+ public TraceInfo(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException();
+ }
+ fName = name;
+ }
+
+ /**
+ * Copy constructor
+ * @param other - the instance to copy
+ */
+ public TraceInfo(TraceInfo other) {
+ if (other == null) {
+ throw new IllegalArgumentException();
+ } else {
+ fName = String.valueOf(other.fName);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#getName()
+ */
+ @Override
+ public String getName() {
+ return fName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#setName(java.lang.String)
+ */
+ @Override
+ public void setName(String name) {
+ fName = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @Override
+ public String formatString() {
+ return toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((fName == null) ? 0 : fName.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TraceInfo other = (TraceInfo) obj;
+ if (fName == null) {
+ if (other.fName != null) {
+ return false;
+ }
+ } else if (!fName.equals(other.fName)) {
+ return false;
+ }
+ return true;
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuffer output = new StringBuffer();
+ output.append("[TraceInfo(");
+ output.append("Name=");
+ output.append(getName());
+ output.append(")]");
+ return output.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceProbeEventPropertySource;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+
+/**
+ * <b><u>TraceProbeEventComponent</u></b>
+ * <p>
+ * Implementation of the trace channel component.
+ * </p>
+ */
+public class TraceProbeEventComponent extends TraceEventComponent {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * 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
+ // ------------------------------------------------------------------------
+
+ /**
+ * Sets the event information.
+ * @param eventInfo - the event information to set.
+ */
+ @Override
+ public void setEventInfo(IEventInfo eventInfo) {
+ if (eventInfo instanceof ProbeEventInfo) {
+ fEventInfo = eventInfo;
+ return;
+ }
+ 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) {
+ return new TraceProbeEventPropertySource(this);
+ }
+ return null;
+ }
+ /**
+ * @return the address of the probe. (null if Symbol is used)
+ */
+ public String getAddress() {
+ return getEventInfo().getAddress();
+ }
+ /**
+ * Sets the address of the probe.
+ * @param address - a address
+ */
+ public void setAddress(String address) {
+ getEventInfo().setAddress(address);
+ }
+ /**
+ * @return the offset applied to the symbol.
+ */
+ public String getOffset() {
+ return getEventInfo().getOffset();
+ }
+ /**
+ * Sets the offset applied to the symbol. (valid if symbol is used)
+ * @param offset - a offset
+ */
+ public void setOffset(String offset) {
+ getEventInfo().setOffset(offset);
+ }
+ /**
+ * @return the symbol name. (null if address is used)
+ */
+ public String getSymbol() {
+ return getEventInfo().getSymbol();
+ }
+ /**
+ * Sets the symbol name.
+ * @param symbol - a symbol name (null if address is used)
+ */
+ public void setSymbol(String symbol) {
+ getEventInfo().setSymbol(symbol);
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ private ProbeEventInfo getEventInfo() {
+ return (ProbeEventInfo) fEventInfo;
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo;
+
+/**
+ * <b><u>TraceProviderGroup</u></b>
+ * <p>
+ * Implementation of the trace provider group.
+ * </p>
+ */
+public class TraceProviderGroup extends TraceControlComponent {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Path to icon file for this component.
+ */
+ public static final String TRACE_PROVIDERS_ICON_FILE = "icons/obj16/providers.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ * @param parent - the parent of this component.
+ */
+ public TraceProviderGroup(String name, ITraceControlComponent parent) {
+ super(name, parent);
+ setImage(TRACE_PROVIDERS_ICON_FILE);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /**
+ * Gets the provider information from the target node.
+ * @throws ExecutionException
+ */
+ public void getProviderFromNode() throws ExecutionException {
+ getProviderFromNode(new NullProgressMonitor());
+ }
+
+ /**
+ * Gets the provider information from the target node.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void getProviderFromNode(IProgressMonitor monitor) throws ExecutionException {
+
+ List<IBaseEventInfo> eventInfos = getControlService().getKernelProvider(monitor);
+ KernelProviderComponent component = new KernelProviderComponent(Messages.TraceControl_KernelProviderDisplayName, this);
+ addChild(component);
+ component.setEventInfo(eventInfos);
+
+ List<IUstProviderInfo> allProviders = getControlService().getUstProvider(monitor);
+
+ for (Iterator<IUstProviderInfo> iterator = allProviders.iterator(); iterator.hasNext();) {
+ IUstProviderInfo ustProviderInfo = (IUstProviderInfo) iterator.next();
+ UstProviderComponent ustComponent = new UstProviderComponent(ustProviderInfo.getName(), this);
+ addChild(ustComponent);
+ ustComponent.setUstProvider(ustProviderInfo);
+ }
+ }
+}
+
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+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.model.IDomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceSessionPropertySource;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * <b><u>TraceSessionComponent</u></b>
+ * <p>
+ * Implementation of the trace session component.
+ * </p>
+ */
+public class TraceSessionComponent extends TraceControlComponent {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Path to icon file for this component (inactive state).
+ */
+ public static final String TRACE_SESSION_ICON_FILE_INACTIVE = "icons/obj16/session_inactive.gif"; //$NON-NLS-1$
+ /**
+ * Path to icon file for this component (active state).
+ */
+ public static final String TRACE_SESSION_ICON_FILE_ACTIVE = "icons/obj16/session_active.gif"; //$NON-NLS-1$
+ /**
+ * Path to icon file for this component (destroyed state).
+ */
+ public static final String TRACE_SESSION_ICON_FILE_DESTROYED = "icons/obj16/session_destroyed.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The session information.
+ */
+ private ISessionInfo fSessionInfo = null;
+ /**
+ * A flag to indicate if session has been destroyed.
+ */
+ private boolean fIsDestroyed = false;
+ /**
+ * The image to be displayed in state active.
+ */
+ private Image fActiveImage = null;
+ /**
+ * The image to be displayed in state destroyed
+ */
+ private Image fDestroyedImage = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ * @param parent - the parent of this component.
+ */
+ public TraceSessionComponent(String name, ITraceControlComponent parent) {
+ super(name, parent);
+ setImage(TRACE_SESSION_ICON_FILE_INACTIVE);
+ setToolTip(Messages.TraceControl_SessionDisplayName);
+ fSessionInfo = new SessionInfo(name);
+ fActiveImage = Activator.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_ACTIVE);
+ fDestroyedImage = Activator.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_DESTROYED);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
+ */
+ @Override
+ public Image getImage() {
+ if (fIsDestroyed) {
+ return fDestroyedImage;
+ }
+
+ if (fSessionInfo.getSessionState() == TraceSessionState.INACTIVE) {
+ return super.getImage();
+ }
+
+ return fActiveImage;
+ }
+
+ /**
+ * @return the whether the session is destroyed or not.
+ */
+ public boolean isDestroyed() {
+ return fIsDestroyed;
+ }
+
+ /**
+ * Sets the session destroyed state to the given value.
+ * @param destroyed - value to set.
+ */
+ public void setDestroyed(boolean destroyed) {
+ fIsDestroyed = destroyed;
+ }
+
+ /**
+ * @return the session state state (active or inactive).
+ */
+ public TraceSessionState getSessionState() {
+ return fSessionInfo.getSessionState();
+ }
+
+ /**
+ * Sets the session state to the given value.
+ * @param state - state to set.
+ */
+ public void setSessionState(TraceSessionState state) {
+ fSessionInfo.setSessionState(state);
+ }
+
+ /**
+ * Sets the event state to the value specified by the given name.
+ * @param stateName - state to set.
+ */
+ public void setSessionState(String stateName) {
+ fSessionInfo.setSessionState(stateName);
+ }
+
+ /**
+ * @return path string where session is located.
+ */
+ public String getSessionPath() {
+ return fSessionInfo.getSessionPath();
+ }
+
+ /**
+ * Sets the path string (where session is located) to the given value.
+ * @param path - session path to set.
+ */
+ public void setSessionPath(String sessionPath) {
+ fSessionInfo.setSessionPath(sessionPath);
+ }
+
+ /*
+ * (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 TraceSessionPropertySource(this);
+ }
+ return null;
+ }
+
+ /**
+ * @return all available domains of this session.
+ */
+ public TraceDomainComponent[] getDomains() {
+ List<ITraceControlComponent> sessions = getChildren(TraceDomainComponent.class);
+ return (TraceDomainComponent[])sessions.toArray(new TraceDomainComponent[sessions.size()]);
+ }
+
+ /**
+ * @return the parent target node
+ */
+ public TargetNodeComponent getTargetNode() {
+ return ((TraceSessionGroup)getParent()).getTargetNode();
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Retrieves the session configuration from the node.
+ * @throws ExecutionException
+ */
+ public void getConfigurationFromNode() throws ExecutionException {
+ getConfigurationFromNode(new NullProgressMonitor());
+ }
+
+ /**
+ * Retrieves the session configuration from the node.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
+ removeAllChildren();
+ fSessionInfo = getControlService().getSession(getName(), monitor);
+ IDomainInfo[] domains = fSessionInfo.getDomains();
+ for (int i = 0; i < domains.length; i++) {
+ TraceDomainComponent domainComponent = new TraceDomainComponent(domains[i].getName(), this);
+ addChild(domainComponent);
+ domainComponent.setDomainInfo(domains[i]);
+ }
+ }
+
+ /**
+ * Starts the session.
+ * throws ExecutionExecption
+ */
+ public void startSession() throws ExecutionException {
+ startSession(new NullProgressMonitor());
+ }
+
+ /**
+ * Starts the session.
+ * @param monitor - a progress monitor
+ * throws ExecutionExecption
+ */
+ public void startSession(IProgressMonitor monitor) throws ExecutionException {
+ getControlService().startSession(getName(), monitor);
+ }
+
+ /**
+ * Starts the session.
+ * throws ExecutionExecption
+ */
+ public void stopSession() throws ExecutionException {
+ startSession(new NullProgressMonitor());
+ }
+
+ /**
+ * Starts the session.
+ * @param monitor - a progress monitor
+ * throws ExecutionExecption
+ */
+ public void stopSession(IProgressMonitor monitor) throws ExecutionException {
+ getControlService().stopSession(getName(), monitor);
+ }
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @throws ExecutionException
+ */
+ public void enableEvent(List<String> eventNames, boolean isKernel) throws ExecutionException {
+ enableEvents(eventNames, isKernel, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableEvents(getName(), null, eventNames, isKernel, monitor);
+ }
+
+ /**
+ * Enables all syscalls (for kernel domain)
+ * @throws ExecutionException
+ */
+ public void enableSyscalls() throws ExecutionException {
+ enableSyscalls(new NullProgressMonitor());
+ }
+
+ /**
+ * Enables all syscalls (for kernel domain)
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableSyscalls(getName(), null, monitor);
+ }
+
+ /**
+ * Enables a dynamic probe (for kernel domain)
+ * @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
+ * @param probe - the actual probe
+ * @throws ExecutionException
+ */
+ public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException {
+ enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables a dynamic probe (for kernel domain)
+ * @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
+ * @param probe - the actual probe
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableProbe(getName(), null, eventName, isFunction, probe, monitor);
+ }
+
+ /**
+ * Enables events using log level.
+ * @param eventName - a event name
+ * @param logLevelType - a log level type
+ * @param level - a log level
+ * @throws ExecutionException
+ */
+ public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level) throws ExecutionException {
+ enableLogLevel(eventName, logLevelType, level, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables events using log level.
+ * @param eventName - a event name
+ * @param logLevelType - a log level type
+ * @param level - a log level
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableLogLevel(getName(), null, eventName, logLevelType, level, monitor);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+
+/**
+ * <b><u>TraceSessionGroup</u></b>
+ * <p>
+ * Implementation of the trace session group.
+ * </p>
+ */
+public class TraceSessionGroup extends TraceControlComponent {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Path to icon file for this component.
+ */
+ public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ * @param parent - the parent of this component.
+ */
+ public TraceSessionGroup(String name, ITraceControlComponent parent) {
+ super(name, parent);
+ setImage(TRACE_SESSIONS_ICON_FILE);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the parent target node
+ */
+ public TargetNodeComponent getTargetNode() {
+ return (TargetNodeComponent)getParent();
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Retrieves the sessions information from the node.
+ * @throws ExecutionException
+ */
+ public void getSessionsFromNode() throws ExecutionException {
+ getSessionsFromNode(new NullProgressMonitor());
+ }
+
+ /**
+ * Retrieves the sessions information from the node.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void getSessionsFromNode(IProgressMonitor monitor) throws ExecutionException {
+ String[] sessionNames = getControlService().getSessionNames(monitor);
+ for (int i = 0; i < sessionNames.length; i++) {
+ TraceSessionComponent session = new TraceSessionComponent(sessionNames[i], this);
+ addChild(session);
+ session.getConfigurationFromNode(monitor);
+ }
+ }
+
+ /**
+ * Creates a session with given session name and location.
+ * @param sessionName - a session name to create
+ * @param sessionPath - a path for storing the traces (use null for default)
+ * @return the session information
+ * throws ExecutionExecption
+ */
+ public void createSession(String sessionName, String sessionPath) throws ExecutionException {
+ createSession(sessionName, sessionPath, new NullProgressMonitor());
+ }
+
+ /**
+ * Creates a session with given session name and location.
+ * @param sessionName - a session name to create
+ * @param sessionPath - a path for storing the traces (use null for default)
+ * @Param monitor - a progress monitor
+ * @return the session information
+ * throws ExecutionExecption
+ */
+ public void createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+ ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, monitor);
+ if (sessionInfo != null) {
+ TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
+ addChild(session);
+ session.getConfigurationFromNode(monitor);
+ }
+ }
+
+ /**
+ * Destroys a session with given session name.
+ * @param session - a session component to destroy
+ * throws ExecutionExecption
+ */
+ public void destroySession(TraceSessionComponent session) throws ExecutionException {
+ destroySession(session, new NullProgressMonitor());
+ }
+
+ /**
+ * Destroys a session with given session name.
+ * @param session - a session component to destroy
+ * @param monitor - a progress monitor
+ * throws ExecutionExecption
+ */
+ public void destroySession(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().destroySession(session.getName(), monitor);
+ session.removeAllChildren();
+ removeChild(session);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.UstProviderPropertySource;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * <b><u>UstProviderComponent</u></b>
+ * <p>
+ * Implementation of the UST provider component.
+ * </p>
+ */
+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
+ * @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);
+ fProviderInfo = new UstProviderInfo(name);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * Sets the UST provider information to the given value.
+ * @param providerInfo - the provider information to set
+ */
+ public void setUstProvider(IUstProviderInfo providerInfo) {
+ fProviderInfo = providerInfo;
+ IBaseEventInfo[] events = providerInfo.getEvents();
+ for (int i = 0; i < events.length; i++) {
+ BaseEventComponent component = new BaseEventComponent(events[i].getName(), this);
+ component.setEventInfo(events[i]);
+ addChild(component);
+ }
+ setToolTip("PID=" + fProviderInfo.getPid()); //$NON-NLS-1$
+ }
+
+ /**
+ * @return the process ID of the UST provider.
+ */
+ public int getPid() {
+ return fProviderInfo.getPid();
+ }
+
+ /**
+ * Sets the process ID of the UST provider to the given value.
+ * @param pid - process ID to set
+ */
+ public void setPid(int pid) {
+ fProviderInfo.setPid(pid);
+ }
+
+ /*
+ * (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
+ // ------------------------------------------------------------------------
+
+}
+
+
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo;
+
+/**
+ * <b><u>UstProviderInfo</u></b>
+ * <p>
+ * Implementation of the Ust Provider interface (IUstProviderInfo) to store UST
+ * provider related data.
+ * </p>
+ */
+public class UstProviderInfo extends TraceInfo implements IUstProviderInfo {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The process ID of the UST provider.
+ */
+ private int fPid = 0;
+ /**
+ * List of event information.
+ */
+ private List<IBaseEventInfo> fEvents = new ArrayList<IBaseEventInfo>();
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - name of UST provider
+ */
+ public UstProviderInfo(String name) {
+ super(name);
+ }
+
+ /**
+ * Copy constructor
+ * @param other - the instance to copy
+ */
+ public UstProviderInfo(UstProviderInfo other) {
+ super(other);
+ fPid = other.fPid;
+ for (Iterator<IBaseEventInfo> iterator = other.fEvents.iterator(); iterator.hasNext();) {
+ IBaseEventInfo event = iterator.next();
+ if (event instanceof BaseEventInfo) {
+ fEvents.add(new BaseEventInfo((BaseEventInfo)event));
+ } else {
+ fEvents.add(event);
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#getPid()
+ */
+ @Override
+ public int getPid() {
+ return fPid;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#setPid(int)
+ */
+ @Override
+ public void setPid(int pid) {
+ fPid = pid;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#getEvents()
+ */
+ @Override
+ public IBaseEventInfo[] getEvents() {
+ return fEvents.toArray(new IBaseEventInfo[fEvents.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#setEvents(java.util.List)
+ */
+ @Override
+ public void setEvents(List<IBaseEventInfo> events) {
+ for (Iterator<IBaseEventInfo> iterator = events.iterator(); iterator.hasNext();) {
+ IBaseEventInfo eventInfo = (IBaseEventInfo) iterator.next();
+ fEvents.add(eventInfo);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#addEvent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo)
+ */
+ @Override
+ public void addEvent(IBaseEventInfo event) {
+ fEvents.add(event);
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ //PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ output.append("\nPID: ");
+ output.append(fPid);
+ output.append(" - Name: ");
+ output.append(getName());
+ for (Iterator<IBaseEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
+ IBaseEventInfo event = (IBaseEventInfo) iterator.next();
+ output.append(event.formatString());
+ }
+ output.append("\n");
+
+ return output.toString();
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fEvents == null) ? 0 : fEvents.hashCode());
+ result = prime * result + fPid;
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ UstProviderInfo other = (UstProviderInfo) obj;
+ if (fEvents == null) {
+ if (other.fEvents != null) {
+ return false;
+ }
+ } else if (!fEvents.equals(other.fEvents)) {
+ return false;
+ }
+ if (fPid != other.fPid) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuffer output = new StringBuffer();
+ output.append("[EventInfo(");
+ output.append(super.toString());
+ output.append(",PID=");
+ output.append(fPid);
+ output.append(",Events=");
+ if (fEvents.isEmpty()) {
+ output.append("None");
+ } else {
+ for (Iterator<IBaseEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
+ IBaseEventInfo event = (IBaseEventInfo) iterator.next();
+ output.append(event.toString());
+ }
+ }
+ output.append(")]");
+ return output.toString();
+ }
+
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * <b><u>BaseEventPropertySource</u></b>
+ * <p>
+ * Property source implementation for the base event component.
+ * </p>
+ */
+public class BaseEventPropertySource extends BasePropertySource {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * The base event 'name' property ID.
+ */
+ public static final String BASE_EVENT_NAME_PROPERTY_ID = "base.event.name"; //$NON-NLS-1$
+ /**
+ * The base event 'type' property ID.
+ */
+ public static final String BASE_EVENT_TYPE_PROPERTY_ID = "base.event.type"; //$NON-NLS-1$
+ /**
+ * The base event 'log level' property ID.
+ */
+ public static final String BASE_EVENT_LOGLEVEL_PROPERTY_ID = "base.event.loglevel"; //$NON-NLS-1$
+ /**
+ * The base event 'name' property name.
+ */
+ public static final String BASE_EVENT_NAME_PROPERTY_NAME = Messages.TraceControl_EventNamePropertyName;
+ /**
+ * The base event 'type' property name.
+ */
+ public static final String BASE_EVENT_TYPE_PROPERTY_NAME = Messages.TraceControl_EventTypePropertyName;
+ /**
+ * The base event 'log level' property name.
+ */
+ public static final String BASE_EVENT_LOGLEVEL_PROPERTY_NAME = Messages.TraceControl_LogLevelPropertyName;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The base event component which this property source is for.
+ */
+ private final BaseEventComponent fBaseEvent;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param component - the base event component
+ */
+ public BaseEventPropertySource(BaseEventComponent component) {
+ fBaseEvent = component;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
+ */
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> ();
+ list.add(new TextPropertyDescriptor(BASE_EVENT_NAME_PROPERTY_ID, BASE_EVENT_NAME_PROPERTY_NAME));
+ list.add(new TextPropertyDescriptor(BASE_EVENT_TYPE_PROPERTY_ID, BASE_EVENT_TYPE_PROPERTY_NAME));
+ if (fBaseEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) {
+ list.add(new TextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID, BASE_EVENT_LOGLEVEL_PROPERTY_NAME));
+ }
+ return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ public Object getPropertyValue(Object id) {
+ if(BASE_EVENT_NAME_PROPERTY_ID.equals(id)) {
+ return fBaseEvent.getName();
+ }
+ if (BASE_EVENT_TYPE_PROPERTY_ID.equals(id)) {
+ return fBaseEvent.getEventType().name();
+ }
+ if (BASE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) {
+ return fBaseEvent.getLogLevel().name();
+ }
+ return null;
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * <b><u>BaseEventPropertySource</u></b>
+ * <p>
+ * Base property source implementation.
+ * </p>
+ */
+abstract public class BasePropertySource implements IPropertySource {
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
+ */
+ @Override
+ public Object getEditableValue() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
+ */
+ @Override
+ abstract public IPropertyDescriptor[] getPropertyDescriptors();
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ abstract public Object getPropertyValue(Object id);
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
+ */
+ @Override
+ public boolean isPropertySet(Object id) {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
+ */
+ @Override
+ public void resetPropertyValue(Object id) {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void setPropertyValue(Object id, Object value) {
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.KernelProviderComponent;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * <b><u>KernelProviderPropertySource</u></b>
+ * <p>
+ * Property source implementation for the kernl provider component.
+ * </p>
+ */
+public class KernelProviderPropertySource extends BasePropertySource {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The kernel provider 'name' property ID.
+ */
+ public static final String KERNEL_PROVIDER_NAME_PROPERTY_ID = "ust.provider.name"; //$NON-NLS-1$
+ /**
+ * The kernel provider 'name' property name.
+ */
+ public static final String KERNEL_PROVIDER_NAME_PROPERTY_NAME = Messages.TraceControl_ProviderNamePropertyName;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The kernel provider component which this property source is for.
+ */
+ private KernelProviderComponent fProvider;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param component - the kernel provider component
+ */
+ public KernelProviderPropertySource(KernelProviderComponent component) {
+ fProvider = component;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
+ */
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(KERNEL_PROVIDER_NAME_PROPERTY_ID, KERNEL_PROVIDER_NAME_PROPERTY_NAME)};
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ public Object getPropertyValue(Object id) {
+ if(KERNEL_PROVIDER_NAME_PROPERTY_ID.equals(id)) {
+ return fProvider.getName();
+ }
+ return null;
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * <b><u>TargetNodePropertySource</u></b>
+ * <p>
+ * Property source implementation for the target node component.
+ * </p>
+ */
+public class TargetNodePropertySource extends BasePropertySource {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The node name property ID.
+ */
+ public static final String TARGET_NODE_NAME_PROPERTY_ID = "target.node.name"; //$NON-NLS-1$
+ /**
+ * The node address property ID.
+ */
+ public static final String TARGET_NODE_ADDRESS_PROPERTY_ID = "target.node.address"; //$NON-NLS-1$
+ /**
+ * The state property ID.
+ */
+ public static final String TARGET_NODE_STATE_PROPERTY_ID = "target.node.state"; //$NON-NLS-1$
+ /**
+ * The node name property name.
+ */
+ public static final String TARGET_NODE_NAME_PROPERTY_NAME = Messages.TraceControl_HostNamePropertyName;
+ /**
+ * The node address property name.
+ */
+ public static final String TARGET_NODE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_HostAddressPropertyName;
+ /**
+ * The state address property name.
+ */
+ public static final String TARGET_NODE_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The node component which this property source is for.
+ */
+ private final TargetNodeComponent fTargetNode;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param component - the node component
+ */
+ public TargetNodePropertySource(TargetNodeComponent component) {
+ fTargetNode = component;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
+ */
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(TARGET_NODE_NAME_PROPERTY_ID, TARGET_NODE_NAME_PROPERTY_NAME),
+ new TextPropertyDescriptor(TARGET_NODE_ADDRESS_PROPERTY_ID, TARGET_NODE_ADDRESS_PROPERTY_NAME),
+ new TextPropertyDescriptor(TARGET_NODE_STATE_PROPERTY_ID, TARGET_NODE_STATE_PROPERTY_NAME)};
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ public Object getPropertyValue(Object id) {
+ if(TARGET_NODE_NAME_PROPERTY_ID.equals(id)) {
+ return fTargetNode.getName();
+ }
+ if (TARGET_NODE_ADDRESS_PROPERTY_ID.equals(id)) {
+ return fTargetNode.getHostName();
+ }
+ if (TARGET_NODE_STATE_PROPERTY_ID.equals(id)) {
+ return fTargetNode.getTargetNodeState().name();
+ }
+ return null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * <b><u>TraceChannelPropertySource</u></b>
+ * <p>
+ * Property source implementation for the trace channel component.
+ * </p>
+ */
+public class TraceChannelPropertySource extends BasePropertySource {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The trace channel 'name' property ID.
+ */
+ public static final String TRACE_CHANNEL_NAME_PROPERTY_ID = "trace.channel.name"; //$NON-NLS-1$
+ /**
+ * The trace channel 'state' ID.
+ */
+ public static final String TRACE_CHANNEL_STATE_PROPERTY_ID = "trace.channel.state"; //$NON-NLS-1$
+ /**
+ * The trace channel 'overwrite mode' property ID.
+ */
+ public static final String TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID = "trace.channel.overwrite.mode"; //$NON-NLS-1$
+ /**
+ * The trace channel 'sub-buffer size' property ID.
+ */
+ public static final String TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID = "trace.channel.subbuffer.size"; //$NON-NLS-1$
+ /**
+ * The trace channel 'number of sub-buffers' property ID.
+ */
+ public static final String TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID = "trace.channel.no.subbuffers"; //$NON-NLS-1$
+ /**
+ * The trace channel 'switch timer interval' property ID.
+ */
+ public static final String TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID = "trace.channel.switch.timer"; //$NON-NLS-1$
+ /**
+ * The trace channel 'read timer interval' property ID.
+ */
+ public static final String TRACE_CHANNEL_READ_TIMER_PROPERTY_ID = "trace.channel.read.timer"; //$NON-NLS-1$
+ /**
+ * The trace channel 'output type' property ID.
+ */
+ public static final String TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID = "trace.channel.output.type"; //$NON-NLS-1$
+ /**
+ * The trace channel 'name' property name.
+ */
+ public static final String TRACE_CHANNEL_NAME_PROPERTY_NAME = Messages.TraceControl_ChannelNamePropertyName;
+ /**
+ * The trace channel 'state' property name.
+ */
+ public static final String TRACE_CHANNEL_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
+ /**
+ * The trace channel 'overwrite mode' property name.
+ */
+ public static final String TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME = Messages.TraceControl_OverwriteModePropertyName;
+ /**
+ * The trace channel 'sub-buffer size' property name.
+ */
+ public static final String TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME = Messages.TraceControl_SubBufferSizePropertyName;
+ /**
+ * The trace channel 'sub-buffer size' property name.
+ */
+ public static final String TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME = Messages.TraceControl_NbSubBuffersPropertyName;
+ /**
+ * The trace channel 'switch timer interval' property name.
+ */
+ public static final String TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME = Messages.TraceControl_SwitchTimerPropertyName;
+ /**
+ * The trace channel 'read timer interval' property name.
+ */
+ public static final String TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME = Messages.TraceControl_ReadTimerPropertyName;
+ /**
+ * The trace channel 'output type' property name.
+ */
+ public static final String TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME = Messages.TraceControl_OutputTypePropertyName;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The channel component which this property source is for.
+ */
+ private final TraceChannelComponent fChannel;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param component - the channel component
+ */
+ public TraceChannelPropertySource(TraceChannelComponent component) {
+ fChannel = component;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
+ */
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(TRACE_CHANNEL_NAME_PROPERTY_ID, TRACE_CHANNEL_NAME_PROPERTY_NAME),
+ new TextPropertyDescriptor(TRACE_CHANNEL_STATE_PROPERTY_ID, TRACE_CHANNEL_STATE_PROPERTY_NAME),
+ new TextPropertyDescriptor(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID, TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME),
+ new TextPropertyDescriptor(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID, TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME),
+ new TextPropertyDescriptor(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID, TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME),
+ new TextPropertyDescriptor(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID, TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME),
+ new TextPropertyDescriptor(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID, TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME),
+ new TextPropertyDescriptor(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID, TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME)};
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ public Object getPropertyValue(Object id) {
+ if(TRACE_CHANNEL_NAME_PROPERTY_ID.equals(id)) {
+ return fChannel.getName();
+ }
+ if (TRACE_CHANNEL_STATE_PROPERTY_ID.equals(id)) {
+ return fChannel.getState().name();
+ }
+ if(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID.equals(id)) {
+ return String.valueOf(fChannel.isOverwriteMode());
+ }
+ if(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID.equals(id)) {
+ return String.valueOf(fChannel.getSubBufferSize());
+ }
+ if(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID.equals(id)) {
+ return String.valueOf(fChannel.getNumberOfSubBuffers());
+ }
+ if(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID.equals(id)) {
+ return String.valueOf(fChannel.getSwitchTimer());
+ }
+ if(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID.equals(id)) {
+ return String.valueOf(fChannel.getReadTimer());
+ }
+ if(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID.equals(id)) {
+ return fChannel.getOutputType();
+ }
+ return null;
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * <b><u>TraceDomainPropertySource</u></b>
+ * <p>
+ * Property source implementation for the trace domain component.
+ * </p>
+ */
+public class TraceDomainPropertySource extends BasePropertySource {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * The trace domain 'name' property ID.
+ */
+ public static final String TRACE_DOMAIN_NAME_PROPERTY_ID = "trace.domain.name"; //$NON-NLS-1$
+ /**
+ * The trace domain 'name' property name.
+ */
+ public static final String TRACE_DOMAIN_NAME_PROPERTY_NAME = Messages.TraceControl_DomainNamePropertyName;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The trace domain component which this property source is for.
+ */
+ private final TraceDomainComponent fBaseEvent;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param component - the trace domain component
+ */
+ public TraceDomainPropertySource(TraceDomainComponent component) {
+ fBaseEvent = component;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
+ */
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(TRACE_DOMAIN_NAME_PROPERTY_ID, TRACE_DOMAIN_NAME_PROPERTY_NAME)};
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ public Object getPropertyValue(Object id) {
+ if(TRACE_DOMAIN_NAME_PROPERTY_ID.equals(id)) {
+ return fBaseEvent.getName();
+ }
+ return null;
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * <b><u>TraceEventPropertySource</u></b>
+ * <p>
+ * Property source implementation for the trace event component.
+ * </p>
+ */
+public class TraceEventPropertySource extends BasePropertySource {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The trace event 'name' property ID.
+ */
+ public static final String TRACE_EVENT_NAME_PROPERTY_ID = "trace.event.name"; //$NON-NLS-1$
+ /**
+ * The trace event 'type' property ID.
+ */
+ public static final String TRACE_EVENT_TYPE_PROPERTY_ID = "trace.event.type"; //$NON-NLS-1$
+ /**
+ * The trace event 'log level' property ID.
+ */
+ public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_ID = "trace.event.loglevel"; //$NON-NLS-1$
+ /**
+ * The trace event 'state' property ID.
+ */
+ public static final String TRACE_EVENT_STATE_PROPERTY_ID = "trace.event.state"; //$NON-NLS-1$
+ /**
+ * The trace event 'name' property name.
+ */
+ public static final String TRACE_EVENT_NAME_PROPERTY_NAME = Messages.TraceControl_EventNamePropertyName;
+ /**
+ * The trace event 'type' property name.
+ */
+ public static final String TRACE_EVENT_TYPE_PROPERTY_NAME = Messages.TraceControl_EventTypePropertyName;
+ /**
+ * The trace event 'log level' property name.
+ */
+ public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_NAME = Messages.TraceControl_LogLevelPropertyName;
+ /**
+ * The trace event 'state' property name.
+ */
+ public static final String TRACE_EVENT_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The event component which this property source is for.
+ */
+ protected final TraceEventComponent fEvent;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param component - the base event component
+ */
+ public TraceEventPropertySource(TraceEventComponent component) {
+ fEvent = component;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
+ */
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> ();
+ list.add(new TextPropertyDescriptor(TRACE_EVENT_NAME_PROPERTY_ID, TRACE_EVENT_NAME_PROPERTY_NAME));
+ list.add(new TextPropertyDescriptor(TRACE_EVENT_TYPE_PROPERTY_ID, TRACE_EVENT_TYPE_PROPERTY_NAME));
+ list.add( new TextPropertyDescriptor(TRACE_EVENT_STATE_PROPERTY_ID, TRACE_EVENT_STATE_PROPERTY_NAME));
+ if (fEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) {
+ list.add(new TextPropertyDescriptor(TRACE_EVENT_LOGLEVEL_PROPERTY_ID, TRACE_EVENT_LOGLEVEL_PROPERTY_NAME));
+ }
+ return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ public Object getPropertyValue(Object id) {
+ if(TRACE_EVENT_NAME_PROPERTY_ID.equals(id)) {
+ return fEvent.getName();
+ }
+ if (TRACE_EVENT_TYPE_PROPERTY_ID.equals(id)) {
+ return fEvent.getEventType().name();
+ }
+ if (TRACE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) {
+ return fEvent.getLogLevel().name();
+ }
+ if (TRACE_EVENT_STATE_PROPERTY_ID.equals(id)) {
+ return fEvent.getState().name();
+ }
+ return null;
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProbeEventComponent;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * <b><u>TraceEventPropertySource</u></b>
+ * <p>
+ * Property source implementation for the trace probe event component.
+ * </p>
+ */
+public class TraceProbeEventPropertySource extends TraceEventPropertySource {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The trace event 'probe address' property ID.
+ */
+ public static final String TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID = "trace.event.probe.address"; //$NON-NLS-1$
+ /**
+ * The trace event 'probe offset' property ID.
+ */
+ public static final String TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID = "trace.event.probe.offset"; //$NON-NLS-1$
+ /**
+ * The trace event 'probe symbol' property ID.
+ */
+ public static final String TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID = "trace.event.probe.symbol"; //$NON-NLS-1$
+ /**
+ * The trace event 'probe address' property name.
+ */
+ public static final String TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_ProbeAddressPropertyName;
+ /**
+ * The trace event 'probe offset' property ID.
+ */
+ public static final String TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME = Messages.TraceControl_ProbeOffsetPropertyName;
+ /**
+ * The trace event 'probe symbol' property ID.
+ */
+ public static final String TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME = Messages.TraceControl_ProbeSymbolPropertyName;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ public TraceProbeEventPropertySource(TraceEventComponent component) {
+ super(component);
+ if (component.getClass() != TraceProbeEventComponent.class) {
+ throw new IllegalArgumentException("Invalid type passed. Only class of type TraceProbeEventComponent allowed:\n" + component.getClass()); //$NON-NLS-1$
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
+ */
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ IPropertyDescriptor[] superProperties = super.getPropertyDescriptors();
+ List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor>();
+ for (int i = 0; i < superProperties.length; i++) {
+ list.add(superProperties[i]);
+ }
+
+ if (fEvent instanceof TraceProbeEventComponent) {
+ TraceProbeEventComponent event = (TraceProbeEventComponent) fEvent;
+ if (event.getAddress() != null) {
+ list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID, TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME));
+ }
+
+ if (event.getOffset() != null) {
+ list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID, TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME));
+ }
+
+ if (event.getSymbol() != null) {
+ list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID, TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME));
+ }
+ }
+ return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ public Object getPropertyValue(Object id) {
+ if(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID.equals(id)) {
+ return ((TraceProbeEventComponent)fEvent).getAddress();
+ }
+ if (TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID.equals(id)) {
+ return ((TraceProbeEventComponent)fEvent).getOffset();
+ }
+ if (TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID.equals(id)) {
+ return ((TraceProbeEventComponent)fEvent).getSymbol();
+ }
+ return super.getPropertyValue(id);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * <b><u>TraceSessionPropertySource</u></b>
+ * <p>
+ * Property source implementation for the trace session component.
+ * </p>
+ */
+public class TraceSessionPropertySource extends BasePropertySource {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The trace session name property ID.
+ */
+ public static final String TRACE_SESSION_NAME_PROPERTY_ID = "trace.session.name"; //$NON-NLS-1$
+ /**
+ * The trace session path property ID.
+ */
+ public static final String TRACE_SESSION_PATH_PROPERTY_ID = "trace.session.path"; //$NON-NLS-1$
+ /**
+ * The trace session state ID.
+ */
+ public static final String TRACE_SESSION_STATE_PROPERTY_ID = "trace.session.state"; //$NON-NLS-1$
+ /**
+ * The trace session name property name.
+ */
+ public static final String TRACE_SESSION_NAME_PROPERTY_NAME = Messages.TraceControl_SessionNamePropertyName;
+ /**
+ * The trace session path property name.
+ */
+ public static final String TRACE_SESSION_PATH_PROPERTY_NAME = Messages.TraceControl_SessionPathPropertyName;
+ /**
+ * The trace session state property name.
+ */
+ public static final String TRACE_SESSION_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The session component which this property source is for.
+ */
+ private final TraceSessionComponent fSession;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param component - the session component
+ */
+ public TraceSessionPropertySource(TraceSessionComponent component) {
+ fSession = component;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
+ */
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(TRACE_SESSION_NAME_PROPERTY_ID, TRACE_SESSION_NAME_PROPERTY_NAME),
+ new TextPropertyDescriptor(TRACE_SESSION_PATH_PROPERTY_ID, TRACE_SESSION_PATH_PROPERTY_NAME),
+ new TextPropertyDescriptor(TRACE_SESSION_STATE_PROPERTY_ID, TRACE_SESSION_STATE_PROPERTY_NAME)};
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ public Object getPropertyValue(Object id) {
+ if(TRACE_SESSION_NAME_PROPERTY_ID.equals(id)) {
+ return fSession.getName();
+ }
+ if(TRACE_SESSION_PATH_PROPERTY_ID.equals(id)) {
+ return fSession.getSessionPath();
+ }
+ if (TRACE_SESSION_STATE_PROPERTY_ID.equals(id)) {
+ return fSession.getSessionState().name();
+ }
+ return null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderComponent;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * <b><u>UstProviderPropertySource</u></b>
+ * <p>
+ * Property source implementation for the UST provider component.
+ * </p>
+ */
+public class UstProviderPropertySource extends BasePropertySource {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The UST provider 'name' property ID.
+ */
+ public static final String UST_PROVIDER_NAME_PROPERTY_ID = "ust.provider.name"; //$NON-NLS-1$
+ /**
+ * The UST provider 'PID' property ID.
+ */
+ public static final String UST_PROVIDER_PID_PROPERTY_ID = "ust.provider.pid"; //$NON-NLS-1$
+ /**
+ * The UST provider 'name' property name.
+ */
+ public static final String UST_PROVIDER_NAME_PROPERTY_NAME = Messages.TraceControl_ProviderNamePropertyName;
+ /**
+ * The UST provider 'type' property name.
+ */
+ public static final String UST_PROVIDER_PID_PROPERTY_NAME = Messages.TraceControl_ProcessIdPropertyName;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The UST provider component which this property source is for.
+ */
+ private UstProviderComponent fUstProvider;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param component - the UST provider component
+ */
+ public UstProviderPropertySource(UstProviderComponent component) {
+ fUstProvider = component;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
+ */
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(UST_PROVIDER_NAME_PROPERTY_ID, UST_PROVIDER_NAME_PROPERTY_NAME),
+ new TextPropertyDescriptor(UST_PROVIDER_PID_PROPERTY_ID, UST_PROVIDER_PID_PROPERTY_NAME)};
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ public Object getPropertyValue(Object id) {
+ if(UST_PROVIDER_NAME_PROPERTY_ID.equals(id)) {
+ return fUstProvider.getName();
+ }
+ if (UST_PROVIDER_PID_PROPERTY_ID.equals(id)) {
+ return String.valueOf(fUstProvider.getPid());
+ }
+ return null;
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandShell;
+import org.eclipse.rse.core.model.IRSECallback;
+import org.eclipse.rse.core.subsystems.ICommunicationsListener;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.services.shells.IShellService;
+import org.eclipse.rse.services.terminals.ITerminalService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+
+/**
+ * <b><u>IRemoteSystemProxy</u></b>
+ * <p>
+ * Remote System Proxy interface.
+ * </p>
+ */
+public interface IRemoteSystemProxy {
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Find the first shell service.
+ *
+ * @return shell service object, or <code>null</code> if not found.
+ */
+ public IShellService getShellService();
+
+ /**
+ * Find the first terminal service.
+ *
+ * @return shell service object, or <code>null</code> if not found.
+ */
+ public ITerminalService getTerminalService();
+
+ /**
+ * Find the first IShellServiceSubSystem service.
+ *
+ * @return shell service subsystem, or <code>null</code> if not found.
+ */
+ public ISubSystem getShellServiceSubSystem();
+
+ /**
+ * Find the first ITerminalServiceSubSystem service.
+ *
+ * @param host the connection
+ * @return shell service subsystem, or <code>null</code> if not found.
+ */
+ public ISubSystem getTerminalServiceSubSystem();
+
+ /**
+ * Finds the File Service Subsystem.
+ * @return file service subsystem, or <code>null</code> if not found.
+ */
+ public IFileServiceSubSystem getFileServiceSubSystem();
+
+ /**
+ * Connects the shell service sub system.
+ *
+ * @param callback - call-back method being called when connection was finished
+ * @throws Exception
+ */
+ public void connect(IRSECallback callback) throws ExecutionException;
+
+ /**
+ * Disconnects from the shell service sub system.
+ *
+ * @throws Exception
+ */
+ public void disconnect() throws ExecutionException;
+
+ /**
+ * Creates a command shell.
+ *
+ * @return the command shell implementation
+ * @throws Exception
+ */
+ public ICommandShell createCommandShell() throws ExecutionException;
+
+ /**
+ * Method to add a communication listener to the connector service defined for
+ * the given connection.
+ *
+ * @param listener - listener to add
+ * @throws Exception
+ */
+ public void addCommunicationListener(ICommunicationsListener listener);
+
+ /**
+ * Method to remove a communication listener from the connector service defined for
+ * the given connection.
+ *
+ * @param listener - listener to remove
+ * @throws Exception
+ */
+ public void removeCommunicationListener(ICommunicationsListener listener);
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.CommandShell;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandShell;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.IRSECallback;
+import org.eclipse.rse.core.subsystems.ICommunicationsListener;
+import org.eclipse.rse.core.subsystems.IConnectorService;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.services.IService;
+import org.eclipse.rse.services.shells.IShellService;
+import org.eclipse.rse.services.terminals.ITerminalService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+
+/**
+ * <b><u>RemoteSystemProxy</u></b>
+ * <p>
+ * RemoteSystemProxy implementation.
+ * </p>
+ */
+public class RemoteSystemProxy implements IRemoteSystemProxy {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ private IHost fHost;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ public RemoteSystemProxy(IHost host) {
+ fHost = host;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getShellService(org.eclipse.rse.core.model.IHost)
+ */
+ @Override
+ public IShellService getShellService() {
+ ISubSystem ss = getShellServiceSubSystem();
+ if (ss != null) {
+ return (IShellService)ss.getSubSystemConfiguration().getService(fHost).getAdapter(IShellService.class);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getTerminalService()
+ */
+ @Override
+ public ITerminalService getTerminalService() {
+ ISubSystem ss = getTerminalServiceSubSystem();
+ if (ss != null) {
+ return (ITerminalService)ss.getSubSystemConfiguration().getService(fHost).getAdapter(ITerminalService.class);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getShellServiceSubSystem()
+ */
+ @Override
+ public ISubSystem getShellServiceSubSystem() {
+ if (fHost == null) {
+ return null;
+ }
+ ISubSystem[] subSystems = fHost.getSubSystems();
+ IShellService ssvc = null;
+ for (int i = 0; subSystems != null && i < subSystems.length; i++) {
+ IService svc = subSystems[i].getSubSystemConfiguration().getService(fHost);
+ if (svc!=null) {
+ ssvc = (IShellService)svc.getAdapter(IShellService.class);
+ if (ssvc != null) {
+ return subSystems[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getTerminalServiceSubSystem()
+ */
+ @Override
+ public ISubSystem getTerminalServiceSubSystem() {
+ if (fHost == null) {
+ return null;
+ }
+ ISubSystem[] subSystems = fHost.getSubSystems();
+ ITerminalService ssvc = null;
+ for (int i = 0; subSystems != null && i < subSystems.length; i++) {
+ IService svc = subSystems[i].getSubSystemConfiguration().getService(fHost);
+ if (svc!=null) {
+ ssvc = (ITerminalService)svc.getAdapter(ITerminalService.class);
+ if (ssvc != null) {
+ return subSystems[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy#getFileServiceSubSystem()
+ */
+ @Override
+ public IFileServiceSubSystem getFileServiceSubSystem() {
+ if (fHost == null) {
+ return null;
+ }
+ ISubSystem[] subSystems = fHost.getSubSystems();
+ for (int i = 0; subSystems != null && i < subSystems.length; i++) {
+ if (subSystems[i] instanceof IFileServiceSubSystem) {
+ return (IFileServiceSubSystem)subSystems[i];
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#connect(org.eclipse.rse.core.model.IRSECallback)
+ */
+ @Override
+ public void connect(IRSECallback callback) throws ExecutionException {
+ ISubSystem shellSubSystem = getShellServiceSubSystem();
+ if (shellSubSystem != null) {
+ if (!shellSubSystem.isConnected()) {
+ try {
+ shellSubSystem.connect(false, callback);
+ } catch (Exception e) {
+ throw new ExecutionException(e.toString(), e);
+ }
+ } else {
+ callback.done(Status.OK_STATUS, null);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#disconnect()
+ */
+ @Override
+ public void disconnect() throws ExecutionException {
+ ISubSystem shellSubSystem = getShellServiceSubSystem();
+ if (shellSubSystem != null) {
+ try {
+ shellSubSystem.disconnect();
+ } catch (Exception e) {
+ throw new ExecutionException(e.toString(), e);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#createCommandShell()
+ */
+ @Override
+ public ICommandShell createCommandShell() throws ExecutionException {
+ ICommandShell shell = new CommandShell(this);
+ shell.connect();
+ return shell;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#addCommunicationListener(org.eclipse.rse.core.subsystems.ICommunicationsListener)
+ */
+ @Override
+ public void addCommunicationListener(ICommunicationsListener listener) {
+ IConnectorService[] css = fHost.getConnectorServices();
+ for (IConnectorService cs : css) {
+ cs.addCommunicationsListener(listener);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#removeCommunicationListener(org.eclipse.rse.core.subsystems.ICommunicationsListener)
+ */
+ @Override
+ public void removeCommunicationListener(ICommunicationsListener listener) {
+ IConnectorService[] css = fHost.getConnectorServices();
+ for (IConnectorService cs : css) {
+ cs.removeCommunicationsListener(listener);
+ }
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.service;
+
+import java.util.Arrays;
+
+/**
+ * <b><u>CommandResult</u></b>
+ * <p>
+ * Class containing command result of remote command execution.
+ * </p>
+ */
+public class CommandResult implements ICommandResult {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The result of the command. 0 if successful else > 0
+ */
+ private int fResult;
+
+ /**
+ * The output as String array.
+ */
+ private String[] fOutput = new String[0];
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+ public CommandResult(int result, String[] output) {
+ fResult = result;
+ if (output != null) {
+ fOutput = Arrays.copyOf(output, output.length);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessor
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandResult#getResult()
+ */
+ @Override
+ public int getResult() {
+ return fResult;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandResult#setResult(int)
+ */
+ @Override
+ public void setResult(int result) {
+ fResult = result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandResult#getOutput()
+ */
+ @Override
+ public String[] getOutput() {
+ return Arrays.copyOf(fOutput, fOutput.length);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandResult#setOutput(java.lang.String[])
+ */
+ @Override
+ public void setOutput(String[] output) {
+ fOutput = new String[0];
+ if (output != null) {
+ fOutput = Arrays.copyOf(output, output.length);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Patrick Tasse - Initial API and implementation
+ * Bernd Hufmann - Updated using Executor Framework
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.service;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy;
+import org.eclipse.rse.services.shells.HostShellProcessAdapter;
+import org.eclipse.rse.services.shells.IHostShell;
+import org.eclipse.rse.services.shells.IShellService;
+
+/**
+ * <b><u>CommandShell</u></b>
+ * <p>
+ * Implementation of remote command execution using RSE's shell service.
+ * </p>
+ */
+public class CommandShell implements ICommandShell {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ // 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$
+
+ //command delimiter for shell
+ public final static String CMD_DELIMITER = "\n"; //$NON-NLS-1$
+
+ public final static String SHELL_ECHO_CMD = " echo "; //$NON-NLS-1$
+
+ private final static int DEFAULT_TIMEOUT_VALUE = 15000; // in milliseconds
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ private IRemoteSystemProxy fProxy = null;
+ private IHostShell fHostShell = null;
+ private BufferedReader fBufferReader = null;
+ private ExecutorService fExecutor = Executors.newFixedThreadPool(1);
+ private boolean fIsConnected = false;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ public CommandShell(IRemoteSystemProxy proxy) {
+ fProxy = proxy;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandShell#connect()
+ */
+ @Override
+ public void connect() throws ExecutionException {
+ IShellService shellService = fProxy.getShellService();
+ Process p = null;
+ try {
+ fHostShell = shellService.launchShell("", new String[0], new NullProgressMonitor()); //$NON-NLS-1$
+ p = new HostShellProcessAdapter(fHostShell);
+ } catch (Exception e) {
+ throw new ExecutionException(Messages.TraceControl_CommandShellError, e);
+ }
+ fBufferReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ fIsConnected = true;
+
+ // Flush Login messages
+ executeCommand(" ", new NullProgressMonitor(), false); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandShell#disconnect()
+ */
+ @Override
+ public void disconnect() {
+ fIsConnected = false;
+ try {
+ fBufferReader.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandShell#executeCommand(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public ICommandResult executeCommand(String command, IProgressMonitor monitor) throws ExecutionException {
+ return executeCommand(command, monitor, true);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandShell#executeCommand(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean)
+ */
+ @Override
+ public ICommandResult executeCommand(final String command, final IProgressMonitor monitor, final boolean checkReturnValue) throws ExecutionException {
+ if (fIsConnected) {
+ FutureTask<CommandResult> future = new FutureTask<CommandResult>(new Callable<CommandResult>() {
+ @Override
+ public CommandResult call() throws IOException, CancellationException {
+ final ArrayList<String> result = new ArrayList<String>();
+ int returnValue = 0;
+
+ synchronized (fHostShell) {
+ fHostShell.writeToShell(formatShellCommand(command));
+ String nextLine;
+ while ((nextLine = fBufferReader.readLine()) != null) {
+
+ if (monitor.isCanceled()) {
+ flushInput();
+ throw new CancellationException();
+ }
+
+ if (nextLine.contains(DONE_MARKUP_STRING) && nextLine.contains(SHELL_ECHO_CMD)) {
+ break;
+ }
+ }
+
+ while ((nextLine = fBufferReader.readLine()) != null) {
+ // check if job was cancelled
+ if (monitor.isCanceled()) {
+ flushInput();
+ throw new CancellationException();
+ }
+
+ if (!nextLine.contains(DONE_MARKUP_STRING)) {
+ result.add(nextLine);
+ } else {
+ if (checkReturnValue) {
+ returnValue = Integer.valueOf(nextLine.substring(DONE_MARKUP_STRING.length()+1));
+ }
+ break;
+ }
+ }
+
+ flushInput();
+ }
+ return new CommandResult(returnValue, result.toArray(new String[result.size()]));
+ }
+ });
+
+ fExecutor.execute(future);
+
+ try {
+ return future.get(DEFAULT_TIMEOUT_VALUE, TimeUnit.MILLISECONDS);
+ } catch (java.util.concurrent.ExecutionException ex) {
+ throw new ExecutionException(Messages.TraceControl_ExecutionFailure, ex);
+ } catch (InterruptedException ex) {
+ throw new ExecutionException(Messages.TraceControl_ExecutionCancelled, ex);
+ } catch (TimeoutException ex) {
+ throw new ExecutionException(Messages.TraceControl_ExecutionTimeout, ex);
+ }
+ }
+ throw new ExecutionException(Messages.TraceControl_ShellNotConnected, null);
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ /**
+ * Flushes the buffer reader
+ * @throws IOException
+ */
+ private void flushInput() throws IOException {
+ char[] cbuf = new char[1];
+ while (fBufferReader.ready()) {
+ if (fBufferReader.read(cbuf, 0, 1) == -1) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * format the command to be sent into the shell command with the done markup string.
+ * The done markup string is needed so we can tell that end of output has been reached.
+ *
+ * @param cmd
+ * @return formatted command string
+ */
+ private String formatShellCommand(String cmd) {
+ if (cmd == null || cmd.equals("")) //$NON-NLS-1$
+ return cmd;
+ StringBuffer formattedCommand = new StringBuffer();
+ // Make a multi line command by using \ and \r. This is needed for matching
+ // the DONE_MARKUP_STRING in echoed command when having a long command
+ // (bigger than max SSH line)
+ formattedCommand.append(cmd).append("\\\r;"); //$NON-NLS-1$
+ formattedCommand.append(SHELL_ECHO_CMD).append(DONE_MARKUP_STRING);
+ formattedCommand.append(" $?"); //$NON-NLS-1$
+ formattedCommand.append(CMD_DELIMITER);
+ return formattedCommand.toString();
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ *********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.service;
+
+/**
+ * <b><u>IommandResult</u></b>
+ * <p>
+ * Interface for providing command execution result.
+ * </p>
+ */
+public interface ICommandResult {
+ /**
+ * The result of the command.
+ * @return 0 if successful else >0
+ */
+ public int getResult() ;
+
+ /**
+ * Sets the command result value.
+ * @param result
+ */
+ public void setResult(int result);
+
+ /**
+ * @return returns the command output.
+ */
+ public String[] getOutput();
+
+ /**
+ * Sets the command output.
+ * @param output
+ */
+ public void setOutput(String[] output);
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.service;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * <b><u>ICommandShell</u></b>
+ * <p>
+ * Interface for a command shell implementation
+ * </p>
+ */
+public interface ICommandShell {
+
+ /**
+ * Method to connect the command shell.
+ * @throws ExecutionException
+ */
+ public void connect() throws ExecutionException;
+
+ /**
+ * Method to disconnect the command shell.
+ */
+ public void disconnect();
+
+ /**
+ * Method to execute a command on the command shell.
+ *
+ * @param command - the command to executed
+ * @param monitor - a progress monitor
+ * @return the command result
+ * @throws ExecutionException
+ */
+ public ICommandResult executeCommand(String command, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Method to execute a command on the command shell.
+ *
+ * @param command - the command to executed
+ * @param monitor - a progress monitor
+ * @param checkReturnValue - flag to indicate that the command result should be checked. If false the command result will be always 0.
+ * @return the command result
+ * @throws ExecutionException
+ */
+ public ICommandResult executeCommand(final String command, final IProgressMonitor monitor, final boolean checkReturnValue) throws ExecutionException;
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.service;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+
+
+/** <b><u>ILttngControlService</u></b>
+* <p>
+* Interface for LTTng trace control command service.
+* </p>
+*/
+public interface ILttngControlService {
+ /**
+ * Retrieves the existing sessions names from the node.
+ * @param monitor - a progress monitor
+ * @return an array with session names.
+ * @throws ExecutionException
+ */
+ public String[] getSessionNames(IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Retrieves the session information with the given name the node.
+ * @param sessionName - the session name
+ * @param monitor - a progress monitor
+ * @return session information
+ * @throws ExecutionException
+ */
+ public ISessionInfo getSession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Retrieves the kernel provider information (i.e. the kernel events)
+ * @param monitor - a progress monitor
+ * @return the list of existing kernel events.
+ * @throws ExecutionException
+ */
+ public List<IBaseEventInfo> getKernelProvider(IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Retrieves the UST provider information from the node.
+ * @return - the UST provider information.
+ * @throws ExecutionException
+ */
+ public List<IUstProviderInfo> getUstProvider() throws ExecutionException;
+ /**
+ * Retrieves the UST provider information from the node.
+ * @param monitor - a progress monitor
+ * @return the UST provider information.
+ * @throws ExecutionException
+ */
+ public List<IUstProviderInfo> getUstProvider(IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Creates a session with given session name and location.
+ * @param sessionName - a session name to create
+ * @param sessionPath - a path for storing the traces (use null for default)
+ * @param monitor - a progress monitor
+ * @return the session information
+ * @throws ExecutionException
+ */
+ public ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Destroys a session with given session name.
+ * @param sessionName - a session name to destroy
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void destroySession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Starts a session with given session name.
+ * @param sessionName - a session name to start
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void startSession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Stops a session with given session name.
+ * @param sessionName - a session name to stop
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void stopSession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
+
+
+ /**
+ * Enables a list of channels for given session and given channel information (configuration).
+ * @param sessionName - a session name to create
+ * @param channelNames - a list of channel names to be enabled
+ * @param isKernel - a flag to indicate Kernel or UST (true for Kernel, false for UST)
+ * @param info - channel information used for creation of a channel (or null for default)
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableChannels(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Disables a list of channels for given session and given channel information (configuration).
+ * @param sessionName - a session name to create
+ * @param channelNames - a list of channel names to be enabled
+ * @param isKernel - a flag to indicate Kernel or UST (true for Kernel, false for UST)
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void disableChannels(String sessionName, List<String> channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param sessionName - a session name
+ * @param channelName - a channel name or null for default channel
+ * @param eventNames - a list of event names to be enabled, or null (list of size = 0)for all events .
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableEvents(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Enables all syscall events.
+ * @param sessionName - a session name
+ * @param channelName - a channel name or null for default channel
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableSyscalls(String sessionName, String channelName, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Enables a dynamic probe or dynamic function entry/return probe.
+ * @param sessionName - a session name
+ * @param channelName - a channel name or null for default channel
+ * @param eventName - a event name
+ * @param isFunction - true for dynamic function entry/return probe else false
+ * @param probe - a dynamic probe information
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableProbe(String sessionName, String channelName, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Enables events using log level
+ * @param sessionName - a session name
+ * @param channelName - a channel name (null for default channel)
+ * @param eventName - a event name
+ * @param logLevelType - a log level type
+ * @param level - a log level
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableLogLevel(String sessionName, String channelName, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Disables a list of events with no additional parameters.
+ * @param sessionName - a session name
+ * @param channelName - a channel name (null for default channel)
+ * @param eventNames - a list of event names to enabled.
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void disableEvent(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.service;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IProbeEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.DomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.EventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ProbeEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.SessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderInfo;
+
+/**
+ * <b><u>LTTngControlService</u></b>
+ * <p>
+ * Service for sending LTTng trace control commands to remote host.
+ * </p>
+ */
+public class LTTngControlService implements ILttngControlService {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ // Command constants
+ /**
+ * The lttng tools command.
+ */
+ private final static String CONTROL_COMMAND = "lttng"; //$NON-NLS-1$
+ /**
+ * Command: lttng list.
+ */
+ private final static String COMMAND_LIST = CONTROL_COMMAND + " list "; //$NON-NLS-1$
+ /**
+ * Command to list kernel tracer information.
+ */
+ private final static String COMMAND_LIST_KERNEL = COMMAND_LIST + "-k"; //$NON-NLS-1$
+ /**
+ * Command to list user space trace information.
+ */
+ private final static String COMMAND_LIST_UST = COMMAND_LIST + "-u"; //$NON-NLS-1$
+ /**
+ * Command to create a session.
+ */
+ private final static String COMMAND_CREATE_SESSION = CONTROL_COMMAND + " create "; //$NON-NLS-1$
+ /**
+ * Command to destroy a session.
+ */
+ private final static String COMMAND_DESTROY_SESSION = CONTROL_COMMAND + " destroy "; //$NON-NLS-1$
+ /**
+ * Command to destroy a session.
+ */
+ private final static String COMMAND_START_SESSION = CONTROL_COMMAND + " start "; //$NON-NLS-1$
+ /**
+ * Command to destroy a session.
+ */
+ private final static String COMMAND_STOP_SESSION = CONTROL_COMMAND + " stop "; //$NON-NLS-1$
+ /**
+ * Command to enable a channel.
+ */
+ private final static String COMMAND_ENABLE_CHANNEL = CONTROL_COMMAND + " enable-channel "; //$NON-NLS-1$
+ /**
+ * Command to disable a channel.
+ */
+ private final static String COMMAND_DISABLE_CHANNEL = CONTROL_COMMAND + " disable-channel "; //$NON-NLS-1$
+ /**
+ * Command to enable a event.
+ */
+ private final static String COMMAND_ENABLE_EVENT = CONTROL_COMMAND + " enable-event "; //$NON-NLS-1$
+ /**
+ * Command to disable a event.
+ */
+ private final static String COMMAND_DISABLE_EVENT = CONTROL_COMMAND + " disable-event "; //$NON-NLS-1$
+
+ // Command options constants
+ /**
+ * Command line option for kernel tracer.
+ */
+ private final static String OPTION_KERNEL = " -k "; //$NON-NLS-1$
+ /**
+ * Command line option for UST tracer.
+ */
+ private final static String OPTION_UST = " -u "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a session.
+ */
+ private final static String OPTION_SESSION = " -s "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a channel.
+ */
+ private final static String OPTION_CHANNEL = " -c "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying all events.
+ */
+ private final static String OPTION_ALL = " -a "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying tracepoint events.
+ */
+ private final static String OPTION_TRACEPOINT = " --tracepoint "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying syscall events.
+ */
+ private final static String OPTION_SYSCALL = " --syscall "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a dynamic probe.
+ */
+ private final static String OPTION_PROBE = " --probe "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a dynamic function entry/return probe.
+ */
+ private final static String OPTION_FUNCTION_PROBE = " --function "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a log level range.
+ */
+ private final static String OPTION_LOGLEVEL = " --loglevel "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a specific log level.
+ */
+ private final static String OPTION_LOGLEVEL_ONLY = " --loglevel-only "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's overwrite mode.
+ */
+ private final static String OPTION_OVERWRITE = " --overwrite "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's number of sub buffers.
+ */
+ private final static String OPTION_NUM_SUB_BUFFERS = " --num-subbuf "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's sub buffer size.
+ */
+ private final static String OPTION_SUB_BUFFER_SIZE = " --subbuf-size "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's switch timer interval.
+ */
+ private final static String OPTION_SWITCH_TIMER = " --switch-timer "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's read timer interval.
+ */
+ private final static String OPTION_READ_TIMER = " --read-timer "; //$NON-NLS-1$
+
+ // Parsing constants
+ /**
+ * Pattern to match for error output
+ */
+ private final static Pattern ERROR_PATTERN = Pattern.compile("\\s*Error\\:.*"); //$NON-NLS-1$
+ /**
+ * Pattern to match for session information (lttng list)
+ */
+ private final static Pattern SESSION_PATTERN = Pattern.compile("\\s+(\\d+)\\)\\s+(.*)\\s+\\((.*)\\)\\s+\\[(active|inactive)\\].*"); //$NON-NLS-1$
+ /**
+ * Pattern to match for session information (lttng list <session>)
+ */
+ private final static Pattern TRACE_SESSION_PATTERN = Pattern.compile("\\s*Tracing\\s+session\\s+(.*)\\:\\s+\\[(active|inactive)\\].*"); //$NON-NLS-1$
+ /**
+ * Pattern to match for session path information (lttng list <session>)
+ */
+ private final static Pattern TRACE_SESSION_PATH_PATTERN = Pattern.compile("\\s*Trace\\s+path\\:\\s+(.*)"); //$NON-NLS-1$
+ /**
+ * Pattern to match for kernel domain information (lttng list <session>)
+ */
+ private final static Pattern DOMAIN_KERNEL_PATTERN = Pattern.compile("=== Domain: Kernel ==="); //$NON-NLS-1$
+ /**
+ * Pattern to match for ust domain information (lttng list <session>)
+ */
+ private final static Pattern DOMAIN_UST_GLOBAL_PATTERN = Pattern.compile("=== Domain: UST global ==="); //$NON-NLS-1$
+ /**
+ * Pattern to match for channels section (lttng list <session>)
+ */
+ private final static Pattern CHANNELS_SECTION_PATTERN = Pattern.compile("\\s*Channels\\:"); //$NON-NLS-1$
+ /**
+ * Pattern to match for channel information (lttng list <session>)
+ */
+ private final static Pattern CHANNEL_PATTERN = Pattern.compile("\\s*-\\s+(.*)\\:\\s+\\[(enabled|disabled)\\]"); //$NON-NLS-1$
+ /**
+ * Pattern to match for events section information (lttng list <session>)
+ */
+ private final static Pattern EVENT_SECTION_PATTERN = Pattern.compile("\\s*Events\\:"); //$NON-NLS-1$
+ /**
+ * Pattern to match for event information (no enabled events) (lttng list <session>)
+ */
+ // private final static String EVENT_NONE_PATTERN = "\\s+None"; //$NON-NLS-1$
+ /**
+ * Pattern to match for event information (lttng list <session>)
+ */
+ private final static Pattern EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
+ /**
+ * Pattern to match a wildcarded event information (lttng list <session>)
+ */
+ private final static Pattern WILDCARD_EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
+ /**
+ * Pattern to match a probe address information (lttng list <session>)
+ */
+ private final static Pattern PROBE_ADDRESS_PATTERN = Pattern.compile("\\s+(addr)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
+ /**
+ * Pattern to match a probe OFFSET information (lttng list <session>)
+ */
+ private final static Pattern PROBE_OFFSET_PATTERN = Pattern.compile("\\s+(offset)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
+ /**
+ * Pattern to match a probe SYMBOL information (lttng list <session>)
+ */
+ private final static Pattern PROBE_SYMBOL_PATTERN = Pattern.compile("\\s+(symbol)\\:\\s+(.+)"); //$NON-NLS-1$
+ /**
+ * Pattern to match for channel (overwite mode) information (lttng list
+ * <session>)
+ */
+ private final static Pattern OVERWRITE_MODE_ATTRIBUTE = Pattern.compile("\\s+overwrite\\s+mode\\:.*"); //$NON-NLS-1$
+ /**
+ * Pattern to match indicating false for overwrite mode
+ */
+ private final static String OVERWRITE_MODE_ATTRIBUTE_FALSE = "0"; //$NON-NLS-1$
+ /**
+ * Pattern to match for channel (sub-buffer size) information (lttng list
+ * <session>)
+ */
+ private final static Pattern SUBBUFFER_SIZE_ATTRIBUTE = Pattern.compile("\\s+subbufers\\s+size\\:.*"); //$NON-NLS-1$
+ /**
+ * Pattern to match for channel (number of sub-buffers) information (lttng
+ * list <session>)
+ */
+ private final static Pattern NUM_SUBBUFFERS_ATTRIBUTE = Pattern.compile("\\s+number\\s+of\\s+subbufers\\:.*"); //$NON-NLS-1$
+ /**
+ * Pattern to match for channel (switch timer) information (lttng list
+ * <session>)
+ */
+ private final static Pattern SWITCH_TIMER_ATTRIBUTE = Pattern.compile("\\s+switch\\s+timer\\s+interval\\:.*"); //$NON-NLS-1$
+ /**
+ * Pattern to match for channel (read timer) information (lttng list
+ * <session>)
+ */
+ private final static Pattern READ_TIMER_ATTRIBUTE = Pattern.compile("\\s+read\\s+timer\\s+interval\\:.*"); //$NON-NLS-1$
+ /**
+ * Pattern to match for channel (output type) information (lttng list
+ * <session>)
+ */
+ private final static Pattern OUTPUT_ATTRIBUTE = Pattern.compile("\\s+output\\:.*"); //$NON-NLS-1$
+ /**
+ * Pattern to match for provider information (lttng list -k/-u)
+ */
+ private final static Pattern PROVIDER_EVENT_PATTERN = Pattern.compile("\\s*(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)"); //$NON-NLS-1$
+ /**
+ * Pattern to match for UST provider information (lttng list -u)
+ */
+ private final static Pattern UST_PROVIDER_PATTERN = Pattern.compile("\\s*PID\\:\\s+(\\d+)\\s+-\\s+Name\\:\\s+(.*)"); //$NON-NLS-1$
+ /**
+ * Pattern to match for session information (lttng create <session name>)
+ */
+ private final static Pattern CREATE_SESSION_NAME_PATTERN = Pattern.compile("\\s*Session\\s+(.*)\\s+created\\."); //$NON-NLS-1$
+ /**
+ * Pattern to match for session path information (lttng create <session name>)
+ */
+ private final static Pattern CREATE_SESSION_PATH_PATTERN = Pattern.compile("\\s*Traces\\s+will\\s+be\\s+written\\s+in\\s+(.*).*"); //$NON-NLS-1$
+ /**
+ * Pattern to match for session command output for "session name not found".
+ */
+ private final static Pattern SESSION_NOT_FOUND_ERROR_PATTERN = Pattern.compile("\\s*Error:\\s+Session\\s+name\\s+not\\s+found"); //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The command shell implementation
+ */
+ private ICommandShell fCommandShell = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ *
+ * @param shell
+ * - the command shell implementation to use
+ */
+ public LTTngControlService(ICommandShell shell) {
+ fCommandShell = shell;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
+ * #getSessionNames(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public String[] getSessionNames(IProgressMonitor monitor) throws ExecutionException {
+
+ String command = COMMAND_LIST;
+ ICommandResult result = fCommandShell.executeCommand(command, monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Output:
+ // Available tracing sessions:
+ // 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928)
+ // [inactive]
+ // 2) mysession (/home/user/lttng-traces/mysession-20120123-083318)
+ // [inactive]
+ //
+ // Use lttng list <session_name> for more details
+
+ ArrayList<String> retArray = new ArrayList<String>();
+ int index = 0;
+ while (index < result.getOutput().length) {
+ String line = result.getOutput()[index];
+ Matcher matcher = SESSION_PATTERN.matcher(line);
+ if (matcher.matches()) {
+ retArray.add(matcher.group(2).trim());
+ }
+ index++;
+ }
+ return retArray.toArray(new String[retArray.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
+ * #getSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public ISessionInfo getSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+
+ String command = COMMAND_LIST + sessionName;
+ ICommandResult result = fCommandShell.executeCommand(command, monitor);
+
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ int index = 0;
+
+ // Output:
+ // Tracing session mysession2: [inactive]
+ // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330
+ ISessionInfo sessionInfo = new SessionInfo(sessionName);
+
+ while (index < result.getOutput().length) {
+ // Tracing session mysession2: [inactive]
+ // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330
+ //
+ // === Domain: Kernel ===
+ //
+ String line = result.getOutput()[index];
+ Matcher matcher = TRACE_SESSION_PATTERN.matcher(line);
+ if (matcher.matches()) {
+ sessionInfo.setSessionState(matcher.group(2));
+ index++;
+ continue;
+ }
+
+ matcher = TRACE_SESSION_PATH_PATTERN.matcher(line);
+ if (matcher.matches()) {
+ sessionInfo.setSessionPath(matcher.group(1).trim());
+ index++;
+ continue;
+ }
+
+ matcher = DOMAIN_KERNEL_PATTERN.matcher(line);
+ if (matcher.matches()) {
+ // Create Domain
+ IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_KernelDomainDisplayName);
+ sessionInfo.addDomain(domainInfo);
+
+ // in domain kernel
+ ArrayList<IChannelInfo> channels = new ArrayList<IChannelInfo>();
+ index = parseDomain(result.getOutput(), index, channels);
+
+ // set channels
+ domainInfo.setChannels(channels);
+
+ // set kernel flag
+ domainInfo.setIsKernel(true);
+ continue;
+ }
+
+ matcher = DOMAIN_UST_GLOBAL_PATTERN.matcher(line);
+ if (matcher.matches()) {
+ IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_UstGlobalDomainDisplayName);
+ sessionInfo.addDomain(domainInfo);
+
+ // in domain UST
+ ArrayList<IChannelInfo> channels = new ArrayList<IChannelInfo>();
+ index = parseDomain(result.getOutput(), index, channels);
+
+ // set channels
+ domainInfo.setChannels(channels);
+
+ // set kernel flag
+ domainInfo.setIsKernel(false);
+ continue;
+ }
+ index++;
+ }
+ return sessionInfo;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
+ * #getKernelProvider(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public List<IBaseEventInfo> getKernelProvider(IProgressMonitor monitor) throws ExecutionException {
+ String command = COMMAND_LIST_KERNEL;
+ ICommandResult result = fCommandShell.executeCommand(command, monitor);
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Kernel events:
+ // -------------
+ // sched_kthread_stop (type: tracepoint)
+ List<IBaseEventInfo> events = new ArrayList<IBaseEventInfo>();
+ getProviderEventInfo(result.getOutput(), 0, events);
+ return events;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
+ * #getUstProvider()
+ */
+ @Override
+ public List<IUstProviderInfo> getUstProvider() throws ExecutionException {
+ return getUstProvider(new NullProgressMonitor());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
+ * #getUstProvider(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public List<IUstProviderInfo> getUstProvider(IProgressMonitor monitor) throws ExecutionException {
+ String command = COMMAND_LIST_UST;
+ ICommandResult result = fCommandShell.executeCommand(command, monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // UST events:
+ // -------------
+ //
+ // PID: 3635 - Name:
+ // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
+ // tracepoint)
+ // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
+ //
+ // PID: 6459 - Name:
+ // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
+ // tracepoint)
+ // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
+
+ List<IUstProviderInfo> allProviders = new ArrayList<IUstProviderInfo>();
+ IUstProviderInfo provider = null;
+
+ int index = 0;
+ while (index < result.getOutput().length) {
+ String line = result.getOutput()[index];
+ Matcher matcher = UST_PROVIDER_PATTERN.matcher(line);
+ if (matcher.matches()) {
+
+ provider = new UstProviderInfo(matcher.group(2).trim());
+ provider.setPid(Integer.valueOf(matcher.group(1).trim()));
+ List<IBaseEventInfo> events = new ArrayList<IBaseEventInfo>();
+ index = getProviderEventInfo(result.getOutput(), ++index, events);
+ provider.setEvents(events);
+ allProviders.add(provider);
+
+ } else {
+ index++;
+ }
+
+ }
+ return allProviders;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#createSession(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+
+ String newName = formatParameter(sessionName);
+ String newPath = formatParameter(sessionPath);
+
+ String command = COMMAND_CREATE_SESSION + newName;
+ if (newPath != null && !"".equals(newPath)) { //$NON-NLS-1$
+ command += " -o " + newPath; //$NON-NLS-1$
+ }
+
+ ICommandResult result = fCommandShell.executeCommand(command, monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ //Session myssession2 created.
+ //Traces will be written in /home/user/lttng-traces/myssession2-20120209-095418
+ String[] output = result.getOutput();
+
+ // Get and verify session name
+ Matcher matcher = CREATE_SESSION_NAME_PATTERN.matcher(output[0]);
+ String name = null;
+
+ if (matcher.matches()) {
+ name = String.valueOf(matcher.group(1).trim());
+ } else {
+ // Output format not expected
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ Messages.TraceControl_UnexpectedCommnadOutputFormat + ":\n" + //$NON-NLS-1$
+ formatOutput(result.getOutput()));
+ }
+
+ if ((name == null) || (!name.equals(sessionName))) {
+ // Unexpected name returned
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ Messages.TraceControl_UnexpectedNameError + ": " + name); //$NON-NLS-1$
+ }
+
+ // Get and verify session path
+ matcher = CREATE_SESSION_PATH_PATTERN.matcher(output[1]);
+ String path = null;
+
+ if (matcher.matches()) {
+ path = String.valueOf(matcher.group(1).trim());
+ } else {
+ // Output format not expected
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ Messages.TraceControl_UnexpectedCommnadOutputFormat + ":\n" + //$NON-NLS-1$
+ formatOutput(result.getOutput()));
+ }
+
+ if ((path == null) || ((sessionPath != null) && (!path.contains(sessionPath)))) {
+ // Unexpected path
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$
+ }
+
+ SessionInfo sessionInfo = new SessionInfo(name);
+ sessionInfo.setSessionPath(path);
+
+ return sessionInfo;
+ }
+
+ @Override
+ public void destroySession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+ String newName = formatParameter(sessionName);
+ String command = COMMAND_DESTROY_SESSION + newName;
+
+ ICommandResult result = fCommandShell.executeCommand(command, monitor);
+ String[] output = result.getOutput();
+
+ if (isError(result)) {
+ // In case "session not found" treat it as success
+ if ((output == null) || (!SESSION_NOT_FOUND_ERROR_PATTERN.matcher(output[0]).matches())) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ //Session <sessionName> destroyed
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#startSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void startSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+
+ String newSessionName = formatParameter(sessionName);
+
+ String command = COMMAND_START_SESSION + newSessionName;
+
+ ICommandResult result = fCommandShell.executeCommand(command, monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ //Session <sessionName> started
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#stopSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void stopSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+ String newSessionName = formatParameter(sessionName);
+ String command = COMMAND_STOP_SESSION + newSessionName;
+
+ ICommandResult result = fCommandShell.executeCommand(command, monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ //Session <sessionName> stopped
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableChannel(java.lang.String, java.util.List, boolean, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableChannels(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
+
+ // no channels to enable
+ if (channelNames.size() == 0) {
+ return;
+ }
+
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_CHANNEL);
+
+ for (Iterator<String> iterator = channelNames.iterator(); iterator.hasNext();) {
+ String channel = (String) iterator.next();
+ command.append(channel);
+ if (iterator.hasNext()) {
+ command.append(","); //$NON-NLS-1$
+ }
+ }
+
+ if (isKernel) {
+ command.append(OPTION_KERNEL);
+ } else {
+ command.append(OPTION_UST);
+ }
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (info != null) {
+// --discard Discard event when buffers are full (default)
+
+// --overwrite Flight recorder mode
+ if (info.isOverwriteMode()) {
+ command.append(OPTION_OVERWRITE);
+ }
+// --subbuf-size SIZE Subbuffer size in bytes
+// (default: 4096, kernel default: 262144)
+ command.append(OPTION_SUB_BUFFER_SIZE);
+ command.append(String.valueOf(info.getSubBufferSize()));
+
+// --num-subbuf NUM Number of subbufers
+// (default: 8, kernel default: 4)
+ command.append(OPTION_NUM_SUB_BUFFERS);
+ command.append(String.valueOf(info.getNumberOfSubBuffers()));
+
+// --switch-timer USEC Switch timer interval in usec (default: 0)
+ command.append(OPTION_SWITCH_TIMER);
+ command.append(String.valueOf(info.getSwitchTimer()));
+
+// --read-timer USEC Read timer interval in usec (default: 200)
+ command.append(OPTION_READ_TIMER);
+ command.append(String.valueOf(info.getReadTimer()));
+ }
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#disableChannel(java.lang.String, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void disableChannels(String sessionName, List<String> channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+
+ // no channels to enable
+ if (channelNames.size() == 0) {
+ return;
+ }
+
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_DISABLE_CHANNEL);
+
+ for (Iterator<String> iterator = channelNames.iterator(); iterator.hasNext();) {
+ String channel = (String) iterator.next();
+ command.append(channel);
+ if (iterator.hasNext()) {
+ command.append(","); //$NON-NLS-1$
+ }
+ }
+
+ if (isKernel) {
+ command.append(OPTION_KERNEL);
+ } else {
+ command.append(OPTION_UST);
+ }
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableEvents(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
+
+ if (eventNames == null || eventNames.size() == 0) {
+ command.append(OPTION_ALL);
+ } else {
+
+ for (Iterator<String> iterator = eventNames.iterator(); iterator.hasNext();) {
+ String event = (String) iterator.next();
+ command.append(event);
+ if (iterator.hasNext()) {
+ command.append(","); //$NON-NLS-1$
+ }
+ }
+ }
+
+ if (isKernel) {
+ command.append(OPTION_KERNEL);
+ } else {
+ command.append(OPTION_UST);
+ }
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
+ command.append(OPTION_TRACEPOINT);
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableSyscalls(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableSyscalls(String sessionName, String channelName, IProgressMonitor monitor) throws ExecutionException {
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
+
+ command.append(OPTION_ALL);
+ command.append(OPTION_KERNEL);
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
+ command.append(OPTION_SYSCALL);
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableProbe(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableProbe(String sessionName, String channelName, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
+
+ command.append(eventName);
+ command.append(OPTION_KERNEL);
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+ if (isFunction) {
+ command.append(OPTION_FUNCTION_PROBE);
+ } else {
+ command.append(OPTION_PROBE);
+ }
+
+ command.append(probe);
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableLogLevel(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableLogLevel(String sessionName, String channelName, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
+
+ command.append(eventName);
+ command.append(OPTION_UST);
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
+ if (logLevelType == LogLevelType.LOGLEVEL) {
+ command.append(OPTION_LOGLEVEL);
+ } else if (logLevelType == LogLevelType.LOGLEVEL_ONLY) {
+ command.append(OPTION_LOGLEVEL_ONLY);
+
+ } else {
+ return;
+ }
+ command.append(level.getInName());
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#disableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void disableEvent(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_DISABLE_EVENT);
+ if (eventNames == null) {
+ command.append(OPTION_ALL);
+ } else {
+ // no events to enable
+ if (eventNames.size() == 0) {
+ return;
+ }
+
+ for (Iterator<String> iterator = eventNames.iterator(); iterator.hasNext();) {
+ String event = (String) iterator.next();
+ command.append(event);
+ if (iterator.hasNext()) {
+ command.append(","); //$NON-NLS-1$
+ }
+ }
+ }
+
+ if (isKernel) {
+ command.append(OPTION_KERNEL);
+ } else {
+ command.append(OPTION_UST);
+ }
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ /**
+ * Checks if command result is an error result.
+ *
+ * @param result
+ * - the command result to check
+ * @return true if error else false
+ */
+ private boolean isError(ICommandResult result) {
+ if ((result.getResult()) != 0 || (result.getOutput().length < 1 || ERROR_PATTERN.matcher(result.getOutput()[0]).matches())) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Formats the output string as single string.
+ *
+ * @param output
+ * - output array
+ * @return - the formatted output
+ */
+ private String formatOutput(String[] output) {
+ if (output == null || output.length == 0) {
+ return ""; //$NON-NLS-1$
+ }
+
+ StringBuffer ret = new StringBuffer();
+ for (int i = 0; i < output.length; i++) {
+ ret.append(output[i] + "\n"); //$NON-NLS-1$
+ }
+ return ret.toString();
+ }
+
+ /**
+ * Parses the domain information.
+ *
+ * @param output
+ * - a command output array
+ * @param currentIndex
+ * - current index in command output array
+ * @param channels
+ * - list for returning channel information
+ * @return the new current index in command output array
+ */
+ private int parseDomain(String[] output, int currentIndex, List<IChannelInfo> channels) {
+ int index = currentIndex;
+
+ // Channels:
+ // -------------
+ // - channnel1: [enabled]
+ //
+ // Attributes:
+ // overwrite mode: 0
+ // subbufers size: 262144
+ // number of subbufers: 4
+ // switch timer interval: 0
+ // read timer interval: 200
+ // output: splice()
+
+ while (index < output.length) {
+ String line = output[index];
+
+ Matcher outerMatcher = CHANNELS_SECTION_PATTERN.matcher(line);
+ if (outerMatcher.matches()) {
+ IChannelInfo channelInfo = null;
+ while (index < output.length) {
+ String subLine = output[index];
+
+ Matcher innerMatcher = CHANNEL_PATTERN.matcher(subLine);
+ if (innerMatcher.matches()) {
+ channelInfo = new ChannelInfo(""); //$NON-NLS-1$
+ // get channel name
+ channelInfo.setName(innerMatcher.group(1));
+
+ // get channel enablement
+ channelInfo.setState(innerMatcher.group(2));
+
+ // add channel
+ channels.add(channelInfo);
+
+ } else if (OVERWRITE_MODE_ATTRIBUTE.matcher(subLine).matches()) {
+ String value = getAttributeValue(subLine);
+ channelInfo.setOverwriteMode(!OVERWRITE_MODE_ATTRIBUTE_FALSE.equals(value));
+ } else if (SUBBUFFER_SIZE_ATTRIBUTE.matcher(subLine).matches()) {
+ channelInfo.setSubBufferSize(Long.valueOf(getAttributeValue(subLine)));
+
+ } else if (NUM_SUBBUFFERS_ATTRIBUTE.matcher(subLine).matches()) {
+ channelInfo.setNumberOfSubBuffers(Integer.valueOf(getAttributeValue(subLine)));
+
+ } else if (SWITCH_TIMER_ATTRIBUTE.matcher(subLine).matches()) {
+ channelInfo.setSwitchTimer(Long.valueOf(getAttributeValue(subLine)));
+
+ } else if (READ_TIMER_ATTRIBUTE.matcher(subLine).matches()) {
+ channelInfo.setReadTimer(Long.valueOf(getAttributeValue(subLine)));
+
+ } else if (OUTPUT_ATTRIBUTE.matcher(subLine).matches()) {
+ channelInfo.setOutputType(getAttributeValue(subLine));
+
+ } else if (EVENT_SECTION_PATTERN.matcher(subLine).matches()) {
+ List<IEventInfo> events = new ArrayList<IEventInfo>();
+ index = parseEvents(output, index, events);
+ channelInfo.setEvents(events);
+ // we want to stay at the current index to be able to
+ // exit the domain
+ continue;
+ } else if (DOMAIN_KERNEL_PATTERN.matcher(subLine).matches()) {
+ return index;
+
+ } else if (DOMAIN_UST_GLOBAL_PATTERN.matcher(subLine).matches()) {
+ return index;
+ }
+ index++;
+ }
+ }
+ index++;
+ }
+ return index;
+ }
+
+ /**
+ * Parses the event information within a domain.
+ *
+ * @param output
+ * - a command output array
+ * @param currentIndex
+ * - current index in command output array
+ * @param events
+ * - list for returning event information
+ * @return the new current index in command output array
+ */
+ private int parseEvents(String[] output, int currentIndex, List<IEventInfo> events) {
+ int index = currentIndex;
+
+ while (index < output.length) {
+ String line = output[index];
+ if (CHANNEL_PATTERN.matcher(line).matches()) {
+ // end of channel
+ return index;
+ } else if (DOMAIN_KERNEL_PATTERN.matcher(line).matches()) {
+ // end of domain
+ return index;
+ } else if (DOMAIN_UST_GLOBAL_PATTERN.matcher(line).matches()) {
+ // end of domain
+ return index;
+ }
+
+ Matcher matcher = EVENT_PATTERN.matcher(line);
+ Matcher matcher2 = WILDCARD_EVENT_PATTERN.matcher(line);
+
+ if (matcher.matches()) {
+ IEventInfo eventInfo = new EventInfo(matcher.group(1).trim());
+ eventInfo.setLogLevel(matcher.group(2).trim());
+ eventInfo.setEventType(matcher.group(3).trim());
+ eventInfo.setState(matcher.group(4));
+ events.add(eventInfo);
+ index++;
+ } else if (matcher2.matches()) {
+ IEventInfo eventInfo = new EventInfo(matcher2.group(1).trim());
+ eventInfo.setLogLevel(TraceLogLevel.LEVEL_UNKNOWN);
+ eventInfo.setEventType(matcher2.group(2).trim());
+ eventInfo.setState(matcher2.group(3));
+
+ if (eventInfo.getEventType() == TraceEventType.PROBE) {
+ IProbeEventInfo probeEvent = new ProbeEventInfo(eventInfo.getName());
+ probeEvent.setLogLevel(eventInfo.getLogLevel());
+ probeEvent.setEventType(eventInfo.getEventType());
+ probeEvent.setState(eventInfo.getState());
+
+ // Overwrite eventinfo
+ eventInfo = probeEvent;
+
+ // myevent2 (type: probe) [enabled]
+ // addr: 0xc0101340
+ // myevent0 (type: probe) [enabled]
+ // offset: 0x0
+ // symbol: init_post
+ index++;
+ while (index < output.length) {
+ String probeLine = output[index];
+ // parse probe
+ Matcher addrMatcher = PROBE_ADDRESS_PATTERN.matcher(probeLine);
+ Matcher offsetMatcher = PROBE_OFFSET_PATTERN.matcher(probeLine);
+ Matcher symbolMatcher = PROBE_SYMBOL_PATTERN.matcher(probeLine);
+ if (addrMatcher.matches()) {
+ String addr = addrMatcher.group(2).trim();
+ probeEvent.setAddress(addr);
+ } else if (offsetMatcher.matches()) {
+ String offset = offsetMatcher.group(2).trim();
+ probeEvent.setOffset(offset);
+ } else if (symbolMatcher.matches()) {
+ String symbol = symbolMatcher.group(2).trim();
+ probeEvent.setSymbol(symbol);
+ } else if ((EVENT_PATTERN.matcher(probeLine).matches()) || (WILDCARD_EVENT_PATTERN.matcher(probeLine).matches())) {
+ break;
+ } else if (CHANNEL_PATTERN.matcher(probeLine).matches()) {
+ break;
+ } else if (DOMAIN_KERNEL_PATTERN.matcher(probeLine).matches()) {
+ // end of domain
+ break;
+ } else if (DOMAIN_UST_GLOBAL_PATTERN.matcher(probeLine).matches()) {
+ // end of domain
+ break;
+ }
+ index++;
+ }
+ events.add(eventInfo);
+ } else {
+ events.add(eventInfo);
+ index++;
+ continue;
+ }
+ } else {
+ index++;
+ }
+// else if (line.matches(EVENT_NONE_PATTERN)) {
+ // do nothing
+// } else
+
+ }
+
+ return index;
+ }
+
+ /**
+ * Parses a line with attributes: <attribute Name>: <attribute value>
+ *
+ * @param line
+ * - attribute line to parse
+ * @return the attribute value as string
+ */
+ private String getAttributeValue(String line) {
+ String[] temp = line.split("\\: "); //$NON-NLS-1$
+ return temp[1];
+ }
+
+ /**
+ * Parses the event information within a provider.
+ *
+ * @param output
+ * - a command output array
+ * @param currentIndex
+ * - current index in command output array
+ * @param events
+ * - list for returning event information
+ * @return the new current index in command output array
+ */
+ private int getProviderEventInfo(String[] output, int currentIndex, List<IBaseEventInfo> events) {
+ int index = currentIndex;
+ while (index < output.length) {
+ String line = output[index];
+ Matcher matcher = PROVIDER_EVENT_PATTERN.matcher(line);
+ if (matcher.matches()) {
+ // sched_kthread_stop (loglevel: TRACE_EMERG0) (type:
+ // tracepoint)
+ IBaseEventInfo eventInfo = new BaseEventInfo(matcher.group(1).trim());
+ eventInfo.setLogLevel(matcher.group(2).trim());
+ eventInfo.setEventType(matcher.group(3).trim());
+ events.add(eventInfo);
+ } else if (UST_PROVIDER_PATTERN.matcher(line).matches()) {
+ return index;
+ }
+ index++;
+ }
+ return index;
+ }
+
+ /**
+ * Formats a command parameter for the command execution i.e. adds quotes
+ * at the beginning and end if necessary.
+ * @param parameter - parameter to format
+ * @return formated parameter
+ */
+ private String formatParameter(String parameter) {
+ if (parameter != null) {
+ String newString = String.valueOf(parameter);
+
+ if (parameter.contains(" ")) { //$NON-NLS-1$
+ newString = "\"" + newString + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return newString;
+ }
+ return null;
+ }
+
+}