001: /*
002: * Project: AMODA - Abstract Modeled Application
003: * Class: de.gulden.framework.amoda.generic.interaction.GenericDialog
004: * Version: snapshot-beautyj-1.1
005: *
006: * Date: 2004-09-29
007: *
008: * This is a snapshot version of the AMODA 0.2 development branch,
009: * it is not released as a seperate version.
010: * For AMODA, see http://amoda.berlios.de/.
011: *
012: * This is licensed under the GNU Lesser General Public License (LGPL)
013: * and comes with NO WARRANTY.
014: *
015: * Author: Jens Gulden
016: * Email: amoda@jensgulden.de
017: */
018:
019: package de.gulden.framework.amoda.generic.interaction;
020:
021: import de.gulden.framework.amoda.generic.option.*;
022: import de.gulden.framework.amoda.model.interaction.Dialog;
023: import de.gulden.framework.amoda.model.option.*;
024: import java.lang.*;
025: import java.util.*;
026: import javax.swing.*;
027:
028: /**
029: * Class GenericDialog.
030: *
031: * @author Jens Gulden
032: * @version snapshot-beautyj-1.1
033: */
034: public class GenericDialog extends GenericQuestion implements Dialog {
035:
036: // ------------------------------------------------------------------------
037: // --- fields ---
038: // ------------------------------------------------------------------------
039:
040: public boolean fileDialog = false;
041:
042: public boolean save = false;
043:
044: public boolean directories = false;
045:
046: public JDialog jDialog;
047:
048: // ------------------------------------------------------------------------
049: // --- constructor ---
050: // ------------------------------------------------------------------------
051:
052: public GenericDialog() {
053: setType(PLAIN_MESSAGE);
054: setAnswers(OK + "," + CANCEL);
055: setDefaultAnswer(OK);
056: }
057:
058: // ------------------------------------------------------------------------
059: // --- methods ---
060: // ------------------------------------------------------------------------
061:
062: public JDialog getJDialog() {
063: return jDialog;
064: }
065:
066: public void setJDialog(JDialog jDialog) {
067: this .jDialog = jDialog;
068: }
069:
070: public void ok() {
071: setAnswer(OK);
072: ((de.gulden.framework.amoda.generic.option.GenericOptions) getOptions())
073: .shiftAllValues(Option.STATE_EDIT, Option.STATE_CURRENT);
074: // update option values
075: /*Map map=getOptions().getAll(de.gulden.framework.amoda.generic.option.GenericOptionEntry.class,true);
076: for (Iterator it=map.values().iterator();it.hasNext();) {
077: de.gulden.framework.amoda.generic.option.GenericOptionEntry entry=(de.gulden.framework.amoda.generic.option.GenericOptionEntry)it.next();
078: entry.shiftValue(Option.STATE_EDIT,Option.STATE_CURRENT);
079: }*/
080: JDialog d = getJDialog();
081: d.setVisible(false);
082: }
083:
084: public void reset() {
085: for (Iterator it = getOptions()
086: .getAll(
087: de.gulden.framework.amoda.generic.option.GenericOptionEntry.class,
088: true).values().iterator(); it.hasNext();) {
089: de.gulden.framework.amoda.generic.option.GenericOptionEntry entry = (de.gulden.framework.amoda.generic.option.GenericOptionEntry) it
090: .next();
091: entry.shiftValue(Option.STATE_CURRENT, Option.STATE_EDIT);
092: // **** GUI updaten !!!!!!!!********
093: }
094: }
095:
096: public void perform() {
097: ((de.gulden.framework.amoda.generic.core.GenericApplicationEnvironment) getApplication()
098: .getEnvironment()).doDialog(this );
099: }
100:
101: public String toString() {
102: return getText();
103: }
104:
105: public void cancel() {
106: setAnswer(CANCEL);
107: Map map = getOptions()
108: .getAll(
109: de.gulden.framework.amoda.generic.option.GenericOptionEntry.class,
110: true);
111: for (Iterator it = map.values().iterator(); it.hasNext();) {
112: de.gulden.framework.amoda.generic.option.GenericOptionEntry entry = (de.gulden.framework.amoda.generic.option.GenericOptionEntry) it
113: .next();
114: ((de.gulden.framework.amoda.generic.data.GenericValue) (entry
115: .getValue(Option.STATE_EDIT))).set(null);
116: }
117: getJDialog().setVisible(false);
118: }
119:
120: public boolean isFileDialog() {
121: return fileDialog;
122: }
123:
124: public void setFileDialog(boolean _fileDialog) {
125: fileDialog = _fileDialog;
126: }
127:
128: public boolean isSave() {
129: return save;
130: }
131:
132: public void setSave(boolean _save) {
133: save = _save;
134: }
135:
136: public boolean isDirectories() {
137: return directories;
138: }
139:
140: public void setDirectories(boolean _directories) {
141: directories = _directories;
142: }
143:
144: } // end GenericDialog
|