use of org.freeplane.features.format.FormattedDate in project freeplane by freeplane.
the class TypedListCellRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
final Icon icon;
if (value instanceof String) {
icon = textIcon;
} else if (value instanceof FormattedDate) {
final FormattedDate fd = (FormattedDate) value;
if (fd.containsTime())
icon = dateTimeIcon;
else
icon = dateIcon;
} else if (value instanceof URI) {
icon = linkIcon;
} else if (value instanceof Number) {
icon = numberIcon;
} else if (value instanceof ObjectAndIcon) {
icon = ((ObjectAndIcon) value).getIcon();
} else
icon = null;
final IconFactory iconFactory = IconFactory.getInstance();
if (icon != null && iconFactory.canScaleIcon(icon)) {
final int fontSize = getFont().getSize();
setIcon(iconFactory.getScaledIcon(icon, new Quantity<LengthUnits>(fontSize, LengthUnits.px)));
} else
setIcon(icon);
return this;
}
use of org.freeplane.features.format.FormattedDate in project freeplane by freeplane.
the class TimeConditionController method loadCondition.
public ASelectableCondition loadCondition(final XMLElement element) {
try {
if (element.getName().equalsIgnoreCase(TimeConditionCreatedBefore.NAME)) {
final String dateString = element.getAttribute(TimeCondition.DATE, null);
FormattedDate date = FormattedDate.createDefaultFormattedDate(Long.parseLong(dateString), IFormattedObject.TYPE_DATETIME);
return new TimeConditionCreatedBefore(date);
}
if (element.getName().equalsIgnoreCase(TimeConditionCreatedAfter.NAME)) {
final String dateString = element.getAttribute(TimeCondition.DATE, null);
FormattedDate date = FormattedDate.createDefaultFormattedDate(Long.parseLong(dateString), IFormattedObject.TYPE_DATETIME);
return new TimeConditionCreatedAfter(date);
}
if (element.getName().equalsIgnoreCase(TimeConditionModifiedBefore.NAME)) {
final String dateString = element.getAttribute(TimeCondition.DATE, null);
FormattedDate date = FormattedDate.createDefaultFormattedDate(Long.parseLong(dateString), IFormattedObject.TYPE_DATETIME);
return new TimeConditionModifiedBefore(date);
}
if (element.getName().equalsIgnoreCase(TimeConditionModifiedAfter.NAME)) {
final String dateString = element.getAttribute(TimeCondition.DATE, null);
FormattedDate date = FormattedDate.createDefaultFormattedDate(Long.parseLong(dateString), IFormattedObject.TYPE_DATETIME);
return new TimeConditionModifiedAfter(date);
}
} catch (final Exception e) {
LogUtils.severe(e);
}
return null;
}
use of org.freeplane.features.format.FormattedDate in project freeplane by freeplane.
the class TimeComboBoxEditor method updateDate.
private void updateDate() {
final FormattedDate newDate = new FormattedDate(calenderComponent.getDate(), calenderComponent.isTimeVisible() ? "yyyy-MM-dd HH:mm" : "yyyy-MM-dd");
final String type = newDate.containsTime() ? IFormattedObject.TYPE_DATETIME : IFormattedObject.TYPE_DATE;
date = FormattedDate.createDefaultFormattedDate(newDate.getTime(), type);
if (actionListeners.size() == 0) {
return;
}
final ActionEvent actionEvent = new ActionEvent(this, 0, null);
for (final ActionListener l : actionListeners) {
l.actionPerformed(actionEvent);
}
}
use of org.freeplane.features.format.FormattedDate in project freeplane by freeplane.
the class FormattedObjectTest method testStrangeInput.
@Test
public void testStrangeInput() {
final FormattedDate date = new FormattedDate(new Date(), "yyyy-mm-dd");
final FormattedObject formattedObject = new FormattedObject(date, "#.##");
assertEquals("decimal format is not applicable to date", date.toString(), formattedObject.toString());
}
Aggregations