- fixed stackOverflow for ToggleableTextFieldController
authorPatric Plitzner <p.plitzner@bgbm.org>
Wed, 28 Aug 2013 15:41:04 +0000 (15:41 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Wed, 28 Aug 2013 15:41:04 +0000 (15:41 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/basicFields/ToggleableTextFieldController.java

index 2e7f7e34f0407e9d6844e0deb1d0ffcdd68f662b..1307f0496a21a288fba49a7ab65c4fbd99217b43 100644 (file)
@@ -21,8 +21,10 @@ import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Text;
 
 import org.eclipse.swt.widgets.Text;
 
+import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.taxeditor.preference.Resources;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
 import eu.etaxonomy.taxeditor.preference.Resources;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
@@ -101,9 +103,14 @@ public class ToggleableTextFieldController extends AbstractCdmFormElement implem
             Text textField = toggleableTextField.getText();
             int caretPosition = textField.getCaretPosition();
 
             Text textField = toggleableTextField.getText();
             int caretPosition = textField.getCaretPosition();
 
-            textField.removeModifyListener(this);
-            textField.setText(text);
-            textField.addModifyListener(this);
+            Listener[] listeners = textField.getListeners(SWT.Modify);
+            for (Listener listener : listeners) {
+                textField.removeListener(SWT.Modify, listener);
+            }
+            textField.setText(CdmUtils.Nz(text));
+            for (Listener listener : listeners) {
+                textField.addListener(SWT.Modify, listener);
+            }
 
             // restore caret position
             textField.setSelection(caretPosition);
 
             // restore caret position
             textField.setSelection(caretPosition);