ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / parsers / wizards / CustomTxtParserOutputWizardPage.java
index c01cd1d9925f38f9583f0f71cb000f98d79f4cf2..b93f94c3bca6843f08a2938123adc23f99573066 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2013 Ericsson
+ * Copyright (c) 2010, 2014 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -22,12 +22,15 @@ import java.util.List;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 import org.eclipse.linuxtools.internal.tmf.ui.Messages;
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventsTable;
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTrace;
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventTableColumns;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
+import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTrace;
+import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTraceDefinition;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.SashForm;
 import org.eclipse.swt.custom.ScrolledComposite;
@@ -51,13 +54,13 @@ public class CustomTxtParserOutputWizardPage extends WizardPage {
     private static final Image DOWN_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/down_button.gif"); //$NON-NLS-1$
     private final CustomTxtParserWizard wizard;
     private CustomTxtTraceDefinition definition;
-    private List<Output> outputs = new ArrayList<Output>();
+    private List<Output> outputs = new ArrayList<>();
     private Composite container;
     private SashForm sash;
     private ScrolledComposite outputsScrolledComposite;
     private Composite outputsContainer;
     private Composite tableContainer;
-    private CustomEventsTable previewTable;
+    private TmfEventsTable previewTable;
     private File tmpFile;
 
     /**
@@ -103,7 +106,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage {
         tableLayout.marginHeight = 0;
         tableLayout.marginWidth = 0;
         tableContainer.setLayout(tableLayout);
-        previewTable = new CustomEventsTable(new CustomTxtTraceDefinition(), tableContainer, 0);
+        previewTable = new TmfEventsTable(tableContainer, 0, CustomEventTableColumns.generateColumns(new CustomTxtTraceDefinition()));
         previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
         if (wizard.definition != null) {
@@ -213,23 +216,28 @@ public class CustomTxtParserOutputWizardPage extends WizardPage {
     private void updatePreviewTable() {
         final int CACHE_SIZE = 50;
         definition.outputs = extractOutputs();
+        tmpFile = Activator.getDefault().getStateLocation().addTrailingSeparator().append("customwizard.tmp").toFile(); //$NON-NLS-1$
 
-        try {
-            tmpFile = Activator.getDefault().getStateLocation().addTrailingSeparator().append("customwizard.tmp").toFile(); //$NON-NLS-1$
-            final FileWriter writer = new FileWriter(tmpFile);
+        try (final FileWriter writer = new FileWriter(tmpFile);) {
             writer.write(wizard.inputPage.getInputText());
-            writer.close();
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error creating CustomTxtTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$
+        }
 
-            final CustomTxtTrace trace = new CustomTxtTrace(null, definition, tmpFile.getAbsolutePath(), CACHE_SIZE);
+        try {
+            final CustomTxtTrace trace = new CustomTxtTrace(null, definition, tmpFile.getAbsolutePath(), CACHE_SIZE) {
+                @Override
+                protected ITmfTraceIndexer createIndexer(int interval) {
+                    return new TmfCheckpointIndexer(this, interval);
+                }
+            };
             trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
             previewTable.dispose();
-            previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE);
+            previewTable = new TmfEventsTable(tableContainer, CACHE_SIZE, CustomEventTableColumns.generateColumns(definition));
             previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
             previewTable.setTrace(trace, true);
         } catch (final TmfTraceException e) {
             Activator.getDefault().logError("Error creating CustomTxtTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$
-        } catch (final IOException e) {
-            Activator.getDefault().logError("Error creating CustomTxtTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$
         }
 
         tableContainer.layout();
@@ -248,7 +256,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage {
                 numColumns++;
             }
         }
-        final List<OutputColumn> outputColumns = new ArrayList<OutputColumn>(numColumns);
+        final List<OutputColumn> outputColumns = new ArrayList<>(numColumns);
         numColumns = 0;
         for (int i = 0; i < outputs.size(); i++) {
             final Output output = outputs.get(i);
This page took 0.027509 seconds and 5 git commands to generate.