Search in sources :

Example 11 with CalendarDate

use of org.apache.pivot.util.CalendarDate in project pivot by apache.

the class ExpenseSheet method clear.

@Override
public void clear() {
    super.clear();
    // Set date to today
    dateSpinner.setSelectedItem(new CalendarDate());
}
Also used : CalendarDate(org.apache.pivot.util.CalendarDate)

Example 12 with CalendarDate

use of org.apache.pivot.util.CalendarDate in project pivot by apache.

the class Pivot714 method getWindow.

public Window getWindow(final Window ownerArgument) {
    this.owner = ownerArgument;
    final BXMLSerializer bxmlSerializer = new BXMLSerializer();
    try {
        result = (Dialog) bxmlSerializer.readObject(Pivot714.class.getResource("pivot_714.bxml"));
    } catch (IOException e) {
        e.printStackTrace();
    } catch (SerializationException e) {
        e.printStackTrace();
    }
    final ListButton motif = (ListButton) bxmlSerializer.getNamespace().get("motif");
    ArrayList<String> al = new ArrayList<>();
    al.add("One");
    al.add("Two");
    motif.setListData(al);
    CalendarButton cbDate = (CalendarButton) bxmlSerializer.getNamespace().get("date");
    dcl = (new DialogCloseListener() {

        @Override
        public void dialogClosed(Dialog dialog, boolean modal) {
        // empty block
        }
    });
    cbDate.getCalendarButtonSelectionListeners().add(new CalendarButtonSelectionListener() {

        @Override
        public void selectedDateChanged(CalendarButton calendarButton, CalendarDate previousSelectedDate) {
        // empty block
        }
    });
    return result;
}
Also used : SerializationException(org.apache.pivot.serialization.SerializationException) ArrayList(org.apache.pivot.collections.ArrayList) CalendarButtonSelectionListener(org.apache.pivot.wtk.CalendarButtonSelectionListener) IOException(java.io.IOException) ListButton(org.apache.pivot.wtk.ListButton) CalendarDate(org.apache.pivot.util.CalendarDate) CalendarButton(org.apache.pivot.wtk.CalendarButton) Dialog(org.apache.pivot.wtk.Dialog) DialogCloseListener(org.apache.pivot.wtk.DialogCloseListener) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 13 with CalendarDate

use of org.apache.pivot.util.CalendarDate in project pivot by apache.

the class TableViewDateCellRenderer method toString.

@Override
public String toString(Object row, String columnName) {
    Object cellData = JSON.get(row, columnName);
    String string;
    if (cellData instanceof Date) {
        string = dateFormat.format((Date) cellData);
    } else if (cellData instanceof Long) {
        string = dateFormat.format(new Date((Long) cellData));
    } else if (cellData instanceof Calendar) {
        string = dateFormat.format(((Calendar) cellData).getTime());
    } else if (cellData instanceof CalendarDate) {
        string = dateFormat.format(((CalendarDate) cellData).toCalendar().getTime());
    } else {
        string = (cellData == null) ? null : cellData.toString();
    }
    return string;
}
Also used : CalendarDate(org.apache.pivot.util.CalendarDate) Calendar(java.util.Calendar) Date(java.util.Date) CalendarDate(org.apache.pivot.util.CalendarDate)

Example 14 with CalendarDate

use of org.apache.pivot.util.CalendarDate in project pivot by apache.

the class CalendarButton method setSelectedDate.

/**
 * Sets the selected date.
 *
 * @param selectedDate The date to select, or <tt>null</tt> to clear the
 * selection.
 */
public void setSelectedDate(CalendarDate selectedDate) {
    CalendarDate previousSelectedDate = this.selectedDate;
    if (previousSelectedDate != selectedDate) {
        this.selectedDate = selectedDate;
        calendarButtonSelectionListeners.selectedDateChanged(this, previousSelectedDate);
    }
}
Also used : CalendarDate(org.apache.pivot.util.CalendarDate)

Example 15 with CalendarDate

use of org.apache.pivot.util.CalendarDate in project pivot by apache.

the class Calendar method load.

@Override
public void load(Object context) {
    if (selectedDateKey != null && JSON.containsKey(context, selectedDateKey) && selectedDateBindType != BindType.STORE) {
        Object value = JSON.get(context, selectedDateKey);
        CalendarDate selectedDateLocal = null;
        if (value instanceof CalendarDate) {
            selectedDateLocal = (CalendarDate) value;
        } else if (selectedDateBindMapping == null) {
            if (value != null) {
                selectedDateLocal = CalendarDate.decode(value.toString());
            }
        } else {
            selectedDateLocal = selectedDateBindMapping.toDate(value);
        }
        setSelectedDate(selectedDateLocal);
    }
}
Also used : CalendarDate(org.apache.pivot.util.CalendarDate)

Aggregations

CalendarDate (org.apache.pivot.util.CalendarDate)15 CalendarButton (org.apache.pivot.wtk.CalendarButton)5 Locale (java.util.Locale)2 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)2 CalendarButtonSelectionListener (org.apache.pivot.wtk.CalendarButtonSelectionListener)2 Test (org.junit.Test)2 GradientPaint (java.awt.GradientPaint)1 IOException (java.io.IOException)1 DateFormat (java.text.DateFormat)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 ArrayList (org.apache.pivot.collections.ArrayList)1 SerializationException (org.apache.pivot.serialization.SerializationException)1 Filter (org.apache.pivot.util.Filter)1 Time (org.apache.pivot.util.Time)1 Task (org.apache.pivot.util.concurrent.Task)1 Calendar (org.apache.pivot.wtk.Calendar)1