Search in sources :

Example 1 with DialogCloseListener

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

the class ShutdownTest method shutdown.

@Override
public boolean shutdown(boolean optional) {
    System.out.println("shutdown()");
    if (alert == null) {
        ArrayList<String> options = new ArrayList<>();
        options.add("Yes");
        options.add("No");
        alert = new Alert(MessageType.QUESTION, "Cancel shutdown?", options);
        alert.setModal(false);
        alert.open(display, new DialogCloseListener() {

            @Override
            public void dialogClosed(Dialog dialog, boolean modal) {
                if (!(dialog instanceof Alert)) {
                    return;
                }
                Alert alertLocal = (Alert) dialog;
                if (alertLocal.getResult()) {
                    if (alertLocal.getSelectedOptionIndex() == 1) {
                        cancelShutdown = false;
                        DesktopApplicationContext.exit();
                    }
                }
                ShutdownTest.this.alert = null;
            }
        });
    }
    return cancelShutdown;
}
Also used : Dialog(org.apache.pivot.wtk.Dialog) ArrayList(org.apache.pivot.collections.ArrayList) Alert(org.apache.pivot.wtk.Alert) DialogCloseListener(org.apache.pivot.wtk.DialogCloseListener)

Example 2 with DialogCloseListener

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

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