/** * 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); }
/** * Translate return codes from sheet selection * * @param sender Button pressed * @return Sheet callback constant * @see SheetCallback#DEFAULT_OPTION * @see SheetCallback#CANCEL_OPTION */ public int getOption(final NSButton sender) { return this.getOption(sender.tag()); }
@Override public void cleanup() { for(ThirdpartyBookmarkCollection t : collections) { t.filter(bookmarks); if(t.isEmpty()) { preferences.setProperty(t.getConfiguration(), true); continue; } final NSAlert alert = NSAlert.alert( MessageFormat.format(LocaleFactory.localizedString("Import {0} Bookmarks", "Configuration"), t.getName()), MessageFormat.format(LocaleFactory.localizedString("{0} bookmarks found. Do you want to add these to your bookmarks?", "Configuration"), t.size()), LocaleFactory.localizedString("Import", "Configuration"), //default null, //other LocaleFactory.localizedString("Cancel", "Configuration")); alert.setShowsSuppressionButton(true); alert.suppressionButton().setTitle(LocaleFactory.localizedString("Don't ask again", "Configuration")); alert.setAlertStyle(NSAlert.NSInformationalAlertStyle); int choice = new AlertSheetReturnCodeMapper().getOption(alert.runModal()); //alternate if(alert.suppressionButton().state() == NSCell.NSOnState) { // Never show again. preferences.setProperty(t.getConfiguration(), true); } if(choice == SheetCallback.DEFAULT_OPTION) { bookmarks.addAll(t); // Flag as imported preferences.setProperty(t.getConfiguration(), true); } } } }
); alert.setAlertStyle(NSAlert.NSInformationalAlertStyle); if(new AlertSheetReturnCodeMapper().getOption(alert.runModal()) == SheetCallback.DEFAULT_OPTION) { for(BrowserController c : MainController.getBrowsers()) { c.removeDonateWindowTitle();
alert.setShowsSuppressionButton(true); alert.suppressionButton().setTitle(LocaleFactory.localizedString("Don't ask again", "Configuration")); int choice = new AlertSheetReturnCodeMapper().getOption(alert.runModal()); if(alert.suppressionButton().state() == NSCell.NSOnState) {
alert.setShowsSuppressionButton(true); alert.suppressionButton().setTitle(LocaleFactory.localizedString("Don't ask again", "Configuration")); int choice = new AlertSheetReturnCodeMapper().getOption(alert.runModal()); if(alert.suppressionButton().state() == NSCell.NSOnState) {