Skip to main content



      Home
Home » Newcomers » Newcomers » Choosing the correct Property Descriptor
Choosing the correct Property Descriptor [message #261363] Thu, 17 July 2008 08:30
Eclipse UserFriend
Originally posted by: gang.xu.delphi.com

I have a treeviewer where each node has associated read-only and editable
properties. I used the approach in "taking control of your properties" and
have a property page implementing IPropertySource for each node.

Some of the editable properties are integer and double values. But, I used
the pre-existing TextPropertyDescriptor for these and at first simply
casted as doubles and back when setting the values since I figured the
get/set methods expected an object rather than string explicitly.

On running however, only my string values are editable, and the double
values just show up as normal PropertyDescriptors-the value is displayed
and not editable.

Any suggestions on which PropertyDescriptor to use instead or if there is
a simple fix? Thanks!


(below, name is a string while tolerance is a double and "debugging" is an
integer.)

<
TextPropertyDescriptor tolerance = new
TextPropertyDescriptor(xVariable.PROP_variableTolerance, "Tolerance");
tolerance.setLabelProvider(new LabelProvider());
tolerance.setCategory("Writeable");
TextPropertyDescriptor debugger = new
TextPropertyDescriptor(xVariable.PROP_variableBaseType, "Debugging");
debugger.setLabelProvider(new LabelProvider());
debugger.setCategory("Writeable");
TextPropertyDescriptor name = new
TextPropertyDescriptor("name", "Variable Name");
name.setLabelProvider(new LabelProvider());
name.setCategory("Writeable");

IPropertyDescriptor[] propertyDescriptors = new
IPropertyDescriptor[] {
minValue, maxValue, resolution, tolerance, debugger, name};
return propertyDescriptors;



public Object getPropertyValue(Object id) {
return variable.getProperty((String)id);
}

public void setPropertyValue(Object id, Object value) {
variable.setProperty((String)id, (String)value);
}

I also noticed this-I am also getting the following error logged when I
click on the supposedly editable area when the value is an integer or
double:

org.eclipse.core.runtime.AssertionFailedException: assertion failed: at
org.eclipse.core.runtime.Assert.isTrue(Assert.java:111)
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:97)
at
org.eclipse.jface.viewers.TextCellEditor.doSetValue(TextCell Editor.java:228)
at org.eclipse.jface.viewers.CellEditor.setValue(CellEditor.jav a:855)
at
org.eclipse.ui.views.properties.PropertySheetEntry.getEditor (PropertySheetEntry.java:384)
at
org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:163)
at
org.eclipse.ui.views.properties.PropertySheetViewer.handleSe lect(PropertySheetViewer.java:729)
at
org.eclipse.ui.views.properties.PropertySheetViewer.access$8 (PropertySheetViewer.java:707)
at
org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseD own(PropertySheetViewer.java:817)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:179)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Previous Topic:Ganymede fails after update
Next Topic:Custominzing FileDialog
Goto Forum:
  


Current Time: Tue Jun 03 06:47:55 EDT 2025

Powered by FUDForum. Page generated in 0.27473 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top