From: lmcpata Date: Thu, 20 Oct 2011 22:08:52 +0000 (-0400) Subject: Fix for custom parsers X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=4bf17f4aea8e5821171b4a0e5cea95b3107f3e14;p=deliverable%2Ftracecompass.git Fix for custom parsers --- diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java index 0e92a16d30..3849fe63ed 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java @@ -23,6 +23,7 @@ public class LttngEvent extends TmfEvent { // Parameter-less constructor public LttngEvent() { super(); + fType = LttngEventType.DEFAULT_EVENT_TYPE; } /** diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventContent.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventContent.java index 2cc91644c1..126f6207bb 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventContent.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventContent.java @@ -215,19 +215,19 @@ public class LttngEventContent extends TmfEventContent { */ @Override public synchronized Object getField(String name) { - - // Check for generic table header fields - if (name.equals(FIELD_ID_TIMESTAMP)) { - return new Long(fParentEvent.getTimestamp().getValue()).toString(); - } else if (name.equals(FIELD_ID_SOURCE)) { - return fParentEvent.getSource().getSourceId().toString(); - } else if (name.equals(FIELD_ID_TYPE)) { - return fParentEvent.getType().getTypeId().toString(); - } else if (name.equals(FIELD_ID_REFERENCE)) { - return fParentEvent.getReference().getReference().toString(); - } else if (name.equals(FIELD_ID_CONTENT)) { - return fParentEvent.getContent().toString(); - } + + // Check for generic table header fields + if (name.equals(LttngEventType.CONTENT_LABEL) || name.equals(FIELD_ID_CONTENT)) { + return fParentEvent.getContent().toString(); + } else if (name.equals(LttngEventType.MARKER_LABEL) || name.equals(FIELD_ID_TYPE)) { + return fParentEvent.getType().getTypeId().toString(); + } else if (name.equals(LttngEventType.TRACE_LABEL) || name.equals(FIELD_ID_REFERENCE)) { + return fParentEvent.getReference().getReference().toString(); + } else if (name.equals(LttngEventType.TIMESTAMP_LABEL) || name.equals(FIELD_ID_TIMESTAMP)) { + return new Long(fParentEvent.getTimestamp().getValue()).toString(); + } else if (name.equals(FIELD_ID_SOURCE)) { + return fParentEvent.getSource().getSourceId().toString(); + } // *** VERIFY *** // Should we check if the field exists in LttngType before parsing? diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventType.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventType.java index 6eb80fa729..3435197cf2 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventType.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventType.java @@ -23,6 +23,17 @@ import org.eclipse.linuxtools.tmf.event.*; */ public class LttngEventType extends TmfEventType { + private static final String DEFAULT_TYPE_ID = "Kernel Trace"; //$NON-NLS-1$ + // These should match the column names in LTTng Events Table + public static final String TIMESTAMP_LABEL = "Timestamp"; //$NON-NLS-1$ + public static final String TRACE_LABEL = "Trace"; //$NON-NLS-1$ + public static final String MARKER_LABEL = "Marker"; //$NON-NLS-1$ + public static final String CONTENT_LABEL = "Content"; //$NON-NLS-1$ + private static final String[] DEFAULT_LABELS = { + TIMESTAMP_LABEL, TRACE_LABEL, MARKER_LABEL, CONTENT_LABEL + }; + public static final LttngEventType DEFAULT_EVENT_TYPE = new LttngEventType(DEFAULT_TYPE_ID, DEFAULT_LABELS); + private String tracefileName = null; private Long cpuId = null; private String markerName = null; @@ -36,6 +47,14 @@ public class LttngEventType extends TmfEventType { super(); } + /** + * Default Constructor.

+ * + */ + public LttngEventType(String typeId, String[] labels) { + super(typeId, labels); + } + /** * Constructor with parameters.

* diff --git a/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF index b0ef95b37e..6e346c69dd 100644 --- a/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF @@ -18,7 +18,6 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.linuxtools.tmf.ui, org.eclipse.linuxtools.tmf.ui.editors, - org.eclipse.linuxtools.tmf.ui.parsers, org.eclipse.linuxtools.tmf.ui.project.model, org.eclipse.linuxtools.tmf.ui.project.wizards, org.eclipse.linuxtools.tmf.ui.signal, diff --git a/org.eclipse.linuxtools.tmf.ui/plugin.xml b/org.eclipse.linuxtools.tmf.ui/plugin.xml index ecaca74882..8d33080b31 100644 --- a/org.eclipse.linuxtools.tmf.ui/plugin.xml +++ b/org.eclipse.linuxtools.tmf.ui/plugin.xml @@ -1,7 +1,6 @@ - - - - - - - - - - - - - - - - - A parser provider registers a list of trace parsers to the tracing framework. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPlugin.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPlugin.java index 711b61e783..0840bdad46 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPlugin.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPlugin.java @@ -14,7 +14,6 @@ package org.eclipse.linuxtools.tmf.ui; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -61,7 +60,6 @@ public class TmfUiPlugin extends AbstractUIPlugin { super.start(context); plugin = this; TmfUiTracer.init(); - ParserProviderManager.init(); TmfTraceElement.init(); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPreferenceInitializer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPreferenceInitializer.java deleted file mode 100644 index 9b012c1167..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPreferenceInitializer.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui; - -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; - -public class TmfUiPreferenceInitializer extends AbstractPreferenceInitializer { - - public static final String ACTIVE_PROJECT_PREFERENCE = "ACTIVE_PROJECT"; //$NON-NLS-1$ - public static final String ACTIVE_PROJECT_DEFAULT = ""; //$NON-NLS-1$ - - public TmfUiPreferenceInitializer() { - super(); - } - - @Override - public void initializeDefaultPreferences() { - IEclipsePreferences node = new InstanceScope().getNode(TmfUiPlugin.PLUGIN_ID); - node.put(ACTIVE_PROJECT_PREFERENCE, ACTIVE_PROJECT_DEFAULT); - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java index 59a5db5434..52fb9287a0 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java @@ -12,39 +12,17 @@ package org.eclipse.linuxtools.tmf.ui.dialogs; -import java.io.File; -import java.net.URI; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; -import org.eclipse.linuxtools.tmf.ui.TmfUiPreferenceInitializer; -import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor; import org.eclipse.linuxtools.tmf.ui.internal.Messages; -import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTraceDefinition; -import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTrace; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition; -import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTrace; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTraceDefinition; import org.eclipse.linuxtools.tmf.ui.parsers.wizards.CustomTxtParserWizard; import org.eclipse.linuxtools.tmf.ui.parsers.wizards.CustomXmlParserWizard; -import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -59,13 +37,6 @@ import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.FileEditorInput; public class ManageCustomParsersDialog extends Dialog { @@ -79,7 +50,6 @@ public class ManageCustomParsersDialog extends Dialog { Button deleteButton; Button importButton; Button exportButton; - Button parseButton; public ManageCustomParsersDialog(Shell parent) { super(parent); @@ -142,12 +112,10 @@ public class ManageCustomParsersDialog extends Dialog { editButton.setEnabled(false); deleteButton.setEnabled(false); exportButton.setEnabled(false); - parseButton.setEnabled(false); } else { editButton.setEnabled(true); deleteButton.setEnabled(true); exportButton.setEnabled(true); - parseButton.setEnabled(true); } }}); @@ -277,109 +245,12 @@ public class ManageCustomParsersDialog extends Dialog { } }}); - parseButton = new Button(buttonContainer, SWT.PUSH); - parseButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); - parseButton.setText(Messages.ManageCustomParsersDialog_ParseButtonLabel); - parseButton.setEnabled(false); - parseButton.addSelectionListener(new SelectionListener(){ - @Override - public void widgetDefaultSelected(SelectionEvent e) {} - @Override - public void widgetSelected(SelectionEvent e) { - FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN); - dialog.setText(Messages.ManageCustomParsersDialog_TraceSelection + parserList.getSelection()[0]); - if (xmlButton.getSelection()) { - dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$ - } - String path = dialog.open(); - String parser = null; - if (path != null) { - CustomTraceDefinition def = null; - if (txtButton.getSelection()) { - def = CustomTxtTraceDefinition.load(parserList.getSelection()[0]); - parser = CustomTxtTrace.class.getCanonicalName() + "." + def.definitionName; //$NON-NLS-1$ - } else if (xmlButton.getSelection()) { - def = CustomXmlTraceDefinition.load(parserList.getSelection()[0]); - parser = CustomXmlTrace.class.getCanonicalName() + "." + def.definitionName; //$NON-NLS-1$ - } - if (def != null) { - try { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IPath location = Path.fromOSString(path); - IFile file = workspace.getRoot().getFileForLocation(location); - if (file == null) { - file = createLink(new File(location.toPortableString()).toURI()); - } - file.setPersistentProperty(ParserProviderManager.PARSER_PROPERTY, parser); - IEditorInput editorInput = new FileEditorInput(file); - IWorkbench wb = PlatformUI.getWorkbench(); - IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage(); - - String editorId = TmfEventsEditor.ID; - IEditorPart editor = activePage.findEditor(editorInput); - if (editor != null && editor instanceof IReusableEditor) { - activePage.reuseEditor((IReusableEditor)editor, editorInput); - activePage.activate(editor); - } else { - editor = activePage.openEditor(editorInput, editorId); - } - } catch (CoreException e1) { - MessageDialog.openError(getShell(), "Parse Error", e1.getMessage()); //$NON-NLS-1$ - } - } - } - }}); - fillParserList(); getShell().setMinimumSize(300, 275); return composite; } - // ///////////////////////////////////////////////////////////////////////////// - // FIXME: Duplicated in TmfEventsEditor - // From the legacy ProjectView - // ///////////////////////////////////////////////////////////////////////////// - - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - static public IFolder getActiveProjectTracesFolder() { - IEclipsePreferences node = new InstanceScope() - .getNode(TmfUiPlugin.PLUGIN_ID); - String activeProjectName = node.get( - TmfUiPreferenceInitializer.ACTIVE_PROJECT_PREFERENCE, - TmfUiPreferenceInitializer.ACTIVE_PROJECT_DEFAULT); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject[] projects = root.getProjects(); - for (IProject project : projects) { - if (project.isAccessible() - && project.getName().equals(activeProjectName)) { - return project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME); - } - } - return null; - } - - static public IFile createLink(URI uri) throws CoreException { - IFolder folder = getActiveProjectTracesFolder(); - if (folder == null || !folder.exists()) { - throw new CoreException(new Status(Status.ERROR, - TmfUiPlugin.PLUGIN_ID, "No active project set")); //$NON-NLS-1$ - } - String path = uri.getPath(); - // TODO: support duplicate file names - IFile file = folder.getFile(path.substring(path - .lastIndexOf(Path.SEPARATOR))); - if (!file.exists()) { - file.createLink(uri, IResource.NONE, null); - } - return file; - } - - // ///////////////////////////////////////////////////////////////////////////// - /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ @@ -402,7 +273,6 @@ public class ManageCustomParsersDialog extends Dialog { editButton.setEnabled(false); deleteButton.setEnabled(false); exportButton.setEnabled(false); - parseButton.setEnabled(false); } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java index f29ee3bad2..7912862f46 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java @@ -12,43 +12,35 @@ package org.eclipse.linuxtools.tmf.ui.editors; +import java.io.FileNotFoundException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.net.URI; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarkerDelta; -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.InvalidRegistryObjectException; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.linuxtools.tmf.TmfCorePlugin; +import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.signal.TmfTraceSelectedSignal; import org.eclipse.linuxtools.tmf.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; -import org.eclipse.linuxtools.tmf.ui.TmfUiPreferenceInitializer; -import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomEventsTable; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTrace; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTrace; import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; -import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceClosedSignal; import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceOpenedSignal; import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceParserUpdatedSignal; import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; +import org.eclipse.linuxtools.tmf.util.TmfTraceType; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorInput; @@ -58,7 +50,6 @@ import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IPropertyListener; import org.eclipse.ui.IReusableEditor; import org.eclipse.ui.PartInitException; -import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.ide.IGotoMarker; import org.osgi.framework.Bundle; @@ -71,7 +62,8 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus private TmfEventsTable fEventsTable; private IResource fResource; - private ITmfTrace fTrace; + @SuppressWarnings("rawtypes") + private ITmfTrace fTrace; private Composite fParent; @Override @@ -82,6 +74,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus public void doSaveAs() { } + @SuppressWarnings("unchecked") @Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { if (input instanceof TmfEditorInput) { @@ -89,17 +82,27 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus fTrace = ((TmfEditorInput) input).getTrace(); } else if (input instanceof IFileEditorInput) { fResource = ((IFileEditorInput) input).getFile(); - fTrace = ParserProviderManager.getTrace(fResource); - input = new TmfEditorInput(fResource, fTrace); - } else if (input instanceof FileStoreEditorInput) { try { - FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) input; - fResource = createLink(fileStoreEditorInput.getURI()); - fTrace = ParserProviderManager.getTrace(fResource); - input = new TmfEditorInput(fResource, fTrace); + String traceTypeId = fResource.getPersistentProperty(TmfTraceElement.TRACETYPE); + if (traceTypeId != null) { + for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { + if (traceTypeId.equals(ce.getAttribute(TmfTraceType.ID_ATTR))) { + fTrace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR); + TmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR); + String path = fResource.getLocation().toOSString(); + fTrace.initTrace(path, event.getClass(), true); + break; + } + } + } + } catch (InvalidRegistryObjectException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); } catch (CoreException e) { - throw new PartInitException(e.getMessage()); + e.printStackTrace(); } + input = new TmfEditorInput(fResource, fTrace); } else { throw new PartInitException("Invalid IEditorInput: " + input.getClass()); //$NON-NLS-1$ } @@ -110,49 +113,6 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus super.setInput(input); } - /////////////////////////////////////////////////////////////////////////////// - // FIXME: Duplicated in ManageCustomParsersDialog - // From the legacy ProjectView - /////////////////////////////////////////////////////////////////////////////// - - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - static public IFolder getActiveProjectTracesFolder() { - @SuppressWarnings("deprecation") - IEclipsePreferences node = new InstanceScope() - .getNode(TmfUiPlugin.PLUGIN_ID); - String activeProjectName = node.get( - TmfUiPreferenceInitializer.ACTIVE_PROJECT_PREFERENCE, - TmfUiPreferenceInitializer.ACTIVE_PROJECT_DEFAULT); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject[] projects = root.getProjects(); - for (IProject project : projects) { - if (project.isAccessible() - && project.getName().equals(activeProjectName)) { - return project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME); - } - } - return null; - } - - static public IFile createLink(URI uri) throws CoreException { - IFolder folder = getActiveProjectTracesFolder(); - if (folder == null || !folder.exists()) { - throw new CoreException(new Status(Status.ERROR, TmfUiPlugin.PLUGIN_ID, "No active project set")); //$NON-NLS-1$ - } - String path = uri.getPath(); - // TODO: support duplicate file names - IFile file = folder.getFile(path.substring(path - .lastIndexOf(Path.SEPARATOR))); - if (!file.exists()) { - file.createLink(uri, IResource.NONE, null); - } - return file; - } - /////////////////////////////////////////////////////////////////////////////// - @Override public boolean isDirty() { return false; @@ -227,16 +187,21 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus private TmfEventsTable getEventsTable(Composite parent, int cacheSize) { TmfEventsTable eventsTable = null; - IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfCorePlugin.TMF_TRACE_TYPE_ID); try { String traceType = fResource.getPersistentProperty(TmfTraceElement.TRACETYPE); - for (IConfigurationElement ce : config) { - if (ce.getAttribute(TmfTraceElement.ID).equals(traceType)) { - IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceElement.EVENTS_TABLE_TYPE); + if (traceType.startsWith(CustomTxtTrace.class.getCanonicalName())) { + return new CustomEventsTable(((CustomTxtTrace) fTrace).getDefinition(), parent, cacheSize); + } + if (traceType.startsWith(CustomXmlTrace.class.getCanonicalName())) { + return new CustomEventsTable(((CustomXmlTrace) fTrace).getDefinition(), parent, cacheSize); + } + for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { + if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(traceType)) { + IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceType.EVENTS_TABLE_TYPE_ELEM); if (eventsTableTypeCE.length != 1) { break; } - String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceElement.CLASS); + String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceType.CLASS_ATTR); if (eventsTableType == null || eventsTableType.length() == 0) { break; } @@ -326,11 +291,32 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus // Signal handlers // ------------------------------------------------------------------------ + @SuppressWarnings("unchecked") @TmfSignalHandler public void traceParserUpdated(TmfTraceParserUpdatedSignal signal) { if (signal.getTraceResource().equals(fResource)) { broadcast(new TmfTraceClosedSignal(this, fTrace)); - fTrace = ParserProviderManager.getTrace(fResource); + try { + fTrace = null; + String traceTypeId = fResource.getPersistentProperty(TmfTraceElement.TRACETYPE); + if (traceTypeId != null) { + for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { + if (traceTypeId.equals(ce.getAttribute(TmfTraceType.ID_ATTR))) { + fTrace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR); + TmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR); + String path = fResource.getLocation().toOSString(); + fTrace.initTrace(path, event.getClass(), true); + break; + } + } + } + } catch (InvalidRegistryObjectException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (CoreException e) { + e.printStackTrace(); + } fEventsTable.dispose(); if (fTrace != null) { fEventsTable = createEventsTable(fParent, fTrace.getCacheSize()); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/Messages.java index 3561aaa111..05dac3369e 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/Messages.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/Messages.java @@ -3,245 +3,246 @@ package org.eclipse.linuxtools.tmf.ui.internal; import org.eclipse.osgi.util.NLS; public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.internal.messages"; //$NON-NLS-1$ + private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.internal.messages"; //$NON-NLS-1$ - public static String ManageCustomParsersDialog_DeleteButtonLabel; - public static String ManageCustomParsersDialog_DeleteConfirmation; - public static String ManageCustomParsersDialog_DeleteParserDialogHeader; - public static String ManageCustomParsersDialog_DialogHeader; - public static String ManageCustomParsersDialog_EditButtonLabel; - public static String ManageCustomParsersDialog_ExportButtonLabel; - public static String ManageCustomParsersDialog_ExportParserSelection; - public static String ManageCustomParsersDialog_ImportButtonLabel; - public static String ManageCustomParsersDialog_ImportParserSelection; - public static String ManageCustomParsersDialog_NewButtonLabel; - public static String ManageCustomParsersDialog_ParseButtonLabel; - public static String ManageCustomParsersDialog_TextButtonLabel; - public static String ManageCustomParsersDialog_TraceSelection; + public static String ManageCustomParsersDialog_DeleteButtonLabel; + public static String ManageCustomParsersDialog_DeleteConfirmation; + public static String ManageCustomParsersDialog_DeleteParserDialogHeader; + public static String ManageCustomParsersDialog_DialogHeader; + public static String ManageCustomParsersDialog_EditButtonLabel; + public static String ManageCustomParsersDialog_ExportButtonLabel; + public static String ManageCustomParsersDialog_ExportParserSelection; + public static String ManageCustomParsersDialog_ImportButtonLabel; + public static String ManageCustomParsersDialog_ImportParserSelection; + public static String ManageCustomParsersDialog_NewButtonLabel; + public static String ManageCustomParsersDialog_ParseButtonLabel; + public static String ManageCustomParsersDialog_ParseError; + public static String ManageCustomParsersDialog_TextButtonLabel; + public static String ManageCustomParsersDialog_TraceSelection; - public static String CustomTraceDefinition_messageTag; - public static String CustomTraceDefinition_otherTag; - public static String CustomTraceDefinition_timestampTag; - public static String CustomTxtTraceDefinition_action; - public static String CustomTxtTraceDefinition_cardinality; - public static String CustomTxtTraceDefinition_definition; - public static String CustomTxtTraceDefinition_definitionRootElement; - public static String CustomTxtTraceDefinition_format; - public static String CustomTxtTraceDefinition_inputData; - public static String CustomTxtTraceDefinition_inputLine; - public static String CustomTxtTraceDefinition_max; - public static String CustomTxtTraceDefinition_min; - public static String CustomTxtTraceDefinition_name; - public static String CustomTxtTraceDefinition_outputColumn; - public static String CustomTxtTraceDefinition_regEx; - public static String CustomTxtTraceDefinition_timestampOutputFormat; - public static String CustomXmlTraceDefinition_action; - public static String CustomXmlTraceDefinition_attribute; - public static String CustomXmlTraceDefinition_definition; - public static String CustomXmlTraceDefinition_definitionRootElement; - public static String CustomXmlTraceDefinition_format; - public static String CustomXmlTraceDefinition_ignoreTag; - public static String CustomXmlTraceDefinition_inputData; - public static String CustomXmlTraceDefinition_inputElement; - public static String CustomXmlTraceDefinition_logEntry; - public static String CustomXmlTraceDefinition_name; - public static String CustomXmlTraceDefinition_outputColumn; - public static String CustomXmlTraceDefinition_timestampOutputFormat; + public static String CustomTraceDefinition_messageTag; + public static String CustomTraceDefinition_otherTag; + public static String CustomTraceDefinition_timestampTag; + public static String CustomTxtTraceDefinition_action; + public static String CustomTxtTraceDefinition_cardinality; + public static String CustomTxtTraceDefinition_definition; + public static String CustomTxtTraceDefinition_definitionRootElement; + public static String CustomTxtTraceDefinition_format; + public static String CustomTxtTraceDefinition_inputData; + public static String CustomTxtTraceDefinition_inputLine; + public static String CustomTxtTraceDefinition_max; + public static String CustomTxtTraceDefinition_min; + public static String CustomTxtTraceDefinition_name; + public static String CustomTxtTraceDefinition_outputColumn; + public static String CustomTxtTraceDefinition_regEx; + public static String CustomTxtTraceDefinition_timestampOutputFormat; + public static String CustomXmlTraceDefinition_action; + public static String CustomXmlTraceDefinition_attribute; + public static String CustomXmlTraceDefinition_definition; + public static String CustomXmlTraceDefinition_definitionRootElement; + public static String CustomXmlTraceDefinition_format; + public static String CustomXmlTraceDefinition_ignoreTag; + public static String CustomXmlTraceDefinition_inputData; + public static String CustomXmlTraceDefinition_inputElement; + public static String CustomXmlTraceDefinition_logEntry; + public static String CustomXmlTraceDefinition_name; + public static String CustomXmlTraceDefinition_outputColumn; + public static String CustomXmlTraceDefinition_timestampOutputFormat; - public static String TmfEventsTable_AddBookmarkActionText; - public static String TmfEventsTable_AddBookmarkDialogText; - public static String TmfEventsTable_AddBookmarkDialogTitle; - public static String TmfEventsTable_ApplyPresetFilterMenuName; - public static String TmfEventsTable_ClearFiltersActionText; - public static String TmfEventsTable_ContentColumnHeader; - public static String TmfEventsTable_FilterHint; - public static String TmfEventsTable_HideRawActionText; - public static String TmfEventsTable_HideTableActionText; - public static String TmfEventsTable_ReferenceColumnHeader; - public static String TmfEventsTable_RemoveBookmarkActionText; - public static String TmfEventsTable_SearchHint; - public static String TmfEventsTable_SearchingJobName; - public static String TmfEventsTable_ShowFilterBarActionText; - public static String TmfEventsTable_ShowRawActionText; - public static String TmfEventsTable_ShowSearchBarActionText; - public static String TmfEventsTable_ShowTableActionText; - public static String TmfEventsTable_SourceColumnHeader; - public static String TmfEventsTable_TimestampColumnHeader; - public static String TmfEventsTable_TypeColumnHeader; + public static String TmfEventsTable_AddBookmarkActionText; + public static String TmfEventsTable_AddBookmarkDialogText; + public static String TmfEventsTable_AddBookmarkDialogTitle; + public static String TmfEventsTable_ApplyPresetFilterMenuName; + public static String TmfEventsTable_ClearFiltersActionText; + public static String TmfEventsTable_ContentColumnHeader; + public static String TmfEventsTable_FilterHint; + public static String TmfEventsTable_HideRawActionText; + public static String TmfEventsTable_HideTableActionText; + public static String TmfEventsTable_ReferenceColumnHeader; + public static String TmfEventsTable_RemoveBookmarkActionText; + public static String TmfEventsTable_SearchHint; + public static String TmfEventsTable_SearchingJobName; + public static String TmfEventsTable_ShowFilterBarActionText; + public static String TmfEventsTable_ShowRawActionText; + public static String TmfEventsTable_ShowSearchBarActionText; + public static String TmfEventsTable_ShowTableActionText; + public static String TmfEventsTable_SourceColumnHeader; + public static String TmfEventsTable_TimestampColumnHeader; + public static String TmfEventsTable_TypeColumnHeader; - public static String TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS; - public static String TmfTimeFilterDialog_TRACE_FILTER; - public static String TmfTimeFilterDialog_TRACE_FILTER_DESC; - public static String TmfTimeFilterDialog_TRACE_ID; - public static String TmfTimeFilterDialog_TRACE_NAME; - public static String TmfTimeLegend_LEGEND; - public static String TmfTimeLegend_TRACE_STATES; - public static String TmfTimeLegend_TRACE_STATES_TITLE; - public static String TmfTimeLegend_WINDOW_TITLE; + public static String TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS; + public static String TmfTimeFilterDialog_TRACE_FILTER; + public static String TmfTimeFilterDialog_TRACE_FILTER_DESC; + public static String TmfTimeFilterDialog_TRACE_ID; + public static String TmfTimeFilterDialog_TRACE_NAME; + public static String TmfTimeLegend_LEGEND; + public static String TmfTimeLegend_TRACE_STATES; + public static String TmfTimeLegend_TRACE_STATES_TITLE; + public static String TmfTimeLegend_WINDOW_TITLE; - public static String TimeScaleCtrl_Timescale; - public static String TmfTimeStatesCtrl_TRACE_GROUP_LABEL; - public static String TmfTimeStatesCtrl_UNDEFINED_GROUP; - public static String TmfTimeTipHandler_DURATION; - public static String TmfTimeTipHandler_NUMBER_OF_TRACES; - public static String TmfTimeTipHandler_TRACE_CLASS_NAME; - public static String TmfTimeTipHandler_TRACE_DATE; - public static String TmfTimeTipHandler_TRACE_EVENT_TIME; - public static String TmfTimeTipHandler_TRACE_GROUP_NAME; - public static String TmfTimeTipHandler_TRACE_NAME; - public static String TmfTimeTipHandler_TRACE_START_TIME; - public static String TmfTimeTipHandler_TRACE_STATE; - public static String TmfTimeTipHandler_TRACE_STOP_TIME; + public static String TimeScaleCtrl_Timescale; + public static String TmfTimeStatesCtrl_TRACE_GROUP_LABEL; + public static String TmfTimeStatesCtrl_UNDEFINED_GROUP; + public static String TmfTimeTipHandler_DURATION; + public static String TmfTimeTipHandler_NUMBER_OF_TRACES; + public static String TmfTimeTipHandler_TRACE_CLASS_NAME; + public static String TmfTimeTipHandler_TRACE_DATE; + public static String TmfTimeTipHandler_TRACE_EVENT_TIME; + public static String TmfTimeTipHandler_TRACE_GROUP_NAME; + public static String TmfTimeTipHandler_TRACE_NAME; + public static String TmfTimeTipHandler_TRACE_START_TIME; + public static String TmfTimeTipHandler_TRACE_STATE; + public static String TmfTimeTipHandler_TRACE_STOP_TIME; - public static String ColorsView_AddActionToolTipText; - public static String ColorsView_BackgroundButtonText; - public static String ColorsView_BackgroundDialogText; - public static String ColorsView_DeleteActionToolTipText; - public static String ColorsView_ExportActionToolTipText; - public static String ColorsView_FilterButtonText; - public static String ColorsView_ForegroundButtonText; - public static String ColorsView_ForegroundDialogText; - public static String ColorsView_ImportActionToolTipText; - public static String ColorsView_ImportOverwriteDialogMessage1; - public static String ColorsView_ImportOverwriteDialogMessage2; - public static String ColorsView_ImportOverwriteDialogTitle; - public static String ColorsView_MoveDownActionToolTipText; - public static String ColorsView_MoveUpActionToolTipText; - public static String ColorsView_TickButtonText; - public static String TickColorDialog_TickColorDialogTitle; + public static String ColorsView_AddActionToolTipText; + public static String ColorsView_BackgroundButtonText; + public static String ColorsView_BackgroundDialogText; + public static String ColorsView_DeleteActionToolTipText; + public static String ColorsView_ExportActionToolTipText; + public static String ColorsView_FilterButtonText; + public static String ColorsView_ForegroundButtonText; + public static String ColorsView_ForegroundDialogText; + public static String ColorsView_ImportActionToolTipText; + public static String ColorsView_ImportOverwriteDialogMessage1; + public static String ColorsView_ImportOverwriteDialogMessage2; + public static String ColorsView_ImportOverwriteDialogTitle; + public static String ColorsView_MoveDownActionToolTipText; + public static String ColorsView_MoveUpActionToolTipText; + public static String ColorsView_TickButtonText; + public static String TickColorDialog_TickColorDialogTitle; - public static String CustomTxtParserInputWizardPage_addChildLine; - public static String CustomTxtParserInputWizardPage_addGroup; - public static String CustomTxtParserInputWizardPage_addNextLine; - public static String CustomTxtParserInputWizardPage_append; - public static String CustomTxtParserInputWizardPage_appendWith; - public static String CustomTxtParserInputWizardPage_capturedGroup; - public static String CustomTxtParserInputWizardPage_cardinality; - public static String CustomTxtParserInputWizardPage_dateFormatHelp; - public static String CustomTxtParserInputWizardPage_desccriptionEdit; - public static String CustomTxtParserInputWizardPage_descriptionNew; - public static String CustomTxtParserInputWizardPage_format; - public static String CustomTxtParserInputWizardPage_group; - public static String CustomTxtParserInputWizardPage_highlightAll; - public static String CustomTxtParserInputWizardPage_logType; - public static String CustomTxtParserInputWizardPage_matchingLineRoot; - public static String CustomTxtParserInputWizardPage_matchingOtherLine; - public static String CustomTxtParserInputWizardPage_matchingRootLine; - public static String CustomTxtParserInputWizardPage_max; - public static String CustomTxtParserInputWizardPage_min; - public static String CustomTxtParserInputWizardPage_moveDown; - public static String CustomTxtParserInputWizardPage_moveUp; - public static String CustomTxtParserInputWizardPage_name; - public static String CustomTxtParserInputWizardPage_newGroup; - public static String CustomTxtParserInputWizardPage_noMatch; - public static String CustomTxtParserInputWizardPage_noMatchingGroup; - public static String CustomTxtParserInputWizardPage_noMatchingLine; - public static String CustomTxtParserInputWizardPage_noMatchingTimestamp; - public static String CustomTxtParserInputWizardPage_noMathcingLine; - public static String CustomTxtParserInputWizardPage_nonMatchingLine; - public static String CustomTxtParserInputWizardPage_noTimestampGroup; - public static String CustomTxtParserInputWizardPage_preview; - public static String CustomTxtParserInputWizardPage_previewInput; - public static String CustomTxtParserInputWizardPage_previewLegend; - public static String CustomTxtParserInputWizardPage_regularExpression; - public static String CustomTxtParserInputWizardPage_regularExpressionHelp; - public static String CustomTxtParserInputWizardPage_removeGroup; - public static String CustomTxtParserInputWizardPage_removeLine; - public static String CustomTxtParserInputWizardPage_set; - public static String CustomTxtParserInputWizardPage_timestampFormat; - public static String CustomTxtParserInputWizardPage_uncapturedText; - public static String CustomTxtParserInputWizardPage_unidentifiedCaptureGroup; - public static String CustomTxtParserInputWizardPage_windowTitleEdit; - public static String CustomTxtParserInputWizardPage_windowTitleNew; - public static String CustomTxtParserOutputWizardPage_description; - public static String CustomTxtParserOutputWizardPage_moveAfter; - public static String CustomTxtParserOutputWizardPage_moveBefore; - public static String CustomTxtParserOutputWizardPage_visible; - public static String CustomXmlParserInputWizardPage_emptyLogTypeError; - public static String CustomXmlParserInputWizardPage_duplicatelogTypeError; - public static String CustomXmlParserInputWizardPage_noDocumentError; - public static String CustomXmlParserInputWizardPage_missingLogEntryError; - public static String CustomXmlParserInputWizardPage_missingTimestampFmtError; - public static String CustomXmlParserInputWizardPage_invalidTimestampFmtError; - public static String CustomXmlParserInputWizardPage_notimestamporAttributeError; - public static String CustomXmlParserInputWizardPage_missingDocumentElementError; - public static String CustomXmlParserInputWizardPage_timestampFormatPrompt; - public static String CustomXmlParserInputWizardPage_timestampElementPrompt; - public static String CustomXmlParserInputWizardPage_missingInputElementNameError; - public static String CustomXmlParserInputWizardPage_attributePrompt; - public static String CustomXmlParserInputWizardPage_missingAttribute; - public static String CustomXmlParserInputWizardPage_duplicateAttributeError; - public static String CustomXmlParserInputWizardPage_missingTimestampInFmtError; - public static String CustomXmlParserInputWizardPage_invalidTimestampInFmtError; - public static String CustomXmlParserInputWizardPage_missingDataGroupNameError; - public static String CustomXmlParserInputWizardPage_missingElementNameError; - public static String CustomXmlParserInputWizardPage_duplicateElementNameError; - public static String CustomXmlParserInputWizardPage_addAttribute; - public static String CustomXmlParserInputWizardPage_addChildElement; - public static String CustomXmlParserInputWizardPage_addDocumentEleemnt; - public static String CustomXmlParserInputWizardPage_addDocumentElement; - public static String CustomXmlParserInputWizardPage_addNextElement; - public static String CustomXmlParserInputWizardPage_append; - public static String CustomXmlParserInputWizardPage_appendWith; - public static String CustomXmlParserInputWizardPage_attibute; - public static String CustomXmlParserInputWizardPage_dateFormatHelp; - public static String CustomXmlParserInputWizardPage_descriptionEdit; - public static String CustomXmlParserInputWizardPage_descriptionNew; - public static String CustomXmlParserInputWizardPage_elementName; - public static String CustomXmlParserInputWizardPage_feelingLucky; - public static String CustomXmlParserInputWizardPage_format; - public static String CustomXmlParserInputWizardPage_logEntry; - public static String CustomXmlParserInputWizardPage_logType; - public static String CustomXmlParserInputWizardPage_moveDown; - public static String CustomXmlParserInputWizardPage_moveUp; - public static String CustomXmlParserInputWizardPage_name; - public static String CustomXmlParserInputWizardPage_newAttibute; - public static String CustomXmlParserInputWizardPage_noMatchingAttribute; - public static String CustomXmlParserInputWizardPage_noMatch; - public static String CustomXmlParserInputWizardPage_noMatchingElement; - public static String CustomXmlParserInputWizardPage_preview; - public static String CustomXmlParserInputWizardPage_previewInput; - public static String CustomXmlParserInputWizardPage_removeAttribute; - public static String CustomXmlParserInputWizardPage_removeElement; - public static String CustomXmlParserInputWizardPage_set; - public static String CustomXmlParserInputWizardPage_tagName; - public static String CustomXmlParserInputWizardPage_timestampFormat; - public static String CustomXmlParserInputWizardPage_titleEdit; - public static String CustomXmlParserInputWizardPage_titleNew; - public static String CustomXmlParserOutputWizardPage_description; - public static String CustomXmlParserOutputWizardPage_moveAfter; - public static String CustomXmlParserOutputWizardPage_moveBefore; - public static String CustomXmlParserOutputWizardPage_visible; + public static String CustomTxtParserInputWizardPage_addChildLine; + public static String CustomTxtParserInputWizardPage_addGroup; + public static String CustomTxtParserInputWizardPage_addNextLine; + public static String CustomTxtParserInputWizardPage_append; + public static String CustomTxtParserInputWizardPage_appendWith; + public static String CustomTxtParserInputWizardPage_capturedGroup; + public static String CustomTxtParserInputWizardPage_cardinality; + public static String CustomTxtParserInputWizardPage_dateFormatHelp; + public static String CustomTxtParserInputWizardPage_desccriptionEdit; + public static String CustomTxtParserInputWizardPage_descriptionNew; + public static String CustomTxtParserInputWizardPage_format; + public static String CustomTxtParserInputWizardPage_group; + public static String CustomTxtParserInputWizardPage_highlightAll; + public static String CustomTxtParserInputWizardPage_logType; + public static String CustomTxtParserInputWizardPage_matchingLineRoot; + public static String CustomTxtParserInputWizardPage_matchingOtherLine; + public static String CustomTxtParserInputWizardPage_matchingRootLine; + public static String CustomTxtParserInputWizardPage_max; + public static String CustomTxtParserInputWizardPage_min; + public static String CustomTxtParserInputWizardPage_moveDown; + public static String CustomTxtParserInputWizardPage_moveUp; + public static String CustomTxtParserInputWizardPage_name; + public static String CustomTxtParserInputWizardPage_newGroup; + public static String CustomTxtParserInputWizardPage_noMatch; + public static String CustomTxtParserInputWizardPage_noMatchingGroup; + public static String CustomTxtParserInputWizardPage_noMatchingLine; + public static String CustomTxtParserInputWizardPage_noMatchingTimestamp; + public static String CustomTxtParserInputWizardPage_noMathcingLine; + public static String CustomTxtParserInputWizardPage_nonMatchingLine; + public static String CustomTxtParserInputWizardPage_noTimestampGroup; + public static String CustomTxtParserInputWizardPage_preview; + public static String CustomTxtParserInputWizardPage_previewInput; + public static String CustomTxtParserInputWizardPage_previewLegend; + public static String CustomTxtParserInputWizardPage_regularExpression; + public static String CustomTxtParserInputWizardPage_regularExpressionHelp; + public static String CustomTxtParserInputWizardPage_removeGroup; + public static String CustomTxtParserInputWizardPage_removeLine; + public static String CustomTxtParserInputWizardPage_set; + public static String CustomTxtParserInputWizardPage_timestampFormat; + public static String CustomTxtParserInputWizardPage_uncapturedText; + public static String CustomTxtParserInputWizardPage_unidentifiedCaptureGroup; + public static String CustomTxtParserInputWizardPage_windowTitleEdit; + public static String CustomTxtParserInputWizardPage_windowTitleNew; + public static String CustomTxtParserOutputWizardPage_description; + public static String CustomTxtParserOutputWizardPage_moveAfter; + public static String CustomTxtParserOutputWizardPage_moveBefore; + public static String CustomTxtParserOutputWizardPage_visible; + public static String CustomXmlParserInputWizardPage_emptyLogTypeError; + public static String CustomXmlParserInputWizardPage_duplicatelogTypeError; + public static String CustomXmlParserInputWizardPage_noDocumentError; + public static String CustomXmlParserInputWizardPage_missingLogEntryError; + public static String CustomXmlParserInputWizardPage_missingTimestampFmtError; + public static String CustomXmlParserInputWizardPage_invalidTimestampFmtError; + public static String CustomXmlParserInputWizardPage_notimestamporAttributeError; + public static String CustomXmlParserInputWizardPage_missingDocumentElementError; + public static String CustomXmlParserInputWizardPage_timestampFormatPrompt; + public static String CustomXmlParserInputWizardPage_timestampElementPrompt; + public static String CustomXmlParserInputWizardPage_missingInputElementNameError; + public static String CustomXmlParserInputWizardPage_attributePrompt; + public static String CustomXmlParserInputWizardPage_missingAttribute; + public static String CustomXmlParserInputWizardPage_duplicateAttributeError; + public static String CustomXmlParserInputWizardPage_missingTimestampInFmtError; + public static String CustomXmlParserInputWizardPage_invalidTimestampInFmtError; + public static String CustomXmlParserInputWizardPage_missingDataGroupNameError; + public static String CustomXmlParserInputWizardPage_missingElementNameError; + public static String CustomXmlParserInputWizardPage_duplicateElementNameError; + public static String CustomXmlParserInputWizardPage_addAttribute; + public static String CustomXmlParserInputWizardPage_addChildElement; + public static String CustomXmlParserInputWizardPage_addDocumentEleemnt; + public static String CustomXmlParserInputWizardPage_addDocumentElement; + public static String CustomXmlParserInputWizardPage_addNextElement; + public static String CustomXmlParserInputWizardPage_append; + public static String CustomXmlParserInputWizardPage_appendWith; + public static String CustomXmlParserInputWizardPage_attibute; + public static String CustomXmlParserInputWizardPage_dateFormatHelp; + public static String CustomXmlParserInputWizardPage_descriptionEdit; + public static String CustomXmlParserInputWizardPage_descriptionNew; + public static String CustomXmlParserInputWizardPage_elementName; + public static String CustomXmlParserInputWizardPage_feelingLucky; + public static String CustomXmlParserInputWizardPage_format; + public static String CustomXmlParserInputWizardPage_logEntry; + public static String CustomXmlParserInputWizardPage_logType; + public static String CustomXmlParserInputWizardPage_moveDown; + public static String CustomXmlParserInputWizardPage_moveUp; + public static String CustomXmlParserInputWizardPage_name; + public static String CustomXmlParserInputWizardPage_newAttibute; + public static String CustomXmlParserInputWizardPage_noMatchingAttribute; + public static String CustomXmlParserInputWizardPage_noMatch; + public static String CustomXmlParserInputWizardPage_noMatchingElement; + public static String CustomXmlParserInputWizardPage_preview; + public static String CustomXmlParserInputWizardPage_previewInput; + public static String CustomXmlParserInputWizardPage_removeAttribute; + public static String CustomXmlParserInputWizardPage_removeElement; + public static String CustomXmlParserInputWizardPage_set; + public static String CustomXmlParserInputWizardPage_tagName; + public static String CustomXmlParserInputWizardPage_timestampFormat; + public static String CustomXmlParserInputWizardPage_titleEdit; + public static String CustomXmlParserInputWizardPage_titleNew; + public static String CustomXmlParserOutputWizardPage_description; + public static String CustomXmlParserOutputWizardPage_moveAfter; + public static String CustomXmlParserOutputWizardPage_moveBefore; + public static String CustomXmlParserOutputWizardPage_visible; - public static String FilterDialog_FilterDialogTitle; - public static String FilterView_AddActionToolTipText; - public static String FilterView_DeleteActionToolTipText; - public static String FilterView_ExportActionToolTipText; - public static String FilterView_FileDialogFilterName; - public static String FilterView_ImportActionToolTipText; - public static String FilterView_SaveActionToolTipText; - public static String FilterViewer_AlphaButtonText; - public static String FilterViewer_DeleteActionText; - public static String FilterViewer_FieldLabel; - public static String FilterViewer_FilterNameHint; - public static String FilterViewer_IgnoreCaseButtonText; - public static String FilterViewer_NameLabel; - public static String FilterViewer_NewPrefix; - public static String FilterViewer_NotLabel; - public static String FilterViewer_NumButtonText; - public static String FilterViewer_RegexHint; - public static String FilterViewer_RegexLabel; - public static String FilterViewer_ResultLabel; - public static String FilterViewer_TimestampButtonText; - public static String FilterViewer_TypeLabel; - public static String FilterViewer_ValueHint; - public static String FilterViewer_ValueLabel; + public static String FilterDialog_FilterDialogTitle; + public static String FilterView_AddActionToolTipText; + public static String FilterView_DeleteActionToolTipText; + public static String FilterView_ExportActionToolTipText; + public static String FilterView_FileDialogFilterName; + public static String FilterView_ImportActionToolTipText; + public static String FilterView_SaveActionToolTipText; + public static String FilterViewer_AlphaButtonText; + public static String FilterViewer_DeleteActionText; + public static String FilterViewer_FieldLabel; + public static String FilterViewer_FilterNameHint; + public static String FilterViewer_IgnoreCaseButtonText; + public static String FilterViewer_NameLabel; + public static String FilterViewer_NewPrefix; + public static String FilterViewer_NotLabel; + public static String FilterViewer_NumButtonText; + public static String FilterViewer_RegexHint; + public static String FilterViewer_RegexLabel; + public static String FilterViewer_ResultLabel; + public static String FilterViewer_TimestampButtonText; + public static String FilterViewer_TypeLabel; + public static String FilterViewer_ValueHint; + public static String FilterViewer_ValueLabel; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } - private Messages() { - } + private Messages() { + } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/messages.properties b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/messages.properties index e6a6ddeb14..e9e0f28fc5 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/messages.properties +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/messages.properties @@ -10,6 +10,7 @@ ManageCustomParsersDialog_ImportButtonLabel=Import... ManageCustomParsersDialog_ImportParserSelection=Select custom parser file to import ManageCustomParsersDialog_NewButtonLabel=New... ManageCustomParsersDialog_ParseButtonLabel=Parse... +ManageCustomParsersDialog_ParseError=Parse Error ManageCustomParsersDialog_TextButtonLabel=Text ManageCustomParsersDialog_TraceSelection=Select log file to parse using diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/IParserProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/IParserProvider.java deleted file mode 100644 index f8678e4133..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/IParserProvider.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.parsers; - -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.linuxtools.tmf.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; -import org.eclipse.swt.widgets.Composite; - -public interface IParserProvider { - - /** - * Return the readable category name for this parser provider - * - * @return the category name - */ - public String getCategory(); - - /** - * Return a trace instance for a resource given a parser id - * - * @param parser the parser id - * @param resource the resource - * @return a trace instance or null if the parser id is not handled by this parser provider - */ - public ITmfTrace getTraceForParser(String parser, IResource resource); - - /** - * Return a trace instance for a resource given a content type id - * - * @param contentTypeId the content type id - * @param resource the resource - * @return a trace instance or null if the content type id is not handled by this parser provider - */ - public ITmfTrace getTraceForContentType(String contentTypeId, IResource resource); - - /** - * Return the parser map for this parser provider - * Map key: readable parser name - * Map value: unique parser id - * - * @return the parser map - */ - public Map getParserMap(); - - /** - * Return the event type map given a parser id - * Map key: readable event type name - * Map value: unique event type id - * - * @param parser the parser id - * @return the event type map or null if the parser id is not handled by this parser provider - */ - public Map getEventTypeMapForParser(String parser); - - /** - * Return the field label array given an event type id - * Array value: readable field label - * - * @param eventType the event type id - * @return the field label array or null if the event type id is not handled by this parser provider - */ - public String[] getFieldLabelsForEventType(String eventType); - - /** - * Return the editor id given a parser id - * - * @param parser the parser id - * @return an editor id or null to use the default trace editor - */ - public String getEditorIdForParser(String parser); - - /** - * Return an events table instance for a given trace - * - * @param parser the parser id - * @param parent the parent composite for the table - * @param cacheSize the desired cache size for the table - * @return an events table instance or null if the trace is not handled by this parser provider - */ - public TmfEventsTable getEventsTable(ITmfTrace trace, Composite parent, int cacheSize); - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/ParserProviderManager.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/ParserProviderManager.java deleted file mode 100644 index a48cd70373..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/ParserProviderManager.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.parsers; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.linuxtools.tmf.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; -import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor; -import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; -import org.eclipse.swt.widgets.Composite; - -public class ParserProviderManager { - - public static final QualifiedName PARSER_PROPERTY = new QualifiedName(TmfUiPlugin.PLUGIN_ID, "PARSER"); //$NON-NLS-1$ - - private static List fParserProviders = new ArrayList(); - - public static void init() { - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IConfigurationElement[] extensions = reg.getConfigurationElementsFor("org.eclipse.linuxtools.tmf.ui.parserProviders"); //$NON-NLS-1$ - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement element = extensions[i]; - try { - IParserProvider parserProvider = (IParserProvider) element.createExecutableExtension("class"); //$NON-NLS-1$ - addParserProvider(parserProvider); - } catch (CoreException e) { - e.printStackTrace(); - } - } - } - - public static void addParserProvider(IParserProvider parserProvider) { - fParserProviders.add(parserProvider); - } - - public static void removeParserProvider(IParserProvider parserProvider) { - fParserProviders.remove(parserProvider); - } - - public static ITmfTrace getTrace(IResource resource) { - if (resource == null) { - return null; - } - try { - String parser = resource.getPersistentProperty(PARSER_PROPERTY); - if (parser != null) { - for (IParserProvider parserProvider : fParserProviders) { - if (parserProvider != null) { - ITmfTrace trace = parserProvider.getTraceForParser(parser, resource); - if (trace != null) { - return trace; - } - } - } - } - IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(resource.getName()); - if (contentType != null) { - for (IParserProvider parserProvider : fParserProviders) { - if (parserProvider != null) { - ITmfTrace trace = parserProvider.getTraceForContentType(contentType.getId(), resource); - if (trace != null) { - resource.setPersistentProperty(PARSER_PROPERTY, trace.getClass().getCanonicalName()); - return trace; - } - } - } - } - } catch (CoreException e) { - e.printStackTrace(); - } - return null; - } - - public static String getEditorId(IResource resource) { - if (resource == null) { - return null; - } - try { - String parser = resource.getPersistentProperty(PARSER_PROPERTY); - if (parser != null) { - for (IParserProvider parserProvider : fParserProviders) { - if (parserProvider != null) { - String editorId = parserProvider.getEditorIdForParser(parser); - if (editorId != null) { - return editorId; - } - } - } - } - return TmfEventsEditor.ID; - } catch (CoreException e) { - e.printStackTrace(); - } - return null; - } - - public static Map> getParserMap() { - Map> parserMap = new LinkedHashMap>(); - for (IParserProvider parserProvider : fParserProviders) { - parserMap.put(parserProvider.getCategory(), parserProvider.getParserMap()); - } - return parserMap; - } - - public static Map getEventTypeMapForParser(String parser) { - for (IParserProvider parserProvider : fParserProviders) { - Map map = parserProvider.getEventTypeMapForParser(parser); - if (map != null) { - return map; - } - } - return new LinkedHashMap(0); - } - - public static String[] getFieldLabelsForEventType(String eventType) { - for (IParserProvider parserProvider : fParserProviders) { - String[] fieldLabels = parserProvider.getFieldLabelsForEventType(eventType); - if (fieldLabels != null) { - return fieldLabels; - } - } - return new String[0]; - } - - public static TmfEventsTable getEventsTable(ITmfTrace trace, Composite parent, int cacheSize) { - for (IParserProvider parserProvider : fParserProviders) { - if (parserProvider != null) { - TmfEventsTable eventsTable = parserProvider.getEventsTable(trace, parent, cacheSize); - if (eventsTable != null) { - return eventsTable; - } - } - } - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java index 1993bfe4d5..d6a04cf4da 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java @@ -23,6 +23,7 @@ import org.eclipse.linuxtools.tmf.event.TmfEventReference; import org.eclipse.linuxtools.tmf.event.TmfEventSource; import org.eclipse.linuxtools.tmf.event.TmfEventType; import org.eclipse.linuxtools.tmf.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn; public class CustomEvent extends TmfEvent { @@ -35,14 +36,19 @@ public class CustomEvent extends TmfEvent { protected Map fData; private String[] fColumnData; + public CustomEvent(CustomTraceDefinition definition) { + fDefinition = definition; + fData = new HashMap(); + } + public CustomEvent(CustomTraceDefinition definition, TmfEvent other) { super(other); fDefinition = definition; fData = new HashMap(); } - public CustomEvent(CustomTraceDefinition definition, TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, TmfEventReference reference) { - super(timestamp, source, type, reference); + public CustomEvent(CustomTraceDefinition definition, ITmfTrace parentTrace, TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, TmfEventReference reference) { + super(parentTrace, timestamp, source, type, reference); fDefinition = definition; fData = new HashMap(); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomParserProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomParserProvider.java deleted file mode 100644 index e89912b6d3..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomParserProvider.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.parsers.custom; - -import java.io.FileNotFoundException; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.linuxtools.tmf.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.ui.parsers.IParserProvider; -import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; -import org.eclipse.swt.widgets.Composite; - -public class CustomParserProvider implements IParserProvider { - - @Override - public String getCategory() { - return "Custom"; //$NON-NLS-1$ - } - - @Override - public ITmfTrace getTraceForParser(String parser, IResource resource) { - try { - String name = resource.getName(); - String path = resource.getLocation().toOSString(); - for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { - if (parser.equals(CustomTxtTrace.class.getCanonicalName() + "." + def.definitionName)) { //$NON-NLS-1$ - return new CustomTxtTrace(name, def, path, 100); - } - } - for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { - if (parser.equals(CustomXmlTrace.class.getCanonicalName() + "." + def.definitionName)) { //$NON-NLS-1$ - return new CustomXmlTrace(name, def, path, 100); - } - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - return null; - } - - @Override - public ITmfTrace getTraceForContentType(String contentTypeId, IResource resource) { - return null; - } - - @Override - public String getEditorIdForParser(String parser) { - return null; - } - - @Override - public Map getEventTypeMapForParser(String parser) { - for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { - if (parser.equals(CustomTxtTrace.class.getCanonicalName() + "." + def.definitionName)) { //$NON-NLS-1$ - Map eventTypeMap = new LinkedHashMap(); - eventTypeMap.put(def.definitionName, CustomTxtEventType.class.getCanonicalName() + "." + def.definitionName); //$NON-NLS-1$ - return eventTypeMap; - } - } - for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { - if (parser.equals(CustomXmlTrace.class.getCanonicalName() + "." + def.definitionName)) { //$NON-NLS-1$ - Map eventTypeMap = new LinkedHashMap(); - eventTypeMap.put(def.definitionName, CustomXmlEventType.class.getCanonicalName() + "." + def.definitionName); //$NON-NLS-1$ - return eventTypeMap; - } - } - return null; - } - - @Override - public String[] getFieldLabelsForEventType(String eventType) { - for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { - if (eventType.equals(CustomTxtEventType.class.getCanonicalName() + "." + def.definitionName)) { //$NON-NLS-1$ - String[] labels = new String[def.outputs.size()]; - for (int i = 0; i < labels.length; i++) { - labels[i] = def.outputs.get(i).name; - } - return labels; - } - } - for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { - if (eventType.equals(CustomXmlEventType.class.getCanonicalName() + "." + def.definitionName)) { //$NON-NLS-1$ - String[] labels = new String[def.outputs.size()]; - for (int i = 0; i < labels.length; i++) { - labels[i] = def.outputs.get(i).name; - } - return labels; - } - } - return null; - } - - @Override - public Map getParserMap() { - Map parserMap = new LinkedHashMap(); - for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { - parserMap.put(def.definitionName, CustomTxtTrace.class.getCanonicalName() + "." + def.definitionName); //$NON-NLS-1$ - } - for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { - parserMap.put(def.definitionName, CustomXmlTrace.class.getCanonicalName() + "." + def.definitionName); //$NON-NLS-1$ - } - return parserMap; - } - - @Override - public TmfEventsTable getEventsTable(ITmfTrace trace, Composite parent, int cacheSize) { - if (trace instanceof CustomTxtTrace) { - return new CustomEventsTable(((CustomTxtTrace) trace).getDefinition(), parent, cacheSize); - } else if (trace instanceof CustomXmlTrace) { - return new CustomEventsTable(((CustomXmlTrace) trace).getDefinition(), parent, cacheSize); - } - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEvent.java index c4ced9d578..fa6833abca 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEvent.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEvent.java @@ -19,17 +19,23 @@ import org.eclipse.linuxtools.tmf.event.TmfEventReference; import org.eclipse.linuxtools.tmf.event.TmfEventSource; import org.eclipse.linuxtools.tmf.event.TmfEventType; import org.eclipse.linuxtools.tmf.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputData; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine; public class CustomTxtEvent extends CustomEvent { + public CustomTxtEvent(CustomTxtTraceDefinition definition) { + super(definition); + fType = new CustomTxtEventType(definition); + } + public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfEvent other) { super(definition, other); } - public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, TmfEventReference reference) { - super(definition, timestamp, source, type, reference); + public CustomTxtEvent(CustomTxtTraceDefinition definition, ITmfTrace parentTrace, TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, TmfEventReference reference) { + super(definition, parentTrace, timestamp, source, type, reference); } public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source, TmfEventType type, TmfEventReference reference) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java index 110e359c3e..ff5af68620 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java @@ -40,7 +40,12 @@ public class CustomTxtTrace extends TmfTrace { private CustomTxtTraceDefinition fDefinition; private CustomTxtEventType fEventType; - + + public CustomTxtTrace(CustomTxtTraceDefinition definition) { + fDefinition = definition; + fEventType = new CustomTxtEventType(fDefinition); + } + public CustomTxtTrace(String name, CustomTxtTraceDefinition definition, String path, int cacheSize) throws FileNotFoundException { super(name, CustomTxtEvent.class, path, cacheSize); fDefinition = definition; @@ -303,7 +308,7 @@ public class CustomTxtTrace extends TmfTrace { } public CustomTxtEvent parseFirstLine(CustomTxtTraceContext context) { - CustomTxtEvent event = new CustomTxtEvent(fDefinition, TmfTimestamp.Zero, new TmfEventSource(""), fEventType, new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$ + CustomTxtEvent event = new CustomTxtEvent(fDefinition, this, TmfTimestamp.Zero, new TmfEventSource(""), fEventType, new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$ event.processGroups(context.inputLine, context.firstLineMatcher); event.setContent(new CustomEventContent(event, new StringBuffer(context.firstLine))); return event; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlEvent.java index e4d10e8e3d..a553b0b752 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlEvent.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlEvent.java @@ -17,15 +17,21 @@ import org.eclipse.linuxtools.tmf.event.TmfEventReference; import org.eclipse.linuxtools.tmf.event.TmfEventSource; import org.eclipse.linuxtools.tmf.event.TmfEventType; import org.eclipse.linuxtools.tmf.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.trace.ITmfTrace; public class CustomXmlEvent extends CustomEvent { + public CustomXmlEvent(CustomXmlTraceDefinition definition) { + super(definition); + fType = new CustomXmlEventType(definition); + } + public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfEvent other) { super(definition, other); } - public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, TmfEventReference reference) { - super(definition, timestamp, source, type, reference); + public CustomXmlEvent(CustomXmlTraceDefinition definition, ITmfTrace parentTrace, TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, TmfEventReference reference) { + super(definition, parentTrace, timestamp, source, type, reference); } public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source, TmfEventType type, TmfEventReference reference) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java index 1ca18f01b1..525a85f318 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java @@ -53,6 +53,12 @@ public class CustomXmlTrace extends TmfTrace { private CustomXmlEventType fEventType; private InputElement fRecordInputElement; + public CustomXmlTrace(CustomXmlTraceDefinition definition) { + fDefinition = definition; + fEventType = new CustomXmlEventType(fDefinition); + fRecordInputElement = getRecordInputElement(fDefinition.rootInputElement); + } + public CustomXmlTrace(String name, CustomXmlTraceDefinition definition, String path, int cacheSize) throws FileNotFoundException { super(name, CustomXmlEvent.class, path, cacheSize); fDefinition = definition; @@ -358,7 +364,7 @@ public class CustomXmlTrace extends TmfTrace { } public CustomXmlEvent extractEvent(Element element, InputElement inputElement) { - CustomXmlEvent event = new CustomXmlEvent(fDefinition, TmfTimestamp.Zero, new TmfEventSource(""), fEventType, new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$ + CustomXmlEvent event = new CustomXmlEvent(fDefinition, this, TmfTimestamp.Zero, new TmfEventSource(""), fEventType, new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$ event.setContent(new CustomEventContent(event, new StringBuffer())); parseElement(element, event, inputElement); return event; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java index 3b3de65148..6e04ad72b6 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java @@ -195,7 +195,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage { } private void updatePreviewTable() { - final int MAX_NUM_ENTRIES = 50; + final int CACHE_SIZE = 50; definition.outputs = extractOutputs(); try { @@ -204,9 +204,9 @@ public class CustomTxtParserOutputWizardPage extends WizardPage { writer.write(wizard.inputPage.getInputText()); writer.close(); - ITmfTrace trace = new CustomTxtTrace(tmpFile.getName(), definition, tmpFile.getAbsolutePath(), MAX_NUM_ENTRIES); + ITmfTrace trace = new CustomTxtTrace(tmpFile.getName(), definition, tmpFile.getAbsolutePath(), CACHE_SIZE); previewTable.dispose(); - previewTable = new CustomEventsTable(definition, tableContainer, MAX_NUM_ENTRIES); + previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE); previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); previewTable.setTrace(trace, true); } catch (FileNotFoundException e) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java index f29b5f98d8..b383336a03 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java @@ -196,7 +196,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage { } private void updatePreviewTable() { - final int MAX_NUM_ENTRIES = 50; + final int CACHE_SIZE = 50; definition.outputs = extractOutputs(); try { @@ -205,9 +205,9 @@ public class CustomXmlParserOutputWizardPage extends WizardPage { writer.write(wizard.inputPage.getInputText()); writer.close(); - ITmfTrace trace = new CustomXmlTrace(tmpFile.getName(), definition, tmpFile.getAbsolutePath(), MAX_NUM_ENTRIES); + ITmfTrace trace = new CustomXmlTrace(tmpFile.getName(), definition, tmpFile.getAbsolutePath(), CACHE_SIZE); previewTable.dispose(); - previewTable = new CustomEventsTable(definition, tableContainer, MAX_NUM_ENTRIES); + previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE); previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); previewTable.setTrace(trace, true); } catch (FileNotFoundException e) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java index bbc6f92d3e..8ca25eb18b 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java @@ -24,9 +24,13 @@ import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.TmfCorePlugin; import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTrace; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTrace; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTraceDefinition; import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.util.TmfTraceType; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; @@ -39,31 +43,38 @@ public class SelectTraceTypeContributionItem extends CompoundContributionItem { //private static final ImageDescriptor SELECTED_ICON = ImageDescriptor.createFromImage(TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/bullet.gif")); //$NON-NLS-1$ private static final ImageDescriptor SELECTED_ICON = TmfUiPlugin.getDefault().getImageDescripterFromPath( "icons/elcl16/bullet.gif"); //$NON-NLS-1$ + private static final String BUNDLE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.bundle"; //$NON-NLS-1$ + private static final String TYPE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.type"; //$NON-NLS-1$ + private static final String ICON_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.icon"; //$NON-NLS-1$ + private static final String SELECT_TRACE_TYPE_COMMAND_ID = "org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type"; //$NON-NLS-1$ + private static final String CUSTOM_TXT_CATEGORY = "Custom Text"; //$NON-NLS-1$ + private static final String CUSTOM_XML_CATEGORY = "Custom XML"; //$NON-NLS-1$ + private static final String DEFAULT_TRACE_ICON_PATH = "icons/elcl16/trace.gif"; //$NON-NLS-1$ @Override protected IContributionItem[] getContributionItems() { - final String CATEGORY_ELEMENT = "category"; //$NON-NLS-1$ - final String TYPE_ELEMENT = "type"; //$NON-NLS-1$ - final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$ - final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$ - final String BUNDLE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.bundle"; //$NON-NLS-1$ - final String TYPE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.type"; //$NON-NLS-1$ - final String ICON_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.icon"; //$NON-NLS-1$ - final String SELECT_TRACE_TYPE_COMMAND_ID = "org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type"; //$NON-NLS-1$ - - Map params; LinkedList list = new LinkedList(); HashMap categoriesMap = new HashMap(); IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor( - TmfCorePlugin.TMF_TRACE_TYPE_ID); + TmfTraceType.TMF_TRACE_TYPE_ID); for (IConfigurationElement ce : config) { - if (ce.getName().equals(CATEGORY_ELEMENT)) { - MenuManager subMenu = new MenuManager(ce.getAttribute(NAME_ATTRIBUTE)); - categoriesMap.put(ce.getAttribute(ID_ATTRIBUTE), subMenu); + if (ce.getName().equals(TmfTraceType.CATEGORY_ELEM)) { + MenuManager subMenu = new MenuManager(ce.getAttribute(TmfTraceType.NAME_ATTR)); + categoriesMap.put(ce.getAttribute(TmfTraceType.ID_ATTR), subMenu); list.add(subMenu); } } + if (CustomTxtTraceDefinition.loadAll().length > 0) { + MenuManager subMenu = new MenuManager(CUSTOM_TXT_CATEGORY); + categoriesMap.put(CUSTOM_TXT_CATEGORY, subMenu); + list.add(subMenu); + } + if (CustomXmlTraceDefinition.loadAll().length > 0) { + MenuManager subMenu = new MenuManager(CUSTOM_XML_CATEGORY); + categoriesMap.put(CUSTOM_XML_CATEGORY, subMenu); + list.add(subMenu); + } HashSet selectedTraceTypes = new HashSet(); IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); @@ -79,46 +90,77 @@ public class SelectTraceTypeContributionItem extends CompoundContributionItem { } for (IConfigurationElement ce : config) { - if (ce.getName().equals(TYPE_ELEMENT)) { + if (ce.getName().equals(TmfTraceType.TYPE_ELEM)) { String traceBundle = ce.getContributor().getName(); - String traceType = ce.getAttribute(ID_ATTRIBUTE); - String traceIcon = ce.getAttribute(TmfTraceElement.ICON); - params = new HashMap(); - params.put(BUNDLE_PARAMETER, traceBundle); - params.put(TYPE_PARAMETER, traceType); - params.put(ICON_PARAMETER, traceIcon); - - String label = ce.getAttribute(NAME_ATTRIBUTE).replaceAll("&", "&&"); //$NON-NLS-1$ //$NON-NLS-2$ - ImageDescriptor icon = null; - if (selectedTraceTypes.contains(traceType)) { - icon = SELECTED_ICON; - } + String traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR); + String traceIcon = ce.getAttribute(TmfTraceType.ICON_ATTR); + String label = ce.getAttribute(TmfTraceType.NAME_ATTR).replaceAll("&", "&&"); //$NON-NLS-1$ //$NON-NLS-2$ + boolean selected = selectedTraceTypes.contains(traceTypeId); + MenuManager subMenu = categoriesMap.get(ce.getAttribute(TmfTraceType.CATEGORY_ATTR)); - CommandContributionItemParameter param = new CommandContributionItemParameter(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow(), "my.parameterid", // id //$NON-NLS-1$ - SELECT_TRACE_TYPE_COMMAND_ID, // commandId - params, // parameters - icon, // icon - icon, // disabled icon - icon, // hover icon - label, // label - null, // mnemonic - null, // tooltip - CommandContributionItem.STYLE_PUSH, // style - null, // help context id - true // visibleEnable - ); - - MenuManager subMenu = categoriesMap.get(ce.getAttribute(TmfTraceElement.CATEGORY)); - if (subMenu != null) { - subMenu.add(new CommandContributionItem(param)); - } else { - list.add(new CommandContributionItem(param)); - } + addContributionItem(list, traceBundle, traceTypeId, traceIcon, label, selected, subMenu); } } + // add the custom trace types + for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { + String traceBundle = TmfUiPlugin.getDefault().getBundle().getSymbolicName(); + String traceTypeId = CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$ + String traceIcon = DEFAULT_TRACE_ICON_PATH; + String label = def.definitionName; + boolean selected = selectedTraceTypes.contains(traceTypeId); + MenuManager subMenu = categoriesMap.get(CUSTOM_TXT_CATEGORY); + + addContributionItem(list, traceBundle, traceTypeId, traceIcon, label, selected, subMenu); + } + for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { + String traceBundle = TmfUiPlugin.getDefault().getBundle().getSymbolicName(); + String traceTypeId = CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$ + String traceIcon = DEFAULT_TRACE_ICON_PATH; + String label = def.definitionName; + boolean selected = selectedTraceTypes.contains(traceTypeId); + MenuManager subMenu = categoriesMap.get(CUSTOM_XML_CATEGORY); + + addContributionItem(list, traceBundle, traceTypeId, traceIcon, label, selected, subMenu); + } + return list.toArray(new IContributionItem[list.size()]); } + private void addContributionItem(LinkedList list, + String traceBundle, String traceTypeId, String traceIcon, String label, boolean selected, + MenuManager subMenu) { + Map params; + + params = new HashMap(); + params.put(BUNDLE_PARAMETER, traceBundle); + params.put(TYPE_PARAMETER, traceTypeId); + params.put(ICON_PARAMETER, traceIcon); + + ImageDescriptor icon = null; + if (selected) { + icon = SELECTED_ICON; + } + + CommandContributionItemParameter param = new CommandContributionItemParameter(PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(), "my.parameterid", // id //$NON-NLS-1$ + SELECT_TRACE_TYPE_COMMAND_ID, // commandId + params, // parameters + icon, // icon + icon, // disabled icon + icon, // hover icon + label, // label + null, // mnemonic + null, // tooltip + CommandContributionItem.STYLE_PUSH, // style + null, // help context id + true // visibleEnable + ); + + if (subMenu != null) { + subMenu.add(new CommandContributionItem(param)); + } else { + list.add(new CommandContributionItem(param)); + } + } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java index 8f41f29a09..c437a2234d 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java @@ -20,9 +20,16 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.linuxtools.tmf.TmfCorePlugin; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtEvent; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTrace; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlEvent; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTrace; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTraceDefinition; +import org.eclipse.linuxtools.tmf.util.TmfTraceType; import org.eclipse.ui.IActionFilter; import org.eclipse.ui.views.properties.IPropertyDescriptor; import org.eclipse.ui.views.properties.IPropertySource2; @@ -43,19 +50,6 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi public static final QualifiedName TRACETYPE = new QualifiedName("org.eclipse.linuxtools.tmf", "tracetype.id"); //$NON-NLS-1$//$NON-NLS-2$ public static final QualifiedName TRACEICON = new QualifiedName("org.eclipse.linuxtools.tmf", "tracetype.icon"); //$NON-NLS-1$//$NON-NLS-2$ - // Extension point fields - public static final String TYPE = "type"; //$NON-NLS-1$ - public static final String ID = "id"; //$NON-NLS-1$ - public static final String CATEGORY = "category"; //$NON-NLS-1$ - public static final String NAME = "name"; //$NON-NLS-1$ - public static final String TRACE_TYPE = "trace_type"; //$NON-NLS-1$ - public static final String EVENT_TYPE = "event_type"; //$NON-NLS-1$ - public static final String ICON = "icon"; //$NON-NLS-1$ - - public static final String DEFAULT_EDITOR = "defaultEditor"; //$NON-NLS-1$ - public static final String EVENTS_TABLE_TYPE = "eventsTableType"; //$NON-NLS-1$ - public static final String CLASS = "class"; //$NON-NLS-1$ - // Other attributes public static final String BUNDLE = "bundle"; //$NON-NLS-1$ public static final String IS_LINKED = "isLinked"; //$NON-NLS-1$ @@ -102,14 +96,14 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi // Initialize statically at startup public static void init() { - IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfCorePlugin.TMF_TRACE_TYPE_ID); + IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfTraceType.TMF_TRACE_TYPE_ID); for (IConfigurationElement ce : config) { - String attribute = ce.getName(); - if (attribute.equals(TYPE)) { - String traceTypeId = ce.getAttribute(ID); + String elementName = ce.getName(); + if (elementName.equals(TmfTraceType.TYPE_ELEM)) { + String traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR); sfTraceTypeAttributes.put(traceTypeId, ce); - } else if (attribute.equals(CATEGORY)) { - String categoryId = ce.getAttribute(ID); + } else if (elementName.equals(TmfTraceType.CATEGORY_ELEM)) { + String categoryId = ce.getAttribute(TmfTraceType.ID_ATTR); sfTraceCategories.put(categoryId, ce); } } @@ -152,8 +146,22 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi public ITmfTrace instantiateTrace() { try { if (fTraceTypeId != null) { + if (fTraceTypeId.startsWith(CustomTxtTrace.class.getCanonicalName())) { + for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { + if (fTraceTypeId.equals(CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ + return new CustomTxtTrace(def); + } + } + } + if (fTraceTypeId.startsWith(CustomXmlTrace.class.getCanonicalName())) { + for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { + if (fTraceTypeId.equals(CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ + return new CustomXmlTrace(def); + } + } + } IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); - ITmfTrace trace = (ITmfTrace) ce.createExecutableExtension(TRACE_TYPE); + ITmfTrace trace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR); return trace; } } catch (CoreException e) { @@ -165,8 +173,22 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi public TmfEvent instantiateEvent() { try { if (fTraceTypeId != null) { + if (fTraceTypeId.startsWith(CustomTxtTrace.class.getCanonicalName())) { + for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { + if (fTraceTypeId.equals(CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ + return new CustomTxtEvent(def); + } + } + } + if (fTraceTypeId.startsWith(CustomXmlTrace.class.getCanonicalName())) { + for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { + if (fTraceTypeId.equals(CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ + return new CustomXmlEvent(def); + } + } + } IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); - TmfEvent event = (TmfEvent) ce.createExecutableExtension(EVENT_TYPE); + TmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR); return event; } } catch (CoreException e) { @@ -177,10 +199,16 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi public String getEditorId() { if (fTraceTypeId != null) { + if (fTraceTypeId.startsWith(CustomTxtTrace.class.getCanonicalName())) { + return TmfEventsEditor.ID; + } + if (fTraceTypeId.startsWith(CustomXmlTrace.class.getCanonicalName())) { + return TmfEventsEditor.ID; + } IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); - IConfigurationElement[] defaultEditorCE = ce.getChildren(DEFAULT_EDITOR); + IConfigurationElement[] defaultEditorCE = ce.getChildren(TmfTraceType.DEFAULT_EDITOR_ELEM); if (defaultEditorCE.length == 1) { - return defaultEditorCE[0].getAttribute(ID); + return defaultEditorCE[0].getAttribute(TmfTraceType.ID_ATTR); } } return null; @@ -251,7 +279,7 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi if (sfEventType.equals(id)) { if (fTraceTypeId != null) { IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); - return (ce != null) ? (getCategory(ce) + " : " + ce.getAttribute(NAME)) : ""; //$NON-NLS-1$ //$NON-NLS-2$ + return (ce != null) ? (getCategory(ce) + " : " + ce.getAttribute(TmfTraceType.NAME_ATTR)) : ""; //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -259,11 +287,11 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi } private String getCategory(IConfigurationElement ce) { - String categoryId = ce.getAttribute(CATEGORY); + String categoryId = ce.getAttribute(TmfTraceType.CATEGORY_ATTR); if (categoryId != null) { IConfigurationElement category = sfTraceCategories.get(categoryId); - if (category != null && !category.equals("")) { //$NON-NLS-1$ - return category.getAttribute(NAME); + if (category != null) { + return category.getAttribute(TmfTraceType.NAME_ATTR); } } return "[no category]"; //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java index c8962bfaca..2649ebf983 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java @@ -43,12 +43,16 @@ import org.eclipse.jface.viewers.CheckboxTreeViewer; import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.linuxtools.tmf.TmfCorePlugin; import org.eclipse.linuxtools.tmf.TmfProjectNature; import org.eclipse.linuxtools.tmf.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTrace; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTrace; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTraceDefinition; import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.linuxtools.tmf.util.TmfTraceType; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.events.FocusEvent; @@ -98,6 +102,9 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L // ------------------------------------------------------------------------ static private final String IMPORT_WIZARD_PAGE = "ImportTraceWizardPage"; //$NON-NLS-1$ + private static final String CUSTOM_TXT_CATEGORY = "Custom Text"; //$NON-NLS-1$ + private static final String CUSTOM_XML_CATEGORY = "Custom XML"; //$NON-NLS-1$ + private static final String DEFAULT_TRACE_ICON_PATH = "icons/elcl16/trace.gif"; //$NON-NLS-1$ // ------------------------------------------------------------------------ // Attributes @@ -539,14 +546,14 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L private String[] getAvailableTraceTypes() { // Populate the Categories and Trace Types - IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfCorePlugin.TMF_TRACE_TYPE_ID); + IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfTraceType.TMF_TRACE_TYPE_ID); for (IConfigurationElement ce : config) { - String attribute = ce.getName(); - if (attribute.equals(TmfTraceElement.TYPE)) { - String traceTypeId = ce.getAttribute(TmfTraceElement.ID); + String elementName = ce.getName(); + if (elementName.equals(TmfTraceType.TYPE_ELEM)) { + String traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR); fTraceTypeAttributes.put(traceTypeId, ce); - } else if (attribute.equals(TmfTraceElement.CATEGORY)) { - String categoryId = ce.getAttribute(TmfTraceElement.ID); + } else if (elementName.equals(TmfTraceType.CATEGORY_ELEM)) { + String categoryId = ce.getAttribute(TmfTraceType.ID_ATTR); fTraceCategories.put(categoryId, ce); } } @@ -555,26 +562,32 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L List traceTypes = new ArrayList(); for (String typeId : fTraceTypeAttributes.keySet()) { IConfigurationElement ce = fTraceTypeAttributes.get(typeId); - String traceTypeName = getCategory(ce) + " : " + ce.getAttribute(TmfTraceElement.NAME); //$NON-NLS-1$ + String traceTypeName = getCategory(ce) + " : " + ce.getAttribute(TmfTraceType.NAME_ATTR); //$NON-NLS-1$ fTraceAttributes.put(traceTypeName, ce); traceTypes.add(traceTypeName); } Collections.sort(traceTypes); - // TODO: Add Custom Parsers + // add the custom trace types + for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { + String traceTypeName = CUSTOM_TXT_CATEGORY + " : " + def.definitionName; //$NON-NLS-1$ + traceTypes.add(traceTypeName); + } + for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { + String traceTypeName = CUSTOM_XML_CATEGORY + " : " + def.definitionName; //$NON-NLS-1$ + traceTypes.add(traceTypeName); + } // Format result - String[] result = new String[traceTypes.size()]; - result = traceTypes.toArray(result); - return result; + return traceTypes.toArray(new String[0]); } private String getCategory(IConfigurationElement ce) { - String categoryId = ce.getAttribute(TmfTraceElement.CATEGORY); + String categoryId = ce.getAttribute(TmfTraceType.CATEGORY_ATTR); if (categoryId != null) { IConfigurationElement category = fTraceCategories.get(categoryId); if (category != null && !category.equals("")) { //$NON-NLS-1$ - return category.getAttribute(TmfTraceElement.NAME); + return category.getAttribute(TmfTraceType.NAME_ATTR); } } return "[no category]"; //$NON-NLS-1$ @@ -654,13 +667,15 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L // Perform trace validation String traceTypeName = fTraceTypes.getText(); - if (traceTypeName != null && !"".equals(traceTypeName)) { //$NON-NLS-1$ + if (traceTypeName != null && !"".equals(traceTypeName) && //$NON-NLS-1$ + !traceTypeName.startsWith(CUSTOM_TXT_CATEGORY) && !traceTypeName.startsWith(CUSTOM_XML_CATEGORY)) { + List traces = isolateTraces(); for (File trace : traces) { - IConfigurationElement ce = fTraceAttributes.get(traceTypeName); ITmfTrace tmfTrace = null; try { - tmfTrace = (ITmfTrace) ce.createExecutableExtension(TmfTraceElement.TRACE_TYPE); + IConfigurationElement ce = fTraceAttributes.get(traceTypeName); + tmfTrace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR); if (!tmfTrace.validate(fProject, trace.getAbsolutePath())) { setMessage(null); setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed); @@ -749,9 +764,42 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L if (fileSystemObjects.size() > 0) { boolean ok = importResources(sourceDirPath, fileSystemObjects); + String traceBundle = null; + String traceTypeId = null; + String traceIcon = null; String traceType = fTraceTypes.getText(); - IConfigurationElement ce = fTraceAttributes.get(traceType); - if (ok && !traceType.equals("") && ce != null) { //$NON-NLS-1$ + if (traceType.startsWith(CUSTOM_TXT_CATEGORY)) { + ok = false; + for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { + if (traceType.equals(CUSTOM_TXT_CATEGORY + " : " + def.definitionName)) { //$NON-NLS-1$ + ok = true; + traceBundle = TmfUiPlugin.getDefault().getBundle().getSymbolicName(); + traceTypeId = CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$ + traceIcon = DEFAULT_TRACE_ICON_PATH; + break; + } + } + } else if (traceType.startsWith(CUSTOM_XML_CATEGORY)) { + for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { + if (traceType.equals(CUSTOM_XML_CATEGORY + " : " + def.definitionName)) { //$NON-NLS-1$ + ok = true; + traceBundle = TmfUiPlugin.getDefault().getBundle().getSymbolicName(); + traceTypeId = CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$ + traceIcon = DEFAULT_TRACE_ICON_PATH; + break; + } + } + } else { + IConfigurationElement ce = fTraceAttributes.get(traceType); + if (ce != null) { + traceBundle = ce.getContributor().getName(); + traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR); + traceIcon = ce.getAttribute(TmfTraceType.ICON_ATTR); + } else { + ok = false; + } + } + if (ok && !traceType.equals("")) { //$NON-NLS-1$ // Tag the selected traces with their type List files = new ArrayList(fileSystemObjects.keySet()); Collections.sort(files); @@ -766,9 +814,9 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L if (resource != null) { try { // Set the trace properties for this resource - resource.setPersistentProperty(TmfTraceElement.TRACEBUNDLE, ce.getContributor().getName()); - resource.setPersistentProperty(TmfTraceElement.TRACETYPE, ce.getAttribute(TmfTraceElement.ID)); - resource.setPersistentProperty(TmfTraceElement.TRACEICON, ce.getAttribute(TmfTraceElement.ICON)); + resource.setPersistentProperty(TmfTraceElement.TRACEBUNDLE, traceBundle); + resource.setPersistentProperty(TmfTraceElement.TRACETYPE, traceTypeId); + resource.setPersistentProperty(TmfTraceElement.TRACEICON, traceIcon); } catch (CoreException e) { e.printStackTrace(); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java index db8a97f804..1d15d9dc80 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java @@ -17,6 +17,8 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; @@ -28,6 +30,8 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.linuxtools.tmf.event.TmfEvent; +import org.eclipse.linuxtools.tmf.event.TmfEventType; import org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode; import org.eclipse.linuxtools.tmf.filter.model.TmfFilterAndNode; import org.eclipse.linuxtools.tmf.filter.model.TmfFilterCompareNode; @@ -40,7 +44,14 @@ import org.eclipse.linuxtools.tmf.filter.model.TmfFilterNode; import org.eclipse.linuxtools.tmf.filter.model.TmfFilterOrNode; import org.eclipse.linuxtools.tmf.filter.model.TmfFilterRootNode; import org.eclipse.linuxtools.tmf.ui.internal.Messages; -import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtEvent; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTrace; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlEvent; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTrace; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTraceDefinition; +import org.eclipse.linuxtools.tmf.util.TmfTraceType; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.events.FocusEvent; @@ -64,907 +75,999 @@ import org.eclipse.swt.widgets.TreeItem; class FilterViewer extends Composite { - private static final Map> EVENT_TYPES_MAP; - static { - Map> eventTypesMap = new LinkedHashMap>(); - for (Entry> categoryEntry : ParserProviderManager.getParserMap().entrySet()) { - for (Entry parserEntry : categoryEntry.getValue().entrySet()) { - String prefix = categoryEntry.getKey() + " - " + parserEntry.getKey() + " - "; //$NON-NLS-1$ //$NON-NLS-2$ - for (Entry eventTypeEntry : ParserProviderManager.getEventTypeMapForParser(parserEntry.getValue()).entrySet()) { - eventTypesMap.put(prefix + eventTypeEntry.getKey(), eventTypeEntry); - } - } - } - EVENT_TYPES_MAP = eventTypesMap; - } - - private static final String[] FIELDS_LIST; - static { - ArrayList fieldsList = new ArrayList(); - for (Entry> categoryEntry : ParserProviderManager.getParserMap().entrySet()) { - for (Entry parserEntry : categoryEntry.getValue().entrySet()) { - fieldsList.add(""); //$NON-NLS-1$ - fieldsList.add("["+ categoryEntry.getKey() +" - " + parserEntry.getKey() +"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - for (String eventType : ParserProviderManager.getEventTypeMapForParser(parserEntry.getValue()).values()) { - for (String field : ParserProviderManager.getFieldLabelsForEventType(eventType)) { - fieldsList.add(field); - } - } - } - } - FIELDS_LIST = fieldsList.toArray(new String[0]); - } - + private static final String CUSTOM_TXT_CATEGORY = "Custom Text"; //$NON-NLS-1$ + private static final String CUSTOM_XML_CATEGORY = "Custom XML"; //$NON-NLS-1$ + private TreeViewer fViewer; private Composite fComposite; - public FilterViewer(Composite parent, int style) { - super(parent, style); + public FilterViewer(Composite parent, int style) { + super(parent, style); - setLayout(new FillLayout()); - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); - setLayoutData(gd); - + 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 = new TreeViewer(sash, SWT.NONE); - 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(); - gl.marginHeight = 0; - gl.marginWidth = 0; - fComposite.setLayout(gl); + // Create the tree viewer to display the filter tree + fViewer = new TreeViewer(sash, SWT.NONE); + 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(); + gl.marginHeight = 0; + gl.marginWidth = 0; + fComposite.setLayout(gl); - createContextMenu(); - - fViewer.addSelectionChangedListener(new ISelectionChangedListener() { - @Override + createContextMenu(); + + fViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override public void selectionChanged(SelectionChangedEvent event) { - if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) { - // Update the filter node properties panel to the selection - IStructuredSelection selection = (IStructuredSelection) event.getSelection(); - ITmfFilterTreeNode node = (ITmfFilterTreeNode) selection.getFirstElement(); - updateFilterNodeComposite(node); - // Highlight the selection's children - highlightTreeItems(fViewer.getTree().getSelection()[0].getItems()); - } else { - updateFilterNodeComposite(null); - } - } - }); - } - - /** - * Create the context menu for the tree viewer - */ - private void createContextMenu() { - // Adds root context menu - MenuManager menuManager = new MenuManager(); - menuManager.setRemoveAllWhenShown(true); - menuManager.addMenuListener(new IMenuListener() { - @Override + if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) { + // Update the filter node properties panel to the selection + IStructuredSelection selection = (IStructuredSelection) event.getSelection(); + ITmfFilterTreeNode node = (ITmfFilterTreeNode) selection.getFirstElement(); + updateFilterNodeComposite(node); + // Highlight the selection's children + highlightTreeItems(fViewer.getTree().getSelection()[0].getItems()); + } else { + updateFilterNodeComposite(null); + } + } + }); + } + + /** + * Create the context menu for the tree viewer + */ + private void createContextMenu() { + // Adds root context menu + MenuManager menuManager = new MenuManager(); + menuManager.setRemoveAllWhenShown(true); + menuManager.addMenuListener(new IMenuListener() { + @Override public void menuAboutToShow(IMenuManager manager) { - fillContextMenu(manager); - } - }); + fillContextMenu(manager); + } + }); - // Context - Menu contextMenu = menuManager.createContextMenu(fViewer.getTree()); + // Context + Menu contextMenu = menuManager.createContextMenu(fViewer.getTree()); - // Publish it - fViewer.getTree().setMenu(contextMenu); - } - - /** - * Fill the context menu for the tree viewer - */ - protected void fillContextMenu(IMenuManager manager) { - final ISelection selection = fViewer.getSelection(); - ITmfFilterTreeNode filterTreeNode = null; - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - if (element instanceof ITmfFilterTreeNode) { - filterTreeNode = (ITmfFilterTreeNode) element; - } - } + // Publish it + fViewer.getTree().setMenu(contextMenu); + } + + /** + * Fill the context menu for the tree viewer + */ + protected void fillContextMenu(IMenuManager manager) { + final ISelection selection = fViewer.getSelection(); + ITmfFilterTreeNode filterTreeNode = null; + if (selection instanceof StructuredSelection) { + Object element = ((StructuredSelection) selection).getFirstElement(); + if (element instanceof ITmfFilterTreeNode) { + filterTreeNode = (ITmfFilterTreeNode) element; + } + } - final ITmfFilterTreeNode selectedNode = filterTreeNode; - - if (selectedNode != null) { - - fillContextMenuForNode(selectedNode, manager); - - if (selectedNode.getValidChildren().size() > 0) { - manager.add(new Separator()); - } + final ITmfFilterTreeNode selectedNode = filterTreeNode; + + if (selectedNode != null) { + + fillContextMenuForNode(selectedNode, manager); + + if (selectedNode.getValidChildren().size() > 0) { + manager.add(new Separator()); + } - Action deleteAction = new Action() { - @Override - public void run() { - selectedNode.remove(); - fViewer.refresh(); - } - }; - deleteAction.setText(Messages.FilterViewer_DeleteActionText); - manager.add(deleteAction); - - manager.add(new Separator()); - } + Action deleteAction = new Action() { + @Override + public void run() { + selectedNode.remove(); + fViewer.refresh(); + } + }; + 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 - */ - protected void fillContextMenuForNode(final ITmfFilterTreeNode node, IMenuManager manager) { - for (final String child : node.getValidChildren()) { - final Action action = new Action() { - @Override - public void run() { - ITmfFilterTreeNode newNode = null; - if (TmfFilterNode.NODE_NAME.equals(child)) { - newNode = new TmfFilterNode(node, ""); //$NON-NLS-1$ - } else if (TmfFilterEventTypeNode.NODE_NAME.equals(child)) { - newNode = new TmfFilterEventTypeNode(node); - } else if (TmfFilterAndNode.NODE_NAME.equals(child)) { - newNode = new TmfFilterAndNode(node); - } else if (TmfFilterOrNode.NODE_NAME.equals(child)) { - newNode = new TmfFilterOrNode(node); - } else if (TmfFilterContainsNode.NODE_NAME.equals(child)) { - newNode = new TmfFilterContainsNode(node); - } else if (TmfFilterEqualsNode.NODE_NAME.equals(child)) { - newNode = new TmfFilterEqualsNode(node); - } else if (TmfFilterMatchesNode.NODE_NAME.equals(child)) { - newNode = new TmfFilterMatchesNode(node); - } else if (TmfFilterCompareNode.NODE_NAME.equals(child)) { - newNode = new TmfFilterCompareNode(node); - } - if (newNode != null) { - fViewer.refresh(); - fViewer.setSelection(new StructuredSelection(newNode), true); - } - } - }; - if (TmfFilterNode.NODE_NAME.equals(child)) { - action.setText(Messages.FilterViewer_NewPrefix + " " + child); //$NON-NLS-1$ - } else { - action.setText(child); - } - manager.add(action); - } - } - - /** - * Create the appropriate filter node properties composite - */ - private void updateFilterNodeComposite(ITmfFilterTreeNode node) { - for (Control control : fComposite.getChildren()) { - control.dispose(); - } - - if (node instanceof TmfFilterNode) { - new FilterNodeComposite(fComposite, (TmfFilterNode) node); - } else if (node instanceof TmfFilterEventTypeNode) { - new FilterEventTypeNodeComposite(fComposite, (TmfFilterEventTypeNode) node); - } else if (node instanceof TmfFilterAndNode) { - new FilterAndNodeComposite(fComposite, (TmfFilterAndNode) node); - } else if (node instanceof TmfFilterOrNode) { - new FilterOrNodeComposite(fComposite, (TmfFilterOrNode) node); - } else if (node instanceof TmfFilterContainsNode) { - new FilterContainsNodeComposite(fComposite, (TmfFilterContainsNode) node); - } else if (node instanceof TmfFilterEqualsNode) { - new FilterEqualsNodeComposite(fComposite, (TmfFilterEqualsNode) node); - } else if (node instanceof TmfFilterMatchesNode) { - new FilterMatchesNodeComposite(fComposite, (TmfFilterMatchesNode) node); - } else if (node instanceof TmfFilterCompareNode) { - new FilterCompareNodeComposite(fComposite, (TmfFilterCompareNode) node); - } else { - new FilterBaseNodeComposite(fComposite); - } - fComposite.layout(); - } - - /** - * Highlight the provided tree items - */ - private void highlightTreeItems(TreeItem[] items) { - resetTreeItems(fViewer.getTree().getItems()); - for (TreeItem item : items) { - item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE)); - } + 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 + */ + protected void fillContextMenuForNode(final ITmfFilterTreeNode node, IMenuManager manager) { + for (final String child : node.getValidChildren()) { + final Action action = new Action() { + @Override + public void run() { + ITmfFilterTreeNode newNode = null; + if (TmfFilterNode.NODE_NAME.equals(child)) { + newNode = new TmfFilterNode(node, ""); //$NON-NLS-1$ + } else if (TmfFilterEventTypeNode.NODE_NAME.equals(child)) { + newNode = new TmfFilterEventTypeNode(node); + } else if (TmfFilterAndNode.NODE_NAME.equals(child)) { + newNode = new TmfFilterAndNode(node); + } else if (TmfFilterOrNode.NODE_NAME.equals(child)) { + newNode = new TmfFilterOrNode(node); + } else if (TmfFilterContainsNode.NODE_NAME.equals(child)) { + newNode = new TmfFilterContainsNode(node); + } else if (TmfFilterEqualsNode.NODE_NAME.equals(child)) { + newNode = new TmfFilterEqualsNode(node); + } else if (TmfFilterMatchesNode.NODE_NAME.equals(child)) { + newNode = new TmfFilterMatchesNode(node); + } else if (TmfFilterCompareNode.NODE_NAME.equals(child)) { + newNode = new TmfFilterCompareNode(node); + } + if (newNode != null) { + fViewer.refresh(); + fViewer.setSelection(new StructuredSelection(newNode), true); + } + } + }; + if (TmfFilterNode.NODE_NAME.equals(child)) { + action.setText(Messages.FilterViewer_NewPrefix + " " + child); //$NON-NLS-1$ + } else { + action.setText(child); + } + manager.add(action); + } + } + + /** + * Create the appropriate filter node properties composite + */ + private void updateFilterNodeComposite(ITmfFilterTreeNode node) { + for (Control control : fComposite.getChildren()) { + control.dispose(); + } + + if (node instanceof TmfFilterNode) { + new FilterNodeComposite(fComposite, (TmfFilterNode) node); + } else if (node instanceof TmfFilterEventTypeNode) { + new FilterEventTypeNodeComposite(fComposite, (TmfFilterEventTypeNode) node); + } else if (node instanceof TmfFilterAndNode) { + new FilterAndNodeComposite(fComposite, (TmfFilterAndNode) node); + } else if (node instanceof TmfFilterOrNode) { + new FilterOrNodeComposite(fComposite, (TmfFilterOrNode) node); + } else if (node instanceof TmfFilterContainsNode) { + new FilterContainsNodeComposite(fComposite, (TmfFilterContainsNode) node); + } else if (node instanceof TmfFilterEqualsNode) { + new FilterEqualsNodeComposite(fComposite, (TmfFilterEqualsNode) node); + } else if (node instanceof TmfFilterMatchesNode) { + new FilterMatchesNodeComposite(fComposite, (TmfFilterMatchesNode) node); + } else if (node instanceof TmfFilterCompareNode) { + new FilterCompareNodeComposite(fComposite, (TmfFilterCompareNode) node); + } else { + new FilterBaseNodeComposite(fComposite); + } + fComposite.layout(); + } + + /** + * Highlight the provided tree items + */ + private void highlightTreeItems(TreeItem[] items) { + resetTreeItems(fViewer.getTree().getItems()); + for (TreeItem item : items) { + item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE)); + } - } - - /** - * Reset the provided tree items (remove highlight) - */ - private void resetTreeItems(TreeItem[] items) { - for (TreeItem item : items) { - item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - 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(); - } + } + + /** + * Reset the provided tree items (remove highlight) + */ + private void resetTreeItems(TreeItem[] items) { + for (TreeItem item : items) { + item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + 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, boolean reveal) { - fViewer.setSelection(new StructuredSelection(node), reveal); - } + public void setSelection(ITmfFilterTreeNode node, boolean reveal) { + fViewer.setSelection(new StructuredSelection(node), reveal); + } - public void setSelection(ITmfFilterTreeNode node) { - fViewer.setSelection(new StructuredSelection(node)); - } - - public ITmfFilterTreeNode getSelection() { - final ISelection selection = fViewer.getSelection(); - ITmfFilterTreeNode filterTreeNode = null; - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - if (element instanceof ITmfFilterTreeNode) { - filterTreeNode = (ITmfFilterTreeNode) element; - } - } + public void setSelection(ITmfFilterTreeNode node) { + fViewer.setSelection(new StructuredSelection(node)); + } + + public ITmfFilterTreeNode getSelection() { + final ISelection selection = fViewer.getSelection(); + ITmfFilterTreeNode filterTreeNode = null; + if (selection instanceof StructuredSelection) { + Object element = ((StructuredSelection) selection).getFirstElement(); + if (element instanceof ITmfFilterTreeNode) { + filterTreeNode = (ITmfFilterTreeNode) element; + } + } - 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) { - while (node != null) { - if (node instanceof TmfFilterEventTypeNode) { - TmfFilterEventTypeNode eventTypeNode = (TmfFilterEventTypeNode) node; - return ParserProviderManager.getFieldLabelsForEventType(eventTypeNode.getEventType()); - } - node = node.getParent(); - } - return FIELDS_LIST; - } - } + 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 fieldsList = new ArrayList(); + while (node != null) { + if (node instanceof TmfFilterEventTypeNode) { + TmfFilterEventTypeNode eventTypeNode = (TmfFilterEventTypeNode) node; + for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { + if (ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR).equals(eventTypeNode.getEventType())) { + try { + TmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR); + TmfEventType eventType = event.getType(); + if (eventType != null) { + for (String field : eventType.getLabels()) { + fieldsList.add(field); + } + } + } catch (CoreException e) { + } + return fieldsList.toArray(new String[0]); + } + } + if (eventTypeNode.getEventType().startsWith(CustomTxtEvent.class.getCanonicalName())) { + for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { + if (eventTypeNode.getEventType().equals(CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ + for (OutputColumn output : def.outputs) { + fieldsList.add(output.name); + } + return fieldsList.toArray(new String[0]); + } + } + } + if (eventTypeNode.getEventType().startsWith(CustomXmlEvent.class.getCanonicalName())) { + for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { + if (eventTypeNode.getEventType().equals(CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ + for (OutputColumn output : def.outputs) { + fieldsList.add(output.name); + } + return fieldsList.toArray(new String[0]); + } + } + } + } + node = node.getParent(); + } + for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { + try { + TmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR); + TmfEventType eventType = event.getType(); + if (eventType != null) { + fieldsList.add("[" + TmfTraceType.getCategoryName(ce.getAttribute(TmfTraceType.CATEGORY_ATTR)) + //$NON-NLS-1$ + " : " + ce.getAttribute(TmfTraceType.NAME_ATTR) + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + for (String field : eventType.getLabels()) { + fieldsList.add(field); + } + fieldsList.add(""); //$NON-NLS-1$ + } + } catch (CoreException e) { + } + } + for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { + fieldsList.add("[" + CUSTOM_TXT_CATEGORY + //$NON-NLS-1$ + " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + for (OutputColumn output : def.outputs) { + fieldsList.add(output.name); + } + fieldsList.add(""); //$NON-NLS-1$ + } + for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { + fieldsList.add("[" + CUSTOM_XML_CATEGORY + //$NON-NLS-1$ + " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + for (OutputColumn output : def.outputs) { + fieldsList.add(output.name); + } + fieldsList.add(""); //$NON-NLS-1$ + } + return fieldsList.toArray(new String[0]); + } + } - 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) { - fNameText.setText(node.getFilterName()); - } else { - fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - fNameText.setText(Messages.FilterViewer_FilterNameHint); - } - fNameText.addFocusListener(new FocusListener() { - @Override + 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) { + fNameText.setText(node.getFilterName()); + } else { + fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + fNameText.setText(Messages.FilterViewer_FilterNameHint); + } + fNameText.addFocusListener(new FocusListener() { + @Override public void focusLost(FocusEvent e) { - if (fNode.getFilterName() == null || fNode.getFilterName().length() == 0) { - fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - fNameText.setText(Messages.FilterViewer_FilterNameHint); - } - } - @Override + if (fNode.getFilterName() == null || fNode.getFilterName().length() == 0) { + fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + fNameText.setText(Messages.FilterViewer_FilterNameHint); + } + } + @Override public void focusGained(FocusEvent e) { - if (fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { - fNameText.setText(""); //$NON-NLS-1$ - } - fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - } - }); - fNameText.addModifyListener(new ModifyListener() { - @Override + if (fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { + fNameText.setText(""); //$NON-NLS-1$ + } + fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + } + }); + fNameText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { - if (! fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { - fNode.setFilterName(fNameText.getText()); - fViewer.refresh(fNode); - } - } - }); - } - } + if (! fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { + fNode.setFilterName(fNameText.getText()); + fViewer.refresh(fNode); + } + } + }); + } + } - private class FilterEventTypeNodeComposite extends FilterBaseNodeComposite { - TmfFilterEventTypeNode fNode; - Combo fTypeCombo; - - FilterEventTypeNodeComposite(Composite parent, TmfFilterEventTypeNode node) { - super(parent); - fNode = node; + private class FilterEventTypeNodeComposite extends FilterBaseNodeComposite { + TmfFilterEventTypeNode fNode; + Combo fTypeCombo; + Map fEventsTypeMap; + + FilterEventTypeNodeComposite(Composite parent, TmfFilterEventTypeNode node) { + super(parent); + fNode = node; + fEventsTypeMap = getEventsTypeMap(); - 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(EVENT_TYPES_MAP.keySet().toArray(new String[0])); - if (fNode.getEventType() != null) { - for (Entry > eventTypeEntry : EVENT_TYPES_MAP.entrySet()) { - if (eventTypeEntry.getValue().getValue().equals(fNode.getEventType())) { - fTypeCombo.setText(eventTypeEntry.getKey()); - } - } - } - fTypeCombo.addModifyListener(new ModifyListener() { - @Override + 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])); + if (fNode.getEventType() != null) { + for (Entry eventTypeEntry : fEventsTypeMap.entrySet()) { + Object value = eventTypeEntry.getValue(); + if (value instanceof IConfigurationElement) { + IConfigurationElement ce = (IConfigurationElement) value; + if (ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR).equals(fNode.getEventType())) { + fTypeCombo.setText(eventTypeEntry.getKey()); + } + } else if (value instanceof CustomTxtTraceDefinition) { + CustomTxtTraceDefinition def = (CustomTxtTraceDefinition) value; + String eventType = CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$ + if (eventType.equals(fNode.getEventType())) { + fTypeCombo.setText(eventTypeEntry.getKey()); + } + } else if (value instanceof CustomXmlTraceDefinition) { + CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) value; + String eventType = CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$ + if (eventType.equals(fNode.getEventType())) { + fTypeCombo.setText(eventTypeEntry.getKey()); + } + } + } + } + fTypeCombo.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { - for (Entry > eventTypeEntry : EVENT_TYPES_MAP.entrySet()) { - if (eventTypeEntry.getKey().equals(fTypeCombo.getText())) { - fNode.setEventType(eventTypeEntry.getValue().getValue()); - fNode.setName(eventTypeEntry.getValue().getKey()); - fViewer.refresh(fNode); - break; - } - } - } - }); - } - } - - 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.setSelection(fNode.isNot()); - fNotButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fNode.setNot(fNotButton.getSelection()); - fViewer.refresh(fNode); - } - }); - } - } + for (Entry eventTypeEntry : fEventsTypeMap.entrySet()) { + if (eventTypeEntry.getKey().equals(fTypeCombo.getText())) { + Object value = eventTypeEntry.getValue(); + if (value instanceof IConfigurationElement) { + IConfigurationElement ce = (IConfigurationElement) value; + fNode.setEventType(ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR)); + fNode.setName(ce.getAttribute(TmfTraceType.NAME_ATTR)); + } else if (value instanceof CustomTxtTraceDefinition) { + CustomTxtTraceDefinition def = (CustomTxtTraceDefinition) value; + fNode.setEventType(CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName); //$NON-NLS-1$ + fNode.setName(def.definitionName); + } else if (value instanceof CustomXmlTraceDefinition) { + CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) value; + fNode.setEventType(CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName); //$NON-NLS-1$ + fNode.setName(def.definitionName); + } + fViewer.refresh(fNode); + break; + } + } + } + }); + } + + protected Map getEventsTypeMap() { + Map eventsTypeMap = new LinkedHashMap(); + for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { + String categoryName = TmfTraceType.getCategoryName(ce.getAttribute(TmfTraceType.CATEGORY_ATTR)); + String text = categoryName + " : " + ce.getAttribute(TmfTraceType.NAME_ATTR); //$NON-NLS-1$ + eventsTypeMap.put(text, ce); + } + for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { + String text = CUSTOM_TXT_CATEGORY + " : " + def.definitionName; //$NON-NLS-1$ + eventsTypeMap.put(text, def); + } + for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { + String text = CUSTOM_XML_CATEGORY + " : " + def.definitionName; //$NON-NLS-1$ + eventsTypeMap.put(text, def); + } + 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()); + fNotButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fNode.setNot(fNotButton.getSelection()); + fViewer.refresh(fNode); + } + }); + } + } - 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.setSelection(fNode.isNot()); - fNotButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fNode.setNot(fNotButton.getSelection()); - fViewer.refresh(fNode); - } - }); - } - } - - 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.setSelection(fNode.isNot()); - fNotButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fNode.setNot(fNotButton.getSelection()); - 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)); - if (fNode.getField() != null) { - fFieldCombo.setText(fNode.getField()); - } - fFieldCombo.addModifyListener(new ModifyListener() { - @Override + 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()); + fNotButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fNode.setNot(fNotButton.getSelection()); + fViewer.refresh(fNode); + } + }); + } + } + + 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()); + fNotButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fNode.setNot(fNotButton.getSelection()); + 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)); + if (fNode.getField() != null) { + fFieldCombo.setText(fNode.getField()); + } + fFieldCombo.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { - fNode.setField(fFieldCombo.getText()); - 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) { - fValueText.setText(node.getValue()); - } else { - fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - fValueText.setText(Messages.FilterViewer_ValueHint); - } - fValueText.addFocusListener(new FocusListener() { - @Override + fNode.setField(fFieldCombo.getText()); + 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) { + fValueText.setText(node.getValue()); + } else { + fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + fValueText.setText(Messages.FilterViewer_ValueHint); + } + fValueText.addFocusListener(new FocusListener() { + @Override public void focusLost(FocusEvent e) { - if (fNode.getValue() == null || fNode.getValue().length() == 0) { - fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - fValueText.setText(Messages.FilterViewer_ValueHint); - } - } - @Override + if (fNode.getValue() == null || fNode.getValue().length() == 0) { + fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + fValueText.setText(Messages.FilterViewer_ValueHint); + } + } + @Override public void focusGained(FocusEvent e) { - if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { - fValueText.setText(""); //$NON-NLS-1$ - } - fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - } - }); - fValueText.addModifyListener(new ModifyListener() { - @Override + if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { + fValueText.setText(""); //$NON-NLS-1$ + } + fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + } + }); + fValueText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { - if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { - fNode.setValue(fValueText.getText()); - fViewer.refresh(fNode); - } - } - }); - - 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); - fIgnoreCaseButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - fIgnoreCaseButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fNode.setIgnoreCase(fIgnoreCaseButton.getSelection()); - fViewer.refresh(fNode); - } - }); - } - } + if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { + fNode.setValue(fValueText.getText()); + fViewer.refresh(fNode); + } + } + }); + + 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); + fIgnoreCaseButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + fIgnoreCaseButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fNode.setIgnoreCase(fIgnoreCaseButton.getSelection()); + fViewer.refresh(fNode); + } + }); + } + } - private class FilterEqualsNodeComposite extends FilterBaseNodeComposite { - TmfFilterEqualsNode fNode; - Button fNotButton; - 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.setSelection(fNode.isNot()); - fNotButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fNode.setNot(fNotButton.getSelection()); - 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)); - if (fNode.getField() != null) { - fFieldCombo.setText(fNode.getField()); - } - fFieldCombo.addModifyListener(new ModifyListener() { - @Override + private class FilterEqualsNodeComposite extends FilterBaseNodeComposite { + TmfFilterEqualsNode fNode; + Button fNotButton; + 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()); + fNotButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fNode.setNot(fNotButton.getSelection()); + 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)); + if (fNode.getField() != null) { + fFieldCombo.setText(fNode.getField()); + } + fFieldCombo.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { - fNode.setField(fFieldCombo.getText()); - 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) { - fValueText.setText(node.getValue()); - } else { - fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - fValueText.setText(Messages.FilterViewer_ValueHint); - } - fValueText.addFocusListener(new FocusListener() { - @Override + fNode.setField(fFieldCombo.getText()); + 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) { + fValueText.setText(node.getValue()); + } else { + fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + fValueText.setText(Messages.FilterViewer_ValueHint); + } + fValueText.addFocusListener(new FocusListener() { + @Override public void focusLost(FocusEvent e) { - if (fNode.getValue() == null || fNode.getValue().length() == 0) { - fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - fValueText.setText(Messages.FilterViewer_ValueHint); - } - } - @Override + if (fNode.getValue() == null || fNode.getValue().length() == 0) { + fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + fValueText.setText(Messages.FilterViewer_ValueHint); + } + } + @Override public void focusGained(FocusEvent e) { - if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { - fValueText.setText(""); //$NON-NLS-1$ - } - fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - } - }); - fValueText.addModifyListener(new ModifyListener() { - @Override + if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { + fValueText.setText(""); //$NON-NLS-1$ + } + fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + } + }); + fValueText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { - if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { - fNode.setValue(fValueText.getText()); - fViewer.refresh(fNode); - } - } - }); - - 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); - fIgnoreCaseButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - fIgnoreCaseButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fNode.setIgnoreCase(fIgnoreCaseButton.getSelection()); - fViewer.refresh(fNode); - } - }); - } - } + if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { + fNode.setValue(fValueText.getText()); + fViewer.refresh(fNode); + } + } + }); + + 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); + fIgnoreCaseButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + fIgnoreCaseButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fNode.setIgnoreCase(fIgnoreCaseButton.getSelection()); + fViewer.refresh(fNode); + } + }); + } + } - private class FilterMatchesNodeComposite extends FilterBaseNodeComposite { - TmfFilterMatchesNode fNode; - 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.setSelection(fNode.isNot()); - fNotButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fNode.setNot(fNotButton.getSelection()); - 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)); - if (fNode.getField() != null) { - fFieldCombo.setText(fNode.getField()); - } - fFieldCombo.addModifyListener(new ModifyListener() { - @Override + private class FilterMatchesNodeComposite extends FilterBaseNodeComposite { + TmfFilterMatchesNode fNode; + 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()); + fNotButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fNode.setNot(fNotButton.getSelection()); + 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)); + if (fNode.getField() != null) { + fFieldCombo.setText(fNode.getField()); + } + fFieldCombo.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { - fNode.setField(fFieldCombo.getText()); - 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) { - fRegexText.setText(node.getRegex()); - } else { - fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - fRegexText.setText(Messages.FilterViewer_RegexHint); - } - fRegexText.addFocusListener(new FocusListener() { - @Override + fNode.setField(fFieldCombo.getText()); + 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) { + fRegexText.setText(node.getRegex()); + } else { + fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + fRegexText.setText(Messages.FilterViewer_RegexHint); + } + fRegexText.addFocusListener(new FocusListener() { + @Override public void focusLost(FocusEvent e) { - if (fNode.getRegex() == null || fNode.getRegex().length() == 0) { - fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - fRegexText.setText(Messages.FilterViewer_RegexHint); - } - } - @Override + if (fNode.getRegex() == null || fNode.getRegex().length() == 0) { + fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + fRegexText.setText(Messages.FilterViewer_RegexHint); + } + } + @Override public void focusGained(FocusEvent e) { - if (fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { - fRegexText.setText(""); //$NON-NLS-1$ - } - fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - } - }); - fRegexText.addModifyListener(new ModifyListener() { - @Override + if (fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { + fRegexText.setText(""); //$NON-NLS-1$ + } + fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + } + }); + fRegexText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { - if (! fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { - fNode.setRegex(fRegexText.getText()); - fViewer.refresh(fNode); - } - } - }); - } - } + if (! fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { + fNode.setRegex(fRegexText.getText()); + fViewer.refresh(fNode); + } + } + }); + } + } - private class FilterCompareNodeComposite extends FilterBaseNodeComposite { - TmfFilterCompareNode fNode; - Button fNotButton; - Combo fFieldCombo; - Text fValueText; - Button fLTButton; - Button fEQButton; - Button fGTButton; - 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.setSelection(fNode.isNot()); - fNotButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fNode.setNot(fNotButton.getSelection()); - 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)); - if (fNode.getField() != null) { - fFieldCombo.setText(fNode.getField()); - } - fFieldCombo.addModifyListener(new ModifyListener() { - @Override + private class FilterCompareNodeComposite extends FilterBaseNodeComposite { + TmfFilterCompareNode fNode; + Button fNotButton; + Combo fFieldCombo; + Text fValueText; + Button fLTButton; + Button fEQButton; + Button fGTButton; + 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()); + fNotButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fNode.setNot(fNotButton.getSelection()); + 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)); + if (fNode.getField() != null) { + fFieldCombo.setText(fNode.getField()); + } + fFieldCombo.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { - fNode.setField(fFieldCombo.getText()); - 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$ - fLTButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - fLTButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (fLTButton.getSelection()) { - fNode.setResult(-1); - } - fViewer.refresh(fNode); - } - }); - - fEQButton = new Button(resultGroup, SWT.RADIO); - fEQButton.setSelection(fNode.getResult() == 0); - fEQButton.setText("="); //$NON-NLS-1$ - fEQButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - fEQButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (fEQButton.getSelection()) { - fNode.setResult(0); - } - fViewer.refresh(fNode); - } - }); - - fGTButton = new Button(resultGroup, SWT.RADIO); - fGTButton.setSelection(fNode.getResult() > 0); - fGTButton.setText(">"); //$NON-NLS-1$ - fGTButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - fGTButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (fGTButton.getSelection()) { - fNode.setResult(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); - fNumButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - fNumButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (fNumButton.getSelection()) { - fNode.setType(Type.NUM); - } - fViewer.refresh(fNode); - } - }); - - fAlphaButton = new Button(typeGroup, SWT.RADIO); - fAlphaButton.setSelection(fNode.getType() == Type.ALPHA); - fAlphaButton.setText(Messages.FilterViewer_AlphaButtonText); - fAlphaButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - fAlphaButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (fAlphaButton.getSelection()) { - fNode.setType(Type.ALPHA); - } - fViewer.refresh(fNode); - } - }); - - fTimestampButton = new Button(typeGroup, SWT.RADIO); - fTimestampButton.setSelection(fNode.getType() == Type.TIMESTAMP); - fTimestampButton.setText(Messages.FilterViewer_TimestampButtonText); - fTimestampButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - fTimestampButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (fTimestampButton.getSelection()) { - fNode.setType(Type.TIMESTAMP); - } - 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) { - fValueText.setText(node.getValue()); - } else { - fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - fValueText.setText(Messages.FilterViewer_ValueHint); - } - fValueText.addFocusListener(new FocusListener() { - @Override + fNode.setField(fFieldCombo.getText()); + 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$ + fLTButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + fLTButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (fLTButton.getSelection()) { + fNode.setResult(-1); + } + fViewer.refresh(fNode); + } + }); + + fEQButton = new Button(resultGroup, SWT.RADIO); + fEQButton.setSelection(fNode.getResult() == 0); + fEQButton.setText("="); //$NON-NLS-1$ + fEQButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + fEQButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (fEQButton.getSelection()) { + fNode.setResult(0); + } + fViewer.refresh(fNode); + } + }); + + fGTButton = new Button(resultGroup, SWT.RADIO); + fGTButton.setSelection(fNode.getResult() > 0); + fGTButton.setText(">"); //$NON-NLS-1$ + fGTButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + fGTButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (fGTButton.getSelection()) { + fNode.setResult(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); + fNumButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + fNumButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (fNumButton.getSelection()) { + fNode.setType(Type.NUM); + } + fViewer.refresh(fNode); + } + }); + + fAlphaButton = new Button(typeGroup, SWT.RADIO); + fAlphaButton.setSelection(fNode.getType() == Type.ALPHA); + fAlphaButton.setText(Messages.FilterViewer_AlphaButtonText); + fAlphaButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + fAlphaButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (fAlphaButton.getSelection()) { + fNode.setType(Type.ALPHA); + } + fViewer.refresh(fNode); + } + }); + + fTimestampButton = new Button(typeGroup, SWT.RADIO); + fTimestampButton.setSelection(fNode.getType() == Type.TIMESTAMP); + fTimestampButton.setText(Messages.FilterViewer_TimestampButtonText); + fTimestampButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + fTimestampButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (fTimestampButton.getSelection()) { + fNode.setType(Type.TIMESTAMP); + } + 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) { + fValueText.setText(node.getValue()); + } else { + fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + fValueText.setText(Messages.FilterViewer_ValueHint); + } + fValueText.addFocusListener(new FocusListener() { + @Override public void focusLost(FocusEvent e) { - if (fNode.getValue() == null || fNode.getValue().length() == 0) { - fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - fValueText.setText(Messages.FilterViewer_ValueHint); - } - } - @Override + if (fNode.getValue() == null || fNode.getValue().length() == 0) { + fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + fValueText.setText(Messages.FilterViewer_ValueHint); + } + } + @Override public void focusGained(FocusEvent e) { - if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { - fValueText.setText(""); //$NON-NLS-1$ - } - fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - } - }); - fValueText.addModifyListener(new ModifyListener() { - @Override + if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { + fValueText.setText(""); //$NON-NLS-1$ + } + fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + } + }); + fValueText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { - if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { - fNode.setValue(fValueText.getText()); - fViewer.refresh(fNode); - } - } - }); - } - } + if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { + fNode.setValue(fValueText.getText()); + fViewer.refresh(fNode); + } + } + }); + } + } } diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java index 9c8393220e..949ac5b330 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java @@ -29,7 +29,6 @@ public class TmfCorePlugin extends Plugin { // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf"; //$NON-NLS-1$ - public static final String TMF_TRACE_TYPE_ID = "org.eclipse.linuxtools.tmf.tracetype"; //$NON-NLS-1$ // The shared instance private static TmfCorePlugin fPlugin; diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java index 8f8ebc1d39..be395743de 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java @@ -43,7 +43,7 @@ public class TmfEvent extends TmfData implements Cloneable { // Attributes // ------------------------------------------------------------------------ - protected ITmfTrace fParentTrace; + protected ITmfTrace fParentTrace; protected long fEventRank; protected TmfTimestamp fEffectiveTimestamp; protected TmfTimestamp fOriginalTimestamp; @@ -60,13 +60,14 @@ public class TmfEvent extends TmfData implements Cloneable { // ------------------------------------------------------------------------ /** + * @param trace the parent trace * @param originalTS the original timestamp * @param effectiveTS the effective timestamp * @param source the event source (generator) * @param type the event type * @param reference a free-form reference field */ - public TmfEvent(ITmfTrace trace, long rank, TmfTimestamp originalTS, TmfTimestamp effectiveTS, + public TmfEvent(ITmfTrace trace, long rank, TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source, TmfEventType type, TmfEventReference reference) { fParentTrace = trace; @@ -91,6 +92,19 @@ public class TmfEvent extends TmfData implements Cloneable { this(null, -1, originalTS, effectiveTS, source, type, reference); } + /** + * @param trace the parent trace + * @param timestamp the effective timestamp + * @param source the event source (generator) + * @param type the event type + * @param reference a free-form reference field + */ + public TmfEvent(ITmfTrace parentTrace, TmfTimestamp timestamp, TmfEventSource source, + TmfEventType type, TmfEventReference reference) + { + this(parentTrace, -1, timestamp, timestamp, source, type, reference); + } + /** * @param timestamp the effective timestamp * @param source the event source (generator) @@ -136,7 +150,7 @@ public class TmfEvent extends TmfData implements Cloneable { /** * @return the parent trace */ - public ITmfTrace getParentTrace() { + public ITmfTrace getParentTrace() { return fParentTrace; } diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventContent.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventContent.java index 09b77807ad..bd9f701e31 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventContent.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventContent.java @@ -20,11 +20,11 @@ package org.eclipse.linuxtools.tmf.event; public class TmfEventContent implements Cloneable { // Default field ids - public static final String FIELD_ID_TIMESTAMP = "$time$"; //$NON-NLS-1$ - public static final String FIELD_ID_SOURCE = "$sour$"; //$NON-NLS-1$ - public static final String FIELD_ID_TYPE = "$type$"; //$NON-NLS-1$ - public static final String FIELD_ID_REFERENCE = "$refe$"; //$NON-NLS-1$ - public static final String FIELD_ID_CONTENT = "$cont$"; //$NON-NLS-1$ + public static final String FIELD_ID_TIMESTAMP = ":timestamp:"; //$NON-NLS-1$ + public static final String FIELD_ID_SOURCE = ":source:"; //$NON-NLS-1$ + public static final String FIELD_ID_TYPE = ":type:"; //$NON-NLS-1$ + public static final String FIELD_ID_REFERENCE = ":reference:"; //$NON-NLS-1$ + public static final String FIELD_ID_CONTENT = ":content:"; //$NON-NLS-1$ // ------------------------------------------------------------------------ // Attributes @@ -105,28 +105,28 @@ public class TmfEventContent implements Cloneable { * @return the corresponding field * @throws TmfNoSuchFieldException */ - public Object getField(String id) throws TmfNoSuchFieldException { - if (fFields == null) { - parseContent(); - } - try { - return fFields[getType().getFieldIndex(id)]; + public Object getField(String id) throws TmfNoSuchFieldException { + if (fFields == null) { + parseContent(); + } + try { + return fFields[getType().getFieldIndex(id)]; } catch (TmfNoSuchFieldException e) { - // Required for filtering from default TmfEventsTable columns - if (id.equals(FIELD_ID_TIMESTAMP)) { - return new Long(fParentEvent.getTimestamp().getValue()).toString(); - } else if (id.equals(FIELD_ID_SOURCE)) { - return fParentEvent.getSource().getSourceId().toString(); - } else if (id.equals(FIELD_ID_TYPE)) { - return fParentEvent.getType().getTypeId().toString(); - } else if (id.equals(FIELD_ID_REFERENCE)) { - return fParentEvent.getReference().getReference().toString(); - } else if (id.equals(FIELD_ID_CONTENT)) { - return fParentEvent.getContent().toString(); - } - throw e; + // Required for filtering from default TmfEventsTable columns + if (id.equals(FIELD_ID_CONTENT)) { + return fParentEvent.getContent().toString(); + } else if (id.equals(FIELD_ID_TIMESTAMP)) { + return new Long(fParentEvent.getTimestamp().getValue()).toString(); + } else if (id.equals(FIELD_ID_SOURCE)) { + return fParentEvent.getSource().getSourceId().toString(); + } else if (id.equals(FIELD_ID_TYPE)) { + return fParentEvent.getType().getTypeId().toString(); + } else if (id.equals(FIELD_ID_REFERENCE)) { + return fParentEvent.getReference().getReference().toString(); + } + throw e; } - } + } /** * @param n the field index as per TmfEventType.getLabels() diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/filter/model/TmfFilterEventTypeNode.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/filter/model/TmfFilterEventTypeNode.java index d2cadd30cb..66ea2571e1 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/filter/model/TmfFilterEventTypeNode.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/filter/model/TmfFilterEventTypeNode.java @@ -52,19 +52,32 @@ public class TmfFilterEventTypeNode extends TmfFilterTreeNode { this.fName = name; } - @Override - public boolean matches(TmfEvent event) { - if (event.getType().getTypeId().equals(fName)) { - // There should be at most one child - for (ITmfFilterTreeNode node : getChildren()) { - if (! node.matches(event)) { - return false; - } - } - return true; - } - return false; - } + @Override + public boolean matches(TmfEvent event) { + boolean match = false; + if (fType.contains(":")) { //$NON-NLS-1$ + // special case for custom parsers + if (fType.startsWith(event.getClass().getCanonicalName())) { + if (fType.endsWith(event.getType().getTypeId())) { + match = true; + } + } + } else { + if (event.getClass().getCanonicalName().equals(fType)) { + match = true; + } + } + if (match) { + // There should be at most one child + for (ITmfFilterTreeNode node : getChildren()) { + if (! node.matches(event)) { + return false; + } + } + return true; + } + return false; + } @Override public List getValidChildren() { diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/util/TmfTraceType.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/util/TmfTraceType.java new file mode 100644 index 0000000000..748e46752f --- /dev/null +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/util/TmfTraceType.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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: + * Patrick Tasse - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.util; + +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; + +public class TmfTraceType { + + // Extension point ID + public static final String TMF_TRACE_TYPE_ID = "org.eclipse.linuxtools.tmf.tracetype"; //$NON-NLS-1$ + + // Extension point elements + public static final String CATEGORY_ELEM = "category"; //$NON-NLS-1$ + public static final String TYPE_ELEM = "type"; //$NON-NLS-1$ + public static final String DEFAULT_EDITOR_ELEM = "defaultEditor"; //$NON-NLS-1$ + public static final String EVENTS_TABLE_TYPE_ELEM = "eventsTableType"; //$NON-NLS-1$ + + // Extension point attributes + public static final String ID_ATTR = "id"; //$NON-NLS-1$ + public static final String NAME_ATTR = "name"; //$NON-NLS-1$ + public static final String CATEGORY_ATTR = "category"; //$NON-NLS-1$ + public static final String TRACE_TYPE_ATTR = "trace_type"; //$NON-NLS-1$ + public static final String EVENT_TYPE_ATTR = "event_type"; //$NON-NLS-1$ + public static final String ICON_ATTR = "icon"; //$NON-NLS-1$ + public static final String CLASS_ATTR = "class"; //$NON-NLS-1$ + + public static String getCategoryName(String categoryId) { + IConfigurationElement[] elements = Platform.getExtensionRegistry() + .getConfigurationElementsFor(TMF_TRACE_TYPE_ID); + for (IConfigurationElement element : elements) { + if (element.getName().equals(CATEGORY_ELEM) && categoryId.equals(element.getAttribute(ID_ATTR))) { + return element.getAttribute(NAME_ATTR); + } + } + return ""; //$NON-NLS-1$ + } + + public static IConfigurationElement[] getTypeElements() { + IConfigurationElement[] elements = Platform.getExtensionRegistry() + .getConfigurationElementsFor(TMF_TRACE_TYPE_ID); + List typeElements = new LinkedList(); + for (IConfigurationElement element : elements) { + if (element.getName().equals(TYPE_ELEM)) { + typeElements.add(element); + } + } + return typeElements.toArray(new IConfigurationElement[0]); + } +}