Search in sources :

Example 1 with NumericInputVerifier

use of com.att.aro.ui.utils.NumericInputVerifier in project VideoOptimzer by attdevsupport.

the class PreferencesDialog method getValuePanel.

private Component getValuePanel(final Config config) {
    int fieldHeight = Util.isLinuxOS() ? 28 : 20;
    JPanel panel = new JPanel();
    Dimension size = new Dimension(300, fieldHeight);
    panel.setLayout(new BoxLayout(panel, LINE_AXIS));
    setSize(panel, size);
    if (config.getConfigType() == ConfigType.TEXT) {
        panel.add(getValueTextField(config, size));
    } else if (config.getConfigType() == ConfigType.MEMORY || config.getConfigType() == ConfigType.NUMBER) {
        double maximumValue = 1;
        JTextField textField = getValueTextField(config, size);
        if (config.getConfigType() == ConfigType.MEMORY) {
            maximumValue = ((JvmSettings) JvmSettings.getInstance()).getMaximumMemoryGB();
        }
        textField.setInputVerifier(new NumericInputVerifier(maximumValue, 2, 1, false, this));
        textField.addKeyListener(getKeyListener(textField));
        textField.addFocusListener(new FocusListener() {

            @Override
            public void focusLost(FocusEvent e) {
                if (hider != null) {
                    closePopup();
                }
            }

            @Override
            public void focusGained(FocusEvent e) {
            }
        });
        panel.add(textField);
    } else if (config.getConfigType() == ConfigType.FILE) {
        Dimension txtSize = new Dimension(220, fieldHeight);
        final JTextField textField = getValueTextField(config, txtSize);
        Dimension btnSize = new Dimension(75, fieldHeight);
        JButton btnBrowse = new JButton("Browse");
        setSize(btnBrowse, btnSize);
        btnBrowse.addActionListener((ActionEvent e) -> setPathTextField(textField));
        panel.add(textField);
        panel.add(btnBrowse);
    } else if (config.getConfigType() == ConfigType.COMBO) {
        JComboBox<String> comboBox = new JComboBox<>(getComboValue(config));
        comboBox.addActionListener((ActionEvent e) -> setLoggingLvl((String) comboBox.getSelectedItem()));
        comboBox.setSelectedItem(Util.getLoggingLevel());
        panel.add(comboBox);
    }
    return panel;
}
Also used : JPanel(javax.swing.JPanel) JComboBox(javax.swing.JComboBox) NumericInputVerifier(com.att.aro.ui.utils.NumericInputVerifier) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) FocusEvent(java.awt.event.FocusEvent) Point(java.awt.Point) JvmSettings(com.att.aro.core.settings.impl.JvmSettings) FocusListener(java.awt.event.FocusListener)

Example 2 with NumericInputVerifier

use of com.att.aro.ui.utils.NumericInputVerifier in project VideoOptimzer by attdevsupport.

the class VideoPreferencesPanel method getVideoPrefencesPanel.

private Component getVideoPrefencesPanel() {
    stallTriggerTimeEdit = new JTextField(String.format("%.3f", videoUsagePrefs.getStallTriggerTime()), 5);
    maxBufferEdit = new JTextField(String.format("%.2f", videoUsagePrefs.getMaxBuffer()), 5);
    stallPausePointEdit = new JTextField(String.format("%.4f", videoUsagePrefs.getStallPausePoint()), 5);
    stallRecoveryEdit = new JTextField(String.format("%.4f", videoUsagePrefs.getStallRecovery()), 5);
    targetedStartupDelayEdit = new JTextField(String.format("%.2f", videoUsagePrefs.getStartupDelay()), 5);
    nearStallEdit = new JTextField(String.format("%.4f", videoUsagePrefs.getNearStall()), 5);
    stallTriggerTimeEdit.setInputVerifier(getNumericInputVerifier(MAX_STALLTRIGGERTIME, 0.01, 3));
    stallTriggerTimeEdit.addKeyListener(getKeyListener(stallTriggerTimeEdit));
    maxBufferEdit.setInputVerifier(getNumericInputVerifier(MAX_BUFFER, 0, 2));
    maxBufferEdit.addKeyListener(getKeyListener(maxBufferEdit));
    stallPausePointEdit.setInputVerifier(getNumericInputVerifier(MAX_STALLRECOVERY, 0, 4));
    stallPausePointEdit.addKeyListener(getKeyListener(stallPausePointEdit));
    stallRecoveryEdit.setInputVerifier(getNumericInputVerifier(MAX_STALLRECOVERY, 0, 4));
    stallRecoveryEdit.addKeyListener(getKeyListener(stallRecoveryEdit));
    targetedStartupDelayEdit.setInputVerifier(getNumericInputVerifier(MAX_TARGETEDSTARTUPDELAY, 0, 2));
    targetedStartupDelayEdit.addKeyListener(getKeyListener(targetedStartupDelayEdit));
    NumericInputVerifier numericInputVerifier = getNumericInputVerifier(MAX_NEARSTALL, 0.01, 4);
    nearStallEdit.setInputVerifier(numericInputVerifier);
    nearStallEdit.addKeyListener(getKeyListener(nearStallEdit));
    startupDelayReminder = new JCheckBox();
    duplicateHandlingEditCombo = new JComboBox<>();
    for (DUPLICATE_HANDLING item : DUPLICATE_HANDLING.values()) {
        duplicateHandlingEditCombo.addItem(item);
    }
    duplicateHandlingEditCombo.setSelectedItem(videoUsagePrefs.getDuplicateHandling());
    idx = 0;
    GridBagLayout gridBagLayout = new GridBagLayout();
    JPanel panel = new JPanel(gridBagLayout);
    panel.setAlignmentX(CENTER_ALIGNMENT);
    panel.setBorder(new RoundedBorder(new Insets(10, 10, 10, 10), null));
    addVideoPreference(panel);
    addDefaultButton(panel, 2, numericInputVerifier);
    return panel;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) NumericInputVerifier(com.att.aro.ui.utils.NumericInputVerifier) JTextField(javax.swing.JTextField) RoundedBorder(com.att.aro.ui.commonui.RoundedBorder) DUPLICATE_HANDLING(com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs.DUPLICATE_HANDLING)

Aggregations

NumericInputVerifier (com.att.aro.ui.utils.NumericInputVerifier)2 JPanel (javax.swing.JPanel)2 JTextField (javax.swing.JTextField)2 JvmSettings (com.att.aro.core.settings.impl.JvmSettings)1 DUPLICATE_HANDLING (com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs.DUPLICATE_HANDLING)1 RoundedBorder (com.att.aro.ui.commonui.RoundedBorder)1 Dimension (java.awt.Dimension)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 Point (java.awt.Point)1 ActionEvent (java.awt.event.ActionEvent)1 FocusEvent (java.awt.event.FocusEvent)1 FocusListener (java.awt.event.FocusListener)1 BoxLayout (javax.swing.BoxLayout)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1