Mercurial > projects > dwt-addons
annotate dwtx/cdt/managedbuilder/ui/properties/MultiLineTextFieldEditor.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.MultiLineTextFieldEditor; |
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 //import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 import dwtx.jface.preference.FieldEditor; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
17 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
|
18 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
|
19 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
|
20 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
|
21 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
|
22 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
|
23 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
|
24 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
|
25 import dwt.layout.GridData; |
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.Label; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
28 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
|
29 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
30 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
|
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 * MultiLineTextFieldEditor. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
34 * Field editor that is same as string field editor but |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
35 * will have the multi line text field for user input. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
36 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
37 public class MultiLineTextFieldEditor : FieldEditor { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
38 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
39 alias FieldEditor.showErrorMessage showErrorMessage; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
40 private static final String ERROR_MESSAGE = "Multiline.error.message"; //$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
|
41 private static final String ERROR_MESSAGE_CONST = "Please give correct input"; //$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
|
42 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
43 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
44 * Validation strategy constant (value <code>0</code>) indicating that |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
45 * the editor should perform validation after every key stroke. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
46 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
47 * @see #setValidateStrategy |
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 public static const int VALIDATE_ON_KEY_STROKE = 0; |
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 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
52 * Validation strategy constant (value <code>1</code>) indicating that |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
53 * the editor should perform validation only when the text widget |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
54 * loses focus. |
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 * @see #setValidateStrategy |
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 public static const int VALIDATE_ON_FOCUS_LOST = 1; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
59 |
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 * Text limit constant (value <code>-1</code>) indicating unlimited |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
62 * text limit and width. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
63 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
64 public static int UNLIMITED = -1; |
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 * Cached valid state. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
68 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
69 private bool isValid_; |
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 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
72 * Old text value. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
73 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
74 private String oldValue; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
75 private String compTitle; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
76 private Label title; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
77 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
78 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
79 * 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
|
80 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
81 private Text textField; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
82 |
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 * Width 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
|
85 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
86 private int widthInChars; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
87 |
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 * 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
|
90 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
91 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
|
92 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
93 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
94 * The error message, 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
|
95 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
96 private String errorMessage; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
97 |
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 * Indicates whether the empty string is legal; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
100 * <code>true</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
|
101 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
102 private bool emptyStringAllowed = true; |
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 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
105 * 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
|
106 * <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
|
107 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
108 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
|
109 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
110 * Creates a new string field editor |
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 protected this() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
113 widthInChars = UNLIMITED; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
114 textLimit = UNLIMITED; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
115 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
|
116 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
117 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
118 * Creates a string field editor. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
119 * 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
|
120 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
121 * @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
|
122 * @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
|
123 * @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
|
124 * 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
|
125 * @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
|
126 * 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
|
127 * 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
|
128 * @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
|
129 * @since 2.0 |
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 public this( |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
132 String name, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
133 String labelText, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
134 int width, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
135 int strategy, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
136 Composite parent) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
137 this(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
138 init(name, labelText); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
139 widthInChars = width; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
140 setValidateStrategy(strategy); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
141 isValid_ = false; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
142 //errorMessage = ManagedBuilderUIMessages.getResourceString(ERROR_MESSAGE); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
143 errorMessage = ERROR_MESSAGE_CONST; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
144 createControl(parent); |
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 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
147 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
148 * Creates a string field editor. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
149 * 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
|
150 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
151 * @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
|
152 * @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
|
153 * @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
|
154 * 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
|
155 * @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
|
156 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
157 public this(String name, String labelText, int width, Composite parent) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
158 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
|
159 this.compTitle = labelText; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
160 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
161 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
162 * Creates a string 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
|
163 * 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
|
164 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
165 * @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
|
166 * @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
|
167 * @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
|
168 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
169 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
|
170 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
|
171 } |
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 * Adjusts the horizontal span of this field editor's basic controls |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
175 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
176 * Subclasses must implement this method to adjust the horizontal span |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
177 * of controls so they appear correct in the given number of columns. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
178 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
179 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
180 * The number of columns will always be equal to or greater than the |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
181 * value returned by this editor's <code>getNumberOfControls</code> method. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
182 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
183 * @param numColumns the number of columns |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
184 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
185 protected void adjustForNumColumns(int numColumns) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
186 GridData gd = cast(GridData) textField.getLayoutData(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
187 gd.horizontalSpan = numColumns - 1; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
188 // We only grab excess space if we have to |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
189 // If another field editor has more columns then |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
190 // we assume it is setting the width. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
191 gd.grabExcessHorizontalSpace = gd.horizontalSpan == 1; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
192 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
193 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
194 * Checks whether the text input field contains a valid value or not. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
195 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
196 * @return <code>true</code> if the field value is valid, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
197 * and <code>false</code> if invalid |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
198 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
199 protected bool checkState() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
200 bool result = false; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
201 if (emptyStringAllowed) |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
202 result = true; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
203 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
204 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
|
205 result = false; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
206 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
207 String txt = textField.getText(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
208 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
209 if (txt is null) |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
210 result = false; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
211 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
212 result = (txt.trim().length > 0) || emptyStringAllowed; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
213 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
214 // call hook for subclasses |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
215 result = result && doCheckState(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
216 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
217 if (result) |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
218 clearErrorMessage(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
219 else |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
220 showErrorMessage(errorMessage); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
221 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
222 return result; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
223 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
224 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
225 * Hook for subclasses to do specific state checks. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
226 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
227 * The default implementation of this framework method does |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
228 * nothing and returns <code>true</code>. Subclasses should |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
229 * override this method to specific state checks. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
230 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
231 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
232 * @return <code>true</code> if the field value is valid, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
233 * and <code>false</code> if invalid |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
234 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
235 protected bool doCheckState() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
236 return true; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
237 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
238 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
239 * Fills this field editor's basic controls into the given parent. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
240 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
241 * The string field implementation of this <code>FieldEditor</code> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
242 * framework method contributes the text field. Subclasses may override |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
243 * but must call <code>super.doFillIntoGrid</code>. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
244 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
245 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
246 protected void doFillIntoGrid(Composite parent, int numColumns) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
247 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
248 title = new Label(parent, DWT.UP); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
249 title.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
|
250 this.compTitle = getLabelText(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
251 title.setText(this.compTitle); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
252 title.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
253 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
254 textField = getTextControl(parent); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
255 GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
256 gd.widthHint = 100; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
257 gd.heightHint = 70; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
258 textField.setLayoutData(gd); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
259 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
260 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
261 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
262 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
263 * Initializes this field editor with the preference value from |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
264 * the preference store. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
265 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
266 * Subclasses must implement this method to properly initialize |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
267 * 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
|
268 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
269 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
270 protected void doLoad() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
271 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
|
272 String value = getPreferenceStore().getString(getPreferenceName()); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
273 textField.setText(value); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
274 oldValue = value; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
275 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
276 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
277 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
278 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
279 * Initializes this field editor with the default preference value from |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
280 * the preference store. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
281 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
282 * Subclasses must implement this method to properly initialize |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
283 * 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
|
284 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
285 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
286 protected void doLoadDefault() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
287 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
|
288 String value = |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
289 getPreferenceStore().getDefaultString(getPreferenceName()); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
290 textField.setText(value); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
291 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
292 valueChanged(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
293 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
294 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
295 /* (non-Javadoc) |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
296 * @see dwtx.jface.preference.FieldEditor#doStore() |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
297 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
298 protected void doStore() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
299 getPreferenceStore().setValue(getPreferenceName(), textField.getText()); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
300 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
301 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
302 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
303 * Returns the error message that will be displayed when and if |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
304 * an error occurs. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
305 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
306 * @return the error message, 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
|
307 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
308 public String getErrorMessage() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
309 return errorMessage; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
310 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
311 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
312 * Returns the number of basic controls this field editor consists of. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
313 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
314 * @return the number of controls |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
315 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
316 public int getNumberOfControls() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
317 return 2; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
318 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
319 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
320 * Returns the field editor's value. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
321 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
322 * @return the current value |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
323 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
324 public String getStringValue() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
325 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
|
326 return textField.getText(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
327 else |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
328 return getPreferenceStore().getString(getPreferenceName()); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
329 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
330 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
331 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
332 * 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
|
333 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
334 * @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
|
335 * @return the text control, or <code>null</code> if no |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
336 * text field is created yet |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
337 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
338 protected Text getTextControl() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
339 return textField; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
340 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
341 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
342 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
343 * 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
|
344 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
345 * 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
|
346 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
347 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
348 * @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
|
349 * @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
|
350 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
351 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
|
352 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
|
353 textField = |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
354 new Text( |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
355 parent, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
356 DWT.MULTI | DWT.V_SCROLL | DWT.BORDER | DWT.WRAP); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
357 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
|
358 switch (validateStrategy) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
359 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
|
360 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
|
361 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
|
362 valueChanged(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
363 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
364 }); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
365 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
366 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
|
367 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
|
368 refreshValidState(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
369 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
370 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
|
371 clearErrorMessage(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
372 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
373 }); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
374 break; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
375 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
|
376 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
|
377 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
|
378 clearErrorMessage(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
379 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
380 }); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
381 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
|
382 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
|
383 refreshValidState(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
384 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
385 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
|
386 valueChanged(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
387 clearErrorMessage(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
388 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
389 }); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
390 break; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
391 default : |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
392 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
|
393 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
394 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
|
395 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
|
396 textField = null; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
397 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
398 }); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
399 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
|
400 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
|
401 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
402 } else { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
403 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
|
404 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
405 return textField; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
406 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
407 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
408 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
409 * Returns whether an empty string is a valid value. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
410 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
411 * @return <code>true</code> if an empty string is a valid value, and |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
412 * <code>false</code> if an empty string is invalid |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
413 * @see #setEmptyStringAllowed |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
414 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
415 public bool isEmptyStringAllowed() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
416 return emptyStringAllowed; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
417 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
418 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
419 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
420 * Returns whether this field editor contains a valid value. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
421 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
422 * The default implementation of this framework method |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
423 * returns <code>true</code>. Subclasses wishing to perform |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
424 * validation should override both this method and |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
425 * <code>refreshValidState</code>. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
426 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
427 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
428 * @return <code>true</code> if the field value is valid, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
429 * and <code>false</code> if invalid |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
430 * @see #refreshValidState |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
431 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
432 public bool isValid() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
433 return isValid_; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
434 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
435 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
436 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
437 * Refreshes this field editor's valid state after a value change |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
438 * and fires an <code>IS_VALID</code> property change event if |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
439 * warranted. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
440 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
441 * The default implementation of this framework method does |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
442 * nothing. Subclasses wishing to perform validation should override |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
443 * both this method and <code>isValid_</code>. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
444 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
445 * @see #isValid_ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
446 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
447 protected void refreshValidState() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
448 isValid_ = checkState(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
449 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
450 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
451 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
452 * Sets whether the empty string is a valid value or not. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
453 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
454 * @param b <code>true</code> if the empty string is allowed, |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
455 * and <code>false</code> if it is considered invalid |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
456 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
457 public void setEmptyStringAllowed(bool b) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
458 emptyStringAllowed = b; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
459 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
460 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
461 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
462 * Sets the error message that will be displayed when and if |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
463 * an error occurs. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
464 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
465 * @param message the error message |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
466 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
467 public void setErrorMessage(String message) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
468 errorMessage = message; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
469 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
470 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
471 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
472 * Sets the focus to this field editor. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
473 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
474 * The default implementation of this framework method |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
475 * does nothing. Subclasses may reimplement. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
476 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
477 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
478 public void setFocus() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
479 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
|
480 textField.setFocus(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
481 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
482 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
483 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
484 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
485 * Sets this field editor's value. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
486 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
487 * @param value the new value, or <code>null</code> meaning the empty string |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
488 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
489 public void setStringValue(String value) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
490 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
|
491 if (value is null) |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
492 value = ""; //$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
|
493 oldValue = textField.getText(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
494 if (!oldValue.equals(value)) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
495 textField.setText(value); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
496 valueChanged(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
497 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
498 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
499 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
500 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
501 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
502 * Sets this text field's text limit. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
503 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
504 * @param limit the limit on the number of character in the text |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
505 * input field, 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
|
506 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
507 public void setTextLimit(int limit) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
508 textLimit = limit; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
509 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
|
510 textField.setTextLimit(limit); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
511 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
512 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
513 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
514 * Sets the strategy for validating the text. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
515 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
516 * Calling this method has no effect after <code>createPartControl</code> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
517 * is called. Thus this method is really only useful for subclasses to call |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
518 * in their constructor. However, it has public visibility for backward |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
519 * compatibility. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
520 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
521 * |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
522 * @param value 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
|
523 * 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
|
524 * 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
|
525 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
526 public void setValidateStrategy(int value) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
527 Assert.isTrue( |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
528 value == VALIDATE_ON_FOCUS_LOST || value == 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
|
529 validateStrategy = value; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
530 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
531 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
532 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
533 * Shows the error message set via <code>setErrorMessage</code>. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
534 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
535 public void showErrorMessage() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
536 showErrorMessage(errorMessage); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
537 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
538 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
539 /** |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
540 * Informs this field editor's listener, if it has one, about a change |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
541 * to the value (<code>VALUE</code> property) provided that the old and |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
542 * new values are different. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
543 * <p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
544 * This hook is <em>not</em> called when the text is initialized |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
545 * (or reset to the default value) from the preference store. |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
546 * </p> |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
547 */ |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
548 protected void valueChanged() { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
549 setPresentsDefaultValue(false); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
550 bool oldState = isValid_; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
551 refreshValidState(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
552 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
553 if (isValid_ !is oldState) |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
554 fireStateChanged(IS_VALID, oldState, isValid_); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
555 |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
556 String newValue = textField.getText(); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
557 if (!newValue.equals(oldValue)) { |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
558 fireValueChanged(VALUE, stringcast(oldValue), stringcast(newValue)); |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
559 oldValue = newValue; |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
560 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
561 } |
a26bb7394581
Add two field editor from the CDT project, thanks yidabu for the port.
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
562 } |