Revision 5953dcce
Added by Katja Luther almost 3 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/ToggleableTextElement.java | ||
---|---|---|
29 | 29 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
30 | 30 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
31 | 31 |
import eu.etaxonomy.taxeditor.preference.Resources; |
32 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
32 | 33 |
|
33 | 34 |
/** |
34 | 35 |
* When the button is pressed, this textfield may be edited. |
... | ... | |
38 | 39 |
*/ |
39 | 40 |
public class ToggleableTextElement |
40 | 41 |
extends AbstractRelevanceFormElement |
41 |
implements SelectionListener, ModifyListener, IEnableableFormElement, ISelectable { |
|
42 |
implements SelectionListener, ModifyListener, |
|
43 |
IEnableableFormElement, ISelectable { |
|
42 | 44 |
|
43 | 45 |
private final Text text_cache; |
44 | 46 |
private final Button btnToggleProtectTitleCache; |
... | ... | |
79 | 81 |
text_cache.addKeyListener( new KeyAdapter(){ |
80 | 82 |
@Override |
81 | 83 |
public void keyPressed(KeyEvent e) { |
82 |
if(e.character == SWT.CR) { |
|
83 |
e.doit = false; |
|
84 |
} |
|
84 |
if (!state){ |
|
85 |
return; |
|
86 |
} |
|
87 |
if(e.character == SWT.CR) { |
|
88 |
e.doit = false; |
|
89 |
} |
|
85 | 90 |
} |
86 | 91 |
}); |
87 | 92 |
|
... | ... | |
100 | 105 |
// store current caret position |
101 | 106 |
int caretPosition = text_cache.getCaretPosition(); |
102 | 107 |
|
103 |
text_cache.removeModifyListener(this); |
|
104 |
text_cache.setText(text); |
|
105 |
text_cache.addModifyListener(this); |
|
108 |
StoreUtil.setTextWithoutModifyListeners(text_cache, text != null? text.trim(): text); |
|
109 |
// text_cache.removeModifyListener(this); |
|
110 |
// text_cache.setText(text); |
|
111 |
// text_cache.addModifyListener(this); |
|
106 | 112 |
|
107 | 113 |
// restore caret position |
108 | 114 |
text_cache.setSelection(caretPosition); |
... | ... | |
166 | 172 |
|
167 | 173 |
@Override |
168 | 174 |
public void widgetSelected(SelectionEvent e) { |
169 |
setState(btnToggleProtectTitleCache.getSelection());
|
|
175 |
setState(btnToggleProtectTitleCache.getSelection());
|
|
170 | 176 |
for(SelectionListener listener : selectionListener){ |
171 | 177 |
listener.widgetSelected(e); |
172 | 178 |
} |
... | ... | |
186 | 192 |
|
187 | 193 |
@Override |
188 | 194 |
public void modifyText(ModifyEvent e) { |
189 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)); |
|
195 |
if (state){ |
|
196 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)); |
|
197 |
} |
|
190 | 198 |
} |
191 | 199 |
|
192 | 200 |
@Override |
Also available in: Unified diff
fix #9688: Adapt toggleable text field to textWithLabel to avoid changes if disabled