Revision 6a822179
Added by Patrick Plitzner over 9 years ago
- fixed removing of control characters (fixes #4373, affects #2248)
- added condition to only replace if the string contains control characters
- cursor will still jump back but only when control characters were removed
- removed unused method
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java | ||
---|---|---|
171 | 171 |
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection; |
172 | 172 |
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection; |
173 | 173 |
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement; |
174 |
import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement; |
|
175 | 174 |
import eu.etaxonomy.taxeditor.ui.section.media.MediaDetailElement; |
175 |
import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement; |
|
176 | 176 |
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement; |
177 | 177 |
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartElement; |
178 | 178 |
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection; |
... | ... | |
787 | 787 |
return element; |
788 | 788 |
} |
789 | 789 |
|
790 |
/** |
|
791 |
* <p> |
|
792 |
* createTextElement |
|
793 |
* </p> |
|
794 |
* |
|
795 |
* @param parentElement |
|
796 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} |
|
797 |
* object. |
|
798 |
* @param initialText |
|
799 |
* a {@link java.lang.String} object. |
|
800 |
* @param style |
|
801 |
* a int. |
|
802 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement} |
|
803 |
* object. |
|
804 |
*/ |
|
805 |
public TextWithLabelElement createTextElement(ICdmFormElement parentElement, String initialText, int style) { |
|
806 |
TextWithLabelElement element = new TextWithLabelElement(this, parentElement, null, initialText, null, style); |
|
807 |
adapt(element); |
|
808 |
parentElement.addElement(element); |
|
809 |
return element; |
|
810 |
} |
|
811 | 790 |
|
812 | 791 |
/** |
813 | 792 |
* <p> |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/TextWithLabelElement.java | ||
---|---|---|
160 | 160 |
public void modifyText(ModifyEvent e) { |
161 | 161 |
if(e.widget == text){ |
162 | 162 |
Text text = (Text) e.widget; |
163 |
//remove control character such as line breaks etc. |
|
164 |
setText(text.getText().replaceAll("\\p{C}", "?")); |
|
163 |
boolean hasControlCharacters = false; |
|
164 |
String textString = text.getText(); |
|
165 |
int stringLength = textString.length(); |
|
166 |
for (int i = 0; i < stringLength; i++) { |
|
167 |
if (Character.isISOControl(textString.charAt(i))) { |
|
168 |
hasControlCharacters = true; |
|
169 |
break; |
|
170 |
} |
|
171 |
} |
|
172 |
if(hasControlCharacters){ |
|
173 |
//remove control character such as line breaks etc. |
|
174 |
setText(text.getText().replaceAll("\\p{C}", "")); |
|
175 |
} |
|
165 | 176 |
} |
166 | 177 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)); |
167 | 178 |
} |
Also available in: Unified diff