Search in sources :

Example 1 with CalendarButtonSelectionListener

use of org.apache.pivot.wtk.CalendarButtonSelectionListener in project pivot by apache.

the class ComponentInspectorSkin method addCalendarDateControl.

private static Component addCalendarDateControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
    CalendarDate calendarDate = (CalendarDate) dictionary.get(key);
    CalendarButton calendarButton = new CalendarButton();
    calendarButton.setMinimumWidth(75);
    calendarButton.setSelectedDate(calendarDate);
    section.add(calendarButton);
    Form.setLabel(calendarButton, key);
    calendarButton.getCalendarButtonSelectionListeners().add(new CalendarButtonSelectionListener() {

        @Override
        public void selectedDateChanged(CalendarButton calendarButtonArgument, CalendarDate previousSelectedDate) {
            try {
                dictionary.put(key, calendarButtonArgument.getSelectedDate());
            } catch (Exception exception) {
                displayErrorMessage(exception, calendarButtonArgument.getWindow());
                dictionary.put(key, previousSelectedDate);
            }
        }
    });
    return calendarButton;
}
Also used : CalendarDate(org.apache.pivot.util.CalendarDate) CalendarButton(org.apache.pivot.wtk.CalendarButton) CalendarButtonSelectionListener(org.apache.pivot.wtk.CalendarButtonSelectionListener)

Example 2 with CalendarButtonSelectionListener

use of org.apache.pivot.wtk.CalendarButtonSelectionListener 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)

Aggregations

CalendarDate (org.apache.pivot.util.CalendarDate)2 CalendarButton (org.apache.pivot.wtk.CalendarButton)2 CalendarButtonSelectionListener (org.apache.pivot.wtk.CalendarButtonSelectionListener)2 IOException (java.io.IOException)1 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)1 ArrayList (org.apache.pivot.collections.ArrayList)1 SerializationException (org.apache.pivot.serialization.SerializationException)1 Dialog (org.apache.pivot.wtk.Dialog)1 DialogCloseListener (org.apache.pivot.wtk.DialogCloseListener)1 ListButton (org.apache.pivot.wtk.ListButton)1