Search in sources :

Example 6 with FormattedDate

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;
}
Also used : FormattedDate(org.freeplane.features.format.FormattedDate) Quantity(org.freeplane.core.util.Quantity) Icon(javax.swing.Icon) URI(java.net.URI) IconFactory(org.freeplane.features.icon.factory.IconFactory)

Example 7 with FormattedDate

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;
}
Also used : FormattedDate(org.freeplane.features.format.FormattedDate)

Example 8 with FormattedDate

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);
    }
}
Also used : FormattedDate(org.freeplane.features.format.FormattedDate) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 9 with FormattedDate

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());
}
Also used : FormattedDate(org.freeplane.features.format.FormattedDate) FormattedObject(org.freeplane.features.format.FormattedObject) FormattedDate(org.freeplane.features.format.FormattedDate) Date(java.util.Date) Test(org.junit.Test)

Aggregations

FormattedDate (org.freeplane.features.format.FormattedDate)9 Component (java.awt.Component)2 JComponent (javax.swing.JComponent)2 JTable (javax.swing.JTable)2 JTextComponent (javax.swing.text.JTextComponent)2 FormattedObject (org.freeplane.features.format.FormattedObject)2 NodeModel (org.freeplane.features.map.NodeModel)2 ModeController (org.freeplane.features.mode.ModeController)2 MTextController (org.freeplane.features.text.mindmapmode.MTextController)2 Window (java.awt.Window)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 URI (java.net.URI)1 Date (java.util.Date)1 Vector (java.util.Vector)1 Icon (javax.swing.Icon)1 JComboBox (javax.swing.JComboBox)1 BasicComboBoxEditor (javax.swing.plaf.basic.BasicComboBoxEditor)1