001: /*
002: * Jacareto Copyright (c) 2002-2005
003: * Applied Computer Science Research Group, Darmstadt University of
004: * Technology, Institute of Mathematics & Computer Science,
005: * Ludwigsburg University of Education, and Computer Based
006: * Learning Research Group, Aachen University. All rights reserved.
007: *
008: * Jacareto is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * Jacareto is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public
019: * License along with Jacareto; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: *
022: */
023:
024: package jacareto.comp;
025:
026: import jacareto.record.Recordable;
027: import jacareto.system.Environment;
028:
029: import java.util.Collection;
030: import java.util.Vector;
031:
032: /**
033: * This class represents the component mode.
034: *
035: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
036: * @version 1.0
037: */
038: public class ComponentMode extends Recordable {
039: /** Whether or not new dialogs should be set to modal. */
040: private boolean newDialogsModal;
041:
042: /** Whether or not the new dialogs modal property should be applied. */
043: private boolean applyNewDialogsModal;
044:
045: /** The vector which contains the names for renaming new roots. */
046: private Vector newRootNames;
047:
048: /** Whether or not popup menues should be numbered. */
049: private boolean numberPopupMenues;
050:
051: /**
052: * Creates a new instance with the given values.
053: *
054: * @param env the environment
055: * @param newDialogsModal whether or not new dialogs should be set to modal
056: * @param applyNewDialogsModal whether or not the new dialogs modal property should be applied
057: * @param numberPopupMenues DOCUMENT ME!
058: * @param newRootNames the vector with the new root names
059: */
060: public ComponentMode(Environment env, boolean newDialogsModal,
061: boolean applyNewDialogsModal, boolean numberPopupMenues,
062: Vector newRootNames) {
063: super (env);
064: setNewDialogsModal(newDialogsModal);
065: setApplyNewDialogsModal(applyNewDialogsModal);
066: setNumberPopupMenues(numberPopupMenues);
067: this .newRootNames = newRootNames;
068: }
069:
070: /**
071: * Creates a new instance with the given values.
072: *
073: * @param env the environment
074: * @param newDialogsModal whether or not new dialogs should be set to modal
075: * @param applyNewDialogsModal whether or not the new dialogs modal property should be applied
076: * @param numberPopupMenues DOCUMENT ME!
077: */
078: public ComponentMode(Environment env, boolean newDialogsModal,
079: boolean applyNewDialogsModal, boolean numberPopupMenues) {
080: this (env, newDialogsModal, applyNewDialogsModal,
081: numberPopupMenues, new Vector(5, 5));
082: }
083:
084: /**
085: * Creates a new user with default values.
086: *
087: * @param env the environment
088: */
089: public ComponentMode(Environment env) {
090: this (env, false, false, true);
091: }
092:
093: /**
094: * Creates an instance with default values and no environment. The environment should be
095: * defined with the method {@link
096: * jacareto.system.EnvironmentMember#setEnvironment(Environment)} before environment instances
097: * will be accessed.
098: */
099: public ComponentMode() {
100: this (null);
101: }
102:
103: /**
104: * Sets the new dialog modal property.
105: *
106: * @param newDialogsModal whether or not new dialogs should be made modal
107: */
108: public void setNewDialogsModal(boolean newDialogsModal) {
109: this .newDialogsModal = newDialogsModal;
110: fireValuesChanged();
111: }
112:
113: /**
114: * Returns the new dialog modal property.
115: *
116: * @return guess!
117: */
118: public boolean getNewDialogsModal() {
119: return newDialogsModal;
120: }
121:
122: /**
123: * Sets whether or not the dialog modal property should be applied
124: *
125: * @param applyNewDialogsModal whether or not the the property should be applied
126: */
127: public void setApplyNewDialogsModal(boolean applyNewDialogsModal) {
128: this .applyNewDialogsModal = applyNewDialogsModal;
129: fireValuesChanged();
130: }
131:
132: /**
133: * Returns whether or not the dialog modal property should be applied
134: *
135: * @return guess!
136: */
137: public boolean getApplyNewDialogsModal() {
138: return applyNewDialogsModal;
139: }
140:
141: /**
142: * Sets whether or not new popup menues should be numbered
143: *
144: * @param numberPopupMenues <code>true</code> if popup menues should be numbered, otherwise
145: * <code>false</code>
146: */
147: public void setNumberPopupMenues(boolean numberPopupMenues) {
148: this .numberPopupMenues = numberPopupMenues;
149: fireValuesChanged();
150: }
151:
152: /**
153: * Returns whether or not the popup menues should be numbered should be applied
154: *
155: * @return guess!
156: */
157: public boolean getNumberPopupMenues() {
158: return numberPopupMenues;
159: }
160:
161: /**
162: * Adds names for renaming new roots.
163: *
164: * @param names the names to be added
165: */
166: public void addNewRootNames(Collection names) {
167: newRootNames.addAll(names);
168: fireValuesChanged();
169: }
170:
171: /**
172: * Returns whether or not a new root name is contained.
173: *
174: * @return <code>true</code> if there is a new root name, otherwise <code>false</code>
175: */
176: public boolean containsNewRootName() {
177: return !newRootNames.isEmpty();
178: }
179:
180: /**
181: * Adds a new root name.
182: *
183: * @param name the new name
184: */
185: public void addNewRootName(String name) {
186: newRootNames.add(name);
187: fireValuesChanged();
188: }
189:
190: /**
191: * Removes the new root name at the specified index.
192: *
193: * @param index the index of the name to be removed
194: */
195: public void removeNewRootName(int index) {
196: if ((0 <= index) && (index < newRootNames.size())) {
197: newRootNames.remove(index);
198: fireValuesChanged();
199: }
200: }
201:
202: /**
203: * Clears the list of new root names.
204: */
205: public void clearNewRootNames() {
206: newRootNames.clear();
207: fireValuesChanged();
208: }
209:
210: /**
211: * Returns a vector with the new root names.
212: *
213: * @return DOCUMENT ME!
214: */
215: public Vector getNewRootNames() {
216: return newRootNames;
217: }
218:
219: /**
220: * Returns the new root name at <code>index</code>.
221: *
222: * @param index the index
223: *
224: * @return the name
225: */
226: public String getNewRootName(int index) {
227: return (String) newRootNames.get(index);
228: }
229:
230: /**
231: * Returns the name of the recordable
232: *
233: * @return the name
234: */
235: public String getElementName() {
236: return getLanguage().getString("Components.Mode.Name");
237: }
238:
239: /**
240: * Returns a description of the recordable.
241: *
242: * @return the description
243: */
244: public String getElementDescription() {
245: return getLanguage().getString("Components.Mode.Description");
246: }
247:
248: /**
249: * Returns a String which describes the content of the recordable shortly.
250: *
251: * @return a string with a short description of the recordable
252: */
253: public String toShortString() {
254: return getElementName();
255: }
256:
257: /**
258: * Clones the element.
259: *
260: * @return a clone
261: */
262: public Object clone() {
263: ComponentMode result = (ComponentMode) super .clone();
264: result.newRootNames = new Vector(this .newRootNames);
265:
266: return result;
267: }
268:
269: public boolean hasProcTime() {
270: return false;
271: }
272: }
|