/** * This must be the target action for any button in the sheet dialog. Will validate the input * and close the sheet; #sheetDidClose will be called afterwards * * @param sender A button in the sheet dialog */ @Action public void closeSheet(final NSButton sender) { if(log.isDebugEnabled()) { log.debug(String.format("Close sheet with button %s", sender.title())); } final int option = new AlertSheetReturnCodeMapper().getOption(sender); if(option == SheetCallback.DEFAULT_OPTION || option == SheetCallback.ALTERNATE_OPTION) { window.endEditingFor(null); if(!this.validate()) { AppKitFunctionsLibrary.beep(); return; } } callback.callback(option); application.endSheet(window, option); }