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:net.pms.newgui.NavigationShareTab.java

private void initSimpleComponents(CellConstraints cc) {
    // Thumbnail seeking position
    seekpos = new JTextField("" + configuration.getThumbnailSeekPos());
    seekpos.addKeyListener(new KeyAdapter() {
        @Override//from  w  w  w  . ja  v  a  2 s .  c  o  m
        public void keyReleased(KeyEvent e) {
            try {
                int ab = Integer.parseInt(seekpos.getText());
                configuration.setThumbnailSeekPos(ab);
                if (configuration.getUseCache()) {
                    PMS.get().getDatabase().init(true);
                }
            } catch (NumberFormatException nfe) {
                LOGGER.debug("Could not parse thumbnail seek position from \"" + seekpos.getText() + "\"");
            }

        }
    });
    if (configuration.isThumbnailGenerationEnabled()) {
        seekpos.setEnabled(true);
    } else {
        seekpos.setEnabled(false);
    }

    // Generate thumbnails
    thumbgenCheckBox = new JCheckBox(Messages.getString("NetworkTab.2"),
            configuration.isThumbnailGenerationEnabled());
    thumbgenCheckBox.setContentAreaFilled(false);
    thumbgenCheckBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setThumbnailGenerationEnabled((e.getStateChange() == ItemEvent.SELECTED));
            seekpos.setEnabled(configuration.isThumbnailGenerationEnabled());
            mplayer_thumb.setEnabled(configuration.isThumbnailGenerationEnabled());
        }
    });

    // Use MPlayer for video thumbnails
    mplayer_thumb = new JCheckBox(Messages.getString("FoldTab.14"), configuration.isUseMplayerForVideoThumbs());
    mplayer_thumb.setToolTipText(Messages.getString("FoldTab.61"));
    mplayer_thumb.setContentAreaFilled(false);
    mplayer_thumb.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setUseMplayerForVideoThumbs((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    if (configuration.isThumbnailGenerationEnabled()) {
        mplayer_thumb.setEnabled(true);
    } else {
        mplayer_thumb.setEnabled(false);
    }

    // DVD ISO thumbnails
    dvdiso_thumb = new JCheckBox(Messages.getString("FoldTab.19"), configuration.isDvdIsoThumbnails());
    dvdiso_thumb.setContentAreaFilled(false);
    dvdiso_thumb.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setDvdIsoThumbnails((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Image thumbnails
    image_thumb = new JCheckBox(Messages.getString("FoldTab.21"), configuration.getImageThumbnailsEnabled());
    image_thumb.setContentAreaFilled(false);
    image_thumb.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setImageThumbnailsEnabled((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Audio thumbnails import
    final KeyedComboBoxModel<CoverSupplier, String> thumbKCBM = new KeyedComboBoxModel<>(
            new CoverSupplier[] { CoverSupplier.NONE, CoverSupplier.COVER_ART_ARCHIVE },
            new String[] { Messages.getString("FoldTab.35"), Messages.getString("FoldTab.73") });
    audiothumbnail = new JComboBox<>(thumbKCBM);
    audiothumbnail.setEditable(false);

    thumbKCBM.setSelectedKey(configuration.getAudioThumbnailMethod());

    audiothumbnail.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setAudioThumbnailMethod(thumbKCBM.getSelectedKey());
                LOGGER.info("Setting {} {}", Messages.getRootString("FoldTab.26"),
                        thumbKCBM.getSelectedValue());
            }
        }
    });

    // Alternate video cover art folder
    defaultThumbFolder = new JTextField(configuration.getAlternateThumbFolder());
    defaultThumbFolder.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setAlternateThumbFolder(defaultThumbFolder.getText());
        }
    });

    // Alternate video cover art folder button
    select = new CustomJButton("...");
    select.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser;
            try {
                chooser = new JFileChooser();
            } catch (Exception ee) {
                chooser = new JFileChooser(new RestrictedFileSystemView());
            }
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString("FoldTab.28"));
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                defaultThumbFolder.setText(chooser.getSelectedFile().getAbsolutePath());
                configuration.setAlternateThumbFolder(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });

    // Show Server Settings folder
    isShowFolderServerSettings = new JCheckBox(Messages.getString("FoldTab.ShowServerSettingsFolder"),
            configuration.isShowServerSettingsFolder());
    isShowFolderServerSettings.setContentAreaFilled(false);
    isShowFolderServerSettings.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setShowServerSettingsFolder((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Show #--TRANSCODE--# folder
    isShowFolderTranscode = new JCheckBox(Messages.getString("FoldTab.ShowTranscodeFolder"),
            configuration.isShowTranscodeFolder());
    isShowFolderTranscode.setContentAreaFilled(false);
    isShowFolderTranscode.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setShowTranscodeFolder((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Show Media Library folder
    isShowFolderMediaLibrary = new JCheckBox(Messages.getString("FoldTab.ShowMediaLibraryFolder"),
            configuration.isShowMediaLibraryFolder());
    isShowFolderMediaLibrary.setContentAreaFilled(false);
    isShowFolderMediaLibrary.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setShowMediaLibraryFolder((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Browse compressed archives
    archive = new JCheckBox(Messages.getString("NetworkTab.1"), configuration.isArchiveBrowsing());
    archive.setContentAreaFilled(false);
    archive.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setArchiveBrowsing(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    // Enable the Media Library
    cacheenable = new JCheckBox(Messages.getString("NetworkTab.EnableMediaLibrary"),
            configuration.getUseCache());
    cacheenable.setToolTipText(Messages.getString("FoldTab.ShowMediaLibraryFolderTooltip"));
    cacheenable.setContentAreaFilled(false);
    cacheenable.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setUseCache((e.getStateChange() == ItemEvent.SELECTED));
            cachereset.setEnabled(configuration.getUseCache());
            setScanLibraryEnabled(configuration.getUseCache());
        }
    });

    // Reset cache
    cachereset = new CustomJButton(Messages.getString("NetworkTab.EmptyMediaLibrary"));
    cachereset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int option = JOptionPane.showConfirmDialog(looksFrame,
                    Messages.getString("NetworkTab.MediaLibraryEmptiedExceptFullyPlayed") + "\n"
                            + Messages.getString("NetworkTab.19"),
                    Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION);
            if (option == JOptionPane.YES_OPTION) {
                PMS.get().getDatabase().init(true);
            }

        }
    });
    cachereset.setEnabled(configuration.getUseCache());

    // Hide file extensions
    hideextensions = new JCheckBox(Messages.getString("FoldTab.5"), configuration.isHideExtensions());
    hideextensions.setContentAreaFilled(false);
    if (configuration.isPrettifyFilenames()) {
        hideextensions.setEnabled(false);
    }
    hideextensions.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setHideExtensions((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Hide transcoding engine names
    hideengines = new JCheckBox(Messages.getString("FoldTab.8"), configuration.isHideEngineNames());
    hideengines.setToolTipText(Messages.getString("FoldTab.46"));
    hideengines.setContentAreaFilled(false);
    hideengines.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setHideEngineNames((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Hide empty folders
    hideemptyfolders = new JCheckBox(Messages.getString("FoldTab.31"), configuration.isHideEmptyFolders());
    hideemptyfolders.setToolTipText(Messages.getString("FoldTab.59"));
    hideemptyfolders.setContentAreaFilled(false);
    hideemptyfolders.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setHideEmptyFolders((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Show iTunes library
    itunes = new JCheckBox(Messages.getString("FoldTab.30"), configuration.isShowItunesLibrary());
    itunes.setToolTipText(Messages.getString("FoldTab.47"));
    itunes.setContentAreaFilled(false);
    if (!(Platform.isMac() || Platform.isWindows())) {
        itunes.setEnabled(false);
    }
    itunes.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setShowItunesLibrary((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Show iPhoto library
    iphoto = new JCheckBox(Messages.getString("FoldTab.29"), configuration.isShowIphotoLibrary());
    iphoto.setContentAreaFilled(false);
    if (!Platform.isMac()) {
        iphoto.setEnabled(false);
    }
    iphoto.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setShowIphotoLibrary((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Show aperture library
    aperture = new JCheckBox(Messages.getString("FoldTab.34"), configuration.isShowApertureLibrary());
    aperture.setContentAreaFilled(false);
    if (!Platform.isMac()) {
        aperture.setEnabled(false);
    }
    aperture.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setShowApertureLibrary((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // File order
    final KeyedComboBoxModel<Integer, String> kcbm = new KeyedComboBoxModel<>(
            new Integer[] { UMSUtils.SORT_LOC_SENS, // alphabetical
                    UMSUtils.SORT_LOC_NAT, // natural sort
                    UMSUtils.SORT_INS_ASCII, // ASCIIbetical
                    UMSUtils.SORT_MOD_NEW, // newest first
                    UMSUtils.SORT_MOD_OLD, // oldest first
                    UMSUtils.SORT_RANDOM, // random
                    UMSUtils.SORT_NO_SORT // no sorting
            },
            new String[] { Messages.getString("FoldTab.15"), Messages.getString("FoldTab.22"),
                    Messages.getString("FoldTab.20"), Messages.getString("FoldTab.16"),
                    Messages.getString("FoldTab.17"), Messages.getString("FoldTab.58"),
                    Messages.getString("FoldTab.62") });
    sortmethod = new JComboBox<>(kcbm);
    sortmethod.setEditable(false);
    kcbm.setSelectedKey(configuration.getSortMethod(null));

    sortmethod.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setSortMethod(kcbm.getSelectedKey());
                LOGGER.info("Setting {} {}", Messages.getRootString("FoldTab.18"), kcbm.getSelectedValue());
            }
        }
    });

    // Ignore the word "the" while sorting
    ignorethewordthe = new JCheckBox(Messages.getString("FoldTab.39"), configuration.isIgnoreTheWordAandThe());
    ignorethewordthe.setToolTipText(Messages.getString("FoldTab.44"));
    ignorethewordthe.setContentAreaFilled(false);
    ignorethewordthe.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setIgnoreTheWordAandThe((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    atzLimit = new JTextField("" + configuration.getATZLimit());
    atzLimit.setToolTipText(Messages.getString("FoldTab.49"));
    atzLimit.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            try {
                int ab = Integer.parseInt(atzLimit.getText());
                configuration.setATZLimit(ab);
            } catch (NumberFormatException nfe) {
                LOGGER.debug("Could not parse ATZ limit from \"" + atzLimit.getText() + "\"");
                LOGGER.debug("The full error was: " + nfe);
            }
        }
    });

    isShowFolderLiveSubtitles = new JCheckBox(Messages.getString("FoldTab.ShowLiveSubtitlesFolder"),
            configuration.isShowLiveSubtitlesFolder());
    isShowFolderLiveSubtitles.setContentAreaFilled(false);
    isShowFolderLiveSubtitles.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setShowLiveSubtitlesFolder((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    prettifyfilenames = new JCheckBox(Messages.getString("FoldTab.43"), configuration.isPrettifyFilenames());
    prettifyfilenames.setToolTipText(Messages.getString("FoldTab.45"));
    prettifyfilenames.setContentAreaFilled(false);
    prettifyfilenames.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setPrettifyFilenames((e.getStateChange() == ItemEvent.SELECTED));
            hideextensions.setEnabled((e.getStateChange() != ItemEvent.SELECTED));
            episodeTitles.setEnabled((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    episodeTitles = new JCheckBox(Messages.getString("FoldTab.74"), configuration.isUseInfoFromIMDb());
    episodeTitles.setToolTipText(Messages.getString("FoldTab.64"));
    episodeTitles.setContentAreaFilled(false);
    if (!configuration.isPrettifyFilenames()) {
        episodeTitles.setEnabled(false);
    }
    episodeTitles.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setUseInfoFromIMDb((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    isShowFolderNewMedia = new JCheckBox(Messages.getString("FoldTab.ShowNewMediaFolder"),
            configuration.isShowNewMediaFolder());
    isShowFolderNewMedia.setToolTipText(Messages.getString("FoldTab.66"));
    isShowFolderNewMedia.setContentAreaFilled(false);
    isShowFolderNewMedia.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setShowNewMediaFolder((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    resume = new JCheckBox(Messages.getString("NetworkTab.68"), configuration.isResumeEnabled());
    resume.setToolTipText(Messages.getString("NetworkTab.69"));
    resume.setContentAreaFilled(false);
    resume.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setResume((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    isShowFolderRecentlyPlayed = new JCheckBox(Messages.getString("FoldTab.ShowRecentlyPlayedFolder"),
            configuration.isShowRecentlyPlayedFolder());
    isShowFolderRecentlyPlayed.setContentAreaFilled(false);
    isShowFolderRecentlyPlayed.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setShowRecentlyPlayedFolder((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    // Fully played action
    final KeyedComboBoxModel<FullyPlayedAction, String> fullyPlayedActionModel = new KeyedComboBoxModel<>(
            new FullyPlayedAction[] { FullyPlayedAction.NO_ACTION, FullyPlayedAction.MARK,
                    FullyPlayedAction.HIDE_VIDEO, FullyPlayedAction.MOVE_FOLDER, FullyPlayedAction.MOVE_TRASH },
            new String[] { Messages.getString("FoldTab.67"), Messages.getString("FoldTab.68"),
                    Messages.getString("FoldTab.69"), Messages.getString("FoldTab.70"),
                    Messages.getString("FoldTab.71") });
    fullyPlayedAction = new JComboBox<>(fullyPlayedActionModel);
    fullyPlayedAction.setEditable(false);
    fullyPlayedActionModel.setSelectedKey(configuration.getFullyPlayedAction());
    fullyPlayedAction.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setFullyPlayedAction(fullyPlayedActionModel.getSelectedKey());
                fullyPlayedOutputDirectory
                        .setEnabled(fullyPlayedActionModel.getSelectedKey() == FullyPlayedAction.MOVE_FOLDER);
                selectFullyPlayedOutputDirectory
                        .setEnabled(fullyPlayedActionModel.getSelectedKey() == FullyPlayedAction.MOVE_FOLDER);

                if (configuration.getUseCache()
                        && fullyPlayedActionModel.getSelectedKey() == FullyPlayedAction.NO_ACTION) {
                    PMS.get().getDatabase().init(true);
                }
            }
        }
    });

    // Watched video output directory
    fullyPlayedOutputDirectory = new JTextField(configuration.getFullyPlayedOutputDirectory());
    fullyPlayedOutputDirectory.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setFullyPlayedOutputDirectory(fullyPlayedOutputDirectory.getText());
        }
    });
    fullyPlayedOutputDirectory
            .setEnabled(configuration.getFullyPlayedAction() == FullyPlayedAction.MOVE_FOLDER);

    // Watched video output directory selection button
    selectFullyPlayedOutputDirectory = new CustomJButton("...");
    selectFullyPlayedOutputDirectory.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser;
            try {
                chooser = new JFileChooser();
            } catch (Exception ee) {
                chooser = new JFileChooser(new RestrictedFileSystemView());
            }
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString("FoldTab.28"));
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                fullyPlayedOutputDirectory.setText(chooser.getSelectedFile().getAbsolutePath());
                configuration.setFullyPlayedOutputDirectory(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });
    selectFullyPlayedOutputDirectory
            .setEnabled(configuration.getFullyPlayedAction() == FullyPlayedAction.MOVE_FOLDER);
}

From source file:AltiConsole.AltiConsoleMainScreen.java

/**
 * Starting point for the altimeter console application.
 * /*from ww  w. j  a va  2  s.  co  m*/
 * @param args
 *            ignored.
 */
public static void main(final String[] args) {

    initializeL10n();
    final Translator trans = Application.getTranslator();
    Splash.init();

    // "Altimeter console"
    final AltiConsoleMainScreen alticonsole = new AltiConsoleMainScreen(
            trans.get("AltiConsoleMainScreen.Title"));

    Image icone;

    URL myURL;
    myURL = AltiConsoleMainScreen.class.getResource("/pix/bear_altimeters-small.png");
    if (myURL == null)
        myURL = AltiConsoleMainScreen.class.getResource("/bear_altimeters-small.png");
    icone = Toolkit.getDefaultToolkit().getImage(myURL);

    if (icone == null) {
        icone = Toolkit.getDefaultToolkit()
                .getImage(AltiConsoleMainScreen.class.getResource("/bear_altimeters-small.png"));

    }
    alticonsole.pack();
    alticonsole.setIconImage(icone);
    alticonsole.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    alticonsole.addWindowListener(new java.awt.event.WindowAdapter() {
        @Override
        public void windowClosing(java.awt.event.WindowEvent windowEvent) {

            System.out.println("exit and disconnecting\n");
            if (JOptionPane.showConfirmDialog(alticonsole, trans.get("AltiConsoleMainScreen.ClosingWindow"),
                    trans.get("AltiConsoleMainScreen.ReallyClosing"), JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
                alticonsole.DisconnectFromAlti();
                System.exit(0);
            }
        }
    });
    RefineryUtilities.centerFrameOnScreen(alticonsole);
    alticonsole.setVisible(true);

}

From source file:edu.ku.brc.specify.config.init.secwiz.UserPanel.java

@Override
public void aboutToLeave() {
    if (userModel.isChanged()) {
        String msg = UIRegistry.getResourceString("MSTR_SAVE_CHANGES");
        if (UIRegistry.askYesNoLocalized("SAVE", "EXIT", msg, "SAVE") == JOptionPane.YES_OPTION) {
            saveUserData();/*  w  w w . j  a  va  2 s .  c o  m*/
        }
    }
    super.aboutToLeave();
}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

/**
 * Constructs the MessageFilter (this.filter) based on the current form selections
 *//*w ww .  j a v  a2s .c  o m*/
private boolean generateMessageFilter() {
    messageFilter = new MessageFilter();

    // set start/end date
    try {
        messageFilter.setStartDate(getCalendar(mirthDatePicker1, mirthTimePicker1));
        Calendar endCalendar = getCalendar(mirthDatePicker2, mirthTimePicker2);

        if (endCalendar != null && !mirthTimePicker2.isEnabled()) {
            // If the end time picker is disabled, it will be set to 00:00:00 of the day provided.
            // Since our query is using <= instead of <, we add one day and then subtract a millisecond 
            // in order to set the time to the last millisecond of the day we want to search on
            endCalendar.add(Calendar.DATE, 1);
            endCalendar.add(Calendar.MILLISECOND, -1);
        }
        messageFilter.setEndDate(endCalendar);
    } catch (ParseException e) {
        parent.alertError(parent, "Invalid date.");
        return false;
    }

    Calendar startDate = messageFilter.getStartDate();
    Calendar endDate = messageFilter.getEndDate();

    if (startDate != null && endDate != null && startDate.getTimeInMillis() > endDate.getTimeInMillis()) {
        parent.alertError(parent, "Start date cannot be after the end date.");
        return false;
    }

    // Set text search
    String textSearch = StringUtils.trim(textSearchField.getText());

    if (textSearch.length() > 0) {
        messageFilter.setTextSearch(textSearch);
        List<String> textSearchMetaDataColumns = new ArrayList<String>();

        for (MetaDataColumn metaDataColumn : getMetaDataColumns()) {
            if (metaDataColumn.getType() == MetaDataColumnType.STRING) {
                textSearchMetaDataColumns.add(metaDataColumn.getName());
            }
        }

        messageFilter.setTextSearchMetaDataColumns(textSearchMetaDataColumns);
    }

    if (regexTextSearchCheckBox.isSelected()) {
        messageFilter.setTextSearchRegex(true);
    }

    // set status
    Set<Status> statuses = new HashSet<Status>();

    if (statusBoxReceived.isSelected()) {
        statuses.add(Status.RECEIVED);
    }

    if (statusBoxTransformed.isSelected()) {
        statuses.add(Status.TRANSFORMED);
    }

    if (statusBoxFiltered.isSelected()) {
        statuses.add(Status.FILTERED);
    }

    if (statusBoxSent.isSelected()) {
        statuses.add(Status.SENT);
    }

    if (statusBoxError.isSelected()) {
        statuses.add(Status.ERROR);
    }

    if (statusBoxQueued.isSelected()) {
        statuses.add(Status.QUEUED);
    }

    if (!statuses.isEmpty()) {
        messageFilter.setStatuses(statuses);
    }

    if (StringUtils.isNotEmpty(textSearch)
            && Preferences.userNodeForPackage(Mirth.class).getBoolean("textSearchWarning", true)) {
        JCheckBox dontShowTextSearchWarningCheckBox = new JCheckBox(
                "Don't show this message again in the future");

        String textSearchWarning = "<html>Text searching may take a long time, depending on the amount of messages being searched.<br/>Are you sure you want to proceed?</html>";
        String textRegexSearchWarning = "<html>Regular expression pattern matching may take a long time and be a costly operation, depending on the amount of messages being searched.<br/>Are you sure you want to proceed?</html>";
        String searchWarning = (regexTextSearchCheckBox.isSelected()) ? textRegexSearchWarning
                : textSearchWarning;
        Object[] params = new Object[] { searchWarning, dontShowTextSearchWarningCheckBox };
        int result = JOptionPane.showConfirmDialog(this, params, "Select an Option", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        Preferences.userNodeForPackage(Mirth.class).putBoolean("textSearchWarning",
                !dontShowTextSearchWarningCheckBox.isSelected());

        if (result != JOptionPane.YES_OPTION) {
            return false;
        }
    }

    advancedSearchPopup.applySelectionsToFilter(messageFilter);
    selectedMetaDataIds = messageFilter.getIncludedMetaDataIds();

    if (messageFilter.getMaxMessageId() == null) {
        try {
            Long maxMessageId = parent.mirthClient.getMaxMessageId(channelId);
            messageFilter.setMaxMessageId(maxMessageId);
        } catch (ClientException e) {
            parent.alertThrowable(parent, e);
            return false;
        }
    }

    return true;
}

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

private void btnguardar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardar1ActionPerformed
    // TODO add your handling code here:
    List<Integer> array = new ArrayList();
    array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.NUMERO, this.nombreField, "Nombre"));
    array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.NUMERO, this.empleadoField, "Responsable"));

    FormularioUtil.validar2(array);/* w  w  w  .  j a v  a  2  s . c  om*/

    if (FormularioUtil.error) {
        JOptionPane.showMessageDialog(null, FormularioUtil.mensaje, "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
        FormularioUtil.mensaje = "";
        FormularioUtil.error = false;
    } else {
        String palabra = "";
        String palabra2 = "";
        if (accion == 1) {
            palabra = "registrar";
            palabra2 = "registrado";

            if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Ambiente?",
                    "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                ambienteControlador.getSeleccionado().setCodigo(idField.getText().toUpperCase());
                ambienteControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase());

                Area area = (Area) cmbArea.getSelectedItem();
                ambienteControlador.getSeleccionado().setArea(area);

                ambienteControlador.accion(accion);
                lista.add(ambienteControlador.getSeleccionado());

                if (accion == 1) {
                    JOptionPane.showMessageDialog(null, "Ambiente " + palabra2 + " correctamente",
                            "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);
                    FormularioUtil.limpiarComponente(panelDatos);
                } else {
                    JOptionPane.showMessageDialog(null, "Ambiente no " + palabra2, "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                FormularioUtil.limpiarComponente(panelDatos);
                JOptionPane.showMessageDialog(null, "Ambiente no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        } else if (accion == 2) {
            palabra = "modificar";
            palabra2 = "modificado";

            if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Ambiente?",
                    "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                if (accion == 2) {
                    JOptionPane.showMessageDialog(null, "Ambiente " + palabra2 + " correctamente",
                            "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);

                    lista.clear();
                    ambienteControlador.getSeleccionado().setCodigo(idField.getText().toUpperCase());
                    ambienteControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase());
                    Area area = (Area) cmbArea.getSelectedItem();
                    ambienteControlador.getSeleccionado().setArea(area);

                    ambienteControlador.accion(accion);
                    listar();

                    FormularioUtil.limpiarComponente(panelDatos);

                } else {
                    JOptionPane.showMessageDialog(null, "Ambiente no " + palabra2, "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                FormularioUtil.limpiarComponente(panelDatos);
                JOptionPane.showMessageDialog(null, "Ambiente no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

        FormularioUtil.activarComponente(panelOpciones, true);
        FormularioUtil.activarComponente(panelGuardar, false);
        FormularioUtil.activarComponente(panelDatos, false);
    }
}

From source file:com.mirth.connect.client.ui.panels.connectors.PollingSettingsPanel.java

private void scheduleTypeActionPerformed() {
    String selectedType = (String) scheduleTypeComboBox.getSelectedItem();

    // If connector is changing, ignore this...
    if (lastSelectedPollingType != null && channelContext && (!isDefaultProperties()
            || !cachedAdvancedConnectorProperties.equals(new PollConnectorPropertiesAdvanced()))) {
        if (!selectedType.equals(lastSelectedPollingType) && JOptionPane.showConfirmDialog(
                PlatformUI.MIRTH_FRAME,/*from w w  w .  ja va 2  s  .c  om*/
                "Are you sure you would like to change the polling type and lose all of the current properties?",
                "Select an Option", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
            clearProperties();
            enableComponents(selectedType);
        } else {
            scheduleTypeComboBox.setSelectedItem(lastSelectedPollingType);
        }
    } else {
        scheduleTypeComboBox.setSelectedItem(selectedType);
        enableComponents(selectedType);
    }

    updateNextFireTime();
}

From source file:UserInterface.FinanceRole.DonateToPoorPeopleJPanel.java

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

    objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount();

    BigDecimal worldDonation = AutoDonate.donationCheck(objWorldEnterprise, objUserAccount);
    BigDecimal worldBalance = objWorldEnterprise.getObjTransactionDirectory().getAvailableVirtualBalance();
    System.out.println(worldDonation);

    System.out.println(objWorldEnterprise.getObjTransactionDirectory().getAvailableRealBalance());
    System.out.println(objWorldEnterprise.getObjTransactionDirectory().getAvailableVirtualBalance());

    int positiveWorldBalance = worldBalance.compareTo(worldDonation);

    if (positiveWorldBalance >= 1) {
        //JDialog.setDefaultLookAndFeelDecorated(true);

        int response = JOptionPane.showConfirmDialog(null,
                "Total donation of $ " + worldDonation + "/- Do you want to Donate?", "Confirm",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            System.out.println("Yes button clicked");
            worldDonation = AutoDonate.donationConfirm(objWorldEnterprise, objUserAccount);

            JOptionPane.showMessageDialog(null, "$ " + worldDonation + "/- donated successfully");
        }/*from   ww  w.  j av a  2  s  .c  o m*/
    } else {
        JOptionPane.showMessageDialog(null, "World Balance is low");
    }
}

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

private void exportAsHTML() {
    List<Village> selection = getSelectedElements();
    if (selection.isEmpty()) {
        showInfo("Keine Drfer ausgewhlt");
        return;/*  w w  w. jav  a 2s .c om*/
    }
    //do HTML export
    String dir = GlobalOptions.getProperty("screen.dir");

    JFileChooser chooser = null;
    try {
        //handle vista problem
        chooser = new JFileChooser(dir);
    } catch (Exception e) {
        JOptionPaneHelper.showErrorBox(this,
                "Konnte Dateiauswahldialog nicht ffnen.\nMglicherweise verwendest du Windows Vista. Ist dies der Fall, beende DS Workbench, klicke mit der rechten Maustaste auf DSWorkbench.exe,\n"
                        + "whle 'Eigenschaften' und deaktiviere dort unter 'Kompatibilitt' den Windows XP Kompatibilittsmodus.",
                "Fehler");
        return;
    }

    chooser.setDialogTitle("Datei auswhlen");
    chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {

        @Override
        public boolean accept(File f) {
            return (f != null) && (f.isDirectory() || f.getName().endsWith(".html"));
        }

        @Override
        public String getDescription() {
            return "*.html";
        }
    });
    //open dialog
    chooser.setSelectedFile(new File(dir + "/Dorfliste.html"));
    int ret = chooser.showSaveDialog(this);
    if (ret == JFileChooser.APPROVE_OPTION) {
        try {
            //check extension
            File f = chooser.getSelectedFile();
            String file = f.getCanonicalPath();
            if (!file.endsWith(".html")) {
                file += ".html";
            }

            //check overwrite
            File target = new File(file);
            if (target.exists()) {
                if (JOptionPaneHelper.showQuestionConfirmBox(this, "Bestehende Datei berschreiben?",
                        "berschreiben", "Nein", "Ja") == JOptionPane.NO_OPTION) {
                    //do not overwrite
                    return;
                }
            }
            //do export
            SelectionHTMLExporter.doExport(target, selection);
            GlobalOptions.addProperty("screen.dir", target.getParent());
            showSuccess("Auswahl erfolgreich gespeichert");
            if (JOptionPaneHelper.showQuestionConfirmBox(this,
                    "Willst du die erstellte Datei jetzt im Browser betrachten?", "Information", "Nein",
                    "Ja") == JOptionPane.YES_OPTION) {
                BrowserInterface.openPage(target.toURI().toURL().toString());
            }
        } catch (Exception inner) {
            logger.error("Failed to write selection to HTML", inner);
            showError("Fehler beim Speichern");
        }
    }
}

From source file:corelyzer.ui.CorelyzerGLCanvas.java

private void doDeleteSection() {
    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(getPopupParent(), "Are you sure?")) {
        CorelyzerApp app = CorelyzerApp.getApp();

        if (app != null) {
            app.getController().deleteSection(selectedTrack, selectedTrackSection);
            app.updateGLWindows();//from  w w w .ja  va  2 s .c  om
        }
    }
}

From source file:biz.wolschon.finance.jgnucash.JGnucash.java

/**
 * {@inheritDoc}/*  w ww . j  ava2s.com*/
 */
@Override
protected void doExit() {
    if (hasChanged) {
        int state = JOptionPane.showConfirmDialog(this, "File has been changed. Save before exit?");
        if (state == JOptionPane.YES_OPTION) {
            saveFile();
        } else if (state == JOptionPane.CANCEL_OPTION) {
            return;
        }
    }
    System.exit(0);
}