KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > gulden > framework > amoda > generic > interaction > GenericDialog


1 /*
2  * Project: AMODA - Abstract Modeled Application
3  * Class: de.gulden.framework.amoda.generic.interaction.GenericDialog
4  * Version: snapshot-beautyj-1.1
5  *
6  * Date: 2004-09-29
7  *
8  * This is a snapshot version of the AMODA 0.2 development branch,
9  * it is not released as a seperate version.
10  * For AMODA, see http://amoda.berlios.de/.
11  *
12  * This is licensed under the GNU Lesser General Public License (LGPL)
13  * and comes with NO WARRANTY.
14  *
15  * Author: Jens Gulden
16  * Email: amoda@jensgulden.de
17  */

18
19 package de.gulden.framework.amoda.generic.interaction;
20
21 import de.gulden.framework.amoda.generic.option.*;
22 import de.gulden.framework.amoda.model.interaction.Dialog;
23 import de.gulden.framework.amoda.model.option.*;
24 import java.lang.*;
25 import java.util.*;
26 import javax.swing.*;
27
28 /**
29  * Class GenericDialog.
30  *
31  * @author Jens Gulden
32  * @version snapshot-beautyj-1.1
33  */

34 public class GenericDialog extends GenericQuestion implements Dialog {
35
36     // ------------------------------------------------------------------------
37
// --- fields ---
38
// ------------------------------------------------------------------------
39

40     public boolean fileDialog = false;
41
42     public boolean save = false;
43
44     public boolean directories = false;
45
46     public JDialog jDialog;
47
48
49     // ------------------------------------------------------------------------
50
// --- constructor ---
51
// ------------------------------------------------------------------------
52

53     public GenericDialog() {
54         setType(PLAIN_MESSAGE);
55         setAnswers(OK+","+CANCEL);
56         setDefaultAnswer(OK);
57     }
58
59
60     // ------------------------------------------------------------------------
61
// --- methods ---
62
// ------------------------------------------------------------------------
63

64     public JDialog getJDialog() {
65         return jDialog;
66     }
67
68     public void setJDialog(JDialog jDialog) {
69         this.jDialog = jDialog;
70     }
71
72     public void ok() {
73         setAnswer(OK);
74         ((de.gulden.framework.amoda.generic.option.GenericOptions)getOptions()).shiftAllValues(Option.STATE_EDIT,Option.STATE_CURRENT);
75         // update option values
76
/*Map map=getOptions().getAll(de.gulden.framework.amoda.generic.option.GenericOptionEntry.class,true);
77         for (Iterator it=map.values().iterator();it.hasNext();) {
78             de.gulden.framework.amoda.generic.option.GenericOptionEntry entry=(de.gulden.framework.amoda.generic.option.GenericOptionEntry)it.next();
79             entry.shiftValue(Option.STATE_EDIT,Option.STATE_CURRENT);
80         }*/

81         JDialog d = getJDialog();
82         d.setVisible(false);
83     }
84
85     public void reset() {
86         for (Iterator it=getOptions().getAll(de.gulden.framework.amoda.generic.option.GenericOptionEntry.class,true).values().iterator();it.hasNext();) {
87             de.gulden.framework.amoda.generic.option.GenericOptionEntry entry=(de.gulden.framework.amoda.generic.option.GenericOptionEntry)it.next();
88             entry.shiftValue(Option.STATE_CURRENT,Option.STATE_EDIT);
89             // **** GUI updaten !!!!!!!!********
90
}
91     }
92
93     public void perform() {
94         ((de.gulden.framework.amoda.generic.core.GenericApplicationEnvironment)getApplication().getEnvironment()).doDialog(this);
95     }
96
97     public String JavaDoc toString() {
98         return getText();
99     }
100
101     public void cancel() {
102         setAnswer(CANCEL);
103         Map map=getOptions().getAll(de.gulden.framework.amoda.generic.option.GenericOptionEntry.class,true);
104         for (Iterator it=map.values().iterator();it.hasNext();) {
105             de.gulden.framework.amoda.generic.option.GenericOptionEntry entry=(de.gulden.framework.amoda.generic.option.GenericOptionEntry)it.next();
106             ((de.gulden.framework.amoda.generic.data.GenericValue)(entry.getValue(Option.STATE_EDIT))).set(null);
107         }
108         getJDialog().setVisible(false);
109     }
110
111     public boolean isFileDialog() {
112         return fileDialog;
113     }
114
115     public void setFileDialog(boolean _fileDialog) {
116         fileDialog = _fileDialog;
117     }
118
119     public boolean isSave() {
120         return save;
121     }
122
123     public void setSave(boolean _save) {
124         save = _save;
125     }
126
127     public boolean isDirectories() {
128         return directories;
129     }
130
131     public void setDirectories(boolean _directories) {
132         directories = _directories;
133     }
134
135 } // end GenericDialog
136
Popular Tags