Search in sources :

Example 1 with CustomTxtTraceDefinition

use of org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition in project tracecompass by tracecompass.

the class CustomTxtIndexTest method createTrace.

@Override
protected TestTrace createTrace() throws Exception {
    CustomTxtTraceDefinition definition = createDefinition();
    final File file = new File(TRACE_PATH);
    try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
        for (int i = 0; i < NB_EVENTS; ++i) {
            SimpleDateFormat f = new SimpleDateFormat(TIMESTAMP_FORMAT);
            String eventStr = f.format(new Date(i)) + " hello world\n";
            writer.write(eventStr);
            int extra = i % 3;
            for (int j = 0; j < extra; j++) {
                writer.write("extra line\n");
            }
        }
    }
    return new TestTxtTrace(file.toString(), definition, BLOCK_SIZE);
}
Also used : FileWriter(java.io.FileWriter) CustomTxtTraceDefinition(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) BufferedWriter(java.io.BufferedWriter)

Example 2 with CustomTxtTraceDefinition

use of org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition in project tracecompass by tracecompass.

the class ProjectExplorerTraceActionsTest method init.

/**
 * Test Class setup
 *
 * @throws IOException
 *             on error
 */
@BeforeClass
public static void init() throws IOException {
    TestDirectoryStructureUtil.generateTraceStructure(TEST_TRACES_PATH);
    SWTBotUtils.initialize();
    /*
         * FIXME: We can't use Manage Custom Parsers > Import because it uses a native
         * dialog. We'll still check that they show up in the dialog
         */
    CustomTxtTraceDefinition[] txtDefinitions = CustomTxtTraceDefinition.loadAll(getPath("customParsers/ExampleCustomTxtParser.xml"));
    txtDefinitions[0].save();
    /* set up test trace */
    fTestFile = new File(getPath(new Path("import").append(CUSTOM_TEXT_LOG.getTracePath()).toString()));
    assertTrue(fTestFile.exists());
    /* Set up for swtbot */
    SWTBotPreferences.TIMEOUT = 20000;
    /* 20 second timeout */
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    fLogger.removeAllAppenders();
    fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
    fBot = new SWTWorkbenchBot();
    /* Finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
    SWTBotUtils.createProject(TRACE_PROJECT_NAME);
}
Also used : Path(org.eclipse.core.runtime.Path) ConsoleAppender(org.apache.log4j.ConsoleAppender) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SimpleLayout(org.apache.log4j.SimpleLayout) CustomTxtTraceDefinition(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition) IFile(org.eclipse.core.resources.IFile) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 3 with CustomTxtTraceDefinition

use of org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition in project tracecompass by tracecompass.

the class ProjectExplorerTracesFolderTest method importCustomParsers.

private static void importCustomParsers() {
    // FIXME: We can't use Manage Custom Parsers > Import because it uses a native dialog. We'll still check that they show up in the dialog
    CustomTxtTraceDefinition[] txtDefinitions = CustomTxtTraceDefinition.loadAll(getPath("customParsers/ExampleCustomTxtParser.xml"));
    txtDefinitions[0].save();
    CustomXmlTraceDefinition[] xmlDefinitions = CustomXmlTraceDefinition.loadAll(getPath("customParsers/ExampleCustomXmlParser.xml"));
    xmlDefinitions[0].save();
    SWTBotTreeItem traceFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
    traceFolder.contextMenu("Manage Custom Parsers...").click();
    SWTBotShell shell = fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).activate();
    SWTBot shellBot = shell.bot();
    // Make sure the custom text trace type is imported
    shellBot.list().select(CUSTOM_TEXT_LOG.getTraceType());
    // Make sure the custom xml trace type is imported
    shellBot.radio("XML").click();
    shellBot.list().select(CUSTOM_XML_LOG.getTraceType());
    shellBot.button("Close").click();
    shellBot.waitUntil(Conditions.shellCloses(shell), DISK_ACCESS_TIMEOUT);
}
Also used : CustomXmlTraceDefinition(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) CustomTxtTraceDefinition(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition)

Example 4 with CustomTxtTraceDefinition

use of org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition in project tracecompass by tracecompass.

the class TestRefreshCustomTextTrace method createDefinition.

private static void createDefinition() throws URISyntaxException, IOException {
    File file = getBundleFile(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DEFINITION_PATH));
    CustomTxtTraceDefinition[] definitions = CustomTxtTraceDefinition.loadAll(file.toString());
    for (CustomTxtTraceDefinition text : definitions) {
        text.save();
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) File(java.io.File) CustomTxtTraceDefinition(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition)

Example 5 with CustomTxtTraceDefinition

use of org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition in project tracecompass by tracecompass.

the class ManageCustomParsersDialog method fillParserList.

private void fillParserList() {
    parserList.removeAll();
    if (txtButton.getSelection()) {
        for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll(false)) {
            parserList.add(def.categoryName + SEP + def.definitionName);
        }
    } else if (xmlButton.getSelection()) {
        for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll(false)) {
            parserList.add(def.categoryName + SEP + def.definitionName);
        }
    }
    editButton.setEnabled(false);
    deleteButton.setEnabled(false);
    exportButton.setEnabled(false);
}
Also used : CustomXmlTraceDefinition(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition) CustomTxtTraceDefinition(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition)

Aggregations

CustomTxtTraceDefinition (org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition)10 CustomXmlTraceDefinition (org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition)6 File (java.io.File)3 Path (org.eclipse.core.runtime.Path)3 CustomTxtTrace (org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTrace)3 CustomXmlTrace (org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace)3 CoreException (org.eclipse.core.runtime.CoreException)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IPath (org.eclipse.core.runtime.IPath)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 URL (java.net.URL)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 ConsoleAppender (org.apache.log4j.ConsoleAppender)1 SimpleLayout (org.apache.log4j.SimpleLayout)1 IFile (org.eclipse.core.resources.IFile)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1