Example usage for javax.swing JOptionPane QUESTION_MESSAGE

List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane QUESTION_MESSAGE.

Prototype

int QUESTION_MESSAGE

To view the source code for javax.swing JOptionPane QUESTION_MESSAGE.

Click Source Link

Document

Used for questions.

Usage

From source file:org.fhaes.FHRecorder.FireHistoryRecorder.java

/**
 * Closes the dialog but only after running necessary checks
 * to ensure user doesn't inadvertently loose data 
 * /*w  w  w. j a v a  2 s  .c  om*/
 */
private void closeAfterRunningChecks() {
    if (Controller.isModified()) {
        Object[] options = { "Save", "Close without saving", "Cancel" };
        int n = JOptionPane.showOptionDialog(Controller.thePrimaryWindow,
                "Save changes to file before closing?", "Confirm", JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, options, options[2]);

        if (n == JOptionPane.YES_OPTION) {
            Controller.save();
            setVisible(false);
        } else if (n == JOptionPane.NO_OPTION) {
            Controller.setIsModified(false);
            Controller.setIsChangedSinceOpened(false);
            setVisible(false);
        } else if (n == JOptionPane.CANCEL_OPTION) {
            return;
        }

    }

    setVisible(false);
}

From source file:gdt.jgui.entity.procedure.JProcedurePanel.java

/**
 * Get the context menu.// w  ww  .j  a  v  a 2 s  . c  o  m
 * @return the context menu.
 */
@Override
public JMenu getContextMenu() {
    menu = new JMenu("Context");
    menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            menu.removeAll();
            JMenuItem runItem = new JMenuItem("Run");
            runItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    run();
                }
            });
            menu.add(runItem);
            Entigrator entigrator = console.getEntigrator(entihome$);
            Sack procedure = entigrator.getEntityAtKey(entityKey$);
            if (procedure.getElementItem("parameter", "noreset") == null) {
                JMenuItem resetItem = new JMenuItem("Reset");
                resetItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        int response = JOptionPane.showConfirmDialog(console.getContentPanel(),
                                "Reset source to default ?", "Confirm", JOptionPane.YES_NO_OPTION,
                                JOptionPane.QUESTION_MESSAGE);
                        if (response == JOptionPane.YES_OPTION)
                            reset();
                    }
                });
                menu.add(resetItem);
            }
            JMenuItem folderItem = new JMenuItem("Open folder");
            folderItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        File file = new File(entihome$ + "/" + entityKey$);
                        Desktop.getDesktop().open(file);
                    } catch (Exception ee) {
                        Logger.getLogger(getClass().getName()).info(ee.toString());
                    }
                }
            });
            menu.add(folderItem);
            try {
                //Entigrator entigrator=console.getEntigrator(entihome$);
                Sack entity = entigrator.getEntityAtKey(entityKey$);
                String template$ = entity.getAttributeAt("template");
                if (template$ != null) {
                    JMenuItem adaptClone = new JMenuItem("Adapt clone");
                    adaptClone.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            try {
                                adaptClone(console, getLocator());
                            } catch (Exception ee) {
                                Logger.getLogger(getClass().getName()).info(ee.toString());
                            }
                        }
                    });
                    menu.add(adaptClone);
                }
            } catch (Exception ee) {
                Logger.getLogger(getClass().getName()).info(ee.toString());
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    return menu;
}

From source file:com.sshtools.appframework.ui.SshToolsApplicationFrame.java

/**
 * @param application//  w w  w  . j a v a 2s .  c  om
 * @param panel
 * 
 * @throws SshToolsApplicationException
 */

public void init(final SshToolsApplication application, SshToolsApplicationPanel panel)
        throws SshToolsApplicationException {
    log.debug("Initialising frame");
    this.panel = panel;
    this.application = application;
    if (application != null) {
        setTitle(application.getApplicationName() + " - " + application.getApplicationVersion());
    }
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    // Register the File menu
    panel.registerActionMenu(new ActionMenu("File", "File", 'f', 0));
    // Register the Exit action
    if (showExitAction && application != null) {
        panel.registerAction(exitAction = new ExitAction(application, this));
        // Register the New Window Action
    }
    if (showNewWindowAction && application != null) {
        panel.registerAction(newWindowAction = new NewWindowAction(application));
        // Register the Help menu
    }
    panel.registerActionMenu(new ActionMenu("Help", "Help", 'h', 99));
    // Register the About box action
    if (showAboutBox && application != null) {
        panel.registerAction(aboutAction = new AboutAction(this, application));
    }

    getApplicationPanel().rebuildActionComponents();
    // JPanel p = new JPanel(new ToolBarLayout());
    JPanel p = new JPanel(new BorderLayout(0, 0));
    JPanel center = new JPanel(new BorderLayout(0, 0));
    if (panel.getJMenuBar() != null) {
        setJMenuBar(panel.getJMenuBar());
    }

    if (panel.getToolBar() != null) {
        // center.add(toolSeparator = new JSeparator(JSeparator.HORIZONTAL),
        // BorderLayout.NORTH);
        // toolSeparator.setVisible(panel.getToolBar().isVisible());
        // panel.getToolBar().addComponentListener(new ComponentAdapter() {
        // public void componentShown(ComponentEvent e) {
        // toolSeparator.setVisible(SshToolsApplicationFrame.this.panel.getToolBar().isVisible());
        // }
        //
        // public void componentHidden(ComponentEvent e) {
        // toolSeparator.setVisible(SshToolsApplicationFrame.this.panel.getToolBar().isVisible());
        // }
        //
        // });
        final SshToolsApplicationPanel pnl = panel;
        panel.getToolBar().addComponentListener(new ComponentAdapter() {

            public void componentHidden(ComponentEvent evt) {
                // toolSeparator.setVisible(pnl.getToolBar().isVisible());

            }

        });
        p.add(panel.getToolBar(), BorderLayout.NORTH);
    }
    center.add(panel, BorderLayout.CENTER);
    p.add(center, BorderLayout.CENTER);
    getContentPane().setLayout(new GridLayout(1, 1, 0, 0));
    getContentPane().add(p);
    // Watch for the frame closing
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent evt) {
            if (application != null) {
                application.closeContainer(SshToolsApplicationFrame.this);
            } else {
                int confirm = JOptionPane.showOptionDialog(SshToolsApplicationFrame.this,
                        "Close " + getTitle() + "?", "Close Operation", JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE, null, null, null);
                if (confirm == 0) {
                    hide();
                }
            }

        }

    });
    // If this is the first frame, center the window on the screen
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    boolean found = false;
    if (application != null && application.getContainerCount() != 0) {
        for (int i = 0; (i < application.getContainerCount()) && !found; i++) {
            SshToolsApplicationContainer c = application.getContainerAt(i);
            if (c instanceof SshToolsApplicationFrame) {
                SshToolsApplicationFrame f = (SshToolsApplicationFrame) c;
                setSize(f.getSize());
                Point newLocation = new Point(f.getX(), f.getY());
                newLocation.x += 48;
                newLocation.y += 48;
                if (newLocation.x > (screenSize.getWidth() - 64)) {
                    newLocation.x = 0;
                }
                if (newLocation.y > (screenSize.getHeight() - 64)) {
                    newLocation.y = 0;
                }
                setLocation(newLocation);
                found = true;
            }
        }
    }
    if (!found) {
        // Is there a previous stored geometry we can use?
        if (PreferencesStore.preferenceExists(PREF_LAST_FRAME_GEOMETRY)) {
            setBounds(PreferencesStore.getRectangle(PREF_LAST_FRAME_GEOMETRY, getBounds()));
        } else {
            pack();
            setSize(800, 600);
            UIUtil.positionComponent(SwingConstants.CENTER, this);
        }
    }
    log.debug("Initialisation of frame complete");
}

From source file:net.atomique.ksar.ui.GraphView.java

private String askSaveFilename(String title, File chdirto) {
    String filename = null;//from   ww  w .  java  2  s  .co m
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(title);
    if (chdirto != null) {
        chooser.setCurrentDirectory(chdirto);
    }
    int returnVal = chooser.showSaveDialog(GlobalOptions.getUI());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        filename = chooser.getSelectedFile().getAbsolutePath();
    }

    if (filename == null) {
        return null;
    }

    if (new File(filename).exists()) {
        String[] choix = { "Yes", "No" };
        int resultat = JOptionPane.showOptionDialog(null, "Overwrite " + filename + " ?", "File Exist",
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, choix, choix[1]);
        if (resultat != 0) {
            return null;
        }
    }
    return filename;
}

From source file:com.willwinder.universalgcodesender.utils.FirmwareUtils.java

/**
 * Copy any missing files from the the jar's resources/firmware_config/ dir
 * into the settings/firmware_config dir.
 */// w ww  . jav a 2s .c o m
public synchronized static void initialize() {
    System.out.println("Initializing firmware... ...");
    File firmwareConfig = new File(SettingsFactory.getSettingsDirectory(), FIRMWARE_CONFIG_DIRNAME);

    // Create directory if it's missing.
    if (!firmwareConfig.exists()) {
        firmwareConfig.mkdirs();
    }

    FileSystem fileSystem = null;

    // Copy firmware config files.
    try {
        final String dir = "/resources/firmware_config/";

        URI location = FirmwareUtils.class.getResource(dir).toURI();

        Path myPath;
        if (location.getScheme().equals("jar")) {
            try {
                // In case the filesystem already exists.
                fileSystem = FileSystems.getFileSystem(location);
            } catch (FileSystemNotFoundException e) {
                // Otherwise create the new filesystem.
                fileSystem = FileSystems.newFileSystem(location, Collections.<String, String>emptyMap());
            }

            myPath = fileSystem.getPath(dir);
        } else {
            myPath = Paths.get(location);
        }

        Stream<Path> files = Files.walk(myPath, 1);
        for (Path path : (Iterable<Path>) () -> files.iterator()) {
            System.out.println(path);
            final String name = path.getFileName().toString();
            File fwConfig = new File(firmwareConfig, name);
            if (name.endsWith(".json")) {
                boolean copyFile = !fwConfig.exists();
                ControllerSettings jarSetting = getSettingsForStream(Files.newInputStream(path));

                // If the file is outdated... ask the user (once).
                if (fwConfig.exists()) {
                    ControllerSettings current = getSettingsForStream(new FileInputStream(fwConfig));
                    boolean outOfDate = current.getVersion() < jarSetting.getVersion();
                    if (outOfDate && !userNotified && !overwriteOldFiles) {
                        int result = NarrowOptionPane.showNarrowConfirmDialog(200,
                                Localization.getString("settings.file.outOfDate.message"),
                                Localization.getString("settings.file.outOfDate.title"),
                                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                        overwriteOldFiles = result == JOptionPane.OK_OPTION;
                        userNotified = true;
                    }

                    if (overwriteOldFiles) {
                        copyFile = true;
                        jarSetting.getProcessorConfigs().Custom = current.getProcessorConfigs().Custom;
                    }
                }

                // Copy file from jar to firmware_config directory.
                if (copyFile) {
                    try {
                        save(fwConfig, jarSetting);
                    } catch (IOException ex) {
                        logger.log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    } catch (Exception ex) {
        String errorMessage = String.format("%s %s", Localization.getString("settings.file.generalError"),
                ex.getLocalizedMessage());
        GUIHelpers.displayErrorDialog(errorMessage);
        logger.log(Level.SEVERE, errorMessage, ex);
    } finally {
        if (fileSystem != null) {
            try {
                fileSystem.close();
            } catch (IOException ex) {
                logger.log(Level.SEVERE, "Problem closing filesystem.", ex);
            }
        }
    }

    configFiles.clear();
    for (File f : firmwareConfig.listFiles()) {
        try {
            ControllerSettings config = new Gson().fromJson(new FileReader(f), ControllerSettings.class);
            //ConfigLoader config = new ConfigLoader(f);
            configFiles.put(config.getName(), new ConfigTuple(config, f));
        } catch (FileNotFoundException | JsonSyntaxException | JsonIOException ex) {
            GUIHelpers.displayErrorDialog("Unable to load configuration files: " + f.getAbsolutePath());
        }
    }
}

From source file:com.sshtools.common.ui.SshToolsApplicationFrame.java

/**
 *
 *
 * @param application//from  w ww. j a  v a 2s . c  o m
 * @param panel
 *
 * @throws SshToolsApplicationException
 */
public void init(final SshToolsApplication application, SshToolsApplicationPanel panel)
        throws SshToolsApplicationException {
    this.panel = panel;
    this.application = application;

    if (application != null) {
        setTitle(ConfigurationLoader.getVersionString(application.getApplicationName(),
                application.getApplicationVersion())); // + " " + application.getApplicationVersion());
    }

    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    // Register the File menu
    panel.registerActionMenu(new SshToolsApplicationPanel.ActionMenu("File", "File", 'f', 0));
    // Register the Exit action
    if (showExitAction && application != null) {
        panel.registerAction(exitAction = new ExitAction(application, this));

        // Register the New Window Action
    }
    if (showNewWindowAction && application != null) {
        panel.registerAction(newWindowAction = new NewWindowAction(application));

        // Register the Help menu
    }
    panel.registerActionMenu(new SshToolsApplicationPanel.ActionMenu("Help", "Help", 'h', 99));

    // Register the About box action
    if (showAboutBox && application != null) {
        panel.registerAction(aboutAction = new AboutAction(this, application));

    }

    // Register the Changelog box action
    if (showChangelogBox && application != null) {
        panel.registerAction(changelogAction = new ChangelogAction(this, application));

    }
    panel.registerAction(faqAction = new FAQAction());
    panel.registerAction(beginnerAction = new BeginnerAction());
    panel.registerAction(advancedAction = new AdvancedAction());

    getApplicationPanel().rebuildActionComponents();

    JPanel p = new JPanel(new BorderLayout());

    if (panel.getJMenuBar() != null) {
        setJMenuBar(panel.getJMenuBar());
    }

    if (panel.getToolBar() != null) {
        JPanel t = new JPanel(new BorderLayout());
        t.add(panel.getToolBar(), BorderLayout.NORTH);
        t.add(toolSeparator = new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH);
        toolSeparator.setVisible(panel.getToolBar().isVisible());

        final SshToolsApplicationPanel pnl = panel;
        panel.getToolBar().addComponentListener(new ComponentAdapter() {
            public void componentHidden(ComponentEvent evt) {
                log.debug("Tool separator is now " + pnl.getToolBar().isVisible());
                toolSeparator.setVisible(pnl.getToolBar().isVisible());
            }
        });
        p.add(t, BorderLayout.NORTH);
    }

    p.add(panel, BorderLayout.CENTER);

    if (panel.getStatusBar() != null) {
        p.add(panel.getStatusBar(), BorderLayout.SOUTH);
    }

    getContentPane().setLayout(new GridLayout(1, 1));
    getContentPane().add(p);

    // Watch for the frame closing
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            if (application != null) {
                application.closeContainer(SshToolsApplicationFrame.this);
            } else {
                int confirm = JOptionPane.showOptionDialog(SshToolsApplicationFrame.this,
                        "Close " + getTitle() + "?", "Close Operation", JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE, null, null, null);
                if (confirm == 0) {
                    hide();
                }

            }
        }
    });

    // If this is the first frame, center the window on the screen
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    boolean found = false;

    if (application != null && application.getContainerCount() != 0) {
        for (int i = 0; (i < application.getContainerCount()) && !found; i++) {
            SshToolsApplicationContainer c = application.getContainerAt(i);

            if (c instanceof SshToolsApplicationFrame) {
                SshToolsApplicationFrame f = (SshToolsApplicationFrame) c;
                setSize(f.getSize());

                Point newLocation = new Point(f.getX(), f.getY());
                newLocation.x += 48;
                newLocation.y += 48;

                if (newLocation.x > (screenSize.getWidth() - 64)) {
                    newLocation.x = 0;
                }

                if (newLocation.y > (screenSize.getHeight() - 64)) {
                    newLocation.y = 0;
                }

                setLocation(newLocation);
                found = true;
            }
        }
    }

    if (!found) {
        // Is there a previous stored geometry we can use?
        if (PreferencesStore.preferenceExists(PREF_LAST_FRAME_GEOMETRY)) {
            setBounds(PreferencesStore.getRectangle(PREF_LAST_FRAME_GEOMETRY, getBounds()));
        } else {
            pack();
            UIUtil.positionComponent(SwingConstants.CENTER, this);
        }
    }
}

From source file:de.fhg.igd.mapviewer.server.file.FileTiler.java

/**
 * Load the command paths from the preferences or ask the user for them
 *///from   ww w .  j  av a2 s  . c  om
private void loadCommandPaths() {
    String convert = pref.get(PREF_CONVERT, null);
    String identify = pref.get(PREF_IDENTIFY, null);

    JFileChooser commandChooser = new JFileChooser();

    if (convert != null && identify != null) {
        if (JOptionPane.showConfirmDialog(null,
                "<html>Found paths to executables:<br/><b>" + convert + "<br/>" + identify
                        + "</b><br/>Do you want to use this settings?</html>",
                "Paths to executables", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
            convert = null;
            identify = null;
        }
    }

    if (convert == null) {
        // ask for convert path
        convert = askForPath(commandChooser, new ContainsFileFilter("convert"),
                "Please select your convert executable");
    }

    if (convert != null && identify == null) {
        // ask for identify path
        identify = askForPath(commandChooser, new ContainsFileFilter("identify"),
                "Please select your identify executable");
    }

    if (convert == null)
        pref.remove(PREF_CONVERT);
    else
        pref.put(PREF_CONVERT, convert);

    if (identify == null)
        pref.remove(PREF_IDENTIFY);
    else
        pref.put(PREF_IDENTIFY, identify);

    convertPath = convert;
    identifyPath = identify;
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.PubChemXMLCreatorGUI.java

public void actionPerformed(ActionEvent e) {
    try {/*from w w w .  j a v  a  2  s.  c  o  m*/
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (e.getSource() == jbnFileTemplate) {
            gc.fileChooser(jtfFileTemplate, ".xml", "open");
            jtfFileTemplate.setEnabled(true);
        } else if (e.getSource() == jbnFileExcel) {
            gc.fileChooser(jtfFileExcel, ".xlsx", "open");
        } else if (e.getSource() == jbnRunCreator) {
            String stringTemplate = jtfFileTemplate.getText();
            InputStream fileTemplate;
            if (stringTemplate.equals(template) | stringTemplate.equals("")) {
                URL url = getClass().getClassLoader().getResource("blank.xml");
                fileTemplate = url.openStream();
            } else
                fileTemplate = new FileInputStream(jtfFileTemplate.getText());
            File fileExcel = new File(jtfFileExcel.getText());
            File fileOutput = File.createTempFile("pubchem", ".xml");
            fileOutput.deleteOnExit();
            PubChemAssay assay = new PubChemXMLCreatorController().createPubChemXML(fileTemplate, fileExcel,
                    fileOutput);
            String message = assay.getMessage();
            if (!message.equals("")) {
                int nn = JOptionPane.showOptionDialog(this,
                        notError + message + "\nWould you like to edit your Excel Workbook?", SwingGUI.APP_NAME,
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
                if (nn == JOptionPane.YES_OPTION) {
                    log.info("Opening Excel Workbook with Desktop: " + fileExcel);
                    Desktop.getDesktop().open(fileExcel);
                } else {
                    log.info("Opening XML file: " + fileOutput);
                    Desktop.getDesktop().open(fileOutput);
                }
            } else {
                log.info("Opening XML file: " + fileOutput);
                Desktop.getDesktop().open(fileOutput);
            }
        } else if (e.getSource() == jbnReportCreator) {
            File fileExcel = new File(jtfFileExcel.getText());
            File filePDFOutput = File.createTempFile("PubChem_PDF_Report", ".pdf");
            File fileWordOutput = File.createTempFile("PubChem_Word_Report", ".docx");
            filePDFOutput.deleteOnExit();
            fileWordOutput.deleteOnExit();
            ArrayList<PubChemAssay> assay = new ReportController().createReport(pcDep, fileExcel, filePDFOutput,
                    fileWordOutput, isInternal);
            String message = null;
            for (PubChemAssay xx : assay) {
                message = xx.getMessage();
                if (!message.equals("")) {
                    int nn = JOptionPane.showOptionDialog(this,
                            notError + message + "\nWould you like to edit your Excel Workbook?",
                            SwingGUI.APP_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                            null, null);
                    if (nn == JOptionPane.YES_OPTION) {
                        log.info("Opening Excel Workbook with Desktop: " + fileExcel);
                        Desktop.getDesktop().open(fileExcel);
                    } else {
                        gc.openPDF(isInternal, filePDFOutput, this);
                        Desktop.getDesktop().open(fileWordOutput);
                    }
                } else {
                    gc.openPDF(isInternal, filePDFOutput, this);
                    Desktop.getDesktop().open(fileWordOutput);
                }
            }
        }
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    } catch (Throwable throwable) {
        SwingGUI.handleError(this, throwable);
    }
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.PubChemXMLExtractorGUI.java

private URL templateForExcel() {
    URL template;//from   w w w . j a va  2 s . com
    int nn = JOptionPane.showOptionDialog(this,
            "If you are editing the Excel file, would you like a BAO categorized comments sheet included?",
            SwingGUI.APP_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    String resource = "ExcelTemplate";
    if (nn == JOptionPane.YES_OPTION)
        resource = resource + "_withBAO_EditingVersion";

    if (isInternal)
        resource = resource + "_Internal";

    log.info("Getting resource: " + resource);
    template = getClass().getClassLoader().getResource(resource + ".xlsx");

    return template;
}

From source file:net.sf.jabref.external.AutoSetExternalFileForEntries.java

@Override
public void run() {
    if (!goOn) {//from  www  . ja va2s.  co m
        panel.output(Localization.lang("No entries selected."));
        return;
    }
    panel.frame().setProgressBarValue(0);
    panel.frame().setProgressBarVisible(true);
    int weightAutoSet = 10; // autoSet takes 10 (?) times longer than checkExisting
    int progressBarMax = (autoSet ? weightAutoSet * sel.length : 0) + (checkExisting ? sel.length : 0);
    panel.frame().setProgressBarMaximum(progressBarMax);
    int progress = 0;
    entriesChanged = 0;
    int brokenLinks = 0;
    NamedCompound ce = new NamedCompound(Localization.lang("Autoset %0 field", fieldName));

    final OpenFileFilter off = Util.getFileFilterForField(fieldName);

    ExternalFilePanel extPan = new ExternalFilePanel(fieldName, panel.metaData(), null, null, off);
    TextField editor = new TextField(fieldName, "", false);

    // Find the default directory for this field type:
    String[] dirs = panel.metaData().getFileDirectory(fieldName);

    // First we try to autoset fields
    if (autoSet) {
        for (BibtexEntry aSel : sel) {
            progress += weightAutoSet;
            panel.frame().setProgressBarValue(progress);

            final String old = aSel.getField(fieldName);
            // Check if a extension is already set, and if so, if we are allowed to overwrite it:
            if (old != null && !old.equals("") && !overWriteAllowed) {
                continue;
            }
            extPan.setEntry(aSel, panel.getDatabase());
            editor.setText(old != null ? old : "");
            JabRefExecutorService.INSTANCE.executeAndWait(extPan.autoSetFile(fieldName, editor));
            // If something was found, entriesChanged it:
            if (!editor.getText().equals("") && !editor.getText().equals(old)) {
                // Store an undo edit:
                //System.out.println("Setting: "+sel[i].getCiteKey()+" "+editor.getText());
                ce.addEdit(new UndoableFieldChange(aSel, fieldName, old, editor.getText()));
                aSel.setField(fieldName, editor.getText());
                entriesChanged++;
            }
        }
    }
    //System.out.println("Done setting");
    // The following loop checks all external links that are already set.
    if (checkExisting) {
        mainLoop: for (BibtexEntry aSel : sel) {
            panel.frame().setProgressBarValue(progress++);
            final String old = aSel.getField(fieldName);
            // Check if a extension is set:
            if (old != null && !old.equals("")) {
                // Get an absolute path representation:
                File file = FileUtil.expandFilename(old, dirs);

                if (file == null || !file.exists()) {

                    int answer = JOptionPane.showOptionDialog(panel.frame(),
                            Localization.lang("<HTML>Could not find file '%0'<BR>linked from entry '%1'</HTML>",
                                    new String[] { old, aSel.getCiteKey() }),
                            Localization.lang("Broken link"), JOptionPane.YES_NO_CANCEL_OPTION,
                            JOptionPane.QUESTION_MESSAGE, null, brokenLinkOptions, brokenLinkOptions[0]);
                    switch (answer) {
                    case 1:
                        // Assign new file.
                        AttachFileDialog afd = new AttachFileDialog(panel.frame(), panel.metaData(), aSel,
                                fieldName);
                        Util.placeDialog(afd, panel.frame());
                        afd.setVisible(true);
                        if (!afd.cancelled()) {
                            ce.addEdit(new UndoableFieldChange(aSel, fieldName, old, afd.getValue()));
                            aSel.setField(fieldName, afd.getValue());
                            entriesChanged++;
                        }
                        break;
                    case 2:
                        // Clear field
                        ce.addEdit(new UndoableFieldChange(aSel, fieldName, old, null));
                        aSel.setField(fieldName, null);
                        entriesChanged++;
                        break;
                    case 3:
                        // Cancel
                        break mainLoop;
                    }
                    brokenLinks++;
                }

            }
        }
    }

    //log brokenLinks if some were found
    if (brokenLinks > 0) {
        log.warn(Localization.lang("Found %0 broken links", brokenLinks + ""));
    }

    if (entriesChanged > 0) {
        // Add the undo edit:
        ce.end();
        panel.undoManager.addEdit(ce);
    }
}