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
@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;
}
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]);
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]);
@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]);
}
--- /dev/null
+/*******************************************************************************
+ * 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;
+ }
+
+}