Search in sources :

Example 1 with TmfTraceElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement in project tracecompass by tracecompass.

the class ImportHandler method initializeTraceResource.

private static void initializeTraceResource(final LttngRelaydConnectionInfo connectionInfo, final String tracePath, final IProject project) throws CoreException, TmfTraceImportException {
    final TmfProjectElement projectElement = TmfProjectRegistry.getProject(project, true);
    final TmfTraceFolder tracesFolder = projectElement.getTracesFolder();
    if (tracesFolder != null) {
        IFolder folder = tracesFolder.getResource();
        IFolder traceFolder = folder.getFolder(connectionInfo.getSessionName());
        Path location = new Path(tracePath);
        IStatus result = ResourcesPlugin.getWorkspace().validateLinkLocation(folder, location);
        if (result.isOK()) {
            traceFolder.createLink(location, IResource.REPLACE, new NullProgressMonitor());
        } else {
            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, result.getMessage()));
        }
        TraceTypeHelper selectedTraceType = TmfTraceTypeUIUtils.selectTraceType(location.toOSString(), null, null);
        // No trace type was determined.
        TmfTraceTypeUIUtils.setTraceType(traceFolder, selectedTraceType);
        TmfTraceElement found = null;
        final List<TmfTraceElement> traces = tracesFolder.getTraces();
        for (TmfTraceElement candidate : traces) {
            if (candidate.getName().equals(connectionInfo.getSessionName())) {
                found = candidate;
            }
        }
        if (found == null) {
            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_LiveTraceElementError));
        }
        // Properties used to be able to reopen a trace in live mode
        traceFolder.setPersistentProperty(CtfConstants.LIVE_HOST, connectionInfo.getHost());
        traceFolder.setPersistentProperty(CtfConstants.LIVE_PORT, Integer.toString(connectionInfo.getPort()));
        traceFolder.setPersistentProperty(CtfConstants.LIVE_SESSION_NAME, connectionInfo.getSessionName());
        final TmfTraceElement finalTrace = found;
        Display.getDefault().syncExec(() -> TmfOpenTraceHelper.openFromElement(finalTrace));
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) TraceTypeHelper(org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper) CoreException(org.eclipse.core.runtime.CoreException) TmfTraceElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement) TmfTraceFolder(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder) TmfProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with TmfTraceElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement in project tracecompass by tracecompass.

the class FetchRemoteTracesTest method test_8_13.

/**
 * Test 8.13: Run Profile "TestSpecificMultiGroupRecursive"
 */
@Test
public void test_8_13() {
    SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
    projectExplorerBot.show();
    SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);
    tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
    SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
    fBot.comboBox().setSelection("TestSpecificMultiGroupRecursive");
    fBot.button("Next >").click();
    fBot.button("Finish").click();
    fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
    WaitUtils.waitForJobs();
    TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true);
    fBot.waitUntil(new TraceCountCondition(project, 2));
    final TmfTraceFolder tracesFolder = project.getTracesFolder();
    assertNotNull(tracesFolder);
    List<TmfTraceElement> traces = tracesFolder.getTraces();
    assertEquals(2, traces.size());
    testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_KERNEL);
    testTrace(traces.get(1), CONNECTION_NODE1_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
}
Also used : TmfTraceElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement) TmfTraceFolder(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TmfProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 3 with TmfTraceElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement in project tracecompass by tracecompass.

the class FetchRemoteTracesTest method test_8_06.

/**
 * Test 8.6: Re-Run Profile "TestAllRecursive" (Overwrite)
 *
 * @throws CoreException if an exception occurs
 */
@Test
public void test_8_06() throws CoreException {
    SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
    projectExplorerBot.show();
    SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);
    tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
    SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
    fBot.comboBox().setSelection("TestAllRecursive");
    fBot.button("Next >").click();
    fBot.button("Finish").click();
    fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
    WaitUtils.waitForJobs();
    TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true);
    fBot.waitUntil(new TraceCountCondition(project, 3));
    final TmfTraceFolder tracesFolder = project.getTracesFolder();
    assertNotNull(tracesFolder);
    for (TmfTraceElement traceElement : tracesFolder.getTraces()) {
        traceElement.getResource().setPersistentProperty(ORIGINAL, Boolean.TRUE.toString());
    }
    tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
    shell = fBot.shell(FETCH_SHELL_NAME).activate();
    fBot.comboBox().setSelection("TestAllRecursive");
    fBot.button("Next >").click();
    fBot.button("Finish").click();
    fBot.shell(CONFIRMATION_SHELL_NAME).activate();
    fBot.button("Overwrite").click();
    fBot.shell(CONFIRMATION_SHELL_NAME).activate();
    fBot.button("Overwrite All").click();
    fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
    WaitUtils.waitForJobs();
    fBot.waitUntil(new TraceCountCondition(project, 3));
    List<TmfTraceElement> traces = tracesFolder.getTraces();
    assertEquals(3, traces.size());
    testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_KERNEL);
    testTrace(traces.get(1), CONNECTION_NODE1_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
    testTrace(traces.get(2), CONNECTION_NODE1_NAME + "/resources/unrecognized", null);
    // Verify overwritten traces lost the original property
    for (TmfTraceElement traceElement : traces) {
        assertNull(traceElement.getResource().getPersistentProperty(ORIGINAL));
    }
}
Also used : TmfTraceElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement) TmfTraceFolder(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TmfProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 4 with TmfTraceElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement in project tracecompass by tracecompass.

the class FetchRemoteTracesTest method test_8_08.

/**
 * Test 8.8: Re-Run Profile "TestAllRecursive" (Overwrite without warning)
 *
 * @throws CoreException if an exception occurs
 */
@Test
public void test_8_08() throws CoreException {
    SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
    projectExplorerBot.show();
    SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);
    tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
    SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
    fBot.comboBox().setSelection("TestAllRecursive");
    fBot.button("Next >").click();
    fBot.button("Finish").click();
    fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
    WaitUtils.waitForJobs();
    TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true);
    fBot.waitUntil(new TraceCountCondition(project, 3));
    final TmfTraceFolder tracesFolder = project.getTracesFolder();
    assertNotNull(tracesFolder);
    for (TmfTraceElement traceElement : tracesFolder.getTraces()) {
        traceElement.getResource().setPersistentProperty(ORIGINAL, Boolean.TRUE.toString());
    }
    tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
    shell = fBot.shell(FETCH_SHELL_NAME).activate();
    fBot.comboBox().setSelection("TestAllRecursive");
    fBot.checkBox("Overwrite existing trace without warning").select();
    fBot.button("Next >").click();
    fBot.button("Finish").click();
    fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
    WaitUtils.waitForJobs();
    fBot.waitUntil(new TraceCountCondition(project, 3));
    assertNotNull(tracesFolder);
    List<TmfTraceElement> traces = tracesFolder.getTraces();
    assertEquals(3, traces.size());
    testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_KERNEL);
    testTrace(traces.get(1), CONNECTION_NODE1_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
    testTrace(traces.get(2), CONNECTION_NODE1_NAME + "/resources/unrecognized", null);
    // Verify overwritten traces lost the original property
    for (TmfTraceElement traceElement : traces) {
        assertNull(traceElement.getResource().getPersistentProperty(ORIGINAL));
    }
}
Also used : TmfTraceElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement) TmfTraceFolder(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TmfProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 5 with TmfTraceElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement in project tracecompass by tracecompass.

the class FetchRemoteTracesTest method test_8_04.

/**
 * Test 8.4: Run Profile "TestAllRecursive"
 */
@Test
public void test_8_04() {
    SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
    projectExplorerBot.show();
    SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);
    tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
    SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
    fBot.comboBox().setSelection("TestAllRecursive");
    fBot.button("Next >").click();
    fBot.button("Finish").click();
    fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
    WaitUtils.waitForJobs();
    TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true);
    fBot.waitUntil(new TraceCountCondition(project, 3));
    final TmfTraceFolder tracesFolder = project.getTracesFolder();
    assertNotNull(tracesFolder);
    List<TmfTraceElement> traces = tracesFolder.getTraces();
    assertEquals(3, traces.size());
    testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_KERNEL);
    testTrace(traces.get(1), CONNECTION_NODE1_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
    testTrace(traces.get(2), CONNECTION_NODE1_NAME + "/resources/unrecognized", null);
}
Also used : TmfTraceElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement) TmfTraceFolder(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TmfProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Aggregations

TmfTraceElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement)84 TmfTraceFolder (org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder)45 TmfProjectElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement)32 TmfExperimentElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement)28 Test (org.junit.Test)22 CoreException (org.eclipse.core.runtime.CoreException)21 IResource (org.eclipse.core.resources.IResource)18 IPath (org.eclipse.core.runtime.IPath)17 ISelection (org.eclipse.jface.viewers.ISelection)17 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)16 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)13 IFolder (org.eclipse.core.resources.IFolder)12 ArrayList (java.util.ArrayList)11 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)11 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)11 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 IProject (org.eclipse.core.resources.IProject)10 Shell (org.eclipse.swt.widgets.Shell)9 TmfCommonProjectElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement)9