|
@@ -23,21 +23,20 @@
|
23
|
23
|
package com.dmdirc.ui.swing.dialogs.profiles;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.IconManager;
|
|
26
|
+import com.dmdirc.Main;
|
|
27
|
+import com.dmdirc.ui.swing.MainFrame;
|
26
|
28
|
import com.dmdirc.ui.swing.components.ImageButton;
|
27
|
|
-import static com.dmdirc.ui.swing.UIUtilities.layoutGrid;
|
28
|
|
-import static com.dmdirc.ui.swing.UIUtilities.SMALL_BORDER;
|
|
29
|
+import com.dmdirc.ui.swing.components.StandardInputDialog;
|
|
30
|
+import com.dmdirc.ui.swing.components.validating.NotEmptyValidator;
|
|
31
|
+import com.dmdirc.ui.swing.components.validating.RegexValidator;
|
|
32
|
+import com.dmdirc.ui.swing.components.validating.ValidatingJTextField;
|
29
|
33
|
|
30
|
|
-import java.awt.Component;
|
31
|
34
|
import java.awt.Dimension;
|
32
|
|
-import java.awt.GridLayout;
|
33
|
35
|
import java.awt.event.ActionEvent;
|
34
|
36
|
import java.awt.event.ActionListener;
|
35
|
37
|
import java.util.ArrayList;
|
36
|
38
|
import java.util.Enumeration;
|
37
|
|
-import java.util.HashMap;
|
38
|
|
-import java.util.Map;
|
39
|
39
|
|
40
|
|
-import javax.swing.Box;
|
41
|
40
|
import javax.swing.DefaultListModel;
|
42
|
41
|
import javax.swing.Icon;
|
43
|
42
|
import javax.swing.JButton;
|
|
@@ -46,76 +45,52 @@ import javax.swing.JList;
|
46
|
45
|
import javax.swing.JOptionPane;
|
47
|
46
|
import javax.swing.JPanel;
|
48
|
47
|
import javax.swing.JScrollPane;
|
49
|
|
-import javax.swing.JTextField;
|
50
|
|
-import javax.swing.SpringLayout;
|
51
|
|
-import javax.swing.event.DocumentEvent;
|
52
|
|
-import javax.swing.event.DocumentListener;
|
53
|
48
|
import javax.swing.event.ListDataEvent;
|
54
|
49
|
import javax.swing.event.ListDataListener;
|
55
|
50
|
import javax.swing.event.ListSelectionEvent;
|
56
|
51
|
import javax.swing.event.ListSelectionListener;
|
57
|
|
-import javax.swing.text.Document;
|
|
52
|
+
|
|
53
|
+import net.miginfocom.swing.MigLayout;
|
58
|
54
|
|
59
|
55
|
/** Profile detail panel. */
|
60
|
56
|
public class ProfileDetailPanel extends JPanel implements ActionListener,
|
61
|
|
- ListSelectionListener, DocumentListener,
|
62
|
|
- ListDataListener {
|
|
57
|
+ ListSelectionListener, ListDataListener {
|
63
|
58
|
|
64
|
59
|
/**
|
65
|
60
|
* A version number for this class. It should be changed whenever the class
|
66
|
61
|
* structure is changed (or anything else that would prevent serialized
|
67
|
62
|
* objects being unserialized with the new class).
|
68
|
63
|
*/
|
69
|
|
- private static final long serialVersionUID = 1;
|
70
|
|
- /** Invalid filename characters. */
|
71
|
|
- private static final String FILENAME_REGEX = ".*[^\\w ].*";
|
72
|
|
- /** Invalid nickname characters. */
|
73
|
|
- private static final String NICKNAME_REGEX = ".*[\\a\\v\\s].*";
|
74
|
|
- /** Invalid ident characters. */
|
75
|
|
- private static final String IDENT_REGEX = ".*[\\a\\v\\s].*";
|
|
64
|
+ private static final long serialVersionUID = 2;
|
|
65
|
+ /** Nickname regex. */
|
|
66
|
+ private static final String NICKNAME_REGEX =
|
|
67
|
+ "[A-Za-z0-9\\[\\]{|}\\-\\^\\\\]+";
|
|
68
|
+ /** Filename regex. */
|
|
69
|
+ private static final String FILENAME_REGEX = "[A-Za-z0-9]+";
|
76
|
70
|
/** Displayed profile. */
|
77
|
71
|
private Profile profile;
|
78
|
72
|
/** Name text field. */
|
79
|
|
- private JTextField name;
|
|
73
|
+ private ValidatingJTextField name;
|
80
|
74
|
/** Nick name text field. */
|
81
|
|
- private JTextField nickname;
|
|
75
|
+ private ValidatingJTextField nickname;
|
82
|
76
|
/** Realname text field. */
|
83
|
|
- private JTextField realname;
|
|
77
|
+ private ValidatingJTextField realname;
|
84
|
78
|
/** Ident text field. */
|
85
|
|
- private JTextField ident;
|
|
79
|
+ private ValidatingJTextField ident;
|
86
|
80
|
/** Alternate nicknames list. */
|
87
|
81
|
private JList altNicknames;
|
88
|
|
- /** Buttons panel. */
|
89
|
|
- private JPanel buttonsPanel;
|
90
|
82
|
/** Add button. */
|
91
|
83
|
private JButton addButton;
|
92
|
84
|
/** Delete button. */
|
93
|
85
|
private JButton delButton;
|
94
|
86
|
/** Edit button. */
|
95
|
87
|
private JButton editButton;
|
96
|
|
- /** name error. */
|
97
|
|
- private ImageButton nameError;
|
98
|
|
- /** nick error. */
|
99
|
|
- private ImageButton nicknameError;
|
100
|
|
- /** real name error. */
|
101
|
|
- private ImageButton realnameError;
|
102
|
|
- /** ident error. */
|
103
|
|
- private ImageButton identError;
|
104
|
88
|
/** Alt nicknames error. */
|
105
|
89
|
private ImageButton altNicknamesError;
|
106
|
|
- /** Document -> Component map. */
|
107
|
|
- private Map<Document, Component> map;
|
108
|
|
- /** Error icon. */
|
109
|
|
- private Icon errorIcon;
|
110
|
|
- /** Warning icon. */
|
111
|
|
- private Icon warningIcon;
|
112
|
|
- /** Transparent icon. */
|
113
|
|
- private Icon normalIcon;
|
114
|
90
|
|
115
|
91
|
/** Creates a new profile detail panel. */
|
116
|
92
|
public ProfileDetailPanel() {
|
117
|
93
|
initMainComponents();
|
118
|
|
- initButtonsPanel();
|
119
|
94
|
layoutComponents();
|
120
|
95
|
|
121
|
96
|
clearProfile();
|
|
@@ -123,39 +98,19 @@ public class ProfileDetailPanel extends JPanel implements ActionListener,
|
123
|
98
|
|
124
|
99
|
/** Initialises the components in the main panel. */
|
125
|
100
|
private void initMainComponents() {
|
126
|
|
- map = new HashMap<Document, Component>();
|
127
|
|
-
|
128
|
|
- errorIcon =
|
129
|
|
- IconManager.getIconManager().getIcon("input-error");
|
130
|
|
- warningIcon = IconManager.getIconManager().getIcon("warning");
|
131
|
|
- normalIcon = IconManager.getIconManager().getIcon("nothing");
|
132
|
|
-
|
133
|
|
- name = new JTextField();
|
134
|
|
- nickname = new JTextField();
|
135
|
|
- realname = new JTextField();
|
136
|
|
- ident = new JTextField();
|
|
101
|
+ name = new ValidatingJTextField(new RegexValidator(FILENAME_REGEX,
|
|
102
|
+ "Name must only contain letters and numbers."));
|
|
103
|
+ nickname =
|
|
104
|
+ new ValidatingJTextField(new RegexValidator(NICKNAME_REGEX,
|
|
105
|
+ "Nickname must only contain letters, numbers and []{}|-^\\."));
|
|
106
|
+ realname = new ValidatingJTextField(new NotEmptyValidator());
|
|
107
|
+ ident = new ValidatingJTextField(new RegexValidator(NICKNAME_REGEX,
|
|
108
|
+ "Ident must only contain letters, numbers and []{}|-^\\."));
|
137
|
109
|
altNicknames = new JList(new DefaultListModel());
|
138
|
110
|
|
139
|
|
- nameError =
|
140
|
|
- new ImageButton("nicknameError", normalIcon);
|
141
|
|
- nicknameError =
|
142
|
|
- new ImageButton("nicknameError", normalIcon);
|
143
|
|
- realnameError =
|
144
|
|
- new ImageButton("realnameError", normalIcon);
|
145
|
|
- identError = new ImageButton("identError", normalIcon);
|
146
|
|
- altNicknamesError =
|
147
|
|
- new ImageButton("altNicknamesError", normalIcon);
|
148
|
|
-
|
149
|
|
- nameError.setFocusable(false);
|
150
|
|
- nicknameError.setFocusable(false);
|
151
|
|
- realnameError.setFocusable(false);
|
152
|
|
- identError.setFocusable(false);
|
153
|
|
- altNicknamesError.setFocusable(false);
|
154
|
|
-
|
155
|
|
- map.put(name.getDocument(), nameError);
|
156
|
|
- map.put(nickname.getDocument(), nicknameError);
|
157
|
|
- map.put(realname.getDocument(), realnameError);
|
158
|
|
- map.put(ident.getDocument(), identError);
|
|
111
|
+ addButton = new JButton("Add");
|
|
112
|
+ delButton = new JButton("Delete");
|
|
113
|
+ editButton = new JButton("Edit");
|
159
|
114
|
|
160
|
115
|
name.setPreferredSize(new Dimension(0, name.getFont().getSize()));
|
161
|
116
|
nickname.setPreferredSize(new Dimension(0, nickname.getFont().getSize()));
|
|
@@ -163,21 +118,8 @@ public class ProfileDetailPanel extends JPanel implements ActionListener,
|
163
|
118
|
ident.setPreferredSize(new Dimension(0, nickname.getFont().getSize()));
|
164
|
119
|
altNicknames.setVisibleRowCount(3);
|
165
|
120
|
|
166
|
|
- name.getDocument().addDocumentListener(this);
|
167
|
|
- nickname.getDocument().addDocumentListener(this);
|
168
|
|
- realname.getDocument().addDocumentListener(this);
|
169
|
|
- ident.getDocument().addDocumentListener(this);
|
170
|
121
|
altNicknames.addListSelectionListener(this);
|
171
|
122
|
altNicknames.getModel().addListDataListener(this);
|
172
|
|
- }
|
173
|
|
-
|
174
|
|
- /** Initialiases the components in the buttons panel. */
|
175
|
|
- private void initButtonsPanel() {
|
176
|
|
- buttonsPanel =
|
177
|
|
- new JPanel(new GridLayout(1, 3, SMALL_BORDER, SMALL_BORDER));
|
178
|
|
- addButton = new JButton("Add");
|
179
|
|
- delButton = new JButton("Delete");
|
180
|
|
- editButton = new JButton("Edit");
|
181
|
123
|
|
182
|
124
|
addButton.addActionListener(this);
|
183
|
125
|
delButton.addActionListener(this);
|
|
@@ -186,38 +128,26 @@ public class ProfileDetailPanel extends JPanel implements ActionListener,
|
186
|
128
|
|
187
|
129
|
/** Lays out the components in the panel. */
|
188
|
130
|
private void layoutComponents() {
|
189
|
|
- buttonsPanel.add(addButton);
|
190
|
|
- buttonsPanel.add(editButton);
|
191
|
|
- buttonsPanel.add(delButton);
|
192
|
|
-
|
193
|
|
- setLayout(new SpringLayout());
|
|
131
|
+ setLayout(new MigLayout("fill"));
|
194
|
132
|
|
195
|
133
|
add(new JLabel("Name:"));
|
196
|
|
- add(nameError);
|
197
|
|
- add(name);
|
|
134
|
+ add(name, "growx, pushx, wrap");
|
198
|
135
|
|
199
|
136
|
add(new JLabel("Nickname:"));
|
200
|
|
- add(nicknameError);
|
201
|
|
- add(nickname);
|
|
137
|
+ add(nickname, "growx, pushx, wrap");
|
202
|
138
|
|
203
|
139
|
add(new JLabel("Realname:"));
|
204
|
|
- add(realnameError);
|
205
|
|
- add(realname);
|
|
140
|
+ add(realname, "growx, pushx, wrap");
|
206
|
141
|
|
207
|
142
|
add(new JLabel("Ident:"));
|
208
|
|
- add(identError);
|
209
|
|
- add(ident);
|
|
143
|
+ add(ident, "growx, pushx, wrap");
|
210
|
144
|
|
211
|
145
|
add(new JLabel("Alternate nicknames:"));
|
212
|
|
- add(altNicknamesError);
|
213
|
|
- add(new JScrollPane(altNicknames));
|
214
|
|
-
|
215
|
|
- add(Box.createHorizontalGlue());
|
216
|
|
- add(Box.createHorizontalGlue());
|
217
|
|
- add(buttonsPanel);
|
|
146
|
+ add(new JScrollPane(altNicknames), "growx, pushx, wrap");
|
218
|
147
|
|
219
|
|
- layoutGrid(this, 6, 3, SMALL_BORDER, SMALL_BORDER, SMALL_BORDER,
|
220
|
|
- SMALL_BORDER);
|
|
148
|
+ add(addButton, "skip 1, split 3, sg button, growx");
|
|
149
|
+ add(editButton, "sg button, growx");
|
|
150
|
+ add(delButton, "sg button, growx");
|
221
|
151
|
}
|
222
|
152
|
|
223
|
153
|
/**
|
|
@@ -247,7 +177,7 @@ public class ProfileDetailPanel extends JPanel implements ActionListener,
|
247
|
177
|
for (String altNick : profile.getAltNicknames()) {
|
248
|
178
|
((DefaultListModel) altNicknames.getModel()).addElement(altNick);
|
249
|
179
|
}
|
250
|
|
-
|
|
180
|
+
|
251
|
181
|
name.setEnabled(true);
|
252
|
182
|
nickname.setEnabled(true);
|
253
|
183
|
realname.setEnabled(true);
|
|
@@ -272,8 +202,6 @@ public class ProfileDetailPanel extends JPanel implements ActionListener,
|
272
|
202
|
addButton.setEnabled(false);
|
273
|
203
|
delButton.setEnabled(false);
|
274
|
204
|
editButton.setEnabled(false);
|
275
|
|
-
|
276
|
|
- clearErrors();
|
277
|
205
|
}
|
278
|
206
|
|
279
|
207
|
/** Saves the detail panels details to the profile. */
|
|
@@ -293,205 +221,85 @@ public class ProfileDetailPanel extends JPanel implements ActionListener,
|
293
|
221
|
profile.addAltNickname((String) enumeration.nextElement());
|
294
|
222
|
}
|
295
|
223
|
}
|
296
|
|
-
|
297
|
|
- /** Clears error states. */
|
298
|
|
- private void clearErrors() {
|
299
|
|
- nameError.setToolTipText("");
|
300
|
|
- nicknameError.setToolTipText("");
|
301
|
|
- realnameError.setToolTipText("");
|
302
|
|
- identError.setToolTipText("");
|
303
|
|
- altNicknamesError.setToolTipText("");
|
304
|
|
-
|
305
|
|
- nameError.setIcons(normalIcon);
|
306
|
|
- nicknameError.setIcons(normalIcon);
|
307
|
|
- realnameError.setIcons(normalIcon);
|
308
|
|
- identError.setIcons(normalIcon);
|
309
|
|
- altNicknamesError.setIcons(normalIcon);
|
310
|
|
- }
|
311
|
224
|
|
312
|
225
|
/**
|
313
|
226
|
* Validates the current details.
|
314
|
227
|
*
|
315
|
228
|
* @return Validation Result
|
316
|
229
|
*/
|
317
|
|
- public ValidationResult validateDetails() {
|
318
|
|
- clearErrors();
|
319
|
|
-
|
320
|
|
- final ValidationResult checkAltNicknames = checkAltNicknames();
|
321
|
|
- final ValidationResult checkIdent = checkIdent();
|
322
|
|
- final ValidationResult checkRealname = checkRealname();
|
323
|
|
- final ValidationResult checkNickname = checkNickname();
|
324
|
|
- final ValidationResult checkName = checkName();
|
325
|
|
-
|
326
|
|
- if (checkAltNicknames.equals(ValidationResult.FAIL) ||
|
327
|
|
- checkIdent.equals(ValidationResult.FAIL) ||
|
328
|
|
- checkRealname.equals(ValidationResult.FAIL) ||
|
329
|
|
- checkNickname.equals(ValidationResult.FAIL) ||
|
330
|
|
- checkName.equals(ValidationResult.FAIL)) {
|
331
|
|
- return ValidationResult.FAIL;
|
332
|
|
- } else if (checkAltNicknames.equals(ValidationResult.WARNING) ||
|
333
|
|
- checkIdent.equals(ValidationResult.WARNING) ||
|
334
|
|
- checkRealname.equals(ValidationResult.WARNING) ||
|
335
|
|
- checkNickname.equals(ValidationResult.WARNING) ||
|
336
|
|
- checkName.equals(ValidationResult.WARNING)) {
|
337
|
|
- return ValidationResult.WARNING;
|
338
|
|
- } else {
|
339
|
|
- return ValidationResult.PASS;
|
340
|
|
- }
|
341
|
|
- }
|
342
|
|
-
|
343
|
|
- /**
|
344
|
|
- * Validates the alternate nicknames.
|
345
|
|
- *
|
346
|
|
- * @return Validation result
|
347
|
|
- */
|
348
|
|
- private ValidationResult checkAltNicknames() {
|
349
|
|
- if (!altNicknames.isEnabled() || altNicknames.getModel().getSize() == 0) {
|
350
|
|
- return ValidationResult.PASS;
|
351
|
|
- }
|
352
|
|
-
|
353
|
|
- ValidationResult returnValue =
|
354
|
|
- ValidationResult.PASS;
|
355
|
|
- final Enumeration<?> enumeration =
|
356
|
|
- ((DefaultListModel) altNicknames.getModel()).elements();
|
357
|
|
- while (enumeration.hasMoreElements()) {
|
358
|
|
- final String altNickname =
|
359
|
|
- (String) enumeration.nextElement();
|
360
|
|
- if (altNickname.isEmpty() || altNickname.matches(NICKNAME_REGEX)) {
|
361
|
|
- altNicknamesError.setIcons(errorIcon);
|
362
|
|
- altNicknamesError.setToolTipText("Your nickname cannot be blank.");
|
363
|
|
- return ValidationResult.FAIL;
|
364
|
|
- } else if (altNickname.length() <= 1 || altNickname.length() > 9) {
|
365
|
|
- altNicknamesError.setIcons(warningIcon);
|
366
|
|
- returnValue =
|
367
|
|
- ValidationResult.WARNING;
|
368
|
|
- altNicknamesError.setToolTipText("Some servers may not allow nicknames this "
|
369
|
|
- + (altNickname.length() <= 1 ? "short" : "long") + ".");
|
370
|
|
- }
|
371
|
|
- }
|
372
|
|
-
|
373
|
|
- return returnValue;
|
374
|
|
- }
|
375
|
|
-
|
376
|
|
- /**
|
377
|
|
- * Validates the ident.
|
378
|
|
- *
|
379
|
|
- * @return Validation result
|
380
|
|
- */
|
381
|
|
- private ValidationResult checkIdent() {
|
382
|
|
- ValidationResult returnValue =
|
383
|
|
- ValidationResult.PASS;
|
384
|
|
- final String identText = ident.getText();
|
385
|
|
-
|
386
|
|
- if (!ident.isEnabled()) {
|
387
|
|
- returnValue = ValidationResult.PASS;
|
388
|
|
- } else if (identText.matches(IDENT_REGEX)) {
|
389
|
|
- identError.setIcons(errorIcon);
|
390
|
|
- ident.requestFocus();
|
391
|
|
- returnValue =
|
392
|
|
- ValidationResult.FAIL;
|
393
|
|
- identError.setToolTipText("Your ident cannot be blank.");
|
394
|
|
- }
|
395
|
|
-
|
396
|
|
- return returnValue;
|
397
|
|
- }
|
398
|
|
-
|
399
|
|
- /**
|
400
|
|
- * Validates the realname.
|
401
|
|
- *
|
402
|
|
- * @return Validation result
|
403
|
|
- */
|
404
|
|
- private ValidationResult checkRealname() {
|
405
|
|
- ValidationResult returnValue =
|
406
|
|
- ValidationResult.PASS;
|
407
|
|
- final String realnameText = realname.getText();
|
408
|
|
-
|
409
|
|
- if (!realname.isEnabled()) {
|
410
|
|
- returnValue = ValidationResult.PASS;
|
411
|
|
- } else if (realnameText.isEmpty()) {
|
412
|
|
- realnameError.setIcons(errorIcon);
|
413
|
|
- realname.requestFocus();
|
414
|
|
- returnValue =
|
415
|
|
- ValidationResult.FAIL;
|
416
|
|
- realnameError.setToolTipText("Your realname cannot be blank.");
|
|
230
|
+ public boolean validateDetails() {
|
|
231
|
+ if (!ident.validateText() || !realname.validateText() ||
|
|
232
|
+ !nickname.validateText() || !name.validateText()) {
|
|
233
|
+ return false;
|
417
|
234
|
}
|
418
|
|
-
|
419
|
|
- return returnValue;
|
|
235
|
+ return true;
|
420
|
236
|
}
|
421
|
237
|
|
422
|
|
- /**
|
423
|
|
- * Validates the nickname.
|
424
|
|
- *
|
425
|
|
- * @return Validation result
|
|
238
|
+ /**
|
|
239
|
+ * {@inheritDoc}
|
|
240
|
+ *
|
|
241
|
+ * @param e Action event
|
426
|
242
|
*/
|
427
|
|
- private ValidationResult checkNickname() {
|
428
|
|
- ValidationResult returnValue =
|
429
|
|
- ValidationResult.PASS;
|
430
|
|
- final String nicknameText = nickname.getText();
|
431
|
|
-
|
432
|
|
- if (!nickname.isEnabled()) {
|
433
|
|
- returnValue = ValidationResult.PASS;
|
434
|
|
- } else if (nicknameText.isEmpty() || nicknameText.matches(NICKNAME_REGEX)) {
|
435
|
|
- nicknameError.setIcons(errorIcon);
|
436
|
|
- nickname.requestFocus();
|
437
|
|
- returnValue =
|
438
|
|
- ValidationResult.FAIL;
|
439
|
|
- nicknameError.setToolTipText("Your nickname cannot be blank.");
|
440
|
|
- } else if (nicknameText.length() <= 1 || nicknameText.length() > 9) {
|
441
|
|
- nicknameError.setIcons(warningIcon);
|
442
|
|
- returnValue =
|
443
|
|
- ValidationResult.WARNING;
|
444
|
|
- nicknameError.setToolTipText("Some servers may not allow nicknames this "
|
445
|
|
- + (nicknameText.length() <= 1 ? "short" : "long") + ".");
|
446
|
|
- }
|
447
|
|
-
|
448
|
|
- return returnValue;
|
449
|
|
- }
|
450
|
|
-
|
451
|
|
- /**
|
452
|
|
- * Validates the name.
|
453
|
|
- *
|
454
|
|
- * @return Validation result
|
455
|
|
- */
|
456
|
|
- private ValidationResult checkName() {
|
457
|
|
- ValidationResult returnValue =
|
458
|
|
- ValidationResult.PASS;
|
459
|
|
- final String nameText = name.getText();
|
460
|
|
-
|
461
|
|
- if (!name.isEnabled()) {
|
462
|
|
- returnValue = ValidationResult.PASS;
|
463
|
|
- } else if (nameText.isEmpty() || nameText.matches(FILENAME_REGEX)) {
|
464
|
|
- nameError.setIcons(errorIcon);
|
465
|
|
- name.requestFocus();
|
466
|
|
- returnValue = ValidationResult.FAIL;
|
467
|
|
- nameError.setToolTipText("The profile name "
|
468
|
|
- + (nameText.isEmpty() ? "must not be blank." :
|
469
|
|
- "may only contain letters, numbers, underscores and spaces."));
|
470
|
|
- }
|
471
|
|
-
|
472
|
|
- return returnValue;
|
473
|
|
- }
|
474
|
|
-
|
475
|
|
- /** {@inheritDoc} */
|
476
|
243
|
@Override
|
477
|
244
|
public void actionPerformed(final ActionEvent e) {
|
478
|
245
|
if (e.getSource() == addButton) {
|
479
|
|
- final String newName =
|
480
|
|
- JOptionPane.showInputDialog(this,
|
|
246
|
+ new StandardInputDialog((MainFrame) Main.getUI().getMainWindow(),
|
|
247
|
+ false, "New Alternate Nickname",
|
481
|
248
|
"Please enter the name for alternate nickname",
|
482
|
|
- "New Alternate Nickname");
|
483
|
|
- if (newName != null && !newName.isEmpty()) {
|
484
|
|
- ((DefaultListModel) altNicknames.getModel()).addElement(newName);
|
485
|
|
- }
|
|
249
|
+ new RegexValidator(NICKNAME_REGEX,
|
|
250
|
+ "Ident must only contain letters, numbers and []{}|-^\\.")) {
|
|
251
|
+
|
|
252
|
+ /**
|
|
253
|
+ * A version number for this class. It should be changed whenever the class
|
|
254
|
+ * structure is changed (or anything else that would prevent serialized
|
|
255
|
+ * objects being unserialized with the new class).
|
|
256
|
+ */
|
|
257
|
+ private static final long serialVersionUID = 2;
|
|
258
|
+
|
|
259
|
+ /** {@inheritDoc} */
|
|
260
|
+ @Override
|
|
261
|
+ public boolean save() {
|
|
262
|
+ ((DefaultListModel) altNicknames.getModel()).addElement(getText());
|
|
263
|
+ return true;
|
|
264
|
+ }
|
|
265
|
+
|
|
266
|
+ /** {@inheritDoc} */
|
|
267
|
+ @Override
|
|
268
|
+ public void cancelled() {
|
|
269
|
+ //Ignore
|
|
270
|
+ }
|
|
271
|
+ }.display();
|
486
|
272
|
} else if (e.getSource() == editButton) {
|
487
|
|
- final String newName =
|
488
|
|
- JOptionPane.showInputDialog(this,
|
489
|
|
- "Please enter the new nickname for the alternate nickname",
|
490
|
|
- altNicknames.getSelectedValue());
|
491
|
|
- if (newName != null && !newName.isEmpty()) {
|
492
|
|
- ((DefaultListModel) altNicknames.getModel()).setElementAt(newName,
|
493
|
|
- altNicknames.getSelectedIndex());
|
494
|
|
- }
|
|
273
|
+ final StandardInputDialog dialog = new StandardInputDialog(
|
|
274
|
+ (MainFrame) Main.getUI().getMainWindow(),
|
|
275
|
+ false, "New Alternate Nickname",
|
|
276
|
+ "Please enter the name for alternate nickname",
|
|
277
|
+ new RegexValidator(NICKNAME_REGEX,
|
|
278
|
+ "Ident must only contain letters, numbers and []{}|-^\\.")) {
|
|
279
|
+
|
|
280
|
+ /**
|
|
281
|
+ * A version number for this class. It should be changed whenever the class
|
|
282
|
+ * structure is changed (or anything else that would prevent serialized
|
|
283
|
+ * objects being unserialized with the new class).
|
|
284
|
+ */
|
|
285
|
+ private static final long serialVersionUID = 2;
|
|
286
|
+
|
|
287
|
+ /** {@inheritDoc} */
|
|
288
|
+ @Override
|
|
289
|
+ public boolean save() {
|
|
290
|
+ ((DefaultListModel) altNicknames.getModel()).setElementAt(
|
|
291
|
+ getText(), altNicknames.getSelectedIndex());
|
|
292
|
+ return true;
|
|
293
|
+ }
|
|
294
|
+
|
|
295
|
+ /** {@inheritDoc} */
|
|
296
|
+ @Override
|
|
297
|
+ public void cancelled() {
|
|
298
|
+ //Ignore
|
|
299
|
+ }
|
|
300
|
+ };
|
|
301
|
+ dialog.setText((String) altNicknames.getSelectedValue());
|
|
302
|
+ dialog.display();
|
495
|
303
|
} else if (e.getSource() == delButton) {
|
496
|
304
|
if (JOptionPane.showConfirmDialog(this,
|
497
|
305
|
"Are you sure you want to delete this nickname?",
|
|
@@ -514,24 +322,6 @@ public class ProfileDetailPanel extends JPanel implements ActionListener,
|
514
|
322
|
}
|
515
|
323
|
}
|
516
|
324
|
|
517
|
|
- /** {@inheritDoc} */
|
518
|
|
- @Override
|
519
|
|
- public void insertUpdate(final DocumentEvent e) {
|
520
|
|
- validateDetails();
|
521
|
|
- }
|
522
|
|
-
|
523
|
|
- /** {@inheritDoc} */
|
524
|
|
- @Override
|
525
|
|
- public void removeUpdate(final DocumentEvent e) {
|
526
|
|
- validateDetails();
|
527
|
|
- }
|
528
|
|
-
|
529
|
|
- /** {@inheritDoc} */
|
530
|
|
- @Override
|
531
|
|
- public void changedUpdate(final DocumentEvent e) {
|
532
|
|
- //Ignore
|
533
|
|
- }
|
534
|
|
-
|
535
|
325
|
/** {@inheritDoc} */
|
536
|
326
|
@Override
|
537
|
327
|
public void intervalAdded(final ListDataEvent e) {
|
|
@@ -549,4 +339,4 @@ public class ProfileDetailPanel extends JPanel implements ActionListener,
|
549
|
339
|
public void contentsChanged(final ListDataEvent e) {
|
550
|
340
|
validateDetails();
|
551
|
341
|
}
|
552
|
|
-}
|
|
342
|
+}
|