summaryrefslogtreecommitdiff
path: root/NET/worlds/console/UpdateableDialog.java
blob: f476433acc5879a5bcc8a8c49ac4f08d74bf649b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/*     */ package NET.worlds.console;
/*     */ 
/*     */ import java.awt.Button;
/*     */ import java.awt.Event;
/*     */ import java.awt.Font;
/*     */ import java.awt.GridBagConstraints;
/*     */ import java.awt.GridBagLayout;
/*     */ import java.awt.Window;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class UpdateableDialog
/*     */   extends PolledDialog
/*     */ {
/*     */   private static final long serialVersionUID = 8859312510212567551L;
/*  29 */   protected Button okButton = new Button(Console.message("OK"));
/*  30 */   protected Button cancelButton = new Button(Console.message("Cancel"));
/*  31 */   protected GridBagLayout gbag = new GridBagLayout();
/*     */   private String prompt;
/*     */   private MultiLineLabel promptLabel;
/*  34 */   private static Font font = new Font(Console.message("MenuFont"), 
/*  35 */     0, 12);
/*  36 */   private static Font bfont = new Font(Console.message("ButtonFont"), 
/*  37 */     0, 12);
/*     */   
/*     */ 
/*  40 */   protected int cancelKey = 27;
/*  41 */   protected int confirmKey = 10;
/*     */   
/*     */   protected UpdateableDialog(Window parent, String title)
/*     */   {
/*  45 */     this(parent, (DialogReceiver)parent, title);
/*     */   }
/*     */   
/*     */   protected UpdateableDialog(Window parent, String title, String cancel, String ok)
/*     */   {
/*  50 */     this(parent, (DialogReceiver)parent, title, cancel, ok);
/*     */   }
/*     */   
/*     */   protected UpdateableDialog(Window parent, DialogReceiver target, String title)
/*     */   {
/*  55 */     this(parent, target, title, true);
/*     */   }
/*     */   
/*     */   protected UpdateableDialog(Window parent, DialogReceiver target, String title, boolean modal)
/*     */   {
/*  60 */     super(parent, target, title, modal);
/*  61 */     setLayout(this.gbag);
/*     */   }
/*     */   
/*     */   protected UpdateableDialog(Window parent, DialogReceiver target, String title, String cancel, String ok)
/*     */   {
/*  66 */     this(parent, target, title, cancel, ok, true);
/*     */   }
/*     */   
/*     */   protected UpdateableDialog(Window parent, DialogReceiver target, String title, String cancel, String ok, boolean modal)
/*     */   {
/*  71 */     this(parent, target, title, modal);
/*  72 */     if (ok != null) {
/*  73 */       this.okButton.setLabel(ok);
/*     */     } else {
/*  75 */       this.okButton = null;
/*     */     }
/*  77 */     if (cancel != null) {
/*  78 */       this.cancelButton.setLabel(cancel);
/*     */     } else {
/*  80 */       this.cancelButton = null;
/*     */     }
/*     */   }
/*     */   
/*     */   public UpdateableDialog(Window parent, DialogReceiver target, String title, String cancel, String ok, String prompt) {
/*  85 */     this(parent, target, title, cancel, ok, prompt, true);
/*     */   }
/*     */   
/*     */   public UpdateableDialog(Window parent, DialogReceiver target, String title, String cancel, String ok, String prompt, boolean modal)
/*     */   {
/*  90 */     this(parent, target, title, cancel, ok, modal);
/*  91 */     setFont(font);
/*  92 */     this.prompt = prompt;
/*  93 */     ready();
/*     */   }
/*     */   
/*     */ 
/*     */   public UpdateableDialog(Window parent, DialogReceiver target, String title, String cancel, String ok, String prompt, boolean modal, int alignment)
/*     */   {
/*  99 */     this(parent, target, title, cancel, ok, modal);
/* 100 */     this.prompt = prompt;
/* 101 */     setAlignment(alignment);
/* 102 */     ready();
/*     */   }
/*     */   
/*     */   protected void build()
/*     */   {
/* 107 */     GridBagConstraints c = new GridBagConstraints();
/* 108 */     if (this.prompt != null) {
/* 109 */       c.weightx = 1.0D;
/* 110 */       c.weighty = 1.0D;
/* 111 */       c.gridwidth = 0;
/* 112 */       this.promptLabel = new MultiLineLabel(this.prompt, 5, 5);
/* 113 */       this.promptLabel.setFont(font);
/* 114 */       add(this.gbag, this.promptLabel, c);
/*     */     }
/* 116 */     int count = 0;
/* 117 */     if (this.okButton != null)
/* 118 */       count++;
/* 119 */     if (this.cancelButton != null)
/* 120 */       count++;
/* 121 */     c.gridwidth = count;
/* 122 */     c.weightx = 1.0D;
/* 123 */     c.weighty = 0.0D;
/* 124 */     if (this.okButton != null) {
/* 125 */       this.okButton.setFont(bfont);
/* 126 */       add(this.gbag, this.okButton, c);
/*     */     }
/* 128 */     if (this.cancelButton != null) {
/* 129 */       this.cancelButton.setFont(bfont);
/* 130 */       add(this.gbag, this.cancelButton, c);
/*     */     }
/*     */   }
/*     */   
/*     */   @Deprecated
/*     */   public boolean action(Event event, Object what)
/*     */   {
/* 137 */     Object target = event.target;
/* 138 */     if ((target == this.okButton) && (setValue()))
/* 139 */       return done(true);
/* 140 */     if (target == this.cancelButton)
/* 141 */       return done(false);
/* 142 */     return false;
/*     */   }
/*     */   
/*     */   protected boolean setValue() {
/* 146 */     return true;
/*     */   }
/*     */   
/*     */   public void setCancelKey(int key) {
/* 150 */     this.cancelKey = key;
/*     */   }
/*     */   
/*     */   public void setConfirmKey(int key) {
/* 154 */     this.confirmKey = key;
/*     */   }
/*     */   
/*     */   @Deprecated
/*     */   public boolean keyDown(Event event, int key)
/*     */   {
/* 160 */     if (key == this.cancelKey)
/* 161 */       return done(false);
/* 162 */     if (key == this.confirmKey)
/*     */     {
/*     */ 
/*     */ 
/* 166 */       if (this.okButton != null) {
/* 167 */         if (setValue())
/* 168 */           return done(true);
/*     */       } else
/* 170 */         return done(false);
/*     */     }
/* 172 */     return super.keyDown(event, key);
/*     */   }
/*     */   
/*     */   public void setPrompt(String text) {
/* 176 */     GridBagConstraints c = new GridBagConstraints();
/* 177 */     this.prompt = text;
/* 178 */     if (this.promptLabel != null) {
/* 179 */       this.gbag.removeLayoutComponent(this.promptLabel);
/*     */     }
/*     */     
/* 182 */     c.weightx = 1.0D;
/* 183 */     c.weighty = 1.0D;
/* 184 */     c.gridwidth = 0;
/* 185 */     this.promptLabel = new MultiLineLabel(this.prompt, 5, 5);
/* 186 */     add(this.gbag, this.promptLabel, c);
/*     */     
/* 188 */     setVisible(true);
/*     */   }
/*     */   
/*     */   public void closeIt(boolean state)
/*     */   {
/* 193 */     done(state);
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\UpdateableDialog.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */