* 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
- * $Id: CommonUIImages.java,v 1.6 2010/05/05 12:32:31 paules Exp $
*
* Contributors:
* Bernd Hufmann - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.internal.tmf.ui;
-@SuppressWarnings("nls")
+/**
+ * Names for generic icons and buttons used in TMF
+ */
+@SuppressWarnings({"nls", "javadoc"})
public interface ITmfImageConstants {
public static final String ICONS_PATH = "icons/"; //$NON-NLS-1$
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ *
+ *******************************************************************************/
+
package org.eclipse.linuxtools.internal.tmf.ui;
import org.eclipse.osgi.util.NLS;
+/**
+ * TMF message bundle
+ */
+@SuppressWarnings("javadoc")
public class Messages extends NLS {
+
private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.tmf.ui.messages"; //$NON-NLS-1$
public static String ManageCustomParsersDialog_DeleteButtonLabel;
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ *
+ *******************************************************************************/
+
package org.eclipse.linuxtools.internal.tmf.ui;
import java.io.BufferedWriter;
import org.eclipse.core.runtime.Platform;
+/**
+ * Tracer class for the tmf.ui plugin
+ */
@SuppressWarnings("nls")
public class TmfUiTracer {
- private static String pluginID = Activator.PLUGIN_ID;
-
- static Boolean ERROR = Boolean.FALSE;
- static Boolean WARNING = Boolean.FALSE;
- static Boolean INFO = Boolean.FALSE;
-
- static Boolean INDEX = Boolean.FALSE;
- static Boolean DISPLAY = Boolean.FALSE;
- static Boolean SORTING = Boolean.FALSE;
-
- private static String LOGNAME = "traceUI.log";
- private static BufferedWriter fTraceLog = null;
-
- private static BufferedWriter openLogFile(String filename) {
- BufferedWriter outfile = null;
- try {
- outfile = new BufferedWriter(new FileWriter(filename));
- } catch (IOException e) {
- Activator.getDefault().logError("Error creating log file " + LOGNAME, e); //$NON-NLS-1$
- }
- return outfile;
- }
-
- public static void init() {
-
- String traceKey;
- boolean isTracing = false;
-
- traceKey = Platform.getDebugOption(pluginID + "/error");
- if (traceKey != null) {
- ERROR = (Boolean.valueOf(traceKey)).booleanValue();
- isTracing |= ERROR;
- }
-
- traceKey = Platform.getDebugOption(pluginID + "/warning");
- if (traceKey != null) {
- WARNING = (Boolean.valueOf(traceKey)).booleanValue();
- isTracing |= WARNING;
- }
-
- traceKey = Platform.getDebugOption(pluginID + "/info");
- if (traceKey != null) {
- INFO = (Boolean.valueOf(traceKey)).booleanValue();
- isTracing |= INFO;
- }
-
- traceKey = Platform.getDebugOption(pluginID + "/updateindex");
- if (traceKey != null) {
- INDEX = (Boolean.valueOf(traceKey)).booleanValue();
- isTracing |= INDEX;
- }
-
- traceKey = Platform.getDebugOption(pluginID + "/display");
- if (traceKey != null) {
- DISPLAY = (Boolean.valueOf(traceKey)).booleanValue();
- isTracing |= DISPLAY;
- }
-
- traceKey = Platform.getDebugOption(pluginID + "/sorting");
- if (traceKey != null) {
- SORTING = (Boolean.valueOf(traceKey)).booleanValue();
- isTracing |= SORTING;
- }
-
- // Create trace log file if needed
- if (isTracing) {
- fTraceLog = openLogFile(LOGNAME);
- }
- }
-
- public static void stop() {
- if (fTraceLog == null)
- return;
-
- try {
- fTraceLog.close();
- fTraceLog = null;
- } catch (IOException e) {
- Activator.getDefault().logError("Error closing log file " + LOGNAME, e); //$NON-NLS-1$
- }
- }
-
- // Predicates
- public static boolean isErrorTraced() {
- return ERROR;
- }
-
- public static boolean isIndexTraced() {
- return INDEX;
- }
-
- public static boolean isDisplayTraced() {
- return DISPLAY;
- }
-
- public static boolean isSortingTraced() {
- return SORTING;
- }
-
- // Tracers
- public static void trace(String msg) {
- long currentTime = System.currentTimeMillis();
- StringBuilder message = new StringBuilder("[");
- message.append(currentTime / 1000);
- message.append(".");
- message.append(String.format("%1$03d", currentTime % 1000));
- message.append("] ");
- message.append(msg);
-
- if (fTraceLog != null) {
- try {
- fTraceLog.write(message.toString());
- fTraceLog.newLine();
- fTraceLog.flush();
- } catch (IOException e) {
- Activator.getDefault().logError("Error writing to log file " + LOGNAME, e); //$NON-NLS-1$
- }
- }
- }
-
- public static void traceIndex(String msg) {
- String message = ("[INDEX] " + msg);
- trace(message);
- }
-
- public static void traceDisplay(String msg) {
- String message = ("[DISPLAY]" + msg);
- trace(message);
- }
-
- public static void traceSorting(String msg) {
- String message = ("[SORT] " + msg);
- trace(message);
- }
-
- public static void traceError(String msg) {
- String message = ("[ERR] Thread=" + Thread.currentThread().getId() + " " + msg);
- trace(message);
- }
-
- public static void traceWarning(String msg) {
- String message = ("[WARN] Thread=" + Thread.currentThread().getId() + " " + msg);
- trace(message);
- }
-
- public static void traceInfo(String msg) {
- String message = ("[INF] Thread=" + Thread.currentThread().getId() + " " + msg);
- trace(message);
- }
-
-
+ private static String pluginID = Activator.PLUGIN_ID;
+
+ static Boolean ERROR = Boolean.FALSE;
+ static Boolean WARNING = Boolean.FALSE;
+ static Boolean INFO = Boolean.FALSE;
+
+ static Boolean INDEX = Boolean.FALSE;
+ static Boolean DISPLAY = Boolean.FALSE;
+ static Boolean SORTING = Boolean.FALSE;
+
+ private static String LOGNAME = "traceUI.log";
+ private static BufferedWriter fTraceLog = null;
+
+ private static BufferedWriter openLogFile(String filename) {
+ BufferedWriter outfile = null;
+ try {
+ outfile = new BufferedWriter(new FileWriter(filename));
+ } catch (IOException e) {
+ Activator.getDefault().logError("Error creating log file " + LOGNAME, e); //$NON-NLS-1$
+ }
+ return outfile;
+ }
+
+ /**
+ * Initialize tracing
+ */
+ public static void init() {
+
+ String traceKey;
+ boolean isTracing = false;
+
+ traceKey = Platform.getDebugOption(pluginID + "/error");
+ if (traceKey != null) {
+ ERROR = (Boolean.valueOf(traceKey)).booleanValue();
+ isTracing |= ERROR;
+ }
+
+ traceKey = Platform.getDebugOption(pluginID + "/warning");
+ if (traceKey != null) {
+ WARNING = (Boolean.valueOf(traceKey)).booleanValue();
+ isTracing |= WARNING;
+ }
+
+ traceKey = Platform.getDebugOption(pluginID + "/info");
+ if (traceKey != null) {
+ INFO = (Boolean.valueOf(traceKey)).booleanValue();
+ isTracing |= INFO;
+ }
+
+ traceKey = Platform.getDebugOption(pluginID + "/updateindex");
+ if (traceKey != null) {
+ INDEX = (Boolean.valueOf(traceKey)).booleanValue();
+ isTracing |= INDEX;
+ }
+
+ traceKey = Platform.getDebugOption(pluginID + "/display");
+ if (traceKey != null) {
+ DISPLAY = (Boolean.valueOf(traceKey)).booleanValue();
+ isTracing |= DISPLAY;
+ }
+
+ traceKey = Platform.getDebugOption(pluginID + "/sorting");
+ if (traceKey != null) {
+ SORTING = (Boolean.valueOf(traceKey)).booleanValue();
+ isTracing |= SORTING;
+ }
+
+ // Create trace log file if needed
+ if (isTracing) {
+ fTraceLog = openLogFile(LOGNAME);
+ }
+ }
+
+ /**
+ * Stop tracing
+ */
+ public static void stop() {
+ if (fTraceLog == null) {
+ return;
+ }
+
+ try {
+ fTraceLog.close();
+ fTraceLog = null;
+ } catch (IOException e) {
+ Activator.getDefault().logError("Error closing log file " + LOGNAME, e); //$NON-NLS-1$
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Predicates
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return If ERROR messages are traced
+ */
+ public static boolean isErrorTraced() {
+ return ERROR;
+ }
+
+ /**
+ * @return If INDEX messages are traced
+ */
+ public static boolean isIndexTraced() {
+ return INDEX;
+ }
+
+ /**
+ * @return If DISPLAY messages are traced
+ */
+ public static boolean isDisplayTraced() {
+ return DISPLAY;
+ }
+
+ /**
+ * @return If SORTING messages are traced
+ */
+ public static boolean isSortingTraced() {
+ return SORTING;
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Tracing methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Trace a generic event
+ *
+ * @param msg
+ * The event's message
+ */
+ public static void trace(String msg) {
+ long currentTime = System.currentTimeMillis();
+ StringBuilder message = new StringBuilder("[");
+ message.append(currentTime / 1000);
+ message.append(".");
+ message.append(String.format("%1$03d", currentTime % 1000));
+ message.append("] ");
+ message.append(msg);
+
+ if (fTraceLog != null) {
+ try {
+ fTraceLog.write(message.toString());
+ fTraceLog.newLine();
+ fTraceLog.flush();
+ } catch (IOException e) {
+ Activator.getDefault().logError("Error writing to log file " + LOGNAME, e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * Trace an INDEX event
+ *
+ * @param msg
+ * The event's message
+ */
+ public static void traceIndex(String msg) {
+ String message = ("[INDEX] " + msg);
+ trace(message);
+ }
+
+ /**
+ * Trace a DISPLAY event
+ *
+ * @param msg
+ * The event's message
+ */
+ public static void traceDisplay(String msg) {
+ String message = ("[DISPLAY]" + msg);
+ trace(message);
+ }
+
+ /**
+ * Trace a SORTING event
+ *
+ * @param msg
+ * The event's message
+ */
+ public static void traceSorting(String msg) {
+ String message = ("[SORT] " + msg);
+ trace(message);
+ }
+
+ /**
+ * Trace an ERROR event
+ *
+ * @param msg
+ * The event's message
+ */
+ public static void traceError(String msg) {
+ String message = ("[ERR] Thread=" + Thread.currentThread().getId() + " " + msg);
+ trace(message);
+ }
+
+ /**
+ * Trace a WARNING event
+ *
+ * @param msg
+ * The event's message
+ */
+ public static void traceWarning(String msg) {
+ String message = ("[WARN] Thread=" + Thread.currentThread().getId() + " " + msg);
+ trace(message);
+ }
+
+ /**
+ * Trace an INFO event
+ *
+ * @param msg
+ * The event's message
+ */
+ public static void traceInfo(String msg) {
+ String message = ("[INF] Thread=" + Thread.currentThread().getId() + " " + msg);
+ trace(message);
+ }
}
/*******************************************************************************
* Copyright (c) 2010 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 Tasse - Initial API and implementation
*******************************************************************************/
import org.eclipse.linuxtools.internal.tmf.ui.dialogs.ManageCustomParsersDialog;
import org.eclipse.swt.widgets.Display;
+/**
+ * Command handler for custom text parsers.
+ *
+ * @author Patrick Tassé
+ */
public class ManageCustomParsersCommandHandler extends AbstractHandler {
@Override
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
+/**
+ * Dialog for custom text parsers.
+ *
+ * @author Patrick Tassé
+ */
public class ManageCustomParsersDialog extends Dialog {
private static final Image image = Activator.getDefault().getImageFromPath("/icons/etool16/customparser_wizard.gif"); //$NON-NLS-1$
Button importButton;
Button exportButton;
+ /**
+ * Constructor
+ *
+ * @param parent
+ * Parent shell of this dialog
+ */
public ManageCustomParsersDialog(Shell parent) {
super(parent);
setShellStyle(SWT.RESIZE | SWT.MAX | getShellStyle());
txtButton = new Button(radioContainer, SWT.RADIO);
txtButton.setText(Messages.ManageCustomParsersDialog_TextButtonLabel);
txtButton.setSelection(true);
- txtButton.addSelectionListener(new SelectionListener(){
+ txtButton.addSelectionListener(new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
fillParserList();
- }});
+ }
+ });
xmlButton = new Button(radioContainer, SWT.RADIO);
xmlButton.setText("XML"); //$NON-NLS-1$
- xmlButton.addSelectionListener(new SelectionListener(){
+ xmlButton.addSelectionListener(new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
fillParserList();
- }});
+ }
+ });
parserList = new List(listContainer, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
parserList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- parserList.addSelectionListener(new SelectionListener(){
+ parserList.addSelectionListener(new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
if (parserList.getSelectionCount() == 0) {
editButton.setEnabled(false);
deleteButton.setEnabled(false);
deleteButton.setEnabled(true);
exportButton.setEnabled(true);
}
- }});
+ }
+ });
Composite buttonContainer = new Composite(composite, SWT.NULL);
buttonContainer.setLayout(new GridLayout());
newButton = new Button(buttonContainer, SWT.PUSH);
newButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
newButton.setText(Messages.ManageCustomParsersDialog_NewButtonLabel);
- newButton.addSelectionListener(new SelectionListener(){
+ newButton.addSelectionListener(new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
WizardDialog dialog = null;
if (txtButton.getSelection()) {
dialog = new WizardDialog(getShell(), new CustomTxtParserWizard());
fillParserList();
}
}
- }});
+ }
+ });
editButton = new Button(buttonContainer, SWT.PUSH);
editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
editButton.setText(Messages.ManageCustomParsersDialog_EditButtonLabel);
editButton.setEnabled(false);
- editButton.addSelectionListener(new SelectionListener(){
+ editButton.addSelectionListener(new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
WizardDialog dialog = null;
if (txtButton.getSelection()) {
dialog = new WizardDialog(getShell(),
fillParserList();
}
}
- }});
+ }
+ });
deleteButton = new Button(buttonContainer, SWT.PUSH);
deleteButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
deleteButton.setText(Messages.ManageCustomParsersDialog_DeleteButtonLabel);
deleteButton.setEnabled(false);
- deleteButton.addSelectionListener(new SelectionListener(){
+ deleteButton.addSelectionListener(new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
boolean confirm = MessageDialog.openQuestion(
getShell(),
Messages.ManageCustomParsersDialog_DeleteParserDialogHeader,
}
fillParserList();
}
- }});
+ }
+ });
new Label(buttonContainer, SWT.NONE); // filler
importButton = new Button(buttonContainer, SWT.PUSH);
importButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
importButton.setText(Messages.ManageCustomParsersDialog_ImportButtonLabel);
- importButton.addSelectionListener(new SelectionListener(){
+ importButton.addSelectionListener(new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
dialog.setText(Messages.ManageCustomParsersDialog_ImportParserSelection);
- dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$
+ dialog.setFilterExtensions(new String[] { "*.xml", "*" }); //$NON-NLS-1$ //$NON-NLS-2$
String path = dialog.open();
if (path != null) {
CustomTraceDefinition[] defs = null;
fillParserList();
}
}
- }});
+ }
+ });
exportButton = new Button(buttonContainer, SWT.PUSH);
exportButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
exportButton.setText(Messages.ManageCustomParsersDialog_ExportButtonLabel);
exportButton.setEnabled(false);
- exportButton.addSelectionListener(new SelectionListener(){
+ exportButton.addSelectionListener(new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
dialog.setText(Messages.ManageCustomParsersDialog_ExportParserSelection + parserList.getSelection()[0]);
- dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$
+ dialog.setFilterExtensions(new String[] { "*.xml", "*" }); //$NON-NLS-1$ //$NON-NLS-2$
String path = dialog.open();
if (path != null) {
CustomTraceDefinition def = null;
def.save(path);
}
}
- }});
+ }
+ });
fillParserList();
*
* Overrides InputDialog to support multiple line text input.
*
- * @author Patrick Tasse
- *
+ * @author Patrick Tassé
*/
public class MultiLineInputDialog extends InputDialog {
/*******************************************************************************
* Copyright (c) 2010 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 Tasse - Initial API and implementation
*******************************************************************************/
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
+/**
+ * Handler to add bookmarks.
+ *
+ * @author Patrick Tasse
+ */
public class AddBookmarkHandler extends AbstractHandler {
- @Override
+ @Override
public boolean isEnabled() {
- return true;
+ return true;
}
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();
IEditorPart activeEditor = activePage.getActiveEditor();
if (activeEditor instanceof TmfEventsEditor) {
- TmfEventsEditor editor = (TmfEventsEditor) activeEditor;
- editor.addBookmark();
+ TmfEventsEditor editor = (TmfEventsEditor) activeEditor;
+ editor.addBookmark();
}
- return null;
- }
+ return null;
+ }
}
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+/**
+ * Base event for custom text parsers.
+ *
+ * @author Patrick Tassé
+ */
public class CustomEvent extends TmfEvent {
+ /** Default timestamp scale for text-parser events */
+ public static final byte TIMESTAMP_SCALE = -3;
+
+ /** Input format key */
protected static final String TIMESTAMP_INPUT_FORMAT_KEY = "CE_TS_I_F"; //$NON-NLS-1$
+
+ /** Empty message */
protected static final String NO_MESSAGE = ""; //$NON-NLS-1$
- public static final byte TIMESTAMP_SCALE = -3;
+ /** The trace to which this event belongs */
protected CustomTraceDefinition fDefinition;
+
+ /** The payload data of this event, <field name, value> */
protected Map<String, String> fData;
+
private TmfEventField[] fColumnData;
+ /**
+ * Basic constructor.
+ *
+ * @param definition
+ * The trace definition to which this event belongs
+ */
public CustomEvent(CustomTraceDefinition definition) {
fDefinition = definition;
fData = new HashMap<String, String>();
}
+ /**
+ * Build a new CustomEvent from an existing TmfEvent.
+ *
+ * @param definition
+ * The trace definition to which this event belongs
+ * @param other
+ * The TmfEvent to copy
+ */
public CustomEvent(CustomTraceDefinition definition, TmfEvent other) {
super(other);
fDefinition = definition;
fData = new HashMap<String, String>();
}
- public CustomEvent(CustomTraceDefinition definition, ITmfTrace parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {
+ /**
+ * Full constructor
+ *
+ * @param definition
+ * Trace definition of this event
+ * @param parentTrace
+ * Parent trace object
+ * @param timestamp
+ * Timestamp of this event
+ * @param source
+ * Source of the event
+ * @param type
+ * Event type
+ * @param reference
+ * Event reference
+ */
+ public CustomEvent(CustomTraceDefinition definition, ITmfTrace parentTrace,
+ ITmfTimestamp timestamp, String source, TmfEventType type,
+ String reference) {
super(parentTrace, timestamp, source, type, null, reference);
fDefinition = definition;
fData = new HashMap<String, String>();
return super.getTimestamp();
}
+ /**
+ * @return The event fields
+ */
public TmfEventField[] extractItemFields() {
if (fData != null) {
processData();
+/*******************************************************************************
+ * Copyright (c) 2010 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.custom;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+/**
+ * Event content for custom text parsers
+ *
+ * @author Patrick Tassé
+ */
public class CustomEventContent extends TmfEventField {
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * Parent event
+ * @param content
+ * Event content
+ */
public CustomEventContent(CustomEvent parent, StringBuffer content) {
super(ITmfEventField.ROOT_FIELD_ID, content);
}
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
return super.hashCode();
}
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
+ /**
+ * Modify the fields to the given value.
+ *
+ * @param fields
+ * The array of fields to use as event content
+ */
public void setFields(ITmfEventField[] fields) {
super.setValue(getValue(), fields);
}
+/*******************************************************************************
+ * Copyright (c) 2010 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.custom;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
+/**
+ * Event type for custom text parsers.
+ *
+ * @author Patrick Tassé
+ */
public abstract class CustomEventType extends TmfEventType {
-
+
private static String CONTEXT_ID = "CustomEventType"; //$NON-NLS-1$
-
+
+ /**
+ * Constructor
+ *
+ * @param definition
+ * Trace definition
+ */
public CustomEventType(CustomTraceDefinition definition) {
super(CONTEXT_ID, definition.definitionName, getRootField(definition));
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
+/**
+ * Events table for custom text parsers.
+ *
+ * @author Patrick Tassé
+ */
public class CustomEventsTable extends TmfEventsTable {
private final CustomTraceDefinition fDefinition;
+ /**
+ * Constructor.
+ *
+ * @param definition
+ * Trace definition object
+ * @param parent
+ * Parent composite of the view
+ * @param cacheSize
+ * How many events to keep in cache
+ */
public CustomEventsTable(CustomTraceDefinition definition, Composite parent, int cacheSize) {
super(parent, cacheSize, new ColumnData[0]);
fDefinition = definition;
createColumnHeaders();
}
+ /**
+ * Create the table's headers.
+ */
protected void createColumnHeaders() {
- if (fDefinition == null) {
+ if (fDefinition == null) {
return;
}
- List<ColumnData> columnData = new LinkedList<ColumnData>();
- for (OutputColumn outputColumn : fDefinition.outputs) {
- ColumnData column = new ColumnData(outputColumn.name, 0, SWT.LEFT);
- columnData.add(column);
- }
- setColumnHeaders(columnData.toArray(new ColumnData[0]));
+ List<ColumnData> columnData = new LinkedList<ColumnData>();
+ for (OutputColumn outputColumn : fDefinition.outputs) {
+ ColumnData column = new ColumnData(outputColumn.name, 0, SWT.LEFT);
+ columnData.add(column);
+ }
+ setColumnHeaders(columnData.toArray(new ColumnData[0]));
}
@Override
import org.eclipse.linuxtools.internal.tmf.ui.Messages;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-
+/**
+ * Base class for custom trace definitions.
+ *
+ * @author Patrick Tassé
+ */
public abstract class CustomTraceDefinition {
+ /** "set" action */
public static final int ACTION_SET = 0;
+
+ /** "append" action */
public static final int ACTION_APPEND = 1;
+
+ /** "append with separator" action */
public static final int ACTION_APPEND_WITH_SEPARATOR = 2;
+ /** Timestamp tag */
public static final String TAG_TIMESTAMP = Messages.CustomTraceDefinition_timestampTag;
+
+ /** Message tag */
public static final String TAG_MESSAGE = Messages.CustomTraceDefinition_messageTag;
+
+ /** "Other" tag */
public static final String TAG_OTHER = Messages.CustomTraceDefinition_otherTag;
+ /** Name of this trace definition */
public String definitionName;
+
+ /** List of output columns */
public List<OutputColumn> outputs;
+
+ /** Timestamp format */
public String timeStampOutputFormat;
+ /**
+ * Definition of an output column
+ */
public static class OutputColumn {
+
+ /** Name of this column */
public String name;
+ /**
+ * Default constructor (empty)
+ */
public OutputColumn() {}
+ /**
+ * Constructor
+ *
+ * @param name Name of this output column
+ */
public OutputColumn(String name) {
this.name = name;
}
}
}
+ /**
+ * Format a timestamp in this trace's current time stamp format.
+ *
+ * @param timestamp
+ * The timestamp to format
+ * @return The same timestamp as a formatted string
+ */
public String formatTimeStamp(TmfTimestamp timestamp) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeStampOutputFormat);
return simpleDateFormat.format(timestamp.getValue());
}
+ /**
+ * Save this custom trace in the default path.
+ */
public abstract void save();
+
+ /**
+ * Save this custom trace in the supplied path.
+ *
+ * @param path
+ * The path to save to
+ */
public abstract void save(String path);
}
import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+/**
+ * Trace event for custom text parsers.
+ *
+ * @author Patrick Tassé
+ */
public class CustomTxtEvent extends CustomEvent {
+ /**
+ * Constructor
+ *
+ * @param definition
+ * Trace definition
+ */
public CustomTxtEvent(CustomTxtTraceDefinition definition) {
super(definition);
setType(new CustomTxtEventType(definition));
}
+ /**
+ * Construct a custom text event from an existing TmfEvent.
+ *
+ * @param definition
+ * Trace definition
+ * @param other
+ * The TmfEvent object to copy
+ */
public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfEvent other) {
super(definition, other);
}
- public CustomTxtEvent(CustomTxtTraceDefinition definition, ITmfTrace parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {
+ /**
+ * Full constructor.
+ *
+ * @param definition
+ * Trace definition
+ * @param parentTrace
+ * Parent trace object
+ * @param timestamp
+ * Timestamp of this event
+ * @param source
+ * Source of this event
+ * @param type
+ * Event type
+ * @param reference
+ * Reference if this event
+ */
+ public CustomTxtEvent(CustomTxtTraceDefinition definition,
+ ITmfTrace parentTrace, ITmfTimestamp timestamp, String source,
+ TmfEventType type, String reference) {
super(definition, parentTrace, timestamp, source, type, reference);
}
super.setContent(content);
}
+ /**
+ * Process an entry in the trace file
+ *
+ * @param input
+ * The input line to read
+ * @param matcher
+ * The regex matcher to use
+ */
public void processGroups(InputLine input, Matcher matcher) {
if (input.columns == null) {
return;
/*******************************************************************************
* Copyright (c) 2010 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 Tasse - Initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+/**
+ * Event type for custom text traces.
+ *
+ * @author Patrick Tassé
+ */
public class CustomTxtEventType extends CustomEventType {
- public CustomTxtEventType(CustomTxtTraceDefinition definition) {
- super(definition);
- }
+ /**
+ * Constructor
+ *
+ * @param definition
+ * Custom text trace definition
+ */
+ public CustomTxtEventType(CustomTxtTraceDefinition definition) {
+ super(definition);
+ }
}
import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+/**
+ * Base class for custom plain text traces.
+ *
+ * @author Patrick Tassé
+ */
public class CustomTxtTrace extends TmfTrace implements ITmfEventParser {
private static final TmfLongLocation NULL_LOCATION = new TmfLongLocation((Long) null);
private final CustomTxtEventType fEventType;
private BufferedRandomAccessFile fFile;
+ /**
+ * Basic constructor.
+ *
+ * @param definition
+ * Text trace definition
+ */
public CustomTxtTrace(final CustomTxtTraceDefinition definition) {
fDefinition = definition;
fEventType = new CustomTxtEventType(fDefinition);
setCacheSize(DEFAULT_CACHE_SIZE);
}
- public CustomTxtTrace(final IResource resource, final CustomTxtTraceDefinition definition, final String path, final int cacheSize) throws TmfTraceException {
+ /**
+ * Full constructor.
+ *
+ * @param resource
+ * Trace's resource.
+ * @param definition
+ * Text trace definition
+ * @param path
+ * Path to the trace file
+ * @param cacheSize
+ * Cache size to use
+ * @throws TmfTraceException
+ * If we couldn't open the trace at 'path'
+ */
+ public CustomTxtTrace(final IResource resource,
+ final CustomTxtTraceDefinition definition, final String path,
+ final int cacheSize) throws TmfTraceException {
this(definition);
setCacheSize((cacheSize > 0) ? cacheSize : DEFAULT_CACHE_SIZE);
initTrace(resource, path, CustomTxtEvent.class);
return event;
}
+ /**
+ * @return The first few lines of the text file
+ */
public List<InputLine> getFirstLines() {
return fDefinition.inputs;
}
+ /**
+ * Parse the first line of the trace (to recognize the type).
+ *
+ * @param context
+ * Trace context
+ * @return The first event
+ */
public CustomTxtEvent parseFirstLine(final CustomTxtTraceContext context) {
final CustomTxtEvent event = new CustomTxtEvent(fDefinition, this, TmfTimestamp.ZERO, "", fEventType, ""); //$NON-NLS-1$ //$NON-NLS-2$
event.processGroups(context.inputLine, context.firstLineMatcher);
return event;
}
+ /**
+ * Get the trace definition.
+ *
+ * @return The trace definition
+ */
public CustomTraceDefinition getDefinition() {
return fDefinition;
}
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+/**
+ * Trace context for custom text traces.
+ *
+ * @author Patrick Tassé
+ */
public class CustomTxtTraceContext extends TmfContext {
+
+ /** Regex matcher for the first line of the trace */
public Matcher firstLineMatcher;
+
+ /** First line of the text file */
public String firstLine;
+
+ /** Position in the file where the 'current' next line is */
public long nextLineLocation;
+
+ /** InputLine object for the currently read line */
public InputLine inputLine;
+ /**
+ * Constructor.
+ *
+ * @param location
+ * Location in the trace
+ * @param rank
+ * Rank of the event at this location
+ */
public CustomTxtTraceContext(ITmfLocation location, long rank) {
super(location, rank);
}
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
+/**
+ * Trace definition for custom text traces.
+ *
+ * @author Patrick Tassé
+ */
public class CustomTxtTraceDefinition extends CustomTraceDefinition {
+ /** Input lines */
+ public List<InputLine> inputs;
+
+ /** File name of the definition file */
protected static final String CUSTOM_TXT_TRACE_DEFINITIONS_FILE_NAME = "custom_txt_parsers.xml"; //$NON-NLS-1$
+
+ /** Path of the definition file */
protected static final String CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME =
Activator.getDefault().getStateLocation().addTrailingSeparator().append(CUSTOM_TXT_TRACE_DEFINITIONS_FILE_NAME).toString();
private static final String FORMAT_ATTRIBUTE = Messages.CustomTxtTraceDefinition_format;
private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomTxtTraceDefinition_outputColumn;
- public List<InputLine> inputs;
-
+ /**
+ * Default constructor.
+ */
public CustomTxtTraceDefinition() {
this("", new ArrayList<InputLine>(0), new ArrayList<OutputColumn>(0), ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public CustomTxtTraceDefinition(String logtype, List<InputLine> inputs, List<OutputColumn> outputs, String timeStampOutputFormat) {
+ /**
+ * Full constructor.
+ *
+ * @param logtype
+ * Name of the trace type
+ * @param inputs
+ * List of inputs
+ * @param outputs
+ * List of output columns
+ * @param timeStampOutputFormat
+ * The timestamp format to use
+ */
+ public CustomTxtTraceDefinition(String logtype, List<InputLine> inputs,
+ List<OutputColumn> outputs, String timeStampOutputFormat) {
this.definitionName = logtype;
this.inputs = inputs;
this.outputs = outputs;
this.timeStampOutputFormat = timeStampOutputFormat;
}
+ /**
+ * Wrapper to store a line of the log file
+ */
public static class InputLine {
+
+ /** Data columns of this line */
public List<InputData> columns;
+
+ /** Cardinality of this line (see {@link Cardinality}) */
public Cardinality cardinality;
- private String regex;
- private Pattern pattern;
+
+ /** Parent line */
public InputLine parentInput;
+
+ /** Level of this line */
public int level;
+
+ /** Next input line in the file */
public InputLine nextInput;
+
+ /** Children of this line (if one "event" spans many lines) */
public List<InputLine> childrenInputs;
+ private String regex;
+ private Pattern pattern;
+
+ /**
+ * Default (empty) constructor.
+ */
public InputLine() {}
+ /**
+ * Constructor.
+ *
+ * @param cardinality Cardinality of this line.
+ * @param regex Regex
+ * @param columns Columns to use
+ */
public InputLine(Cardinality cardinality, String regex, List<InputData> columns) {
this.cardinality = cardinality;
this.regex = regex;
this.columns = columns;
}
+ /**
+ * Set the regex of this input line
+ *
+ * @param regex
+ * Regex to set
+ */
public void setRegex(String regex) {
this.regex = regex;
this.pattern = null;
}
+ /**
+ * Get the current regex
+ *
+ * @return The current regex
+ */
public String getRegex() {
return regex;
}
+ /**
+ * Get the Pattern object of this line's regex
+ *
+ * @return The Pattern
+ * @throws PatternSyntaxException
+ * If the regex does not parse correctly
+ */
public Pattern getPattern() throws PatternSyntaxException {
if (pattern == null) {
pattern = Pattern.compile(regex);
return pattern;
}
+ /**
+ * Add a child line to this line.
+ *
+ * @param input
+ * The child input line
+ */
public void addChild(InputLine input) {
if (childrenInputs == null) {
childrenInputs = new ArrayList<InputLine>(1);
input.level = this.level + 1;
}
+ /**
+ * Set the next input line.
+ *
+ * @param input
+ * The next input line
+ */
public void addNext(InputLine input) {
if (parentInput != null) {
int index = parentInput.childrenInputs.indexOf(this);
input.level = this.level;
}
+ /**
+ * Move this line up in its parent's children.
+ */
public void moveUp() {
if (parentInput != null) {
int index = parentInput.childrenInputs.indexOf(this);
}
}
+ /**
+ * Move this line down in its parent's children.
+ */
public void moveDown() {
if (parentInput != null) {
int index = parentInput.childrenInputs.indexOf(this);
}
}
+ /**
+ * Add a data column to this line
+ *
+ * @param column
+ * The column to add
+ */
public void addColumn(InputData column) {
if (columns == null) {
columns = new ArrayList<InputData>(1);
columns.add(column);
}
+ /**
+ * Get the next input lines.
+ *
+ * @param countMap
+ * The map of line "sets".
+ * @return The next list of lines.
+ */
public List<InputLine> getNextInputs(Map<InputLine, Integer> countMap) {
List<InputLine> nextInputs = new ArrayList<InputLine>();
InputLine next = nextInput;
return nextInputs;
}
+ /**
+ * Get the minimum possible amount of entries.
+ *
+ * @return The minimum
+ */
public int getMinCount() {
return cardinality.min;
}
+ /**
+ * Get the maximum possible amount of entries.
+ *
+ * @return The maximum
+ */
public int getMaxCount() {
return cardinality.max;
}
public String toString() {
return regex + " " + cardinality; //$NON-NLS-1$
}
-
}
+ /**
+ * Data column for input lines.
+ */
public static class InputData {
+
+ /** Name of this column */
public String name;
+
+ /** Action id */
public int action;
+
+ /** Format */
public String format;
+ /**
+ * Default (empty) constructor
+ */
public InputData() {}
+ /**
+ * Full constructor
+ *
+ * @param name Name
+ * @param action Action
+ * @param format Format
+ */
public InputData(String name, int action, String format) {
this.name = name;
this.action = action;
this.format = format;
}
+ /**
+ * Constructor with default format
+ *
+ * @param name Name
+ * @param action Action
+ */
public InputData(String name, int action) {
this.name = name;
this.action = action;
}
}
+ /**
+ * Input line cardinality
+ */
public static class Cardinality {
+
+ /** Representation of infinity */
public final static int INF = Integer.MAX_VALUE;
+
+ /** Preset for [1, 1] */
public final static Cardinality ONE = new Cardinality(1, 1);
+
+ /** Preset for [1, inf] */
public final static Cardinality ONE_OR_MORE = new Cardinality(1, INF);
+
+ /** Preset for [0, 1] */
public final static Cardinality ZERO_OR_ONE = new Cardinality(0, 1);
+
+ /** Preset for [0, inf] */
public final static Cardinality ZERO_OR_MORE = new Cardinality(0, INF);
private final int min;
private final int max;
+ /**
+ * Constructor.
+ *
+ * @param min
+ * Minimum
+ * @param max
+ * Maximum
+ */
public Cardinality(int min, int max) {
this.min = min;
this.max = max;
return "(" + (min >= 0 ? min : "?") + "," + (max == INF ? "\u221E" : (max >= 0 ? max : "?")) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
}
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
final int prime = 31;
return result;
}
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
if (this == obj) {
}
@Override
- public void save(String path) {
+ public void save(String path) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// The following allows xml parsing without access to the dtd
- EntityResolver resolver = new EntityResolver () {
- @Override
- public InputSource resolveEntity (String publicId, String systemId) {
+ EntityResolver resolver = new EntityResolver() {
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) {
String empty = ""; //$NON-NLS-1$
ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
return new InputSource(bais);
db.setEntityResolver(resolver);
// The following catches xml parsing exceptions
- db.setErrorHandler(new ErrorHandler(){
- @Override
+ db.setErrorHandler(new ErrorHandler() {
+ @Override
public void error(SAXParseException saxparseexception) throws SAXException {}
- @Override
+
+ @Override
public void warning(SAXParseException saxparseexception) throws SAXException {}
- @Override
+
+ @Override
public void fatalError(SAXParseException saxparseexception) throws SAXException {
throw saxparseexception;
- }});
+ }
+ });
Document doc = null;
File file = new File(path);
return inputLineElement;
}
+ /**
+ * Load the default text trace definitions file.
+ *
+ * @return The loaded trace definitions
+ */
public static CustomTxtTraceDefinition[] loadAll() {
return loadAll(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);
}
+ /**
+ * Load a specific text trace definition file.
+ *
+ * @param path
+ * The path to the file to load
+ * @return The loaded trace definitions
+ */
public static CustomTxtTraceDefinition[] loadAll(String path) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// The following allows xml parsing without access to the dtd
- EntityResolver resolver = new EntityResolver () {
- @Override
- public InputSource resolveEntity (String publicId, String systemId) {
+ EntityResolver resolver = new EntityResolver() {
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) {
String empty = ""; //$NON-NLS-1$
ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
return new InputSource(bais);
db.setEntityResolver(resolver);
// The following catches xml parsing exceptions
- db.setErrorHandler(new ErrorHandler(){
- @Override
+ db.setErrorHandler(new ErrorHandler() {
+ @Override
public void error(SAXParseException saxparseexception) throws SAXException {}
- @Override
+
+ @Override
public void warning(SAXParseException saxparseexception) throws SAXException {}
- @Override
+
+ @Override
public void fatalError(SAXParseException saxparseexception) throws SAXException {
throw saxparseexception;
- }});
+ }
+ });
File file = new File(path);
if (!file.canRead()) {
return new CustomTxtTraceDefinition[0];
}
+ /**
+ * Load a single definition.
+ *
+ * @param definitionName
+ * Name of the definition to load
+ * @return The loaded trace definition
+ */
public static CustomTxtTraceDefinition load(String definitionName) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// The following allows xml parsing without access to the dtd
- EntityResolver resolver = new EntityResolver () {
- @Override
- public InputSource resolveEntity (String publicId, String systemId) {
+ EntityResolver resolver = new EntityResolver() {
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) {
String empty = ""; //$NON-NLS-1$
ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
return new InputSource(bais);
db.setEntityResolver(resolver);
// The following catches xml parsing exceptions
- db.setErrorHandler(new ErrorHandler(){
- @Override
+ db.setErrorHandler(new ErrorHandler() {
+ @Override
public void error(SAXParseException saxparseexception) throws SAXException {}
- @Override
+
+ @Override
public void warning(SAXParseException saxparseexception) throws SAXException {}
- @Override
+
+ @Override
public void fatalError(SAXParseException saxparseexception) throws SAXException {
throw saxparseexception;
- }});
+ }
+ });
File file = new File(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);
Document doc = db.parse(file);
return null;
}
+ /**
+ * Get the definition from a definition element.
+ *
+ * @param definitionElement
+ * The Element to extract from
+ * @return The loaded trace definition
+ */
public static CustomTxtTraceDefinition extractDefinition(Element definitionElement) {
CustomTxtTraceDefinition def = new CustomTxtTraceDefinition();
return inputLine;
}
+ /**
+ * Delete a definition from the currently loaded ones.
+ *
+ * @param definitionName
+ * The name of the definition to delete
+ */
public static void delete(String definitionName) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// The following allows xml parsing without access to the dtd
- EntityResolver resolver = new EntityResolver () {
- @Override
- public InputSource resolveEntity (String publicId, String systemId) {
+ EntityResolver resolver = new EntityResolver() {
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) {
String empty = ""; //$NON-NLS-1$
ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
return new InputSource(bais);
db.setEntityResolver(resolver);
// The following catches xml parsing exceptions
- db.setErrorHandler(new ErrorHandler(){
- @Override
+ db.setErrorHandler(new ErrorHandler() {
+ @Override
public void error(SAXParseException saxparseexception) throws SAXException {}
- @Override
+
+ @Override
public void warning(SAXParseException saxparseexception) throws SAXException {}
- @Override
+
+ @Override
public void fatalError(SAXParseException saxparseexception) throws SAXException {
throw saxparseexception;
- }});
+ }
+ });
File file = new File(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);
Document doc = db.parse(file);
import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+/**
+ * Trace event for custom XML traces.
+ *
+ * @author Patrick Tassé
+ */
public class CustomXmlEvent extends CustomEvent {
+ /**
+ * Constructor defining only the trace definition
+ *
+ * @param definition
+ * Trace definition
+ */
public CustomXmlEvent(CustomXmlTraceDefinition definition) {
super(definition);
setType(new CustomXmlEventType(definition));
}
+ /**
+ * Build a custom trace event from an existing TmfEvent.
+ *
+ * @param definition
+ * Trace definition
+ * @param other
+ * Other TmfEvent to copy
+ */
public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfEvent other) {
super(definition, other);
}
+ /**
+ * Full constructor
+ *
+ * @param definition
+ * Trace definition
+ * @param parentTrace
+ * Parent trace object
+ * @param timestamp
+ * Timestamp of the event
+ * @param source
+ * Source of the event
+ * @param type
+ * Event type
+ * @param reference
+ * Reference of the event
+ */
public CustomXmlEvent(CustomXmlTraceDefinition definition, ITmfTrace parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {
super(definition, parentTrace, timestamp, source, type, reference);
}
super.setContent(content);
}
+ /**
+ * Parse an entry.
+ *
+ * @param value Value
+ * @param name Name
+ * @param inputAction Input action
+ * @param inputFormat Input format
+ */
public void parseInput(String value, String name, int inputAction, String inputFormat) {
if (value.length() == 0) {
return;
/*******************************************************************************
* Copyright (c) 2010 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 Tasse - Initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+/**
+ * Event type class for custom XML traces.
+ *
+ * @author Patrick Tassé
+ */
public class CustomXmlEventType extends CustomEventType {
+ /**
+ * Constructor
+ *
+ * @param definition
+ * Trace definition
+ */
public CustomXmlEventType(CustomXmlTraceDefinition definition) {
super(definition);
}
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
+/**
+ * Trace object for custom XML trace parsers.
+ *
+ * @author Patrick Tassé
+ */
public class CustomXmlTrace extends TmfTrace implements ITmfEventParser {
private static final TmfLongLocation NULL_LOCATION = new TmfLongLocation((Long) null);
private final InputElement fRecordInputElement;
private BufferedRandomAccessFile fFile;
+ /**
+ * Basic constructor
+ *
+ * @param definition Trace definition
+ */
public CustomXmlTrace(final CustomXmlTraceDefinition definition) {
fDefinition = definition;
fEventType = new CustomXmlEventType(fDefinition);
setCacheSize(DEFAULT_CACHE_SIZE);
}
- public CustomXmlTrace(final IResource resource, final CustomXmlTraceDefinition definition, final String path, final int pageSize) throws TmfTraceException {
+ /**
+ * Full constructor
+ *
+ * @param resource
+ * Trace resource
+ * @param definition
+ * Trace definition
+ * @param path
+ * Path to the trace/log file
+ * @param pageSize
+ * Page size to use
+ * @throws TmfTraceException
+ * If the trace/log couldn't be opened
+ */
+ public CustomXmlTrace(final IResource resource,
+ final CustomXmlTraceDefinition definition, final String path,
+ final int pageSize) throws TmfTraceException {
this(definition);
setCacheSize((pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE);
initTrace(resource, path, CustomXmlEvent.class);
}
}
+ /**
+ * Parse an XML element.
+ *
+ * @param parentElement
+ * The parent element
+ * @param buffer
+ * The contents to parse
+ * @return The parsed content
+ */
public static StringBuffer parseElement(final Element parentElement, final StringBuffer buffer) {
final NodeList nodeList = parentElement.getChildNodes();
String separator = null;
return buffer;
}
+ /**
+ * Get an input element if it is a valid record input. If not, we will look
+ * into its children for valid inputs.
+ *
+ * @param inputElement
+ * The main element to check for.
+ * @return The record element
+ */
public InputElement getRecordInputElement(final InputElement inputElement) {
if (inputElement.logEntry) {
return inputElement;
return null;
}
+ /**
+ * Extract a trace event from an XML element.
+ *
+ * @param element
+ * The element
+ * @param inputElement
+ * The input element
+ * @return The extracted event
+ */
public CustomXmlEvent extractEvent(final Element element, final InputElement inputElement) {
final CustomXmlEvent event = new CustomXmlEvent(fDefinition, this, TmfTimestamp.ZERO, "", fEventType,""); //$NON-NLS-1$ //$NON-NLS-2$
event.setContent(new CustomEventContent(event, new StringBuffer()));
return;
}
+ /**
+ * Retrieve the trace definition.
+ *
+ * @return The trace definition
+ */
public CustomTraceDefinition getDefinition() {
return fDefinition;
}
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+/**
+ * Trace context for custom XML traces.
+ *
+ * @author Patrick Tassé
+ */
public class CustomXmlTraceContext extends TmfContext {
+ /**
+ * Constructor
+ *
+ * @param location
+ * The location (in the file) of this context
+ * @param rank
+ * The rank of the event pointed by this context
+ */
public CustomXmlTraceContext(ITmfLocation location, long rank) {
super(location, rank);
}
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
+/**
+ * Trace definition for custom XML traces.
+ *
+ * @author Patrick Tassé
+ */
public class CustomXmlTraceDefinition extends CustomTraceDefinition {
+ /** "ignore" tag */
+ public static final String TAG_IGNORE = Messages.CustomXmlTraceDefinition_ignoreTag;
+
+ /** Name of the XML definitions file */
protected static final String CUSTOM_XML_TRACE_DEFINITIONS_FILE_NAME = "custom_xml_parsers.xml"; //$NON-NLS-1$
+
+ /** Path to the XML definitions file */
protected static final String CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME =
Activator.getDefault().getStateLocation().addTrailingSeparator().append(CUSTOM_XML_TRACE_DEFINITIONS_FILE_NAME).toString();
- public static final String TAG_IGNORE = Messages.CustomXmlTraceDefinition_ignoreTag;
-
private static final String CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT = Messages.CustomXmlTraceDefinition_definitionRootElement;
private static final String DEFINITION_ELEMENT = Messages.CustomXmlTraceDefinition_definition;
private static final String NAME_ATTRIBUTE = Messages.CustomXmlTraceDefinition_name;
private static final String FORMAT_ATTRIBUTE = Messages.CustomXmlTraceDefinition_format;
private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomXmlTraceDefinition_outputColumn;
+ /** Top-level input element */
public InputElement rootInputElement;
+ /**
+ * Default constructor
+ */
public CustomXmlTraceDefinition() {
this("", null, new ArrayList<OutputColumn>(), ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public CustomXmlTraceDefinition(String logtype, InputElement rootElement, List<OutputColumn> outputs, String timeStampOutputFormat) {
+ /**
+ * Full constructor
+ *
+ * @param logtype
+ * Type of trace type
+ * @param rootElement
+ * The top-level XML element
+ * @param outputs
+ * The list of output columns
+ * @param timeStampOutputFormat
+ * The timestamp format to use
+ */
+ public CustomXmlTraceDefinition(String logtype, InputElement rootElement,
+ List<OutputColumn> outputs, String timeStampOutputFormat) {
this.definitionName = logtype;
this.rootInputElement = rootElement;
this.outputs = outputs;
this.timeStampOutputFormat = timeStampOutputFormat;
}
+ /**
+ * Wrapper for input XML elements
+ */
public static class InputElement {
+
+ /** Name of the element */
public String elementName;
+
+ /** Indicates if this is a log entry */
public boolean logEntry;
+
+ /** Name of the input element */
public String inputName;
+
+ /** Input action */
public int inputAction;
+
+ /** Input format */
public String inputFormat;
+
+ /** XML attributes of this element */
public List<InputAttribute> attributes;
+
+ /** Parent element */
public InputElement parentElement;
+
+ /** Following element in the file */
public InputElement nextElement;
+
+ /** Child elements */
public List<InputElement> childElements;
+ /**
+ * Default (empty) constructor
+ */
public InputElement() {}
- public InputElement(String elementName, boolean logEntry, String inputName, int inputAction, String inputFormat, List<InputAttribute> attributes) {
+ /**
+ * Constructor
+ *
+ * @param elementName
+ * Element name
+ * @param logEntry
+ * If this element is a log entry
+ * @param inputName
+ * Name of the the input
+ * @param inputAction
+ * Input action
+ * @param inputFormat
+ * Input format
+ * @param attributes
+ * XML attributes of this element
+ */
+ public InputElement(String elementName, boolean logEntry,
+ String inputName, int inputAction, String inputFormat,
+ List<InputAttribute> attributes) {
this.elementName = elementName;
this.logEntry = logEntry;
this.inputName = inputName;
this.attributes = attributes;
}
+ /**
+ * Add a XML attribute to the element
+ *
+ * @param attribute
+ * The attribute to add
+ */
public void addAttribute(InputAttribute attribute) {
if (attributes == null) {
attributes = new ArrayList<InputAttribute>(1);
attributes.add(attribute);
}
+ /**
+ * Add a child element to this one.
+ *
+ * @param input
+ * The input element to add as child
+ */
public void addChild(InputElement input) {
if (childElements == null) {
childElements = new ArrayList<InputElement>(1);
input.parentElement = this;
}
+ /**
+ * Set the following input element.
+ *
+ * @param input
+ * The input element to add as next element
+ */
public void addNext(InputElement input) {
if (parentElement != null) {
int index = parentElement.childElements.indexOf(this);
input.parentElement = this.parentElement;
}
+ /**
+ * Move this element up in its parent's list of children.
+ */
public void moveUp() {
if (parentElement != null) {
int index = parentElement.childElements.indexOf(this);
}
}
+ /**
+ * Move this element down in its parent's list of children.
+ */
public void moveDown() {
if (parentElement != null) {
int index = parentElement.childElements.indexOf(this);
}
+ /**
+ * Wrapper for XML element attributes
+ */
public static class InputAttribute {
+
+ /** Name of the XML attribute */
public String attributeName;
+
+ /** Input name */
public String inputName;
+
+ /** Input action */
public int inputAction;
+
+ /** Input format */
public String inputFormat;
+ /**
+ * Default (empty) constructor
+ */
public InputAttribute() {}
- public InputAttribute(String attributeName, String inputName, int inputAction, String inputFormat) {
+ /**
+ * Constructor
+ *
+ * @param attributeName
+ * Name of the XML attribute
+ * @param inputName
+ * Input name
+ * @param inputAction
+ * Input action
+ * @param inputFormat
+ * Input format
+ */
+ public InputAttribute(String attributeName, String inputName,
+ int inputAction, String inputFormat) {
this.attributeName = attributeName;
this.inputName = inputName;
this.inputAction = inputAction;
}
}
- @Override
+ @Override
public void save() {
save(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
}
DocumentBuilder db = dbf.newDocumentBuilder();
// The following allows xml parsing without access to the dtd
- EntityResolver resolver = new EntityResolver () {
+ EntityResolver resolver = new EntityResolver() {
@Override
- public InputSource resolveEntity (String publicId, String systemId) {
+ public InputSource resolveEntity(String publicId, String systemId) {
String empty = ""; //$NON-NLS-1$
ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
return new InputSource(bais);
db.setEntityResolver(resolver);
// The following catches xml parsing exceptions
- db.setErrorHandler(new ErrorHandler(){
+ db.setErrorHandler(new ErrorHandler() {
@Override
- public void error(SAXParseException saxparseexception) throws SAXException {}
+ public void error(SAXParseException saxparseexception) throws SAXException {}
+
@Override
- public void warning(SAXParseException saxparseexception) throws SAXException {}
+ public void warning(SAXParseException saxparseexception) throws SAXException {}
+
@Override
- public void fatalError(SAXParseException saxparseexception) throws SAXException {
+ public void fatalError(SAXParseException saxparseexception) throws SAXException {
throw saxparseexception;
- }});
+ }
+ });
Document doc = null;
File file = new File(path);
return inputElementElement;
}
+ /**
+ * Load all the XML trace definitions in the default definitions file.
+ *
+ * @return The loaded trace definitions
+ */
public static CustomXmlTraceDefinition[] loadAll() {
return loadAll(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
}
+ /**
+ * Load all the XML trace definitions in the given definitions file.
+ *
+ * @param path
+ * Path to the definitions file to load
+ * @return The loaded trace definitions
+ */
public static CustomXmlTraceDefinition[] loadAll(String path) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// The following allows xml parsing without access to the dtd
- EntityResolver resolver = new EntityResolver () {
+ EntityResolver resolver = new EntityResolver() {
@Override
- public InputSource resolveEntity (String publicId, String systemId) {
+ public InputSource resolveEntity(String publicId, String systemId) {
String empty = ""; //$NON-NLS-1$
ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
return new InputSource(bais);
db.setEntityResolver(resolver);
// The following catches xml parsing exceptions
- db.setErrorHandler(new ErrorHandler(){
+ db.setErrorHandler(new ErrorHandler() {
@Override
- public void error(SAXParseException saxparseexception) throws SAXException {}
+ public void error(SAXParseException saxparseexception) throws SAXException {}
+
@Override
- public void warning(SAXParseException saxparseexception) throws SAXException {}
+ public void warning(SAXParseException saxparseexception) throws SAXException {}
+
@Override
- public void fatalError(SAXParseException saxparseexception) throws SAXException {
+ public void fatalError(SAXParseException saxparseexception) throws SAXException {
throw saxparseexception;
- }});
+ }
+ });
File file = new File(path);
if (!file.canRead()) {
return new CustomXmlTraceDefinition[0];
}
+ /**
+ * Load the given trace definition.
+ *
+ * @param definitionName
+ * Name of the XML trace definition to load
+ * @return The loaded trace definition
+ */
public static CustomXmlTraceDefinition load(String definitionName) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// The following allows xml parsing without access to the dtd
- EntityResolver resolver = new EntityResolver () {
+ EntityResolver resolver = new EntityResolver() {
@Override
- public InputSource resolveEntity (String publicId, String systemId) {
+ public InputSource resolveEntity(String publicId, String systemId) {
String empty = ""; //$NON-NLS-1$
ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
return new InputSource(bais);
db.setEntityResolver(resolver);
// The following catches xml parsing exceptions
- db.setErrorHandler(new ErrorHandler(){
+ db.setErrorHandler(new ErrorHandler() {
@Override
- public void error(SAXParseException saxparseexception) throws SAXException {}
+ public void error(SAXParseException saxparseexception) throws SAXException {}
+
@Override
- public void warning(SAXParseException saxparseexception) throws SAXException {}
+ public void warning(SAXParseException saxparseexception) throws SAXException {}
+
@Override
- public void fatalError(SAXParseException saxparseexception) throws SAXException {
+ public void fatalError(SAXParseException saxparseexception) throws SAXException {
throw saxparseexception;
- }});
+ }
+ });
File file = new File(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
Document doc = db.parse(file);
return null;
}
+ /**
+ * Extract a trace definition from an XML element.
+ *
+ * @param definitionElement
+ * Definition element
+ * @return The extracted trace definition
+ */
public static CustomXmlTraceDefinition extractDefinition(Element definitionElement) {
CustomXmlTraceDefinition def = new CustomXmlTraceDefinition();
return inputElement;
}
+ /**
+ * Delete the given trace definition from the list of currently loaded ones.
+ *
+ * @param definitionName
+ * Name of the trace definition to delete
+ */
public static void delete(String definitionName) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// The following allows xml parsing without access to the dtd
- EntityResolver resolver = new EntityResolver () {
+ EntityResolver resolver = new EntityResolver() {
@Override
- public InputSource resolveEntity (String publicId, String systemId) {
+ public InputSource resolveEntity(String publicId, String systemId) {
String empty = ""; //$NON-NLS-1$
ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
return new InputSource(bais);
db.setEntityResolver(resolver);
// The following catches xml parsing exceptions
- db.setErrorHandler(new ErrorHandler(){
+ db.setErrorHandler(new ErrorHandler() {
@Override
- public void error(SAXParseException saxparseexception) throws SAXException {}
+ public void error(SAXParseException saxparseexception) throws SAXException {}
+
@Override
- public void warning(SAXParseException saxparseexception) throws SAXException {}
+ public void warning(SAXParseException saxparseexception) throws SAXException {}
+
@Override
- public void fatalError(SAXParseException saxparseexception) throws SAXException {
+ public void fatalError(SAXParseException saxparseexception) throws SAXException {
throw saxparseexception;
- }});
+ }
+ });
File file = new File(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
Document doc = db.parse(file);
+/*******************************************************************************
+ * 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.BufferedReader;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+/**
+ * Input wizard page for custom text parsers.
+ *
+ * @author Patrick Tassé
+ */
public class CustomTxtParserInputWizardPage extends WizardPage {
private static final String DEFAULT_REGEX = "\\s*(.*\\S)"; //$NON-NLS-1$
private String timeStampFormat;
private boolean timestampFound;
- protected CustomTxtParserInputWizardPage(ISelection selection, CustomTxtTraceDefinition definition) {
+ /**
+ * Constructor
+ *
+ * @param selection
+ * The Selection object
+ * @param definition
+ * The trace definition
+ */
+ protected CustomTxtParserInputWizardPage(ISelection selection,
+ CustomTxtTraceDefinition definition) {
super("CustomParserWizardPage"); //$NON-NLS-1$
if (definition == null) {
setTitle(Messages.CustomTxtParserInputWizardPage_windowTitleNew);
dateFormatHelpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_dateFormatHelp);
dateFormatHelpButton.addSelectionListener(new SelectionAdapter() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
openHelpShell(SIMPLE_DATE_FORMAT_URL);
}
});
removeButton.setImage(deleteImage);
removeButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_removeLine);
removeButton.addSelectionListener(new SelectionAdapter() {
- @Override
+ @Override
public void widgetSelected(SelectionEvent e) {
if (treeViewer.getSelection().isEmpty() || selectedLine == null) {
return;
addChildButton.setImage(addChildImage);
addChildButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_addChildLine);
addChildButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
InputLine inputLine = new InputLine(Cardinality.ZERO_OR_MORE, "", null); //$NON-NLS-1$
if (((List<?>) treeViewer.getInput()).size() == 0) {
definition.inputs.add(inputLine);
moveUpButton.setImage(moveUpImage);
moveUpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_moveUp);
moveUpButton.addSelectionListener(new SelectionAdapter() {
- @Override
+ @Override
public void widgetSelected(SelectionEvent e) {
if (treeViewer.getSelection().isEmpty()) {
return;
moveDownButton.setImage(moveDownImage);
moveDownButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_moveDown);
moveDownButton.addSelectionListener(new SelectionAdapter() {
- @Override
+ @Override
public void widgetSelected(SelectionEvent e) {
if (treeViewer.getSelection().isEmpty()) {
return;
highlightAllButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
highlightAllButton.setText(Messages.CustomTxtParserInputWizardPage_highlightAll);
highlightAllButton.addSelectionListener(new SelectionAdapter() {
- @Override
+ @Override
public void widgetSelected(SelectionEvent e) {
updatePreviews(true);
}
legendButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_previewLegend);
legendButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
legendButton.addSelectionListener(new SelectionAdapter() {
- @Override
+ @Override
public void widgetSelected(SelectionEvent e) {
openLegend();
}
private static class InputLineTreeNodeContentProvider implements ITreeContentProvider {
- @Override
+ @Override
public Object[] getElements(Object inputElement) {
return ((List<?>) inputElement).toArray();
}
- @Override
+ @Override
public Object[] getChildren(Object parentElement) {
InputLine inputLine = (InputLine) parentElement;
if (inputLine.childrenInputs == null) {
return inputLine.childrenInputs.toArray();
}
- @Override
+ @Override
public boolean hasChildren(Object element) {
InputLine inputLine = (InputLine) element;
return (inputLine.childrenInputs != null && inputLine.childrenInputs.size() > 0);
}
- @Override
+ @Override
public void dispose() {
}
- @Override
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
- @Override
+ @Override
public Object getParent(Object element) {
InputLine inputLine = (InputLine) element;
return inputLine.parentInput;
}
private class InputLineTreeSelectionChangedListener implements ISelectionChangedListener {
- @Override
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
if (selectedLine != null) {
selectedLine.dispose();
InputLine inputLine = (InputLine) selection.getFirstElement();
selectedLine = new Line(lineContainer, getName(inputLine), inputLine);
lineContainer.layout();
- lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);
+ lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
container.layout();
validate();
updatePreviews();
return getName(inputLine.parentInput) + "." + Integer.toString(inputLine.parentInput.childrenInputs.indexOf(inputLine)+1); //$NON-NLS-1$
}
+ /**
+ * Get the global list of input names.
+ *
+ * @return The list of input names
+ */
public List<String> getInputNames() {
List<String> inputs = new ArrayList<String>();
for (InputLine inputLine : definition.inputs) {
return inputs;
}
+ /**
+ * Get the list of input names for the given input line.
+ *
+ * @param inputLine
+ * The input line
+ * @return The list of input names
+ */
public List<String> getInputNames(InputLine inputLine) {
List<String> inputs = new ArrayList<String>();
if (inputLine.columns != null) {
helpShell.setLayout(new FillLayout());
helpBrowser = new Browser(helpShell, SWT.NONE);
helpBrowser.addTitleListener(new TitleListener() {
- @Override
- public void changed(TitleEvent event) {
- helpShell.setText(event.title);
- }
+ @Override
+ public void changed(TitleEvent event) {
+ helpShell.setText(event.title);
+ }
});
- helpBrowser.setBounds(0,0,600,400);
+ helpBrowser.setBounds(0, 0, 600, 400);
helpShell.pack();
helpShell.open();
helpBrowser.setUrl(url);
private class UpdateListener implements ModifyListener, SelectionListener {
- @Override
+ @Override
public void modifyText(ModifyEvent e) {
validate();
updatePreviews();
}
- @Override
+ @Override
public void widgetDefaultSelected(SelectionEvent e) {
validate();
updatePreviews();
}
- @Override
+ @Override
public void widgetSelected(SelectionEvent e) {
validate();
updatePreviews();
regexHelpButton.setImage(helpImage);
regexHelpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_regularExpressionHelp);
regexHelpButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
openHelpShell(PATTERN_URL);
}
});
Cardinality.ZERO_OR_ONE.toString(),
Cardinality.ONE.toString(),
"(?,?)"}); //$NON-NLS-1$
- cardinalityCombo.addSelectionListener(new SelectionListener(){
- @Override
+ cardinalityCombo.addSelectionListener(new SelectionListener() {
+ @Override
public void widgetDefaultSelected(SelectionEvent e) {}
- @Override
+
+ @Override
public void widgetSelected(SelectionEvent e) {
switch (cardinalityCombo.getSelectionIndex()) {
- case 4: //(?,?)
+ case 4: // (?,?)
cardinalityMinLabel.setVisible(true);
cardinalityMinText.setVisible(true);
cardinalityMaxLabel.setVisible(true);
cardinalityContainer.layout();
validate();
updatePreviews();
- }});
+ }
+ });
cardinalityMinLabel = new Label(cardinalityContainer, SWT.NONE);
cardinalityMinLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
}
}
+ /**
+ * Validate an input line.
+ *
+ * @param inputLine
+ * The line to clean up
+ * @param name
+ * The name of the line
+ * @return The cleaned up line
+ */
public StringBuffer validateLine(InputLine inputLine, String name) {
StringBuffer errors = new StringBuffer();
Line line = null;
return errors;
}
+ /**
+ * Get the trace definition.
+ *
+ * @return The trace definition
+ */
public CustomTxtTraceDefinition getDefinition() {
return definition;
}
+ /**
+ * Get the raw text of the input.
+ *
+ * @return The raw input text
+ */
public char[] getInputText() {
return inputText.getText().toCharArray();
}
+/*******************************************************************************
+ * 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 org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
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());
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++) {
}
}
+ /**
+ * Get the trace definition.
+ *
+ * @return The trace definition
+ */
public CustomTxtTraceDefinition getDefinition() {
return definition;
}
+/*******************************************************************************
+ * 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 org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+/**
+ * Wizard for custom text trace parsers.
+ *
+ * @author Patrick Tassé
+ */
public class CustomTxtParserWizard extends Wizard implements INewWizard {
CustomTxtParserInputWizardPage inputPage;
private ISelection selection;
CustomTxtTraceDefinition definition;
+ /**
+ * Default constructor
+ */
public CustomTxtParserWizard() {
super();
}
+ /**
+ * Constructor
+ *
+ * @param definition
+ * The trace definition
+ */
public CustomTxtParserWizard(CustomTxtTraceDefinition definition) {
super();
this.definition = definition;
return true;
}
- /**
- * Adding the page to the wizard.
- */
-
@Override
- public void addPages() {
+ public void addPages() {
inputPage = new CustomTxtParserInputWizardPage(selection, definition);
addPage(inputPage);
outputPage = new CustomTxtParserOutputWizardPage(this);
addPage(outputPage);
}
- @Override
+ @Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
this.selection = selection;
}
+/*******************************************************************************
+ * 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.BufferedReader;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
+/**
+ * Input wizard page for custom XML trace parsers.
+ *
+ * @author Patrick Tassé
+ */
public class CustomXmlParserInputWizardPage extends WizardPage {
private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$
private int logEntriesCount;
private boolean logEntryFound;
+ /**
+ * Constructor
+ *
+ * @param selection
+ * Selection object
+ * @param definition
+ * Trace definition
+ */
protected CustomXmlParserInputWizardPage(ISelection selection, CustomXmlTraceDefinition definition) {
super("CustomXmlParserWizardPage"); //$NON-NLS-1$
if (definition == null) {
super.setVisible(visible);
}
+ /**
+ * Get the global list of input names.
+ *
+ * @return The list of input names
+ */
public List<String> getInputNames() {
return getInputNames(definition.rootInputElement);
}
+ /**
+ * Get the list of input names for a given element.
+ *
+ * @param inputElement
+ * The element
+ * @return The input names for this element
+ */
public List<String> getInputNames(InputElement inputElement) {
List<String> inputs = new ArrayList<String>();
if (inputElement.inputName != null && !inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
}
}
+ /**
+ * Clean up the specified XML element.
+ *
+ * @param inputElement
+ * The element to clean up
+ * @return The validated element
+ */
public StringBuffer validateElement(InputElement inputElement) {
StringBuffer errors = new StringBuffer();
ElementNode elementNode = null;
return errors;
}
+ /**
+ * Get the trace definition.
+ *
+ * @return The trace definition
+ */
public CustomXmlTraceDefinition getDefinition() {
return definition;
}
+ /**
+ * Get the raw text input.
+ *
+ * @return The raw text input.
+ */
public char[] getInputText() {
return inputText.getText().toCharArray();
}
+/*******************************************************************************
+ * 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 org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
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 XML trace parsers.
+ *
+ * @author Patrick Tassé
+ */
public class CustomXmlParserOutputWizardPage 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 CustomXmlParserOutputWizardPage(final CustomXmlParserWizard wizard) {
super("CustomParserOutputWizardPage"); //$NON-NLS-1$
setTitle(wizard.inputPage.getTitle());
container.layout();
}
+ /**
+ * Extract the output columns from the page's current contents.
+ *
+ * @return The list of output columns
+ */
public List<OutputColumn> extractOutputs() {
int numColumns = 0;
for (int i = 0; i < outputs.size(); i++) {
}
}
+ /**
+ * Get the trace definition.
+ *
+ * @return The trace definition
+ */
public CustomXmlTraceDefinition getDefinition() {
return definition;
}
+/*******************************************************************************
+ * 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 org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+/**
+ * Wizard for custom XML trace parsers.
+ *
+ * @author Patrick Tassé
+ */
public class CustomXmlParserWizard extends Wizard implements INewWizard {
CustomXmlParserInputWizardPage inputPage;
private ISelection selection;
CustomXmlTraceDefinition definition;
+ /**
+ * Default constructor
+ */
public CustomXmlParserWizard() {
super();
}
+ /**
+ * Constructor
+ *
+ * @param definition
+ * The trace definition
+ */
public CustomXmlParserWizard(CustomXmlTraceDefinition definition) {
super();
this.definition = definition;
*/
@Override
- public void addPages() {
+ public void addPages() {
inputPage = new CustomXmlParserInputWizardPage(selection, definition);
addPage(inputPage);
outputPage = new CustomXmlParserOutputWizardPage(this);
}
@Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
this.selection = selection;
}
/*******************************************************************************
* Copyright (c) 2011 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:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
import org.eclipse.osgi.util.NLS;
+/**
+ * Message bundle for dialog messages.
+ */
+@SuppressWarnings("javadoc")
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.tmf.ui.project.dialogs.messages"; //$NON-NLS-1$
public static String SelectSpplementaryResources_DialogTitle;
public static String SelectSpplementaryResources_ResourcesGroupTitle;
-
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
/*******************************************************************************
* Copyright (c) 2009, 2011 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:
* Francois Chouinard - Copied and adapted from NewFolderDialog
*******************************************************************************/
import org.eclipse.ui.PlatformUI;
/**
- * <b><u>SelectSupplementaryResourcesDialog</u></b>
- * <p>
+ * SelectSupplementaryResourcesDialog
*/
public class SelectSupplementaryResourcesDialog extends Dialog {
// Constructor
// ------------------------------------------------------------------------
+ /**
+ * Constructor.
+ *
+ * @param shell
+ * Parent shell of this dialog
+ * @param resources
+ * Available resources
+ */
public SelectSupplementaryResourcesDialog(Shell shell, IResource[] resources) {
super(shell);
fAvailableResources = Arrays.copyOf(resources, resources.length);
// ------------------------------------------------------------------------
// Getters/Setters
// ------------------------------------------------------------------------
-
+
+ /**
+ * @return A copy of the resources
+ */
public IResource[] getResources() {
return Arrays.copyOf(fReturndResources, fReturndResources.length);
}
-
+
// ------------------------------------------------------------------------
// Dialog
// ------------------------------------------------------------------------
newShell.setText(Messages.SelectSpplementaryResources_DialogTitle);
newShell.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_DELETE));
}
-
+
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
contextGroup.setText(Messages.SelectSpplementaryResources_ResourcesGroupTitle);
contextGroup.setLayout(new GridLayout());
contextGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
fTreeViewer = new CheckboxTreeViewer(contextGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
GridData data = new GridData(GridData.FILL_BOTH);
Tree tree = fTreeViewer.getTree();
if (parentElement instanceof IResource[]) {
return (Object[]) parentElement;
}
- return null;
+ return null;
}
});
// fTreeViewer.setLabelProvider(new WorkbenchLabelProvider());
-
+
fTreeViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IResource) {
IResource resource = (IResource) element;
- // show also trace name
+ // show also trace name
return resource.getParent().getName() + File.separator + resource.getName();
}
return super.getText(element);
- }
+ }
});
fTreeViewer.setInput(fAvailableResources);
super.okPressed();
}
-
}
import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.menus.CommandContributionItemParameter;
+/**
+ * ContributionItem for the trace type selection.
+ *
+ * @author Patrick Tassé
+ */
public class SelectTraceTypeContributionItem extends CompoundContributionItem {
//private static final ImageDescriptor SELECTED_ICON = ImageDescriptor.createFromImage(TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/bullet.gif")); //$NON-NLS-1$
/*******************************************************************************
* Copyright (c) 2012 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 Tasse - Initial API and implementation
*******************************************************************************/
import org.eclipse.ui.navigator.ICommonViewerSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+/**
+ * Base action provider.
+ *
+ * @author Patrick Tassé
+ */
public class TmfActionProvider extends CommonActionProvider {
private OpenAction openAction;
// Table data
// ------------------------------------------------------------------------
- protected Composite fComposite;
- protected SashForm fSashForm;
+ /** The virtual event table */
protected TmfVirtualTable fTable;
- protected TmfRawEventViewer fRawViewer;
- protected ITmfTrace fTrace;
- protected boolean fPackDone = false;
- protected HeaderState fHeaderState = HeaderState.SEARCH;
- protected long fSelectedRank = 0;
+
+ private Composite fComposite;
+ private SashForm fSashForm;
+ private TmfRawEventViewer fRawViewer;
+ private ITmfTrace fTrace;
+ private boolean fPackDone = false;
+ private HeaderState fHeaderState = HeaderState.SEARCH;
+ private long fSelectedRank = 0;
// Filter data
- protected long fFilterMatchCount;
- protected long fFilterCheckCount;
- protected FilterThread fFilterThread;
- protected boolean fFilterThreadResume = false;
- protected final Object fFilterSyncObj = new Object();
- protected SearchThread fSearchThread;
- protected final Object fSearchSyncObj = new Object();
+ private long fFilterMatchCount;
+ private long fFilterCheckCount;
+ private FilterThread fFilterThread;
+ private boolean fFilterThreadResume = false;
+ private final Object fFilterSyncObj = new Object();
+ private SearchThread fSearchThread;
+ private final Object fSearchSyncObj = new Object();
/**
* List of selection change listeners (element type: <code>ISelectionChangedListener</code>).
private ListenerList selectionChangedListeners = new ListenerList();
// Bookmark map <Rank, MarkerId>
- protected Map<Long, Long> fBookmarksMap = new HashMap<Long, Long>();
- protected IFile fBookmarksFile;
- protected long fPendingGotoRank = -1;
+ private Map<Long, Long> fBookmarksMap = new HashMap<Long, Long>();
+ private IFile fBookmarksFile;
+ private long fPendingGotoRank = -1;
// SWT resources
- protected LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
- protected Color fGrayColor;
- protected Color fGreenColor;
- protected Font fBoldFont;
+ private LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
+ private Color fGrayColor;
+ private Color fGreenColor;
+ private Font fBoldFont;
// Table column names
- static private final String[] COLUMN_NAMES = new String[] { Messages.TmfEventsTable_TimestampColumnHeader,
+ private static final String[] COLUMN_NAMES = new String[] { Messages.TmfEventsTable_TimestampColumnHeader,
Messages.TmfEventsTable_SourceColumnHeader, Messages.TmfEventsTable_TypeColumnHeader,
Messages.TmfEventsTable_ReferenceColumnHeader, Messages.TmfEventsTable_ContentColumnHeader };
- static private final ColumnData[] COLUMN_DATA = new ColumnData[] { new ColumnData(COLUMN_NAMES[0], 100, SWT.LEFT),
+ private static final ColumnData[] COLUMN_DATA = new ColumnData[] { new ColumnData(COLUMN_NAMES[0], 100, SWT.LEFT),
new ColumnData(COLUMN_NAMES[1], 100, SWT.LEFT), new ColumnData(COLUMN_NAMES[2], 100, SWT.LEFT),
new ColumnData(COLUMN_NAMES[3], 100, SWT.LEFT), new ColumnData(COLUMN_NAMES[4], 100, SWT.LEFT) };
private boolean fDisposeOnClose;
// ------------------------------------------------------------------------
- // Constructor
+ // Constructors
// ------------------------------------------------------------------------
/**
createPopupMenu();
}
+ /**
+ * Create a pop-up menu.
+ */
protected void createPopupMenu() {
final IAction showTableAction = new Action(Messages.TmfEventsTable_ShowTableActionText) {
@Override
}
- @SuppressWarnings("unused")
+ /**
+ * Append an item to the event table's pop-up menu.
+ *
+ * @param tablePopupMenu
+ * The menu manager
+ * @param selectedItem
+ * The item to append
+ */
protected void appendToTablePopupMenu(final MenuManager tablePopupMenu, final TableItem selectedItem) {
// override to append more actions
}
- @SuppressWarnings("unused")
+ /**
+ * Append an item to the raw viewer's pop-up menu.
+ *
+ * @param rawViewerPopupMenu
+ * The menu manager
+ */
protected void appendToRawPopupMenu(final MenuManager rawViewerPopupMenu) {
// override to append more actions
}
fTable.setColumnHeaders(columnData);
}
+ /**
+ * Set a table item's data.
+ *
+ * @param item
+ * The item to set
+ * @param event
+ * Which trace event to link with this entry
+ * @param rank
+ * Which rank this event has in the trace/experiment
+ */
protected void setItemData(final TableItem item, final ITmfEvent event, final long rank) {
final ITmfEventField[] fields = extractItemFields(event);
final String[] content = new String[fields.length];
}
}
+ /**
+ * Set the item data of the header row.
+ *
+ * @param item
+ * The item to use as table header
+ */
protected void setHeaderRowItemData(final TableItem item) {
String txtKey = null;
if (fHeaderState == HeaderState.SEARCH) {
}
}
+ /**
+ * Set the item data of the "filter status" row.
+ *
+ * @param item
+ * The item to use as filter status row
+ */
protected void setFilterStatusRowItemData(final TableItem item) {
for (int i = 0; i < fTable.getColumns().length; i++) {
if (i == 0) {
item.setBackground(null);
}
+ /**
+ * Create an editor for the header.
+ */
protected void createHeaderEditor() {
final TableEditor tableEditor = fTable.createTableEditor();
tableEditor.horizontalAlignment = SWT.LEFT;
});
}
+ /**
+ * Send an event indicating a filter has been applied.
+ *
+ * @param filter
+ * The filter that was just applied
+ */
protected void fireFilterApplied(final ITmfFilter filter) {
broadcast(new TmfEventFilterAppliedSignal(this, fTrace, filter));
}
+ /**
+ * Send an event indicating that a search has been applied.
+ *
+ * @param filter
+ * The search filter that was just applied
+ */
protected void fireSearchApplied(final ITmfFilter filter) {
broadcast(new TmfEventSearchAppliedSignal(this, fTrace, filter));
}
+ /**
+ * Start the filtering thread.
+ */
protected void startFilterThread() {
synchronized (fFilterSyncObj) {
final ITmfFilterTreeNode filter = (ITmfFilterTreeNode) fTable.getData(Key.FILTER_OBJ);
}
}
+ /**
+ * Stop the filtering thread.
+ */
protected void stopFilterThread() {
synchronized (fFilterSyncObj) {
if (fFilterThread != null) {
}
/**
+ * Apply a filter.
+ *
+ * @param filter
+ * The filter to apply
* @since 1.1
*/
protected void applyFilter(ITmfFilter filter) {
fireFilterApplied(filter);
}
+ /**
+ * Clear all currently active filters.
+ */
protected void clearFilters() {
if (fTable.getData(Key.FILTER_OBJ) == null) {
return;
fireFilterApplied(null);
}
+ /**
+ * Wrapper Thread object for the filtering thread.
+ */
protected class FilterThread extends Thread {
private final ITmfFilterTreeNode filter;
private TmfDataRequest request;
private boolean refreshPending = false;
private final Object syncObj = new Object();
+ /**
+ * Constructor.
+ *
+ * @param filter
+ * The filter this thread will be processing
+ */
public FilterThread(final ITmfFilterTreeNode filter) {
super("Filter Thread"); //$NON-NLS-1$
this.filter = filter;
}
}
+ /**
+ * Refresh the filter.
+ */
public void refreshTable() {
synchronized (syncObj) {
if (refreshBusy) {
});
}
+ /**
+ * Cancel this filtering thread.
+ */
public void cancel() {
if (request != null) {
request.cancel();
}
}
+ /**
+ * Go to the next item of a search.
+ */
protected void searchNext() {
synchronized (fSearchSyncObj) {
if (fSearchThread != null) {
}
}
+ /**
+ * Go to the previous item of a search.
+ */
protected void searchPrevious() {
synchronized (fSearchSyncObj) {
if (fSearchThread != null) {
}
}
+ /**
+ * Stop the search thread.
+ */
protected void stopSearchThread() {
fPendingGotoRank = -1;
synchronized (fSearchSyncObj) {
}
}
+ /**
+ * Wrapper for the search thread.
+ */
protected class SearchThread extends Job {
- protected ITmfFilterTreeNode searchFilter;
- protected ITmfFilterTreeNode eventFilter;
- protected int startIndex;
- protected int direction;
- protected long rank;
- protected long foundRank = -1;
- protected TmfDataRequest request;
+
+ private ITmfFilterTreeNode searchFilter;
+ private ITmfFilterTreeNode eventFilter;
+ private int startIndex;
+ private int direction;
+ private long rank;
+ private long foundRank = -1;
+ private TmfDataRequest request;
private ITmfTimestamp foundTimestamp = null;
- public SearchThread(final ITmfFilterTreeNode searchFilter, final ITmfFilterTreeNode eventFilter, final int startIndex,
+ /**
+ * Constructor.
+ *
+ * @param searchFilter
+ * The search filter
+ * @param eventFilter
+ * The event filter
+ * @param startIndex
+ * The index at which we should start searching
+ * @param currentRank
+ * The current rank
+ * @param direction
+ * In which direction should we search, forward or backwards
+ */
+ public SearchThread(final ITmfFilterTreeNode searchFilter,
+ final ITmfFilterTreeNode eventFilter, final int startIndex,
final long currentRank, final int direction) {
super(Messages.TmfEventsTable_SearchingJobName);
this.searchFilter = searchFilter;
}
}
+ /**
+ * Create the resources.
+ */
protected void createResources() {
fGrayColor = fResourceManager.createColor(ColorUtil.blend(fTable.getBackground().getRGB(), fTable
.getForeground().getRGB()));
fBoldFont = fResourceManager.createFont(FontDescriptor.createFrom(fTable.getFont()).setStyle(SWT.BOLD));
}
+ /**
+ * Pack the columns.
+ */
protected void packColumns() {
if (fPackDone) {
return;
}
/**
+ * Extract the fields of an event (item in the table).
+ *
* @param event
- * @return
+ * The event to extract from
+ * @return The array of fields
*
* FIXME: Add support for column selection
*/
}
}
+ /**
+ * Callback for when populating the table is complete.
+ */
protected void populateCompleted() {
// Nothing by default;
}
/**
* Get the event types paths.
*
- * @param event
- * Event to get the path for.
- * @param extraInfo
- * Extra information to pass along with the event
- * @return Array of FixedArray representing the paths.
+ * @param traceName
+ * The name of the trace (will be used as a sub-tree in the view)
+ * @param type
+ * The event type
+ * @return Array of arrays representing the paths
*/
protected String[][] getTypePaths(String traceName, String type) {
String[][] paths = { new String[] {traceName, HEADER_EVENT_TYPES, type } };
/**
* Get the standard paths for an event.
*
- * @param event
- * Event to get the path for.
- * @param extraInfo
- * Extra information to pass along with the event
- * @return Array of FixedArray representing the paths.
+ * @param traceName
+ * The name of the trace (will be used as a sub-tree in the view)
+ * @return Array of arrays representing the paths
*/
protected String[][] getNormalPaths(String traceName) {
String[][] paths = { new String[] { traceName } };
/*******************************************************************************
* Copyright (c) 2010 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 Tasse - Initial API and implementation
*******************************************************************************/
private TreeViewer fViewer;
private Composite fComposite;
-
+
public FilterViewer(Composite parent, int style) {
super(parent, style);
setLayout(new FillLayout());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
setLayoutData(gd);
-
+
final SashForm sash = new SashForm(this, SWT.HORIZONTAL);
// Create the tree viewer to display the filter tree
fViewer.setContentProvider(new FilterTreeContentProvider());
fViewer.setLabelProvider(new FilterTreeLabelProvider());
fViewer.setInput(new TmfFilterRootNode());
-
+
// Create the empty filter node properties panel
fComposite = new Composite(sash, SWT.NONE);
GridLayout gl = new GridLayout();
fComposite.setLayout(gl);
createContextMenu();
-
+
fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
}
});
}
-
+
/**
* Create the context menu for the tree viewer
*/
// Publish it
fViewer.getTree().setMenu(contextMenu);
}
-
+
/**
- * Fill the context menu for the tree viewer
+ * Fill the context menu for the tree viewer.
+ *
+ * @param manager
+ * The menu manager
*/
protected void fillContextMenu(IMenuManager manager) {
final ISelection selection = fViewer.getSelection();
}
final ITmfFilterTreeNode selectedNode = filterTreeNode;
-
+
if (selectedNode != null) {
-
+
fillContextMenuForNode(selectedNode, manager);
-
+
if (selectedNode.getValidChildren().size() > 0) {
manager.add(new Separator());
}
};
deleteAction.setText(Messages.FilterViewer_DeleteActionText);
manager.add(deleteAction);
-
+
manager.add(new Separator());
}
if (fViewer.getInput() instanceof TmfFilterRootNode || selectedNode == null) {
final ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput();
-
+
fillContextMenuForNode(root, manager);
}
}
-
+
/**
* Fill the context menu with the valid children of the provided node
+ *
+ * @param node
+ * The target node
+ * @param manager
+ * The menu manager
*/
protected void fillContextMenuForNode(final ITmfFilterTreeNode node, IMenuManager manager) {
for (final String child : node.getValidChildren()) {
manager.add(action);
}
}
-
+
/**
* Create the appropriate filter node properties composite
*/
for (Control control : fComposite.getChildren()) {
control.dispose();
}
-
+
if (node instanceof TmfFilterNode) {
new FilterNodeComposite(fComposite, (TmfFilterNode) node);
} else if (node instanceof TmfFilterEventTypeNode) {
}
fComposite.layout();
}
-
+
/**
* Highlight the provided tree items
*/
}
}
-
+
/**
* Reset the provided tree items (remove highlight)
*/
resetTreeItems(item.getItems());
}
}
-
+
public void setInput(ITmfFilterTreeNode root) {
fViewer.setInput(root);
fViewer.expandAll();
-
+
updateFilterNodeComposite(null);
}
-
+
public ITmfFilterTreeNode getInput() {
return (ITmfFilterTreeNode) fViewer.getInput();
}
-
+
public void refresh() {
fViewer.refresh();
}
public void setSelection(ITmfFilterTreeNode node) {
fViewer.setSelection(new StructuredSelection(node));
}
-
+
public ITmfFilterTreeNode getSelection() {
final ISelection selection = fViewer.getSelection();
ITmfFilterTreeNode filterTreeNode = null;
final ITmfFilterTreeNode selectedNode = filterTreeNode;
return selectedNode;
}
-
+
public void addSelectionChangedListener(ISelectionChangedListener listener) {
fViewer.addSelectionChangedListener(listener);
}
-
+
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
fViewer.removeSelectionChangedListener(listener);
}
-
+
private class FilterBaseNodeComposite extends Composite {
-
+
FilterBaseNodeComposite(Composite parent) {
super(parent, SWT.NONE);
setLayout(new GridLayout(2, false));
setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
}
-
+
protected String[] getFieldsList(ITmfFilterTreeNode node) {
ArrayList<String> fieldsList = new ArrayList<String>();
while (node != null) {
private class FilterNodeComposite extends FilterBaseNodeComposite {
TmfFilterNode fNode;
Text fNameText;
-
+
FilterNodeComposite(Composite parent, TmfFilterNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NameLabel);
-
+
fNameText = new Text(this, SWT.BORDER);
fNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (node.getFilterName() != null && node.getFilterName().length() > 0) {
TmfFilterEventTypeNode fNode;
Combo fTypeCombo;
Map<String, Object> fEventsTypeMap;
-
+
FilterEventTypeNodeComposite(Composite parent, TmfFilterEventTypeNode node) {
super(parent);
fNode = node;
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_TypeLabel);
-
+
fTypeCombo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
fTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fTypeCombo.setItems(fEventsTypeMap.keySet().toArray(new String[0]));
return eventsTypeMap;
}
}
-
+
private class FilterAndNodeComposite extends FilterBaseNodeComposite {
TmfFilterAndNode fNode;
Button fNotButton;
-
+
FilterAndNodeComposite(Composite parent, TmfFilterAndNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
private class FilterOrNodeComposite extends FilterBaseNodeComposite {
TmfFilterOrNode fNode;
Button fNotButton;
-
+
FilterOrNodeComposite(Composite parent, TmfFilterOrNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
});
}
}
-
+
private class FilterContainsNodeComposite extends FilterBaseNodeComposite {
TmfFilterContainsNode fNode;
Button fNotButton;
Combo fFieldCombo;
Text fValueText;
Button fIgnoreCaseButton;
-
+
FilterContainsNodeComposite(Composite parent, TmfFilterContainsNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_FieldLabel);
-
+
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_ValueLabel);
-
+
fValueText = new Text(this, SWT.BORDER);
fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (node.getValue() != null && node.getValue().length() > 0) {
}
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
-
+
fIgnoreCaseButton = new Button(this, SWT.CHECK);
fIgnoreCaseButton.setSelection(fNode.isIgnoreCase());
fIgnoreCaseButton.setText(Messages.FilterViewer_IgnoreCaseButtonText);
Combo fFieldCombo;
Text fValueText;
Button fIgnoreCaseButton;
-
+
FilterEqualsNodeComposite(Composite parent, TmfFilterEqualsNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_FieldLabel);
-
+
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_ValueLabel);
-
+
fValueText = new Text(this, SWT.BORDER);
fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (node.getValue() != null && node.getValue().length() > 0) {
}
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
-
+
fIgnoreCaseButton = new Button(this, SWT.CHECK);
fIgnoreCaseButton.setSelection(fNode.isIgnoreCase());
fIgnoreCaseButton.setText(Messages.FilterViewer_IgnoreCaseButtonText);
Button fNotButton;
Combo fFieldCombo;
Text fRegexText;
-
+
FilterMatchesNodeComposite(Composite parent, TmfFilterMatchesNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_FieldLabel);
-
+
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_RegexLabel);
-
+
fRegexText = new Text(this, SWT.BORDER);
fRegexText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (node.getRegex() != null && node.getRegex().length() > 0) {
Button fNumButton;
Button fAlphaButton;
Button fTimestampButton;
-
+
FilterCompareNodeComposite(Composite parent, TmfFilterCompareNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_FieldLabel);
-
+
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_ResultLabel);
-
+
Composite resultGroup = new Composite(this, SWT.NONE);
GridLayout rggl = new GridLayout(3, true);
rggl.marginHeight = 0;
rggl.marginWidth = 0;
resultGroup.setLayout(rggl);
resultGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
-
+
fLTButton = new Button(resultGroup, SWT.RADIO);
fLTButton.setSelection(fNode.getResult() < 0);
fLTButton.setText("<"); //$NON-NLS-1$
fViewer.refresh(fNode);
}
});
-
+
fEQButton = new Button(resultGroup, SWT.RADIO);
fEQButton.setSelection(fNode.getResult() == 0);
fEQButton.setText("="); //$NON-NLS-1$
fViewer.refresh(fNode);
}
});
-
+
fGTButton = new Button(resultGroup, SWT.RADIO);
fGTButton.setSelection(fNode.getResult() > 0);
fGTButton.setText(">"); //$NON-NLS-1$
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_TypeLabel);
-
+
Composite typeGroup = new Composite(this, SWT.NONE);
GridLayout tggl = new GridLayout(3, false);
tggl.marginHeight = 0;
tggl.marginWidth = 0;
typeGroup.setLayout(tggl);
typeGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
-
+
fNumButton = new Button(typeGroup, SWT.RADIO);
fNumButton.setSelection(fNode.getType() == Type.NUM);
fNumButton.setText(Messages.FilterViewer_NumButtonText);
fViewer.refresh(fNode);
}
});
-
+
fAlphaButton = new Button(typeGroup, SWT.RADIO);
fAlphaButton.setSelection(fNode.getType() == Type.ALPHA);
fAlphaButton.setText(Messages.FilterViewer_AlphaButtonText);
fViewer.refresh(fNode);
}
});
-
+
fTimestampButton = new Button(typeGroup, SWT.RADIO);
fTimestampButton.setSelection(fNode.getType() == Type.TIMESTAMP);
fTimestampButton.setText(Messages.FilterViewer_TimestampButtonText);
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_ValueLabel);
-
+
fValueText = new Text(this, SWT.BORDER);
fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (node.getValue() != null && node.getValue().length() > 0) {
* Called when the mouse enter the ScrollView area
*
* @param e
+ * Mouse event
*/
protected void contentsMouseExit(MouseEvent e) {
}
/**
- * Called when the mouse enter the ScrollView area after and system defined time
+ * Called when the mouse enter the ScrollView area after and system defined
+ * time
*
* @param e
+ * Mouse event
*/
protected void contentsMouseHover(MouseEvent e) {
}
* Called when the mouse enter the ScrollView area
*
* @param e
+ * Mouse event
*/
protected void contentsMouseEnter(MouseEvent e) {
}
* Called when user double on contents area.
*
* @param e
+ * Mouse event
*/
protected void contentsMouseDoubleClickEvent(MouseEvent e) {
}
* Called when mouse is on contents area and button is pressed.
*
* @param e
+ * Mouse event
*/
protected void contentsMouseDownEvent(MouseEvent e) {
fMouseDownX = e.x;
* TimerTask for auto scroll feature.
*/
protected static class AutoScroll extends TimerTask {
+
+ /** X delta */
public int deltaX;
+
+ /** Y delta */
public int deltaY;
+
+ /** ScrollView object */
public ScrollView scrollView;
+ /**
+ * Constructor.
+ *
+ * @param sv
+ * ScrollView object to use
+ * @param dx
+ * X delta
+ * @param dy
+ * Y delta
+ */
public AutoScroll(ScrollView sv, int dx, int dy) {
scrollView = sv;
deltaX = dx;
* Called when mouse is on contents area and mode.
*
* @param event
+ * Mouse event
*/
protected void contentsMouseMoveEvent(MouseEvent event) {
if ((event.stateMask & SWT.BUTTON_MASK) != 0) {
* Called when mouse is on contents area and button is released
*
* @param event
+ * Mouse event
*/
protected void contentsMouseUpEvent(MouseEvent event) {
// reset auto scroll if it's engaged
}
/**
- * Responsible to draw contents area. At least rectangle clipX must be redrawn. This rectangle is given in contents
- * coordinates. By default, no paint is produced.
+ * Responsible to draw contents area. At least rectangle clipX must be
+ * redrawn. This rectangle is given in contents coordinates. By default, no
+ * paint is produced.
*
* @param gc
+ * Graphics context
* @param clipx
+ * X clip
* @param clipy
+ * Y clip
* @param clipw
+ * W clip
* @param cliph
+ * H clip
*/
protected void drawContents(GC gc, int clipx, int clipy, int clipw, int cliph) {
}
}
/**
- * setup scroll bars visibility, return true if one of visibility changed.
+ * Setup scroll bars visibility.
+ *
+ * @return True if one of visibility changed.
*/
protected boolean updateScrollBarVisiblity() {
boolean change = false;
}
/**
- * Add support for arrow key, scroll the ... scroll view. But you can redefine this method for your convenience.
+ * Add support for arrow key, scroll the ... scroll view. But you can
+ * redefine this method for your convenience.
+ *
+ * @param event
+ * Keyboard event
*/
protected void keyPressedEvent(KeyEvent event) {
switch (event.keyCode) {
/**
* Process overview appear
+ *
+ * @param mx
+ * X coordinate
+ * @param my
+ * Y coordinate
*/
protected void overviewAppear(int mx, int my) {
if (fOverview == null) {
/**
* Convert overview coordinates to global coordinates.
*
- * @param loc the control reference
- * @param x The x coordinate to convert
- * @param y The y coordinate to convert
- * @return
+ * @param loc
+ * the control reference
+ * @param x
+ * The x coordinate to convert
+ * @param y
+ * The y coordinate to convert
+ * @return The new converted Point
*/
protected Point toGlobalCoordinates(Control loc, int x, int y) {
Point p = new Point(x, y);
/**
* Checks for focus of children.
*
- * @param children Control to check
+ * @param children
+ * Control to check
* @return true if child is on focus else false
*/
- protected boolean checkFocusOnChilds(Control childs) {
- if (childs instanceof Composite) {
- Control[] child = ((Composite) childs).getChildren();
+ protected boolean checkFocusOnChilds(Control children) {
+ if (children instanceof Composite) {
+ Control[] child = ((Composite) children).getChildren();
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
* Informs the given lifeline about the maximum occurrence if applicable.
*
* @param lifeLine
+ * Concerned lifeline
* @param occurrence
+ * Occurrence number
*/
protected void informFrame(Lifeline lifeLine, int occurrence) {
if ((lifeLine != null) && (lifeLine.getFrame() != null) && (lifeLine.getFrame().getMaxEventOccurrence() < occurrence)) {
/**
* Rewrite this method in your extension in order to support customized fill colors
*
- * @param context
+ * @param context Graphics context
* @return IColor
*/
protected IColor setUnselectedFillColor(IGC context) {
/**
* Rewrite this method in your extension in order to support customized stroke colors
*
- * @param context
+ * @param context Graphics context
* @return IColor
*/
protected IColor setUnselectedStrokeColor(IGC context) {
* Set the frame on which this lifeline must be drawn
*
* @param parentFrame
+ * Parent frame
*/
protected void setFrame(Frame parentFrame) {
fFrame = parentFrame;
/**********************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2011, 2012 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:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
/**
* Class implementation of the pages dialog.<br>
- *
+ *
* It is associated to an SDView and to a ISDAdvancedPagingProvider.<br>
- *
+ *
* @version 1.0
* @author sveyrier
*/
* viewer and provided are kept here as attributes
*/
protected ISDAdvancedPagingProvider fProvider = null;
+
+ /** Current page */
protected TextArea fCurrentPage;
+
+ /** Comment label */
protected Label fTotalPageComment;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
-
+
/**
* Standard constructor
- *
+ *
* @param view The sequence diagram view reference
* @param provider The paging provider reference
*/
}
/**
- * Updates the comments texts.
+ * Updates the comments texts.
*/
protected void updateComments() {
int pages = Math.max(0, fProvider.pagesCount());
fTotalPageComment.setText(totalPageCommentText.toString());
}
-
+
// ------------------------------------------------------------------------
// Helper classes
// ------------------------------------------------------------------------
/**
* Constructor
- *
+ *
* @param parent The paren composite
*/
public TextArea(Composite parent) {
/**
* Sets the page value.
- *
+ *
* @param page The page value
*/
public void setValue(int page) {
/**
* Returns the page value.
- *
+ *
* @return the page value
*/
public int getValue() {
/**
* Sets the minimum and maximum page values.
- *
+ *
* @param min A minimum page value
* @param max A maximum page value
*/
* List of pages to print.
*/
protected int fPagesList[];
+
+ /**
+ * Value for dividing the sequence diagram into pages
+ */
+ protected float fStepX;
+
/**
- * Values for dividing sequence diagram into pages.
+ * Value for dividing the sequence diagram into pages
*/
- protected float fStepX, fStepY, sTX, sTY;
+ protected float fStepY;
+
+ /**
+ * Value for dividing the sequence diagram into pages
+ */
+ protected float sTX;
+
+ /**
+ * Value for dividing the sequence diagram into pages
+ */
+ protected float sTY;
+
/**
* Page which to print from.
*/
/**********************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2011, 2012 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:
+ *
+ * Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
/**
* Default implementation of the IColor interface.
- *
+ *
* @version 1.0
* @author sveyrier
- *
+ *
*/
public class ColorImpl implements IColor {
// ------------------------------------------------------------------------
/**
* Constructor
- *
+ *
* @param display The display to use
* @param r A value for red
* @param g A value for green
fColor = new Color(display, r, g, b);
}
- /**
+ /**
* Copy constructor
- *
- * @param A color to copy
+ *
+ * @param color
+ * A color to copy
*/
protected ColorImpl(Color color) {
fColor = color;
/**
* Returns a system color.
- *
- * @param color The color ID
+ *
+ * @param color The color ID
* @return a system color
*/
public static ColorImpl getSystemColor(int color) {
return new ColorImpl(Display.getDefault().getSystemColor(color));
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor#getColor()
}
}
+ /**
+ * Swap viewer preferences.
+ *
+ * @param toTemp Switch to the temporary preferences
+ */
protected void swapPref(boolean toTemp) {
String TAG1 = "";//$NON-NLS-1$
String TAG2 = TEMP_TAG;
}
}
+ /**
+ * @return The string representing the view type
+ */
protected String getViewTypeStr() {
return "viewoption.threads"; //$NON-NLS-1$
}
- int getMarginWidth(int idx) {
+ int getMarginWidth() {
return 0;
}
- int getMarginHeight(int idx) {
+ int getMarginHeight() {
return 0;
}
Utils.saveIntOption(getPreferenceString("namewidth"), _nameWidth); //$NON-NLS-1$
}
+ /**
+ * Create a data viewer.
+ *
+ * @param parent
+ * Parent composite
+ * @param style
+ * Style to use
+ * @return The new data viewer
+ */
protected Control createDataViewer(Composite parent, int style) {
loadOptions();
_colors = new TimeGraphColorScheme();
}
/**
+ * Create a new time graph control.
+ *
+ * @param parent
+ * The parent composite
+ * @param colors
+ * The color scheme
+ * @return The new TimeGraphControl
* @since 2.0
*/
- protected TimeGraphControl createTimeGraphControl(Composite parent, TimeGraphColorScheme colors) {
+ protected TimeGraphControl createTimeGraphControl(Composite parent,
+ TimeGraphColorScheme colors) {
return new TimeGraphControl(parent, colors);
}
* @author Patrick Tasse
*/
public class TimeEvent implements ITimeEvent {
+
+ /** TimeGraphEntry matching this time event */
protected ITimeGraphEntry fEntry;
+
+ /** Beginning timestamp of this time event */
protected long fTime;
+
+ /** Duration of this time event */
protected long fDuration;
/**
* @return If the time format is calendar (true) or relative (false)
* @deprecated replaced by {@link #getTimeFormat()}
*/
+ @Deprecated
boolean isCalendarFormat();
/**
public abstract class TimeGraphBaseControl extends Canvas implements PaintListener {
/** Default left margin size */
- static public final int MARGIN = 4;
+ public static final int MARGIN = 4;
/** Default expanded size */
- static public final int EXPAND_SIZE = 9; // the [+] or [-] control size
+ public static final int EXPAND_SIZE = 9; // the [+] or [-] control size
/** Default size of the right margin */
- static public final int RIGHT_MARGIN = 1; // 1 pixels less to make sure end time is visible
+ public static final int RIGHT_MARGIN = 1; // 1 pixels less to make sure end time is visible
/** Default size for small icons */
- static public final int SMALL_ICON_SIZE = 16;
+ public static final int SMALL_ICON_SIZE = 16;
+ /** Color scheme */
protected TimeGraphColorScheme _colors;
+
+ /** Font size */
protected int _fontHeight = 0;
/**
*/
public class TimeGraphControl extends TimeGraphBaseControl implements FocusListener, KeyListener, MouseMoveListener, MouseListener, MouseWheelListener, ControlListener, SelectionListener, MouseTrackListener, TraverseListener, ISelectionProvider, MenuDetectListener {
+ /** Max scrollbar size */
+ public static final int H_SCROLLBAR_MAX = Integer.MAX_VALUE - 1;
+
+ /** Resource manager */
+ protected LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
+
+ /** Color map for event types */
+ protected Color[] fEventColorMap = null;
+
private static final int DRAG_NONE = 0;
private static final int DRAG_TRACE_ITEM = 1;
private static final int DRAG_SPLIT_LINE = 2;
private static final int DRAG_ZOOM = 3;
- public static final boolean DEFAULT_DRAW_THREAD_JOIN = true;
- public static final boolean DEFAULT_DRAW_THREAD_WAIT = true;
- public static final boolean DEFAULT_DRAW_THREAD_RELEASE = true;
- public static final int H_SCROLLBAR_MAX = Integer.MAX_VALUE - 1;
+
private static final int CUSTOM_ITEM_HEIGHT = -1; // get item height from provider
private static final double zoomCoeff = 1.5;
private Listener mouseScrollFilterListener;
- protected LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
- protected Color[] fEventColorMap = null;
-
private MouseScrollNotifier fMouseScrollNotifier;
private final Object fMouseScrollNotifierLock = new Object();
private class MouseScrollNotifier extends Thread {
*
* @param item the item to draw
* @param bounds the container rectangle
+ * @param timeProvider Time provider
* @param i the item index
* @param nameSpace the name space
- * @param gc
+ * @param gc Graphics context
*/
protected void drawItem(Item item, Rectangle bounds, ITimeDataProvider timeProvider, int i, int nameSpace, GC gc) {
ITimeGraphEntry entry = item._trace;
fTimeGraphProvider.postDrawEntry(entry, rect, gc);
}
+ /**
+ * Draw the name of an item.
+ *
+ * @param item
+ * Item object
+ * @param bounds
+ * Where to draw the name
+ * @param gc
+ * Graphics context
+ */
protected void drawName(Item item, Rectangle bounds, GC gc) {
boolean hasTimeEvents = item._trace.hasTimeEvents();
if (! hasTimeEvents) {
}
}
+ /**
+ * Draw the state (color fill)
+ *
+ * @param colors
+ * Color scheme
+ * @param event
+ * Time event for which we're drawing the state
+ * @param rect
+ * Where to draw
+ * @param gc
+ * Graphics context
+ * @param selected
+ * Is this time event currently selected (so it appears
+ * highlighted)
+ * @param timeSelected
+ * Is the timestamp currently selected
+ */
protected void drawState(TimeGraphColorScheme colors, ITimeEvent event,
Rectangle rect, GC gc, boolean selected, boolean timeSelected) {
fTimeGraphProvider.postDrawEvent(event, rect, gc);
}
+ /**
+ * Fill the space between two contiguous time events
+ *
+ * @param rect
+ * Rectangle to fill
+ * @param gc
+ * Graphics context
+ * @param selected
+ * Is this time event selected or not
+ */
protected void fillSpace(Rectangle rect, GC gc, boolean selected) {
gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));
gc.fillRectangle(rect);
public abstract void draw(GC gc, long time, Rectangle rect);
+ /**
+ * Override to draw absolute time header This is for the time information
+ * not shown in the draw of each tick
+ *
+ * @param gc
+ * Graphics context
+ * @param time
+ * Timestamp
+ * @param absHeaderRect
+ * Header rectangle
+ */
public void drawAbsHeader(GC gc, long time, Rectangle absHeaderRect) {
- // Override to draw absolute time header
- // This is for the time information not shown in the draw of each tick
}
public abstract String hint();
*****************************************************************************/
package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
-import java.text.NumberFormat;
import java.util.Iterator;
import java.util.Map;
NUMBER,
}
- static public final int IMG_THREAD_RUNNING = 0;
- static public final int IMG_THREAD_SUSPENDED = 1;
- static public final int IMG_THREAD_STOPPED = 2;
- static public final int IMG_METHOD_RUNNING = 3;
- static public final int IMG_METHOD = 4;
- static public final int IMG_NUM = 5;
+ /**
+ * Timestamp resolution
+ */
+ public static enum Resolution {
+ /** seconds */
+ SECONDS,
- static public final Object[] _empty = new Object[0];
+ /** milliseconds */
+ MILLISEC,
- public static enum Resolution {
- SECONDS, MILLISEC, MICROSEC, NANOSEC
+ /** microseconds */
+ MICROSEC,
+
+ /** nanoseconds */
+ NANOSEC
}
static private final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$