Label label = textEditor.getLabel();
String editorData = textEditor.getEditor().getText();
if (editorData != null) {
- /** TODO : need validation */
- if (isDefaultValue(editorData)) {
+ if (!validateTextEditor(textEditor)) {
+ return;
+ } else if (isDefaultValue(editorData)) {
label.setText(DEFAULT_VALUE);
} else {
label.setText(editorData);
Label label = textEditor.getLabel();
String editorData = textEditor.getEditor().getText();
if (editorData != null) {
- /** TODO : need validation */
- if (isDefaultValue(editorData)) {
+ if (!validateTextEditor(textEditor)) {
+ textEditor.showLabel();
+ return;
+ } else if (isDefaultValue(editorData)) {
label.setText(DEFAULT_VALUE);
} else {
label.setText(editorData);
data.right = new FormAttachment(100, 0);
return data;
}
+
+ private boolean validateTextEditor(TextEditor textEditor) {
+ String labelText = textEditor.getLabel().getText();
+ String editorData = textEditor.getEditor().getText();
+ if (editorData == null) {
+ return false;
+ } else if (!editorData.matches(BuilderConstants.INTEGERVALUE)) {
+ return false;
+ } else if (editorData.equals(labelText)) {
+ return false;
+ }
+ return true;
+ }
}