summaryrefslogtreecommitdiff
path: root/NET/worlds/console/EditNamesDialog.java
blob: be17e1e352333bc45ad3779c444e2422c62d3d8b (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
202
203
204
205
206
207
208
209
/*     */ 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.List;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ class EditNamesDialog
/*     */   extends PolledDialog
/*     */   implements DialogReceiver
/*     */ {
/*     */   private static final long serialVersionUID = -3309806087387084117L;
/*  34 */   private List listbox = new List(10);
/*  35 */   private Button addButton = new Button(Console.message("Add"));
/*  36 */   private Button delButton = new Button(Console.message("Delete"));
/*  37 */   private Button cancelButton = new Button(Console.message("Done"));
/*     */   private NameListOwner owner;
/*     */   private String addTitle;
/*  40 */   private static Font font = new Font(Console.message("ButtonFont"), 
/*  41 */     0, 12);
/*     */   
/*     */ 
/*     */   EditNamesDialog(NameListOwner owner, String title, String addTitle)
/*     */   {
/*  46 */     super(Console.getFrame(), null, title, true);
/*     */     
/*     */ 
/*  49 */     this.owner = owner;
/*  50 */     this.addTitle = addTitle;
/*  51 */     ready();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   protected void build()
/*     */   {
/*  58 */     int count = this.owner.getNameListCount();
/*  59 */     for (int i = 0; i < count; i++) {
/*  60 */       this.listbox.add(this.owner.getNameListName(i));
/*     */     }
/*     */     
/*  63 */     GridBagLayout gbag = new GridBagLayout();
/*  64 */     setLayout(gbag);
/*  65 */     GridBagConstraints c = new GridBagConstraints();
/*  66 */     c.fill = 1;
/*  67 */     c.weightx = 1.0D;
/*  68 */     c.weighty = 1.0D;
/*  69 */     c.gridwidth = 2;
/*  70 */     c.gridheight = 3;
/*  71 */     add(gbag, this.listbox, c);
/*  72 */     c.weightx = 0.0D;
/*  73 */     c.weighty = 0.0D;
/*  74 */     c.gridwidth = 0;
/*  75 */     c.gridheight = 1;
/*  76 */     c.fill = 2;
/*  77 */     this.addButton.setFont(font);
/*  78 */     this.delButton.setFont(font);
/*  79 */     this.cancelButton.setFont(font);
/*  80 */     add(gbag, this.addButton, c);
/*  81 */     add(gbag, this.delButton, c);
/*  82 */     c.weighty = 1.0D;
/*  83 */     c.anchor = 15;
/*  84 */     add(gbag, this.cancelButton, c);
/*     */   }
/*     */   
/*     */ 
/*     */   private void select(boolean state)
/*     */   {
/*  90 */     this.delButton.setEnabled(state);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public void setVisible(boolean visible)
/*     */   {
/*  98 */     super.setVisible(visible);
/*     */     
/* 100 */     if (visible)
/*     */     {
/* 102 */       if (this.listbox.getItemCount() != 0) {
/* 103 */         this.listbox.select(0);
/* 104 */         select(true);
/*     */       } else {
/* 106 */         select(false);
/*     */       }
/*     */       
/* 109 */       this.listbox.requestFocus();
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   @Deprecated
/*     */   public boolean handleEvent(Event event)
/*     */   {
/* 118 */     if (event.id == 701) {
/* 119 */       select(true);
/* 120 */     } else if (event.id == 702) {
/* 121 */       select(false);
/*     */     }
/*     */     
/* 124 */     return super.handleEvent(event);
/*     */   }
/*     */   
/*     */ 
/*     */   @Deprecated
/*     */   public boolean action(Event event, Object what)
/*     */   {
/* 131 */     Object target = event.target;
/*     */     
/*     */ 
/* 134 */     if (target == this.cancelButton) {
/* 135 */       return done(false);
/*     */     }
/*     */     
/* 138 */     if (target == this.delButton) {
/* 139 */       int index = this.listbox.getSelectedIndex();
/* 140 */       if (index != -1)
/*     */       {
/*     */ 
/* 143 */         this.listbox.remove(index);
/* 144 */         this.owner.removeNameListName(index);
/*     */         
/*     */ 
/* 147 */         int count = this.listbox.getItemCount();
/* 148 */         if (index < count - 1) {
/* 149 */           this.listbox.select(index);
/* 150 */         } else if (count > 0) {
/* 151 */           this.listbox.select(count - 1);
/*     */         } else {
/* 153 */           select(false);
/* 154 */           this.listbox.requestFocus();
/*     */         }
/*     */       }
/* 157 */       return true;
/*     */     }
/*     */     
/*     */ 
/* 161 */     if (target == this.addButton)
/*     */     {
/*     */ 
/* 164 */       if (this.owner.mayAddNameListName(this))
/* 165 */         new AddNameDialog(this, this.addTitle);
/* 166 */       return true;
/*     */     }
/* 168 */     return false;
/*     */   }
/*     */   
/*     */ 
/*     */   @Deprecated
/*     */   public boolean keyDown(Event event, int key)
/*     */   {
/* 175 */     if ((key == 27) || (key == 10))
/* 176 */       return done(false);
/* 177 */     return super.keyDown(event, key);
/*     */   }
/*     */   
/*     */   public void dialogDone(Object who, boolean confirmed)
/*     */   {
/* 182 */     if (confirmed)
/*     */     {
/*     */ 
/* 185 */       String name = 
/* 186 */         Console.parseUnicode(((AddNameDialog)who).getName());
/* 187 */       int pos = this.owner.addNameListName(name);
/*     */       
/* 189 */       if (pos == -1) {
/* 190 */         return;
/*     */       }
/*     */       
/*     */ 
/* 194 */       if (pos == this.listbox.getItemCount()) {
/* 195 */         this.listbox.add(name);
/*     */       }
/*     */       
/* 198 */       this.listbox.makeVisible(pos);
/* 199 */       this.listbox.select(pos);
/* 200 */       select(true);
/*     */     }
/*     */   }
/*     */ }


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