Use a read-only TextPropertyDescriptor for event properties
authorBernd Hufmann <bhufmann@gmail.com>
Wed, 17 Apr 2013 15:52:03 +0000 (11:52 -0400)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Mon, 22 Apr 2013 18:45:17 +0000 (14:45 -0400)
Use a custom, read-only TextPropertyDescriptor to use the cursor
in the value column to scroll for long property strings. In the
previous implementation, long value strings couldn't be read properly.

Change-Id: I6469442cb5b8f6779c807e90f8dc569ed3f71b49
Signed-off-by: Bernd Hufmann <bhufmann@gmail.com>
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/11984
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/ReadOnlyTextPropertyDescriptor.java [new file with mode: 0644]

index aef3ccd9e7c9b9ae304837bb4ce14d45c0aee8f5..caae025ef7da769a03caac11f4bbc407d9224b32 100644 (file)
@@ -10,6 +10,7 @@ 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",
index 25dec41510723b68f01f2a4f3f8682790337b96f..2ede1e1aae6be84c0b599faa39891e4a4e08b75f 100644 (file)
@@ -19,9 +19,9 @@ 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;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
 
 /**
  * Property source for events
@@ -71,9 +71,9 @@ public class TmfEventPropertySource implements IPropertySource {
         @Override
         public IPropertyDescriptor[] getPropertyDescriptors() {
             IPropertyDescriptor[] descriptors = new IPropertyDescriptor[3];
-            descriptors[0] = new PropertyDescriptor(ID_TIMESTAMP_VALUE, NAME_TIMESTAMP_VALUE);
-            descriptors[1] = new PropertyDescriptor(ID_TIMESTAMP_SCALE, NAME_TIMESTAMP_SCALE);
-            descriptors[2] = new PropertyDescriptor(ID_TIMESTAMP_PRECISION, NAME_TIMESTAMP_PRECISION);
+            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;
         }
 
@@ -120,7 +120,7 @@ public class TmfEventPropertySource implements IPropertySource {
             List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>(fContent.getFields().length);
             for (ITmfEventField field : fContent.getFields()) {
                 if (field != null) {
-                    descriptors.add(new PropertyDescriptor(field, field.getName()));
+                    descriptors.add(new ReadOnlyTextPropertyDescriptor(field, field.getName()));
                 }
             }
             return descriptors.toArray(new IPropertyDescriptor[0]);
@@ -177,11 +177,11 @@ public class TmfEventPropertySource implements IPropertySource {
         public IPropertyDescriptor[] getPropertyDescriptors() {
             List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>();
             if (fSourceLookup.getCallsite() != null) {
-                descriptors.add(new PropertyDescriptor(ID_FILE_NAME, NAME_FILE_NAME));
-                descriptors.add(new PropertyDescriptor(ID_LINE_NUMBER, NAME_LINE_NUMBER));
+                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 PropertyDescriptor(ID_FUNCTION_NAME, NAME_FUNCTION_NAME));
+                    descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_FUNCTION_NAME, NAME_FUNCTION_NAME));
                 }
             }
             return descriptors.toArray(new IPropertyDescriptor[0]);
@@ -233,17 +233,17 @@ public class TmfEventPropertySource implements IPropertySource {
     @Override
     public IPropertyDescriptor[] getPropertyDescriptors() {
         List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>();
-        descriptors.add(new PropertyDescriptor(ID_TIMESTAMP, NAME_TIMESTAMP));
-        descriptors.add(new PropertyDescriptor(ID_SOURCE, NAME_SOURCE));
-        descriptors.add(new PropertyDescriptor(ID_TYPE, NAME_TYPE));
-        descriptors.add(new PropertyDescriptor(ID_REFERENCE, NAME_REFERENCE));
+        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));
         if ((fEvent instanceof ITmfSourceLookup) && (((ITmfSourceLookup)fEvent).getCallsite() != null)) {
-            descriptors.add(new PropertyDescriptor(ID_SOURCE_LOOKUP, NAME_SOURCE_LOOKUP));
+            descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_SOURCE_LOOKUP, NAME_SOURCE_LOOKUP));
         }
         if ((fEvent instanceof ITmfModelLookup) && (((ITmfModelLookup)fEvent).getModelUri() != null)) {
-            descriptors.add(new PropertyDescriptor(ID_MODEL_URI, NAME_MODEL_URI));
+            descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_MODEL_URI, NAME_MODEL_URI));
         }
-        descriptors.add(new PropertyDescriptor(ID_CONTENT, NAME_CONTENT));
+        descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_CONTENT, NAME_CONTENT));
         return descriptors.toArray(new IPropertyDescriptor[0]);
     }
 
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
new file mode 100644 (file)
index 0000000..83f745b
--- /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.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;
+    }
+
+}
This page took 0.029569 seconds and 5 git commands to generate.