Revision 281 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/AbstractDynObjectModel.java

View differences:

AbstractDynObjectModel.java
43 43
import org.gvsig.tools.swing.api.dynobject.DynObjectModel;
44 44

  
45 45
/**
46
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
46
 *
47
 * Abstract class that implements the basics of the DynObjectModel implementation.
47 48
 * 
49
 * @author 2010 - <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG Team
50
 * @author 2010 - <a href="mailto:reinhold@uji.es">Cristian Mart?n&nbsp;</a>  - gvSIG Team
51
 * @version $Id$
52
 *
48 53
 */
49 54
public abstract class AbstractDynObjectModel implements DynObjectModel {
50 55

  
51 56
    private Map modelsList;
52 57
    protected DynClass dynClass;
53 58

  
59
    /**
60
     * Constructor.
61
     * 
62
     * @param theClass
63
     *      the current DynClass.
64
     * @param initAll <br>
65
     *      &nbsp;&nbsp;&nbsp;&nbsp;<b>true</b>&nbsp;&nbsp;&nbsp;if we want to populate the Model with the default given values.
66
     *      <br>&nbsp;&nbsp;&nbsp;&nbsp;<b>false</b>&nbsp;&nbsp;if we want to get an empty DynObjectModel.  
67
     */
54 68
    public AbstractDynObjectModel(DynClass theClass, boolean initAll) {
55 69
        this.dynClass = theClass;
56 70
        this.modelsList = new LinkedHashMap();
......
58 72
            initDynFieldModelList();
59 73
    }
60 74

  
75
    /**
76
     * Creates a new DynFieldModel object with a default group set to "General" and a field name
77
     *   set to the <b>fieldName</b> value, and returns the created DynFieldModel.
78
     */
61 79
    public DynFieldModel add(String fieldName) {
62 80
        return add("General", fieldName);
63 81
    }
......
74 92
        if (fieldName != null) {
75 93
            DynFieldModel elem =
76 94
                createDynObjectModelElement(fieldName, dynClass, group);
77
            List list = getGroup(group);
95
            List list = getGroupElements(group);
78 96
            if (isNewElement(list, elem))
79 97
                list.add(list.size(), elem);
80 98
            return elem;
......
88 106
    }
89 107

  
90 108
    /**
91
     * @param field
109
     * Creates a new DynFieldModel based on the following parameters:
110
     * @param fieldName
111
     *      a given field name.
92 112
     * @param dynClass
113
     *      a given DynClass.
114
     * @param group
115
     *      a given group name.
93 116
     * @return
94 117
     */
95 118
    protected abstract DynFieldModel createDynObjectModelElement(
96 119
        String fieldName, DynClass dynClass, String group);
97 120

  
98
    protected List getGroup(String group) {
99
        return (List) this.modelsList.get(group);
100
    }
101 121

  
122

  
102 123
    /*
103 124
     * (non-Javadoc)
104 125
     * 
105 126
     * @see
106 127
     * org.gvsig.tools.swing.api.dynobject.DynObjectComponentModel#getFieldModel
107
     * ()
128
     * 
108 129
     */
109 130
    public List getGroupElements(String group) {
110 131
        return (List) this.modelsList.get(group);
......
114 135
        return (String[]) this.modelsList.keySet().toArray(new String[0]);
115 136
    }
116 137

  
117
    protected boolean hasGroup(String group) {
138
    /**
139
     * Determines if a given group name exists or not in the list.
140
     * @param group
141
     *      the group name.
142
     * @return<br>
143
     *      &nbsp;&nbsp;&nbsp;&nbsp;<b>true</b>&nbsp;&nbsp;&nbsp;there are DynModelElements for this DynObjectModel.
144
     *      <br>&nbsp;&nbsp;&nbsp;&nbsp;<b>false</b>&nbsp;&nbsp;there are no DynModelElements for this DynObjectModel.  
145
     */
146
    private boolean hasGroup(String group) {
118 147
        return this.modelsList.containsKey(group);
119 148
    }
120 149

  
121 150
    /**
122
     * 
151
     * Inits the list of DynFieldModels.
123 152
     */
124 153
    public abstract void initDynFieldModelList();
125 154

  
126 155
    /**
156
     * 
157
     * Determines if the DynFieldModel is already in the List or not. If so, 
158
     *   it is not included again.
159
     * 
127 160
     * @param list
128
     * @param elem
161
     *          the current list of DynFielModelElements
162
     * @param DynFieldModel 
163
     *          the element to be verified.
129 164
     * @return
165
     *          true if it already exists, false otherwise.
130 166
     */
131 167
    private boolean isNewElement(List list, DynFieldModel elem) {
132 168
        if ((list == null) || (elem == null))

Also available in: Unified diff