1 |
af979d17
|
n.hoffmann
|
/**
|
2 |
|
|
*
|
3 |
|
|
*/
|
4 |
78222507
|
n.hoffmann
|
package eu.etaxonomy.taxeditor.ui.element;
|
5 |
af979d17
|
n.hoffmann
|
|
6 |
|
|
import org.eclipse.swt.SWT;
|
7 |
1dc94266
|
n.hoffmann
|
import org.eclipse.swt.events.ModifyEvent;
|
8 |
|
|
import org.eclipse.swt.events.ModifyListener;
|
9 |
af979d17
|
n.hoffmann
|
import org.eclipse.swt.events.SelectionListener;
|
10 |
cfcb0ce6
|
n.hoffmann
|
import org.eclipse.swt.graphics.Color;
|
11 |
af979d17
|
n.hoffmann
|
import org.eclipse.swt.widgets.Button;
|
12 |
|
|
import org.eclipse.swt.widgets.Composite;
|
13 |
|
|
import org.eclipse.swt.widgets.Label;
|
14 |
|
|
import org.eclipse.swt.widgets.Text;
|
15 |
|
|
|
16 |
|
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
17 |
|
|
|
18 |
|
|
/**
|
19 |
3be6ef3e
|
n.hoffmann
|
* <p>TextActionElement class.</p>
|
20 |
af979d17
|
n.hoffmann
|
*
|
21 |
3be6ef3e
|
n.hoffmann
|
* @author nho
|
22 |
|
|
* @version $Id: $
|
23 |
af979d17
|
n.hoffmann
|
*/
|
24 |
0c52f39c
|
n.hoffmann
|
public class TextActionElement extends AbstractCdmFormElement implements ModifyListener, ISelectable{
|
25 |
af979d17
|
n.hoffmann
|
|
26 |
|
|
private Label label;
|
27 |
|
|
private Text text;
|
28 |
|
|
private Button button;
|
29 |
729887cf
|
n.hoffmann
|
private Composite box;
|
30 |
af979d17
|
n.hoffmann
|
|
31 |
|
|
/**
|
32 |
3be6ef3e
|
n.hoffmann
|
* <p>Constructor for TextActionElement.</p>
|
33 |
|
|
*
|
34 |
|
|
* @param style a int.
|
35 |
78222507
|
n.hoffmann
|
* @param toolkit a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
36 |
|
|
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
|
37 |
3be6ef3e
|
n.hoffmann
|
* @param labelString a {@link java.lang.String} object.
|
38 |
|
|
* @param buttonLabel a {@link java.lang.String} object.
|
39 |
|
|
* @param initialText a {@link java.lang.String} object.
|
40 |
af979d17
|
n.hoffmann
|
*/
|
41 |
729887cf
|
n.hoffmann
|
protected TextActionElement(CdmFormFactory toolkit, ICdmFormElement parentElement, String labelString, String buttonLabel, String initialText, int style) {
|
42 |
|
|
super(toolkit, parentElement);
|
43 |
af979d17
|
n.hoffmann
|
|
44 |
729887cf
|
n.hoffmann
|
label = toolkit.createLabel(getLayoutComposite(), labelString, SWT.WRAP);
|
45 |
|
|
addControl(label);
|
46 |
af979d17
|
n.hoffmann
|
|
47 |
729887cf
|
n.hoffmann
|
box = formFactory.createComposite(getLayoutComposite());
|
48 |
23783f7a
|
n.hoffmann
|
box.setLayout(LayoutConstants.LAYOUT(2, false));
|
49 |
|
|
box.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
|
50 |
729887cf
|
n.hoffmann
|
addControl(box);
|
51 |
af979d17
|
n.hoffmann
|
|
52 |
729887cf
|
n.hoffmann
|
text = toolkit.createText(box, "", style);
|
53 |
|
|
addControl(text);
|
54 |
23783f7a
|
n.hoffmann
|
text.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
|
55 |
af979d17
|
n.hoffmann
|
|
56 |
|
|
setText(CdmUtils.Nz(initialText));
|
57 |
|
|
|
58 |
729887cf
|
n.hoffmann
|
button = toolkit.createButton(box, buttonLabel, SWT.PUSH);
|
59 |
|
|
addControl(button);
|
60 |
af979d17
|
n.hoffmann
|
}
|
61 |
|
|
|
62 |
|
|
/**
|
63 |
3be6ef3e
|
n.hoffmann
|
* <p>Setter for the field <code>text</code>.</p>
|
64 |
|
|
*
|
65 |
|
|
* @param string a {@link java.lang.String} object.
|
66 |
af979d17
|
n.hoffmann
|
*/
|
67 |
|
|
public void setText(String string) {
|
68 |
|
|
text.setText(CdmUtils.Nz(string));
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
/**
|
72 |
3be6ef3e
|
n.hoffmann
|
* <p>Getter for the field <code>text</code>.</p>
|
73 |
|
|
*
|
74 |
af979d17
|
n.hoffmann
|
* @return the text
|
75 |
|
|
*/
|
76 |
|
|
public String getText() {
|
77 |
|
|
return text.getText();
|
78 |
|
|
}
|
79 |
|
|
|
80 |
3be6ef3e
|
n.hoffmann
|
/**
|
81 |
|
|
* <p>addSelectionListener</p>
|
82 |
|
|
*
|
83 |
|
|
* @param listener a {@link org.eclipse.swt.events.SelectionListener} object.
|
84 |
|
|
*/
|
85 |
af979d17
|
n.hoffmann
|
public void addSelectionListener(SelectionListener listener){
|
86 |
|
|
button.addSelectionListener(listener);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
3be6ef3e
|
n.hoffmann
|
/**
|
90 |
|
|
* <p>removeSelectionListener</p>
|
91 |
|
|
*
|
92 |
|
|
* @param listener a {@link org.eclipse.swt.events.SelectionListener} object.
|
93 |
|
|
*/
|
94 |
af979d17
|
n.hoffmann
|
public void removeSelectionListener(SelectionListener listener){
|
95 |
|
|
button.removeSelectionListener(listener);
|
96 |
|
|
}
|
97 |
1dc94266
|
n.hoffmann
|
|
98 |
|
|
/* (non-Javadoc)
|
99 |
|
|
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
|
100 |
|
|
*/
|
101 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
102 |
1dc94266
|
n.hoffmann
|
public void modifyText(ModifyEvent e) {
|
103 |
|
|
propertyChange(null);
|
104 |
|
|
}
|
105 |
729887cf
|
n.hoffmann
|
|
106 |
3be6ef3e
|
n.hoffmann
|
/**
|
107 |
|
|
* <p>addModifyListener</p>
|
108 |
|
|
*
|
109 |
|
|
* @param listener a {@link org.eclipse.swt.events.ModifyListener} object.
|
110 |
|
|
*/
|
111 |
729887cf
|
n.hoffmann
|
public void addModifyListener(ModifyListener listener){
|
112 |
|
|
text.addModifyListener(listener);
|
113 |
|
|
}
|
114 |
|
|
|
115 |
3be6ef3e
|
n.hoffmann
|
/**
|
116 |
|
|
* <p>removeModifyListener</p>
|
117 |
|
|
*
|
118 |
|
|
* @param listener a {@link org.eclipse.swt.events.ModifyListener} object.
|
119 |
|
|
*/
|
120 |
729887cf
|
n.hoffmann
|
public void removeModifyListener(ModifyListener listener){
|
121 |
|
|
text.removeModifyListener(listener);
|
122 |
|
|
}
|
123 |
cfcb0ce6
|
n.hoffmann
|
|
124 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
125 |
cfcb0ce6
|
n.hoffmann
|
@Override
|
126 |
|
|
public void setBackground(Color color) {
|
127 |
|
|
label.setBackground(color);
|
128 |
|
|
}
|
129 |
0c52f39c
|
n.hoffmann
|
|
130 |
|
|
@Override
|
131 |
|
|
public void setSelected(boolean selected) {
|
132 |
|
|
setBackground(selected ? SELECTED : getPersistentBackground());
|
133 |
|
|
}
|
134 |
af979d17
|
n.hoffmann
|
}
|