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 66560894deb62ca4803792cb1faed5b8816834b4..b93f94c3bca6843f08a2938123adc23f99573066 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 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
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Patrick Tassé - Initial API and implementation
+ *   Patrick Tasse - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;
@@ -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.tmf.core.event.TmfTimeRange;
+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;
@@ -43,26 +46,22 @@ import org.eclipse.swt.widgets.Text;
 /**
  * Output wizard page for custom text trace parsers.
  *
- * @author Patrick Tassé
+ * @author Patrick Tasse
  */
 public class CustomTxtParserOutputWizardPage extends WizardPage {
 
-    private static final Image upImage = Activator.getDefault().getImageFromPath("/icons/elcl16/up_button.gif"); //$NON-NLS-1$
-    private static final Image downImage = Activator.getDefault().getImageFromPath("/icons/elcl16/down_button.gif"); //$NON-NLS-1$
+    private static final Image UP_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/up_button.gif"); //$NON-NLS-1$
+    private static final Image DOWN_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/down_button.gif"); //$NON-NLS-1$
     private final CustomTxtParserWizard wizard;
     private CustomTxtTraceDefinition definition;
-    List<Output> outputs = new ArrayList<Output>();
-    //    Output messageOutput;
-    Composite container;
-    SashForm sash;
-    //    Text timestampFormatText;
-    //    Text timestampPreviewText;
-    ScrolledComposite outputsScrolledComposite;
-    Composite outputsContainer;
-    //    ScrolledComposite inputScrolledComposite;
-    Composite tableContainer;
-    CustomEventsTable previewTable;
-    File tmpFile;
+    private List<Output> outputs = new ArrayList<>();
+    private Composite container;
+    private SashForm sash;
+    private ScrolledComposite outputsScrolledComposite;
+    private Composite outputsContainer;
+    private Composite tableContainer;
+    private TmfEventsTable previewTable;
+    private File tmpFile;
 
     /**
      * Constructor
@@ -107,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) {
@@ -130,9 +129,6 @@ public class CustomTxtParserOutputWizardPage extends WizardPage {
         }
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
-     */
     @Override
     public void setVisible(final boolean visible) {
         if (visible) {
@@ -220,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();
@@ -255,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);
@@ -297,7 +298,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage {
             nameLabel.moveBelow(enabledButton);
 
             upButton = new Button(parent, SWT.PUSH);
-            upButton.setImage(upImage);
+            upButton.setImage(UP_IMAGE);
             upButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_moveBefore);
             upButton.addSelectionListener(new SelectionAdapter() {
                 @Override
@@ -308,7 +309,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage {
             upButton.moveBelow(nameLabel);
 
             downButton = new Button(parent, SWT.PUSH);
-            downButton.setImage(downImage);
+            downButton.setImage(DOWN_IMAGE);
             downButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_moveAfter);
             downButton.addSelectionListener(new SelectionAdapter() {
                 @Override
This page took 0.027752 seconds and 5 git commands to generate.