Example usage for javax.swing JOptionPane YES_OPTION

List of usage examples for javax.swing JOptionPane YES_OPTION

Introduction

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

Prototype

int YES_OPTION

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

Click Source Link

Document

Return value from class method if YES is chosen.

Usage

From source file:org.csa.rstb.polarimetric.rcp.toolviews.HaAlphaPlotPanel.java

@Override
protected boolean checkDataToClipboardCopy() {
    final int warnLimit = 2000;
    final int excelLimit = 65536;
    final int numNonEmptyBins = getNumNonEmptyBins();
    if (numNonEmptyBins > warnLimit) {
        String excelNote = "";
        if (numNonEmptyBins > excelLimit - 100) {
            excelNote = "Note that e.g., Microsoft Excel 2002 only supports a total of " + excelLimit
                    + " rows in a sheet.\n";
        }/*from  w w  w .  ja  v  a 2s .  c  om*/
        final String message = MessageFormat.format("This scatter plot contains {0} non-empty bins.\n"
                + "For each bin, a text data row containing an x, y and z value will be created.\n"
                + "{1}\nPress ''Yes'' if you really want to copy this amount of data to the system clipboard.\n",
                numNonEmptyBins, excelNote);
        final int status = JOptionPane.showConfirmDialog(this, message, "Copy Data to Clipboard",
                JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
        if (status != JOptionPane.YES_OPTION) {
            return false;
        }
    }
    return true;
}

From source file:UserInterface.FinanceRole.TransferToRegSiteJPanel.java

private void donateJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_donateJButtonActionPerformed

    //Validation/* w w w.j a v  a 2s . co m*/
    boolean validationSuccess;
    validationSuccess = validationIndividualTansfer();

    if (validationSuccess) {

        RegisteredSiteEnterprise objRegisteredSiteEnterprise = null;

        int selectedRegSite = regSiteJTable.getSelectedRow();

        if (selectedRegSite < 0) {
            JOptionPane.showMessageDialog(null, "Please select a Site");
            return;
        }

        objRegisteredSiteEnterprise = (RegisteredSiteEnterprise) regSiteJTable.getValueAt(selectedRegSite, 1);

        if (objRegisteredSiteEnterprise != null) {

            objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount();

            BigDecimal worldBalance = objWorldEnterprise.getObjTransactionDirectory().getAvailableRealBalance();

            int positiveWorldBalance = worldBalance.compareTo(individualDonationAmount);

            if (positiveWorldBalance >= 1) {

                int response = JOptionPane.showConfirmDialog(null,
                        "Total transfer of $ " + individualDonationAmount + "/- Do you want to transfer?",
                        "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (response == JOptionPane.YES_OPTION) {

                    //Registered Site Transaction
                    Transaction objRealRSTransaction = (Transaction) objRegisteredSiteEnterprise
                            .getObjTransactionDirectory().addNewTransaction();
                    objRealRSTransaction.setTransactionBDAmount(individualDonationAmount);
                    objRealRSTransaction.setObjUserAccountSource(objUserAccount);
                    objRealRSTransaction.setObjUserAccountDestination(null);
                    objRealRSTransaction.setTransactionSource(
                            Transaction.TransactionSourceType.FromWorldEnterprise.getValue());
                    objRealRSTransaction.setTransactionDestination(
                            Transaction.TransactionSourceType.ToRegSiteEnterprise.getValue());
                    objRealRSTransaction.setTransactionType(Transaction.TransactionType.Credit.getValue());
                    objRealRSTransaction.setTransactionMode(Transaction.TransactionModeType.Real.getValue());
                    objRegisteredSiteEnterprise.getObjTransactionDirectory().updateTransactionAccount();

                    //WorldEnterprise Transaction
                    Transaction objRealWETransaction = (Transaction) objWorldEnterprise
                            .getObjTransactionDirectory().addNewTransaction();
                    objRealWETransaction.setTransactionBDAmount(individualDonationAmount);
                    objRealWETransaction.setObjUserAccountSource(objUserAccount);
                    objRealWETransaction.setObjUserAccountDestination(null);
                    objRealWETransaction.setTransactionSource(
                            Transaction.TransactionSourceType.FromWorldEnterprise.getValue());
                    objRealWETransaction.setTransactionDestination(
                            Transaction.TransactionSourceType.ToRegSiteEnterprise.getValue());
                    objRealWETransaction.setTransactionType(Transaction.TransactionType.Debit.getValue());
                    objRealWETransaction.setTransactionMode(Transaction.TransactionModeType.Real.getValue());
                    objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount();

                    populateTransactionTable(objRegisteredSiteEnterprise);

                    JOptionPane.showMessageDialog(null,
                            "$ " + individualDonationAmount + "/- transferred successfully");

                    donationAmountJTextField.setText(null);
                    populateLowRegSiteTable();

                    //RegSiteTransferRecords
                    String donationLogs = objRealWETransaction.getTransactionID() + ","
                            + objRealWETransaction.getTransactionBDAmount() + ","
                            + objRealWETransaction.getObjUserAccountSource() + ","
                            + objRealWETransaction.getTransactionSource() + "," + objRegisteredSiteEnterprise
                            + "," + objRealWETransaction.getTransactionDestination() + ","
                            + objRealWETransaction.getTransactionType() + ","
                            + objRealWETransaction.getTransactionMode();

                    GenerateReports.regSiteTransferRecords(donationLogs);
                }

            } else {
                JOptionPane.showMessageDialog(null, "World Balance is low");
            }
        } else {
            JOptionPane.showMessageDialog(null, "Please select again");
        }
    }
}

From source file:org.pentaho.support.standalone.SDSupportUtility.java

/**
 * initializing UI/*  w ww.j  a  v a2  s.c  o  m*/
 * 
 * @throws Exception
 */
public SDSupportUtility() throws Exception {

    prop = loadProperty();

    setResizable(false);
    setTitle(SDConstant.PENT_SUP_WIZARD);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 665, 516);

    contentPane = new JPanel();
    contentPane.setBackground(UIManager.getColor("Button.background"));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblLastAttached = new JLabel("Last Attached");
    lblLastAttached.setOpaque(false);
    lblLastAttached.setHorizontalAlignment(SwingConstants.LEFT);
    lblLastAttached.setBounds(322, 335, 127, 23);
    contentPane.add(lblLastAttached);

    JLabel lblPentahoCustomerSupport = new JLabel("Pentaho Customer Support Wizard");
    lblPentahoCustomerSupport.setForeground(new Color(51, 51, 51));
    lblPentahoCustomerSupport.setVerticalAlignment(SwingConstants.TOP);
    lblPentahoCustomerSupport.setHorizontalAlignment(SwingConstants.RIGHT);
    lblPentahoCustomerSupport.setFont(new Font("Tahoma", Font.BOLD, 23));
    lblPentahoCustomerSupport.setBounds(130, 109, 506, 37);
    contentPane.add(lblPentahoCustomerSupport);

    JLabel lbllogo = new JLabel();
    lbllogo.setIcon(new ImageIcon(
            SDSupportUtility.class.getResource("/org/pentaho/support/standalone/puc-login-logo.png")));
    lbllogo.setBounds(10, 11, 409, 93);
    contentPane.add(lbllogo);

    chckbxNewCheckBoxEnvironment = new JCheckBox("Environment");
    chckbxNewCheckBoxEnvironment.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.ENVIRONMENT);
            } else {
                ArgList.remove(SDConstant.ENVIRONMENT);
            }
        }
    });
    chckbxNewCheckBoxEnvironment.setBounds(109, 268, 243, 23);
    contentPane.add(chckbxNewCheckBoxEnvironment);
    chckbxNewCheckBoxEnvironment.setOpaque(false);

    chckbxNewCheckBoxStructure = new JCheckBox("Structure Details");
    chckbxNewCheckBoxStructure.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.STRUCT);
            } else {
                ArgList.remove(SDConstant.STRUCT);
            }
        }
    });
    chckbxNewCheckBoxStructure.setBounds(377, 190, 248, 23);
    contentPane.add(chckbxNewCheckBoxStructure);
    chckbxNewCheckBoxStructure.setOpaque(false);

    chckbxLogs = new JCheckBox("Logs");
    chckbxLogs.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.LOGS);
            } else {
                ArgList.remove(SDConstant.LOGS);
            }
        }
    });
    chckbxLogs.setBounds(377, 164, 248, 23);
    contentPane.add(chckbxLogs);
    chckbxLogs.setOpaque(false);

    chckbxGetSecureFiles = new JCheckBox("Secure Files");
    chckbxGetSecureFiles.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.SECURITY);
            } else {
                ArgList.remove(SDConstant.SECURITY);
            }
        }
    });
    chckbxGetSecureFiles.setBounds(109, 190, 243, 23);
    contentPane.add(chckbxGetSecureFiles);
    chckbxGetSecureFiles.setOpaque(false);

    chckbxMd5 = new JCheckBox("MD5 Hash Value");
    chckbxMd5.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.MD5);
            } else {
                ArgList.remove(SDConstant.MD5);
            }
        }
    });
    chckbxMd5.setBounds(109, 216, 243, 23);
    contentPane.add(chckbxMd5);
    chckbxMd5.setOpaque(false);

    chckbxDbdetails = new JCheckBox("Datasource Details");
    chckbxDbdetails.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.DATASOURCE);
            } else {
                ArgList.remove(SDConstant.DATASOURCE);
            }
        }
    });
    chckbxDbdetails.setBounds(109, 294, 243, 23);
    contentPane.add(chckbxDbdetails);
    chckbxDbdetails.setOpaque(false);

    chckbxLicense = new JCheckBox("License File");
    chckbxLicense.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.LICENSE);
            } else {
                ArgList.remove(SDConstant.LICENSE);
            }
        }
    });
    chckbxLicense.setBounds(109, 164, 243, 23);
    contentPane.add(chckbxLicense);
    chckbxLicense.setOpaque(false);

    chckbxProcesslist = new JCheckBox("Running Process");
    chckbxProcesslist.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.RUNNING_TASK);
            } else {
                ArgList.remove(SDConstant.RUNNING_TASK);
            }
        }
    });
    chckbxProcesslist.setBounds(109, 242, 243, 23);
    contentPane.add(chckbxProcesslist);
    chckbxProcesslist.setOpaque(false);

    chckbxTomcatxml = new JCheckBox("XML files from Tomcat");
    chckbxTomcatxml.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                tomcatXml = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                tomcatXml = false;
            }
        }
    });
    chckbxTomcatxml.setBounds(377, 242, 248, 23);
    contentPane.add(chckbxTomcatxml);
    chckbxTomcatxml.setOpaque(false);

    chckbxServerXml = new JCheckBox("XML files from Server");
    chckbxServerXml.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                serverXml = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                serverXml = false;
            }
        }
    });
    chckbxServerXml.setBounds(377, 216, 248, 23);
    contentPane.add(chckbxServerXml);
    chckbxServerXml.setOpaque(false);

    chckbxGetBatfiles = new JCheckBox("Start up files from server");
    chckbxGetBatfiles.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                serverBatFile = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                serverBatFile = false;
            }
        }
    });
    chckbxGetBatfiles.setBounds(377, 268, 248, 23);
    contentPane.add(chckbxGetBatfiles);
    chckbxGetBatfiles.setOpaque(false);

    chckbxServerproperties = new JCheckBox("Properites files from server");
    chckbxServerproperties.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                serverProrperties = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                serverProrperties = false;
            }
        }
    });
    chckbxServerproperties.setBounds(377, 294, 248, 23);
    contentPane.add(chckbxServerproperties);
    chckbxServerproperties.setOpaque(false);

    btnNewButton = new JButton("Package");
    btnNewButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent arg0) {

            try {

                if (installType.equalsIgnoreCase("Manual")) {

                    if (prop.getProperty(SDConstant.BI_TOM_PATH) == null) {
                        JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_12, "Inane error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {

                        WEB_XML = new StringBuilder();
                        WEB_XML.append(prop.getProperty(SDConstant.BI_TOM_PATH)).append(File.separator)
                                .append(SDConstant.WEB_APP).append(File.separator).append(SDConstant.PENTAHO)
                                .append(File.separator).append(SDConstant.WEB_INF).append(File.separator)
                                .append(SDConstant.WEB_XML);

                        PENTAHO_SOLU_PATH = getSolutionPath("biserver", WEB_XML.toString());
                        prop.put(SDConstant.PENTAHO_SOLU_PATH, PENTAHO_SOLU_PATH);
                        prop.put(SDConstant.BI_PATH, PENTAHO_SOLU_PATH);
                    }

                }

                if (prop.getProperty(SDConstant.BI_PATH) == null) {
                    JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_1, "Inane error",
                            JOptionPane.ERROR_MESSAGE);
                }
                if (prop.getProperty(SDConstant.BI_TOM_PATH) == null) {
                    JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_12, "Inane error",
                            JOptionPane.ERROR_MESSAGE);
                }
                disableAll();
                setBIServerPath(prop);
                final String data = textFieldBrowser.getText();
                if (!data.equalsIgnoreCase(null)) {
                    ArgList.add(SDConstant.BROWSER);
                }

                String[] array = new String[ArgList.size()];

                int count = 0;
                for (int i = 0; i < ArgList.size(); i++) {

                    String retName = ArgList.get(i);
                    if (retName.equals("file")) {
                        if (count == 0) {
                            array[i] = retName;
                            count++;
                        }
                    } else {
                        array[i] = retName;
                    }

                }

                ApplicationContext context = new ClassPathXmlApplicationContext(SDConstant.SPRNG_FILE_NAME);

                factory = (CofingRetrieverFactory) context.getBean("cofingRetrieverFactory");
                ConfigRetreiver[] config = factory.getConfigRetrevier(array);

                ExecutorService service = Executors.newFixedThreadPool(10);

                for (final ConfigRetreiver configobj : config) {
                    if (null != configobj) {
                        configobj.setBISeverPath(prop);
                        configobj.setServerName("biserver");

                        if (installType.equalsIgnoreCase("Installer")) {
                            configobj.setInstallType("Installer");
                        } else if (installType.equalsIgnoreCase("Archive")) {
                            configobj.setInstallType("Archive");
                        } else if (installType.equalsIgnoreCase("Manual")) {
                            configobj.setInstallType("Manual");
                        }

                        if (configobj instanceof FileRetriever) {
                            configobj.setBidiXml(serverXml);
                            configobj.setBidiBatFile(serverBatFile);
                            configobj.setBidiProrperties(serverProrperties);
                            configobj.setTomcatXml(tomcatXml);
                        }
                        if (configobj instanceof BrowserInfoRetriever) {
                            configobj.setBrowserInfo(data);
                        }

                        service.execute(new Runnable() {
                            public void run() {
                                if (null != configobj)
                                    configobj.readAndSaveConfiguration(prop);
                            }
                        });
                    }
                }
                btnNewButton.setVisible(false);
                progressBar.setVisible(true);
                ProgressThread thread = new ProgressThread();
                thread.setSupport(getSupport());
                thread.setProp(prop);
                new Thread(thread).start();

                service.shutdown();
            } catch (Exception e1) {
                e1.printStackTrace();
            }

        }

    });

    chckbxSelectAll = new JCheckBox("Select/ De-select");
    chckbxSelectAll.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectAll();
            } else {
                deSelectAll();
            }
        }
    });

    chckbxSelectAll.setBounds(46, 138, 201, 23);
    chckbxSelectAll.setOpaque(false);
    contentPane.add(chckbxSelectAll);
    btnNewButton.setForeground(SystemColor.infoText);
    btnNewButton.setBounds(10, 430, 639, 37);
    contentPane.add(btnNewButton);
    chckbxServerproperties.setOpaque(false);

    JLabel lblAttach = new JLabel("Attach Artifact");
    lblAttach.setHorizontalAlignment(SwingConstants.LEFT);
    lblAttach.setBounds(32, 335, 177, 23);
    contentPane.add(lblAttach);
    lblAttach.setOpaque(false);

    JButton btnNewButtonBrowse = new JButton("Browse");
    btnNewButtonBrowse.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            saveSelectedFile(prop);

            JFrame parentFrame = new JFrame();
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setDialogTitle("Specify a file to save");
            fileChooser.setMultiSelectionEnabled(true);

            int userSelection = fileChooser.showSaveDialog(parentFrame);

            if (userSelection == JFileChooser.APPROVE_OPTION) {
                fileToSave = fileChooser.getSelectedFiles();
                for (int i = 0; i < fileToSave.length; i++) {
                    File file = fileToSave[i];
                    String artifactpath = file.getAbsolutePath();

                    File f = new File(artifactpath);
                    String absolutefilename = f.getName();
                    String filename = ArtifactsDirectory.concat(absolutefilename);
                    CopyFile artifactcopy = new CopyFile(artifactpath, filename);
                    try {
                        artifactcopy.copy();
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }

                }
                uploadedFiles();

                rowList = new JList(model);
                listScrollPane.setViewportView(rowList);
                panel.add(listScrollPane);

            }
            rowList.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    lblDelete.setVisible(true);
                }
            });

        }
    });
    btnNewButtonBrowse.setBounds(208, 335, 104, 23);
    contentPane.add(btnNewButtonBrowse);
    btnNewButtonBrowse.setOpaque(false);

    textFieldBrowser = new JTextField();
    textFieldBrowser.setBounds(208, 364, 441, 23);
    contentPane.add(textFieldBrowser);
    textFieldBrowser.setColumns(10);

    progressBar = new JProgressBar(0, 100);
    progressBar.setBounds(8, 437, 639, 24);
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    contentPane.add(progressBar);

    JLabel lblBrowserInformation = new JLabel("Browser Information");
    lblBrowserInformation.setHorizontalAlignment(SwingConstants.LEFT);
    lblBrowserInformation.setLabelFor(textFieldBrowser);
    lblBrowserInformation.setBounds(32, 368, 174, 14);
    contentPane.add(lblBrowserInformation);

    panel = new JPanel();
    panel.setBounds(423, 325, 127, 33);
    contentPane.add(panel);
    panel.setLayout(null);

    listScrollPane = new JScrollPane();
    listScrollPane.setBounds(0, 0, 127, 33);
    panel.add(listScrollPane);

    lblDelete = new JLabel("");
    lblDelete.setBounds(552, 325, 22, 23);
    lblDelete.setVisible(false);
    lblDelete.setIcon(
            new ImageIcon(SDSupportUtility.class.getResource("/org/pentaho/support/standalone/remove.png")));
    contentPane.add(lblDelete);
    lblDelete.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            int option = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this file ?");
            if (option == JOptionPane.YES_OPTION) {
                String sel = rowList.getSelectedValue().toString();
                String selected = dir + "/" + sel;
                File fileExists = new File(selected);
                fileExists.delete();
                model.remove(sel.indexOf(sel));
                lblDelete.setVisible(false);

            }
        }
    });

    JLabel instalType = new JLabel("Installation Type : ");
    instalType.setBounds(32, 395, 177, 23);
    instalType.setVisible(true);
    contentPane.add(instalType);

    ButtonGroup btnGrp = new ButtonGroup();

    rdbtnInstaller = new JRadioButton("Installer");
    rdbtnInstaller.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            installType = "Installer";
        }
    });
    rdbtnInstaller.setBounds(208, 395, 104, 23);
    rdbtnInstaller.setSelected(true);
    contentPane.add(rdbtnInstaller);
    btnGrp.add(rdbtnInstaller);

    rdbtnArchive = new JRadioButton("Archive");
    rdbtnArchive.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            installType = "Archive";
        }
    });
    rdbtnArchive.setBounds(333, 395, 104, 23);
    contentPane.add(rdbtnArchive);
    btnGrp.add(rdbtnArchive);

    rdbtnManual = new JRadioButton("Manual");
    rdbtnManual.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            installType = "Manual";
        }
    });
    rdbtnManual.setBounds(460, 395, 127, 27);
    contentPane.add(rdbtnManual);
    btnGrp.add(rdbtnManual);

    JLabel lblBackground = new JLabel();
    lblBackground.setIcon(new ImageIcon(
            SDSupportUtility.class.getResource("/org/pentaho/support/standalone/login-crystal-bg.jpg")));
    lblBackground.setBackground(SystemColor.controlHighlight);
    lblBackground.setHorizontalAlignment(SwingConstants.CENTER);
    lblBackground.setBounds(0, 0, 659, 488);
    contentPane.add(lblBackground);
}

From source file:com.proyecto.vista.MantenimientoEmpleado.java

private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed
    // TODO add your handling code here:
    accion = Controlador.ELIMINAR;/*w w w.ja v a 2 s.c o  m*/
    if (tblempleado.getSelectedRow() != -1) {

        Integer codigo = tblempleado.getSelectedRow();

        Empleado empleado = empleadoControlador.buscarPorId(lista.get(codigo).getDni());

        if (empleado != null) {
            if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Empleado?", "Mensaje del Sistema",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                int[] filas = tblempleado.getSelectedRows();
                for (int i = 0; i < filas.length; i++) {
                    Empleado empleado2 = lista.get(filas[0]);
                    lista.remove(empleado2);
                    empleadoControlador.setSeleccionado(empleado2);
                    empleadoControlador.accion(accion);
                }
                if (empleadoControlador.accion(accion) == 3) {
                    JOptionPane.showMessageDialog(null, "Empleado eliminado correctamente",
                            "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);

                } else {
                    JOptionPane.showMessageDialog(null, "Empleado no eliminada", "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(null, "Empleado no eliminada", "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    } else {
        JOptionPane.showMessageDialog(null, "Debe seleccionar un Empleado", "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java

private JMenuBar createMenuBar() {
    final JMenuBar menuBar = new JMenuBar();
    JMenuItem mItem = null;//  ww  w.  j av  a2  s . co  m
    String urlString;
    URL url;

    //============================================================================================
    // File Menu
    //============================================================================================
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('f');
    menuBar.add(fileMenu);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-new.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconNew = new ImageIcon(url, "New");
    mItem = new JMenuItem(new NewTextFileAction("New", iconNew));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-open.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconOpen = new ImageIcon(url, "Open");
    mItem = new JMenuItem(new OpenFileAction("Open...", iconOpen, new Integer(KeyEvent.VK_A)));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconSave = new ImageIcon(url, "Save");
    mItem = new JMenuItem(new SaveAction("Save", iconSave, new Integer(KeyEvent.VK_S)));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save-as.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconSaveAs = new ImageIcon(url, "Save As");
    mItem = new JMenuItem(new SaveAsAction("Save As...", iconSaveAs));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/status/folder-visiting.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconClose = new ImageIcon(url, "Close All Tabs");
    mItem = new JMenuItem(new CloseAllTabsAction("Close All Tabs...", iconClose, new Integer(KeyEvent.VK_C)));
    fileMenu.add(mItem);

    fileMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-print.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconPrint = new ImageIcon(url, "Print");
    mItem = new JMenuItem(new PrintAction("Print...", iconPrint));
    fileMenu.add(mItem);

    fileMenu.addSeparator();

    //      exit menu item
    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/system-log-out.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconExit = new ImageIcon(url, "Exit");
    mItem = new JMenuItem(new ExitAction("Exit", iconExit));
    fileMenu.add(mItem);

    //============================================================================================
    // Edit Menu
    //============================================================================================
    JMenu editMenu = new JMenu("Edit");
    editMenu.setMnemonic(KeyEvent.VK_E);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-cut.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconCut = new ImageIcon(url, "Cut");
    mItem = new JMenuItem(new DefaultEditorKit.CutAction());
    mItem.setText("Cut");
    mItem.setIcon(iconCut);
    mItem.setMnemonic(KeyEvent.VK_X);
    editMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-copy.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconCopy = new ImageIcon(url, "Copy");
    mItem = new JMenuItem(new DefaultEditorKit.CopyAction());
    mItem.setText("Copy");
    mItem.setIcon(iconCopy);
    mItem.setMnemonic(KeyEvent.VK_C);
    editMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-paste.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconPaste = new ImageIcon(url, "Paste");
    mItem = new JMenuItem(new DefaultEditorKit.PasteAction());
    mItem.setText("Paste");
    mItem.setIcon(iconPaste);
    mItem.setMnemonic(KeyEvent.VK_V);
    editMenu.add(mItem);

    editMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-undo.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconUndo = new ImageIcon(url, "Undo");
    mItem = new JMenuItem(new UndoAction("Undo", iconUndo, new Integer(KeyEvent.VK_Z)));
    editMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-redo.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconRedo = new ImageIcon(url, "Redo");
    mItem = new JMenuItem(new RedoAction("Redo", iconRedo, new Integer(KeyEvent.VK_Y)));
    editMenu.add(mItem);

    editMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/categories/preferences-system.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconView = new ImageIcon(url, "Preferences");
    mItem = new JMenuItem("Preferences");
    mItem.setIcon(iconView);
    mItem.setToolTipText("Edit jMetrik preferences");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JmetrikPreferencesManager prefs = new JmetrikPreferencesManager();
            prefs.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener());
            prefs.addPropertyChangeListener(statusBar.getStatusListener());
            JmetrikPreferencesDialog propDialog = new JmetrikPreferencesDialog(Jmetrik.this, prefs);
            //                propDialog.loadPreferences();
            propDialog.setVisible(true);
        }
    });
    editMenu.setMnemonic('e');
    editMenu.add(mItem);

    menuBar.add(editMenu);

    //============================================================================================
    // Log Menu
    //============================================================================================
    JMenu logMenu = new JMenu("Log");

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-properties.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconLog = new ImageIcon(url, "View Log");
    mItem = new JMenuItem(new ViewLogAction("View Log", iconLog));
    logMenu.setMnemonic('l');
    logMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/mimetypes/text-x-generic.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconCommand = new ImageIcon(url, "Script Log");
    mItem = new JMenuItem(new ViewScriptLogAction("Script Log", iconCommand));
    logMenu.setMnemonic('c');
    logMenu.add(mItem);

    menuBar.add(logMenu);

    //============================================================================================
    // Manage Menu
    //============================================================================================
    JMenu manageMenu = new JMenu("Manage");
    manageMenu.setMnemonic('m');

    mItem = new JMenuItem("New Database...");//create db
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            NewDatabaseDialog newDatabaseDialog = new NewDatabaseDialog(Jmetrik.this);
            newDatabaseDialog.setVisible(true);
            if (newDatabaseDialog.canRun()) {
                if (workspace == null) {
                    //                        workspace = new Workspace(workspaceTree, tabbedPane, dataTable, variableTable);
                    workspace = new Workspace(workspaceList, tabbedPane, dataTable, variableTable);
                    workspace.addPropertyChangeListener(statusBar.getStatusListener());
                    workspace.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener());
                }
                workspace.runProcess(newDatabaseDialog.getCommand());
                //                    workspace.createDatabase(newDatabaseDialog.getCommand());
            }
        }
    });
    manageMenu.add(mItem);

    mItem = new JMenuItem("Open Database...");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            OpenDatabaseDialog openDbDialog = new OpenDatabaseDialog(Jmetrik.this, "Open");
            JList l = openDbDialog.getDatabaseList();
            workspace.setDatabaseListModel(l);
            openDbDialog.setVisible(true);
            if (openDbDialog.canRun()) {
                openWorkspace(openDbDialog.getDatabaseName());
            }
        }
    });
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDelete = new ImageIcon(url, "Delete");
    mItem = new JMenuItem("Delete Database...");
    mItem.setIcon(iconDelete);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            OpenDatabaseDialog selectDialog = new OpenDatabaseDialog(Jmetrik.this, "Delete");
            JList l = selectDialog.getDatabaseList();
            workspace.setDatabaseListModel(l);
            selectDialog.setVisible(true);
            if (selectDialog.canRun()) {
                int answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                        "Do you want to delete " + selectDialog.getDatabaseName()
                                + " and all of its contents? \n"
                                + "All data will be permanently deleted. You cannot undo this action.",
                        "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);

                if (answer == JOptionPane.YES_OPTION) {
                    DatabaseCommand command = new DatabaseCommand();
                    DatabaseName dbName = new DatabaseName(selectDialog.getDatabaseName());
                    command.getFreeOption("name").add(dbName.getName());
                    command.getSelectOneOption("action").setSelected("delete-db");

                    DatabaseName currentDb = workspace.getDatabaseName();
                    if (currentDb.getName().equals(dbName.getName())) {
                        JOptionPane.showMessageDialog(Jmetrik.this,
                                "You cannot delete the current database.\n"
                                        + "Close the database before attempting to delete it.",
                                "Database Delete Error", JOptionPane.WARNING_MESSAGE);
                    } else {
                        workspace.runProcess(command);
                    }

                }

            }
        }
    });
    manageMenu.add(mItem);

    manageMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/apps/accessories-text-editor.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDesc = new ImageIcon(url, "Descriptions");
    mItem = new JMenuItem("Table Descriptions...");
    mItem.setIcon(iconDesc);
    mItem.addActionListener(new TableDescriptionActionListener());
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/list-add.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconImport = new ImageIcon(url, "Import");
    mItem = new JMenuItem("Import Data...");
    mItem.setIcon(iconImport);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (workspace.databaseOpened()) {
                ImportDialog importDialog = new ImportDialog(Jmetrik.this, workspace.getDatabaseName(),
                        importExportPath);
                importDialog.setVisible(true);

                if (importDialog.canRun()) {
                    importExportPath = importDialog.getCurrentDirectory();
                    workspace.runProcess(importDialog.getCommand());
                }
            } else {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before importing data.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            }

        }
    });
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/format-indent-less.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconExport = new ImageIcon(url, "Export");
    mItem = new JMenuItem("Export Data...");
    mItem.setIcon(iconExport);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            DataTableName tableName = (DataTableName) workspaceList.getSelectedValue();
            if (!workspace.databaseOpened()) {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before exporting data.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            } else if (tableName == null) {
                JOptionPane.showMessageDialog(Jmetrik.this,
                        "You must select a table in the workspace list. \n "
                                + "Select a table to continue the export.",
                        "No Table Selected", JOptionPane.ERROR_MESSAGE);
            } else {
                ExportDataDialog exportDialog = new ExportDataDialog(Jmetrik.this, workspace.getDatabaseName(),
                        tableName, importExportPath);
                if (exportDialog.canRun()) {
                    importExportPath = exportDialog.getCurrentDirectory();
                    workspace.runProcess(exportDialog.getCommand());
                }
            }
        }
    });
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDeleteTable = new ImageIcon(url, "Delete");
    mItem = new JMenuItem("Delete Table...");
    mItem.setIcon(iconDeleteTable);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (workspace.databaseOpened()) {
                DeleteTableDialog deleteDialog = new DeleteTableDialog(Jmetrik.this,
                        workspace.getDatabaseName(), (SortedListModel<DataTableName>) workspaceList.getModel());
                deleteDialog.setVisible(true);
                if (deleteDialog.canRun()) {
                    int nSelected = deleteDialog.getNumberOfSelectedTables();
                    int answer = JOptionPane.NO_OPTION;
                    if (nSelected > 1) {
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete these " + nSelected + " tables? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    } else {
                        ArrayList<DataTableName> dList = deleteDialog.getSelectedTables();
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete the table " + dList.get(0).getTableName() + "? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    }
                    if (answer == JOptionPane.YES_OPTION) {
                        workspace.runProcess(deleteDialog.getCommand());
                    }

                }
            } else {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before deleting a table.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            }

        }
    });
    manageMenu.add(mItem);

    manageMenu.addSeparator();

    SubsetCasesProcess subsetCasesProcess = new SubsetCasesProcess();
    subsetCasesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList);

    SubsetVariablesProcess subsetVariablesProcess = new SubsetVariablesProcess();
    subsetVariablesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDeleteVariables = new ImageIcon(url, "Delete Variables");
    mItem = new JMenuItem("Delete Variables...");
    mItem.setIcon(iconDeleteVariables);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            DataTableName tableName = (DataTableName) workspaceList.getSelectedValue();
            if (!workspace.databaseOpened()) {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before subsetting data.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            } else if (tableName == null) {
                JOptionPane.showMessageDialog(Jmetrik.this,
                        "You must select a table in the workspace list. \n " + "Select a table to continue.",
                        "No Table Selected", JOptionPane.ERROR_MESSAGE);
            } else if (workspace.tableOpen()) {
                DeleteVariableDialog deleteVariableDialog = new DeleteVariableDialog(Jmetrik.this,
                        workspace.getDatabaseName(), workspace.getCurrentDataTable(), workspace.getVariables());
                deleteVariableDialog.setVisible(true);
                if (deleteVariableDialog.canRun()) {
                    int nSelected = deleteVariableDialog.getNumberOfSelectedVariables();
                    int answer = JOptionPane.NO_OPTION;
                    if (nSelected > 1) {
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete these " + nSelected + " variables? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Variables", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    } else {
                        VariableAttributes v = deleteVariableDialog.getSelectedVariable();
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete the variable " + v.getName().toString() + "? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    }
                    if (answer == JOptionPane.YES_OPTION) {
                        workspace.runProcess(deleteVariableDialog.getCommand());
                    }
                }
            }

        }
    });
    manageMenu.add(mItem);

    menuBar.add(manageMenu);

    //============================================================================================
    // Transform Menu
    //============================================================================================
    JMenu transformMenu = new JMenu("Transform");
    transformMenu.setMnemonic('t');

    BasicScoringProcess basicScoringProcess = new BasicScoringProcess();
    basicScoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    ScoringProcess scoringProcess = new ScoringProcess();
    scoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    transformMenu.addSeparator();

    RankingProcess rankingProcess = new RankingProcess();
    rankingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    TestScalingProcess testScalingProcess = new TestScalingProcess();
    testScalingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    LinearTransformationProcess linearTransformationProcess = new LinearTransformationProcess();
    linearTransformationProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    transformMenu.addSeparator();

    IrtLinkingProcess irtLinkingProcess = new IrtLinkingProcess();
    irtLinkingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    IrtEquatingProcess irtEquatingProcess = new IrtEquatingProcess();
    irtEquatingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    menuBar.add(transformMenu);

    //============================================================================================
    // Analyze Menu
    //============================================================================================
    JMenu analyzeMenu = new JMenu("Analyze");
    analyzeMenu.setMnemonic('a');

    FrequencyProcess frequencyProcess = new FrequencyProcess();
    frequencyProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    DescriptiveProcess descriptiveProcess = new DescriptiveProcess();
    descriptiveProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    CorrelationProcess correlationProcess = new CorrelationProcess();
    correlationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    analyzeMenu.addSeparator();

    ItemAnalysisProcess itemAnalysisProcess = new ItemAnalysisProcess();
    itemAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    CmhProcess cmhProcess = new CmhProcess();
    cmhProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    analyzeMenu.addSeparator();

    RaschAnalysisProcess raschAnalysisProcess = new RaschAnalysisProcess();
    raschAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    IrtItemCalibrationProcess irtItemCalibrationProcess = new IrtItemCalibrationProcess();
    irtItemCalibrationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    IrtPersonScoringProcess irtPersonScoringProcess = new IrtPersonScoringProcess();
    irtPersonScoringProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    menuBar.add(analyzeMenu);

    //============================================================================================
    // Graph Menu
    //============================================================================================
    JMenu graphMenu = new JMenu("Graph");
    graphMenu.setMnemonic('g');

    BarChartProcess barchartProcess = new BarChartProcess();
    barchartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    PieChartProcess piechartProcess = new PieChartProcess();
    piechartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    graphMenu.addSeparator();

    HistogramProcess histogramProcess = new HistogramProcess();
    histogramProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    DensityProcess densityProcess = new DensityProcess();
    densityProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    LineChartProcess lineChartProcess = new LineChartProcess();
    lineChartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    ScatterplotProcess scatterplotProcess = new ScatterplotProcess();
    scatterplotProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    graphMenu.addSeparator();

    NonparametricCurveProcess nonparametricCurveProcess = new NonparametricCurveProcess();
    nonparametricCurveProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    mItem = new JMenuItem("Irt Plot...");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            DataTableName tableName = (DataTableName) workspaceList.getSelectedValue();
            if (tableName == null) {
                JOptionPane.showMessageDialog(Jmetrik.this,
                        "You must open a database and select a table. \n "
                                + "Select a table to continue scoring.",
                        "No Table Selected", JOptionPane.ERROR_MESSAGE);
            } else {
                if (irtPlotDialog == null && workspace.tableOpen()) {

                    //Note that starting this dialog is different because variables
                    //names must be obtained from the rows of a table.

                    DatabaseAccessObject dao = workspace.getDatabaseFactory().getDatabaseAccessObject();

                    try {
                        ArrayList<VariableAttributes> tempVar = dao.getVariableAttributesFromColumn(
                                workspace.getConnection(), workspace.getCurrentDataTable(),
                                new VariableName("name"));
                        irtPlotDialog = new IrtPlotDialog(Jmetrik.this, workspace.getDatabaseName(), tableName,
                                tempVar, (SortedListModel<DataTableName>) workspaceList.getModel());
                    } catch (SQLException ex) {
                        logger.fatal(ex.getMessage(), ex);
                        firePropertyChange("error", "", "Error - Check log for details.");
                    }
                }
                if (irtPlotDialog != null)
                    irtPlotDialog.setVisible(true);
            }

            if (irtPlotDialog != null && irtPlotDialog.canRun()) {
                workspace.runProcess(irtPlotDialog.getCommand());
            }
        }
    });
    graphMenu.add(mItem);

    ItemMapProcess itemMapProcess = new ItemMapProcess();
    itemMapProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    menuBar.add(graphMenu);

    //============================================================================================
    // Command Menu
    //============================================================================================

    JMenu commandMenu = new JMenu("Commands");
    commandMenu.setMnemonic('c');
    mItem = new JMenuItem("Run command");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JScrollPane pain = (JScrollPane) tabbedPane.getSelectedComponent();
            JViewport vp = pain.getViewport();
            Component c = vp.getComponent(0);
            if (c instanceof JmetrikTextFile) {
                JmetrikTab tempTab = (JmetrikTab) tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex());
                JmetrikTextFile textFile = (JmetrikTextFile) c;
                workspace.runFromSyntax(textFile.getText());
            }
        }
    });
    commandMenu.add(mItem);

    mItem = new JMenuItem("Stop command");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //add something
        }
    });
    mItem.setEnabled(false);
    commandMenu.add(mItem);

    mItem = new JMenuItem("Command Reference...");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //add something
        }
    });
    mItem.setEnabled(false);
    commandMenu.add(mItem);

    menuBar.add(commandMenu);

    //============================================================================================
    // Help Menu
    //============================================================================================
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic('h');
    mItem = new JMenuItem("Quick Start Guide");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Desktop deskTop = Desktop.getDesktop();
            try {
                URI uri = new URI("http://www.itemanalysis.com/quick-start-guide.php");
                deskTop.browse(uri);
            } catch (URISyntaxException ex) {
                logger.fatal(ex.getMessage(), ex);
                firePropertyChange("error", "", "Error - Check log for details.");
            } catch (IOException ex) {
                logger.fatal(ex.getMessage(), ex);
                firePropertyChange("error", "", "Error - Check log for details.");
            }
        }
    });
    helpMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/apps/help-browser.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconAbout = new ImageIcon(url, "About");
    mItem = new JMenuItem("About");
    mItem.setIcon(iconAbout);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JmetrikAboutDialog aboutDialog = new JmetrikAboutDialog(Jmetrik.this, APP_NAME, VERSION, AUTHOR,
                    RELEASE_DATE, COPYRIGHT_YEAR, BETA_VERSION);
            aboutDialog.setVisible(true);
        }
    });
    helpMenu.add(mItem);

    menuBar.add(helpMenu);

    return menuBar;
}

From source file:de.tor.tribes.ui.views.DSWorkbenchSOSRequestAnalyzer.java

private void copySelectionToClipboardAsBBCode() {
    HashMap<Tribe, SOSRequest> selectedRequests = new HashMap<>();
    List<DefenseInformation> selection = getSelectedRows();
    if (selection.isEmpty()) {
        showInfo("Keine SOS Anfragen eingelesen");
        return;/*from  w ww  .jav a  2  s. c  om*/
    }

    for (DefenseInformation info : selection) {
        Tribe defender = info.getTarget().getTribe();
        SOSRequest request = selectedRequests.get(defender);
        if (request == null) {
            request = new SOSRequest(defender);
            selectedRequests.put(defender, request);
        }
        TargetInformation targetInfo = request.addTarget(info.getTarget());
        targetInfo.merge(info.getTargetInformation());
    }

    try {
        boolean extended = (JOptionPaneHelper.showQuestionConfirmBox(this,
                "Erweiterte BB-Codes verwenden (nur fr Forum und Notizen geeignet)?", "Erweiterter BB-Code",
                "Nein", "Ja") == JOptionPane.YES_OPTION);

        StringBuilder buffer = new StringBuilder();
        if (extended) {
            buffer.append("[u][size=12]SOS Anfragen[/size][/u]\n\n");
        } else {
            buffer.append("[u]SOS Anfragen[/u]\n\n");
        }

        List<SOSRequest> requests = new LinkedList<>();
        CollectionUtils.addAll(requests, selectedRequests.values());
        buffer.append(new SosListFormatter().formatElements(requests, extended));

        if (extended) {
            buffer.append("\n[size=8]Erstellt am ");
            buffer.append(
                    new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime()));
            buffer.append(" mit DS Workbench ");
            buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "[/size]\n");
        } else {
            buffer.append("\nErstellt am ");
            buffer.append(
                    new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime()));
            buffer.append(" mit DS Workbench ");
            buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "\n");
        }

        String b = buffer.toString();
        StringTokenizer t = new StringTokenizer(b, "[");
        int cnt = t.countTokens();
        if (cnt > 1000) {
            if (JOptionPaneHelper.showQuestionConfirmBox(this,
                    "Die momentan vorhandenen Anfragen bentigen mehr als 1000 BB-Codes\n"
                            + "und knnen daher im Spiel (Forum/IGM/Notizen) nicht auf einmal dargestellt werden.\nTrotzdem exportieren?",
                    "Zu viele BB-Codes", "Nein", "Ja") == JOptionPane.NO_OPTION) {
                return;
            }
        }

        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(b), null);
        showSuccess("Daten in Zwischenablage kopiert");
    } catch (Exception e) {
        logger.error("Failed to copy data to clipboard", e);
        showError("Fehler beim Kopieren in die Zwischenablage");
    }

}

From source file:at.tuwien.ifs.feature.evaluation.SimilarityRetrievalGUI.java

private JButton initButtonLoadClassInfo() {
    buttonLoadClassInfo = new JButton("Load class info file");
    buttonLoadClassInfo.setEnabled(false);
    buttonLoadClassInfo.addActionListener(new ActionListener() {
        @Override//from w w  w  .  ja v a2s .  c om
        public void actionPerformed(ActionEvent e) {
            fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fileChooser.setFileFilter(new ExtensionFileFilterSwing(new String[] { "cls", "txt" }));
            if (fileChooser.getSelectedFile() != null) { // reusing the dialog
                fileChooser.setSelectedFile(null);
            }

            // TODO: remove
            fileChooser
                    .setSelectedFile(new File("/data/music/ISMIRgenre/filelist_ISMIRgenre_mp3_wclasses.txt"));

            int returnVal = fileChooser.showDialog(SimilarityRetrievalGUI.this, "Open class information file");
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                try {
                    SOMLibClassInformation clsInfo = new SOMLibClassInformation(
                            fileChooser.getSelectedFile().getAbsolutePath());
                    // Sanity check if all the inputs are in the class info file
                    String[] labels = inputData.get(0).getLabels();
                    ArrayList<String> missingLabels = new ArrayList<String>();
                    for (String label : labels) {
                        if (!clsInfo.hasClassAssignmentForName(label)) {
                            missingLabels.add(label);
                        }
                    }
                    int answer = JOptionPane.YES_OPTION;
                    if (missingLabels.size() > 0) {
                        System.out.println(missingLabels);
                        String missing = StringUtils.toString(missingLabels.toArray(), 5);
                        answer = JOptionPane.showConfirmDialog(SimilarityRetrievalGUI.this,
                                "Class information file '" + fileChooser.getSelectedFile().getAbsolutePath()
                                        + "' is missing the class assignment for " + missingLabels.size()
                                        + " vectors\n    " + missing + "\nContinue loading?",
                                "Missing class assignment", JOptionPane.YES_NO_OPTION);
                    }
                    if (missingLabels.size() == 0 || answer == JOptionPane.YES_OPTION) {
                        classInfo = clsInfo;
                        TableModel model = databaseDetailsTable.getModel();
                        for (int i = 0; i < labels.length; i++) {
                            model.setValueAt(clsInfo.getClassName(labels[i]), i, 2);
                        }
                        resizeDatabaseDetailsTableColumns();
                    }
                } catch (SOMToolboxException e1) {
                    JOptionPane.showMessageDialog(SimilarityRetrievalGUI.this,
                            "Error loading class information file: " + e1.getMessage() + ". Aborting", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    e1.printStackTrace();
                }
            }
        }
    });
    return buttonLoadClassInfo;
}

From source file:jeplus.gui.EPlusEditorPanel.java

private void cmdLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdLoadActionPerformed
    // Confirm save before open another file
    if (this.isContentChanged()) {
        int ans = JOptionPane.showConfirmDialog(this,
                "The contents of " + CurrentFileName
                        + " has been modified. Would you like to save the changes first?",
                "Confirm saving ...", JOptionPane.YES_NO_OPTION);
        if (ans == JOptionPane.YES_OPTION) {
            saveFileContent(this.CurrentFileName, rsTextArea.getText());
        }// www  .java2  s.c om
    }
    // Select a file to open
    if (FC.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        CurrentFileName = FC.getSelectedFile().getPath();
        String name = FC.getSelectedFile().getName();
        // Open idf/imf file
        rsTextArea.setText(getFileContent(CurrentFileName));
        setContentChanged(false);
        this.Title = name;
        notifyContentChange(false);
    }
}

From source file:ar.edu.uns.cs.vyglab.arq.rockar.gui.JFrameControlPanel.java

private void jButtonRemoveActionPerformed(ActionEvent evt) {
    // TODO/*from   www . j ava 2s.  c  om*/
    int row = this.jTableMinerals.getSelectedRow();
    if (row != -1) {
        int response = JOptionPane.showConfirmDialog(this,
                DataCenter.langResource.getString("remove_mineral_conf"));
        if (response == JOptionPane.YES_OPTION) {
            int key = (Integer) this.jTableMineralsModel.getValueAt(row, 0);
            this.jTableMineralsModel.removeRow(row);
            if (DataCenter.minerals.containsKey(key)) {
                DataCenter.minerals.remove(key);
            }
            if (DataCenter.points.containsValue(key)) {
                //TODO algo...con los puntos ya contados con esta clave
                this.updateVisualizations();
            }
            DataCenter.fileMineralList = null; //La tabla en ejecucin ya no es igual a la que se carg
        }
    }
}

From source file:org.csa.rstb.dat.toolviews.HaAlphaPlotPanel.java

@Override
protected boolean checkDataToClipboardCopy() {
    final int warnLimit = 2000;
    final int excelLimit = 65536;
    final int numNonEmptyBins = getNumNonEmptyBins();
    if (numNonEmptyBins > warnLimit) {
        String excelNote = "";
        if (numNonEmptyBins > excelLimit - 100) {
            excelNote = "Note that e.g., Microsoft Excel 2002 only supports a total of " + excelLimit
                    + " rows in a sheet.\n"; /*I18N*/
        }/* w ww  .  j  a v a 2  s. com*/
        final String message = MessageFormat.format("This scatter plot contains {0} non-empty bins.\n"
                + "For each bin, a text data row containing an x, y and z value will be created.\n"
                + "{1}\nPress ''Yes'' if you really want to copy this amount of data to the system clipboard.\n",
                numNonEmptyBins, excelNote);
        final int status = JOptionPane.showConfirmDialog(this, message, /*I18N*/
                "Copy Data to Clipboard", /*I18N*/
                JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
        if (status != JOptionPane.YES_OPTION) {
            return false;
        }
    }
    return true;
}