Search in sources :

Example 16 with TracePackageFilesElement

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.

the class AbstractGenerateManifestOperation method generatePatterns.

/**
 * Generates regular expression patterns from the template element.
 *
 * @param templateElements
 *            input template elements
 * @return map of generated {@link Pattern} to corresponding
 *         {@link TracePackageFilesElement}
 */
protected Map<Pattern, TracePackageTraceElement> generatePatterns(TracePackageElement[] templateElements) {
    Map<Pattern, TracePackageTraceElement> templatePatterns = new HashMap<>();
    for (TracePackageElement templateElement : templateElements) {
        if (templateElement instanceof TracePackageTraceElement) {
            TracePackageElement[] children = templateElement.getChildren();
            if (children != null) {
                for (TracePackageElement child : children) {
                    if (child instanceof TracePackageFilesElement) {
                        TracePackageFilesElement tracePackageFilesElement = (TracePackageFilesElement) child;
                        Pattern pattern = Pattern.compile(tracePackageFilesElement.getFileName());
                        templatePatterns.put(pattern, (TracePackageTraceElement) templateElement);
                    }
                }
            }
        }
    }
    return templatePatterns;
}
Also used : Pattern(java.util.regex.Pattern) HashMap(java.util.HashMap) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement)

Example 17 with TracePackageFilesElement

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.

the class RemoteImportProfilesWriter method exportTrace.

private static void exportTrace(Node traceGroupNode, TracePackageTraceElement trace) {
    Element traceElement = traceGroupNode.getOwnerDocument().createElement(ITracePackageConstants.TRACE_ELEMENT);
    traceElement.setAttribute(ITracePackageConstants.TRACE_NAME_ATTRIB, trace.getImportName());
    traceElement.setAttribute(ITracePackageConstants.TRACE_TYPE_ATTRIB, trace.getTraceType());
    for (TracePackageElement files : trace.getChildren()) {
        if (files instanceof TracePackageFilesElement) {
            exportTraceFiles(traceElement, (TracePackageFilesElement) files);
            break;
        }
    }
    traceGroupNode.appendChild(traceElement);
}
Also used : TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) Element(org.w3c.dom.Element) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement)

Example 18 with TracePackageFilesElement

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.

the class RemoteImportProfilesWriter method exportTraceFiles.

private static void exportTraceFiles(Node traceNode, TracePackageFilesElement files) {
    Element fileElement = traceNode.getOwnerDocument().createElement(ITracePackageConstants.TRACE_FILE_ELEMENT);
    fileElement.setAttribute(ITracePackageConstants.TRACE_FILE_NAME_ATTRIB, files.getFileName());
    traceNode.appendChild(fileElement);
}
Also used : TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) Element(org.w3c.dom.Element) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement)

Example 19 with TracePackageFilesElement

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.

the class RemoteImportProfilesReaderTest method testLoadElements.

/**
 * Test loading elements from a profiles file.
 *
 * @throws Exception
 *             on error
 */
@Test
public void testLoadElements() throws Exception {
    TracePackageElement[] elements = loadElementsFromPath(VALID_PROFILE_PATH);
    // $NON-NLS-1$
    assertEquals("profile element count", 2, elements.length);
    TracePackageElement element = elements[0];
    assertTrue(element instanceof RemoteImportProfileElement);
    RemoteImportProfileElement profileElement = (RemoteImportProfileElement) element;
    // $NON-NLS-1$
    assertEquals("myProfile", profileElement.getProfileName());
    Image image = profileElement.getImage();
    assertNotNull(image);
    image.dispose();
    // $NON-NLS-1$
    assertEquals("profile children count", 2, profileElement.getChildren().length);
    // First node
    element = getElementOfClass(RemoteImportConnectionNodeElement.class, profileElement.getChildren()).get(0);
    assertTrue(element instanceof RemoteImportConnectionNodeElement);
    RemoteImportConnectionNodeElement nodeElement = (RemoteImportConnectionNodeElement) element;
    // $NON-NLS-1$
    assertEquals("myhost", nodeElement.getName());
    // $NON-NLS-1$
    assertEquals("ssh://user@127.0.0.1:22", nodeElement.getURI());
    image = nodeElement.getImage();
    assertNotNull(image);
    element = getElementOfClass(RemoteImportTraceGroupElement.class, nodeElement.getChildren()).get(0);
    assertTrue(element instanceof RemoteImportTraceGroupElement);
    RemoteImportTraceGroupElement traceGroupElement = (RemoteImportTraceGroupElement) element;
    // $NON-NLS-1$
    assertEquals("/home/user/traces/test/test_with_lttng", traceGroupElement.getRootImportPath());
    assertTrue(traceGroupElement.isRecursive());
    image = traceGroupElement.getImage();
    assertNotNull(image);
    element = getElementOfClass(TracePackageTraceElement.class, traceGroupElement.getChildren()).get(0);
    assertTrue(element instanceof TracePackageTraceElement);
    TracePackageTraceElement traceElement = (TracePackageTraceElement) element;
    // $NON-NLS-1$
    assertEquals("test.log.(group1)", traceElement.getText());
    // $NON-NLS-1$
    assertEquals("org.eclipse.tracecompass.tmf.remote.ui.test.tracetype1", traceElement.getTraceType());
    element = getElementOfClass(TracePackageFilesElement.class, traceElement.getChildren()).get(0);
    assertTrue(element instanceof TracePackageFilesElement);
    TracePackageFilesElement traceFilesElement = (TracePackageFilesElement) element;
    // $NON-NLS-1$
    assertEquals(".*test\\.log\\.(\\d+)", traceFilesElement.getFileName());
    image = traceFilesElement.getImage();
    assertNotNull(image);
    // Second node
    element = getElementOfClass(RemoteImportConnectionNodeElement.class, profileElement.getChildren()).get(1);
    assertTrue(element instanceof RemoteImportConnectionNodeElement);
    nodeElement = (RemoteImportConnectionNodeElement) element;
    // $NON-NLS-1$
    assertEquals("myhost3", nodeElement.getName());
    // $NON-NLS-1$
    assertEquals("ssh://user@127.0.0.1:22", nodeElement.getURI());
    image = nodeElement.getImage();
    assertNotNull(image);
    element = getElementOfClass(RemoteImportTraceGroupElement.class, nodeElement.getChildren()).get(0);
    assertTrue(element instanceof RemoteImportTraceGroupElement);
    traceGroupElement = (RemoteImportTraceGroupElement) element;
    // $NON-NLS-1$
    assertEquals("/home", traceGroupElement.getRootImportPath());
    assertFalse(traceGroupElement.isRecursive());
    image = traceGroupElement.getImage();
    assertNotNull(image);
    element = getElementOfClass(TracePackageTraceElement.class, traceGroupElement.getChildren()).get(0);
    assertTrue(element instanceof TracePackageTraceElement);
    traceElement = (TracePackageTraceElement) element;
    // $NON-NLS-1$
    assertEquals("", traceElement.getText());
    // $NON-NLS-1$
    assertEquals("trace.type", traceElement.getTraceType());
    element = getElementOfClass(TracePackageFilesElement.class, traceElement.getChildren()).get(0);
    assertTrue(element instanceof TracePackageFilesElement);
    traceFilesElement = (TracePackageFilesElement) element;
    // $NON-NLS-1$
    assertEquals(".*", traceFilesElement.getFileName());
    image = traceFilesElement.getImage();
    assertNotNull(image);
}
Also used : RemoteImportConnectionNodeElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportConnectionNodeElement) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement) Image(org.eclipse.swt.graphics.Image) RemoteImportTraceGroupElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportTraceGroupElement) RemoteImportProfileElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement) Test(org.junit.Test)

Example 20 with TracePackageFilesElement

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.

the class RemoteImportProfilesWriterTest method generateElements.

private static TracePackageElement[] generateElements() {
    RemoteImportProfileElement profileElement = new RemoteImportProfileElement(null, // $NON-NLS-1$
    "myProfile");
    RemoteImportConnectionNodeElement nodeElement = new RemoteImportConnectionNodeElement(profileElement, "myhost", // $NON-NLS-1$//$NON-NLS-2$
    "ssh://user@127.0.0.1:22");
    RemoteImportTraceGroupElement traceGroupElement = new RemoteImportTraceGroupElement(nodeElement, // $NON-NLS-1$
    "/home/user/traces/test/test_with_lttng");
    traceGroupElement.setRecursive(true);
    // Profile 1 > Node 1 > Group 1
    TracePackageTraceElement traceElement = new TracePackageTraceElement(traceGroupElement, "test.log.(group1)", // $NON-NLS-1$//$NON-NLS-2$
    "org.eclipse.tracecompass.tmf.remote.ui.test.tracetype1");
    // $NON-NLS-1$
    new TracePackageFilesElement(traceElement, ".*test\\.log\\.(\\d+)");
    traceElement = new TracePackageTraceElement(traceGroupElement, "TestLog.(group1)", // $NON-NLS-1$//$NON-NLS-2$
    "org.eclipse.tracecompass.tmf.remote.ui.test.tracetype2");
    // $NON-NLS-1$
    new TracePackageFilesElement(traceElement, ".*TestLog\\.(\\d+)");
    // Profile 1 > Node 1 > Group 2
    traceGroupElement = new RemoteImportTraceGroupElement(nodeElement, // $NON-NLS-1$
    "/home/user/traces/test/");
    traceGroupElement.setRecursive(false);
    traceElement = new TracePackageTraceElement(traceGroupElement, "lttng/(group1)", // $NON-NLS-1$//$NON-NLS-2$
    "org.eclipse.linuxtools.tmf.ui.type.ctf");
    // $NON-NLS-1$
    new TracePackageFilesElement(traceElement, "lttng/(.*)");
    // Profile 1 > Node 2 > Group 1
    // $NON-NLS-1$//$NON-NLS-2$
    nodeElement = new RemoteImportConnectionNodeElement(profileElement, "myhost3", "ssh://user@127.0.0.1:22");
    // $NON-NLS-1$
    traceGroupElement = new RemoteImportTraceGroupElement(nodeElement, "/home");
    traceGroupElement.setRecursive(false);
    // $NON-NLS-1$//$NON-NLS-2$
    traceElement = new TracePackageTraceElement(traceGroupElement, "", "trace.type");
    // $NON-NLS-1$
    new TracePackageFilesElement(traceElement, ".*");
    // Profile 2 > Node 1 > Group 1
    RemoteImportProfileElement profileElement2 = new RemoteImportProfileElement(null, // $NON-NLS-1$
    "myProfile2");
    RemoteImportConnectionNodeElement nodeElement2 = new RemoteImportConnectionNodeElement(profileElement2, "myhost2", // $NON-NLS-1$//$NON-NLS-2$
    "ssh://user@142.111.222.333:22");
    traceGroupElement = new RemoteImportTraceGroupElement(nodeElement2, // $NON-NLS-1$
    "/home/user/traces/test/");
    traceGroupElement.setRecursive(false);
    traceElement = new TracePackageTraceElement(traceGroupElement, "lttng/(group1)", // $NON-NLS-1$//$NON-NLS-2$
    "org.eclipse.linuxtools.tmf.ui.type.ctf");
    // $NON-NLS-1$
    new TracePackageFilesElement(traceElement, "lttng/(.*)");
    return new TracePackageElement[] { profileElement, profileElement2 };
}
Also used : RemoteImportConnectionNodeElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportConnectionNodeElement) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement) RemoteImportTraceGroupElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportTraceGroupElement) RemoteImportProfileElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement)

Aggregations

TracePackageFilesElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement)20 TracePackageTraceElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement)20 TracePackageElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement)15 RemoteImportConnectionNodeElement (org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportConnectionNodeElement)8 RemoteImportTraceGroupElement (org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportTraceGroupElement)8 RemoteImportProfileElement (org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement)7 ArrayList (java.util.ArrayList)5 TracePackageExperimentElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageExperimentElement)5 IPath (org.eclipse.core.runtime.IPath)4 TracePackageBookmarkElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageBookmarkElement)4 TracePackageSupplFileElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageSupplFileElement)4 TracePackageSupplFilesElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageSupplFilesElement)4 Element (org.w3c.dom.Element)4 Path (org.eclipse.core.runtime.Path)3 Image (org.eclipse.swt.graphics.Image)3 TmfCommonProjectElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement)3 TmfExperimentElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement)3 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2