/*******************************************************************************
- * 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
* 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;
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;
/**
* 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
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) {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
- */
@Override
public void setVisible(final boolean visible) {
if (visible) {
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();
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);
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
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