Search in sources :

Example 1 with JvmSettings

use of com.att.aro.core.settings.impl.JvmSettings 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)

Aggregations

JvmSettings (com.att.aro.core.settings.impl.JvmSettings)1 NumericInputVerifier (com.att.aro.ui.utils.NumericInputVerifier)1 Dimension (java.awt.Dimension)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 JComboBox (javax.swing.JComboBox)1 JPanel (javax.swing.JPanel)1 JTextField (javax.swing.JTextField)1