Revision 9142fb50
Added by Patrick Plitzner about 11 years ago
- fixed stackOverflow for ToggleableTextFieldController
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/basicFields/ToggleableTextFieldController.java | ||
---|---|---|
21 | 21 |
import org.eclipse.swt.events.SelectionListener; |
22 | 22 |
import org.eclipse.swt.graphics.Color; |
23 | 23 |
import org.eclipse.swt.widgets.Button; |
24 |
import org.eclipse.swt.widgets.Listener; |
|
24 | 25 |
import org.eclipse.swt.widgets.Text; |
25 | 26 |
|
27 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
26 | 28 |
import eu.etaxonomy.taxeditor.preference.Resources; |
27 | 29 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
28 | 30 |
import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement; |
... | ... | |
101 | 103 |
Text textField = toggleableTextField.getText(); |
102 | 104 |
int caretPosition = textField.getCaretPosition(); |
103 | 105 |
|
104 |
textField.removeModifyListener(this); |
|
105 |
textField.setText(text); |
|
106 |
textField.addModifyListener(this); |
|
106 |
Listener[] listeners = textField.getListeners(SWT.Modify); |
|
107 |
for (Listener listener : listeners) { |
|
108 |
textField.removeListener(SWT.Modify, listener); |
|
109 |
} |
|
110 |
textField.setText(CdmUtils.Nz(text)); |
|
111 |
for (Listener listener : listeners) { |
|
112 |
textField.addListener(SWT.Modify, listener); |
|
113 |
} |
|
107 | 114 |
|
108 | 115 |
// restore caret position |
109 | 116 |
textField.setSelection(caretPosition); |
Also available in: Unified diff