Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.nuiton.jaxx.widgets.datetime.DateTimeEditor Maven / Gradle / Ivy
package org.nuiton.jaxx.widgets.datetime;
/*-
* #%L
* JAXX :: Widgets DateTime
* %%
* Copyright (C) 2008 - 2017 Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.swing.DefaultBoundedRangeModel;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JSpinner;
import javax.swing.JToolBar;
import javax.swing.SpinnerDateModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXDatePicker;
import org.nuiton.jaxx.runtime.JAXXBinding;
import org.nuiton.jaxx.runtime.JAXXContext;
import org.nuiton.jaxx.runtime.JAXXObject;
import org.nuiton.jaxx.runtime.JAXXObjectDescriptor;
import org.nuiton.jaxx.runtime.JAXXUtil;
import org.nuiton.jaxx.runtime.binding.DefaultJAXXBinding;
import org.nuiton.jaxx.runtime.binding.SimpleJAXXObjectBinding;
import org.nuiton.jaxx.runtime.context.DefaultJAXXContext;
import org.nuiton.jaxx.runtime.swing.SwingUtil;
import org.nuiton.jaxx.validator.JAXXValidator;
import org.nuiton.jaxx.validator.swing.SwingValidator;
import org.nuiton.jaxx.validator.swing.SwingValidatorUtil;
import org.nuiton.jaxx.validator.swing.meta.Validator;
import org.nuiton.jaxx.validator.swing.meta.ValidatorField;
import org.nuiton.jaxx.validator.swing.ui.ImageValidationUI;
import org.nuiton.jaxx.widgets.hidor.HidorButton;
import static org.nuiton.i18n.I18n.t;
public class DateTimeEditor extends JPanel implements JAXXObject, JAXXValidator {
/*-----------------------------------------------------------------------*/
/*---------------- Constants for all javaBean properties ----------------*/
/*-----------------------------------------------------------------------*/
public static final String PROPERTY_SHOW_TIME_EDITOR_SLIDER = "showTimeEditorSlider";
/*-----------------------------------------------------------------------*/
/*------------------ Constants for all public bindings ------------------*/
/*-----------------------------------------------------------------------*/
public static final String BINDING_DAY_DATE_EDITOR_DATE = "dayDateEditor.date";
public static final String BINDING_DAY_DATE_EDITOR_ENABLED = "dayDateEditor.enabled";
public static final String BINDING_HOUR_EDITOR_ENABLED = "hourEditor.enabled";
public static final String BINDING_HOUR_MODEL_VALUE = "hourModel.value";
public static final String BINDING_MINUTE_EDITOR_ENABLED = "minuteEditor.enabled";
public static final String BINDING_MINUTE_MODEL_VALUE = "minuteModel.value";
public static final String BINDING_SLIDER_ENABLED = "slider.enabled";
public static final String BINDING_SLIDER_HIDOR_TARGET_VISIBLE = "sliderHidor.targetVisible";
public static final String BINDING_SLIDER_VALUE = "slider.value";
/*-----------------------------------------------------------------------*/
/*------------------------- Other static fields -------------------------*/
/*-----------------------------------------------------------------------*/
private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAK1WQU8bRxQeO9hgAwmkKAcaqS5JwLRkbdIoF6I2gEEG2QFhgmg5pIN3wEPWs5uZ2djEag499NY/0EOvvVRR+xOinir10iv/oVJ+Qt/M7nrXxsYQxYf17pv3vvneezPfzO//oYTgaMHmxwZzqbSZcYKbTYO7TNI6MTaX9/e3Dk9IVRaIqHLqSJsj7xeLo/gBGjXbdiGRcVACpJyHlFNIOR8pt2rXHZsRFgFaKqG0kKcWETVCpETZvsFVIXKVtudS03G5P1dP1r3m+uenxbMYKfwSR6jpAP1JSPvLKwCEWQ+VUJyaEt0sneBXOGdhdgzkOGXHkNC4sq1aWIinuE5eojdouISSDuYAJtH9DyqPhtNQTUeikbub25gRKy9Rrpt/g5rHRArDxJLoRArwsgsvayY4ccfRMEmJEnXbJJZED6+IUFZhIUyqZrueTaLbKvOmIRpQCKPiUMYIV8FdIaN1ylzfqkyT4dCUqNmNcK6KRU3CJZpUwIYqs7Fi2xbBLELgFQYvDN6w+LpzaY8FpNRzLzCGIGmVrDcndDWahldp5ZZqe4+bfkVK+FDl3Rmgjcpzuh0QNGxRfd/uHAOw00Jk9ozK4QT21AtpOx5m09jcVy7btPqCcBWXaYdfVy0K49sThB5p1aEAfaqDqt8j5Xiv7Z+0VAJF9fVZ58iY17hwpvnO8ZtC96tITZvvQp9W8LkZfXMnw9FInETz/RZkTY0b2mvFlTCswo2Qt/BXyyedOWqr30COZvtteBAYIxSYcK/HDlCCu2CW6E5/bVPytANenjDd6S9Mahrt+OPbN/y3xvuzQI3GgFxmUFREeEEaHG47kDBV3G54UuRKauXK2Fk6QClBLFBtrcpzFzOv+J7AHlh4u00hGUUsaoCWGD5799et7/+9huLrKG3Z2FzHyn8DpWSNQ8Vsy2w63zzR5MYaI/CcUDShFzWb09c2k9hatugxq2sRTFbhj/AmlGru4lK1mb3dev/3rz/fexeUKwZE714mMixZ4juUpMyijGj59pW5p1yPOoK4ph3Kbi8hRiCikkqLOL6QPNbPJ+fqcE2iIa2maKqlVdeA9Vzwtn12/geJho9sXscSGnW9NWOauXI5dwq/GTVEGD60CBw2cy0q1ryP7HxmdjbjQVER7H41BHBNV7Eo6Bqpt3XULTKD+MYhoIotwkzM1ymxYPJbrVXfYBS3nu0831p/Xlj+FvglQGJdyCzfqmFmWoSr3IrBmbCnBrPtnHd9rcrO96YZHiaXoBgcYKOtdtTl6hWcLxfUK6KZl2By4SKH3kvShO+J4EAlGtco9prYF98P6NBk2KHyxtNnu2uR5jyINqccnr5XbE/04L5Cg8ZbkbiP1qKOw+gSO3D80OZwEGxjCl2BuRNH2BJQm6Tt4JeqSIEhdQQCp2cObL2m73HWDSIxBCQk5lDoPSqoxp+GAlR6XHk8VfAuQ3Dh+7wlszNdy0cNGh6JGe0NxyPp660Go95JjwhcTVqetXfDI0kOym4E3B1VXH3/EWrZc1XWtDbuwtUltKWOYLPcF/Q1vMcXF2Fv1PEJ1BGcKg6uwrkN9kf5cAnlW4w0MgVyhF1LrtguM4m5A9dBb01l8wuZxYUMPB/lM19kHjxUGU7A+uiG/Cof7onpVse632DevhBe6T/KEvVvJIMqF9Pb/tSGOw26/hgahzOHlJlA+etzqDH1TA9EVOY/1OPP3gifAsL/t/NfB/kNAAA=";
private static final Log log = LogFactory.getLog(DateTimeEditor.class);
private static final long serialVersionUID = 1L;
/*-----------------------------------------------------------------------*/
/*--------------------------- Internal states ---------------------------*/
/*-----------------------------------------------------------------------*/
protected List $activeBindings = new ArrayList();
protected Map $bindingSources = new HashMap();
protected final Map $bindings = new TreeMap();
protected Map $objectMap = new HashMap();
protected Map, ?> $previousValues = new HashMap();
protected final JAXXContext delegateContext = new DefaultJAXXContext();
/*-----------------------------------------------------------------------*/
/*------------------------ Protected components ------------------------*/
/*-----------------------------------------------------------------------*/
@ValidatorField( validatorId = "validator", propertyName = "date", editorName = "dateEditor")
protected JPanel dateEditor;
protected JLabel dateTimeLabel;
@ValidatorField( validatorId = "validator", propertyName = "dayDate", editorName = "dayDateEditor")
protected JXDatePicker dayDateEditor;
protected DateTimeEditorHandler handler;
protected JSpinner hourEditor;
protected SpinnerDateModel hourModel;
protected JLabel labelH;
protected JSpinner minuteEditor;
protected SpinnerDateModel minuteModel;
protected DateTimeEditorModel model;
protected Boolean showTimeEditorSlider;
protected JSlider slider;
protected HidorButton sliderHidor;
protected JToolBar sliderHidorToolBar;
@ValidatorField( validatorId = "validator", propertyName = "timeDate", editorName = "timeDateEditor")
protected JPanel timeDateEditor;
@Validator( validatorId = "validator")
protected SwingValidator validator;
protected List validatorIds;
/*-----------------------------------------------------------------------*/
/*------------------------- Private components -------------------------*/
/*-----------------------------------------------------------------------*/
private DateTimeEditor $JPanel0;
private JPanel $JPanel1;
/*-----------------------------------------------------------------------*/
/*---------------------- Raw body code from script ----------------------*/
/*-----------------------------------------------------------------------*/
public void init() { handler.init(this); }
public void setPropertyTimeDate(String property) { model.setPropertyTimeDate(property); }
public void setPropertyDayDate(String property) { model.setPropertyDayDate(property); }
public void setPropertyDate(String property) { model.setPropertyDate(property); }
public void setDateEditable(boolean dateEditable) { model.setDateEditable(dateEditable); }
public void setTimeEditable(boolean timeEditable) { model.setTimeEditable(timeEditable); }
public void setBean(Serializable bean) { model.setBean(bean); }
public void setDate(Date date) { model.setDate(date); }
public void setDateFormat(String dateFormat) { dayDateEditor.setFormats(dateFormat); }
public void setLabel(String label) { dateTimeLabel.setText(label); }
/*-----------------------------------------------------------------------*/
/*---------------------------- Constructors ----------------------------*/
/*-----------------------------------------------------------------------*/
public DateTimeEditor(LayoutManager param0, boolean param1) {
super(param0 ,param1);
$initialize();
}
public DateTimeEditor(JAXXContext parentContext, LayoutManager param1, boolean param2) {
super(param1 ,param2);
JAXXUtil.initContext(this, parentContext);
$initialize();
}
public DateTimeEditor(LayoutManager param0) {
super(param0);
$initialize();
}
public DateTimeEditor(JAXXContext parentContext, LayoutManager param1) {
super(param1);
JAXXUtil.initContext(this, parentContext);
$initialize();
}
public DateTimeEditor() {
$initialize();
}
public DateTimeEditor(JAXXContext parentContext) {
JAXXUtil.initContext(this, parentContext);
$initialize();
}
public DateTimeEditor(boolean param0) {
super(param0);
$initialize();
}
public DateTimeEditor(JAXXContext parentContext, boolean param1) {
super(param1);
JAXXUtil.initContext(this, parentContext);
$initialize();
}
/*-----------------------------------------------------------------------*/
/*--------------------------- Statics methods ---------------------------*/
/*-----------------------------------------------------------------------*/
public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
}
/*-----------------------------------------------------------------------*/
/*---------------------- JAXXObject implementation ----------------------*/
/*-----------------------------------------------------------------------*/
@Override
public void applyDataBinding(String $binding) {
if ($bindings.containsKey($binding)) {
getDataBinding($binding).applyDataBinding();
}
processDataBinding($binding);
}
@Override
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
super.firePropertyChange(propertyName, oldValue, newValue);
}
@Override
public Map get$objectMap() {
return $objectMap;
}
@Override
public JAXXBinding getDataBinding(String bindingId) {
return $bindings.get(bindingId);
}
@Override
public JAXXBinding[] getDataBindings() {
return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
}
@Override
public Object getObjectById(String id) {
return $objectMap.get(id);
}
@Override
public void processDataBinding(String $binding, boolean $force) {
if (!$force && $activeBindings.contains($binding)) {
return;
}
$activeBindings.add($binding);
try {
if ($bindings.containsKey($binding)) {
getDataBinding($binding).processDataBinding();
}
} finally {
$activeBindings.remove($binding);
}
}
@Override
public void processDataBinding(String $binding) {
processDataBinding($binding, false);
}
@Override
public void registerDataBinding(JAXXBinding binding) {
$bindings.put(binding.getId(), binding);
}
@Override
public void removeDataBinding(String $binding) {
if ($bindings.containsKey($binding)) {
getDataBinding($binding).removeDataBinding();
}
}
/*-----------------------------------------------------------------------*/
/*--------------------- JAXXContext implementation ---------------------*/
/*-----------------------------------------------------------------------*/
@Override
public T getContextValue(Class clazz) {
return delegateContext.getContextValue(clazz, null);
}
@Override
public T getContextValue(Class clazz, String name) {
return delegateContext.getContextValue(clazz, name);
}
@Override
public JAXXContext getDelegateContext() {
return delegateContext;
}
@Override
public O getParentContainer(Class clazz) {
return SwingUtil.getParentContainer(this, clazz);
}
@Override
public O getParentContainer(Object source, Class clazz) {
return SwingUtil.getParentContainer(source, clazz);
}
@Override
public void removeContextValue(Class clazz) {
delegateContext.removeContextValue(clazz, null);
}
@Override
public void removeContextValue(Class clazz, String name) {
delegateContext.removeContextValue(clazz, name);
}
@Override
public void setContextValue(T o) {
delegateContext.setContextValue(o, null);
}
@Override
public void setContextValue(T o, String name) {
delegateContext.setContextValue(o, name);
}
/*-----------------------------------------------------------------------*/
/*-------------------- JAXXValidator implementation --------------------*/
/*-----------------------------------------------------------------------*/
@Override
public SwingValidator> getValidator(String validatorId) {
return (SwingValidator>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
}
@Override
public List getValidatorIds() {
return validatorIds;
}
@Override
public void registerValidatorFields() {
SwingValidatorUtil.detectValidatorFields(this);
}
/*-----------------------------------------------------------------------*/
/*---------------------------- Event methods ----------------------------*/
/*-----------------------------------------------------------------------*/
public void doActionPerformed__on__dayDateEditor(ActionEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
model.setDayDate((Date)((JXDatePicker)event.getSource()).getDate());
}
public void doStateChanged__on__hourEditor(ChangeEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
handler.setHours((Date)((JSpinner)event.getSource()).getValue());
}
public void doStateChanged__on__minuteEditor(ChangeEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
handler.setMinutes((Date)((JSpinner)event.getSource()).getValue());
}
public void doStateChanged__on__slider(ChangeEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
if (!slider.getValueIsAdjusting()) model.setTimeInMinutes((Integer)((JSlider)event.getSource()).getValue());
}
/*-----------------------------------------------------------------------*/
/*----------------------- Public acessor methods -----------------------*/
/*-----------------------------------------------------------------------*/
public JPanel getDateEditor() {
return dateEditor;
}
public JLabel getDateTimeLabel() {
return dateTimeLabel;
}
public JXDatePicker getDayDateEditor() {
return dayDateEditor;
}
public DateTimeEditorHandler getHandler() {
return handler;
}
public JSpinner getHourEditor() {
return hourEditor;
}
public SpinnerDateModel getHourModel() {
return hourModel;
}
public JLabel getLabelH() {
return labelH;
}
public JSpinner getMinuteEditor() {
return minuteEditor;
}
public SpinnerDateModel getMinuteModel() {
return minuteModel;
}
public DateTimeEditorModel getModel() {
return model;
}
public Boolean getShowTimeEditorSlider() {
return showTimeEditorSlider;
}
public JSlider getSlider() {
return slider;
}
public HidorButton getSliderHidor() {
return sliderHidor;
}
public JToolBar getSliderHidorToolBar() {
return sliderHidorToolBar;
}
public JPanel getTimeDateEditor() {
return timeDateEditor;
}
public SwingValidator getValidator() {
return validator;
}
public Boolean isShowTimeEditorSlider() {
return showTimeEditorSlider !=null && showTimeEditorSlider;
}
/*-----------------------------------------------------------------------*/
/*----------------------- Public mutator methods -----------------------*/
/*-----------------------------------------------------------------------*/
public void setShowTimeEditorSlider(Boolean showTimeEditorSlider) {
Boolean oldValue = this.showTimeEditorSlider;
this.showTimeEditorSlider = showTimeEditorSlider;
firePropertyChange(PROPERTY_SHOW_TIME_EDITOR_SLIDER, oldValue, showTimeEditorSlider);
}
/*-----------------------------------------------------------------------*/
/*--------------------- Protected acessors methods ---------------------*/
/*-----------------------------------------------------------------------*/
protected JPanel get$JPanel1() {
return $JPanel1;
}
/*-----------------------------------------------------------------------*/
/*--------------------- Components creation methods ---------------------*/
/*-----------------------------------------------------------------------*/
protected void addChildrenToDateEditor() {
dateEditor.add(dateTimeLabel, BorderLayout.WEST);
dateEditor.add($JPanel1, BorderLayout.EAST);
}
protected void addChildrenToSliderHidorToolBar() {
sliderHidorToolBar.add(sliderHidor);
}
protected void addChildrenToTimeDateEditor() {
timeDateEditor.add(hourEditor);
timeDateEditor.add(labelH);
timeDateEditor.add(minuteEditor);
}
protected void addChildrenToValidator() {
validator.setUiClass(ImageValidationUI.class);
validator.setBean(model);
}
protected void createDateEditor() {
$objectMap.put("dateEditor", dateEditor = new JPanel());
dateEditor.setName("dateEditor");
dateEditor.setLayout(new BorderLayout());
}
protected void createDateTimeLabel() {
$objectMap.put("dateTimeLabel", dateTimeLabel = new JLabel());
dateTimeLabel.setName("dateTimeLabel");
}
protected void createDayDateEditor() {
$objectMap.put("dayDateEditor", dayDateEditor = new JXDatePicker());
dayDateEditor.setName("dayDateEditor");
dayDateEditor.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__dayDateEditor"));
}
protected void createHourEditor() {
$objectMap.put("hourEditor", hourEditor = new JSpinner());
hourEditor.setName("hourEditor");
hourEditor.addChangeListener(JAXXUtil.getEventListener(ChangeListener.class, "stateChanged", this, "doStateChanged__on__hourEditor"));
}
protected void createHourModel() {
$objectMap.put("hourModel", hourModel = new SpinnerDateModel());
}
protected void createLabelH() {
$objectMap.put("labelH", labelH = new JLabel());
labelH.setName("labelH");
labelH.setHorizontalAlignment(0);
labelH.setText(t("datetimeeditor.H"));
}
protected void createMinuteEditor() {
$objectMap.put("minuteEditor", minuteEditor = new JSpinner());
minuteEditor.setName("minuteEditor");
minuteEditor.addChangeListener(JAXXUtil.getEventListener(ChangeListener.class, "stateChanged", this, "doStateChanged__on__minuteEditor"));
}
protected void createMinuteModel() {
$objectMap.put("minuteModel", minuteModel = new SpinnerDateModel());
}
protected void createModel() {
$objectMap.put("model", model = new DateTimeEditorModel());
}
protected void createShowTimeEditorSlider() {
$objectMap.put("showTimeEditorSlider", showTimeEditorSlider = true);
}
protected void createSlider() {
$objectMap.put("slider", slider = new JSlider());
slider.setName("slider");
slider.setValue(0);
slider.setPaintLabels(true);
slider.setPaintTicks(true);
if (slider.getFont() != null) {
slider.setFont(slider.getFont().deriveFont((float) 11));
}
slider.setMajorTickSpacing(60);
slider.setMinorTickSpacing(30);
slider.addChangeListener(JAXXUtil.getEventListener(ChangeListener.class, "stateChanged", this, "doStateChanged__on__slider"));
}
protected void createSliderHidor() {
$objectMap.put("sliderHidor", sliderHidor = new HidorButton());
sliderHidor.setName("sliderHidor");
}
protected void createSliderHidorToolBar() {
$objectMap.put("sliderHidorToolBar", sliderHidorToolBar = new JToolBar());
sliderHidorToolBar.setName("sliderHidorToolBar");
sliderHidorToolBar.setBorderPainted(false);
sliderHidorToolBar.setOpaque(false);
sliderHidorToolBar.setFloatable(false);
}
protected void createTimeDateEditor() {
$objectMap.put("timeDateEditor", timeDateEditor = new JPanel());
timeDateEditor.setName("timeDateEditor");
}
protected void createValidator() {
$objectMap.put("validator", validator = SwingValidator.newValidator(DateTimeEditorModel.class, null));
}
/*-----------------------------------------------------------------------*/
/*------------------------ Internal jaxx methods ------------------------*/
/*-----------------------------------------------------------------------*/
protected void $initialize() {
if (log.isDebugEnabled()) {
log.debug(this);
}
$JPanel0 = this;
handler = new DateTimeEditorHandler();
handler.beforeInit(this);
$initialize_01_createComponents();
$initialize_02_registerDataBindings();
$initialize_03_finalizeCreateComponents();
$initialize_04_applyDataBindings();
$initialize_05_setProperties();
$initialize_06_finalizeInitialize();
handler.afterInit(this);
}
protected void $initialize_01_createComponents() {
if (log.isDebugEnabled()) {
log.debug(this);
}
$objectMap.put("$JPanel0", $JPanel0);
createModel();
createHourModel();
createMinuteModel();
createShowTimeEditorSlider();
createValidator();
createDateEditor();
createDateTimeLabel();
// inline creation of $JPanel1
$objectMap.put("$JPanel1", $JPanel1 = new JPanel());
$JPanel1.setName("$JPanel1");
createDayDateEditor();
createTimeDateEditor();
createHourEditor();
createLabelH();
createMinuteEditor();
createSliderHidorToolBar();
createSliderHidor();
createSlider();
// inline creation of $JPanel0
setName("$JPanel0");
setLayout(new BorderLayout());
}
protected void $initialize_02_registerDataBindings() {
if (log.isDebugEnabled()) {
log.debug(this);
}
// register 9 data bindings
registerDataBinding(new DefaultJAXXBinding(this, BINDING_HOUR_MODEL_VALUE, true) {
@Override
public void applyDataBinding() {
if (model != null) {
model.addPropertyChangeListener("timeDate", this);
}
}
@Override
public void processDataBinding() {
if (model != null) {
hourModel.setValue(handler.getHourModelValue(model.getTimeDate()));
}
}
@Override
public void removeDataBinding() {
if (model != null) {
model.removePropertyChangeListener("timeDate", this);
}
}
});
registerDataBinding(new DefaultJAXXBinding(this, BINDING_MINUTE_MODEL_VALUE, true) {
@Override
public void applyDataBinding() {
if (model != null) {
model.addPropertyChangeListener("timeDate", this);
}
}
@Override
public void processDataBinding() {
if (model != null) {
minuteModel.setValue(handler.getMinuteModelValue(model.getTimeDate()));
}
}
@Override
public void removeDataBinding() {
if (model != null) {
model.removePropertyChangeListener("timeDate", this);
}
}
});
registerDataBinding(new DefaultJAXXBinding(this, BINDING_DAY_DATE_EDITOR_DATE, true) {
@Override
public void applyDataBinding() {
if (model != null) {
model.addPropertyChangeListener("dayDate", this);
}
}
@Override
public void processDataBinding() {
if (model != null) {
dayDateEditor.setDate(model.getDayDate());
}
}
@Override
public void removeDataBinding() {
if (model != null) {
model.removePropertyChangeListener("dayDate", this);
}
}
});
registerDataBinding(new DefaultJAXXBinding(this, BINDING_DAY_DATE_EDITOR_ENABLED, true, true) {
@Override
public void applyDataBinding() {
addPropertyChangeListener("enabled", this);
if (model != null) {
model.addPropertyChangeListener("dateEditable", this);
}
}
@Override
public void processDataBinding() {
if (model != null) {
dayDateEditor.setEnabled(isEnabled() && model.isDateEditable());
}
}
@Override
public void removeDataBinding() {
removePropertyChangeListener("enabled", this);
if (model != null) {
model.removePropertyChangeListener("dateEditable", this);
}
}
});
registerDataBinding(new DefaultJAXXBinding(this, BINDING_HOUR_EDITOR_ENABLED, true, true) {
@Override
public void applyDataBinding() {
addPropertyChangeListener("enabled", this);
if (model != null) {
model.addPropertyChangeListener("timeEditable", this);
}
}
@Override
public void processDataBinding() {
if (model != null) {
hourEditor.setEnabled(isEnabled() && model.isTimeEditable());
}
}
@Override
public void removeDataBinding() {
removePropertyChangeListener("enabled", this);
if (model != null) {
model.removePropertyChangeListener("timeEditable", this);
}
}
});
registerDataBinding(new DefaultJAXXBinding(this, BINDING_MINUTE_EDITOR_ENABLED, true, true) {
@Override
public void applyDataBinding() {
addPropertyChangeListener("enabled", this);
if (model != null) {
model.addPropertyChangeListener("timeEditable", this);
}
}
@Override
public void processDataBinding() {
if (model != null) {
minuteEditor.setEnabled(isEnabled() && model.isTimeEditable());
}
}
@Override
public void removeDataBinding() {
removePropertyChangeListener("enabled", this);
if (model != null) {
model.removePropertyChangeListener("timeEditable", this);
}
}
});
registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_SLIDER_HIDOR_TARGET_VISIBLE, true ,"showTimeEditorSlider") {
@Override
public void processDataBinding() {
sliderHidor.setTargetVisible(isShowTimeEditorSlider());
}
});
registerDataBinding(new DefaultJAXXBinding(this, BINDING_SLIDER_VALUE, true) {
@Override
public void applyDataBinding() {
if (model != null) {
model.addPropertyChangeListener("timeInMinutes", this);
}
}
@Override
public void processDataBinding() {
if (model != null) {
slider.setValue(model.getTimeInMinutes());
}
}
@Override
public void removeDataBinding() {
if (model != null) {
model.removePropertyChangeListener("timeInMinutes", this);
}
}
});
registerDataBinding(new DefaultJAXXBinding(this, BINDING_SLIDER_ENABLED, true, true) {
@Override
public void applyDataBinding() {
addPropertyChangeListener("enabled", this);
if (model != null) {
model.addPropertyChangeListener("timeEditable", this);
}
}
@Override
public void processDataBinding() {
if (model != null) {
slider.setEnabled(isEnabled() && model.isTimeEditable());
}
}
@Override
public void removeDataBinding() {
removePropertyChangeListener("enabled", this);
if (model != null) {
model.removePropertyChangeListener("timeEditable", this);
}
}
});
}
protected void $initialize_03_finalizeCreateComponents() {
if (log.isDebugEnabled()) {
log.debug(this);
}
// inline complete setup of $JPanel0
add(SwingUtil.boxComponentWithJxLayer(dateEditor), BorderLayout.NORTH);
add(slider, BorderLayout.SOUTH);
addChildrenToValidator();
addChildrenToDateEditor();
// inline complete setup of $JPanel1
$JPanel1.add(SwingUtil.boxComponentWithJxLayer(dayDateEditor));
$JPanel1.add(SwingUtil.boxComponentWithJxLayer(timeDateEditor));
$JPanel1.add(sliderHidorToolBar);
addChildrenToTimeDateEditor();
addChildrenToSliderHidorToolBar();
}
protected void $initialize_04_applyDataBindings() {
if (log.isDebugEnabled()) {
log.debug(this);
}
// apply 9 data bindings
JAXXUtil.applyDataBinding(this, $bindings.keySet());
}
protected void $initialize_05_setProperties() {
if (log.isDebugEnabled()) {
log.debug(this);
}
// apply 11 property setters
hourModel.setCalendarField(Calendar.HOUR_OF_DAY);
minuteModel.setCalendarField(Calendar.MINUTE);
dayDateEditor.setFormats("dd/MM/yyyy");
hourEditor.setModel(hourModel);
minuteEditor.setModel(minuteModel);
sliderHidor.setShowTip(t("datetimeeditor.show.slider"));
sliderHidor.setHideTip(t("datetimeeditor.hide.slider"));
sliderHidor.setTarget(slider);
slider.setModel(new DefaultBoundedRangeModel(0, 1, 0, 60 * 24));// late initializer
// register 1 validator(s)
validatorIds = SwingValidatorUtil.detectValidators(this);
SwingValidatorUtil.installUI(this);
}
protected void $initialize_06_finalizeInitialize() {
if (log.isDebugEnabled()) {
log.debug(this);
}
}
}