*/
public IPropertyDescriptor[] getPropertyDescriptors() {
if (descriptors == null) {
boolean hasAttrs = false;
List<IPropertyDescriptor> descrps = new ArrayList<IPropertyDescriptor>();
PropertyDescriptor d = new PropertyDescriptor(ID, "ID"); //$NON-NLS-1$
d.setCategory(Messages.FeaturePropertySource_feature);
descrps.add(d);
d = new GeometryPropertyDescriptor(DEFAULT_GEOM,
Messages.FeaturePropertySource_defaultGeometry);
d.setCategory(Messages.FeaturePropertySource_geometries);
descrps.add(d);
d = new PropertyDescriptor(BOUNDING_BOX, Messages.FeaturePropertySource_bounds);
d.setCategory(Messages.FeaturePropertySource_feature);
d.setLabelProvider(new LabelProvider(){
/**
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
public String getText( Object element ) {
Envelope bbox = (Envelope) element;
String minx = String.valueOf(bbox.getMinX());
minx = minx.substring(0, Math.min(10, minx.length()));
String maxx = String.valueOf(bbox.getMaxX());
maxx = maxx.substring(0, Math.min(10, maxx.length()));
String miny = String.valueOf(bbox.getMinY());
miny = miny.substring(0, Math.min(10, miny.length()));
String maxy = String.valueOf(bbox.getMaxY());
maxy = maxy.substring(0, Math.min(10, maxy.length()));
return "(" + minx + "," + miny + "), (" + maxx + "," + maxy + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
});
descrps.add(d);
if (!attribute) {
SimpleFeatureType ft = feature.getFeatureType();
attrs = ft.getAttributeDescriptors();
int i = -1;
for (AttributeDescriptor at : attrs) {
i++;
String name = at.getName().getLocalPart().toLowerCase();
name = name.substring(0, 1).toUpperCase() + name.substring(1);
if ( at instanceof GeometryDescriptor ) {
if (feature.getAttribute(at.getLocalName()) != feature.getDefaultGeometry()) {
d = new GeometryPropertyDescriptor(Integer.valueOf(i), name
+ Messages.FeaturePropertySource_geometry);
d.setCategory(Messages.FeaturePropertySource_geometries);
descrps.add(d);
}
} else {
if (SimpleFeature.class.isAssignableFrom(at.getType().getBinding())) {
d = new PropertyDescriptor(FEATURE + Integer.valueOf(i), name);
} else if (Collection.class.isAssignableFrom(at.getType().getBinding()))
d = new PropertyDescriptor(Integer.valueOf(i), name);
else {
d = new AttributePropertyDescriptor(Integer.valueOf(i), name, at, ft, editable);
// if (String.class.isAssignableFrom(at.getType()))
// d = new TextPropertyDescriptor(Integer.valueOf(i), name);
// if (Integer.class.isAssignableFrom(at.getType()))
// d = new TextPropertyDescriptor(Integer.valueOf(i), name);
// if (Double.class.isAssignableFrom(at.getType()))
// d = new TextPropertyDescriptor(Integer.valueOf(i), name);
// if (Boolean.class.isAssignableFrom(at.getType()))
// d = new ComboBoxPropertyDescriptor(Integer.valueOf(i), name,
// new String[]{"true","false"});
// if (Float.class.isAssignableFrom(at.getType()))
// d = new TextPropertyDescriptor(Integer.valueOf(i), name);
}
// d.setValidator(new AttributeValidator(at));
if (name.equalsIgnoreCase("name")) { //$NON-NLS-1$
d.setCategory(Messages.FeaturePropertySource_feature);
descrps.add(0, d);
} else {
hasAttrs = true;
d.setCategory(Messages.FeaturePropertySource_featureAttributes);
descrps.add(d);
}
}
}
}
if (!hasAttrs) {
d = new PropertyDescriptor(
"", Messages.FeaturePropertySource_noOtherAttributes); //$NON-NLS-1$
d.setCategory(Messages.FeaturePropertySource_featureAttributes);
descrps.add(d);
}
descriptors = new IPropertyDescriptor[descrps.size()];
descrps.toArray(descriptors);
}