001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package net.refractions.udig.project.ui.internal.properties;
018:
019: import net.refractions.udig.project.ui.internal.Messages;
020:
021: import org.eclipse.ui.views.properties.IPropertyDescriptor;
022: import org.eclipse.ui.views.properties.IPropertySource2;
023: import org.eclipse.ui.views.properties.PropertyDescriptor;
024: import org.geotools.feature.AttributeType;
025:
026: /**
027: * Allows complex attributes to be a property source. Only nested attributes are property
028: *
029: * @author jeichar
030: * @since 0.3
031: */
032: public class AttributePropertySource implements IPropertySource2 {
033: private Object attr;
034: IPropertyDescriptor[] descriptors;
035: private static final String OTHER = Messages.AttributePropertySource_other;
036:
037: /**
038: * Creates a new instance of AttributePropertySource
039: *
040: * @param type
041: * @param attr
042: */
043: public AttributePropertySource(AttributeType type, Object attr) {
044: this .attr = attr;
045: }
046:
047: /**
048: * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object)
049: */
050: public boolean isPropertyResettable(Object id) {
051: return false;
052: }
053:
054: /**
055: * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
056: */
057: public Object getEditableValue() {
058: return null;
059: }
060:
061: /**
062: * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
063: */
064: public IPropertyDescriptor[] getPropertyDescriptors() {
065: if (descriptors == null) {
066: descriptors = new IPropertyDescriptor[] { new PropertyDescriptor(
067: OTHER, Messages.AttributePropertySource_value) };
068: }
069:
070: IPropertyDescriptor[] c = new IPropertyDescriptor[descriptors.length];
071: System.arraycopy(descriptors, 0, c, 0, c.length);
072: return c;
073: }
074:
075: /**
076: * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
077: */
078: public Object getPropertyValue(Object id) {
079: if (id.equals(OTHER))
080: return attr.toString();
081: return null;
082: }
083:
084: /**
085: * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
086: */
087: public boolean isPropertySet(Object id) {
088: return false;
089: }
090:
091: /**
092: * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
093: */
094: public void resetPropertyValue(Object id) {
095: // do nothing
096: }
097:
098: /**
099: * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object,
100: * java.lang.Object)
101: */
102: public void setPropertyValue(Object id, Object value) {
103: // do nothing
104: }
105: }
|