Example usage for javax.swing JOptionPane INFORMATION_MESSAGE

List of usage examples for javax.swing JOptionPane INFORMATION_MESSAGE

Introduction

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

Prototype

int INFORMATION_MESSAGE

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

Click Source Link

Document

Used for information messages.

Usage

From source file:com.googlecode.bpmn_simulator.gui.BPMNSimulatorFrame.java

private void addDiagrams() {
    final Collection<? extends Diagram<?>> diagrams = currentDefinition.getDiagrams();
    if ((diagrams == null) || diagrams.isEmpty()) {
        JOptionPane.showMessageDialog(this, Messages.getString("containsNoDiagrams"), //$NON-NLS-1$
                Messages.getString("information"), //$NON-NLS-1$
                JOptionPane.INFORMATION_MESSAGE);
    } else {/*from w  ww  .j a v  a  2 s  .  co m*/
        final ScrollDesktopPane desktop = getDesktop();
        for (final Diagram<?> diagram : diagrams) {
            if (diagram != null) {
                final DiagramFrame frame = new DiagramFrame(diagram);
                desktop.add(frame);
                frame.showFrame();
            }
        }
        desktop.arrangeFrames();
    }
}

From source file:de.bfs.radon.omsimulation.gui.OMPanelResults.java

/**
 * Initialises the interface of the results panel.
 *//*from   ww  w  .ja  va2 s .c  om*/
protected void initialize() {
    setLayout(null);

    lblExportChartTo = new JLabel("Export chart to ...");
    lblExportChartTo.setBounds(436, 479, 144, 14);
    lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    lblExportChartTo.setVisible(false);
    add(lblExportChartTo);

    btnMaximize = new JButton("Fullscreen");
    btnMaximize.setBounds(10, 475, 124, 23);
    btnMaximize.setFont(new Font("SansSerif", Font.PLAIN, 11));
    btnMaximize.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (comboBoxSimulations.isEnabled()) {
                if (comboBoxSimulations.getSelectedItem() != null) {
                    JFrame chartFrame = new JFrame();
                    OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem();
                    String title = simulation.toString();
                    DescriptiveStatistics statistics = null;
                    OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem();
                    OMRoomType roomType = null;
                    switch (statisticsType) {
                    case RoomArithmeticMeans:
                        title = "R_AM, " + title;
                        statistics = simulation.getRoomAmDescriptiveStats();
                        roomType = OMRoomType.Room;
                        break;
                    case RoomGeometricMeans:
                        title = "R_GM, " + title;
                        statistics = simulation.getRoomGmDescriptiveStats();
                        roomType = OMRoomType.Room;
                        break;
                    case RoomMedianQ50:
                        title = "R_MED, " + title;
                        statistics = simulation.getRoomMedDescriptiveStats();
                        roomType = OMRoomType.Room;
                        break;
                    case RoomMaxima:
                        title = "R_MAX, " + title;
                        statistics = simulation.getRoomMaxDescriptiveStats();
                        roomType = OMRoomType.Room;
                        break;
                    case CellarArithmeticMeans:
                        title = "C_AM, " + title;
                        statistics = simulation.getCellarAmDescriptiveStats();
                        roomType = OMRoomType.Cellar;
                        break;
                    case CellarGeometricMeans:
                        title = "C_GM, " + title;
                        statistics = simulation.getCellarGmDescriptiveStats();
                        roomType = OMRoomType.Cellar;
                        break;
                    case CellarMedianQ50:
                        title = "C_MED, " + title;
                        statistics = simulation.getCellarMedDescriptiveStats();
                        roomType = OMRoomType.Cellar;
                        break;
                    case CellarMaxima:
                        title = "C_MAX, " + title;
                        statistics = simulation.getCellarMaxDescriptiveStats();
                        roomType = OMRoomType.Cellar;
                        break;
                    default:
                        title = "R_AM, " + title;
                        statistics = simulation.getRoomAmDescriptiveStats();
                        roomType = OMRoomType.Misc;
                        break;
                    }
                    JPanel chartPanel = createDistributionPanel(title, statistics, roomType, false, true, true);
                    chartFrame.getContentPane().add(chartPanel);
                    chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                    chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight());
                    chartFrame.setTitle("OM Simulation Tool: " + title);
                    chartFrame.setResizable(true);
                    chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
                    chartFrame.setVisible(true);
                }
            }
        }
    });
    add(btnMaximize);

    btnCsv = new JButton("CSV");
    btnCsv.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String csv;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("csv")) {
                    csv = "";
                } else {
                    csv = ".csv";
                }
                String csvPath = file.getAbsolutePath() + csv;
                OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem();
                OMCampaign[] campaigns = simulation.getCampaigns();
                File csvFile = new File(csvPath);
                try {
                    FileWriter logWriter = new FileWriter(csvFile);
                    BufferedWriter csvOutput = new BufferedWriter(logWriter);
                    OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem();
                    String head = "";
                    switch (statisticsType) {
                    case RoomArithmeticMeans:
                        head = "R_AM";
                        break;
                    case RoomGeometricMeans:
                        head = "R_GM";
                        break;
                    case RoomMedianQ50:
                        head = "R_MED";
                        break;
                    case RoomMaxima:
                        head = "R_MAX";
                        break;
                    case CellarArithmeticMeans:
                        head = "C_AM";
                        break;
                    case CellarGeometricMeans:
                        head = "C_GM";
                        break;
                    case CellarMedianQ50:
                        head = "C_MED";
                        break;
                    case CellarMaxima:
                        head = "C_MAX";
                        break;
                    default:
                        head = "R_AM";
                        break;
                    }
                    csvOutput.write("\"ID\";\"CAMPAIGN\";\"START\";\"" + head + "\"");
                    csvOutput.newLine();
                    int value = 0;
                    for (int i = 0; i < campaigns.length; i++) {
                        switch (statisticsType) {
                        case RoomArithmeticMeans:
                            value = (int) campaigns[i].getRoomAverage();
                            break;
                        case RoomGeometricMeans:
                            value = (int) campaigns[i].getRoomLogAverage();
                            break;
                        case RoomMedianQ50:
                            value = (int) campaigns[i].getRoomMedian();
                            break;
                        case RoomMaxima:
                            value = (int) campaigns[i].getRoomMaximum();
                            break;
                        case CellarArithmeticMeans:
                            value = (int) campaigns[i].getCellarAverage();
                            break;
                        case CellarGeometricMeans:
                            value = (int) campaigns[i].getCellarLogAverage();
                            break;
                        case CellarMedianQ50:
                            value = (int) campaigns[i].getCellarMedian();
                            break;
                        case CellarMaxima:
                            value = (int) campaigns[i].getCellarMaximum();
                            break;
                        default:
                            value = (int) campaigns[i].getRoomAverage();
                            break;
                        }
                        csvOutput.write("\"" + i + "\";\"" + campaigns[i].getVariation() + "\";\""
                                + campaigns[i].getStart() + "\";\"" + value + "\"");
                        csvOutput.newLine();
                    }
                    JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                    csvOutput.close();
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(null,
                            "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed",
                            JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!",
                        "Failed", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    btnCsv.setBounds(590, 475, 70, 23);
    btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnCsv.setVisible(false);
    add(btnCsv);

    btnPdf = new JButton("PDF");
    btnPdf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String pdf;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("pdf")) {
                    pdf = "";
                } else {
                    pdf = ".pdf";
                }
                String pdfPath = file.getAbsolutePath() + pdf;
                OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem();
                String title = simulation.toString();
                DescriptiveStatistics statistics = null;
                OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem();
                OMRoomType roomType = null;
                switch (statisticsType) {
                case RoomArithmeticMeans:
                    title = "R_AM, " + title;
                    statistics = simulation.getRoomAmDescriptiveStats();
                    roomType = OMRoomType.Room;
                    break;
                case RoomGeometricMeans:
                    title = "R_GM, " + title;
                    statistics = simulation.getRoomGmDescriptiveStats();
                    roomType = OMRoomType.Room;
                    break;
                case RoomMedianQ50:
                    title = "R_MED, " + title;
                    statistics = simulation.getRoomMedDescriptiveStats();
                    roomType = OMRoomType.Room;
                    break;
                case RoomMaxima:
                    title = "R_MAX, " + title;
                    statistics = simulation.getRoomMaxDescriptiveStats();
                    roomType = OMRoomType.Room;
                    break;
                case CellarArithmeticMeans:
                    title = "C_AM, " + title;
                    statistics = simulation.getCellarAmDescriptiveStats();
                    roomType = OMRoomType.Cellar;
                    break;
                case CellarGeometricMeans:
                    title = "C_GM, " + title;
                    statistics = simulation.getCellarGmDescriptiveStats();
                    roomType = OMRoomType.Cellar;
                    break;
                case CellarMedianQ50:
                    title = "C_MED, " + title;
                    statistics = simulation.getCellarMedDescriptiveStats();
                    roomType = OMRoomType.Cellar;
                    break;
                case CellarMaxima:
                    title = "C_MAX, " + title;
                    statistics = simulation.getCellarMaxDescriptiveStats();
                    roomType = OMRoomType.Cellar;
                    break;
                default:
                    title = "R_AM, " + title;
                    statistics = simulation.getRoomAmDescriptiveStats();
                    roomType = OMRoomType.Misc;
                    break;
                }
                JFreeChart chart = OMCharts.createDistributionChart(title, statistics, roomType, false);
                int height = (int) PageSize.A4.getWidth();
                int width = (int) PageSize.A4.getHeight();
                try {
                    OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title);
                    JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(null,
                            "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed",
                            JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!",
                        "Failed", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    btnPdf.setBounds(670, 475, 70, 23);
    btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnPdf.setVisible(false);
    add(btnPdf);

    lblSelectSimulation = new JLabel("Select Simulation");
    lblSelectSimulation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblSelectSimulation.setBounds(10, 65, 132, 14);
    add(lblSelectSimulation);

    lblSelectStatistics = new JLabel("Select Statistics");
    lblSelectStatistics.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblSelectStatistics.setBounds(10, 94, 132, 14);
    add(lblSelectStatistics);

    comboBoxSimulations = new JComboBox<OMSimulation>();
    comboBoxSimulations.setFont(new Font("SansSerif", Font.PLAIN, 11));
    comboBoxSimulations.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent arg0) {
            boolean b = false;
            if (comboBoxSimulations.isEnabled()) {
                if (comboBoxSimulations.getSelectedItem() != null) {
                    b = true;
                    comboBoxStatistics.removeAllItems();
                    comboBoxStatistics.setModel(new DefaultComboBoxModel<OMStatistics>(OMStatistics.values()));
                } else {
                    b = false;
                    comboBoxStatistics.removeAllItems();
                }
            } else {
                b = false;
                comboBoxStatistics.removeAllItems();
            }
            progressBar.setEnabled(b);
            btnPdf.setVisible(b);
            btnCsv.setVisible(b);
            btnMaximize.setVisible(b);
            lblExportChartTo.setVisible(b);
            comboBoxStatistics.setEnabled(b);
            lblSelectStatistics.setEnabled(b);
        }
    });
    comboBoxSimulations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            boolean b = false;
            if (comboBoxSimulations.isEnabled()) {
                if (comboBoxSimulations.getSelectedItem() != null) {
                    b = true;
                    comboBoxStatistics.removeAllItems();
                    comboBoxStatistics.setModel(new DefaultComboBoxModel<OMStatistics>(OMStatistics.values()));
                    comboBoxStatistics.setSelectedIndex(0);
                } else {
                    b = false;
                    comboBoxStatistics.removeAllItems();
                }
            } else {
                b = false;
                comboBoxStatistics.removeAllItems();
            }
            progressBar.setEnabled(b);
            btnPdf.setVisible(b);
            btnCsv.setVisible(b);
            btnMaximize.setVisible(b);
            lblExportChartTo.setVisible(b);
            comboBoxStatistics.setEnabled(b);
            lblSelectStatistics.setEnabled(b);
        }
    });
    comboBoxSimulations.setBounds(152, 61, 454, 22);
    add(comboBoxSimulations);

    btnRefresh = new JButton("Load");
    btnRefresh.setFont(new Font("SansSerif", Font.PLAIN, 11));
    btnRefresh.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (txtOmsFile.getText() != null && !txtOmsFile.getText().equals("")
                    && !txtOmsFile.getText().equals(" ")) {
                txtOmsFile.setBackground(Color.WHITE);
                String omsPath = txtOmsFile.getText();
                String oms;
                String[] tmpFileName = omsPath.split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("oms")) {
                    oms = "";
                } else {
                    oms = ".oms";
                }
                txtOmsFile.setText(omsPath + oms);
                setOmsFile(omsPath + oms);
                File omsFile = new File(omsPath + oms);
                if (omsFile.exists()) {
                    txtOmsFile.setBackground(Color.WHITE);
                    btnRefresh.setEnabled(false);
                    comboBoxSimulations.setEnabled(false);
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    progressBar.setStringPainted(true);
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                    btnPdf.setVisible(false);
                    btnCsv.setVisible(false);
                    btnMaximize.setVisible(false);
                    lblExportChartTo.setVisible(false);
                    refreshSimulationsTask = new RefreshSimulations();
                    refreshSimulationsTask.execute();
                } else {
                    txtOmsFile.setBackground(new Color(255, 222, 222, 128));
                    JOptionPane.showMessageDialog(null, "OMS-file not found, please check the file path!",
                            "Error", JOptionPane.ERROR_MESSAGE);
                }
            } else {
                txtOmsFile.setBackground(new Color(255, 222, 222, 128));
                JOptionPane.showMessageDialog(null, "Please select an OMS-file!", "Warning",
                        JOptionPane.WARNING_MESSAGE);
            }
        }
    });

    comboBoxStatistics = new JComboBox<OMStatistics>();
    comboBoxStatistics.setFont(new Font("SansSerif", Font.PLAIN, 11));
    comboBoxStatistics.setBounds(152, 90, 454, 22);
    comboBoxStatistics.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            updateDistribution();
        }
    });
    add(comboBoxStatistics);

    btnRefresh.setBounds(616, 61, 124, 23);
    add(btnRefresh);

    panelDistribution = new JPanel();
    panelDistribution.setBounds(10, 118, 730, 347);
    add(panelDistribution);

    progressBar = new JProgressBar();
    progressBar.setFont(new Font("SansSerif", Font.PLAIN, 11));
    progressBar.setBounds(10, 475, 730, 23);
    add(progressBar);

    progressBar.setEnabled(false);
    comboBoxStatistics.setEnabled(false);
    lblSelectStatistics.setEnabled(false);
    btnPdf.setVisible(false);
    btnCsv.setVisible(false);
    btnMaximize.setVisible(false);
    lblExportChartTo.setVisible(false);

    lblHelp = new JLabel("Select an OMS-Simulation file to analyse the simulation results and "
            + "display the distribution chart.");
    lblHelp.setForeground(Color.GRAY);
    lblHelp.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblHelp.setBounds(10, 10, 730, 14);
    add(lblHelp);

    lblSelectOms = new JLabel("Open OMS-File");
    lblSelectOms.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblSelectOms.setBounds(10, 36, 132, 14);
    add(lblSelectOms);

    txtOmsFile = new JTextField();
    txtOmsFile.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            setOmsFile(txtOmsFile.getText());
        }
    });
    txtOmsFile.setFont(new Font("SansSerif", Font.PLAIN, 11));
    txtOmsFile.setColumns(10);
    txtOmsFile.setBounds(152, 33, 454, 20);
    add(txtOmsFile);

    buttonBrowse = new JButton("Browse");
    buttonBrowse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.oms", "oms"));
            fileDialog.showOpenDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String oms;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("oms")) {
                    oms = "";
                } else {
                    oms = ".oms";
                }
                txtOmsFile.setText(file.getAbsolutePath() + oms);
                setOmsFile(file.getAbsolutePath() + oms);
            }
        }
    });
    buttonBrowse.setFont(new Font("SansSerif", Font.PLAIN, 11));
    buttonBrowse.setBounds(616, 32, 124, 23);
    add(buttonBrowse);
    progressBar.setVisible(false);
}

From source file:com.diversityarrays.kdxplore.field.FieldViewDialog.java

private void handleFileDrop(Component component, List<File> files, DropLocationInfo dli) {
    Integer column = dli.column;/*from  w w w  . j a  v  a2s.co  m*/
    Integer row = dli.rowOrIndex;

    List<Plot> plots = fieldViewPanel.getFieldLayout().getItemsAt(Arrays.asList(new Point(column, row)));

    System.out.println("Dropped on: col,row=" + column + "," + row);

    List<File> filesAdded = new ArrayList<>();
    for (Plot plot : plots) {
        System.out.println("plot: " + plot.getPlotId() + ": " + plot.getPlotColumn() + "," + plot.getPlotRow());

        List<Specimen> specimens = plot.getSpecimens();
        if (specimens == null || specimens.isEmpty()) {

            try {
                for (File file : files) {
                    File storedFile = copyToMediaStoreDir(file, plot, PlotOrSpecimen.ORGANISM_NUMBER_IS_PLOT);
                    database.addMediaFile(sampleGroupChoiceForNewMedia, trial, plot,
                            PlotOrSpecimen.ORGANISM_NUMBER_IS_PLOT, storedFile);
                    filesAdded.add(file);
                }
            } catch (IOException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(FieldViewDialog.this, e, "Database Error",
                        JOptionPane.ERROR_MESSAGE);
                break;
            }
        } else {
            List<String> plotOrSpecimen = new ArrayList<>();
            Map<String, PlotOrSpecimen> specimenByIdent = new HashMap<>();
            String plotIdent = trial.getPlotIdentOption().createPlotIdentString(plot, ",");
            plotOrSpecimen.add(plotIdent);
            specimenByIdent.put(plotIdent, plot);
            for (Specimen s : specimens) {
                if (PlotOrSpecimen.isSpecimenNumberForSpecimen(s.getSpecimenNumber())) {
                    String ident = "Individual#" + s.getSpecimenNumber();
                    plotOrSpecimen.add(ident);
                    specimenByIdent.put(ident, s);
                }
            }
            Object[] selectionValues = plotOrSpecimen.toArray(new String[plotOrSpecimen.size()]);
            Object initialSelectionValue = null;
            Object chosen = JOptionPane.showInputDialog(FieldViewDialog.this, "Select Plot or Specimen",
                    "Add Attachment", JOptionPane.OK_CANCEL_OPTION, null, selectionValues,
                    initialSelectionValue);
            if (chosen != null) {
                PlotOrSpecimen choice = specimenByIdent.get(chosen);
                if (choice != null) {
                    try {
                        for (File file : files) {
                            File storedFile = copyToMediaStoreDir(file, plot, choice.getSpecimenNumber());
                            database.addMediaFile(sampleGroupChoiceForNewMedia, trial, plot,
                                    choice.getSpecimenNumber(), storedFile);
                            filesAdded.add(file);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(FieldViewDialog.this, e, "Database Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                }
            }
        }
    }

    if (!filesAdded.isEmpty()) {
        String message = filesAdded.stream().map(File::getName).collect(Collectors.joining("\n"));
        JOptionPane.showMessageDialog(FieldViewDialog.this, message, "Attachments Added",
                JOptionPane.INFORMATION_MESSAGE);
    }

}

From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java

/**
 * Creates a new RegistryBrowser object.
 *//*from   w w w . ja  v a  2s. c  om*/
@SuppressWarnings("unchecked")
private RegistryBrowser() {
    instance = this;

    classLoader = getClass().getClassLoader(); // new
    // JAXRBrowserClassLoader(getClass().getClassLoader());
    Thread.currentThread().setContextClassLoader(classLoader);

    /*
     * try { classLoader.loadClass("javax.xml.soap.SOAPMessage"); } catch
     * (ClassNotFoundException e) {
     * log.error("Could not find class javax.xml.soap.SOAPMessage", e); }
     */

    UIManager.addPropertyChangeListener(new UISwitchListener(getRootPane()));

    // add listener for 'locale' bound property
    addPropertyChangeListener(PROPERTY_LOCALE, this);

    menuBar = new JMenuBar();
    fileMenu = new JMenu();
    editMenu = new JMenu();
    viewMenu = new JMenu();
    helpMenu = new JMenu();

    JSeparator JSeparator1 = new JSeparator();
    newItem = new JMenuItem();
    importItem = new JMenuItem();
    saveItem = new JMenuItem();
    saveAsItem = new JMenuItem();
    exitItem = new JMenuItem();
    cutItem = new JMenuItem();
    copyItem = new JMenuItem();
    pasteItem = new JMenuItem();
    aboutItem = new JMenuItem();
    setJMenuBar(menuBar);
    setTitle(resourceBundle.getString("title.registryBrowser.java"));
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    // Scale window to be centered using 70% of screen
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    setBounds((int) (dim.getWidth() * .15), (int) (dim.getHeight() * .1), (int) (dim.getWidth() * .7),
            (int) (dim.getHeight() * .75));
    setVisible(false);
    saveFileDialog.setMode(FileDialog.SAVE);
    saveFileDialog.setTitle(resourceBundle.getString("dialog.save.title"));

    GridBagLayout gb = new GridBagLayout();

    topPanel.setLayout(gb);
    getContentPane().add("North", topPanel);

    GridBagConstraints c = new GridBagConstraints();
    toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
    toolbarPanel.setBounds(0, 0, 488, 29);

    discoveryToolBar = createDiscoveryToolBar();
    toolbarPanel.add(discoveryToolBar);

    // c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    gb.setConstraints(toolbarPanel, c);
    topPanel.add(toolbarPanel);

    // Panel containing context info like registry location and user context
    JPanel contextPanel = new JPanel();
    GridBagLayout gb1 = new GridBagLayout();
    contextPanel.setLayout(gb1);

    locationLabel = new JLabel(resourceBundle.getString("label.registryLocation"));

    // locationLabel.setPreferredSize(new Dimension(80, 23));
    // c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 0, 0);
    gb1.setConstraints(locationLabel, c);

    // contextPanel.setBackground(Color.green);
    contextPanel.add(locationLabel);

    selectAnItemText = new ItemText(selectAnItem);
    registryCombo.addItem(selectAnItemText.toString());

    ConfigurationType uiConfigurationType = UIUtility.getInstance().getConfigurationType();
    RegistryURIListType urlList = uiConfigurationType.getRegistryURIList();

    List<String> urls = urlList.getRegistryURI();
    Iterator<String> urlsIter = urls.iterator();
    while (urlsIter.hasNext()) {
        ItemText url = new ItemText(urlsIter.next());
        registryCombo.addItem(url.toString());
    }

    registryCombo.setEditable(true);
    registryCombo.setEnabled(true);
    registryCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            final String url = (String) registryCombo.getSelectedItem();
            if ((url == null) || (url.equals(selectAnItem))) {
                return;
            }

            // Clean tabbedPaneParent. Will create new content
            tabbedPaneParent.removeAll();
            conceptsTreeDialog = null;
            ConceptsTreeDialog.clearCache();

            // design:
            // 1. connect and construct tabbedPane in a now swing thread
            // 2. add tabbedPane in swing thread
            // 3. call reloadModel that should use WingWorkers
            final SwingWorker worker1 = new SwingWorker(RegistryBrowser.this) {
                public Object doNonUILogic() {
                    try {
                        // Try to connect
                        if (connectToRegistry(url)) {
                            return new JBTabbedPane();
                        }
                    } catch (JAXRException e1) {
                        displayError(e1);
                    }
                    return null;
                }

                public void doUIUpdateLogic() {
                    tabbedPane = (JBTabbedPane) get();
                    if (tabbedPane != null) {
                        tabbedPaneParent.add(tabbedPane, BorderLayout.CENTER);
                        tabbedPane.reloadModel();
                        try {
                            // DBH 1/30/04 - Add the submissions panel if
                            // the user is authenticated.
                            ConnectionImpl connection = RegistryBrowser.client.connection;
                            boolean newValue = connection.isAuthenticated();
                            firePropertyChange(PROPERTY_AUTHENTICATED, false, newValue);
                            getRootPane().updateUI();
                        } catch (JAXRException e1) {
                            displayError(e1);
                        }
                    }
                }
            };
            worker1.start();
        }
    });
    // c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 5, 0);
    gb1.setConstraints(registryCombo, c);
    contextPanel.add(registryCombo);

    JLabel currentUserLabel = new JLabel(resourceBundle.getString("label.currentUser"),
            SwingConstants.TRAILING);
    c.gridx = 2;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    gb1.setConstraints(currentUserLabel, c);

    // contextPanel.add(currentUserLabel);
    currentUserText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            @SuppressWarnings("unused")
            String text = currentUserText.getText();
        }
    });

    currentUserText.setEditable(false);
    c.gridx = 3;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 5, 5);
    gb1.setConstraints(currentUserText, c);

    // contextPanel.add(currentUserText);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 0, 0);
    gb.setConstraints(contextPanel, c);
    topPanel.add(contextPanel, c);

    tabbedPaneParent.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    tabbedPaneParent.setLayout(new BorderLayout());
    tabbedPaneParent.setToolTipText(resourceBundle.getString("tabbedPane.tip"));

    getContentPane().add("Center", tabbedPaneParent);

    fileMenu.setText(resourceBundle.getString("menu.file"));
    fileMenu.setActionCommand("File");
    fileMenu.setMnemonic((int) 'F');
    menuBar.add(fileMenu);

    saveItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    saveItem.setText(resourceBundle.getString("menu.save"));
    saveItem.setActionCommand("Save");
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));
    saveItem.setMnemonic((int) 'S');

    // fileMenu.add(saveItem);
    fileMenu.add(JSeparator1);
    importItem.setText(resourceBundle.getString("menu.import"));
    importItem.setActionCommand("Import");
    importItem.setMnemonic((int) 'I');
    importItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();
            importFromFile();
            RegistryBrowser.setDefaultCursor();
        }
    });
    fileMenu.add(importItem);

    exitItem.setText(resourceBundle.getString("menu.exit"));
    exitItem.setActionCommand("Exit");
    exitItem.setMnemonic((int) 'X');
    fileMenu.add(exitItem);

    editMenu.setText(resourceBundle.getString("menu.edit"));
    editMenu.setActionCommand("Edit");
    editMenu.setMnemonic((int) 'E');

    // menuBar.add(editMenu);
    cutItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    cutItem.setText(resourceBundle.getString("menu.cut"));
    cutItem.setActionCommand("Cut");
    cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
    cutItem.setMnemonic((int) 'T');
    editMenu.add(cutItem);

    copyItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    copyItem.setText(resourceBundle.getString("menu.copy"));
    copyItem.setActionCommand("Copy");
    copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
    copyItem.setMnemonic((int) 'C');
    editMenu.add(copyItem);

    pasteItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    pasteItem.setText(resourceBundle.getString("menu.paste"));
    pasteItem.setActionCommand("Paste");
    pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK));
    pasteItem.setMnemonic((int) 'P');
    editMenu.add(pasteItem);

    viewMenu.setText(resourceBundle.getString("menu.view"));
    viewMenu.setActionCommand("view");
    viewMenu.setMnemonic((int) 'V');

    themeMenu = new MetalThemeMenu(resourceBundle.getString("menu.theme"), themes);
    viewMenu.add(themeMenu);
    menuBar.add(viewMenu);

    helpMenu.setText(resourceBundle.getString("menu.help"));
    helpMenu.setActionCommand("Help");
    helpMenu.setMnemonic((int) 'H');
    menuBar.add(helpMenu);
    aboutItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    aboutItem.setText(resourceBundle.getString("menu.about"));
    aboutItem.setActionCommand("About...");
    aboutItem.setMnemonic((int) 'A');

    aboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object[] aboutArgs = { BROWSER_VERSION };
            MessageFormat form = new MessageFormat(resourceBundle.getString("dialog.about.text"));
            JOptionPane.showMessageDialog(RegistryBrowser.this, form.format(aboutArgs),
                    resourceBundle.getString("dialog.about.title"), JOptionPane.INFORMATION_MESSAGE);
        }
    });

    helpMenu.add(aboutItem);

    // REGISTER_LISTENERS
    SymWindow aSymWindow = new SymWindow();

    this.addWindowListener(aSymWindow);

    SymAction lSymAction = new SymAction();

    saveItem.addActionListener(lSymAction);
    exitItem.addActionListener(lSymAction);

    SwingUtilities.updateComponentTreeUI(getContentPane());
    SwingUtilities.updateComponentTreeUI(menuBar);
    SwingUtilities.updateComponentTreeUI(fileChooser);

    // Auto select the registry that is configured to connect to by default
    String selectedIndexStr = ProviderProperties.getInstance()
            .getProperty("jaxr-ebxml.registryBrowser.registryLocationCombo.initialSelectionIndex", "0");

    int index = Integer.parseInt(selectedIndexStr);

    try {
        registryCombo.setSelectedIndex(index);
    } catch (IllegalArgumentException e) {
        Object[] invalidIndexArguments = { new Integer(index) };
        MessageFormat form = new MessageFormat(resourceBundle.getString("message.error.invalidIndex"));
        displayError(form.format(invalidIndexArguments), e);
    }
}

From source file:de.juwimm.cms.Main.java

public static void showProxies() {
    StringBuffer text = new StringBuffer();
    final String crlf = System.getProperty("line.separator");
    text.append("http.proxyUser=" + System.getProperty("http.proxyUser")).append(crlf);
    text.append("http.proxySet=" + System.getProperty("http.proxySet")).append(crlf);
    text.append("http.proxyHost=" + System.getProperty("http.proxyHost")).append(crlf);
    text.append("http.proxyPort=" + System.getProperty("http.proxyPort")).append(crlf);

    text.append("https.proxySet=" + System.getProperty("https.proxySet")).append(crlf);
    text.append("https.proxyHost=" + System.getProperty("https.proxyHost")).append(crlf);
    text.append("https.proxyPort=" + System.getProperty("https.proxyPort")).append(crlf);

    text.append("proxySet=" + System.getProperty("proxySet")).append(crlf);
    text.append("proxyHost=" + System.getProperty("proxyHost")).append(crlf);
    text.append("proxyPort=" + System.getProperty("proxyPort")).append(crlf);
    log.info(text.toString());/*from w ww.  j av  a 2 s  .c  o  m*/
    JOptionPane.showMessageDialog(null, text.toString(), "Proxy-Info", JOptionPane.INFORMATION_MESSAGE);
}

From source file:dbseer.gui.actions.ExplainChartAction.java

private void savePredicates() {
    DefaultListModel predicateListModel = panel.getControlPanel().getPredicateListModel();
    if (predicateListModel.getSize() == 0) {
        JOptionPane.showMessageDialog(null,
                "There are no predicates to save.\nPlease generate predicates first.", "Warning",
                JOptionPane.WARNING_MESSAGE);
        return;//  w  w w  .  j av a 2  s  . c  o  m
    }
    final StatisticalPackageRunner runner = DBSeerGUI.runner;
    try {
        String cause = (String) JOptionPane.showInputDialog(null, "Enter the cause for predicates ",
                "New Causal Model", JOptionPane.PLAIN_MESSAGE, null, null, "New Causal Model");

        if (cause == null || cause.isEmpty()) {
            JOptionPane.showMessageDialog(null, "Please enter the cause correctly to save the causal model",
                    "Warning", JOptionPane.WARNING_MESSAGE);
            return;
        }

        cause = cause.trim();

        if (cause == "" || cause.isEmpty()) {
            JOptionPane.showMessageDialog(null, "Please enter the cause correctly to save the causal model",
                    "Warning", JOptionPane.WARNING_MESSAGE);
            return;
        }

        String path = cause;
        String actualPath = causalModelPath + File.separator + cause + ".mat";
        boolean exist = false;
        int idx = 0;

        File checkFile = new File(actualPath);
        while (checkFile.exists()) {
            exist = true;
            ++idx;
            actualPath = causalModelPath + File.separator + cause + "-" + idx + ".mat";
            checkFile = new File(actualPath);
        }

        if (exist) {
            path = cause + "-" + idx;
        }

        runner.eval("createCausalModel('" + causalModelPath + "','" + path + "','" + cause + "', predicates);");

        String output = String.format("A causal model with the cause '%s' has been saved as: \n%s", cause,
                actualPath);

        JOptionPane.showMessageDialog(null, output, "Information", JOptionPane.INFORMATION_MESSAGE);

    } catch (Exception e) {
        DBSeerExceptionHandler.handleException(e);
    }
}

From source file:net.sf.jabref.gui.BasePanel.java

private void setupActions() {
    SaveDatabaseAction saveAction = new SaveDatabaseAction(this);
    CleanupAction cleanUpAction = new CleanupAction(this, Globals.prefs);

    actions.put(Actions.UNDO, undoAction);
    actions.put(Actions.REDO, redoAction);

    actions.put(Actions.FOCUS_TABLE, (BaseAction) () -> new FocusRequester(mainTable));

    // The action for opening an entry editor.
    actions.put(Actions.EDIT, (BaseAction) selectionListener::editSignalled);

    // The action for saving a database.
    actions.put(Actions.SAVE, saveAction);

    actions.put(Actions.SAVE_AS, (BaseAction) saveAction::saveAs);

    actions.put(Actions.SAVE_SELECTED_AS, new SaveSelectedAction(SavePreferences.DatabaseSaveType.ALL));

    actions.put(Actions.SAVE_SELECTED_AS_PLAIN,
            new SaveSelectedAction(SavePreferences.DatabaseSaveType.PLAIN_BIBTEX));

    // The action for copying selected entries.
    actions.put(Actions.COPY, (BaseAction) () -> copy());

    //when you modify this action be sure to adjust Actions.DELETE
    //they are the same except of the Localization, delete confirmation and Actions.COPY call
    actions.put(Actions.CUT, (BaseAction) () -> {
        runCommand(Actions.COPY);//w  ww  .  ja  va 2 s .co  m
        List<BibEntry> entries = mainTable.getSelectedEntries();
        if (entries.isEmpty()) {
            return;
        }

        NamedCompound compound = new NamedCompound(
                (entries.size() > 1 ? Localization.lang("cut entries") : Localization.lang("cut entry")));
        for (BibEntry entry : entries) {
            compound.addEdit(new UndoableRemoveEntry(database, entry, BasePanel.this));
            database.removeEntry(entry);
            ensureNotShowingBottomPanel(entry);
        }
        compound.end();
        getUndoManager().addEdit(compound);

        frame.output(formatOutputMessage(Localization.lang("Cut"), entries.size()));
        markBaseChanged();
    });

    //when you modify this action be sure to adjust Actions.CUT,
    //they are the same except of the Localization, delete confirmation and Actions.COPY call
    actions.put(Actions.DELETE, (BaseAction) () -> delete());

    // The action for pasting entries or cell contents.
    //  - more robust detection of available content flavors (doesn't only look at first one offered)
    //  - support for parsing string-flavor clipboard contents which are bibtex entries.
    //    This allows you to (a) paste entire bibtex entries from a text editor, web browser, etc
    //                       (b) copy and paste entries between multiple instances of JabRef (since
    //         only the text representation seems to get as far as the X clipboard, at least on my system)
    actions.put(Actions.PASTE, (BaseAction) () -> paste());

    actions.put(Actions.SELECT_ALL, (BaseAction) mainTable::selectAll);

    // The action for opening the preamble editor
    actions.put(Actions.EDIT_PREAMBLE, (BaseAction) () -> {
        if (preambleEditor == null) {
            PreambleEditor form = new PreambleEditor(frame, BasePanel.this, database);
            form.setLocationRelativeTo(frame);
            form.setVisible(true);
            preambleEditor = form;
        } else {
            preambleEditor.setVisible(true);
        }

    });

    // The action for opening the string editor
    actions.put(Actions.EDIT_STRINGS, (BaseAction) () -> {
        if (stringDialog == null) {
            StringDialog form = new StringDialog(frame, BasePanel.this, database);
            form.setVisible(true);
            stringDialog = form;
        } else {
            stringDialog.setVisible(true);
        }

    });

    // The action for toggling the groups interface
    actions.put(Actions.TOGGLE_GROUPS, (BaseAction) () -> {
        sidePaneManager.toggle("groups");
        frame.groupToggle.setSelected(sidePaneManager.isComponentVisible("groups"));
    });

    // action for collecting database strings from user
    actions.put(Actions.DB_CONNECT, new DbConnectAction(this));

    // action for exporting database to external SQL database
    actions.put(Actions.DB_EXPORT, new AbstractWorker() {

        String errorMessage = "";
        boolean connectedToDB;

        // run first, in EDT:
        @Override
        public void init() {

            DBStrings dbs = bibDatabaseContext.getMetaData().getDBStrings();

            // get DBStrings from user if necessary
            if (dbs.isConfigValid()) {
                connectedToDB = true;
            } else {
                // init DB strings if necessary
                if (!dbs.isInitialized()) {
                    dbs.initialize();
                }

                // show connection dialog
                DBConnectDialog dbd = new DBConnectDialog(frame(), dbs);
                dbd.setLocationRelativeTo(BasePanel.this);
                dbd.setVisible(true);

                connectedToDB = dbd.isConnectedToDB();

                // store database strings
                if (connectedToDB) {
                    dbs = dbd.getDBStrings();
                    bibDatabaseContext.getMetaData().setDBStrings(dbs);
                    dbd.dispose();
                }
            }
        }

        // run second, on a different thread:
        @Override
        public void run() {
            if (!connectedToDB) {
                return;
            }

            final DBStrings dbs = bibDatabaseContext.getMetaData().getDBStrings();

            try {
                frame.output(Localization.lang("Attempting SQL export..."));
                final DBExporterAndImporterFactory factory = new DBExporterAndImporterFactory();
                final DatabaseExporter exporter = factory.getExporter(dbs.getDbPreferences().getServerType());
                exporter.exportDatabaseToDBMS(bibDatabaseContext, getDatabase().getEntries(), dbs, frame);
                dbs.isConfigValid(true);
            } catch (Exception ex) {
                final String preamble = Localization
                        .lang("Could not export to SQL database for the following reason:");
                errorMessage = SQLUtil.getExceptionMessage(ex);
                LOGGER.info("Could not export to SQL database", ex);
                dbs.isConfigValid(false);
                JOptionPane.showMessageDialog(frame, preamble + '\n' + errorMessage,
                        Localization.lang("Export to SQL database"), JOptionPane.ERROR_MESSAGE);
            }

            bibDatabaseContext.getMetaData().setDBStrings(dbs);
        }

        // run third, on EDT:
        @Override
        public void update() {

            // if no error, report success
            if (errorMessage.isEmpty()) {
                if (connectedToDB) {
                    final DBStrings dbs = bibDatabaseContext.getMetaData().getDBStrings();
                    frame.output(Localization.lang("%0 export successful",
                            dbs.getDbPreferences().getServerType().getFormattedName()));
                }
            } else { // show an error dialog if an error occurred
                final String preamble = Localization
                        .lang("Could not export to SQL database for the following reason:");
                frame.output(preamble + "  " + errorMessage);

                JOptionPane.showMessageDialog(frame, preamble + '\n' + errorMessage,
                        Localization.lang("Export to SQL database"), JOptionPane.ERROR_MESSAGE);

                errorMessage = "";
            }
        }

    });

    actions.put(FindUnlinkedFilesDialog.ACTION_COMMAND, (BaseAction) () -> {
        final FindUnlinkedFilesDialog dialog = new FindUnlinkedFilesDialog(frame, frame, BasePanel.this);
        dialog.setLocationRelativeTo(frame);
        dialog.setVisible(true);
    });

    // The action for auto-generating keys.
    actions.put(Actions.MAKE_KEY, new AbstractWorker() {

        List<BibEntry> entries;
        int numSelected;
        boolean canceled;

        // Run first, in EDT:
        @Override
        public void init() {
            entries = getSelectedEntries();
            numSelected = entries.size();

            if (entries.isEmpty()) { // None selected. Inform the user to select entries first.
                JOptionPane.showMessageDialog(frame,
                        Localization.lang("First select the entries you want keys to be generated for."),
                        Localization.lang("Autogenerate BibTeX keys"), JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            frame.block();
            output(formatOutputMessage(Localization.lang("Generating BibTeX key for"), numSelected));
        }

        // Run second, on a different thread:
        @Override
        public void run() {
            BibEntry bes;

            // First check if any entries have keys set already. If so, possibly remove
            // them from consideration, or warn about overwriting keys.
            // This is a partial clone of net.sf.jabref.gui.entryeditor.EntryEditor.GenerateKeyAction.actionPerformed(ActionEvent)
            for (final Iterator<BibEntry> i = entries.iterator(); i.hasNext();) {
                bes = i.next();
                if (bes.getCiteKey() != null) {
                    if (Globals.prefs.getBoolean(JabRefPreferences.AVOID_OVERWRITING_KEY)) {
                        // Remove the entry, because its key is already set:
                        i.remove();
                    } else if (Globals.prefs.getBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY)) {
                        // Ask if the user wants to cancel the operation:
                        CheckBoxMessage cbm = new CheckBoxMessage(
                                Localization.lang("One or more keys will be overwritten. Continue?"),
                                Localization.lang("Disable this confirmation dialog"), false);
                        final int answer = JOptionPane.showConfirmDialog(frame, cbm,
                                Localization.lang("Overwrite keys"), JOptionPane.YES_NO_OPTION);
                        if (cbm.isSelected()) {
                            Globals.prefs.putBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY, false);
                        }
                        if (answer == JOptionPane.NO_OPTION) {
                            // Ok, break off the operation.
                            canceled = true;
                            return;
                        }
                        // No need to check more entries, because the user has already confirmed
                        // that it's ok to overwrite keys:
                        break;
                    }
                }
            }

            Map<BibEntry, Object> oldvals = new HashMap<>();
            // Iterate again, removing already set keys. This is skipped if overwriting
            // is disabled, since all entries with keys set will have been removed.
            if (!Globals.prefs.getBoolean(JabRefPreferences.AVOID_OVERWRITING_KEY)) {
                for (BibEntry entry : entries) {
                    bes = entry;
                    // Store the old value:
                    oldvals.put(bes, bes.getCiteKey());
                    database.setCiteKeyForEntry(bes, null);
                }
            }

            final NamedCompound ce = new NamedCompound(Localization.lang("Autogenerate BibTeX keys"));

            // Finally, set the new keys:
            for (BibEntry entry : entries) {
                bes = entry;
                LabelPatternUtil.makeLabel(bibDatabaseContext.getMetaData(), database, bes, Globals.prefs);
                ce.addEdit(new UndoableKeyChange(database, bes, (String) oldvals.get(bes), bes.getCiteKey()));
            }
            ce.end();
            getUndoManager().addEdit(ce);
        }

        // Run third, on EDT:
        @Override
        public void update() {
            if (canceled) {
                frame.unblock();
                return;
            }
            markBaseChanged();
            numSelected = entries.size();

            ////////////////////////////////////////////////////////////////////////////////
            //          Prevent selection loss for autogenerated BibTeX-Keys
            ////////////////////////////////////////////////////////////////////////////////
            for (final BibEntry bibEntry : entries) {
                SwingUtilities.invokeLater(() -> {
                    final int row = mainTable.findEntry(bibEntry);
                    if ((row >= 0) && (mainTable.getSelectedRowCount() < entries.size())) {
                        mainTable.addRowSelectionInterval(row, row);
                    }
                });
            }
            ////////////////////////////////////////////////////////////////////////////////
            output(formatOutputMessage(Localization.lang("Generated BibTeX key for"), numSelected));
            frame.unblock();
        }
    });

    // The action for cleaning up entry.
    actions.put(Actions.CLEANUP, cleanUpAction);

    actions.put(Actions.MERGE_ENTRIES, (BaseAction) () -> new MergeEntriesDialog(BasePanel.this));

    actions.put(Actions.SEARCH, (BaseAction) searchBar::focus);

    // The action for copying the selected entry's key.
    actions.put(Actions.COPY_KEY, (BaseAction) () -> copyKey());

    // The action for copying a cite for the selected entry.
    actions.put(Actions.COPY_CITE_KEY, (BaseAction) () -> copyCiteKey());

    // The action for copying the BibTeX key and the title for the first selected entry
    actions.put(Actions.COPY_KEY_AND_TITLE, (BaseAction) () -> copyKeyAndTitle());

    actions.put(Actions.MERGE_DATABASE, new AppendDatabaseAction(frame, this));

    actions.put(Actions.ADD_FILE_LINK, new AttachFileAction(this));

    actions.put(Actions.OPEN_EXTERNAL_FILE, (BaseAction) () -> openExternalFile());

    actions.put(Actions.OPEN_FOLDER, (BaseAction) () -> JabRefExecutorService.INSTANCE.execute(() -> {
        final List<File> files = FileUtil.getListOfLinkedFiles(mainTable.getSelectedEntries(),
                bibDatabaseContext.getFileDirectory());
        for (final File f : files) {
            try {
                JabRefDesktop.openFolderAndSelectFile(f.getAbsolutePath());
            } catch (IOException e) {
                LOGGER.info("Could not open folder", e);
            }
        }
    }));

    actions.put(Actions.OPEN_CONSOLE, (BaseAction) () -> JabRefDesktop
            .openConsole(frame.getCurrentBasePanel().getBibDatabaseContext().getDatabaseFile()));

    actions.put(Actions.OPEN_URL, new OpenURLAction());

    actions.put(Actions.MERGE_DOI, (BaseAction) () -> new MergeEntryDOIDialog(BasePanel.this));

    actions.put(Actions.REPLACE_ALL, (BaseAction) () -> {
        final ReplaceStringDialog rsd = new ReplaceStringDialog(frame);
        rsd.setVisible(true);
        if (!rsd.okPressed()) {
            return;
        }
        int counter = 0;
        final NamedCompound ce = new NamedCompound(Localization.lang("Replace string"));
        if (rsd.selOnly()) {
            for (BibEntry be : mainTable.getSelectedEntries()) {
                counter += rsd.replace(be, ce);
            }
        } else {
            for (BibEntry entry : database.getEntries()) {
                counter += rsd.replace(entry, ce);
            }
        }

        output(Localization.lang("Replaced") + ' ' + counter + ' '
                + (counter == 1 ? Localization.lang("occurrence") : Localization.lang("occurrences")) + '.');
        if (counter > 0) {
            ce.end();
            getUndoManager().addEdit(ce);
            markBaseChanged();
        }
    });

    actions.put(Actions.DUPLI_CHECK,
            (BaseAction) () -> JabRefExecutorService.INSTANCE.execute(new DuplicateSearch(BasePanel.this)));

    actions.put(Actions.PLAIN_TEXT_IMPORT, (BaseAction) () -> {
        // get Type of new entry
        EntryTypeDialog etd = new EntryTypeDialog(frame);
        etd.setLocationRelativeTo(BasePanel.this);
        etd.setVisible(true);
        EntryType tp = etd.getChoice();
        if (tp == null) {
            return;
        }

        String id = IdGenerator.next();
        BibEntry bibEntry = new BibEntry(id, tp.getName());
        TextInputDialog tidialog = new TextInputDialog(frame, bibEntry);
        tidialog.setLocationRelativeTo(BasePanel.this);
        tidialog.setVisible(true);

        if (tidialog.okPressed()) {
            UpdateField.setAutomaticFields(Collections.singletonList(bibEntry), false, false);
            insertEntry(bibEntry);
        }
    });

    actions.put(Actions.MARK_ENTRIES, new MarkEntriesAction(frame, 0));

    actions.put(Actions.UNMARK_ENTRIES, (BaseAction) () -> {
        try {
            List<BibEntry> bes = mainTable.getSelectedEntries();
            if (bes.isEmpty()) {
                output(Localization.lang("This operation requires one or more entries to be selected."));
                return;
            }
            NamedCompound ce = new NamedCompound(Localization.lang("Unmark entries"));
            for (BibEntry be : bes) {
                EntryMarker.unmarkEntry(be, false, database, ce);
            }
            ce.end();
            getUndoManager().addEdit(ce);
            markBaseChanged();
            String outputStr;
            if (bes.size() == 1) {
                outputStr = Localization.lang("Unmarked selected entry");
            } else {
                outputStr = Localization.lang("Unmarked all %0 selected entries", Integer.toString(bes.size()));
            }
            output(outputStr);
        } catch (Throwable ex) {
            LOGGER.warn("Could not unmark", ex);
        }
    });

    actions.put(Actions.UNMARK_ALL, (BaseAction) () -> {
        NamedCompound ce = new NamedCompound(Localization.lang("Unmark all"));

        for (BibEntry be : database.getEntries()) {
            EntryMarker.unmarkEntry(be, false, database, ce);
        }
        ce.end();
        getUndoManager().addEdit(ce);
        markBaseChanged();
        output(Localization.lang("Unmarked all entries"));
    });

    // Note that we can't put the number of entries that have been reverted into the undoText as the concrete number cannot be injected
    actions.put(Relevance.getInstance().getValues().get(0).getActionName(),
            new SpecialFieldAction(frame, Relevance.getInstance(),
                    Relevance.getInstance().getValues().get(0).getFieldValue().get(), true,
                    Localization.lang("Toggle relevance")));
    actions.put(Quality.getInstance().getValues().get(0).getActionName(),
            new SpecialFieldAction(frame, Quality.getInstance(),
                    Quality.getInstance().getValues().get(0).getFieldValue().get(), true,
                    Localization.lang("Toggle quality assured")));
    actions.put(Printed.getInstance().getValues().get(0).getActionName(),
            new SpecialFieldAction(frame, Printed.getInstance(),
                    Printed.getInstance().getValues().get(0).getFieldValue().get(), true,
                    Localization.lang("Toggle print status")));

    for (SpecialFieldValue prio : Priority.getInstance().getValues()) {
        actions.put(prio.getActionName(), prio.getAction(this.frame));
    }
    for (SpecialFieldValue rank : Rank.getInstance().getValues()) {
        actions.put(rank.getActionName(), rank.getAction(this.frame));
    }
    for (SpecialFieldValue status : ReadStatus.getInstance().getValues()) {
        actions.put(status.getActionName(), status.getAction(this.frame));
    }

    actions.put(Actions.TOGGLE_PREVIEW, (BaseAction) () -> {
        boolean enabled = !Globals.prefs.getBoolean(JabRefPreferences.PREVIEW_ENABLED);
        Globals.prefs.putBoolean(JabRefPreferences.PREVIEW_ENABLED, enabled);
        setPreviewActiveBasePanels(enabled);
        frame.setPreviewToggle(enabled);
    });

    actions.put(Actions.TOGGLE_HIGHLIGHTS_GROUPS_MATCHING_ANY, (BaseAction) () -> {
        new HighlightMatchingGroupPreferences(Globals.prefs).setToAny();
        // ping the listener so it updates:
        groupsHighlightListener.listChanged(null);
    });

    actions.put(Actions.TOGGLE_HIGHLIGHTS_GROUPS_MATCHING_ALL, (BaseAction) () -> {
        new HighlightMatchingGroupPreferences(Globals.prefs).setToAll();
        // ping the listener so it updates:
        groupsHighlightListener.listChanged(null);
    });

    actions.put(Actions.TOGGLE_HIGHLIGHTS_GROUPS_MATCHING_DISABLE, (BaseAction) () -> {
        new HighlightMatchingGroupPreferences(Globals.prefs).setToDisabled();
        // ping the listener so it updates:
        groupsHighlightListener.listChanged(null);
    });

    actions.put(Actions.SWITCH_PREVIEW, (BaseAction) selectionListener::switchPreview);

    actions.put(Actions.MANAGE_SELECTORS, (BaseAction) () -> {
        ContentSelectorDialog2 csd = new ContentSelectorDialog2(frame, frame, BasePanel.this, false, null);
        csd.setLocationRelativeTo(frame);
        csd.setVisible(true);
    });

    actions.put(Actions.EXPORT_TO_CLIPBOARD, new ExportToClipboardAction(frame));
    actions.put(Actions.SEND_AS_EMAIL, new SendAsEMailAction(frame));

    actions.put(Actions.WRITE_XMP, new WriteXMPAction(this));

    actions.put(Actions.ABBREVIATE_ISO, new AbbreviateAction(this, true));
    actions.put(Actions.ABBREVIATE_MEDLINE, new AbbreviateAction(this, false));
    actions.put(Actions.UNABBREVIATE, new UnabbreviateAction(this));
    actions.put(Actions.AUTO_SET_FILE, new SynchronizeFileField(this));

    actions.put(Actions.BACK, (BaseAction) BasePanel.this::back);
    actions.put(Actions.FORWARD, (BaseAction) BasePanel.this::forward);

    actions.put(Actions.RESOLVE_DUPLICATE_KEYS, new SearchFixDuplicateLabels(this));

    actions.put(Actions.ADD_TO_GROUP, new GroupAddRemoveDialog(this, true, false));
    actions.put(Actions.REMOVE_FROM_GROUP, new GroupAddRemoveDialog(this, false, false));
    actions.put(Actions.MOVE_TO_GROUP, new GroupAddRemoveDialog(this, true, true));

    actions.put(Actions.DOWNLOAD_FULL_TEXT, new FindFullTextAction(this));
}

From source file:com.ln.gui.Main.java

@SuppressWarnings("unchecked")
public Main() {// w w  w .  ja v  a2  s .c o  m
    System.gc();
    setIconImage(Toolkit.getDefaultToolkit().getImage(Configuration.mydir + "\\resources\\icons\\ln6464.png"));
    DateFormat dd = new SimpleDateFormat("dd");
    DateFormat dh = new SimpleDateFormat("HH");
    DateFormat dm = new SimpleDateFormat("mm");
    Date day = new Date();
    Date hour = new Date();
    Date minute = new Date();
    dayd = Integer.parseInt(dd.format(day));
    hourh = Integer.parseInt(dh.format(hour));
    minutem = Integer.parseInt(dm.format(minute));
    setTitle("Liquid Notify Revision 2");
    Description.setBackground(Color.WHITE);
    Description.setContentType("text/html");
    Description.setEditable(false);
    Getcalendar.Main();
    HyperlinkListener hyperlinkListener = new ActivatedHyperlinkListener(f, Description);
    Description.addHyperlinkListener(hyperlinkListener);
    //Add components
    setContentPane(contentPane);
    setJMenuBar(menuBar);
    contentPane.setLayout(
            new MigLayout("", "[220px:230.00:220,grow][209.00px:n:5000,grow]", "[22px][][199.00,grow][grow]"));
    eventsbtn.setToolTipText("Displays events currently set to notify");
    eventsbtn.setMinimumSize(new Dimension(220, 23));
    eventsbtn.setMaximumSize(new Dimension(220, 23));
    contentPane.add(eventsbtn, "cell 0 0");
    NewsArea.setBackground(Color.WHITE);
    NewsArea.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.DARK_GRAY,
            Color.DARK_GRAY));
    NewsArea.setMinimumSize(new Dimension(20, 22));
    NewsArea.setMaximumSize(new Dimension(10000, 22));
    contentPane.add(NewsArea, "cell 1 0,growx,aligny top");
    menuBar.add(File);
    JMenuItem Settings = new JMenuItem("Settings");
    Settings.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\settings.png"));
    Settings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Settings setup = new Settings();
            setup.setVisible(true);
            setup.setLocationRelativeTo(rootPane);
        }
    });
    File.add(Settings);
    File.add(mntmNewMenuItem);
    Tray.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\ln1616.png"));
    File.add(Tray);
    Exit.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\exit.png"));
    File.add(Exit);

    menuBar.add(mnNewMenu);

    Update.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\update.png"));
    Update.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                URL localURL = new URL("http://jiiks.net23.net/tlnotify/online.html");
                URLConnection localURLConnection = localURL.openConnection();
                BufferedReader localBufferedReader = new BufferedReader(
                        new InputStreamReader(localURLConnection.getInputStream()));
                String str = localBufferedReader.readLine();
                if (!str.contains("YES")) {
                    String st2221 = "Updates server appears to be offline";
                    JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE,
                            JOptionPane.DEFAULT_OPTION);
                    JDialog dialog1 = pane1.createDialog("Update");
                    dialog1.setLocationRelativeTo(null);
                    dialog1.setVisible(true);
                    dialog1.setAlwaysOnTop(true);
                } else if (str.contains("YES")) {
                    URL localURL2 = new URL("http://jiiks.net23.net/tlnotify/latestversion.html");
                    URLConnection localURLConnection1 = localURL2.openConnection();
                    BufferedReader localBufferedReader2 = new BufferedReader(
                            new InputStreamReader(localURLConnection1.getInputStream()));
                    String str2 = localBufferedReader2.readLine();
                    Updatechecker.latestver = str2;
                    if (Integer.parseInt(str2) <= Configuration.version) {
                        String st2221 = "No updates available =(";
                        JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE,
                                JOptionPane.DEFAULT_OPTION);
                        JDialog dialog1 = pane1.createDialog("Update");
                        dialog1.setLocationRelativeTo(null);
                        dialog1.setVisible(true);
                        dialog1.setAlwaysOnTop(true);
                    } else if (Integer.parseInt(str2) > Configuration.version) {
                        String st2221 = "Updates available!";
                        JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE,
                                JOptionPane.DEFAULT_OPTION);
                        JDialog dialog1 = pane1.createDialog("Update");
                        dialog1.setLocationRelativeTo(null);
                        dialog1.setVisible(true);
                        dialog1.setAlwaysOnTop(true);

                        Updatechecker upd = new Updatechecker();
                        upd.setVisible(true);
                        upd.setLocationRelativeTo(rootPane);
                        upd.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
                    }
                }
            } catch (MalformedURLException e1) {
                e1.printStackTrace();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

        }

    });
    mnNewMenu.add(Update);
    JMenuItem About = new JMenuItem("About");
    About.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\about.png"));
    About.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            About a = new About();
            a.setVisible(true);
            a.setLocationRelativeTo(rootPane);
            a.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        }
    });
    mnNewMenu.add(About);
    JMenuItem Github = new JMenuItem("Github");
    Github.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\github.png"));
    Github.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String url = "https://github.com/Jiiks/Liquid-Notify-Rev2";
            try {
                java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
    });
    mnNewMenu.add(Github);
    JMenuItem Thread = new JMenuItem("Thread");
    Thread.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\liquid.png"));
    Thread.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String url = "http://www.teamliquid.net/forum/viewmessage.php?topic_id=318184";
            try {
                java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
    });
    mnNewMenu.add(Thread);
    Refreshbtn.setToolTipText("Refreshes calendar, please don't spam ^_^");
    Refreshbtn.setPreferredSize(new Dimension(90, 20));
    Refreshbtn.setMinimumSize(new Dimension(100, 20));
    Refreshbtn.setMaximumSize(new Dimension(100, 20));
    contentPane.add(Refreshbtn, "flowx,cell 0 1,alignx left");
    //Components to secondary panel   
    Titlebox = new JComboBox();
    contentPane.add(Titlebox, "cell 1 1,growx,aligny top");
    Titlebox.setMinimumSize(new Dimension(20, 20));
    Titlebox.setMaximumSize(new Dimension(10000, 20));
    //Set other
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 686, 342);
    contentPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    NewsArea.setEnabled(false);
    NewsArea.setEditable(false);
    NewsArea.setText("News: " + News);
    contentPane.add(panel, "cell 0 2,grow");
    panel.setLayout(null);
    final JCalendar calendar = new JCalendar();
    calendar.getMonthChooser().setPreferredSize(new Dimension(120, 20));
    calendar.getMonthChooser().setMinimumSize(new Dimension(120, 24));
    calendar.getYearChooser().setLocation(new Point(20, 0));
    calendar.getYearChooser().setMaximum(100);
    calendar.getYearChooser().setMaximumSize(new Dimension(100, 2147483647));
    calendar.getYearChooser().setMinimumSize(new Dimension(50, 20));
    calendar.getYearChooser().setPreferredSize(new Dimension(50, 20));
    calendar.getYearChooser().getSpinner().setPreferredSize(new Dimension(100, 20));
    calendar.getYearChooser().getSpinner().setMinimumSize(new Dimension(100, 20));
    calendar.getMonthChooser().getSpinner().setPreferredSize(new Dimension(119, 20));
    calendar.getMonthChooser().getSpinner().setMinimumSize(new Dimension(120, 24));
    calendar.getDayChooser().getDayPanel().setFont(new Font("Tahoma", Font.PLAIN, 11));
    calendar.setDecorationBordersVisible(true);
    calendar.setTodayButtonVisible(true);
    calendar.setBackground(Color.LIGHT_GRAY);
    calendar.setBounds(0, 0, 220, 199);
    calendar.getDate();
    calendar.setWeekOfYearVisible(false);
    calendar.setDecorationBackgroundVisible(false);
    calendar.setMaxDayCharacters(2);
    calendar.getDayChooser().setFont(new Font("Tahoma", Font.PLAIN, 10));
    panel.add(calendar);
    Descriptionscrollpane.setLocation(new Point(100, 100));
    Descriptionscrollpane.setMaximumSize(new Dimension(10000, 10000));
    Descriptionscrollpane.setMinimumSize(new Dimension(20, 200));
    Description.setLocation(new Point(100, 100));
    Description.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.LIGHT_GRAY,
            Color.DARK_GRAY, Color.DARK_GRAY));
    Description.setMaximumSize(new Dimension(1000, 400));
    Description.setMinimumSize(new Dimension(400, 200));
    contentPane.add(Descriptionscrollpane, "cell 1 2 1 2,growx,aligny top");
    Descriptionscrollpane.setViewportView(Description);
    verticalStrut.setMinimumSize(new Dimension(12, 20));
    contentPane.add(verticalStrut, "cell 0 1");
    Notify.setToolTipText("Adds selected event to notify event list.");
    Notify.setHorizontalTextPosition(SwingConstants.CENTER);
    Notify.setPreferredSize(new Dimension(100, 20));
    Notify.setMinimumSize(new Dimension(100, 20));
    Notify.setMaximumSize(new Dimension(100, 20));
    contentPane.add(Notify, "cell 0 1,alignx right");
    calendar.getMonthChooser().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            month = calendar.getMonthChooser().getMonth();
            Parser.parse();
        }
    });

    calendar.getDayChooser().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            try {
                int h = calendar.getMonthChooser().getMonth();
                @SuppressWarnings("deprecation")
                int date = calendar.getDate().getDate();
                int month = calendar.getMonthChooser().getMonth() + 1;
                globmonth = calendar.getMonthChooser().getMonth();
                sdate = date;
                datestring = Integer.toString(sdate);
                monthstring = Integer.toString(month);
                String[] Hours = Betaparser.Hours;
                String[] Titles = Betaparser.STitle;
                String[] Full = new String[Hours.length];
                String[] Minutes = Betaparser.Minutes;
                String[] Des = Betaparser.Description;
                String[] Des2 = new String[Betaparser.Description.length];
                String Seconds = "00";
                String gg;
                int[] IntHours = new int[Hours.length];
                int[] IntMins = new int[Hours.length];
                int Events = 0;
                monthday = monthstring + "|" + datestring + "|";
                Titlebox.removeAllItems();
                for (int a = 0; a != Hours.length; a++) {
                    IntHours[a] = Integer.parseInt(Hours[a]);
                    IntMins[a] = Integer.parseInt(Minutes[a]);
                }
                for (int i1 = 0; i1 != Hours.length; i1++) {
                    if (Betaparser.Events[i1].startsWith(monthday)) {
                        Full[i1] = String.format("%02d:%02d", IntHours[i1], IntMins[i1]) + " | " + Titles[i1];
                        Titlebox.addItem(Full[i1]);
                    }
                }
            } catch (Exception e1) {
                //Catching mainly due to boot property change            
            }
        }
    });
    Image image = Toolkit.getDefaultToolkit().getImage(Configuration.mydir + "\\resources\\icons\\ln1616.png");
    final SystemTray tray = SystemTray.getSystemTray();
    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(true);
        }
    };
    PopupMenu popup = new PopupMenu();
    MenuItem defaultItem = new MenuItem();
    defaultItem.addActionListener(listener);
    TrayIcon trayIcon = null;
    trayIcon = new TrayIcon(image, "LiquidNotify Revision 2", popup);

    trayIcon.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            setVisible(true);
        }
    });//
    try {
        tray.add(trayIcon);
    } catch (AWTException e) {
        System.err.println(e);
    }
    if (trayIcon != null) {
        trayIcon.setImage(image);
    }

    Tray.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    });

    Titlebox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Descparser.parsedesc();
        }
    });

    Refreshbtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Getcalendar.Main();
            Descparser.parsedesc();
        }
    });

    Notify.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            NOTIFY = Descparser.TTT;
            NOTIFYD = Descparser.DDD;
            NOTIFYH = Descparser.HHH;
            NOTIFYM = Descparser.MMM;
            int i = events;
            NOA[i] = NOTIFY;
            NOD[i] = NOTIFYD;
            NOH[i] = NOTIFYH;
            NOM[i] = NOTIFYM;
            Eventlist[i] = "Starts in: " + Integer.toString(NOD[i]) + " Days " + Integer.toString(NOH[i])
                    + " Hours " + Integer.toString(NOM[i]) + " Minutes " + " | " + NOA[i];
            events = events + 1;
            Notifylist si = new Notifylist();
            si.setVisible(false);
            si.setBounds(1, 1, 1, 1);
            si.dispose();
            if (thread.getState().name().equals("PENDING")) {
                thread.execute();
            }
        }
    });
    eventsbtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Notifylist list = new Notifylist();
            if (played == 1) {
                asd.close();
                played = 0;
            }
            list.setVisible(true);
            list.setLocationRelativeTo(rootPane);
            list.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        }
    });

    mntmNewMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (thread.getState().name().equals("PENDING")) {
                thread.execute();
            }
            Userstreams us = new Userstreams();
            us.setVisible(true);
            us.setLocationRelativeTo(rootPane);
        }
    });

    Exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            //Absolute exit
            JOptionPane.showMessageDialog(rootPane, "Bye bye :(", "Exit", JOptionPane.INFORMATION_MESSAGE);
            Runtime ln = Runtime.getRuntime();
            ln.gc();
            final Frame[] allf = Frame.getFrames();
            final Window[] allw = Window.getWindows();
            for (final Window allwindows : allw) {
                allwindows.dispose();
            }
            for (final Frame allframes : allf) {
                allframes.dispose();
                System.exit(0);
            }
        }
    });
}

From source file:userInteface.Patient.ManageVitalSignsJPanel.java

private void deleteVitalSignJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteVitalSignJButtonActionPerformed
    // TODO add your handling code here:
    int selectedRow = viewPatientsJTable.getSelectedRow();
    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(this, "Please select a row from table.");
        return;//  w  w w  .j  av a  2 s  .  com
    }
    Person person = (Person) viewPatientsJTable.getValueAt(selectedRow, 0);
    Patient patient = person.getPatient();
    if (patient == null) {
        JOptionPane.showMessageDialog(this, "Patient not created, Please create Patient first.", "Error",
                JOptionPane.ERROR_MESSAGE);
        return;
    }

    selectedRow = viewVitalSignsJTable.getSelectedRow();
    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(this, "Please select a row from table.", "Error",
                JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    VitalSign vitalSign = (VitalSign) viewVitalSignsJTable.getValueAt(selectedRow, 0);

    int flag = JOptionPane.showConfirmDialog(this, "Are you sure want to remove?", "Warning",
            JOptionPane.YES_NO_OPTION);
    if (flag == 0) {
        patient.getVitalSignHistory().deleteVitalSign(vitalSign);
        refreshVialSigns();
    }
}

From source file:com.proyecto.vista.MantenimientoFactura.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  .  java 2s.co m
    if (tblFactura.getSelectedRow() != -1) {

        Integer codigo = tblFactura.getSelectedRow();

        Factura factura = facturaControlador.buscarPorId(lista.get(codigo).getId());

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

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

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