Search in sources :

Example 6 with TaskPane

use of com.jgoodies.jsdl.core.pane.TaskPane in project kindergarten by clear-group-ausbildung.

the class Dialogs method showUnsavedChangesDialog.

/**
 * Creates and shows a TaskPane to let the user choose how to proceed with a
 * close operation on valid data. Offers: Save, Don't Save and Cancel.
 * <p>
 *
 * Context: A document shall be closed, the document has changes, and the
 * validation has detected no validation errors.
 *
 * @param e
 *          the event object
 * @param objectName
 *          describes the data to be closed, e.g. "BL 32168", "Invoice
 *          2007-10-67", "Unsaved", may be null, empty, or whitespace
 *
 * @return the TaskPane's commit value, one of: {@code CommandValue.SAVE},
 *         {@code CommandValue.DONT_SAVE}, {@code CommandValue.CANCEL}
 */
public static Object showUnsavedChangesDialog(EventObject e, String objectName) {
    String title = RESOURCES.getString("dialogs.saveUnsavedChanges.title");
    boolean hasObject = JSDLUtils.isNotBlank(objectName);
    String mainInstruction = hasObject ? RESOURCES.getString("dialogs.saveUnsavedChanges.mainInstruction", objectName) : RESOURCES.getString("dialogs.saveUnsavedChanges.mainInstruction.noObject");
    TaskPane pane = new // Routine confirmations have no icon.
    TaskPane(// Routine confirmations have no icon.
    MessageType.PLAIN, mainInstruction, CommandValue.SAVE, CommandValue.DONT_SAVE, CommandValue.CANCEL);
    pane.setPreferredWidth(PreferredWidth.LARGE);
    pane.showDialog(e, title);
    return pane.getCommitValue();
}
Also used : TaskPane(com.jgoodies.jsdl.core.pane.TaskPane)

Example 7 with TaskPane

use of com.jgoodies.jsdl.core.pane.TaskPane in project kindergarten by clear-group-ausbildung.

the class Dialogs method unsavedDocuments.

@SuppressWarnings({ "rawtypes", "unchecked" })
public static boolean unsavedDocuments(EventObject e) {
    String title = RESOURCES.getString("unsavedDocuments.title");
    String mainInstruction = RESOURCES.getString("unsavedDocuments.mainInstruction");
    List<?> unsavedDocuments = DesktopManager.INSTANCE.getUnsavedDocuments();
    JList list = new JList(new Vector(unsavedDocuments));
    list.setCellRenderer(new DocumentsCellRenderer());
    Object saveSelected = RESOURCES.getString("unsavedDocuments.saveSelected");
    Object discardSelected = RESOURCES.getString("unsavedDocuments.discardSelected");
    TaskPane pane = new TaskPane(mainInstruction, new JScrollPane(list), saveSelected, discardSelected, CommandValue.CANCEL);
    pane.setMarginContentTop(2);
    pane.setPreferredWidth(PreferredWidth.MEDIUM);
    pane.showDialog(e, title);
    if (pane.getCommitValue() == saveSelected) {
        MainModel.getInstance().saveDocuments(getSelectedDocuments(list));
    } else if (pane.getCommitValue() == discardSelected) {
        MainModel.getInstance().discardDocuments();
    }
    return pane.isCancelled();
}
Also used : JScrollPane(javax.swing.JScrollPane) EventObject(java.util.EventObject) TaskPane(com.jgoodies.jsdl.core.pane.TaskPane) Vector(java.util.Vector) JList(javax.swing.JList)

Example 8 with TaskPane

use of com.jgoodies.jsdl.core.pane.TaskPane in project kindergarten by clear-group-ausbildung.

the class Dialogs method vendorHasErrors.

// API ********************************************************************
/**
 * @return {@code true} if canceled, {@code false} otherwise
 */
public static boolean vendorHasErrors(EventObject e, ValidationResult result) {
    String title = "Fehler bei der Eingabepr\u00fcfung";
    String mainInstruction = "Es konnte aufgrund folgender Fehler nicht gespeichert werden:";
    StringBuilder contentTextBuilder = new StringBuilder("<html>");
    contentTextBuilder.append(result.getMessages().stream().map(ValidationMessage::formattedText).collect(Collectors.joining("<br>")));
    // ich kann den Punkt nur hier entfernen deswegen habe ich noch in
    // VendorValidatable den PROPERTY String separat entfernt
    String contentText = contentTextBuilder.toString().replace('.', ' ').trim();
    TaskPane pane = new TaskPane(MessageType.ERROR, mainInstruction, contentText, CommandValue.CANCEL);
    pane.setPreferredWidth(400);
    pane.showDialog(e, title);
    return pane.isCancelled();
}
Also used : ValidationMessage(com.jgoodies.validation.ValidationMessage) TaskPane(com.jgoodies.jsdl.core.pane.TaskPane)

Example 9 with TaskPane

use of com.jgoodies.jsdl.core.pane.TaskPane in project kindergarten by clear-group-ausbildung.

the class Dialogs method about.

public static void about(EventObject e) {
    String title = RESOURCES.getString("dialogs.about.title");
    String mainInstruction = RESOURCES.getString("application.name") + " " + RESOURCES.getString("application.version");
    String contentText = RESOURCES.getString("dialogs.about.content", RESOURCES.getString("application.copyright"), RESOURCES.getString("application.buildNo"), RESOURCES.getDate("application.buildDate"));
    TaskPane pane = new TaskPane(RESOURCES.getIcon("application.logo"), mainInstruction, contentText, CommandValue.CLOSE);
    pane.setMarginContentTop(4);
    pane.setMarginContentBottom(14);
    pane.showDialog(e, title);
}
Also used : TaskPane(com.jgoodies.jsdl.core.pane.TaskPane)

Aggregations

TaskPane (com.jgoodies.jsdl.core.pane.TaskPane)9 Action (com.jgoodies.application.Action)3 PurchaseBean (de.clearit.kindergarten.domain.PurchaseBean)2 ValidationMessage (com.jgoodies.validation.ValidationMessage)1 VendorBean (de.clearit.kindergarten.domain.VendorBean)1 EventObject (java.util.EventObject)1 Vector (java.util.Vector)1 JList (javax.swing.JList)1 JScrollPane (javax.swing.JScrollPane)1