aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Hufmann2013-04-17 11:52:03 (EDT)
committerBernd Hufmann2013-04-22 14:45:17 (EDT)
commitc1d5d4a80c2675990b96c91738c36860d1327ec2 (patch)
tree751bcfaf95df20900e65b7e905a6e99ab12d51ac
parentd67d6da3d2861646456f26bc458f9572c77825e2 (diff)
downloadorg.eclipse.linuxtools-c1d5d4a80c2675990b96c91738c36860d1327ec2.zip
org.eclipse.linuxtools-c1d5d4a80c2675990b96c91738c36860d1327ec2.tar.gz
org.eclipse.linuxtools-c1d5d4a80c2675990b96c91738c36860d1327ec2.tar.bz2
Use a read-only TextPropertyDescriptor for event propertiesrefs/changes/84/11984/4
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>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java30
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/ReadOnlyTextPropertyDescriptor.java51
3 files changed, 67 insertions, 15 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF
index aef3ccd..caae025 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF
@@ -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",
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
index 25dec41..2ede1e1 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
@@ -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/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/ReadOnlyTextPropertyDescriptor.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/ReadOnlyTextPropertyDescriptor.java
new file mode 100644
index 0000000..83f745b
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/ReadOnlyTextPropertyDescriptor.java
@@ -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;
+ }
+
+}