From 0505c6fc6182f16853eadf2d3ce72e3c9de5c740 Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Wed, 17 Apr 2013 11:52:03 -0400 Subject: [PATCH] Use a read-only TextPropertyDescriptor for event properties 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 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/11984 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Tested-by: Bernd Hufmann --- .../META-INF/MANIFEST.MF | 1 + .../core/event/TmfEventPropertySource.java | 30 +++++------ .../util/ReadOnlyTextPropertyDescriptor.java | 51 +++++++++++++++++++ 3 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/ReadOnlyTextPropertyDescriptor.java diff --git a/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF index aef3ccd9e7..caae025ef7 100644 --- a/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF +++ b/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/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 index 25dec41510..2ede1e1aae 100644 --- 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 @@ -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 descriptors= new ArrayList(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 descriptors= new ArrayList(); 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 descriptors= new ArrayList(); - 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 index 0000000000..83f745bf48 --- /dev/null +++ b/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; + } + +} -- 2.34.1