+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tassé - Initial API and implementation
+ *******************************************************************************/
+
package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;
import java.io.File;
import java.util.List;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;
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.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
+/**
+ * Output wizard page for custom text trace parsers.
+ *
+ * @author Patrick Tassé
+ */
public class CustomTxtParserOutputWizardPage extends WizardPage {
private static final Image upImage = Activator.getDefault().getImageFromPath("/icons/elcl16/up_button.gif"); //$NON-NLS-1$
CustomEventsTable previewTable;
File tmpFile;
+ /**
+ * Constructor
+ *
+ * @param wizard
+ * The wizard to which this page belongs
+ */
protected CustomTxtParserOutputWizardPage(final CustomTxtParserWizard wizard) {
super("CustomParserOutputWizardPage"); //$NON-NLS-1$
setTitle(wizard.inputPage.getTitle());
previewTable = new CustomEventsTable(new CustomTxtTraceDefinition(), tableContainer, 0);
previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- if (wizard.definition != null)
+ if (wizard.definition != null) {
loadDefinition(wizard.definition);
+ }
setControl(container);
}
super.dispose();
}
- private void loadDefinition(final CustomTxtTraceDefinition definition) {
- for (final OutputColumn outputColumn : definition.outputs) {
+ private void loadDefinition(final CustomTxtTraceDefinition def) {
+ for (final OutputColumn outputColumn : def.outputs) {
final Output output = new Output(outputsContainer, outputColumn.name);
outputs.add(output);
}
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
- */
@Override
public void setVisible(final boolean visible) {
if (visible) {
while (iter.hasNext()) {
final Output output = iter.next();
boolean found = false;
- for (final String name : outputNames)
+ for (final String name : outputNames) {
if (output.name.equals(name)) {
found = true;
break;
}
+ }
if (!found) {
output.dispose();
iter.remove();
// create outputs that have been added in the input page
for (final String name : outputNames) {
boolean found = false;
- for (final Output output : outputs)
+ for (final Output output : outputs) {
if (output.name.equals(name)) {
found = true;
break;
}
- if (!found)
+ }
+ if (!found) {
outputs.add(new Output(outputsContainer, name));
+ }
}
outputsContainer.layout();
outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
updatePreviewTable();
- if (sash.getSize().y > outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + previewTable.getTable().getItemHeight())
+ if (sash.getSize().y > outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + previewTable.getTable().getItemHeight()) {
sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sash.getSize().y - outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});
- else
+ } else {
sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, previewTable.getTable().getItemHeight()});
+ }
setPageComplete(true);
- } else
+ } else {
setPageComplete(false);
+ }
super.setVisible(visible);
}
writer.write(wizard.inputPage.getInputText());
writer.close();
- final ITmfTrace<?> trace = new CustomTxtTrace(null, definition, tmpFile.getAbsolutePath(), CACHE_SIZE);
+ final CustomTxtTrace trace = new CustomTxtTrace(null, definition, tmpFile.getAbsolutePath(), CACHE_SIZE);
+ trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
previewTable.dispose();
previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE);
previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
container.layout();
}
+ /**
+ * Extract the list of output columns from the page's contents.
+ *
+ * @return The output columns
+ */
public List<OutputColumn> extractOutputs() {
int numColumns = 0;
- for (int i = 0; i < outputs.size(); i++)
- if (outputs.get(i).enabledButton.getSelection())
+ for (int i = 0; i < outputs.size(); i++) {
+ if (outputs.get(i).enabledButton.getSelection()) {
numColumns++;
+ }
+ }
final List<OutputColumn> outputColumns = new ArrayList<OutputColumn>(numColumns);
numColumns = 0;
for (int i = 0; i < outputs.size(); i++) {
}
}
+ /**
+ * Get the trace definition.
+ *
+ * @return The trace definition
+ */
public CustomTxtTraceDefinition getDefinition() {
return definition;
}