mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
PL-8777 Support for Buffered mode for field components
This commit is contained in:
parent
49d1345d70
commit
8a85f18d75
@ -214,4 +214,31 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
|
||||
public boolean isChecked() {
|
||||
return impl.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
}
|
@ -633,6 +633,33 @@ public class DesktopDateField extends DesktopAbstractField<JPanel> implements Da
|
||||
return new Dimension(110, DesktopComponentsHelper.FIELD_HEIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
public class FocusableComposition extends JPanel implements FocusableComponent, Flushable {
|
||||
|
||||
@Override
|
||||
|
@ -738,6 +738,33 @@ public class DesktopLookupField extends DesktopAbstractOptionsField<JComponent>
|
||||
return Collections.singleton(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
protected class NullOption extends EntityWrapper {
|
||||
public NullOption() {
|
||||
super(new AbstractNotPersistentEntity() {
|
||||
|
@ -62,6 +62,33 @@ public class DesktopPasswordField extends DesktopAbstractTextField<JPasswordFiel
|
||||
return super.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
protected class PasswordFlushableField extends JPasswordField implements Flushable {
|
||||
|
||||
public PasswordFlushableField() {
|
||||
|
@ -594,4 +594,31 @@ public class DesktopPickerField extends DesktopAbstractField<Picker>
|
||||
public Collection getLookupSelectedItems() {
|
||||
return Collections.singleton(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -716,6 +716,33 @@ public class DesktopSearchField extends DesktopAbstractOptionsField<JComponent>
|
||||
return Collections.singleton(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
protected class NullOption extends EntityWrapper {
|
||||
public NullOption() {
|
||||
super(new AbstractNotPersistentEntity() {
|
||||
|
@ -174,6 +174,33 @@ public class DesktopSuggestionPickerField extends DesktopSuggestionField impleme
|
||||
return Collections.singleton(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
private class Picker extends com.haulmont.cuba.desktop.sys.vcl.Picker {
|
||||
@Override
|
||||
protected void initEditor() {
|
||||
|
@ -280,6 +280,33 @@ public class DesktopTextArea extends DesktopAbstractTextField<JTextArea> impleme
|
||||
this.textChangeEventMode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
protected class TextAreaFlushableField extends JTextArea implements Flushable {
|
||||
|
||||
@Override
|
||||
|
@ -241,6 +241,33 @@ public class DesktopTextField extends DesktopAbstractTextField<JTextComponent> i
|
||||
enterPressListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
protected class FlushableTextField extends JTextField implements Flushable {
|
||||
|
||||
@Override
|
||||
|
@ -386,6 +386,33 @@ public class DesktopTimeField extends DesktopAbstractField<JFormattedTextField>
|
||||
return timeFormat.contains("a");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
protected class FieldListener implements FocusListener, KeyListener {
|
||||
private static final int ENTER_CODE = 10;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.haulmont.cuba.gui.components;
|
||||
|
||||
public interface CheckBox extends Field, Component.Focusable {
|
||||
public interface CheckBox extends Field, Component.Buffered, Component.Focusable {
|
||||
String NAME = "checkBox";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -691,6 +691,47 @@ public interface Component {
|
||||
void validate() throws ValidationException;
|
||||
}
|
||||
|
||||
interface Buffered {
|
||||
/**
|
||||
* Updates all changes since the previous commit to the data source.
|
||||
*/
|
||||
void commit();
|
||||
|
||||
/**
|
||||
* Discards all changes since last commit. The object updates its value from the data source.
|
||||
*/
|
||||
void discard();
|
||||
|
||||
/**
|
||||
* @return {@code true} if buffered mode is on, {@code false} otherwise
|
||||
*/
|
||||
boolean isBuffered();
|
||||
|
||||
/**
|
||||
* Sets the buffered mode.
|
||||
* <p>
|
||||
* When in buffered mode, an internal buffer will be used to store changes
|
||||
* until {@link #commit()} is called. Calling {@link #discard()} will revert
|
||||
* the internal buffer to the value of the data source.
|
||||
* <p>
|
||||
* When in non-buffered mode both read and write operations will be done
|
||||
* directly on the data source. In this mode the {@link #commit()} and
|
||||
* {@link #discard()} methods serve no purpose.
|
||||
*
|
||||
* @param buffered {@code true} if buffered mode should be turned on, {@code false} otherwise
|
||||
*/
|
||||
void setBuffered(boolean buffered);
|
||||
|
||||
/**
|
||||
* Tests if the value stored in the object has been modified since it was
|
||||
* last updated from the data source.
|
||||
*
|
||||
* @return {@code true} if the value in the object has been modified
|
||||
* since the last data source update, {@code false} if not.
|
||||
*/
|
||||
boolean isModified();
|
||||
}
|
||||
|
||||
interface HasPresentations extends HasSettings {
|
||||
void usePresentations(boolean b);
|
||||
boolean isUsePresentations();
|
||||
|
@ -19,7 +19,7 @@ package com.haulmont.cuba.gui.components;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public interface DateField extends Field, Component.Focusable {
|
||||
public interface DateField extends Field, Component.Buffered, Component.Focusable {
|
||||
String NAME = "dateField";
|
||||
|
||||
enum Resolution {
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package com.haulmont.cuba.gui.components;
|
||||
|
||||
public interface LookupField extends OptionsField, Component.HasInputPrompt, LookupComponent, Component.Focusable {
|
||||
public interface LookupField extends OptionsField, Component.HasInputPrompt, Component.Buffered, LookupComponent, Component.Focusable {
|
||||
|
||||
String NAME = "lookupField";
|
||||
|
||||
|
@ -54,7 +54,7 @@ import java.util.Map;
|
||||
*
|
||||
* @see LookupPickerField
|
||||
*/
|
||||
public interface PickerField extends Field, Component.ActionsHolder, LookupComponent, Component.Focusable {
|
||||
public interface PickerField extends Field, Component.ActionsHolder, Component.Buffered, LookupComponent, Component.Focusable {
|
||||
|
||||
String NAME = "pickerField";
|
||||
|
||||
|
@ -19,7 +19,7 @@ package com.haulmont.cuba.gui.components;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
public interface TextInputField extends Field, Component.Focusable {
|
||||
public interface TextInputField extends Field, Component.Buffered, Component.Focusable {
|
||||
|
||||
/**
|
||||
* Defines case conversion for text input fields,
|
||||
|
@ -18,7 +18,7 @@ package com.haulmont.cuba.gui.components;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface TimeField extends Field, Component.Focusable {
|
||||
public interface TimeField extends Field, Component.Buffered, Component.Focusable {
|
||||
String NAME = "timeField";
|
||||
|
||||
boolean getShowSeconds();
|
||||
|
@ -783,6 +783,10 @@
|
||||
<xs:attribute name="requiredMessage" type="resourceString"/>
|
||||
</xs:attributeGroup>
|
||||
|
||||
<xs:attributeGroup name="hasBuffered">
|
||||
<xs:attribute name="buffered" type="xs:boolean"/>
|
||||
</xs:attributeGroup>
|
||||
|
||||
<xs:attributeGroup name="hasDatatype">
|
||||
<xs:attribute name="datatype" type="datatypeEnum"/>
|
||||
</xs:attributeGroup>
|
||||
@ -998,6 +1002,7 @@
|
||||
<xs:complexType name="checkBoxComponent">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="baseComponent">
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
<xs:attributeGroup ref="hasTabIndex"/>
|
||||
<xs:attributeGroup ref="hasEditable"/>
|
||||
<xs:attributeGroup ref="hasDatasource"/>
|
||||
@ -1095,6 +1100,7 @@
|
||||
<xs:element name="formatter" minOccurs="0" maxOccurs="1" type="formatterType"/>
|
||||
</xs:sequence>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
<xs:attributeGroup ref="hasDatatype"/>
|
||||
|
||||
<xs:attribute name="stylename" type="textFieldStylename"/>
|
||||
@ -1117,6 +1123,7 @@
|
||||
|
||||
<xs:attribute name="caseConversion" type="caseConversion"/>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
<xs:attributeGroup ref="hasDatatype"/>
|
||||
<xs:attributeGroup ref="hasSettings"/>
|
||||
|
||||
@ -1152,6 +1159,8 @@
|
||||
<xs:extension base="baseTextComponent">
|
||||
<xs:attribute name="mask" type="xs:string" use="required"/>
|
||||
<xs:attribute name="valueMode" type="maskedFieldValueMode"/>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
@ -1161,6 +1170,8 @@
|
||||
<xs:extension base="baseTextComponent">
|
||||
<xs:attribute name="maxLength" type="xs:int"/>
|
||||
<xs:attribute name="autocomplete" type="xs:boolean"/>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
@ -1168,7 +1179,9 @@
|
||||
<!-- RichTextArea -->
|
||||
<xs:complexType name="richTextAreaComponent">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="baseTextComponent"/>
|
||||
<xs:extension base="baseTextComponent">
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
||||
@ -1187,6 +1200,7 @@
|
||||
<xs:attribute name="resolution" type="dateFieldResolution"/>
|
||||
<xs:attribute name="dateFormat" type="xs:string"/>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
<xs:attributeGroup ref="hasTabIndex"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
@ -1228,6 +1242,7 @@
|
||||
<xs:attribute name="showSeconds" type="xs:boolean"/>
|
||||
<xs:attribute name="timeFormat" type="xs:string"/>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
<xs:attributeGroup ref="hasTabIndex"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
@ -1250,6 +1265,8 @@
|
||||
<xs:sequence>
|
||||
<xs:element name="validator" minOccurs="0" maxOccurs="1" type="validatorType"/>
|
||||
</xs:sequence>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
<xs:attributeGroup ref="hasOptions"/>
|
||||
<xs:attributeGroup ref="hasCaptionSource"/>
|
||||
|
||||
@ -1277,6 +1294,7 @@
|
||||
<xs:element name="validator" minOccurs="0" maxOccurs="1" type="validatorType"/>
|
||||
</xs:sequence>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
<xs:attributeGroup ref="hasOptions"/>
|
||||
<xs:attributeGroup ref="hasCaptionSource"/>
|
||||
|
||||
@ -1330,6 +1348,7 @@
|
||||
<xs:element name="actions" minOccurs="0" maxOccurs="1" type="componentActions"/>
|
||||
</xs:sequence>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
<xs:attributeGroup ref="hasCaptionSource"/>
|
||||
<xs:attributeGroup ref="hasTabIndex"/>
|
||||
|
||||
@ -1350,6 +1369,7 @@
|
||||
|
||||
<xs:attribute name="stylename" type="lookupPickerFieldStylename"/>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
<xs:attributeGroup ref="hasOptions"/>
|
||||
<xs:attributeGroup ref="hasCaptionSource"/>
|
||||
<xs:attributeGroup ref="hasTabIndex"/>
|
||||
@ -1373,6 +1393,7 @@
|
||||
<xs:element name="actions" minOccurs="0" maxOccurs="1" type="componentActions"/>
|
||||
</xs:sequence>
|
||||
|
||||
<xs:attributeGroup ref="hasBuffered"/>
|
||||
<xs:attributeGroup ref="hasOptions"/>
|
||||
<xs:attributeGroup ref="hasCaptionSource"/>
|
||||
<xs:attributeGroup ref="hasTabIndex"/>
|
||||
@ -1771,7 +1792,7 @@
|
||||
<xs:complexType name="fieldGroupField">
|
||||
<xs:sequence>
|
||||
<xs:group ref="layoutOrComponent"/>
|
||||
|
||||
|
||||
<xs:element name="formatter" minOccurs="0" maxOccurs="1" type="formatterType"/>
|
||||
<xs:element name="validator" minOccurs="0" maxOccurs="1" type="validatorType"/>
|
||||
</xs:sequence>
|
||||
|
@ -18,6 +18,7 @@ package com.haulmont.cuba.gui.xml.layout.loaders;
|
||||
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.gui.components.Component;
|
||||
import com.haulmont.cuba.gui.components.Field;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Element;
|
||||
@ -87,4 +88,11 @@ public abstract class AbstractFieldLoader<T extends Field> extends AbstractDatas
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadBuffered(Component.Buffered component, Element element) {
|
||||
String buffered = element.attributeValue("buffered");
|
||||
if (StringUtils.isNotEmpty(buffered)) {
|
||||
component.setBuffered(Boolean.parseBoolean(buffered));
|
||||
}
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ public abstract class AbstractTextFieldLoader<T extends TextInputField> extends
|
||||
public void loadComponent() {
|
||||
super.loadComponent();
|
||||
|
||||
loadBuffered(resultComponent, element);
|
||||
loadTabIndex(resultComponent, element);
|
||||
}
|
||||
|
||||
|
@ -25,4 +25,11 @@ public class CheckBoxLoader extends AbstractFieldLoader<CheckBox> {
|
||||
resultComponent = (CheckBox) factory.createComponent(CheckBox.NAME);
|
||||
loadId(resultComponent, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadComponent() {
|
||||
super.loadComponent();
|
||||
|
||||
loadBuffered(resultComponent, element);
|
||||
}
|
||||
}
|
@ -92,6 +92,8 @@ public class DateFieldLoader extends AbstractFieldLoader<DateField> {
|
||||
}
|
||||
resultComponent.setDateFormat(formatStr);
|
||||
|
||||
loadBuffered(resultComponent, element);
|
||||
|
||||
loadRangeStart(resultComponent, element);
|
||||
loadRangeEnd(resultComponent, element);
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ public class LookupFieldLoader extends AbstractFieldLoader<LookupField> {
|
||||
resultComponent.setPageLength(Integer.parseInt(pageLength));
|
||||
}
|
||||
|
||||
loadBuffered(resultComponent, element);
|
||||
|
||||
loadTextInputAllowed();
|
||||
loadInputPrompt(resultComponent, element);
|
||||
|
||||
|
@ -59,6 +59,8 @@ public class PickerFieldLoader extends AbstractFieldLoader<PickerField> {
|
||||
resultComponent.addClearAction();
|
||||
}
|
||||
}
|
||||
|
||||
loadBuffered(resultComponent, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,6 +43,8 @@ public class TimeFieldLoader extends AbstractFieldLoader<TimeField> {
|
||||
if (StringUtils.isNotEmpty(showSeconds)) {
|
||||
resultComponent.setShowSeconds(Boolean.parseBoolean(showSeconds));
|
||||
}
|
||||
|
||||
loadBuffered(resultComponent, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -386,6 +386,26 @@ public abstract class WebAbstractField<T extends com.vaadin.ui.AbstractField>
|
||||
}
|
||||
}
|
||||
|
||||
protected void commit() {
|
||||
component.commit();
|
||||
}
|
||||
|
||||
protected void discard() {
|
||||
component.discard();
|
||||
}
|
||||
|
||||
protected boolean isBuffered() {
|
||||
return component.isBuffered();
|
||||
}
|
||||
|
||||
protected void setBuffered(boolean buffered) {
|
||||
component.setBuffered(buffered);
|
||||
}
|
||||
|
||||
protected boolean isModified() {
|
||||
return component.isModified();
|
||||
}
|
||||
|
||||
protected boolean isEmpty(Object value) {
|
||||
return value == null;
|
||||
}
|
||||
|
@ -206,6 +206,31 @@ public abstract class WebAbstractTextField<T extends AbstractTextField>
|
||||
component.setTabIndex(tabIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
super.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
super.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return super.isBuffered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
super.setBuffered(buffered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return super.isModified();
|
||||
}
|
||||
|
||||
protected class TextFieldStringToDatatypeConverter extends StringToDatatypeConverter {
|
||||
public TextFieldStringToDatatypeConverter(Datatype datatype) {
|
||||
super(datatype);
|
||||
|
@ -99,4 +99,29 @@ public class WebCheckBox extends WebAbstractField<com.vaadin.ui.CheckBox> implem
|
||||
((CubaCheckBox) component).setCaptionManagedByLayout(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
super.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
super.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return super.isBuffered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
super.setBuffered(buffered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return super.isModified();
|
||||
}
|
||||
}
|
@ -75,6 +75,8 @@ public class WebDateField extends WebAbstractField<CubaDateFieldWrapper> impleme
|
||||
protected Datasource.ItemChangeListener itemChangeListener;
|
||||
protected WeakItemChangeListener weakItemChangeListener;
|
||||
|
||||
protected boolean buffered = false;
|
||||
|
||||
public WebDateField() {
|
||||
innerLayout = new com.vaadin.ui.CssLayout();
|
||||
innerLayout.setPrimaryStyleName("c-datefield-layout");
|
||||
@ -300,6 +302,58 @@ public class WebDateField extends WebAbstractField<CubaDateFieldWrapper> impleme
|
||||
updateInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
if (updatingInstance) {
|
||||
return;
|
||||
}
|
||||
|
||||
updatingInstance = true;
|
||||
try {
|
||||
if (datasource != null && metaPropertyPath != null) {
|
||||
Date value = constructDate();
|
||||
|
||||
if (datasource.getItem() != null) {
|
||||
InstanceUtils.setValueEx(datasource.getItem(), metaPropertyPath.getPath(), value);
|
||||
setModified(false);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
updatingInstance = false;
|
||||
}
|
||||
|
||||
Object newValue = getValue();
|
||||
fireValueChanged(newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
if (datasource != null && datasource.getItem() != null) {
|
||||
Date value = getEntityValue(datasource.getItem());
|
||||
setValueToFields(toUserDate(value));
|
||||
fireValueChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return buffered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
this.buffered = buffered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return dateField.isModified();
|
||||
}
|
||||
|
||||
protected void setModified(boolean modified) {
|
||||
dateField.setModified(modified);
|
||||
}
|
||||
|
||||
protected Date toUserDate(Date date) {
|
||||
return timeZone == null ? date : timeZones.convert(date, TimeZone.getDefault(), timeZone);
|
||||
}
|
||||
@ -358,8 +412,13 @@ public class WebDateField extends WebAbstractField<CubaDateFieldWrapper> impleme
|
||||
if (datasource != null && metaPropertyPath != null) {
|
||||
Date value = constructDate();
|
||||
|
||||
if (datasource.getItem() != null) {
|
||||
InstanceUtils.setValueEx(datasource.getItem(), metaPropertyPath.getPath(), value);
|
||||
if (!isBuffered()) {
|
||||
if (datasource.getItem() != null) {
|
||||
InstanceUtils.setValueEx(datasource.getItem(), metaPropertyPath.getPath(), value);
|
||||
setModified(false);
|
||||
}
|
||||
} else {
|
||||
setModified(true);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@ -436,7 +495,7 @@ public class WebDateField extends WebAbstractField<CubaDateFieldWrapper> impleme
|
||||
if (updatingInstance) {
|
||||
return;
|
||||
}
|
||||
if (e.getProperty().equals(metaPropertyPath.toString())) {
|
||||
if (!isBuffered() && e.getProperty().equals(metaPropertyPath.toString())) {
|
||||
setValueToFields(toUserDate((Date) e.getValue()));
|
||||
fireValueChanged(e.getValue());
|
||||
}
|
||||
|
@ -464,6 +464,31 @@ public class WebLookupField extends WebAbstractOptionsField<CubaComboBox> implem
|
||||
return Collections.singleton(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
super.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
super.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return super.isBuffered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
super.setBuffered(buffered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return super.isModified();
|
||||
}
|
||||
|
||||
protected interface LookupFieldDsWrapper {
|
||||
void forceItemSetNotification();
|
||||
}
|
||||
|
@ -244,6 +244,34 @@ public class WebLookupPickerField extends WebLookupField implements LookupPicker
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
super.commit();
|
||||
pickerField.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
super.discard();
|
||||
pickerField.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return pickerField.isBuffered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
super.setBuffered(buffered);
|
||||
pickerField.setBuffered(buffered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return pickerField.isModified();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setEditableToComponent(boolean editable) {
|
||||
super.setEditableToComponent(editable);
|
||||
|
@ -232,7 +232,7 @@ public class WebPickerField extends WebAbstractField<CubaPickerField>
|
||||
datasource.addItemChangeListener(weakItemChangeListener);
|
||||
|
||||
itemPropertyChangeListener = e -> {
|
||||
if (e.getProperty().equals(metaPropertyPath.toString())) {
|
||||
if (!isBuffered() && e.getProperty().equals(metaPropertyPath.toString())) {
|
||||
setValue(e.getValue());
|
||||
}
|
||||
};
|
||||
@ -443,6 +443,32 @@ public class WebPickerField extends WebAbstractField<CubaPickerField>
|
||||
component.getField().setTabIndex(tabIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
super.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
super.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return super.isBuffered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
super.setBuffered(buffered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return super.isModified();
|
||||
}
|
||||
|
||||
|
||||
protected class PickerButton extends WebButton {
|
||||
public PickerButton() {
|
||||
}
|
||||
|
@ -98,4 +98,29 @@ public class WebRichTextArea extends WebAbstractField<CubaRichTextArea> implemen
|
||||
public void setTabIndex(int tabIndex) {
|
||||
component.setTabIndex(tabIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
super.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
super.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return super.isBuffered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
super.setBuffered(buffered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return super.isModified();
|
||||
}
|
||||
}
|
@ -226,6 +226,34 @@ public class WebSearchPickerField extends WebSearchField implements SearchPicker
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
super.commit();
|
||||
pickerField.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
super.discard();
|
||||
pickerField.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return pickerField.isBuffered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
super.setBuffered(buffered);
|
||||
pickerField.setBuffered(buffered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return pickerField.isModified();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setEditableToComponent(boolean editable) {
|
||||
super.setEditableToComponent(editable);
|
||||
|
@ -300,4 +300,29 @@ public class WebSuggestionField extends WebAbstractField<CubaSuggestionField> im
|
||||
public void setTabIndex(int tabIndex) {
|
||||
component.setTabIndex(tabIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
throw new UnsupportedOperationException("Buffered mode isn't supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@ -251,4 +251,29 @@ public class WebSuggestionPickerField extends WebSuggestionField implements Sugg
|
||||
public Collection getLookupSelectedItems() {
|
||||
return Collections.singleton(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
throw new UnsupportedOperationException("Buffered mode isn't supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
@ -322,4 +322,29 @@ public class WebTimeField extends WebAbstractField<CubaMaskedTextField> implemen
|
||||
public void setTabIndex(int tabIndex) {
|
||||
component.setTabIndex(tabIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
super.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
super.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuffered() {
|
||||
return super.isBuffered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuffered(boolean buffered) {
|
||||
super.setBuffered(buffered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return super.isModified();
|
||||
}
|
||||
}
|
@ -59,6 +59,12 @@ public class CubaDateField extends com.vaadin.ui.DateField implements Action.Con
|
||||
return (CubaDateFieldState) super.getState(markAsDirty);
|
||||
}
|
||||
|
||||
public void setModified(boolean modified) {
|
||||
if (getState(false).modified != modified) {
|
||||
getState().modified = modified;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setValue(Date newValue, boolean repaintIsNotNeeded) throws Converter.ConversionException {
|
||||
if (newValue == MARKER_DATE)
|
||||
|
Loading…
Reference in New Issue
Block a user