Example usage for javax.swing JOptionPane NO_OPTION

List of usage examples for javax.swing JOptionPane NO_OPTION

Introduction

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

Prototype

int NO_OPTION

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

Click Source Link

Document

Return value from class method if NO is chosen.

Usage

From source file:storybook.action.ActionHandler.java

public void handleText2Html() {
    int n = SwingUtil.showBetaDialog(mainFrame);
    if (n == JOptionPane.NO_OPTION || n == JOptionPane.CLOSED_OPTION) {
        return;/*from  ww w. j  a va  2 s.  c o  m*/
    }
    mainFrame.setWaitingCursor();
    EntityUtil.convertPlainTextToHtml(mainFrame);
    mainFrame.refresh();
    mainFrame.setDefaultCursor();
}

From source file:storybook.action.ActionHandler.java

public void handleHtml2Text() {
    int n = SwingUtil.showBetaDialog(mainFrame);
    if (n == JOptionPane.NO_OPTION || n == JOptionPane.CLOSED_OPTION) {
        return;/*from   w  w w. j a v a  2 s  . c  o m*/
    }
    mainFrame.setWaitingCursor();
    EntityUtil.convertHtmlToPlainText(mainFrame);
    mainFrame.refresh();
    mainFrame.setDefaultCursor();
}

From source file:storybook.model.oldModel.ModelMigration.java

public boolean checkAndAlterModel() throws Exception {
    oldDbVersion = InternalPeer.getDbModelVersion();
    if (oldDbVersion == null) {
        return true;
    }//from   ww w .  j a v  a2  s .com
    newDbVersion = SbConstants.Storybook.DB_VERSION.toString();

    if (oldDbVersion.equals(newDbVersion)) {
        // model matches, nothing to do
        return true;
    }

    // alter models
    stmt = ModelMigration.getInstance().getConnection().createStatement();
    // old versions
    if (oldDbVersion.equals("0") || oldDbVersion.equals("0.1") || oldDbVersion.equals("0.1")
            || oldDbVersion.equals("0.2") || oldDbVersion.equals("0.3") || oldDbVersion.equals("0.4")
            || oldDbVersion.equals("0.5") || oldDbVersion.equals("0.6") || oldDbVersion.equals("0.7")
            || oldDbVersion.equals("0.8") || oldDbVersion.equals("0.9") || oldDbVersion.equals("1.0")
            || oldDbVersion.equals("1.1") || oldDbVersion.equals("1.2") || oldDbVersion.equals("1.3")
            || oldDbVersion.equals("1.4")) {
        throw new Exception("File version too old. Update to the latest version of Storybook 3 first.");
    }

    // backup current file
    String fn = FilenameUtils.removeExtension(file.getAbsolutePath());
    fn = fn + ".bak";
    File backupFile = new File(fn);
    try {
        if (backupFile.exists()) {
            backupFile.delete();
        }
        FileUtils.copyFile(file, backupFile);
    } catch (IOException e1) {
        int n = JOptionPane.showConfirmDialog(mainFrame,
                I18N.getMsg("msg.migration.error.backup") + "\n" + backupFile.getAbsolutePath() + "\n"
                        + I18N.getMsg("msg.migration.wanttocontinue"),
                "Backup failed", JOptionPane.YES_NO_OPTION);
        if (n == JOptionPane.NO_OPTION || n == JOptionPane.CLOSED_OPTION) {
            return false;
        }
    }

    if (oldDbVersion.equals("1.5")) {
        // 1.5 -> 4.0
        alterFrom1_5to4_0();
    }

    return true;
}

From source file:storybook.SbApp.java

public void exit() {
    trace("SbApp.exit()");
    if (mainFrames.size() > 0) {
        Preference pref = PrefUtil.get(PreferenceKey.CONFIRM_EXIT, true);
        if (pref.getBooleanValue()) {
            int n = JOptionPane.showConfirmDialog(null, I18N.getMsg("msg.mainframe.want.exit"),
                    I18N.getMsg("msg.common.exit"), JOptionPane.YES_NO_OPTION);
            if (n == JOptionPane.NO_OPTION || n == JOptionPane.CLOSED_OPTION) {
                return;
            }/*from w  w w .  j a v  a2  s .c  o m*/
        }
        saveAll();
    }
    System.exit(0);
}

From source file:studio.core.EntryPoint.java

public static void main(final String[] args) {
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));

    if (System.getProperty("mrj.version") != null) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        //     System.setProperty("apple.awt.brushMetalLook", "true");
        System.setProperty("apple.awt.showGrowBox", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Studio for kdb+");
        System.setProperty("com.apple.mrj.application.live-resize", "true");
        System.setProperty("com.apple.macos.smallTabs", "true");
        System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
    }// w  w  w.j  a  v a2s.co m

    if (Config.getInstance().getLookAndFeel() != null) {
        try {
            UIManager.setLookAndFeel(Config.getInstance().getLookAndFeel());
        } catch (Exception ex) {
            // go on with default one
            ex.printStackTrace();
        }
    }
    final CommandLineParser cmdLineGnuParser = new GnuParser();
    try {
        CommandLine commandLine = cmdLineGnuParser.parse(constructGnuOptions(), args);
        if (commandLine.hasOption("servers")) {
            String fileName = commandLine.getOptionValue("servers");
            Config.getInstance().loadFromFile(fileName);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    studio.ui.I18n.setLocale(Locale.getDefault());

    //   studio.ui.I18n.setLocale(new Locale("zh", "cn"));

    if (!Config.getInstance().getAcceptedLicense()) {
        LicensePanel panel = new LicensePanel();
        Object[] options = new String[] { "Accept", "Do Not Accept" };
        int answer = JOptionPane.showOptionDialog(null, panel, "Studio for kdb+", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE, Studio.getImage(Config.imageBase + "32x32/question.png"), //do not use a custom Icon
                options, //the titles of buttons
                options[1]); //default button title

        if (answer == JOptionPane.NO_OPTION)
            System.exit(0);

        Config.getInstance().setAcceptedLicense(Lm.buildDate);
    }

    UIManager.put("Table.font", new javax.swing.plaf.FontUIResource("Monospaced", Font.PLAIN,
            UIManager.getFont("Table.font").getSize()));
    System.setProperty("awt.useSystemAAFontSettings", "on");
    System.setProperty("swing.aatext", "true");

    ThreadGroup exceptionThreadGroup = new ExceptionGroup();

    new Thread(exceptionThreadGroup, "Init thread") {
        public void run() {
            Studio.init(args);
        }
    }.start();

}

From source file:su.fmi.photoshareclient.ui.PhotoViewDialog.java

private void SaveImageButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SaveImageButtonMouseClicked
    JFileChooser fileChooser = new JFileChooser() {
        // A warning for overweiting existing files
        @Override/*w w  w.j  a  va2s  .c om*/
        public void approveSelection() {
            File f = getSelectedFile();
            if (f.exists() && getDialogType() == SAVE_DIALOG) {
                int result = JOptionPane.showConfirmDialog(this, "The file exists, overwrite?", "Existing file",
                        JOptionPane.YES_NO_CANCEL_OPTION);
                switch (result) {
                case JOptionPane.YES_OPTION:
                    super.approveSelection();
                    return;
                case JOptionPane.NO_OPTION:
                    return;
                case JOptionPane.CLOSED_OPTION:
                    return;
                case JOptionPane.CANCEL_OPTION:
                    cancelSelection();
                    return;
                }
            }
            super.approveSelection();
        }
    };
    fileChooser.setDialogTitle("Save image as...");
    File rootVolume = File.listRoots()[0];
    fileChooser.setSelectedFile(new File(rootVolume.getAbsolutePath(), this.imageLabel.getFileName()));

    int userSelection = fileChooser.showSaveDialog(this);

    if (userSelection == JFileChooser.APPROVE_OPTION) {
        try {
            File fileToSave = fileChooser.getSelectedFile();
            BufferedImage bi = (BufferedImage) this.imageLabel.getImage();
            String ext = FilenameUtils.getExtension(fileToSave.getAbsolutePath());
            ImageIO.write(bi, ext, fileToSave);
        } catch (IOException ex) {
            Logger.getLogger(PhotoViewDialog.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:tauargus.gui.PanelTable.java

private void buttonCostActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCostActionPerformed
    int r = table.getSelectedRow();
    int c = table.getSelectedColumn();

    Cell cell = tableSet.getCell(createDimArray(r, c));
    while (true) {
        String value = JOptionPane.showInputDialog(this,
                "Set new cost for (" + doubleFormatter.format(cell.cost) + ")",
                doubleFormatter.format(cell.cost));
        if (value == null) {
            // the user canceled the input
            return;
        }//from w  w  w.  j a  va2 s.com
        try {
            Double newCost = Double.parseDouble(value);
            if (newCost > 0) {
                // the user entered correct input
                if (!tauArgus.SetTableCellCost(tableSet.index, createDimArray(r, c), newCost)) {
                    JOptionPane.showMessageDialog(this, "Unable to modify the cost");
                } else {
                    ((AbstractTableModel) table.getModel()).fireTableCellUpdated(r, c);
                    cell = getCell(r, c);
                    panelCellInformation.update(tableSet, cell, integerFormatter, doubleFormatter);
                }
                return;
            }
        } catch (NumberFormatException ex) {
            // incorrect input
        }
        // incorrect input
        if (JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(null,
                "Illegal value for cost function. Try again?", "Question", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE)) {
            break;
        }
    }
}

From source file:tauargus.gui.PanelTable.java

private boolean VraagMinTabVal(SuppressionMethod soort, TableSet table) {
    double[] xMax = new double[1];
    double xMin = tauArgus.GetMinimumCellValue(tableSet.index, xMax);

    double x = 0.0;
    if (xMin < 0) {
        if (soort == SuppressionMethod.OPTIMAL) {
            if (Application.isAnco()) {
                if (JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(this,
                        "Negative cell values found.\nOptimal is not guaranteed.\nTry the modular or the hypercube as an alternative.\nDo you want to continue?",
                        "Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) {
                    return false;
                }/*  w w w  . j  av  a 2 s . c  o  m*/
            } else {
                JOptionPane.showMessageDialog(this,
                        "Negative cell values found.\nOptimal is not possible.\nTry the modular or the hypercube as an alternative");
                return false;
            }
        }

        x = xMin * 1.5;
        boolean valid = false;
        while (!valid) {
            String input = JOptionPane.showInputDialog(this,
                    "Minimum lower bound for each cell\n(Smallest cell = " + xMin + ")", String.valueOf(x));
            if (input == null) {
                // cancel or close button is pressed
                return false;
            }
            try {
                x = Math.round(Double.parseDouble(input));
                if (x <= xMin) {
                    valid = true;
                }
            } catch (NumberFormatException ex) {
            }
            if (!valid) {
                if (JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(this,
                        "Illegal value for Minimum Table value", "Question", JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE)) {
                    x = xMin;
                    valid = true;
                } else {
                    if (x > 0) {
                        x = 0;
                    }
                }
            }
        }
    }
    // Is eigenlijk onzin !!!!!!!
    table.minTabVal = x;
    table.maxTabVal = 1.5 * xMax[0];
    return true;
}

From source file:tauargus.gui.PanelTable.java

private void buttonSuppressActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSuppressActionPerformed
    JFrame parentFrame = getParentFrame();
    SuppressionMethod Soort = SuppressionMethod.GHMITER;
    if (radioButtonHyperCube.isSelected())
        Soort = SuppressionMethod.GHMITER;
    if (radioButtonModular.isSelected())
        Soort = SuppressionMethod.HITAS;
    if (radioButtonOptimal.isSelected())
        Soort = SuppressionMethod.OPTIMAL;
    if (radioButtonMarginal.isSelected())
        Soort = SuppressionMethod.MARGINAL;
    if (radioButtonNetwork.isSelected())
        Soort = SuppressionMethod.NETWORK;
    if (radioButtonUwe.isSelected())
        Soort = SuppressionMethod.UWE;//  w  ww  .  j a  va2  s.com
    if (radioButtonCta.isSelected())
        Soort = SuppressionMethod.CTA;
    if (radioButtonRounding.isSelected())
        Soort = SuppressionMethod.ROUNDING;

    if (Soort.isAdditivityDesirable() && !tableSet.isAdditive) {
        if (JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(this,
                "Table is not additive. Optimisation routines might be tricky\nDo you want to proceed?",
                "Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) {
            return;
        }
    }

    if (Soort.isUsingSuppliedCostFunction()) {
        if (tableSet.costFunc == TableSet.COST_DIST && !Soort.canUseDistanceFunction()) {
            JOptionPane.showMessageDialog(null, "Distance function is not available for this solution");
            return;
        }
    }

    CellStatusStatistics statistics = tableSet.getCellStatusStatistics();
    if (statistics == null) {
        return; // TODO Show message
    }
    int totalUnsafeCells = statistics.totalPrimaryUnsafe();

    if (!Soort.isCosmetic()) {
        if (totalUnsafeCells == 0) {
            JOptionPane.showMessageDialog(this, "No unsafe cells found\nNo protection required");
            return;
        }
    }

    if (Soort == SuppressionMethod.OPTIMAL && totalUnsafeCells > 50) {
        if (JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(this,
                "This tabel contains " + totalUnsafeCells
                        + " unsafe cells\nthis might take a long time; do you want to proceed?",
                "Question", JOptionPane.YES_NO_OPTION)) {
            return;
        }
    }

    if (Soort.isMinMaxTableValueNeeded()) {
        if (!VraagMinTabVal(Soort, tableSet)) {
            return;
        }
    }

    switch (Soort) {
    case ROUNDING:
        if (Application.solverSelected == Application.SOLVER_CPLEX) {
            JOptionPane.showMessageDialog(null,
                    "Whether controlled rounding can be used when Cplex is selected as solver, depends on your specific license",
                    "", JOptionPane.ERROR_MESSAGE);
        }
        //else
        DialogRoundingParameters paramsR = new DialogRoundingParameters(parentFrame, true);
        if (paramsR.showDialog(tableSet) == DialogRoundingParameters.APPROVE_OPTION) {
            final SwingWorker<Integer, Void> worker = new ProgressSwingWorker<Integer, Void>(
                    ProgressSwingWorker.ROUNDER, "Rounding") {
                @Override
                protected Integer doInBackground() throws ArgusException, Exception {
                    super.doInBackground();
                    OptiSuppress.runRounder(tableSet, getPropertyChangeListener());
                    return null;
                }

                @Override
                protected void done() {
                    super.done();
                    try {
                        get();
                        JOptionPane.showMessageDialog(null,
                                "The table has been rounded\n" + "Number of steps: " + tableSet.roundMaxStep
                                        + "\n" + "Max step: "
                                        + StrUtils.formatDouble(tableSet.roundMaxJump,
                                                tableSet.respVar.nDecimals)
                                        + "\n" + "Processing time: "
                                        + StrUtils.timeToString(tableSet.processingTime));
                        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
                        adjustColumnWidths();
                        updateSuppressButtons();
                    } catch (InterruptedException ex) {
                        logger.log(Level.SEVERE, null, ex);
                    } catch (ExecutionException ex) {
                        JOptionPane.showMessageDialog(null, ex.getCause().getMessage());
                    }
                }
            };

            worker.execute();
            /*                try{
            OptiSuppress.runRounder(tableSet);
            JOptionPane.showMessageDialog(null, "The table has been rounded\n" +
                        "Number of steps: " + tableSet.roundMaxStep+"\n"+
                        "Max step: " + 
                        StrUtils.formatDouble(tableSet.roundMaxJump, tableSet.respVar.nDecimals)  +"\n"+
                        "Processing time: " + StrUtils.timeToString(tableSet.processingTime));
            ((AbstractTableModel)table.getModel()).fireTableDataChanged();
            adjustColumnWidths();
            updateSuppressButtons();
                            }
            // Anco 1.6                
            //                catch (ArgusException | IOException ex) {
                            catch (ArgusException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());}
                            catch (IOException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
                            }*/
        }
        break;
    case CTA: //do CTA
        final int i = JOptionPane.showConfirmDialog(parentFrame, "Do you prefer to use the expert version?",
                "Select CTA version", JOptionPane.YES_NO_CANCEL_OPTION);
        if ((i == JOptionPane.YES_OPTION) || (i == JOptionPane.NO_OPTION)) {
            new Thread() {
                @Override
                public void run() {
                    try {
                        OptiSuppress.RunCTA(tableSet, (i == JOptionPane.YES_OPTION));
                        JOptionPane.showMessageDialog(null,
                                "The CTA procedure has been completed\n" + tableSet.nSecond
                                        + " cells have been modified\n"
                                        + StrUtils.timeToString(tableSet.processingTime) + " needed");
                        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
                        adjustColumnWidths();
                        updateSuppressButtons();
                    } catch (ArgusException ex) {
                        JOptionPane.showMessageDialog(null, ex.getMessage());
                    } catch (FileNotFoundException ex) {
                        JOptionPane.showMessageDialog(null, ex.getMessage());
                    } catch (IOException ex) {
                        JOptionPane.showMessageDialog(null, ex.getMessage());
                    }
                }
            }.start();
        }
        break;
    case UWE:
        DialogModularParameters uweParams = new DialogModularParameters(parentFrame, tableSet, false, true);
        if (uweParams.showDialog() == DialogModularParameters.APPROVE_OPTION) {
            new Thread() {
                @Override
                public void run() {
                    try {
                        OptiSuppress.runUWE(tableSet);
                        JOptionPane.showMessageDialog(null,
                                "The UWE procedure has finished the protection\n" + tableSet.nSecond
                                        + " cells have been suppressed\n"
                                        + StrUtils.timeToString(tableSet.processingTime) + " needed");
                        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
                        adjustColumnWidths();
                        updateSuppressButtons();
                    } catch (ArgusException ex) {
                        JOptionPane.showMessageDialog(null, ex.getMessage());
                    } catch (IOException ex) {
                        JOptionPane.showMessageDialog(null, ex.getMessage());
                    }
                }
            }.start();
        }
        break;
    case GHMITER:
        DialogHypercubeParameters paramsG = new DialogHypercubeParameters(parentFrame, true);
        if (paramsG.showDialog(tableSet) == DialogHypercubeParameters.APPROVE_OPTION) {
            new Thread() {
                @Override
                public void run() {
                    try {
                        GHMiter.RunGHMiter(tableSet);
                        JOptionPane.showMessageDialog(null,
                                "The Hypercube has finished the protection\n" + tableSet.nSecond
                                        + " cells have been suppressed\n" + tableSet.ghMiterMessage
                                        + StrUtils.timeToString(tableSet.processingTime) + " needed");
                        //                              tableSet.suppressed = TableSet.SUP_GHMITER;
                        if (argus.utils.TauArgusUtils.ExistFile(Application.getTempFile("frozen.txt"))) {
                            DialogInfo Info = new DialogInfo(getParentFrame(), true);
                            Info.addLabel("Overview of the frozen cells");
                            try {
                                Info.addTextFile(Application.getTempFile("frozen.txt"));
                            } catch (ArgusException ex1) {
                            }
                            ;
                            Info.setVisible(true);
                        }
                        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
                        adjustColumnWidths();
                        updateSuppressButtons();
                    } catch (ArgusException ex) {

                        JOptionPane.showMessageDialog(null, ex.getMessage());
                        if (GHMiter.ShowProto002) {
                            DialogInfo Info = new DialogInfo(getParentFrame(), true);
                            Info.addLabel("Overview of the file PROTO002");
                            Info.setSize(1000, 500);
                            Info.setLocationRelativeTo(null);
                            try {
                                Info.addTextFile(Application.getTempFile("PROTO002"));
                            } catch (ArgusException ex1) {
                            }
                            ;
                            Info.setVisible(true);
                        }
                    }
                }
            }.start();
        }
        // run hypercube method
        break;
    /*            case HITAS:
    DialogModularParameters params = new DialogModularParameters(parentFrame, tableSet, false, true);
    params.showDialog();
    try {
        boolean oke = OptiSuppress.runModular(tableSet);
        JOptionPane.showMessageDialog(this, "Modular has finished the protection\n"
            + tableSet.nSecond + " cells have been suppressed\n"
            + StrUtils.timeToString(tableSet.processingTime) + " needed");
    } //|FileNotFoundException
    catch (ArgusException | IOException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage());
    }
    break;
    */
    case HITAS:
        DialogModularParameters params = new DialogModularParameters(parentFrame, tableSet, false, true);
        if (params.showDialog() == DialogModularParameters.APPROVE_OPTION) {
            final SwingWorker<Integer, Void> worker = new ProgressSwingWorker<Integer, Void>(
                    ProgressSwingWorker.DOUBLE, "Modular approach") {
                @Override
                protected Integer doInBackground() throws ArgusException, Exception {
                    super.doInBackground();
                    OptiSuppress.runModular(tableSet, getPropertyChangeListener());
                    return null;
                }

                @Override
                protected void done() {
                    super.done();
                    try {
                        get();
                        JOptionPane.showMessageDialog(null,
                                "Modular has finished the protection\n" + tableSet.nSecond
                                        + " cells have been suppressed\n"
                                        + StrUtils.timeToString(tableSet.processingTime) + " needed");
                        tableSet.undoAudit();
                        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
                        adjustColumnWidths();
                        updateSuppressButtons();
                    } catch (InterruptedException ex) {
                        logger.log(Level.SEVERE, null, ex);
                    } catch (ExecutionException ex) {
                        JOptionPane.showMessageDialog(null, ex.getCause().getMessage());
                    }
                }
            };
            worker.execute();
        }
        break;
    case OPTIMAL:
        /*               params = new DialogModularParameters(parentFrame, tableSet, true, true);
        params.showDialog();
        try{
        OptiSuppress.runOptimal(tableSet);
        JOptionPane.showMessageDialog(null, "Optimal has finished the protection\n"
            + tableSet.nSecond + " cells have been suppressed\n"
                        + StrUtils.timeToString(tableSet.processingTime) + " needed");
        tableSet.hasBeenAudited = false;
        } catch (ArgusException| IOException  ex)
        {JOptionPane.showMessageDialog(this, ex.getMessage());
        }
        // run optimal
        */
        params = new DialogModularParameters(parentFrame, tableSet, true, true);
        if (params.showDialog() == DialogModularParameters.APPROVE_OPTION) {
            final SwingWorker<Void, Void> worker = new ProgressSwingWorker<Void, Void>(
                    ProgressSwingWorker.VALUES, "Optimal approach") {

                // called in a separate thread...
                @Override
                protected Void doInBackground() throws ArgusException, Exception {
                    super.doInBackground();
                    OptiSuppress.runOptimal(tableSet, getPropertyChangeListener(),
                            checkBoxInverseWeight.isSelected(), false, 1);
                    return null;
                }

                // called on the GUI thread
                @Override
                protected void done() {
                    super.done();
                    try {
                        get();
                        JOptionPane.showMessageDialog(null,
                                "Optimal has finished the protection\n" + tableSet.nSecond
                                        + " cells have been suppressed\n"
                                        + StrUtils.timeToString(tableSet.processingTime) + " needed");
                        tableSet.undoAudit();
                        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
                        adjustColumnWidths();
                        updateSuppressButtons();
                    } catch (InterruptedException ex) {
                        logger.log(Level.SEVERE, null, ex);
                    } catch (ExecutionException ex) {
                        JOptionPane.showMessageDialog(null, ex.getCause().getMessage());
                    }
                }
            };
            worker.execute();
        }
        break;
    case NETWORK:
        try {
            OptiSuppress.TestNetwork(tableSet);
        } catch (ArgusException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
            break;
        }
        DialogNetwork paramsN = new DialogNetwork(parentFrame, true, tableSet);
        if (paramsN.showDialog() == DialogRoundingParameters.APPROVE_OPTION) {
            new Thread() {
                @Override
                public void run() {
                    try {
                        OptiSuppress.RunNetwork(tableSet);
                        JOptionPane.showMessageDialog(null,
                                "The network has finished the protection\n" + tableSet.nSecond
                                        + " cells have been suppressed\n"
                                        + StrUtils.timeToString(tableSet.processingTime) + " needed");
                        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
                        adjustColumnWidths();
                        updateSuppressButtons();
                    } catch (ArgusException ex) {
                        JOptionPane.showMessageDialog(null, ex.getMessage());
                    }
                }
            }.start();
        }
        break;
    case MARGINAL: {
        JOptionPane.showMessageDialog(null, "The marginal method still has to be implemented");
    }
    }
    //updateSuppressButtons(); // Needs to be at each try{} of "done"because it will not wait for finishing of ProcessSwingWorker
    //        Suppress(tableIndex, false, Soort);
    tableSet.undoAudit();

    // TODO Optimalisation: Only do this if a suppression method has run
    //((AbstractTableModel)table.getModel()).fireTableDataChanged();
    //adjustColumnWidths();
}

From source file:tk.tomby.tedit.actions.ExitAction.java

/**
 * DOCUMENT ME!/*from  w w w .  j a  v a  2s .co  m*/
 *
 * @param evt DOCUMENT ME!
 */
public void actionPerformed(ActionEvent evt) {
    for (IBuffer buffer : WorkspaceManager.getBufferList()) {
        if (buffer.isModified()) {
            if (log.isDebugEnabled()) {
                log.debug(buffer.getFileName() + "was modified");
            }

            int retval = JOptionPane.showConfirmDialog(WorkspaceManager.getMainFrame(),
                    ResourceManager.getProperty("main.savechanges.title"), buffer.getFileName(),
                    JOptionPane.YES_NO_CANCEL_OPTION);

            switch (retval) {
            case JOptionPane.YES_OPTION:

                if (!buffer.isNew()) {
                    buffer.save();
                } else {
                    JFileChooser chooser = new JFileChooser();

                    if (chooser
                            .showSaveDialog(WorkspaceManager.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
                        buffer.saveAs(chooser.getSelectedFile());
                    }
                }

                break;

            case JOptionPane.NO_OPTION:
                break;

            default:
                return;
            }
        }
    }

    if (log.isDebugEnabled()) {
        log.debug("saving workspace");
    }

    WorkspaceManager.save();
    PluginManager.save();

    if (log.isDebugEnabled()) {
        log.debug("exit from application");
    }

    System.exit(0);
}