Revision 298 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/dynobject/valuefield/ListItemValueField.java

View differences:

ListItemValueField.java
42 42
 * Implementation that emulates the ValueField behavior for List objects.
43 43
 * 
44 44
 * @author 2010 - <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG Team
45
 * @author 2010 - <a href="mailto:reinhold@uji.es">Cristian Mart?n&nbsp;</a>  - gvSIG Team
45
 * @author 2010 - <a href="mailto:reinhold@uji.es">Cristian Mart?n&nbsp;</a> -
46
 *         gvSIG Team
46 47
 * @version $Id$
47
 *
48
 * 
48 49
 */
49 50

  
50 51
public class ListItemValueField implements ValueField {
......
60 61
     * Constructor.
61 62
     * 
62 63
     * @param dynObject
63
     *      the current DynObject value.
64
     *            the current DynObject value.
64 65
     * @param fieldName
65
     *      the current field name.
66
     *            the current field name.
66 67
     * @param index
67
     *      the current index value to be pointing at the list.
68
     *            the current index value to be pointing at the list.
68 69
     */
69 70
    public ListItemValueField(DynObject dynObject, String fieldName, int index) {
70 71

  
......
72 73
        this.fieldName = fieldName;
73 74
        this.index = index;
74 75
        this.dynField = dynObject.getDynClass().getDynField(fieldName);
75
        
76 76

  
77 77
        Object value = dynObject.getDynValue(fieldName);
78 78
        if (value == null) {
......
81 81
        this.setValue(value);
82 82
    }
83 83

  
84
    public Object getDefaultFieldValue() {
85
        return getDynField().getDefaultValue();
86
    }
87

  
88
    /*
89
     * (non-Javadoc)
90
     * 
91
     * @see
92
     * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getDefaultValue()
93
     */
94
    public Object getDefaultValue() {
95
        return this.dynField.getDefaultValue();
96
    }
97

  
98
    public DynField getDynField() {
99
        return dynField.getElementsType();
100
    }
101

  
102
    public Object getFieldValue() {
103
        return this.items;
104
    }
105

  
84 106
    /**
85 107
     * Returns the List of values.
86 108
     * 
87
     * @return  the List of values.
109
     * @return the List of values.
88 110
     */
89 111
    public Object getValue() {
90 112
        return this.items;
......
94 116
     * Reutrns the item of the list at a given position.
95 117
     * 
96 118
     * @param index
97
     *     the index position
119
     *            the index position
98 120
     * @return
99
     *     the resulting item.
121
     *         the resulting item.
100 122
     */
101 123
    public Object getValueItem(int index) {
102 124
        return this.items.get(index);
103 125
    }
104 126

  
127
    public void setFieldValue(Object value) {
128
        this.dynObject.setDynValue(this.fieldName, value);
129
    }
130

  
105 131
    /*
106 132
     * (non-Javadoc)
107 133
     * 
......
110 136
     * .lang.Object)
111 137
     */
112 138
    public void setValue(Object value) {
113
        if (value==null)
139
        if (value == null) {
114 140
            this.items = new ArrayList<Object>();
115
        else
141
        } else {
116 142
            this.items = (List<Object>) value;
143
        }
117 144
    }
118 145

  
119
 
120 146
    /**
121 147
     * Sets an item into the list at the index specified.
122 148
     * 
123 149
     * @param item
124
     *      the item to be inserted.
150
     *            the item to be inserted.
125 151
     * @param index
126
     *      the index to insert the item.
152
     *            the index to insert the item.
127 153
     */
128 154
    public void setValueItem(Object item, int index) {
129 155
        this.items.set(index, item);
130 156
    }
131

  
132
    public DynField getDynField() {
133
        return dynField.getElementsType();
134
    }
135

  
136
    public Object getDefaultFieldValue() {
137
        return getDynField().getDefaultValue();
138
    }
139
    
140
    /*
141
     * (non-Javadoc)
142
     * 
143
     * @see
144
     * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getDefaultValue()
145
     */
146
    public Object getDefaultValue() {
147
        return this.dynField.getDefaultValue();
148
    }
149

  
150
    public Object getFieldValue() {
151
        return this.items;
152
    }
153

  
154
    public void setFieldValue(Object value) {
155
        this.dynObject.setDynValue(this.fieldName, value);
156
    }
157 157
}

Also available in: Unified diff