001: /*
002: * This file is part of JGAP.
003: *
004: * JGAP offers a dual license model containing the LGPL as well as the MPL.
005: *
006: * For licensing information please see the file license.txt included with JGAP
007: * or have a look at the top of class org.jgap.Chromosome which representatively
008: * includes the JGAP license policy applicable for any file delivered with JGAP.
009: */
010: package org.jgap.data.config;
011:
012: import java.util.*;
013:
014: /**
015: * Represents a property to be shown on the configuration screen.
016: *
017: * @author Siddhartha Azad
018: * @since 2.3
019: */
020: public class ConfigProperty {
021: /** String containing the CVS revision. Read out via reflection!*/
022: private final static String CVS_REVISION = "$Revision: 1.5 $";
023:
024: // name of the property
025: private String m_name;
026:
027: // widget to use to get the value of this property
028: private String m_widget;
029:
030: // label with which to display this property
031: private String m_label;
032:
033: // allowed values for this property (if applicable)
034: private List m_values;
035:
036: /**
037: * Default Constructor for a ConfigProperty.
038: *
039: * @author Siddhartha Azad
040: * @since 2.3
041: */
042: public ConfigProperty() {
043: // defaults
044: m_name = "";
045: m_label = "";
046: m_widget = "JTextField";
047: m_values = Collections.synchronizedList(new ArrayList());
048: }
049:
050: /**
051: * @return name associated with this property
052: *
053: * @author Siddhartha Azad
054: * @since 2.3
055: */
056: public String getName() {
057: return m_name;
058: }
059:
060: /**
061: * Setter for the name of this property.
062: * @param a_name the name associated with this property. This name will be
063: * used as the key in the properties file for persisting
064: * configuration information
065: *
066: * @author Siddhartha Azad
067: * @since 2.3
068: */
069: public void setName(final String a_name) {
070: m_name = a_name;
071: // by default display label is same as the name
072: if (m_label.equals("")) {
073: m_label = a_name;
074: }
075: }
076:
077: /**
078: * @return name of the widget associated with this property
079: *
080: * @author Siddhartha Azad
081: * @since 2.3
082: */
083: public String getWidget() {
084: return m_widget;
085: }
086:
087: /**
088: * Sets the widget.
089: * @param a_widget either "JList" or "JTextField" for now
090: *
091: * @author Siddhartha Azad
092: * @since 2.3
093: */
094: public void setWidget(final String a_widget) {
095: m_widget = a_widget;
096: }
097:
098: /**
099: * @return label of the property
100: *
101: * @author Siddhartha Azad
102: * @since 2.4
103: */
104: public String getLabel() {
105: return m_label;
106: }
107:
108: /**
109: * Sets the label.
110: * @param a_label the label of this property, by default the same as the
111: * name of the property
112: *
113: * @author Siddhartha Azad
114: * @since 2.4
115: */
116: public void setLabel(final String a_label) {
117: m_label = a_label;
118: }
119:
120: /**
121: * Add a value into the values ArrayList. These values are added in case the
122: * display component is a ListBox or ComboBox or something that can have
123: * multiple values.
124: * @param a_value the value to add
125: *
126: * @author Siddhartha Azad
127: * @since 2.3
128: */
129: public void addValue(final String a_value) {
130: m_values.add(a_value);
131: }
132:
133: /**
134: * @return iterator on the values ArrayList for this property
135: *
136: * @author Siddhartha Azad
137: * @since 2.3
138: */
139: public Iterator getValuesIter() {
140: return m_values.iterator();
141: }
142: }
|