Example usage for javax.swing JOptionPane PLAIN_MESSAGE

List of usage examples for javax.swing JOptionPane PLAIN_MESSAGE

Introduction

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

Prototype

int PLAIN_MESSAGE

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

Click Source Link

Document

No icon is used.

Usage

From source file:com.osparking.attendant.AttListForm.java

private void checkIDButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkIDButtonActionPerformed
    String idEntered = userIDText.getText().trim();
    String sql = "Select count(*) as dataCount From users_osp Where id = ?";

    try {// w w  w  .  j ava  2 s  . co  m
        if (idEntered.length() < 2) {
            // Reject if ID were shorter than 2 characters
            JOptionPane.showConfirmDialog(this, ID_LENGTH_CHECK_DIALOG.getContent(),
                    ATT_ID_DUP_CHCEK_DIALOGTITLE.getContent(), JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
            userIDText.requestFocusInWindow();
            return;
        } else if (dataExistsInDB(sql, idEntered)) {
            // Same ID is being used by other user, let the user know about this.

            String dialogMessage = ID_INUSE_1.getContent() + userIDText.getText().trim()
                    + ID_INUSE_2.getContent() + System.lineSeparator() + ID_INUSE_3.getContent();

            JOptionPane.showConfirmDialog(this, dialogMessage, ATT_ID_DUP_CHCEK_DIALOGTITLE.getContent(),
                    JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
            userIDText.requestFocusInWindow();
        } else {
            String checkResult = IDSyntaxCheckResult(idEntered);

            if (checkResult.length() == 0) {
                ID_usable = true;
                usableID = idEntered;
                checkIDButton.setEnabled(false);

                String dialogMessage = ID_INUSE_1.getContent() + userIDText.getText().trim()
                        + ATT_EMAIL_GOOD_2.getContent() + System.lineSeparator();

                JOptionPane.showConfirmDialog(this, dialogMessage, ATT_ID_DUP_CHCEK_DIALOGTITLE.getContent(),
                        JOptionPane.PLAIN_MESSAGE, INFORMATION_MESSAGE);
            } else {
                JOptionPane.showConfirmDialog(this, checkResult, ATT_ID_DUP_CHCEK_DIALOGTITLE.getContent(),
                        JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
                userIDText.requestFocus();
            }
        }
    } catch (Exception ex) {
        logParkingException(Level.SEVERE, ex,
                "(User Action: new user ID('" + idEntered + "') Check Button is Being Processed)");
    }
}

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openChipOptionsDialog(final int chip) {

    // ------------------------ Disassembly options

    JPanel disassemblyOptionsPanel = new JPanel(new MigLayout("", "[left,grow][left,grow]"));

    // Prepare sample code area
    final RSyntaxTextArea listingArea = new RSyntaxTextArea(20, 90);
    SourceCodeFrame.prepareAreaFormat(chip, listingArea);

    final List<JCheckBox> outputOptionsCheckBoxes = new ArrayList<JCheckBox>();
    ActionListener areaRefresherListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Set<OutputOption> sampleOptions = EnumSet.noneOf(OutputOption.class);
                dumpOptionCheckboxes(outputOptionsCheckBoxes, sampleOptions);
                int baseAddress = framework.getPlatform(chip).getCpuState().getResetAddress();
                int lastAddress = baseAddress;
                Memory sampleMemory = new DebuggableMemory(false);
                sampleMemory.map(baseAddress, 0x100, true, true, true);
                StringWriter writer = new StringWriter();
                Disassembler disassembler;
                if (chip == Constants.CHIP_FR) {
                    sampleMemory.store16(lastAddress, 0x1781); // PUSH    RP
                    lastAddress += 2;/*from  w w  w . j a  v a  2  s . c o  m*/
                    sampleMemory.store16(lastAddress, 0x8FFE); // PUSH    (FP,AC,R12,R11,R10,R9,R8)
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x83EF); // ANDCCR  #0xEF
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x9F80); // LDI:32  #0x68000000,R0
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x6800);
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x0000);
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x2031); // LD      @(FP,0x00C),R1
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0xB581); // LSL     #24,R1
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x1A40); // DMOVB   R13,@0x40
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x9310); // ORCCR   #0x10
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x8D7F); // POP     (R8,R9,R10,R11,R12,AC,FP)
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x0781); // POP    RP
                    lastAddress += 2;

                    disassembler = new Dfr();
                    disassembler.setDebugPrintWriter(new PrintWriter(new StringWriter())); // Ignore
                    disassembler.setOutputFileName(null);
                    disassembler.processOptions(new String[] { "-m", "0x" + Format.asHex(baseAddress, 8) + "-0x"
                            + Format.asHex(lastAddress, 8) + "=CODE" });
                } else {
                    sampleMemory.store32(lastAddress, 0x340B0001); // li      $t3, 0x0001
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x17600006); // bnez    $k1, 0xBFC00020
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x00000000); //  nop
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x54400006); // bnezl   $t4, 0xBFC00028
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x3C0C0000); //  ?lui   $t4, 0x0000
                    lastAddress += 4;

                    int baseAddress16 = lastAddress;
                    int lastAddress16 = baseAddress16;
                    sampleMemory.store32(lastAddress16, 0xF70064F6); // save    $ra,$s0,$s1,$s2-$s7,$fp, 0x30
                    lastAddress16 += 4;
                    sampleMemory.store16(lastAddress16, 0x6500); // nop
                    lastAddress16 += 2;
                    sampleMemory.store32(lastAddress16, 0xF7006476); // restore $ra,$s0,$s1,$s2-$s7,$fp, 0x30
                    lastAddress16 += 4;
                    sampleMemory.store16(lastAddress16, 0xE8A0); // ret
                    lastAddress16 += 2;

                    disassembler = new Dtx();
                    disassembler.setDebugPrintWriter(new PrintWriter(new StringWriter())); // Ignore
                    disassembler.setOutputFileName(null);
                    disassembler.processOptions(new String[] { "-m",
                            "0x" + Format.asHex(baseAddress, 8) + "-0x" + Format.asHex(lastAddress, 8)
                                    + "=CODE:32",
                            "-m", "0x" + Format.asHex(baseAddress16, 8) + "-0x" + Format.asHex(lastAddress16, 8)
                                    + "=CODE:16" });
                }
                disassembler.setOutputOptions(sampleOptions);
                disassembler.setMemory(sampleMemory);
                disassembler.initialize();
                disassembler.setOutWriter(writer);
                disassembler.disassembleMemRanges();
                disassembler.cleanup();
                listingArea.setText("");
                listingArea.append(writer.toString());
                listingArea.setCaretPosition(0);

            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    };

    int i = 1;
    for (OutputOption outputOption : OutputOption.allFormatOptions) {
        JCheckBox checkBox = makeOutputOptionCheckBox(chip, outputOption, prefs.getOutputOptions(chip), false);
        if (checkBox != null) {
            outputOptionsCheckBoxes.add(checkBox);
            disassemblyOptionsPanel.add(checkBox, (i % 2 == 0) ? "wrap" : "");
            checkBox.addActionListener(areaRefresherListener);
            i++;
        }
    }
    if (i % 2 == 0) {
        disassemblyOptionsPanel.add(new JLabel(), "wrap");
    }

    // Force a refresh
    areaRefresherListener.actionPerformed(new ActionEvent(outputOptionsCheckBoxes.get(0), 0, ""));

    //        disassemblyOptionsPanel.add(new JLabel("Sample output:", SwingConstants.LEADING), "gapbottom 1, span, split 2, aligny center");
    //        disassemblyOptionsPanel.add(new JSeparator(), "span 2,wrap");
    disassemblyOptionsPanel.add(new JSeparator(), "span 2, gapleft rel, growx, wrap");
    disassemblyOptionsPanel.add(new JLabel("Sample output:"), "span 2,wrap");
    disassemblyOptionsPanel.add(new JScrollPane(listingArea), "span 2,wrap");
    disassemblyOptionsPanel.add(new JLabel("Tip: hover over the option checkboxes for help"),
            "span 2, center, wrap");

    // ------------------------ Emulation options

    JPanel emulationOptionsPanel = new JPanel(new VerticalLayout(5, VerticalLayout.LEFT));
    emulationOptionsPanel.add(new JLabel());
    JLabel warningLabel = new JLabel(
            "NOTE: these options only take effect after reloading the firmware (or performing a 'Stop and reset')");
    warningLabel.setBackground(Color.RED);
    warningLabel.setOpaque(true);
    warningLabel.setForeground(Color.WHITE);
    warningLabel.setHorizontalAlignment(SwingConstants.CENTER);
    emulationOptionsPanel.add(warningLabel);
    emulationOptionsPanel.add(new JLabel());

    final JCheckBox writeProtectFirmwareCheckBox = new JCheckBox("Write-protect firmware");
    writeProtectFirmwareCheckBox.setSelected(prefs.isFirmwareWriteProtected(chip));
    emulationOptionsPanel.add(writeProtectFirmwareCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, any attempt to write to the loaded firmware area will result in an Emulator error. This can help trap spurious writes"));

    final JCheckBox dmaSynchronousCheckBox = new JCheckBox("Make DMA synchronous");
    dmaSynchronousCheckBox.setSelected(prefs.isDmaSynchronous(chip));
    emulationOptionsPanel.add(dmaSynchronousCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, DMA operations will be performed immediately, pausing the CPU. Otherwise they are performed in a separate thread."));

    final JCheckBox autoEnableTimersCheckBox = new JCheckBox("Auto enable timers");
    autoEnableTimersCheckBox.setSelected(prefs.isAutoEnableTimers(chip));
    emulationOptionsPanel.add(autoEnableTimersCheckBox);
    emulationOptionsPanel
            .add(new JLabel("If checked, timers will be automatically enabled upon reset or firmware load."));

    // Log memory messages
    final JCheckBox logMemoryMessagesCheckBox = new JCheckBox("Log memory messages");
    logMemoryMessagesCheckBox.setSelected(prefs.isLogMemoryMessages(chip));
    emulationOptionsPanel.add(logMemoryMessagesCheckBox);
    emulationOptionsPanel
            .add(new JLabel("If checked, messages related to memory will be logged to the console."));

    // Log serial messages
    final JCheckBox logSerialMessagesCheckBox = new JCheckBox("Log serial messages");
    logSerialMessagesCheckBox.setSelected(prefs.isLogSerialMessages(chip));
    emulationOptionsPanel.add(logSerialMessagesCheckBox);
    emulationOptionsPanel.add(
            new JLabel("If checked, messages related to serial interfaces will be logged to the console."));

    // Log register messages
    final JCheckBox logRegisterMessagesCheckBox = new JCheckBox("Log register messages");
    logRegisterMessagesCheckBox.setSelected(prefs.isLogRegisterMessages(chip));
    emulationOptionsPanel.add(logRegisterMessagesCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, warnings related to unimplemented register addresses will be logged to the console."));

    // Log pin messages
    final JCheckBox logPinMessagesCheckBox = new JCheckBox("Log pin messages");
    logPinMessagesCheckBox.setSelected(prefs.isLogPinMessages(chip));
    emulationOptionsPanel.add(logPinMessagesCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, warnings related to unimplemented I/O pins will be logged to the console."));

    emulationOptionsPanel.add(new JSeparator(JSeparator.HORIZONTAL));

    // Alt mode upon Debug
    JPanel altDebugPanel = new JPanel(new FlowLayout());
    Object[] altDebugMode = EnumSet.allOf(EmulationFramework.ExecutionMode.class).toArray();
    final JComboBox altModeForDebugCombo = new JComboBox(new DefaultComboBoxModel(altDebugMode));
    for (int j = 0; j < altDebugMode.length; j++) {
        if (altDebugMode[j].equals(prefs.getAltExecutionModeForSyncedCpuUponDebug(chip))) {
            altModeForDebugCombo.setSelectedIndex(j);
        }
    }
    altDebugPanel.add(new JLabel(Constants.CHIP_LABEL[1 - chip] + " mode when " + Constants.CHIP_LABEL[chip]
            + " runs in sync Debug: "));
    altDebugPanel.add(altModeForDebugCombo);
    emulationOptionsPanel.add(altDebugPanel);
    emulationOptionsPanel
            .add(new JLabel("If 'sync mode' is selected, this is the mode the " + Constants.CHIP_LABEL[1 - chip]
                    + " chip will run in when running the " + Constants.CHIP_LABEL[chip] + " in Debug mode"));

    // Alt mode upon Step
    JPanel altStepPanel = new JPanel(new FlowLayout());
    Object[] altStepMode = EnumSet.allOf(EmulationFramework.ExecutionMode.class).toArray();
    final JComboBox altModeForStepCombo = new JComboBox(new DefaultComboBoxModel(altStepMode));
    for (int j = 0; j < altStepMode.length; j++) {
        if (altStepMode[j].equals(prefs.getAltExecutionModeForSyncedCpuUponStep(chip))) {
            altModeForStepCombo.setSelectedIndex(j);
        }
    }
    altStepPanel.add(new JLabel(Constants.CHIP_LABEL[1 - chip] + " mode when " + Constants.CHIP_LABEL[chip]
            + " runs in sync Step: "));
    altStepPanel.add(altModeForStepCombo);
    emulationOptionsPanel.add(altStepPanel);
    emulationOptionsPanel
            .add(new JLabel("If 'sync mode' is selected, this is the mode the " + Constants.CHIP_LABEL[1 - chip]
                    + " chip will run in when running the " + Constants.CHIP_LABEL[chip] + " in Step mode"));

    // ------------------------ Prepare tabbed pane

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " Disassembly Options", null, disassemblyOptionsPanel);
    tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " Emulation Options", null, emulationOptionsPanel);

    if (chip == Constants.CHIP_TX) {
        JPanel chipSpecificOptionsPanel = new JPanel(new VerticalLayout(5, VerticalLayout.LEFT));

        chipSpecificOptionsPanel.add(new JLabel("Eeprom status upon startup:"));

        ActionListener eepromInitializationRadioActionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                prefs.setEepromInitMode(Prefs.EepromInitMode.valueOf(e.getActionCommand()));
            }
        };
        JRadioButton blank = new JRadioButton("Blank");
        blank.setActionCommand(Prefs.EepromInitMode.BLANK.name());
        blank.addActionListener(eepromInitializationRadioActionListener);
        if (Prefs.EepromInitMode.BLANK.equals(prefs.getEepromInitMode()))
            blank.setSelected(true);
        JRadioButton persistent = new JRadioButton("Persistent across sessions");
        persistent.setActionCommand(Prefs.EepromInitMode.PERSISTENT.name());
        persistent.addActionListener(eepromInitializationRadioActionListener);
        if (Prefs.EepromInitMode.PERSISTENT.equals(prefs.getEepromInitMode()))
            persistent.setSelected(true);
        JRadioButton lastLoaded = new JRadioButton("Last Loaded");
        lastLoaded.setActionCommand(Prefs.EepromInitMode.LAST_LOADED.name());
        lastLoaded.addActionListener(eepromInitializationRadioActionListener);
        if (Prefs.EepromInitMode.LAST_LOADED.equals(prefs.getEepromInitMode()))
            lastLoaded.setSelected(true);

        ButtonGroup group = new ButtonGroup();
        group.add(blank);
        group.add(persistent);
        group.add(lastLoaded);

        chipSpecificOptionsPanel.add(blank);
        chipSpecificOptionsPanel.add(persistent);
        chipSpecificOptionsPanel.add(lastLoaded);

        chipSpecificOptionsPanel.add(new JLabel("Front panel type:"));
        final JComboBox frontPanelNameCombo = new JComboBox(new String[] { "D5100_small", "D5100_large" });
        if (prefs.getFrontPanelName() != null) {
            frontPanelNameCombo.setSelectedItem(prefs.getFrontPanelName());
        }
        frontPanelNameCombo.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                prefs.setFrontPanelName((String) frontPanelNameCombo.getSelectedItem());
            }
        });
        chipSpecificOptionsPanel.add(frontPanelNameCombo);

        emulationOptionsPanel.add(new JSeparator(JSeparator.HORIZONTAL));

        tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " specific options", null, chipSpecificOptionsPanel);
    }

    // ------------------------ Show it

    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, tabbedPane,
            Constants.CHIP_LABEL[chip] + " options", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
            null, null, JOptionPane.DEFAULT_OPTION)) {
        // save output options
        dumpOptionCheckboxes(outputOptionsCheckBoxes, prefs.getOutputOptions(chip));
        // apply
        TxCPUState.initRegisterLabels(prefs.getOutputOptions(chip));

        // save other prefs
        prefs.setFirmwareWriteProtected(chip, writeProtectFirmwareCheckBox.isSelected());
        prefs.setDmaSynchronous(chip, dmaSynchronousCheckBox.isSelected());
        prefs.setAutoEnableTimers(chip, autoEnableTimersCheckBox.isSelected());
        prefs.setLogRegisterMessages(chip, logRegisterMessagesCheckBox.isSelected());
        prefs.setLogSerialMessages(chip, logSerialMessagesCheckBox.isSelected());
        prefs.setLogPinMessages(chip, logPinMessagesCheckBox.isSelected());
        prefs.setLogMemoryMessages(chip, logMemoryMessagesCheckBox.isSelected());
        prefs.setAltExecutionModeForSyncedCpuUponDebug(chip,
                (EmulationFramework.ExecutionMode) altModeForDebugCombo.getSelectedItem());
        prefs.setAltExecutionModeForSyncedCpuUponStep(chip,
                (EmulationFramework.ExecutionMode) altModeForStepCombo.getSelectedItem());

    }
}

From source file:com.osparking.attendant.AttListForm.java

private void doAfterUpdateOperations(int result) {
    if (result == 1) {
        List sortKeys = usersTable.getRowSorter().getSortKeys();
        loadAttendantTable("");
        usersTable.getRowSorter().setSortKeys(sortKeys);
        int selectIndex = searchRow(userIDText.getText());
        usersTable.changeSelection(selectIndex, 0, false, false);
        usersTable.requestFocus();//from   w ww .j  av  a 2s .  c  o  m

        String dialogMessage = USER_UPDATE_1.getContent() + System.lineSeparator() + System.lineSeparator()
                + USER_UPDATE_2.getContent() + userIDText.getText().trim();
        JOptionPane.showMessageDialog(this, dialogMessage, ATT_USER_UPDATE_DIALOGTITLE.getContent(),
                JOptionPane.PLAIN_MESSAGE);

        clearPasswordFields();
        changedControls.clear();
        logParkingOperation(OpLogLevel.UserCarChange, getModifiedUserInfo());
    } else {
        //<editor-fold desc="-- Handle the case of update failure">
        String dialogMessage = USER_UPDATE_A.getContent() + System.lineSeparator() + System.lineSeparator()
                + USER_UPDATE_2.getContent() + userIDText.getText().trim();

        JOptionPane.showMessageDialog(this, dialogMessage, ATT_USER_UPDATE_DIALOGTITLE.getContent(),
                JOptionPane.PLAIN_MESSAGE);
        //</editor-fold>
    }
}

From source file:au.org.ala.delta.intkey.Intkey.java

@Override
public String promptForString(String message, String initialValue, String directiveName) {
    return (String) JOptionPane.showInputDialog(getMainFrame(), message, directiveName,
            JOptionPane.PLAIN_MESSAGE, null, null, initialValue);
}

From source file:com.osparking.osparking.Settings_System.java

private void SettingsSaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SettingsSaveButtonActionPerformed
    Connection conn = null;//from w w w .ja v  a 2  s.co m
    PreparedStatement updateSettings = null;
    int result = -1;
    boolean newStorePassingDelay = RecordPassingDelayChkBox.isSelected();
    Locale locale = LanguageBox.getLocale();
    boolean langNotSupported = (!locale.equals(defaultLocale) && !locale.equals(enUS_Locale));

    if (langNotSupported) {
        String message = WRONG_LANG_DIALOG_1.getContent() + System.lineSeparator();
        message += WRONG_LANG_DIALOG_2.getContent() + locale.getDisplayName() + System.lineSeparator()
                + System.lineSeparator();
        message += WRONG_LANG_DIALOG_3.getContent() + System.lineSeparator();
        message += WRONG_LANG_DIALOG_4.getContent() + defaultLocale.getDisplayName() + ", "
                + enUS_Locale.getDisplayName() + System.lineSeparator();

        JOptionPane.showConfirmDialog(this, message, LANGUAGE_ERROR_TITLE.getContent(),
                JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
        return;
    }

    //<editor-fold desc="--check setting input errors">
    if (!TextFieldNumericValueOK(TextFieldPicWidth, "Photo Extent Typing Errors")) {
        return;
    }

    if (!TextFieldNumericValueOK(TextFieldPicHeight, "Photo Height Typing Errors")) {
        return;
    }

    if (Integer.parseInt(removeNonNumeric(TextFieldPicHeight.getText().trim())) < 100) {
        TextFieldPicHeight.requestFocusInWindow();
        JOptionPane.showConfirmDialog(this, "Please enter a height value of 100 or more",
                "Picture Height Input Error", JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
        return;
    }

    if (Integer.parseInt(removeNonNumeric(TextFieldPicWidth.getText().trim())) < 100) {
        TextFieldPicWidth.requestFocusInWindow();
        JOptionPane.showConfirmDialog(this, "Please enter a width value of 100 or more",
                "Picture Width Input Error", JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
        return;
    }

    if (someIPaddressWrong()) {
        return;
    }

    if (someCOMportIDsame()) {
        return;
    }
    //</editor-fold>

    int newStatCount = 0;
    short pwLevel = -1;
    short optnLogLevel = -1;
    String maxLineStr = "";
    int imageKeepDuration = 0;
    int picWidth = Integer.parseInt(removeNonNumeric(TextFieldPicWidth.getText()));
    int picHeight = Integer.parseInt(removeNonNumeric(TextFieldPicHeight.getText()));
    int flowCycle = Integer.parseInt(removeNonNumeric((String) FlowingComboBox.getSelectedItem()));
    int blinkCycle = Integer.parseInt(removeNonNumeric(TextFieldPicWidth.getText()));
    boolean gateCountChanged = false;

    try {
        StringBuffer sb = new StringBuffer("Update SettingsTable SET ");
        //<editor-fold desc="--create update statement">
        sb.append("Lot_Name = ?, ");
        sb.append("perfEvalNeeded = ?, PWStrengthLevel = ?, OptnLoggingLevel = ?, ");
        sb.append("languageCode = ?, countryCode = ?, localeIndex = ?, statCount =  ?, ");
        sb.append("MaxMessageLines = ?, GateCount = ?, ");
        sb.append("PictureWidth = ?, PictureHeight = ?, ");
        sb.append("EBD_flow_cycle = ?, EBD_blink_cycle = ?, ");
        sb.append("max_maintain_date = ? ");
        //</editor-fold>

        ConvComboBoxItem selectedItem = (ConvComboBoxItem) PopSizeCBox.getSelectedItem();
        newStatCount = (Integer) selectedItem.getKeyValue();
        if (newStorePassingDelay) {
            for (int gateID = 1; gateID <= gateCount; gateID++) {
                initPassingDelayStatIfNeeded(newStatCount, gateID);
            }
        }
        conn = JDBCMySQL.getConnection();
        updateSettings = conn.prepareStatement(sb.toString());

        int pIndex = 1;

        // <editor-fold defaultstate="collapsed" desc="--Provide values to each parameters of the UPDATE statement">
        updateSettings.setString(pIndex++, lotNameTextField.getText().trim());
        if (newStorePassingDelay) {
            updateSettings.setInt(pIndex++, 1);
        } else {
            updateSettings.setInt(pIndex++, 0);
            if (DEBUG) {
                // Give warning that in debug mode PassingDelay is always recorded.
                JOptionPane.showMessageDialog(null, RECORD_DELAY_DEBUG.getContent());
            }
        }

        pwLevel = (short) (PWStrengthChoiceComboBox.getSelectedIndex());
        updateSettings.setShort(pIndex++, pwLevel);

        optnLogLevel = (short) (OptnLoggingLevelComboBox.getSelectedIndex());
        updateSettings.setShort(pIndex++, optnLogLevel);

        updateSettings.setString(pIndex++, LanguageBox.getLocale().getLanguage());
        updateSettings.setString(pIndex++, LanguageBox.getLocale().getCountry());
        updateSettings.setShort(pIndex++, (short) LanguageBox.getSelectedIndex());
        updateSettings.setInt(pIndex++, PopSizeCBox.getSelectedIndex());

        maxLineStr = (String) MessageMaxLineComboBox.getSelectedItem();
        updateSettings.setShort(pIndex++, new Short(maxLineStr));
        updateSettings.setShort(pIndex++, new Short((String) GateCountComboBox.getSelectedItem()));

        updateSettings.setInt(pIndex++, picWidth);
        updateSettings.setInt(pIndex++, picHeight);
        updateSettings.setInt(pIndex++, flowCycle);
        updateSettings.setInt(pIndex++, blinkCycle);

        ConvComboBoxItem item = (ConvComboBoxItem) ImageDurationCBox.getSelectedItem();
        imageKeepDuration = (Integer) (item.getKeyValue());
        updateSettings.setInt(pIndex++, imageKeepDuration);
        // </editor-fold>

        result = updateSettings.executeUpdate();
        if (index2Level(opLoggingIndex) != Level.OFF && index2Level(optnLogLevel) == Level.OFF) {
            Globals.isFinalWishLog = true;
        }
    } catch (SQLException se) {
        Globals.logParkingException(Level.SEVERE, se,
                "(Save settings: " + (newStorePassingDelay ? "Y" : "N") + ")");
    } finally {
        // <editor-fold defaultstate="collapsed" desc="--Return resources and display the save result">
        closeDBstuff(conn, updateSettings, null, "(Save settings: " + (newStorePassingDelay ? "Y" : "N") + ")");

        if (result == 1) {
            //<editor-fold desc="-- Log system settings change if set to do so">
            if (statCount != newStatCount) {
                logParkingOperation(OpLogLevel.SettingsChange,
                        "Settings Change, Statistics Population Size: " + statCount + " => " + newStatCount);
            }

            if (storePassingDelay != newStorePassingDelay) {
                logParkingOperation(OpLogLevel.SettingsChange, "Settings Change, Average Passing Delay: "
                        + storePassingDelay + " => " + newStorePassingDelay);
            }

            if (pwStrengthLevel != pwLevel) {
                logParkingOperation(OpLogLevel.SettingsChange,
                        "Settings Change, Password Strength Level: "
                                + PWStrengthChoiceComboBox.getItemAt(pwStrengthLevel) + " => "
                                + PWStrengthChoiceComboBox.getItemAt(pwLevel));
            }

            if (opLoggingIndex != optnLogLevel) {
                logParkingOperation(OpLogLevel.LogAlways,
                        "Settings Change, Gen' Operation Log Level: "
                                + OptnLoggingLevelComboBox.getItemAt(opLoggingIndex) + " => "
                                + OptnLoggingLevelComboBox.getItemAt(optnLogLevel));
            }

            if (localeIndex != (short) LanguageBox.getSelectedIndex()) {
                logParkingOperation(OpLogLevel.SettingsChange,
                        "Settings Change, Date Chooser Lang': " + LanguageBox.getItemAt(localeIndex) + " => "
                                + LanguageBox.getItemAt((short) LanguageBox.getSelectedIndex()));
            }

            if (maxMessageLines != new Short(maxLineStr)) {
                logParkingOperation(OpLogLevel.SettingsChange, "Settings Change, Recent Event Line Max: "
                        + maxMessageLines + " => " + new Short(maxLineStr));
            }

            short newGateCount = new Short((String) GateCountComboBox.getSelectedItem());

            gateCountChanged = gateCount != newGateCount;
            if (gateCountChanged) {
                logParkingOperation(OpLogLevel.SettingsChange,
                        "Settings Change, Number of Gates: " + gateCount + " => " + newGateCount);
            }

            if (maxMaintainDate != imageKeepDuration) {
                logParkingOperation(OpLogLevel.SettingsChange, "Settings Change, Image Keep Duration: "
                        + maxMaintainDate + " => " + imageKeepDuration);
            }

            if (PIC_WIDTH != picWidth) {
                logParkingOperation(OpLogLevel.SettingsChange,
                        "Settings Change, Image width: " + PIC_WIDTH + " => " + picWidth);
            }

            if (PIC_HEIGHT != picHeight) {
                logParkingOperation(OpLogLevel.SettingsChange,
                        "Settings Change, Image Height: " + PIC_HEIGHT + " => " + picHeight);
            }

            if (EBD_flowCycle != flowCycle) {
                logParkingOperation(OpLogLevel.UserCarChange,
                        "E-Board Settings Change, Cycles--flowing: " + EBD_flowCycle + " => " + flowCycle);
            }

            if (EBD_blinkCycle != blinkCycle) {
                logParkingOperation(OpLogLevel.UserCarChange,
                        "E-Board Settings Change, Cycles--blinking: " + EBD_blinkCycle + " => " + blinkCycle);
            }

            if (mainForm != null && gateCountChanged) {
                JOptionPane.showMessageDialog(mainForm, REBOOT_MESSAGE.getContent(), REBOOT_POPUP.getContent(),
                        WARNING_MESSAGE,
                        new javax.swing.ImageIcon(mainForm.getClass().getResource("/restart.png")));
                mainForm.askUserIntentionOnProgramStop(true);
            }
            //</editor-fold>

            Globals.getOperationLog().setLevel(index2Level(opLoggingIndex));
        } else {
            JOptionPane.showMessageDialog(this, FAIL_SAVE_SETTINGS_DIALOG.getContent(),
                    SETTINGS_SAVE_RESULT.getContent(), JOptionPane.ERROR_MESSAGE);
        }
        // </editor-fold>
    }
    boolean majorChange[] = new boolean[] { false };

    result += saveGateDevices(majorChange);

    if (mainForm != null && (gateCountChanged || majorChange[0])) {
        JOptionPane.showMessageDialog(mainForm, REBOOT_MESSAGE.getContent(), REBOOT_POPUP.getContent(),
                WARNING_MESSAGE, new javax.swing.ImageIcon(mainForm.getClass().getResource("/restart.png")));
        mainForm.askUserIntentionOnProgramStop(true);
    }

    if (result == gateCount + 1) {
        readSettings();
        Globals.getOperationLog().setLevel(index2Level(opLoggingIndex));
        JOptionPane.showMessageDialog(this, SAVE_SETTINGS_DIALOG.getContent(),
                SETTINGS_SAVE_RESULT.getContent(), JOptionPane.PLAIN_MESSAGE);
        enableSaveCancelButtons(false);
    } else {
        JOptionPane.showMessageDialog(this, FAIL_SAVE_SETTINGS_DIALOG.getContent(),
                SETTINGS_SAVE_RESULT.getContent(), JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.osparking.osparking.Settings_System.java

private void lotNameTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lotNameTextFieldKeyTyped
    if (lotNameTextField.getText().trim().length() >= PARKING_LOT_NAME_LENGTH_MAX) {
        getToolkit().beep();//w  ww .j a v a2 s.  co  m
        JOptionPane.showConfirmDialog(this,
                LOT_NAME_LABEL.getContent() + " " + LIMIT_LABEL.getContent() + " : "
                        + PARKING_LOT_NAME_LENGTH_MAX,
                ERROR_DIALOGTITLE.getContent(), JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
        evt.consume();
    }
}

From source file:com.osparking.osparking.Settings_System.java

/**
 * Checks if natural number is entered and give warning when non-numeric entered.
 * @param textField field whose text is supposed to contain a number
 * @param dialogTitle title of the dialog box that will be shown when non-natural number string is entered
 * @return <b>true</b> when a natural number is in the <code>textField</code>, 
 * <b>false</b> otherwise//  w ww .ja va2s  .c om
 */
private boolean TextFieldNumericValueOK(JTextField textField, String dialogTitle) {
    // Check if empty string or numeric 0 were entered. 
    String input = textField.getText().trim();

    input = removeNonNumeric(input);

    if (input.length() == 0 || Integer.parseInt(input) == 0) {
        JOptionPane.showConfirmDialog(this, "Enter a value of 1 or more ..", dialogTitle,
                JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
        textField.requestFocusInWindow();
        textField.select(0, input.length());
        return false;
    } else {
        return true;
    }
}

From source file:com.osparking.osparking.Settings_System.java

private boolean someIPaddressWrong() {
    InetAddressValidator validator = InetAddressValidator.getInstance();

    for (int i = 0; i < gateCount; i++) {
        JTextField txtField;/*  www.j  a  v a 2s. com*/

        for (DeviceType devType : DeviceType.values()) {
            String devName = devType.toString();
            txtField = (JTextField) getComponentByName(devName + (i + 1) + "_IP_TextField");
            if (!validator.isValidInet4Address(txtField.getText())) {
                GatesTabbedPane.setSelectedIndex(i);
                txtField.requestFocusInWindow();
                JOptionPane.showConfirmDialog(this,
                        devType.getContent() + " #" + (i + 1) + " " + IP_ADDR_ERROR_1.getContent()
                                + System.lineSeparator() + IP_ADDR_ERROR_2.getContent() + "127.0.0.1",
                        IP_ERROR_TITLE.getContent(), JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
                return true;
            }
        }
    }
    return false;
}

From source file:com.osparking.osparking.Settings_System.java

private void rejectLongPortNumber(KeyEvent evt, DeviceType devType, int gateNo) {
    JTextField portField = (JTextField) componentMap.get(devType.toString() + gateNo + "_Port_TextField");

    if (portField.getText().trim().length() >= PORT_NUMBER_LENGTH_MAX) {
        getToolkit().beep();/*from w w  w.  j  av  a2  s.  c  om*/
        JOptionPane.showConfirmDialog(this,
                PORT_LABEL.getContent() + " " + NUMBER_LIMIT_DESCRIPTION.getContent() + " : "
                        + PORT_NUMBER_LENGTH_MAX,
                ERROR_DIALOGTITLE.getContent(), JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
        evt.consume();
    } else {
        // check if portField input is in the available range of port number.
    }
}

From source file:com.osparking.osparking.Settings_System.java

private void checkGateNameLength(int gateNo, KeyEvent evt) {
    JTextField gateNameField = (JTextField) getComponentByName("TextFieldGateName" + gateNo);
    String gateName = gateNameField.getText().trim();

    if (gateName.length() > GATE_NAME_LENGTH_MAX) {
        gateNameField.setText(gateNames[gateNo]);
        getToolkit().beep();/*from ww w . j  a v a2  s.com*/
        JOptionPane.showConfirmDialog(this,
                GATE_NAME_LABEL2.getContent() + " " + System.lineSeparator() + System.lineSeparator()
                        + LIMIT_LABEL.getContent() + GATE_NAME_LENGTH_MAX,
                ERROR_DIALOGTITLE.getContent(), JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
        evt.consume();
    }
}