mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 19:57:36 +08:00
Refs #930 Time datatype, time fields in fieldgroup
This commit is contained in:
parent
a44b9df74d
commit
2f1c113c91
@ -79,9 +79,13 @@ public class DatePicker extends JXDatePicker {
|
||||
public void setFormats(String... formats) {
|
||||
super.setFormats(formats);
|
||||
format = formats[0];
|
||||
if (getEditor() != null)
|
||||
Object prevVal = getEditor().getValue();
|
||||
if (prevVal == null) {
|
||||
getEditor().setText(getMask(format));
|
||||
}
|
||||
getEditor().setDocument(new DatePickerDocument(getEditor(), format, getMask(format), PLACE_HOLDER));
|
||||
if (prevVal != null)
|
||||
getEditor().setValue(prevVal);
|
||||
}
|
||||
|
||||
public void setFormats(DateFormat... formats) {
|
||||
|
@ -134,7 +134,6 @@ public class VMaskedTextField extends VTextField {
|
||||
char c = string.charAt(i);
|
||||
|
||||
if (maskTest.get(i) != null && c == placeholder) {
|
||||
setValue("");
|
||||
valueChange(true);
|
||||
return;
|
||||
}
|
||||
|
@ -237,12 +237,20 @@ public class WebDateField
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
prevValue = getValue();
|
||||
if (dateField.isReadOnly())
|
||||
if (!editable)
|
||||
return;
|
||||
dateField.setValue(value);
|
||||
timeField.setValue(value);
|
||||
}
|
||||
|
||||
private void setValueFromDs(Object value) {
|
||||
boolean isEditable = editable;
|
||||
if (!editable)
|
||||
setEditable(true);
|
||||
setValue(value);
|
||||
setEditable(isEditable);
|
||||
}
|
||||
|
||||
private boolean isHourUsed() {
|
||||
return resolution != null && resolution.ordinal() <= Resolution.HOUR.ordinal();
|
||||
}
|
||||
@ -336,7 +344,7 @@ public class WebDateField
|
||||
if (updatingInstance)
|
||||
return;
|
||||
Date value = InstanceUtils.getValueEx(item, metaPropertyPath.getPath());
|
||||
setValue(value);
|
||||
setValueFromDs(value);
|
||||
fireValueChanged(value);
|
||||
}
|
||||
|
||||
@ -345,13 +353,22 @@ public class WebDateField
|
||||
if (updatingInstance)
|
||||
return;
|
||||
if (property.equals(metaPropertyPath.toString())) {
|
||||
setValue(value);
|
||||
setValueFromDs(value);
|
||||
fireValueChanged(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (datasource.getState() == Datasource.State.VALID && datasource.getItem() != null) {
|
||||
if (property.equals(metaPropertyPath.toString())) {
|
||||
Date value = InstanceUtils.getValueEx(datasource.getItem(), metaPropertyPath.getPath());
|
||||
setValueFromDs(value);
|
||||
fireValueChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setRequired(metaProperty.isMandatory());
|
||||
}
|
||||
|
||||
@ -413,6 +430,8 @@ public class WebDateField
|
||||
|
||||
@Override
|
||||
public void setEditable(boolean editable) {
|
||||
if (this.editable == editable)
|
||||
return;
|
||||
this.editable = editable;
|
||||
timeField.setEditable(editable);
|
||||
dateField.setReadOnly(!editable);
|
||||
|
@ -858,7 +858,7 @@ public class WebFieldGroup extends WebAbstractComponent<FieldGroup> implements c
|
||||
@Override
|
||||
protected void initCommon(com.vaadin.ui.Field field, com.haulmont.cuba.gui.components.Field cubaField, MetaPropertyPath propertyPath) {
|
||||
final Field fieldConf = getField(propertyPath.toString());
|
||||
if ("timeField".equals(fieldType(propertyPath))) {
|
||||
if ("timeField".equals(fieldType(propertyPath))||(cubaField instanceof WebTimeField)) {
|
||||
String s = fieldConf.getXmlDescriptor().attributeValue("showSeconds");
|
||||
if (Boolean.valueOf(s)) {
|
||||
((TimeField) cubaField).setShowSeconds(true);
|
||||
|
@ -85,14 +85,20 @@ public class DateFieldWrapper extends CustomComponent implements Field {
|
||||
public void setInvalidCommitted(boolean isCommitted) {
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
dateField.setEditable(!readOnly);
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return dateField.isEditable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() throws SourceException, Validator.InvalidValueException {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() throws SourceException {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,7 +144,6 @@ public class DateFieldWrapper extends CustomComponent implements Field {
|
||||
|
||||
@Override
|
||||
public Collection<Validator> getValidators() {
|
||||
System.out.println();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user