use of org.freeplane.features.time.TimeComboBoxEditor in project freeplane by freeplane.
the class FrameController method getTextDateTimeEditor.
public static ComboBoxEditor getTextDateTimeEditor() {
final ContainerComboBoxEditor editor = new ContainerComboBoxEditor();
final TranslatedObject keyText = new TranslatedObject("text", "1Ab");
final BasicComboBoxEditor textEditor = new FixedBasicComboBoxEditor() {
private Object oldItem;
@Override
public void setItem(Object object) {
oldItem = object;
if (object instanceof FormattedDate)
super.setItem("");
else
super.setItem(object);
}
@Override
public Object getItem() {
final Object item = super.getItem();
final Object oldItem = this.oldItem;
this.oldItem = null;
if (item != null && oldItem != null && item.toString().equals(oldItem.toString()))
return oldItem;
if (ResourceController.getResourceController().getBooleanProperty("parse_data") && item instanceof String) {
final Object scannedObject = ScannerController.getController().parse((String) item);
return scannedObject;
}
return item;
}
};
editor.put(keyText, textEditor);
final TranslatedObject keyDate = new TranslatedObject("date", "");
keyDate.setIcon(dateIcon);
final TimeComboBoxEditor dateComboBoxEditor = new TimeComboBoxEditor(false) {
@Override
public void setItem(Object object) {
if (object instanceof FormattedDate && !((FormattedDate) object).containsTime())
super.setItem(object);
else
super.setItem(null);
}
};
dateComboBoxEditor.setItem();
editor.put(keyDate, dateComboBoxEditor);
final TranslatedObject keyDateTime = new TranslatedObject("date_time", "");
keyDateTime.setIcon(dateTimeIcon);
final TimeComboBoxEditor dateTimeComboBoxEditor = new TimeComboBoxEditor(true) {
@Override
public void setItem(Object object) {
if (object instanceof FormattedDate && ((FormattedDate) object).containsTime())
super.setItem(object);
else
super.setItem(null);
}
};
dateTimeComboBoxEditor.setItem();
editor.put(keyDateTime, dateTimeComboBoxEditor);
return editor;
}
Aggregations