Skip to content
Pauta4.0.0

Confirm dialog

One question before anything the user made is removed, deleted, discarded or overwritten, asked the same way everywhere: the text names the thing and what happens to it, the confirming button is the action’s own verb in red, and Cancel is the way out. An action that can be taken back needs no question (see Window shell).

  • CONF-01 MUST Before anything the user made is removed, deleted, discarded or overwritten, the app asks first, unless the action can be taken back instead.
    • Check (code): each destructive action calls a confirmation before it changes anything, or records an undo.
    • Reference: Editora ui/CloseCoordinator.java (unsaved changes, Quit) and GitCoordinator.confirmDestructive; Torrenta ui/RemoveConfirm.java, which asks it for the torrent list, the RSS tab and every list in Settings.
  • CONF-02 MUST The question names the thing and what happens to it.
    • Check (code): every confirmation string names the thing, by an argument for its name or count or in its own words (“Quit Editora?”), and says what happens to it.
    • Reference: Editora dialog.unsaved.header, dialog.discard.tracked; Torrenta RemoveConfirm.question, Actions.removeQuestion.
  • CONF-03 MUST The confirming button carries the action’s own verb (Delete files, Remove, Discard, Quit), never OK or Yes, in the danger style.
    • Check (code): the action’s ButtonType is named from the catalog and its button gets the danger style class.
    • Reference: Editora GitCoordinator.confirmDestructive, MainController.styleUnsavedChangesButtons, styleQuitButtonAsDanger; Torrenta RemoveConfirm.ask.
  • CONF-04 MUST Cancel is the way out: Escape and the window’s close button both answer Cancel, and nothing is lost on a dismissal.
    • Check (code): Cancel has the CANCEL_CLOSE role, and the result defaults to Cancel when the dialog closes any other way (showAndWait().orElse(cancel)).
    • Reference: Editora GitCoordinator.confirmDestructive, CloseCoordinator.unsavedAlert; Torrenta RemoveConfirm.ask.
  1. 1Window title: the header's words again ("Remove feed", "Unsaved changes"). A plain confirmation, no icon in the title and no app name.
  2. 2Header, when the question is long enough to need one. Editora's Git confirmations set none and put the whole message in the content; Torrenta's header names the action and the content asks the question.
  3. 3The question names the thing and the consequence. How many ("these 3 torrents", a {0,choice,…} plural), which one ("the feed “Linux ISOs” and its articles"), what stays ("The downloaded files stay on disk."), and "This cannot be undone." only when it is true. Termina's multi-line paste shows the text itself in an expandable area, so the decision is made on what will be sent.
  4. 4The action button carries the action's verb (Delete files, Remove, Discard, Quit, Close), never OK or Yes, and the danger style: red, not the accent. It is the dialog's one colored button.
  5. 5Cancel, in the catalog's word, with the CANCEL_CLOSE role: Escape and the window's close button both answer Cancel.
Unsaved changes
Save changes to Main.java before closing?
SaveDiscardCancel
Remove, files kept
Remove this torrent? The downloaded files stay on disk.
CancelRemove
A program is running
Close this tab? bash (top) is still running. Closing will end it.
CancelClose
Undo instead of a question
Undo Removed Ubuntu ISOC-z
  • CONF-05 SHOULD When saving is an option the question has three answers, in this order: Save (the success style, green), Discard (danger) and Cancel. A Save that fails leaves the tab open.
    • Check (code): the unsaved-changes alert sets Save, Discard and Cancel in that order and styles the first two.
    • Reference: Editora CloseCoordinator.unsavedAlert, MainController.styleUnsavedChangesButtons.
  • CONF-06 SHOULD A question about ending a running program, which is not the user’s data, words the button Close and makes Cancel the default button, so dismissing the dialog by any route keeps the program alive.
    • Check (code): the close-running-program alert calls setDefaultButton(true) on Cancel.
    • Reference: Termina ui/TerminalWindow.java (dialog.closeAnyway).
  • CONF-07 SHOULD Where the action can be taken back, the app asks nothing and offers Undo instead.
    • Check (by hand): close a clean tab and reopen it with Reopen Closed Tab; in Mirada, trash an image and undo.
    • Reference: Mirada moves an image to the trash at once and offers Undo; Torrenta asks before removing a torrent but also keeps the removal on its undo stack for ten minutes (UndoStack.KEEP_MS); Editora ClosedTabs.
PropertyValueReference
KindAlert(CONFIRMATION) owned by the window (initOwner), shown with showAndWait; the answer defaults to Cancel when the dialog is closed any other wayGitCoordinator.confirmDestructive, RemoveConfirm.ask
ButtonsA ButtonType with the action’s name and the OK_DONE role, and Cancel with CANCEL_CLOSE from the catalog, never JavaFX’s stock OK and Cancel, which are worded in the JVM’s localeRemoveConfirm.ask, Torrenta’s StockButtons
Action buttondanger style class: the theme’s .button.danger fills it -color-danger-emphasis with emphasis text. Save in the unsaved question: successMainController.styleUnsavedChangesButtons, styleQuitButtonAsDanger
Default buttonThe action, where it has the OK_DONE role (Editora’s Git confirmations, Torrenta’s Remove): Enter runs it, and red is what says so. Editora’s unsaved-changes and Quit questions give their buttons no role, so Enter does nothing. Termina’s close-running-program question makes Cancel the defaultconfirmDestructive, CloseCoordinator.unsavedAlert, Termina TerminalWindow
FontThe UI font sheet attached to the dialog pane, because a dialog is its own scene and inherits nothing from the windowTorrenta Fonts.installUiFont(DialogPane), Editora App.installUiFont (every window)
StylesheetDialogs.styled adds app.css to a dialog that needs the app’s own rules (About); the -color-* tokens and .button.danger resolve from the theme either wayDialogs
TextThe question in the content; a header only when the question needs a name over it. Counts as plurals, names in quotes, the consequence spelled outActions.removeQuestion, confirm.remove.<kind>
StringsOne key per kind, header and question both, tested to exist for every kindRemoveConfirm.Kind, RemoveConfirmTest
  • CONF-08 SHOULD The question comes before anything changes, and the action runs only on the action button.
    • Check (code): the helper returns true on the action button alone, and the caller acts only on true.
    • Reference: Torrenta RemoveConfirm.ask; Editora GitCoordinator.confirmDestructive.
  • CONF-09 SHOULD One gesture asks one question. An action on many things asks once with the count (“Remove these 3 torrents?”, Torrenta’s “Apply to many torrents” for a bulk command). Closing every tab asks per unsaved buffer, selecting each tab first so the user sees what the question is about, and remembers a Discard answer for exactly the state that was shown.
    • Check (code): a bulk command builds one question with a plural count; the close-all sweep selects each tab before it asks.
    • Reference: Torrenta Actions.removeQuestion; Editora CloseCoordinator.confirmSweep.
  • CONF-10 SHOULD A delete that cannot be undone says so; one that leaves the files says that instead.
    • Check (code): “This cannot be undone.” appears only in the strings of actions that cannot be undone.
    • Reference: Editora dialog.discard.tracked; Torrenta actions.removeQuestion.delete.
  • CONF-11 SHOULD A dangerous alternative (Force with Lease, Delete Anyway) is offered beside the safe one (Pull, then Push), in red, and only once the safe one has failed.
    • Check (code): the force path is reached only from the safe command’s failure result.
    • Reference: Editora GitBranchCoordinator.offerAfterRejection (Force with Lease after a rejected push), confirmForceDelete (Delete Anyway after NOT_FULLY_MERGED).
  • CONF-12 SHOULD The question can be tested without a screen: its words come from pure code, and a capture hook answers the dialog, so a UI test never presses a native button.
    • Check (test): a unit test covers the header and question for every kind, and UI tests set the capture answer.
    • Reference: Torrenta RemoveConfirm.header, question, answerForCapture; RemoveConfirmTest.
KeyEnglish
dialog.unsaved.title / dialog.unsaved.headerUnsaved changes / Save changes to {0} before closing?
dialog.save / dialog.discard / dialog.cancelSave / Discard / Cancel
dialog.quit.header / dialog.quit.buttonQuit Editora? / Quit
dialog.discard.trackedDiscard all changes to “{0}”? This cannot be undone.
dialog.discardAll.actionDiscard All
dialog.deleteBranch.forceDelete Anyway
confirm.remove.feed.header / confirm.remove.feedRemove feed / Remove the feed “{0}” and its articles? The torrents already added stay.
actions.removeQuestion.deleteRemove this torrent and delete the downloaded files? This cannot be undone.
window.remove.button.delete / common.remove / common.cancelDelete files / Remove / Cancel
dialog.closeRunning / dialog.closeAnyway (Termina)Close this tab? / Close

Editora asks for unsaved changes, Quit with busy terminals, pinned tabs, Git discards and branch deletions, and Local History purges, all through Alert with named buttons. Torrenta’s RemoveConfirm serves the torrent list, feeds, rules, watched folders, search providers, engine profiles, categories, tags and saved views with one shape. Termina asks before closing a tab with a running program and before a multi-line paste. Mirada and Modula ask nothing: Mirada’s trash is undoable, and Modula’s preset chips remove on one click, which this template says they should not.

Pauta 4.0.0 · · Changelog · This page in the latest edition