Remove UI dependencies in tmf.core.
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tue, 14 May 2013 22:36:41 +0000 (18:36 -0400)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Thu, 16 May 2013 15:50:03 +0000 (11:50 -0400)
Change-Id: I6b031a39e519b6347c8ae1dede967aad4eb069e3
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/12844
Tested-by: Hudson CI
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
22 files changed:
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/BaseEventPropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/KernelProviderPropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TargetNodePropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TraceChannelPropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TraceDomainPropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TraceEventPropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TraceProbeEventPropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TraceSessionPropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/UstProviderPropertySource.java
org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java [deleted file]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/ReadOnlyTextPropertyDescriptor.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Activator.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentElement.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentFolder.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceFolder.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/ReadOnlyTextPropertyDescriptor.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventAdapterFactory.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventPropertySource.java [new file with mode: 0644]

index 1021bf8041ae7c460d84bbe9c02f76432607ee8a..f31007d9e4bd7635421c73a4940c41c535343171 100644 (file)
@@ -7,8 +7,8 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Bernd Hufmann - Initial API and implementation
- *   Bernd Hufmann - Updated for support of LTTng Tools 2.1
+ *     Bernd Hufmann - Initial API and implementation
+ *     Bernd Hufmann - Updated for support of LTTng Tools 2.1
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
 
@@ -18,7 +18,7 @@ import java.util.List;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 
 /**
index d09396745659529479822883eb61992fda5bfd40..8a9d2ba763f2ec4217a018ad2444055558f9d6df 100644 (file)
@@ -7,13 +7,13 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Bernd Hufmann - Initial API and implementation
+ *     Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
 
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.KernelProviderComponent;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 
 /**
index a4c586d86e2f0202fdb75b5f79acaf7a4d422cf9..96c67d5e12ef17fb0bf74875b7ba9c3bff61e725 100644 (file)
@@ -7,13 +7,13 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Bernd Hufmann - Initial API and implementation
+ *     Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
 
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 
 /**
index f6eb24ca0d6ef768131fbb45caf792d3f3f25052..544c7fa221111758f41c5e754d30edb7492d0dec 100644 (file)
@@ -7,13 +7,13 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Bernd Hufmann - Initial API and implementation
+ *     Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
 
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 
 /**
index 8e5de7f7a76ca738df14b68406a531200cfad416..b0ad41e2406aa31d7389991e25fe288be683ff3f 100644 (file)
@@ -7,13 +7,13 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Bernd Hufmann - Initial API and implementation
+ *     Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
 
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 
 /**
index 51f3d14e2ce6bcd080f73e518c77366ea9292f2a..de98bf2ee2818ba1ece91b4af7893924bdd75c00 100644 (file)
@@ -7,8 +7,8 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Bernd Hufmann - Initial API and implementation
- *   Bernd Hufmann - Updated for support of LTTng Tools 2.1
+ *     Bernd Hufmann - Initial API and implementation
+ *     Bernd Hufmann - Updated for support of LTTng Tools 2.1
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
 
@@ -18,7 +18,7 @@ import java.util.List;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 
 /**
index 4f07ff9c70880589986fb06ae94a01efd19147cf..6811199711933e7c54c87451152a3eb656598f75 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Bernd Hufmann - Initial API and implementation
+ *     Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
 
@@ -18,7 +18,7 @@ import java.util.List;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProbeEventComponent;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 
 /**
index ef6cab63253ba4bc9accd00b1d1f232c5e08d77d..96c7e8f26db7825f68c23fb87175fab8c9e98735 100644 (file)
@@ -7,13 +7,13 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Bernd Hufmann - Initial API and implementation
+ *     Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
 
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 
 /**
index 1bb4f518b7558b764f3271e9bfdcbbca5498bf33..2024346a85de7e106b08da62aa1838c4e466034d 100644 (file)
@@ -7,13 +7,13 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Bernd Hufmann - Initial API and implementation
+ *     Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
 
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderComponent;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 
 /**
index 6e60aff4bba5c594530a45d4233ebf907c7ea72c..270c4fa4a12f344fafbd6e8f1a9ae9c6e0847b24 100644 (file)
@@ -10,8 +10,6 @@ Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.core.resources,
- org.eclipse.jface,
- org.eclipse.ui.views,
  org.eclipse.linuxtools.ctf.core;bundle-version="2.0.0"
 Export-Package: org.eclipse.linuxtools.internal.tmf.core;x-friends:="org.eclipse.linuxtools.tmf.core.tests",
  org.eclipse.linuxtools.internal.tmf.core.component;x-friends:="org.eclipse.linuxtools.tmf.core.tests",
index 1b3a609d62c52e75d3dfebb69e73f7d6ec7905c5..ae002a0cc9a2b3ef3ff71ac7d519c58ece5c2663 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011-2013 Ericsson
+ * Copyright (c) 20112013 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are made
  * available under the terms of the Eclipse Public License v1.0 which
@@ -23,11 +23,9 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventPropertySource;
 import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfModelLookup;
 import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfSourceLookup;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.ui.views.properties.IPropertySource;
 
 /**
  * A wrapper class around CTF's Event Definition/Declaration that maps all
@@ -211,14 +209,4 @@ public final class CtfTmfEvent extends TmfEvent
         return getCustomAttribute(CtfConstants.MODEL_URI_KEY);
     }
 
-    /**
-     * @since 2.0
-     */
-    @Override
-    public Object getAdapter(Class adapter) {
-        if (adapter == IPropertySource.class) {
-            return new TmfEventPropertySource(this);
-        }
-        return null;
-    }
 }
index 7f1cb30defa5c19f9f45f07d4e3147ade2ad76ba..0a1763a8641ac04be7369a40cba0452fda629c1a 100644 (file)
@@ -7,17 +7,17 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Francois Chouinard - Initial API and implementation
- *   Francois Chouinard - Updated as per TMF Event Model 1.0
- *   Alexandre Montplaisir - Made immutable
+ *     Francois Chouinard - Initial API and implementation
+ *     Francois Chouinard - Updated as per TMF Event Model 1.0
+ *     Alexandre Montplaisir - Made immutable
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.event;
 
+import org.eclipse.core.runtime.PlatformObject;
 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.ui.views.properties.IPropertySource;
 
 /**
  * A basic implementation of ITmfEvent.
@@ -29,8 +29,8 @@ import org.eclipse.ui.views.properties.IPropertySource;
  * @see ITmfEventType
  * @see ITmfEventField
  * @see ITmfTrace
-*/
-public class TmfEvent implements ITmfEvent {
+ */
+public class TmfEvent extends PlatformObject implements ITmfEvent {
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -246,14 +246,4 @@ public class TmfEvent implements ITmfEvent {
                 + "]";
     }
 
-    /**
-     * @since 2.0
-     */
-    @Override
-    public Object getAdapter(Class adapter) {
-        if (adapter == IPropertySource.class) {
-            return new TmfEventPropertySource(this);
-        }
-        return null;
-    }
 }
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
deleted file mode 100644 (file)
index 539d10d..0000000
+++ /dev/null
@@ -1,347 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Patrick Tasse - Initial API and implementation
- *   Bernd Hufmann - Added call site and model URI properties
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.event;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfModelLookup;
-import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfSourceLookup;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * Property source for events
- *
- * @since 2.0
- */
-public class TmfEventPropertySource implements IPropertySource {
-
-    private static final String ID_TIMESTAMP = "event_timestamp"; //$NON-NLS-1$
-    private static final String ID_SOURCE = "event_source"; //$NON-NLS-1$
-    private static final String ID_TYPE = "event_type"; //$NON-NLS-1$
-    private static final String ID_REFERENCE = "event_reference"; //$NON-NLS-1$
-    private static final String ID_CONTENT = "event_content"; //$NON-NLS-1$
-    private static final String ID_SOURCE_LOOKUP = "event_lookup"; //$NON-NLS-1$
-    private static final String ID_MODEL_URI = "model_uri"; //$NON-NLS-1$
-    private static final String ID_CUSTOM_ATTRIBUTE = "custom_attribute"; //$NON-NLS-1$
-
-    private static final String NAME_TIMESTAMP = "Timestamp"; //$NON-NLS-1$
-    private static final String NAME_SOURCE = "Source"; //$NON-NLS-1$
-    private static final String NAME_TYPE = "Type"; //$NON-NLS-1$
-    private static final String NAME_REFERENCE = "Reference"; //$NON-NLS-1$
-    private static final String NAME_CONTENT = "Content"; //$NON-NLS-1$
-    private static final String NAME_SOURCE_LOOKUP = "Source Lookup"; //$NON-NLS-1$
-    private static final String NAME_MODEL_URI = "Model URI"; //$NON-NLS-1$
-    private static final String NAME_CUSTOM_ATTRIBUTES = "Custom Attributes"; //$NON-NLS-1$
-
-    private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
-    private ITmfEvent fEvent;
-
-    private class TimestampPropertySource implements IPropertySource {
-        private static final String ID_TIMESTAMP_VALUE = "timestamp_value"; //$NON-NLS-1$
-        private static final String ID_TIMESTAMP_SCALE = "timestamp_scale"; //$NON-NLS-1$
-        private static final String ID_TIMESTAMP_PRECISION = "timestamp_precision"; //$NON-NLS-1$
-        private static final String NAME_TIMESTAMP_VALUE = "value"; //$NON-NLS-1$
-        private static final String NAME_TIMESTAMP_SCALE = "scale"; //$NON-NLS-1$
-        private static final String NAME_TIMESTAMP_PRECISION = "precision"; //$NON-NLS-1$
-
-        private ITmfTimestamp fTimestamp;
-
-        public TimestampPropertySource(ITmfTimestamp timestamp) {
-            fTimestamp = timestamp;
-        }
-
-        @Override
-        public Object getEditableValue() {
-            return fTimestamp.toString();
-        }
-
-        @Override
-        public IPropertyDescriptor[] getPropertyDescriptors() {
-            IPropertyDescriptor[] descriptors = new IPropertyDescriptor[3];
-            descriptors[0] = new ReadOnlyTextPropertyDescriptor(ID_TIMESTAMP_VALUE, NAME_TIMESTAMP_VALUE);
-            descriptors[1] = new ReadOnlyTextPropertyDescriptor(ID_TIMESTAMP_SCALE, NAME_TIMESTAMP_SCALE);
-            descriptors[2] = new ReadOnlyTextPropertyDescriptor(ID_TIMESTAMP_PRECISION, NAME_TIMESTAMP_PRECISION);
-            return descriptors;
-        }
-
-        @Override
-        public Object getPropertyValue(Object id) {
-            if (id.equals(ID_TIMESTAMP_VALUE)) {
-                return Long.toString(fTimestamp.getValue());
-            } else if (id.equals(ID_TIMESTAMP_SCALE)) {
-                return Integer.toString(fTimestamp.getScale());
-            } else if (id.equals(ID_TIMESTAMP_PRECISION)) {
-                return Integer.toString(fTimestamp.getPrecision());
-            }
-            return null;
-        }
-
-        @Override
-        public boolean isPropertySet(Object id) {
-            return false;
-        }
-
-        @Override
-        public void resetPropertyValue(Object id) {
-        }
-
-        @Override
-        public void setPropertyValue(Object id, Object value) {
-        }
-    }
-
-    private class ContentPropertySource implements IPropertySource {
-        private ITmfEventField fContent;
-
-        public ContentPropertySource(ITmfEventField content) {
-            fContent = content;
-        }
-
-        @Override
-        public Object getEditableValue() {
-            return fContent.toString();
-        }
-
-        @Override
-        public IPropertyDescriptor[] getPropertyDescriptors() {
-            List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>(fContent.getFields().length);
-            for (ITmfEventField field : fContent.getFields()) {
-                if (field != null) {
-                    descriptors.add(new ReadOnlyTextPropertyDescriptor(field, field.getName()));
-                }
-            }
-            return descriptors.toArray(new IPropertyDescriptor[0]);
-        }
-
-        @Override
-        public Object getPropertyValue(Object id) {
-            ITmfEventField field = (ITmfEventField) id;
-            if (field.getFields() != null && field.getFields().length > 0) {
-                return new ContentPropertySource(field);
-            }
-            return field.getFormattedValue();
-        }
-
-        @Override
-        public boolean isPropertySet(Object id) {
-            return false;
-        }
-
-        @Override
-        public void resetPropertyValue(Object id) {
-        }
-
-        @Override
-        public void setPropertyValue(Object id, Object value) {
-        }
-    }
-
-    private class SourceLookupPropertySource implements IPropertySource {
-
-        private static final String ID_FILE_NAME = "callsite_file"; //$NON-NLS-1$
-        private static final String ID_FUNCTION_NAME = "callsite_function"; //$NON-NLS-1$
-        private static final String ID_LINE_NUMBER = "callsite_line"; //$NON-NLS-1$
-
-        private static final String NAME_FILE_NAME = "File"; //$NON-NLS-1$
-        private static final String NAME_FUNCTION_NAME = "Function"; //$NON-NLS-1$
-        private static final String NAME_LINE_NUMBER = "Line"; //$NON-NLS-1$
-
-        final private ITmfSourceLookup fSourceLookup;
-
-        public SourceLookupPropertySource(ITmfSourceLookup lookup) {
-            fSourceLookup = lookup;
-        }
-
-        @Override
-        public Object getEditableValue() {
-            if (fSourceLookup.getCallsite() != null) {
-                return fSourceLookup.getCallsite().toString();
-            }
-            return null;
-        }
-
-        @Override
-        public IPropertyDescriptor[] getPropertyDescriptors() {
-            List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>();
-            if (fSourceLookup.getCallsite() != null) {
-                descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_FILE_NAME, NAME_FILE_NAME));
-                descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_LINE_NUMBER, NAME_LINE_NUMBER));
-                // only display function if available
-                if (fSourceLookup.getCallsite().getFunctionName() != null) {
-                    descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_FUNCTION_NAME, NAME_FUNCTION_NAME));
-                }
-            }
-            return descriptors.toArray(new IPropertyDescriptor[0]);
-        }
-
-        @Override
-        public Object getPropertyValue(Object id) {
-            if  (id.equals(ID_FILE_NAME)) {
-                return fSourceLookup.getCallsite().getFileName();
-            } else if (id.equals(ID_FUNCTION_NAME)) {
-                return fSourceLookup.getCallsite().getFunctionName();
-            } else if (id.equals(ID_LINE_NUMBER)) {
-                return Long.valueOf(fSourceLookup.getCallsite().getLineNumber());
-            }
-            return null;
-        }
-
-        @Override
-        public boolean isPropertySet(Object id) {
-            return false;
-        }
-
-        @Override
-        public void resetPropertyValue(Object id) {
-
-        }
-
-        @Override
-        public void setPropertyValue(Object id, Object value) {
-        }
-    }
-
-    private class CustomAttributePropertySource implements IPropertySource {
-
-        private final ITmfCustomAttributes event;
-
-        public CustomAttributePropertySource(ITmfCustomAttributes event) {
-            this.event = event;
-        }
-
-        @Override
-        public Object getEditableValue() {
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public IPropertyDescriptor[] getPropertyDescriptors() {
-            List<IPropertyDescriptor> descriptors = new ArrayList<IPropertyDescriptor>();
-
-            for (String customAttribute : event.listCustomAttributes()) {
-                descriptors.add(new ReadOnlyTextPropertyDescriptor(customAttribute, customAttribute));
-            }
-
-            return descriptors.toArray(new IPropertyDescriptor[0]);
-        }
-
-        @Override
-        public Object getPropertyValue(Object id) {
-            return event.getCustomAttribute((String) id);
-        }
-
-        @Override
-        public boolean isPropertySet(Object id) {
-            return false;
-        }
-
-        @Override
-        public void resetPropertyValue(Object id) {
-        }
-
-        @Override
-        public void setPropertyValue(Object id, Object value) {
-        }
-    }
-
-    /**
-     * Default constructor
-     *
-     * @param event the event
-     */
-    public TmfEventPropertySource(ITmfEvent event) {
-        super();
-        this.fEvent = event;
-    }
-
-    @Override
-    public Object getEditableValue() {
-        return null;
-    }
-
-    @Override
-    public IPropertyDescriptor[] getPropertyDescriptors() {
-        List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>();
-
-        /* Display basic event information */
-        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_TIMESTAMP, NAME_TIMESTAMP));
-        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_SOURCE, NAME_SOURCE));
-        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_TYPE, NAME_TYPE));
-        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_REFERENCE, NAME_REFERENCE));
-
-        /* Display event fields */
-        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_CONTENT, NAME_CONTENT));
-
-        /* Display source lookup information, if the event supplies it */
-        if ((fEvent instanceof ITmfSourceLookup) && (((ITmfSourceLookup)fEvent).getCallsite() != null)) {
-            descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_SOURCE_LOOKUP, NAME_SOURCE_LOOKUP));
-        }
-
-        /* Display Model URI information, if the event supplies it */
-        if ((fEvent instanceof ITmfModelLookup) && (((ITmfModelLookup) fEvent).getModelUri() != null)) {
-            descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_MODEL_URI, NAME_MODEL_URI));
-        }
-
-        /* Display custom attributes, if available */
-        if (fEvent instanceof ITmfCustomAttributes) {
-            ITmfCustomAttributes event = (ITmfCustomAttributes) fEvent;
-            if (event.listCustomAttributes() != null && !event.listCustomAttributes().isEmpty()) {
-                descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_CUSTOM_ATTRIBUTE, NAME_CUSTOM_ATTRIBUTES));
-            }
-        }
-
-        return descriptors.toArray(new IPropertyDescriptor[0]);
-    }
-
-    @Override
-    public Object getPropertyValue(Object id) {
-        if (id.equals(ID_TIMESTAMP) && fEvent.getTimestamp() != null) {
-            return new TimestampPropertySource(fEvent.getTimestamp());
-        } else if (id.equals(ID_SOURCE) && fEvent.getSource() != null) {
-            return fEvent.getSource().toString();
-        } else if (id.equals(ID_TYPE) && fEvent.getType() != null) {
-            return fEvent.getType().toString();
-        } else if (id.equals(ID_REFERENCE) && fEvent.getReference() != null) {
-            return fEvent.getReference().toString();
-        } else if (id.equals(ID_MODEL_URI)) {
-            return ((ITmfModelLookup)fEvent).getModelUri();
-        } else if (id.equals(ID_SOURCE_LOOKUP)) {
-            return new SourceLookupPropertySource(((ITmfSourceLookup)fEvent));
-        } else if (id.equals(ID_CONTENT) && fEvent.getContent() != null) {
-            return new ContentPropertySource(fEvent.getContent());
-        } else if (id.equals(ID_CUSTOM_ATTRIBUTE)) {
-            return new CustomAttributePropertySource((ITmfCustomAttributes) fEvent);
-        }
-        return null;
-    }
-
-    @Override
-    public boolean isPropertySet(Object id) {
-        return false;
-    }
-
-    @Override
-    public void resetPropertyValue(Object id) {
-    }
-
-    @Override
-    public void setPropertyValue(Object id, Object value) {
-    }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/ReadOnlyTextPropertyDescriptor.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/ReadOnlyTextPropertyDescriptor.java
deleted file mode 100644 (file)
index 83f745b..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Alexandre Montplaisir - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.util;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-/**
- * A uneditable version of a {@link TextPropertyDescriptor}.
- *
- * @author Alexandre Montplaisir
- * @since 2.0
- */
-public class ReadOnlyTextPropertyDescriptor extends PropertyDescriptor {
-
-    /**
-     * Creates an property descriptor with the given id and display name.
-     *
-     * @param id
-     *            The id of the property
-     * @param displayName
-     *            The name to display for the property
-     */
-    public ReadOnlyTextPropertyDescriptor(Object id, String displayName) {
-        super(id, displayName);
-    }
-
-    @Override
-    public CellEditor createPropertyEditor(Composite parent) {
-        CellEditor editor = new TextCellEditor(parent, SWT.READ_ONLY);
-        if (getValidator() != null) {
-            editor.setValidator(getValidator());
-        }
-        return editor;
-    }
-
-}
index 559906c3b306b429acfbf33dcb0c93e6bfc3aa98..6b290faff69fa4c88235b9ec3754058cdaf4856e 100644 (file)
@@ -7,17 +7,20 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Francois Chouinard - Initial API and implementation
+ *     Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.internal.tmf.ui;
 
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
 import org.eclipse.linuxtools.tmf.ui.properties.TmfTimePreferences;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventAdapterFactory;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
@@ -41,6 +44,8 @@ public class Activator extends AbstractUIPlugin {
      */
     private static Activator plugin;
 
+    private TmfEventAdapterFactory fTmfEventAdapterFactory;
+
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -75,12 +80,17 @@ public class Activator extends AbstractUIPlugin {
         TmfUiTracer.init();
         TmfTraceElement.init();
         TmfTimePreferences.init();
+
+        fTmfEventAdapterFactory = new TmfEventAdapterFactory();
+        Platform.getAdapterManager().registerAdapters(fTmfEventAdapterFactory, ITmfEvent.class);
     }
 
     @Override
     public void stop(BundleContext context) throws Exception {
         TmfUiTracer.stop();
         plugin = null;
+
+        Platform.getAdapterManager().unregisterAdapters(fTmfEventAdapterFactory);
         super.stop(context);
     }
 
index 8b44a9453125ea66568de9174dfb1fc7ca862175..5e8074a9ba7c1b9e30fdf8dc38723f8a4485f542 100644 (file)
@@ -32,7 +32,7 @@ import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
 import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.IEditorReference;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPage;
index ce7388ef31bf99b546fb10bf1f506dd2ff1e9f81..6498ef257a946556743fa60aab90aae7df0a7706 100644 (file)
@@ -15,7 +15,7 @@ package org.eclipse.linuxtools.tmf.ui.project.model;
 import java.util.Arrays;
 
 import org.eclipse.core.resources.IFolder;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertySource2;
 
index 3652939e1c99614997db3c797d972179c8882e03..2a81f93472c5ccb4e72a8766ebf4044bb86a6344 100644 (file)
@@ -39,8 +39,8 @@ import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.IActionFilter;
 import org.eclipse.ui.IEditorReference;
 import org.eclipse.ui.IWorkbench;
index 946f30dd795b1b9b38e9ab5035631e849fe2d652..4b68b711229800c343ceb2add4b070fe69e99cfc 100644 (file)
@@ -17,7 +17,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.eclipse.core.resources.IFolder;
-import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertySource2;
 
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/ReadOnlyTextPropertyDescriptor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/ReadOnlyTextPropertyDescriptor.java
new file mode 100644 (file)
index 0000000..79dbbfa
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.properties;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * A uneditable version of a {@link TextPropertyDescriptor}.
+ *
+ * @author Alexandre Montplaisir
+ * @since 2.0
+ */
+public class ReadOnlyTextPropertyDescriptor extends PropertyDescriptor {
+
+    /**
+     * Creates an property descriptor with the given id and display name.
+     *
+     * @param id
+     *            The id of the property
+     * @param displayName
+     *            The name to display for the property
+     */
+    public ReadOnlyTextPropertyDescriptor(Object id, String displayName) {
+        super(id, displayName);
+    }
+
+    @Override
+    public CellEditor createPropertyEditor(Composite parent) {
+        CellEditor editor = new TextCellEditor(parent, SWT.READ_ONLY);
+        if (getValidator() != null) {
+            editor.setValidator(getValidator());
+        }
+        return editor;
+    }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventAdapterFactory.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventAdapterFactory.java
new file mode 100644 (file)
index 0000000..05157b7
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Marc-Andre Laperle - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.tmf.ui.viewers.events;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * Implements basic UI support for TMF events.
+ *
+ * @since 2.0
+ */
+public class TmfEventAdapterFactory implements IAdapterFactory {
+
+    private static Class<?>[] PROPERTIES = new Class[] {
+        IPropertySource.class
+    };
+
+    @Override
+    public Class<?>[] getAdapterList() {
+        return PROPERTIES;
+    }
+
+    @Override
+    public Object getAdapter(Object element, Class key) {
+        ITmfEvent tmfEvent = (ITmfEvent) element;
+        if (IPropertySource.class.equals(key)) {
+            return new TmfEventPropertySource(tmfEvent);
+        }
+        return null;
+    }
+}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventPropertySource.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventPropertySource.java
new file mode 100644 (file)
index 0000000..7a66fbc
--- /dev/null
@@ -0,0 +1,350 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Patrick Tasse - Initial API and implementation
+ *     Bernd Hufmann - Added call site and model URI properties
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.events;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfCustomAttributes;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfModelLookup;
+import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfSourceLookup;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * Property source for events
+ *
+ * @since 2.0
+ */
+public class TmfEventPropertySource implements IPropertySource {
+
+    private static final String ID_TIMESTAMP = "event_timestamp"; //$NON-NLS-1$
+    private static final String ID_SOURCE = "event_source"; //$NON-NLS-1$
+    private static final String ID_TYPE = "event_type"; //$NON-NLS-1$
+    private static final String ID_REFERENCE = "event_reference"; //$NON-NLS-1$
+    private static final String ID_CONTENT = "event_content"; //$NON-NLS-1$
+    private static final String ID_SOURCE_LOOKUP = "event_lookup"; //$NON-NLS-1$
+    private static final String ID_MODEL_URI = "model_uri"; //$NON-NLS-1$
+    private static final String ID_CUSTOM_ATTRIBUTE = "custom_attribute"; //$NON-NLS-1$
+
+    private static final String NAME_TIMESTAMP = "Timestamp"; //$NON-NLS-1$
+    private static final String NAME_SOURCE = "Source"; //$NON-NLS-1$
+    private static final String NAME_TYPE = "Type"; //$NON-NLS-1$
+    private static final String NAME_REFERENCE = "Reference"; //$NON-NLS-1$
+    private static final String NAME_CONTENT = "Content"; //$NON-NLS-1$
+    private static final String NAME_SOURCE_LOOKUP = "Source Lookup"; //$NON-NLS-1$
+    private static final String NAME_MODEL_URI = "Model URI"; //$NON-NLS-1$
+    private static final String NAME_CUSTOM_ATTRIBUTES = "Custom Attributes"; //$NON-NLS-1$
+
+    private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+    private ITmfEvent fEvent;
+
+    private class TimestampPropertySource implements IPropertySource {
+        private static final String ID_TIMESTAMP_VALUE = "timestamp_value"; //$NON-NLS-1$
+        private static final String ID_TIMESTAMP_SCALE = "timestamp_scale"; //$NON-NLS-1$
+        private static final String ID_TIMESTAMP_PRECISION = "timestamp_precision"; //$NON-NLS-1$
+        private static final String NAME_TIMESTAMP_VALUE = "value"; //$NON-NLS-1$
+        private static final String NAME_TIMESTAMP_SCALE = "scale"; //$NON-NLS-1$
+        private static final String NAME_TIMESTAMP_PRECISION = "precision"; //$NON-NLS-1$
+
+        private ITmfTimestamp fTimestamp;
+
+        public TimestampPropertySource(ITmfTimestamp timestamp) {
+            fTimestamp = timestamp;
+        }
+
+        @Override
+        public Object getEditableValue() {
+            return fTimestamp.toString();
+        }
+
+        @Override
+        public IPropertyDescriptor[] getPropertyDescriptors() {
+            IPropertyDescriptor[] descriptors = new IPropertyDescriptor[3];
+            descriptors[0] = new ReadOnlyTextPropertyDescriptor(ID_TIMESTAMP_VALUE, NAME_TIMESTAMP_VALUE);
+            descriptors[1] = new ReadOnlyTextPropertyDescriptor(ID_TIMESTAMP_SCALE, NAME_TIMESTAMP_SCALE);
+            descriptors[2] = new ReadOnlyTextPropertyDescriptor(ID_TIMESTAMP_PRECISION, NAME_TIMESTAMP_PRECISION);
+            return descriptors;
+        }
+
+        @Override
+        public Object getPropertyValue(Object id) {
+            if (id.equals(ID_TIMESTAMP_VALUE)) {
+                return Long.toString(fTimestamp.getValue());
+            } else if (id.equals(ID_TIMESTAMP_SCALE)) {
+                return Integer.toString(fTimestamp.getScale());
+            } else if (id.equals(ID_TIMESTAMP_PRECISION)) {
+                return Integer.toString(fTimestamp.getPrecision());
+            }
+            return null;
+        }
+
+        @Override
+        public boolean isPropertySet(Object id) {
+            return false;
+        }
+
+        @Override
+        public void resetPropertyValue(Object id) {
+        }
+
+        @Override
+        public void setPropertyValue(Object id, Object value) {
+        }
+    }
+
+    private class ContentPropertySource implements IPropertySource {
+        private ITmfEventField fContent;
+
+        public ContentPropertySource(ITmfEventField content) {
+            fContent = content;
+        }
+
+        @Override
+        public Object getEditableValue() {
+            return fContent.toString();
+        }
+
+        @Override
+        public IPropertyDescriptor[] getPropertyDescriptors() {
+            List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>(fContent.getFields().length);
+            for (ITmfEventField field : fContent.getFields()) {
+                if (field != null) {
+                    descriptors.add(new ReadOnlyTextPropertyDescriptor(field, field.getName()));
+                }
+            }
+            return descriptors.toArray(new IPropertyDescriptor[0]);
+        }
+
+        @Override
+        public Object getPropertyValue(Object id) {
+            ITmfEventField field = (ITmfEventField) id;
+            if (field.getFields() != null && field.getFields().length > 0) {
+                return new ContentPropertySource(field);
+            }
+            return field.getFormattedValue();
+        }
+
+        @Override
+        public boolean isPropertySet(Object id) {
+            return false;
+        }
+
+        @Override
+        public void resetPropertyValue(Object id) {
+        }
+
+        @Override
+        public void setPropertyValue(Object id, Object value) {
+        }
+    }
+
+    private class SourceLookupPropertySource implements IPropertySource {
+
+        private static final String ID_FILE_NAME = "callsite_file"; //$NON-NLS-1$
+        private static final String ID_FUNCTION_NAME = "callsite_function"; //$NON-NLS-1$
+        private static final String ID_LINE_NUMBER = "callsite_line"; //$NON-NLS-1$
+
+        private static final String NAME_FILE_NAME = "File"; //$NON-NLS-1$
+        private static final String NAME_FUNCTION_NAME = "Function"; //$NON-NLS-1$
+        private static final String NAME_LINE_NUMBER = "Line"; //$NON-NLS-1$
+
+        final private ITmfSourceLookup fSourceLookup;
+
+        public SourceLookupPropertySource(ITmfSourceLookup lookup) {
+            fSourceLookup = lookup;
+        }
+
+        @Override
+        public Object getEditableValue() {
+            if (fSourceLookup.getCallsite() != null) {
+                return fSourceLookup.getCallsite().toString();
+            }
+            return null;
+        }
+
+        @Override
+        public IPropertyDescriptor[] getPropertyDescriptors() {
+            List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>();
+            if (fSourceLookup.getCallsite() != null) {
+                descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_FILE_NAME, NAME_FILE_NAME));
+                descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_LINE_NUMBER, NAME_LINE_NUMBER));
+                // only display function if available
+                if (fSourceLookup.getCallsite().getFunctionName() != null) {
+                    descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_FUNCTION_NAME, NAME_FUNCTION_NAME));
+                }
+            }
+            return descriptors.toArray(new IPropertyDescriptor[0]);
+        }
+
+        @Override
+        public Object getPropertyValue(Object id) {
+            if  (id.equals(ID_FILE_NAME)) {
+                return fSourceLookup.getCallsite().getFileName();
+            } else if (id.equals(ID_FUNCTION_NAME)) {
+                return fSourceLookup.getCallsite().getFunctionName();
+            } else if (id.equals(ID_LINE_NUMBER)) {
+                return Long.valueOf(fSourceLookup.getCallsite().getLineNumber());
+            }
+            return null;
+        }
+
+        @Override
+        public boolean isPropertySet(Object id) {
+            return false;
+        }
+
+        @Override
+        public void resetPropertyValue(Object id) {
+
+        }
+
+        @Override
+        public void setPropertyValue(Object id, Object value) {
+        }
+    }
+
+    private class CustomAttributePropertySource implements IPropertySource {
+
+        private final ITmfCustomAttributes event;
+
+        public CustomAttributePropertySource(ITmfCustomAttributes event) {
+            this.event = event;
+        }
+
+        @Override
+        public Object getEditableValue() {
+            return EMPTY_STRING;
+        }
+
+        @Override
+        public IPropertyDescriptor[] getPropertyDescriptors() {
+            List<IPropertyDescriptor> descriptors = new ArrayList<IPropertyDescriptor>();
+
+            for (String customAttribute : event.listCustomAttributes()) {
+                descriptors.add(new ReadOnlyTextPropertyDescriptor(customAttribute, customAttribute));
+            }
+
+            return descriptors.toArray(new IPropertyDescriptor[0]);
+        }
+
+        @Override
+        public Object getPropertyValue(Object id) {
+            return event.getCustomAttribute((String) id);
+        }
+
+        @Override
+        public boolean isPropertySet(Object id) {
+            return false;
+        }
+
+        @Override
+        public void resetPropertyValue(Object id) {
+        }
+
+        @Override
+        public void setPropertyValue(Object id, Object value) {
+        }
+    }
+
+    /**
+     * Default constructor
+     *
+     * @param event the event
+     */
+    public TmfEventPropertySource(ITmfEvent event) {
+        super();
+        this.fEvent = event;
+    }
+
+    @Override
+    public Object getEditableValue() {
+        return null;
+    }
+
+    @Override
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+        List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>();
+
+        /* Display basic event information */
+        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_TIMESTAMP, NAME_TIMESTAMP));
+        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_SOURCE, NAME_SOURCE));
+        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_TYPE, NAME_TYPE));
+        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_REFERENCE, NAME_REFERENCE));
+
+        /* Display event fields */
+        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_CONTENT, NAME_CONTENT));
+
+        /* Display source lookup information, if the event supplies it */
+        if ((fEvent instanceof ITmfSourceLookup) && (((ITmfSourceLookup)fEvent).getCallsite() != null)) {
+            descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_SOURCE_LOOKUP, NAME_SOURCE_LOOKUP));
+        }
+
+        /* Display Model URI information, if the event supplies it */
+        if ((fEvent instanceof ITmfModelLookup) && (((ITmfModelLookup) fEvent).getModelUri() != null)) {
+            descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_MODEL_URI, NAME_MODEL_URI));
+        }
+
+        /* Display custom attributes, if available */
+        if (fEvent instanceof ITmfCustomAttributes) {
+            ITmfCustomAttributes event = (ITmfCustomAttributes) fEvent;
+            if (event.listCustomAttributes() != null && !event.listCustomAttributes().isEmpty()) {
+                descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_CUSTOM_ATTRIBUTE, NAME_CUSTOM_ATTRIBUTES));
+            }
+        }
+
+        return descriptors.toArray(new IPropertyDescriptor[0]);
+    }
+
+    @Override
+    public Object getPropertyValue(Object id) {
+        if (id.equals(ID_TIMESTAMP) && fEvent.getTimestamp() != null) {
+            return new TimestampPropertySource(fEvent.getTimestamp());
+        } else if (id.equals(ID_SOURCE) && fEvent.getSource() != null) {
+            return fEvent.getSource().toString();
+        } else if (id.equals(ID_TYPE) && fEvent.getType() != null) {
+            return fEvent.getType().toString();
+        } else if (id.equals(ID_REFERENCE) && fEvent.getReference() != null) {
+            return fEvent.getReference().toString();
+        } else if (id.equals(ID_MODEL_URI)) {
+            return ((ITmfModelLookup)fEvent).getModelUri();
+        } else if (id.equals(ID_SOURCE_LOOKUP)) {
+            return new SourceLookupPropertySource(((ITmfSourceLookup)fEvent));
+        } else if (id.equals(ID_CONTENT) && fEvent.getContent() != null) {
+            return new ContentPropertySource(fEvent.getContent());
+        } else if (id.equals(ID_CUSTOM_ATTRIBUTE)) {
+            return new CustomAttributePropertySource((ITmfCustomAttributes) fEvent);
+        }
+        return null;
+    }
+
+    @Override
+    public boolean isPropertySet(Object id) {
+        return false;
+    }
+
+    @Override
+    public void resetPropertyValue(Object id) {
+    }
+
+    @Override
+    public void setPropertyValue(Object id, Object value) {
+    }
+
+}
This page took 0.042905 seconds and 5 git commands to generate.