-package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;\r
-\r
-import java.io.File;\r
-import java.io.FileWriter;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.wizard.WizardPage;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventsTable;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTrace;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.custom.SashForm;\r
-import org.eclipse.swt.custom.ScrolledComposite;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Text;\r
-\r
-public class CustomTxtParserOutputWizardPage extends WizardPage {\r
-\r
- private static final Image upImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/up_button.gif"); //$NON-NLS-1$\r
- private static final Image downImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/down_button.gif"); //$NON-NLS-1$\r
- private final CustomTxtParserWizard wizard;\r
- private CustomTxtTraceDefinition definition;\r
- List<Output> outputs = new ArrayList<Output>();\r
- // Output messageOutput;\r
- Composite container;\r
- SashForm sash;\r
- // Text timestampFormatText;\r
- // Text timestampPreviewText;\r
- ScrolledComposite outputsScrolledComposite;\r
- Composite outputsContainer;\r
- // ScrolledComposite inputScrolledComposite;\r
- Composite tableContainer;\r
- CustomEventsTable previewTable;\r
- File tmpFile;\r
-\r
- protected CustomTxtParserOutputWizardPage(final CustomTxtParserWizard wizard) {\r
- super("CustomParserOutputWizardPage"); //$NON-NLS-1$\r
- setTitle(wizard.inputPage.getTitle());\r
- setDescription(Messages.CustomTxtParserOutputWizardPage_description);\r
- this.wizard = wizard;\r
- setPageComplete(false);\r
- }\r
-\r
- @Override\r
- public void createControl(final Composite parent) {\r
- container = new Composite(parent, SWT.NULL);\r
- container.setLayout(new GridLayout());\r
-\r
- sash = new SashForm(container, SWT.VERTICAL);\r
- sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
- sash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_GRAY));\r
-\r
- outputsScrolledComposite = new ScrolledComposite(sash, SWT.V_SCROLL);\r
- outputsScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
- outputsContainer = new Composite(outputsScrolledComposite, SWT.NONE);\r
- final GridLayout outputsLayout = new GridLayout(4, false);\r
- outputsLayout.marginHeight = 10;\r
- outputsLayout.marginWidth = 0;\r
- outputsContainer.setLayout(outputsLayout);\r
- outputsScrolledComposite.setContent(outputsContainer);\r
- outputsScrolledComposite.setExpandHorizontal(true);\r
- outputsScrolledComposite.setExpandVertical(true);\r
-\r
- outputsContainer.layout();\r
-\r
- outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
-\r
- tableContainer = new Composite(sash, SWT.NONE);\r
- final GridLayout tableLayout = new GridLayout();\r
- tableLayout.marginHeight = 0;\r
- tableLayout.marginWidth = 0;\r
- tableContainer.setLayout(tableLayout);\r
- previewTable = new CustomEventsTable(new CustomTxtTraceDefinition(), tableContainer, 0);\r
- previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-\r
- if (wizard.definition != null)\r
- loadDefinition(wizard.definition);\r
- setControl(container);\r
-\r
- }\r
-\r
- @Override\r
- public void dispose() {\r
- previewTable.dispose();\r
- super.dispose();\r
- }\r
-\r
- private void loadDefinition(final CustomTxtTraceDefinition definition) {\r
- for (final OutputColumn outputColumn : definition.outputs) {\r
- final Output output = new Output(outputsContainer, outputColumn.name);\r
- outputs.add(output);\r
- }\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)\r
- */\r
- @Override\r
- public void setVisible(final boolean visible) {\r
- if (visible) {\r
- this.definition = wizard.inputPage.getDefinition();\r
- final List<String> outputNames = wizard.inputPage.getInputNames();\r
-\r
- // dispose outputs that have been removed in the input page\r
- final Iterator<Output> iter = outputs.iterator();\r
- while (iter.hasNext()) {\r
- final Output output = iter.next();\r
- boolean found = false;\r
- for (final String name : outputNames)\r
- if (output.name.equals(name)) {\r
- found = true;\r
- break;\r
- }\r
- if (!found) {\r
- output.dispose();\r
- iter.remove();\r
- }\r
- }\r
-\r
- // create outputs that have been added in the input page\r
- for (final String name : outputNames) {\r
- boolean found = false;\r
- for (final Output output : outputs)\r
- if (output.name.equals(name)) {\r
- found = true;\r
- break;\r
- }\r
- if (!found)\r
- outputs.add(new Output(outputsContainer, name));\r
- }\r
-\r
- outputsContainer.layout();\r
- outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
- updatePreviewTable();\r
- if (sash.getSize().y > outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + previewTable.getTable().getItemHeight())\r
- sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sash.getSize().y - outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});\r
- else\r
- sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, previewTable.getTable().getItemHeight()});\r
- setPageComplete(true);\r
- } else\r
- setPageComplete(false);\r
- super.setVisible(visible);\r
- }\r
-\r
- private void moveBefore(final Output moved) {\r
- final int i = outputs.indexOf(moved);\r
- if (i > 0) {\r
- final Output previous = outputs.get(i-1);\r
- moved.enabledButton.moveAbove(previous.enabledButton);\r
- moved.nameLabel.moveBelow(moved.enabledButton);\r
- moved.upButton.moveBelow(moved.nameLabel);\r
- moved.downButton.moveBelow(moved.upButton);\r
- outputs.add(i-1, outputs.remove(i));\r
- outputsContainer.layout();\r
- outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
- container.layout();\r
- updatePreviewTable();\r
- }\r
- }\r
-\r
- private void moveAfter(final Output moved) {\r
- final int i = outputs.indexOf(moved);\r
- if (i+1 < outputs.size()) {\r
- final Output next = outputs.get(i+1);\r
- moved.enabledButton.moveBelow(next.downButton);\r
- moved.nameLabel.moveBelow(moved.enabledButton);\r
- moved.upButton.moveBelow(moved.nameLabel);\r
- moved.downButton.moveBelow(moved.upButton);\r
- outputs.add(i+1, outputs.remove(i));\r
- outputsContainer.layout();\r
- outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
- container.layout();\r
- updatePreviewTable();\r
- }\r
- }\r
-\r
- private void updatePreviewTable() {\r
- final int CACHE_SIZE = 50;\r
- definition.outputs = extractOutputs();\r
-\r
- try {\r
- tmpFile = TmfUiPlugin.getDefault().getStateLocation().addTrailingSeparator().append("customwizard.tmp").toFile(); //$NON-NLS-1$\r
- final FileWriter writer = new FileWriter(tmpFile);\r
- writer.write(wizard.inputPage.getInputText());\r
- writer.close();\r
-\r
- final ITmfTrace<?> trace = new CustomTxtTrace(null, definition, tmpFile.getAbsolutePath(), CACHE_SIZE);\r
- previewTable.dispose();\r
- previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE);\r
- previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
- previewTable.setTrace(trace, true);\r
- } catch (final TmfTraceException e) {\r
- TmfUiPlugin.getDefault().logError("Error creating CustomTxtTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$\r
- } catch (final IOException e) {\r
- TmfUiPlugin.getDefault().logError("Error creating CustomTxtTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$\r
- }\r
-\r
- tableContainer.layout();\r
- container.layout();\r
- }\r
-\r
- public List<OutputColumn> extractOutputs() {\r
- int numColumns = 0;\r
- for (int i = 0; i < outputs.size(); i++)\r
- if (outputs.get(i).enabledButton.getSelection())\r
- numColumns++;\r
- final List<OutputColumn> outputColumns = new ArrayList<OutputColumn>(numColumns);\r
- numColumns = 0;\r
- for (int i = 0; i < outputs.size(); i++) {\r
- final Output output = outputs.get(i);\r
- if (output.enabledButton.getSelection()) {\r
- final OutputColumn column = new OutputColumn();\r
- column.name = output.nameLabel.getText();\r
- outputColumns.add(column);\r
- }\r
- }\r
- return outputColumns;\r
- }\r
-\r
- private class Output {\r
- String name;\r
- Button enabledButton;\r
- Text nameLabel;\r
- Button upButton;\r
- Button downButton;\r
-\r
- public Output(final Composite parent, final String name) {\r
- this.name = name;\r
-\r
- enabledButton = new Button(parent, SWT.CHECK);\r
- enabledButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_visible);\r
- enabledButton.setSelection(true);\r
- enabledButton.addSelectionListener(new SelectionAdapter() {\r
- @Override\r
- public void widgetSelected(final SelectionEvent e) {\r
- updatePreviewTable();\r
- }\r
- });\r
- // if (messageOutput != null) {\r
- // enabledButton.moveAbove(messageOutput.enabledButton);\r
- // }\r
-\r
- nameLabel = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.SINGLE);\r
- nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
- nameLabel.setText(name);\r
- nameLabel.moveBelow(enabledButton);\r
-\r
- upButton = new Button(parent, SWT.PUSH);\r
- upButton.setImage(upImage);\r
- upButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_moveBefore);\r
- upButton.addSelectionListener(new SelectionAdapter() {\r
- @Override\r
- public void widgetSelected(final SelectionEvent e) {\r
- moveBefore(Output.this);\r
- }\r
- });\r
- upButton.moveBelow(nameLabel);\r
-\r
- downButton = new Button(parent, SWT.PUSH);\r
- downButton.setImage(downImage);\r
- downButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_moveAfter);\r
- downButton.addSelectionListener(new SelectionAdapter() {\r
- @Override\r
- public void widgetSelected(final SelectionEvent e) {\r
- moveAfter(Output.this);\r
- }\r
- });\r
- downButton.moveBelow(upButton);\r
- }\r
-\r
- private void dispose() {\r
- enabledButton.dispose();\r
- nameLabel.dispose();\r
- upButton.dispose();\r
- downButton.dispose();\r
- }\r
- }\r
-\r
- public CustomTxtTraceDefinition getDefinition() {\r
- return definition;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * 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.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+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.exceptions.TmfTraceException;
+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.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+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$
+ private static final Image downImage = 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;
+
+ /**
+ * Constructor
+ *
+ * @param wizard
+ * The wizard to which this page belongs
+ */
+ protected CustomTxtParserOutputWizardPage(final CustomTxtParserWizard wizard) {
+ super("CustomParserOutputWizardPage"); //$NON-NLS-1$
+ setTitle(wizard.inputPage.getTitle());
+ setDescription(Messages.CustomTxtParserOutputWizardPage_description);
+ this.wizard = wizard;
+ setPageComplete(false);
+ }
+
+ @Override
+ public void createControl(final Composite parent) {
+ container = new Composite(parent, SWT.NULL);
+ container.setLayout(new GridLayout());
+
+ sash = new SashForm(container, SWT.VERTICAL);
+ sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ sash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+
+ outputsScrolledComposite = new ScrolledComposite(sash, SWT.V_SCROLL);
+ outputsScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ outputsContainer = new Composite(outputsScrolledComposite, SWT.NONE);
+ final GridLayout outputsLayout = new GridLayout(4, false);
+ outputsLayout.marginHeight = 10;
+ outputsLayout.marginWidth = 0;
+ outputsContainer.setLayout(outputsLayout);
+ outputsScrolledComposite.setContent(outputsContainer);
+ outputsScrolledComposite.setExpandHorizontal(true);
+ outputsScrolledComposite.setExpandVertical(true);
+
+ outputsContainer.layout();
+
+ outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+
+ tableContainer = new Composite(sash, SWT.NONE);
+ final GridLayout tableLayout = new GridLayout();
+ tableLayout.marginHeight = 0;
+ tableLayout.marginWidth = 0;
+ tableContainer.setLayout(tableLayout);
+ previewTable = new CustomEventsTable(new CustomTxtTraceDefinition(), tableContainer, 0);
+ previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ if (wizard.definition != null) {
+ loadDefinition(wizard.definition);
+ }
+ setControl(container);
+
+ }
+
+ @Override
+ public void dispose() {
+ previewTable.dispose();
+ super.dispose();
+ }
+
+ private void loadDefinition(final CustomTxtTraceDefinition def) {
+ for (final OutputColumn outputColumn : def.outputs) {
+ final Output output = new Output(outputsContainer, outputColumn.name);
+ outputs.add(output);
+ }
+ }
+
+ @Override
+ public void setVisible(final boolean visible) {
+ if (visible) {
+ this.definition = wizard.inputPage.getDefinition();
+ final List<String> outputNames = wizard.inputPage.getInputNames();
+
+ // dispose outputs that have been removed in the input page
+ final Iterator<Output> iter = outputs.iterator();
+ while (iter.hasNext()) {
+ final Output output = iter.next();
+ boolean found = false;
+ 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) {
+ if (output.name.equals(name)) {
+ found = true;
+ break;
+ }
+ }
+ 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()) {
+ sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sash.getSize().y - outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});
+ } else {
+ sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, previewTable.getTable().getItemHeight()});
+ }
+ setPageComplete(true);
+ } else {
+ setPageComplete(false);
+ }
+ super.setVisible(visible);
+ }
+
+ private void moveBefore(final Output moved) {
+ final int i = outputs.indexOf(moved);
+ if (i > 0) {
+ final Output previous = outputs.get(i-1);
+ moved.enabledButton.moveAbove(previous.enabledButton);
+ moved.nameLabel.moveBelow(moved.enabledButton);
+ moved.upButton.moveBelow(moved.nameLabel);
+ moved.downButton.moveBelow(moved.upButton);
+ outputs.add(i-1, outputs.remove(i));
+ outputsContainer.layout();
+ outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+ container.layout();
+ updatePreviewTable();
+ }
+ }
+
+ private void moveAfter(final Output moved) {
+ final int i = outputs.indexOf(moved);
+ if (i+1 < outputs.size()) {
+ final Output next = outputs.get(i+1);
+ moved.enabledButton.moveBelow(next.downButton);
+ moved.nameLabel.moveBelow(moved.enabledButton);
+ moved.upButton.moveBelow(moved.nameLabel);
+ moved.downButton.moveBelow(moved.upButton);
+ outputs.add(i+1, outputs.remove(i));
+ outputsContainer.layout();
+ outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+ container.layout();
+ updatePreviewTable();
+ }
+ }
+
+ private void updatePreviewTable() {
+ final int CACHE_SIZE = 50;
+ definition.outputs = extractOutputs();
+
+ try {
+ tmpFile = Activator.getDefault().getStateLocation().addTrailingSeparator().append("customwizard.tmp").toFile(); //$NON-NLS-1$
+ final FileWriter writer = new FileWriter(tmpFile);
+ writer.write(wizard.inputPage.getInputText());
+ writer.close();
+
+ 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));
+ 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();
+ 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()) {
+ numColumns++;
+ }
+ }
+ final List<OutputColumn> outputColumns = new ArrayList<OutputColumn>(numColumns);
+ numColumns = 0;
+ for (int i = 0; i < outputs.size(); i++) {
+ final Output output = outputs.get(i);
+ if (output.enabledButton.getSelection()) {
+ final OutputColumn column = new OutputColumn();
+ column.name = output.nameLabel.getText();
+ outputColumns.add(column);
+ }
+ }
+ return outputColumns;
+ }
+
+ private class Output {
+ String name;
+ Button enabledButton;
+ Text nameLabel;
+ Button upButton;
+ Button downButton;
+
+ public Output(final Composite parent, final String name) {
+ this.name = name;
+
+ enabledButton = new Button(parent, SWT.CHECK);
+ enabledButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_visible);
+ enabledButton.setSelection(true);
+ enabledButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ updatePreviewTable();
+ }
+ });
+ // if (messageOutput != null) {
+ // enabledButton.moveAbove(messageOutput.enabledButton);
+ // }
+
+ nameLabel = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.SINGLE);
+ nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ nameLabel.setText(name);
+ nameLabel.moveBelow(enabledButton);
+
+ upButton = new Button(parent, SWT.PUSH);
+ upButton.setImage(upImage);
+ upButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_moveBefore);
+ upButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ moveBefore(Output.this);
+ }
+ });
+ upButton.moveBelow(nameLabel);
+
+ downButton = new Button(parent, SWT.PUSH);
+ downButton.setImage(downImage);
+ downButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_moveAfter);
+ downButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ moveAfter(Output.this);
+ }
+ });
+ downButton.moveBelow(upButton);
+ }
+
+ private void dispose() {
+ enabledButton.dispose();
+ nameLabel.dispose();
+ upButton.dispose();
+ downButton.dispose();
+ }
+ }
+
+ /**
+ * Get the trace definition.
+ *
+ * @return The trace definition
+ */
+ public CustomTxtTraceDefinition getDefinition() {
+ return definition;
+ }
+
+}