Temporary fix for AceEditor #PL-1980

This commit is contained in:
Yuriy Artamonov 2013-09-26 08:04:56 +00:00
parent 195aabd9a2
commit 1268ca1b11

View File

@ -7,6 +7,8 @@ package com.haulmont.cuba.web.toolkit.ui;
import com.haulmont.cuba.gui.autocomplete.AutoCompleteSupport;
import com.haulmont.cuba.web.controllers.ControllerUtils;
import com.vaadin.data.Validator;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.ui.AbstractTextField;
import org.apache.commons.lang.StringUtils;
import org.vaadin.aceeditor.AceEditor;
@ -19,8 +21,9 @@ public class CubaSourceCodeEditor extends AceEditor implements AutoCompleteSuppo
public CubaSourceCodeEditor() {
String location = ControllerUtils.getLocationWithoutParams();
if (!StringUtils.endsWith(location, "/"))
if (!StringUtils.endsWith(location, "/")) {
location += "/";
}
String aceLocation = location + "VAADIN/resources/ace";
@ -34,4 +37,23 @@ public class CubaSourceCodeEditor extends AceEditor implements AutoCompleteSuppo
setTextChangeEventMode(AbstractTextField.TextChangeEventMode.LAZY);
setTextChangeTimeout(200);
}
@Override
protected void setInternalValue(String newValue) {
if (newValue == null) {
newValue = "";
}
super.setInternalValue(newValue);
}
@Override
protected void setValue(String newFieldValue, boolean repaintIsNotNeeded)
throws ReadOnlyException, Converter.ConversionException, Validator.InvalidValueException {
if (newFieldValue == null) {
newFieldValue = "";
}
super.setValue(newFieldValue, repaintIsNotNeeded);
}
}