Mercurial > projects > dwt-addons
annotate dwtx/cdt/managedbuilder/ui/properties/PasswordFieldEditor.d @ 110:a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 17:37:04 +0200 |
parents | |
children |
rev | line source |
---|---|
110
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1 /********************************************************************** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2 * Copyright (c) 2004 BitMethods Inc and others. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4 * are made available under the terms of the Common Public License v0.5 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/cpl-v05.html |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
7 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
8 * Contributors: |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
9 * BitMethods Inc - Initial API and implementation |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
10 * Ported to the D programming language |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
11 * yidabu ( D Programming Language China : http://www.d-programming-language-china.org/ ) |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
12 ***********************************************************************/ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
13 module dwtx.cdt.managedbuilder.ui.properties.PasswordFieldEditor; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
14 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
15 /// https://bugs.eclipse.org/bugs/attachment.cgi?id=33204 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 /// https://bugs.eclipse.org/bugs/show_bug.cgi?id=23495 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
17 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
18 import dwtx.jface.util.Assert; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
19 import dwt.DWT; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
20 import dwt.events.DisposeEvent; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
21 import dwt.events.DisposeListener; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
22 import dwt.events.FocusAdapter; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
23 import dwt.events.FocusEvent; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
24 import dwt.events.KeyAdapter; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
25 import dwt.events.KeyEvent; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
26 import dwt.widgets.Composite; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
27 import dwt.widgets.Text; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
28 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
29 import dwt.dwthelper.utils; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
30 import dwtx.jface.preference.StringFieldEditor; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
31 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
32 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
33 * A field editor for a password type preference. This is essentially |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
34 * a StringFieldEditor, but will replace each character in the input |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
35 * box with an '*'. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
36 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
37 * This class may be used as is, or subclassed as required. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
38 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
39 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
40 public class PasswordFieldEditor : StringFieldEditor { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
41 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
42 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
43 * The validation strategy; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
44 * <code>VALIDATE_ON_KEY_STROKE</code> by default. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
45 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
46 private int validateStrategy; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
47 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
48 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
49 * Text limit of text field in characters; initially unlimited. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
50 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
51 private int textLimit; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
52 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
53 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
54 * The text field, or <code>null</code> if none. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
55 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
56 Text textField; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
57 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
58 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
59 * Creates a new password field editor |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
60 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
61 protected this() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
62 //widthInChars = UNLIMITED; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
63 textLimit = UNLIMITED; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
64 validateStrategy = VALIDATE_ON_KEY_STROKE; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
65 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
66 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
67 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
68 * Creates a password field editor. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
69 * Use the method <code>setTextLimit</code> to limit the text. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
70 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
71 * @param name the name of the preference this field editor works on |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
72 * @param labelText the label text of the field editor |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
73 * @param width the width of the text input field in characters, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
74 * or <code>UNLIMITED</code> for no limit |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
75 * @param strategy either <code>VALIDATE_ON_KEY_STROKE</code> to perform |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
76 * on the fly checking (the default), or <code>VALIDATE_ON_FOCUS_LOST</code> to |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
77 * perform validation only after the text has been typed in |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
78 * @param parent the parent of the field editor's control |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
79 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
80 public this(String name, String labelText, int width, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
81 int strategy, Composite parent) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
82 super(name, labelText, width, strategy, parent); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
83 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
84 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
85 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
86 * Creates a password field editor. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
87 * Use the method <code>setTextLimit</code> to limit the text. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
88 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
89 * @param name the name of the preference this field editor works on |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
90 * @param labelText the label text of the field editor |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
91 * @param width the width of the text input field in characters, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
92 * or <code>UNLIMITED</code> for no limit |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
93 * @param parent the parent of the field editor's control |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
94 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
95 public this(String name, String labelText, int width, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
96 Composite parent) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
97 this(name, labelText, width, VALIDATE_ON_KEY_STROKE, parent); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
98 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
99 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
100 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
101 * Creates a password field editor of unlimited width. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
102 * Use the method <code>setTextLimit</code> to limit the text. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
103 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
104 * @param name the name of the preference this field editor works on |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
105 * @param labelText the label text of the field editor |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
106 * @param parent the parent of the field editor's control |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
107 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
108 public this(String name, String labelText, Composite parent) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
109 this(name, labelText, UNLIMITED, parent); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
110 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
111 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
112 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
113 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
114 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
115 * Returns this field editor's text control. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
116 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
117 * The control is created if it does not yet exist |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
118 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
119 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
120 * @param parent the parent |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
121 * @return the text control |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
122 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
123 public Text getTextControl(Composite parent) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
124 if (textField is null) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
125 textField = new Text(parent, DWT.PASSWORD | DWT.SINGLE | DWT.BORDER); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
126 textField.setFont(parent.getFont()); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
127 switch (validateStrategy) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
128 case VALIDATE_ON_KEY_STROKE: |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
129 textField.addKeyListener(new class() KeyAdapter { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
130 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
131 /* (non-Javadoc) |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
132 * @see dwt.events.KeyAdapter#keyReleased(dwt.events.KeyEvent) |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
133 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
134 public void keyReleased(KeyEvent e) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
135 valueChanged(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
136 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
137 }); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
138 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
139 break; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
140 case VALIDATE_ON_FOCUS_LOST: |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
141 textField.addKeyListener(new class() KeyAdapter { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
142 public void keyPressed(KeyEvent e) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
143 clearErrorMessage(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
144 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
145 }); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
146 textField.addFocusListener(new class() FocusAdapter { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
147 public void focusGained(FocusEvent e) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
148 refreshValidState(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
149 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
150 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
151 public void focusLost(FocusEvent e) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
152 valueChanged(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
153 clearErrorMessage(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
154 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
155 }); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
156 break; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
157 default: |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
158 Assert.isTrue(false, "Unknown validate strategy");//$NON-NLS-1$ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
159 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
160 textField.addDisposeListener(new class() DisposeListener { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
161 public void widgetDisposed(DisposeEvent event) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
162 textField = null; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
163 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
164 }); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
165 if (textLimit > 0) {//Only set limits above 0 - see SWT spec |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
166 textField.setTextLimit(textLimit); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
167 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
168 } else { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
169 checkParent(textField, parent); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
170 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
171 return textField; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
172 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
173 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
174 } |