Example usage for javax.swing JOptionPane OK_OPTION

List of usage examples for javax.swing JOptionPane OK_OPTION

Introduction

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

Prototype

int OK_OPTION

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

Click Source Link

Document

Return value form class method if OK is chosen.

Usage

From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java

private void rebuildChart() {
    if (listModel.getSize() < 2) {
        JOptionPane.showMessageDialog(this, "Select 2 compounds.", "Error", JOptionPane.OK_OPTION);
        err = true;//w  w w  .  ja v  a 2  s .  c  o  m
        return;
    }
    if (listModel.getSize() > 2) {
        JOptionPane.showMessageDialog(this, "Select only 2 compounds.", "Error", JOptionPane.OK_OPTION);
        return;
    }
    double T = Double.parseDouble(temperature.getText());
    if (T <= 0) {
        JOptionPane.showMessageDialog(this, "Invalid Temperature.", "Error", JOptionPane.OK_OPTION);
        return;
    }

    COSMOSAC cosmosac = (COSMOSAC) modelBox.getSelectedItem();
    COSMOSACCompound comps[] = new COSMOSACCompound[2];
    try {
        comps[0] = db.getComp((String) listModel.getElementAt(0));
        comps[1] = db.getComp((String) listModel.getElementAt(1));
        cosmosac.setComponents(comps);
    } catch (Exception e1) {
        e1.printStackTrace();
        return;
    }
    if (comps[0] == null || comps[1] == null)
        return;

    cosmosac.setSigmaHB(Double.parseDouble(sigmaHB.getText()));
    cosmosac.setSigmaHB2(Double.parseDouble(sigmaHB2.getText()));
    cosmosac.setSigmaHB3(Double.parseDouble(sigmaHB3.getText()));
    //      cosmosac.setSigmaHBUpper(Double.parseDouble(sigmaHBUpper.getText()));
    cosmosac.setCHB(Double.parseDouble(chargeHB.getText()));
    cosmosac.setSigmaDisp(Double.parseDouble(sigmaDisp.getText()));
    cosmosac.setCDisp(Double.parseDouble(chargeDisp.getText()));
    cosmosac.setBeta(Double.parseDouble(beta.getText()));
    cosmosac.setFpol(Double.parseDouble(fpol.getText()));
    cosmosac.setAnorm(Double.parseDouble(anorm.getText()));
    cosmosac.parametersChanged();

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    //      cosmosac.setParameters(cavityVolume, c1.charge, sigma);

    cosmosac.setTemperature(T);

    // testing several compositions
    XYSeriesCollection dataset = new XYSeriesCollection();
    int n = 20;
    XYSeries lnGamma1 = new XYSeries(comps[0].name);
    XYSeries lnGamma2 = new XYSeries(comps[1].name);
    XYSeries ge_RT = new XYSeries("gE/RT");

    for (int i = 0; i <= n; ++i) {
        z[0] = (double) i / n;
        z[1] = 1 - z[0];
        cosmosac.setComposition(z);
        cosmosac.activityCoefficient(lnGamma);

        lnGamma1.add(z[0], lnGamma[0]);
        lnGamma2.add(z[0], lnGamma[1]);
        ge_RT.add(z[0], z[0] * lnGamma[0] + z[1] * lnGamma[1]);

        if (z[0] == 0) {
            lnGammaInf1Label.setText(String.format("%6.3g", lnGamma[0]));
            gammaInf1Label.setText(String.format("%6.3g", Math.exp(lnGamma[0])));
        }
        if (z[1] == 0) {
            lnGammaInf2Label.setText(String.format("%6.3g", lnGamma[1]));
            gammaInf2Label.setText(String.format("%6.3g", Math.exp(lnGamma[1])));
        }
    }
    dataset.addSeries(lnGamma1);
    dataset.addSeries(lnGamma2);
    dataset.addSeries(ge_RT);

    plot.setDataset(dataset);

    // now the segment gamma
    dataset = new XYSeriesCollection();
    double[][] seggamma = cosmosac.getPureSegmentGamma();

    n = comps[0].charge.length;
    XYSeries g1 = new XYSeries(comps[0].name);
    XYSeries g2 = new XYSeries(comps[1].name);
    XYSeries g1s = new XYSeries(comps[0].name + " * sigma");
    XYSeries g2s = new XYSeries(comps[1].name + " * sigma");

    for (int j = 0; j < n; ++j) {
        g1.add(comps[0].charge[j], Math.log(seggamma[0][j]));
        g2.add(comps[1].charge[j], Math.log(seggamma[1][j]));
        g1s.add(comps[0].charge[j], comps[0].area[j] * (Math.log(seggamma[1][j]) - Math.log(seggamma[0][j])));
        g2s.add(comps[1].charge[j], comps[1].area[j] * (Math.log(seggamma[0][j]) - Math.log(seggamma[1][j])));
    }
    dataset.addSeries(g1);
    dataset.addSeries(g2);
    dataset.addSeries(g1s);
    dataset.addSeries(g2s);
    plotSegGamma.setDataset(dataset);

    // adjust the plot properties
    plotSegGamma.getDomainAxis().setAutoRange(false);
    plotSegGamma.getDomainAxis().setRange(new Range(-0.025, 0.025));
    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plotSegGamma.getRenderer();
    r.setSeriesStroke(0, new BasicStroke(2.5f));
    r.setSeriesStroke(1, new BasicStroke(2.5f));
    BasicStroke dashed = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f);

    r.setSeriesStroke(2, dashed);
    r.setSeriesStroke(3, dashed);
    r.setSeriesPaint(0, Color.RED);
    r.setSeriesPaint(1, Color.BLUE);
    r.setSeriesPaint(2, Color.RED);
    r.setSeriesPaint(3, Color.BLUE);
    //      plotSegGamma.setRenderer(stepRenderer);
    //      plotSegGamma.setRenderer(3, stepRenderer);

    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:net.sf.jabref.exporter.SaveDatabaseAction.java

/**
 * Run the "Save as" operation. This method offloads the actual save operation to a background thread, but
 * still runs synchronously using Spin (the method returns only after completing the operation).
 *///from ww  w . j  av  a 2 s . c  o m
public void saveAs() throws Throwable {
    String chosenFile;
    File f = null;
    while (f == null) {
        chosenFile = FileDialogs.getNewFile(frame,
                new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), ".bib",
                JFileChooser.SAVE_DIALOG, false, null);
        if (chosenFile == null) {
            canceled = true;
            return; // canceled
        }
        f = new File(chosenFile);
        // Check if the file already exists:
        if (f.exists() && (JOptionPane.showConfirmDialog(frame,
                Localization.lang("'%0' exists. Overwrite file?", f.getName()),
                Localization.lang("Save database"), JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)) {
            f = null;
        }
    }

    if (f != null) {
        File oldFile = panel.getBibDatabaseContext().getDatabaseFile();
        panel.getBibDatabaseContext().setDatabaseFile(f);
        Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, f.getParent());
        runCommand();
        // If the operation failed, revert the file field and return:
        if (!success) {
            panel.getBibDatabaseContext().setDatabaseFile(oldFile);
            return;
        }
        // Register so we get notifications about outside changes to the file.
        try {
            panel.setFileMonitorHandle(Globals.fileUpdateMonitor.addUpdateListener(panel,
                    panel.getBibDatabaseContext().getDatabaseFile()));
        } catch (IOException ex) {
            LOGGER.error("Problem registering file change notifications", ex);
        }
        frame.getFileHistory().newFile(panel.getBibDatabaseContext().getDatabaseFile().getPath());
    }
    frame.updateEnabledState();
}

From source file:net.pms.encoders.MEncoderVideo.java

@Override
public JComponent config() {
    // Apply the orientation for the locale
    Locale locale = new Locale(configuration.getLanguage());
    ComponentOrientation orientation = ComponentOrientation.getOrientation(locale);
    String colSpec = FormLayoutUtil.getColSpec(COL_SPEC, orientation);

    FormLayout layout = new FormLayout(colSpec, ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);/*  w w w.  jav  a  2s  .c  o  m*/

    CellConstraints cc = new CellConstraints();

    checkBox = new JCheckBox(Messages.getString("MEncoderVideo.0"));
    checkBox.setContentAreaFilled(false);

    if (configuration.getSkipLoopFilterEnabled()) {
        checkBox.setSelected(true);
    }

    checkBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setSkipLoopFilterEnabled((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 15), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    mencodermt = new JCheckBox(Messages.getString("MEncoderVideo.35"));
    mencodermt.setContentAreaFilled(false);

    if (configuration.getMencoderMT()) {
        mencodermt.setSelected(true);
    }

    mencodermt.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            configuration.setMencoderMT(mencodermt.isSelected());
        }
    });

    mencodermt.setEnabled(Platform.isWindows() || Platform.isMac());

    builder.add(mencodermt, FormLayoutUtil.flip(cc.xy(1, 3), colSpec, orientation));
    builder.add(checkBox, FormLayoutUtil.flip(cc.xyw(3, 3, 12), colSpec, orientation));

    noskip = new JCheckBox(Messages.getString("MEncoderVideo.2"));
    noskip.setContentAreaFilled(false);

    if (configuration.isMencoderNoOutOfSync()) {
        noskip.setSelected(true);
    }

    noskip.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderNoOutOfSync((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    builder.add(noskip, FormLayoutUtil.flip(cc.xy(1, 5), colSpec, orientation));

    JButton button = new JButton(Messages.getString("MEncoderVideo.29"));
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JPanel codecPanel = new JPanel(new BorderLayout());
            final JTextArea textArea = new JTextArea();
            textArea.setText(configuration.getMencoderCodecSpecificConfig());
            textArea.setFont(new Font("Courier", Font.PLAIN, 12));
            JScrollPane scrollPane = new JScrollPane(textArea);
            scrollPane.setPreferredSize(new java.awt.Dimension(900, 100));

            final JTextArea textAreaDefault = new JTextArea();
            textAreaDefault.setText(DEFAULT_CODEC_CONF_SCRIPT);
            textAreaDefault.setBackground(Color.WHITE);
            textAreaDefault.setFont(new Font("Courier", Font.PLAIN, 12));
            textAreaDefault.setEditable(false);
            textAreaDefault.setEnabled(configuration.isMencoderIntelligentSync());
            JScrollPane scrollPaneDefault = new JScrollPane(textAreaDefault);
            scrollPaneDefault.setPreferredSize(new java.awt.Dimension(900, 450));

            JPanel customPanel = new JPanel(new BorderLayout());
            intelligentsync = new JCheckBox(Messages.getString("MEncoderVideo.3"));
            intelligentsync.setContentAreaFilled(false);

            if (configuration.isMencoderIntelligentSync()) {
                intelligentsync.setSelected(true);
            }

            intelligentsync.addItemListener(new ItemListener() {
                @Override
                public void itemStateChanged(ItemEvent e) {
                    configuration.setMencoderIntelligentSync((e.getStateChange() == ItemEvent.SELECTED));
                    textAreaDefault.setEnabled(configuration.isMencoderIntelligentSync());

                }
            });

            JLabel label = new JLabel(Messages.getString("MEncoderVideo.33"));
            customPanel.add(label, BorderLayout.NORTH);
            customPanel.add(scrollPane, BorderLayout.SOUTH);

            codecPanel.add(intelligentsync, BorderLayout.NORTH);
            codecPanel.add(scrollPaneDefault, BorderLayout.CENTER);
            codecPanel.add(customPanel, BorderLayout.SOUTH);

            while (JOptionPane.showOptionDialog(
                    SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame()), codecPanel,
                    Messages.getString("MEncoderVideo.34"), JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null, null, null) == JOptionPane.OK_OPTION) {
                String newCodecparam = textArea.getText();
                DLNAMediaInfo fakemedia = new DLNAMediaInfo();
                DLNAMediaAudio audio = new DLNAMediaAudio();
                audio.setCodecA("ac3");
                fakemedia.setCodecV("mpeg4");
                fakemedia.setContainer("matroska");
                fakemedia.setDuration(45d * 60);
                audio.getAudioProperties().setNumberOfChannels(2);
                fakemedia.setWidth(1280);
                fakemedia.setHeight(720);
                audio.setSampleFrequency("48000");
                fakemedia.setFrameRate("23.976");
                fakemedia.getAudioTracksList().add(audio);
                String result[] = getSpecificCodecOptions(newCodecparam, fakemedia,
                        new OutputParams(configuration), "dummy.mpg", "dummy.srt", false, true);

                if (result.length > 0 && result[0].startsWith("@@")) {
                    String errorMessage = result[0].substring(2);
                    JOptionPane.showMessageDialog(
                            SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame()), errorMessage,
                            Messages.getString("Dialog.Error"), JOptionPane.ERROR_MESSAGE);
                } else {
                    configuration.setMencoderCodecSpecificConfig(newCodecparam);
                    break;
                }
            }
        }
    });
    builder.add(button, FormLayoutUtil.flip(cc.xy(1, 11), colSpec, orientation));

    forcefps = new JCheckBox(Messages.getString("MEncoderVideo.4"));
    forcefps.setContentAreaFilled(false);
    if (configuration.isMencoderForceFps()) {
        forcefps.setSelected(true);
    }
    forcefps.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderForceFps(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    builder.add(forcefps, FormLayoutUtil.flip(cc.xyw(1, 7, 2), colSpec, orientation));

    yadif = new JCheckBox(Messages.getString("MEncoderVideo.26"));
    yadif.setContentAreaFilled(false);
    if (configuration.isMencoderYadif()) {
        yadif.setSelected(true);
    }
    yadif.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderYadif(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    builder.add(yadif, FormLayoutUtil.flip(cc.xyw(3, 7, 7), colSpec, orientation));

    scaler = new JCheckBox(Messages.getString("MEncoderVideo.27"));
    scaler.setContentAreaFilled(false);
    scaler.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderScaler(e.getStateChange() == ItemEvent.SELECTED);
            scaleX.setEnabled(configuration.isMencoderScaler());
            scaleY.setEnabled(configuration.isMencoderScaler());
        }
    });
    builder.add(scaler, FormLayoutUtil.flip(cc.xyw(3, 5, 7), colSpec, orientation));

    builder.addLabel(Messages.getString("MEncoderVideo.28"), FormLayoutUtil
            .flip(cc.xy(9, 5, CellConstraints.RIGHT, CellConstraints.CENTER), colSpec, orientation));
    scaleX = new JTextField("" + configuration.getMencoderScaleX());
    scaleX.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            try {
                configuration.setMencoderScaleX(Integer.parseInt(scaleX.getText()));
            } catch (NumberFormatException nfe) {
                logger.debug("Could not parse scaleX from \"" + scaleX.getText() + "\"");
            }
        }
    });
    builder.add(scaleX, FormLayoutUtil.flip(cc.xy(11, 5), colSpec, orientation));

    builder.addLabel(Messages.getString("MEncoderVideo.30"), FormLayoutUtil
            .flip(cc.xy(13, 5, CellConstraints.RIGHT, CellConstraints.CENTER), colSpec, orientation));
    scaleY = new JTextField("" + configuration.getMencoderScaleY());
    scaleY.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            try {
                configuration.setMencoderScaleY(Integer.parseInt(scaleY.getText()));
            } catch (NumberFormatException nfe) {
                logger.debug("Could not parse scaleY from \"" + scaleY.getText() + "\"");
            }
        }
    });
    builder.add(scaleY, FormLayoutUtil.flip(cc.xy(15, 5), colSpec, orientation));

    if (configuration.isMencoderScaler()) {
        scaler.setSelected(true);
    } else {
        scaleX.setEnabled(false);
        scaleY.setEnabled(false);
    }

    builder.addLabel(Messages.getString("MEncoderVideo.6"),
            FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation));
    mencoder_custom_options = new JTextField(configuration.getMencoderCustomOptions());
    mencoder_custom_options.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setMencoderCustomOptions(mencoder_custom_options.getText());
        }
    });
    builder.add(mencoder_custom_options, FormLayoutUtil.flip(cc.xyw(3, 13, 13), colSpec, orientation));

    builder.addLabel(Messages.getString("MEncoderVideo.93"),
            FormLayoutUtil.flip(cc.xy(1, 15), colSpec, orientation));

    builder.addLabel(Messages.getString("MEncoderVideo.28") + " (%)", FormLayoutUtil
            .flip(cc.xy(1, 15, CellConstraints.RIGHT, CellConstraints.CENTER), colSpec, orientation));
    ocw = new JTextField(configuration.getMencoderOverscanCompensationWidth());
    ocw.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setMencoderOverscanCompensationWidth(ocw.getText());
        }
    });
    builder.add(ocw, FormLayoutUtil.flip(cc.xy(3, 15), colSpec, orientation));

    builder.addLabel(Messages.getString("MEncoderVideo.30") + " (%)",
            FormLayoutUtil.flip(cc.xy(5, 15), colSpec, orientation));
    och = new JTextField(configuration.getMencoderOverscanCompensationHeight());
    och.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setMencoderOverscanCompensationHeight(och.getText());
        }
    });
    builder.add(och, FormLayoutUtil.flip(cc.xy(7, 15), colSpec, orientation));

    cmp = builder.addSeparator(Messages.getString("MEncoderVideo.8"),
            FormLayoutUtil.flip(cc.xyw(1, 17, 15), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(Messages.getString("MEncoderVideo.16"), FormLayoutUtil
            .flip(cc.xy(1, 27, CellConstraints.RIGHT, CellConstraints.CENTER), colSpec, orientation));

    mencoder_noass_scale = new JTextField(configuration.getMencoderNoAssScale());
    mencoder_noass_scale.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setMencoderNoAssScale(mencoder_noass_scale.getText());
        }
    });

    builder.addLabel(Messages.getString("MEncoderVideo.17"),
            FormLayoutUtil.flip(cc.xy(5, 27), colSpec, orientation));

    mencoder_noass_outline = new JTextField(configuration.getMencoderNoAssOutline());
    mencoder_noass_outline.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setMencoderNoAssOutline(mencoder_noass_outline.getText());
        }
    });

    builder.addLabel(Messages.getString("MEncoderVideo.18"),
            FormLayoutUtil.flip(cc.xy(9, 27), colSpec, orientation));

    mencoder_noass_blur = new JTextField(configuration.getMencoderNoAssBlur());
    mencoder_noass_blur.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setMencoderNoAssBlur(mencoder_noass_blur.getText());
        }
    });

    builder.addLabel(Messages.getString("MEncoderVideo.19"),
            FormLayoutUtil.flip(cc.xy(13, 27), colSpec, orientation));

    mencoder_noass_subpos = new JTextField(configuration.getMencoderNoAssSubPos());
    mencoder_noass_subpos.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setMencoderNoAssSubPos(mencoder_noass_subpos.getText());
        }
    });

    builder.add(mencoder_noass_scale, FormLayoutUtil.flip(cc.xy(3, 27), colSpec, orientation));
    builder.add(mencoder_noass_outline, FormLayoutUtil.flip(cc.xy(7, 27), colSpec, orientation));
    builder.add(mencoder_noass_blur, FormLayoutUtil.flip(cc.xy(11, 27), colSpec, orientation));
    builder.add(mencoder_noass_subpos, FormLayoutUtil.flip(cc.xy(15, 27), colSpec, orientation));

    ass = new JCheckBox(Messages.getString("MEncoderVideo.20"));
    ass.setContentAreaFilled(false);
    ass.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e != null) {
                configuration.setMencoderAss(e.getStateChange() == ItemEvent.SELECTED);
            }
        }
    });
    builder.add(ass, FormLayoutUtil.flip(cc.xy(1, 23), colSpec, orientation));
    ass.setSelected(configuration.isMencoderAss());
    ass.getItemListeners()[0].itemStateChanged(null);

    fc = new JCheckBox(Messages.getString("MEncoderVideo.21"));
    fc.setContentAreaFilled(false);
    fc.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderFontConfig(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    builder.add(fc, FormLayoutUtil.flip(cc.xyw(3, 23, 5), colSpec, orientation));
    fc.setSelected(configuration.isMencoderFontConfig());

    assdefaultstyle = new JCheckBox(Messages.getString("MEncoderVideo.36"));
    assdefaultstyle.setContentAreaFilled(false);
    assdefaultstyle.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderAssDefaultStyle(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    builder.add(assdefaultstyle, FormLayoutUtil.flip(cc.xyw(8, 23, 4), colSpec, orientation));
    assdefaultstyle.setSelected(configuration.isMencoderAssDefaultStyle());

    builder.addLabel(Messages.getString("MEncoderVideo.92"),
            FormLayoutUtil.flip(cc.xy(1, 29), colSpec, orientation));
    subq = new JTextField(configuration.getMencoderVobsubSubtitleQuality());
    subq.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setMencoderVobsubSubtitleQuality(subq.getText());
        }
    });
    builder.add(subq, FormLayoutUtil.flip(cc.xyw(3, 29, 1), colSpec, orientation));

    configuration.addConfigurationListener(new ConfigurationListener() {
        @Override
        public void configurationChanged(ConfigurationEvent event) {
            if (event.getPropertyName() == null) {
                return;
            }
            if ((!event.isBeforeUpdate())
                    && event.getPropertyName().equals(PmsConfiguration.KEY_DISABLE_SUBTITLES)) {
                boolean enabled = !configuration.isDisableSubtitles();
                ass.setEnabled(enabled);
                assdefaultstyle.setEnabled(enabled);
                fc.setEnabled(enabled);
                mencoder_noass_scale.setEnabled(enabled);
                mencoder_noass_outline.setEnabled(enabled);
                mencoder_noass_blur.setEnabled(enabled);
                mencoder_noass_subpos.setEnabled(enabled);
                ocw.setEnabled(enabled);
                och.setEnabled(enabled);
                subq.setEnabled(enabled);

                if (enabled) {
                    ass.getItemListeners()[0].itemStateChanged(null);
                }
            }
        }
    });

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    return panel;
}

From source file:com.cch.aj.entryrecorder.frame.EntryJFrame.java

private int FillEntryComboBox(JComboBox comboBox, int id) {
    int result = -1;
    List<Entry> allEntrys = this.entryService.GetAllEntities();
    if (allEntrys.size() > 0) {
        List<Entry> entrys = allEntrys.stream().filter(x -> x.getShift().equals(this.txtEntrySearch.getText()))
                .collect(Collectors.toList());
        if (entrys.size() > 0) {
            List<ComboBoxItem<Entry>> entryNames = entrys.stream().sorted(comparing(x -> x.getCreateDate()))
                    .map(x -> ComboBoxItemConvertor.ConvertToComboBoxItem(x,
                            (x.getMachineId() != null ? x.getMachineId().getMachineNo() : "New") + " / "
                                    + (x.getProductId() != null ? x.getProductId().getCode() : "NA"),
                            x.getId()))/*from w  w w .j a va 2s.c o  m*/
                    .collect(Collectors.toList());
            Entry entry = new Entry();
            entry.setId(0);
            entry.setShift("- Select -");
            entryNames.add(0, new ComboBoxItem<Entry>(entry, entry.getShift(), entry.getId()));
            ComboBoxItem[] entryNamesArray = entryNames.toArray(new ComboBoxItem[entryNames.size()]);
            comboBox.setModel(new DefaultComboBoxModel(entryNamesArray));
            if (id != 0) {
                ComboBoxItem<Entry> currentEntryName = entryNames.stream().filter(x -> x.getId() == id)
                        .findFirst().get();
                result = entryNames.indexOf(currentEntryName);
            } else {
                result = 0;
            }
            comboBox.setSelectedIndex(result);
        } else {
            JOptionPane.showMessageDialog(this, "No entry has been found.", "Info", JOptionPane.OK_OPTION);
        }
    }
    return result;
}

From source file:net.sf.jabref.gui.exporter.SaveDatabaseAction.java

/**
 * Run the "Save as" operation. This method offloads the actual save operation to a background thread, but
 * still runs synchronously using Spin (the method returns only after completing the operation).
 *///w w w  .jav a2 s.  c o  m
public void saveAs() throws Throwable {
    String chosenFile;
    File f = null;
    while (f == null) {
        chosenFile = FileDialogs.getNewFile(frame,
                new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)),
                Collections.singletonList(".bib"), JFileChooser.SAVE_DIALOG, false, null);
        if (chosenFile == null) {
            canceled = true;
            return; // canceled
        }
        f = new File(chosenFile);
        // Check if the file already exists:
        if (f.exists() && (JOptionPane.showConfirmDialog(frame,
                Localization.lang("'%0' exists. Overwrite file?", f.getName()),
                Localization.lang("Save database"), JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)) {
            f = null;
        }
    }

    File oldFile = panel.getBibDatabaseContext().getDatabaseFile();
    panel.getBibDatabaseContext().setDatabaseFile(f);
    Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, f.getParent());
    runCommand();
    // If the operation failed, revert the file field and return:
    if (!success) {
        panel.getBibDatabaseContext().setDatabaseFile(oldFile);
        return;
    }
    // Register so we get notifications about outside changes to the file.
    try {
        panel.setFileMonitorHandle(Globals.getFileUpdateMonitor().addUpdateListener(panel,
                panel.getBibDatabaseContext().getDatabaseFile()));
    } catch (IOException ex) {
        LOGGER.error("Problem registering file change notifications", ex);
    }
    frame.getFileHistory().newFile(panel.getBibDatabaseContext().getDatabaseFile().getPath());
    frame.updateEnabledState();
}

From source file:com.sec.ose.osi.sdk.protexsdk.discovery.report.ReportFactory.java

public static void parser(String projectName, BufferedReader htmlReportReader, UIResponseObserver observer,
        ReportType reportType) {//from   ww  w.  j  ava 2s . c  om
    String tmpLine = null;
    ArrayList<CodeMatchesPrecision> list = new ArrayList<CodeMatchesPrecision>();
    ArrayList<String> data = new ArrayList<String>();
    int insertedCnt = 0;

    if (htmlReportReader == null) {
        log.debug("Fail to generate " + projectName + " " + reportType + " Report");
        observer.setFailMessage("Fail to generate " + projectName + " " + reportType + " Report");
        return;
    }

    String msgHead = " > Creating Report : " + projectName + "\n";
    String pMessage = " >> Parsing [" + reportType.getType() + "] HTML file.";
    log.debug(pMessage);

    try {
        StringBuffer tmpValue = new StringBuffer("");
        while ((tmpLine = htmlReportReader.readLine()) != null) {
            tmpLine = tmpLine.trim();
            if (tmpLine.startsWith("<table border='0' cellspacing='0' cellpadding='0' class='reportTable'")) {
                while ((tmpLine = htmlReportReader.readLine()) != null) {
                    tmpLine = tmpLine.trim();
                    if (tmpLine.startsWith("</thead>")) {
                        break;
                    }
                }
                break;
            }
        }

        while ((tmpLine = htmlReportReader.readLine()) != null) {
            tmpLine = tmpLine.trim();
            if (tmpLine.startsWith("<tr ")) {
                int index = 0;
                while ((tmpLine = htmlReportReader.readLine()) != null) {
                    tmpLine = tmpLine.trim();
                    if (tmpLine.startsWith("<td ")) {
                        while ((tmpLine = htmlReportReader.readLine()) != null) {
                            tmpLine = tmpLine.trim();
                            if (tmpLine.startsWith("</td>")) {
                                String removedTagValue = removeHtmlTag(tmpValue);
                                data.add(removedTagValue);
                                tmpValue.setLength(0);
                                ++index;
                                break;
                            }
                            tmpValue.append(tmpLine);
                        }
                    }
                    if (tmpLine.startsWith("</tr>")) {
                        if (hasNoData(index)) {
                            break;
                        }
                        CodeMatchesPrecision codeMatchesPrecision = new CodeMatchesPrecision();
                        codeMatchesPrecision.setFile(data.get(0));
                        codeMatchesPrecision.setSize(Tools.transStringToInteger(data.get(1)));
                        codeMatchesPrecision.setFileLine(Tools.transStringToInteger(data.get(2)));
                        codeMatchesPrecision.setTotalLines(Tools.transStringToInteger(data.get(3)));
                        codeMatchesPrecision.setComponent(data.get(4));
                        codeMatchesPrecision.setVersion(data.get(5));
                        codeMatchesPrecision.setLicense(data.get(6));
                        codeMatchesPrecision.setUsage(data.get(7));
                        codeMatchesPrecision.setStatus(data.get(8));
                        codeMatchesPrecision.setPercentage(data.get(9));
                        codeMatchesPrecision.setMatchedFile(data.get(10));
                        codeMatchesPrecision.setMatchedFileLine(Tools.transStringToInteger(data.get(11)));
                        codeMatchesPrecision.setFileComment(data.get(12));
                        codeMatchesPrecision.setComponentComment(data.get(13));
                        list.add(codeMatchesPrecision);
                        data.clear();

                        insertedCnt++;
                        if (insertedCnt % 10000 == 0) {
                            log.debug("codeMatchesPrecision insertedCnt: " + insertedCnt);
                            if (observer != null) {
                                observer.pushMessageWithHeader(
                                        msgHead + pMessage + "\n >>> Inserted data count : " + insertedCnt);
                            }
                            insertCodematchTable(projectName, list);
                            list.clear();
                        }
                        break;
                    }
                }
            }
            if (tmpLine.startsWith("</table>")) {
                log.debug("codeMatchesPrecision insertedCnt: " + insertedCnt);
                insertCodematchTable(projectName, list);
                list.clear();
                break;
            }
        }
    } catch (IOException e) {
        ReportAPIWrapper.log.warn(e);
        String[] buttonOK = { "OK" };
        JOptionPane.showOptionDialog(null, "Out Of Memory Error", "Java heap space", JOptionPane.OK_OPTION,
                JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK");
    }
    ReportAPIWrapper.log.debug("codeMatchesPrecision insertedCnt finally : " + insertedCnt);
}

From source file:com.sec.ose.osi.sdk.protexsdk.discovery.report.DefaultEntityListCreator.java

protected ReportEntityList buildEntityList(BufferedReader XmlReportReader, ArrayList<String> entityKeyList,
        ArrayList<String> duplicationCheckingField) {
    ReportEntityList reportEntityList = new ReportEntityList();
    ReportEntity reportEntity = new ReportEntity();
    String tmpLine = null;/*from www  . j  ava 2s. com*/
    StringBuffer value = new StringBuffer();
    int index = 0;

    if (duplicationCheckingField == null) {
        duplicationCheckingField = new ArrayList<String>();
    }
    boolean entityDuplicationCheck = (duplicationCheckingField.size() > 0) ? true : false;
    HashSet<String> entityDuplicationCheckKeySet = new HashSet<String>();
    String duplicationCheckString = "";

    int totalCnt = 0;
    int insertedCnt = 0;

    try {
        while ((tmpLine = XmlReportReader.readLine()) != null) {

            totalCnt++;
            if (totalCnt % 10000 == 0) {
                log.debug("buildEntityList cnt: " + totalCnt + ", insertedCnt: " + insertedCnt);
            }
            if (totalCnt > Property.getInstance().getMaxNumOfReportEntity()) {

                log.error("Report Entity is larger than MAX_NUM_OF_REPORT_ENTITY: "
                        + Property.getInstance().getMaxNumOfReportEntity());
                JOptionPane.showMessageDialog(null,
                        "[OUT OF MEMORY] Project loading has been failed.\n"
                                + "Please, Reanalyze this project with smallar files.\n"
                                + "to reduce the size of project.\n",
                        "Program Exit - Project size is too big", JOptionPane.ERROR_MESSAGE);
                System.exit(0);
            }

            if (tmpLine.startsWith(ROW_END_TAG)) {

                if (entityDuplicationCheck == true) {
                    if (entityDuplicationCheckKeySet.contains(duplicationCheckString) == false) {
                        reportEntityList.addEntity(reportEntity);
                        insertedCnt++;
                    }

                    entityDuplicationCheckKeySet.add(duplicationCheckString);
                    duplicationCheckString = "";
                } else {
                    reportEntityList.addEntity(reportEntity);
                    insertedCnt++;
                }

                reportEntity = new ReportEntity();
                index = 0;
                if (XmlReportReader.readLine().equals(TABLE_END_TAG)) {
                    break; // read <Row ss:Index="#">
                }
            } else {
                int startIndex = tmpLine.indexOf(DATA_START_TAG);
                if (startIndex > 0) {
                    tmpLine = tmpLine.substring(startIndex + DATA_START_TAG_LEN);
                }
                int endIndex = tmpLine.indexOf(DATA_END_TAG_WITH_NS);
                if (endIndex >= 0) {
                    value.append(tmpLine.substring(0, endIndex));
                    if (entityDuplicationCheck == true) {
                        String currentKey = entityKeyList.get(index);
                        if (duplicationCheckingField.contains(currentKey))
                            duplicationCheckString += value.toString() + "-";
                    }
                    reportEntity.setValue(entityKeyList.get(index), value.toString());
                    index++;
                    value = new StringBuffer();

                } else {
                    value.append(tmpLine);
                }

            }

        }
    } catch (IOException e) {
        log.warn(e);
        String[] buttonOK = { "OK" };
        JOptionPane.showOptionDialog(null, "Out Of Memory Error", "Java heap space", JOptionPane.OK_OPTION,
                JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK");
    }
    log.debug("total buildEntityList cnt: " + totalCnt + ", inserted cnt: " + insertedCnt);
    return reportEntityList;
}

From source file:e3fraud.gui.MainWindow.java

public void actionPerformed(ActionEvent e) {

    //Handle open button action.
    if (e.getSource() == openButton) {
        int returnVal = fc.showOpenDialog(MainWindow.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            //parse file
            this.baseModel = FileParser.parseFile(file);
            log.append(currentTime.currentTime() + " Opened: " + file.getName() + "." + newline);
        } else {/*w  ww  .ja  va  2s  .c  o m*/
            log.append(currentTime.currentTime() + " Open command cancelled by user." + newline);
        }
        log.setCaretPosition(log.getDocument().getLength());

        //handle Generate button
    } else if (e.getSource() == generateButton) {
        if (this.baseModel != null) {
            //have the user indicate the ToA via pop-up
            JFrame frame1 = new JFrame("Select Target of Assessment");
            Map<String, Resource> actorsMap = this.baseModel.getActorsMap();
            String selectedActorString = (String) JOptionPane.showInputDialog(frame1,
                    "Which actor's perspective are you taking?", "Choose main actor",
                    JOptionPane.QUESTION_MESSAGE, null, actorsMap.keySet().toArray(),
                    actorsMap.keySet().toArray()[0]);
            if (selectedActorString == null) {
                log.append(currentTime.currentTime() + " Attack generation cancelled!" + newline);
            } else {
                lastSelectedActorString = selectedActorString;
                //have the user select a need via pop-up
                JFrame frame2 = new JFrame("Select graph parameter");
                Map<String, Resource> needsMap = this.baseModel.getNeedsMap();
                String selectedNeedString = (String) JOptionPane.showInputDialog(frame2,
                        "What do you want to use as parameter?", "Choose need to parametrize",
                        JOptionPane.QUESTION_MESSAGE, null, needsMap.keySet().toArray(),
                        needsMap.keySet().toArray()[0]);
                if (selectedNeedString == null) {
                    log.append("Attack generation cancelled!" + newline);
                } else {
                    lastSelectedNeedString = selectedNeedString;
                    //have the user select occurence interval via pop-up
                    JTextField xField = new JTextField("1", 4);
                    JTextField yField = new JTextField("500", 4);
                    JPanel myPanel = new JPanel();
                    myPanel.add(new JLabel("Mininum occurences:"));
                    myPanel.add(xField);
                    myPanel.add(Box.createHorizontalStrut(15)); // a spacer
                    myPanel.add(new JLabel("Maximum occurences:"));
                    myPanel.add(yField);
                    int result = JOptionPane.showConfirmDialog(null, myPanel,
                            "Please Enter occurence rate interval", JOptionPane.OK_CANCEL_OPTION);

                    if (result == JOptionPane.CANCEL_OPTION) {
                        log.append("Attack generation cancelled!" + newline);
                    } else if (result == JOptionPane.OK_OPTION) {
                        startValue = Integer.parseInt(xField.getText());
                        endValue = Integer.parseInt(yField.getText());

                        selectedNeed = needsMap.get(selectedNeedString);
                        selectedActor = actorsMap.get(selectedActorString);

                        //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI)
                        GenerationWorker generationWorker = new GenerationWorker(baseModel, selectedActorString,
                                selectedActor, selectedNeed, selectedNeedString, startValue, endValue, log,
                                lossButton, gainButton, lossGainButton, gainLossButton, groupingButton,
                                collusionsButton) {
                            //make it so that when Worker is done
                            @Override
                            protected void done() {
                                try {
                                    progressBar.setVisible(false);
                                    System.err.println("I made it invisible");
                                    //the Worker's result is retrieved
                                    treeModel.setRoot(get());
                                    tree.setModel(treeModel);

                                    tree.updateUI();
                                    tree.collapseRow(1);
                                    //tree.expandRow(0);
                                    tree.setRootVisible(false);
                                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                                } catch (InterruptedException | ExecutionException ex) {
                                    Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
                                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                                    log.append("Out of memory; please increase heap size of JVM");
                                    PopUps.infoBox(
                                            "Encountered an error. Most likely out of memory; try increasing the heap size of JVM",
                                            "Error");
                                }
                            }
                        };
                        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                        progressBar.setVisible(true);
                        progressBar.setIndeterminate(true);
                        progressBar.setString("generating...");
                        generationWorker.addPropertyChangeListener(new PropertyChangeListener() {
                            public void propertyChange(PropertyChangeEvent evt) {
                                if ("phase".equals(evt.getPropertyName())) {
                                    progressBar.setMaximum(100);
                                    progressBar.setIndeterminate(false);
                                    progressBar.setString("ranking...");
                                } else if ("progress".equals(evt.getPropertyName())) {
                                    progressBar.setValue((Integer) evt.getNewValue());
                                }
                            }
                        });
                        generationWorker.execute();
                    }
                }
            }
        } else {
            log.append("Load a model file first!" + newline);
        }
    } //handle the refresh button
    else if (e.getSource() == refreshButton) {
        if (lastSelectedNeedString != null && lastSelectedActorString != null) {
            Map<String, Resource> actorsMap = this.baseModel.getActorsMap();
            Map<String, Resource> needsMap = this.baseModel.getNeedsMap();
            selectedNeed = needsMap.get(lastSelectedNeedString);
            selectedActor = actorsMap.get(lastSelectedActorString);

            //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI)
            GenerationWorker generationWorker = new GenerationWorker(baseModel, lastSelectedActorString,
                    selectedActor, selectedNeed, lastSelectedNeedString, startValue, endValue, log, lossButton,
                    gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) {
                //make it so that when Worker is done
                @Override
                protected void done() {
                    try {
                        progressBar.setVisible(false);
                        //the Worker's result is retrieved
                        treeModel.setRoot(get());
                        tree.setModel(treeModel);
                        tree.updateUI();
                        tree.collapseRow(1);
                        //tree.expandRow(0);
                        tree.setRootVisible(false);
                        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    } catch (InterruptedException | ExecutionException ex) {
                        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
                        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                        log.append("Most likely out of memory; please increase heap size of JVM");
                        PopUps.infoBox(
                                "Encountered an error. Most likely out of memory; try increasing the heap size of JVM",
                                "Error");
                    }
                }
            };
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            progressBar.setVisible(true);
            progressBar.setIndeterminate(true);
            progressBar.setString("generating...");
            generationWorker.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    if ("phase".equals(evt.getPropertyName())) {
                        progressBar.setMaximum(100);
                        progressBar.setIndeterminate(false);
                        progressBar.setString("ranking...");
                    } else if ("progress".equals(evt.getPropertyName())) {
                        progressBar.setValue((Integer) evt.getNewValue());
                    }
                }
            });
            generationWorker.execute();

        } else {
            log.append(currentTime.currentTime() + " Nothing to refresh. Generate models first" + newline);
        }

    } //handle show ideal graph button
    else if (e.getSource() == idealGraphButton) {
        if (this.baseModel != null) {
            graph1 = GraphingTool.generateGraph(baseModel, selectedNeed, startValue, endValue, true);//expected graph 
            ChartFrame chartframe1 = new ChartFrame("Ideal results", graph1);
            chartframe1.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT));
            chartframe1.pack();
            chartframe1.setLocationByPlatform(true);
            chartframe1.setVisible(true);
        } else {
            log.append(currentTime.currentTime() + " Load a model file first!" + newline);
        }
    } //Handle the graph extend button//Handle the graph extend button
    else if (e.getSource() == expandButton) {
        //make sure there is a graph to show
        if (graph2 == null) {
            log.append(currentTime.currentTime() + " No graph to display. Select one first." + newline);
        } else {
            //this makes sure both graphs have the same y axis:
            //            double lowerBound = min(graph1.getXYPlot().getRangeAxis().getRange().getLowerBound(), graph2.getXYPlot().getRangeAxis().getRange().getLowerBound());
            //            double upperBound = max(graph1.getXYPlot().getRangeAxis().getRange().getUpperBound(), graph2.getXYPlot().getRangeAxis().getRange().getUpperBound());
            //            graph1.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound);
            //            graph2.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound);
            chartPane.removeAll();
            chartPanel = new ChartPanel(graph2);
            chartPanel.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT));
            chartPane.add(chartPanel);
            chartPane.add(collapseButton);
            extended = true;
            this.setPreferredSize(new Dimension(this.getWidth() + CHART_WIDTH, this.getHeight()));
            JFrame frame = (JFrame) getRootPane().getParent();
            frame.pack();
        }
    } //Handle the graph collapse button//Handle the graph collapse button
    else if (e.getSource() == collapseButton) {
        System.out.println("resizing by -" + CHART_WIDTH);
        chartPane.removeAll();
        chartPane.add(expandButton);
        this.setPreferredSize(new Dimension(this.getWidth() - CHART_WIDTH, this.getHeight()));
        chartPane.repaint();
        chartPane.revalidate();
        extended = false;
        JFrame frame = (JFrame) getRootPane().getParent();
        frame.pack();
    }
}

From source file:net.sf.profiler4j.console.Console.java

public void applyRules() {
    int ret = JOptionPane.showConfirmDialog(mainFrame,
            "Request activation of profiling rules now? (This may take some time)", "Activate Profiling Rules",
            JOptionPane.OK_CANCEL_OPTION);
    if (ret != JOptionPane.OK_OPTION) {
        return;/*  ww w.  j  a v  a2 s .  c  o  m*/
    }
    LongTask t = new LongTask() {
        public void executeInBackground() throws Exception {
            setTaskMessage("Activating profiling rules...");
            client.applyRules(project.formatRules(), project.formatOptions(), new ProgressCallback() {
                private int max;

                public void operationStarted(int amount) {
                    max = amount;
                    setTaskProgress(0);
                }

                public void update(int value) {
                    setTaskProgress((value * 100) / max);
                    setTaskMessage("Activating profiling rules... (class " + value + " of " + max + ")");
                }
            });
        };
    };
    runInBackground(t);
    if (t.getError() == null) {
        sendEvent(AppEventType.RULES_APPLIED);
    }
}

From source file:com.floreantpos.ui.views.SwitchboardView.java

protected void doCloseOrder() {
    Ticket ticket = getFirstSelectedTicket();

    if (ticket == null) {
        return;/*from w w  w  .ja va2s.  c  o  m*/
    }

    ticket = TicketDAO.getInstance().loadFullTicket(ticket.getId());

    int due = (int) POSUtil.getDouble(ticket.getDueAmount());
    if (due != 0) {
        POSMessageDialog.showError(this, Messages.getString("SwitchboardView.5")); //$NON-NLS-1$
        return;
    }

    int option = JOptionPane.showOptionDialog(Application.getPosWindow(),
            Messages.getString("SwitchboardView.6") + ticket.getId() + Messages.getString("SwitchboardView.7"), //$NON-NLS-1$//$NON-NLS-2$
            POSConstants.CONFIRM, JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);

    if (option != JOptionPane.OK_OPTION) {
        return;
    }

    OrderController.closeOrder(ticket);

    //tickteListViewObj.updateTicketList();
    updateTicketList();
}