Search in sources :

Example 1 with ConfigurationValueString

use of org.wikipediacleaner.utils.ConfigurationValueString in project wpcleaner by WPCleaner.

the class OptionsPanel method defaultValuesString.

/**
 * Restore all string options to their default values.
 */
private void defaultValuesString() {
    for (Entry<ConfigurationValueString, JComponent> entry : stringValues.entrySet()) {
        if ((entry.getValue() != null) && (entry.getKey() != null)) {
            if (entry.getValue() instanceof JTextField) {
                JTextField text = (JTextField) entry.getValue();
                text.setText(entry.getKey().getDefaultValue());
            }
            if (entry.getValue() instanceof JComboBox) {
                JComboBox combo = (JComboBox) entry.getValue();
                combo.setSelectedItem(entry.getKey().getDefaultValue());
            }
        }
    }
}
Also used : ConfigurationValueString(org.wikipediacleaner.utils.ConfigurationValueString) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) JTextField(javax.swing.JTextField)

Example 2 with ConfigurationValueString

use of org.wikipediacleaner.utils.ConfigurationValueString in project wpcleaner by WPCleaner.

the class OptionsPanel method createJTextField.

/**
 * @param property String property.
 * @param columns Number of columns in the text field.
 * @return JTextField for the string property.
 */
protected JTextField createJTextField(ConfigurationValueString property, int columns) {
    if (property == null) {
        return null;
    }
    Configuration config = Configuration.getConfiguration();
    String value = config.getString(null, property);
    JTextField txt = new JTextField(columns);
    txt.setText(value);
    stringValues.put(property, txt);
    return txt;
}
Also used : Configuration(org.wikipediacleaner.utils.Configuration) ConfigurationValueString(org.wikipediacleaner.utils.ConfigurationValueString) JTextField(javax.swing.JTextField)

Example 3 with ConfigurationValueString

use of org.wikipediacleaner.utils.ConfigurationValueString in project wpcleaner by WPCleaner.

the class OptionsPanel method createJComboBox.

protected JComboBox<String> createJComboBox(ConfigurationValueString property, Vector<String> items) {
    if (property == null) {
        return null;
    }
    JComboBox<String> combo = new JComboBox<>(items);
    combo.setEditable(false);
    Configuration config = Configuration.getConfiguration();
    String value = config.getString(null, property);
    combo.setSelectedItem(value);
    stringValues.put(property, combo);
    return combo;
}
Also used : JComboBox(javax.swing.JComboBox) Configuration(org.wikipediacleaner.utils.Configuration) ConfigurationValueString(org.wikipediacleaner.utils.ConfigurationValueString)

Example 4 with ConfigurationValueString

use of org.wikipediacleaner.utils.ConfigurationValueString in project wpcleaner by WPCleaner.

the class OptionsPanel method applyString.

/**
 * Apply new values to the string options.
 */
private void applyString() {
    Configuration config = Configuration.getConfiguration();
    for (Entry<ConfigurationValueString, JComponent> entry : stringValues.entrySet()) {
        if ((entry.getValue() != null) && (entry.getKey() != null)) {
            if (entry.getValue() instanceof JTextField) {
                JTextField text = (JTextField) entry.getValue();
                config.setString(null, entry.getKey(), text.getText());
            }
            if (entry.getValue() instanceof JComboBox) {
                JComboBox combo = (JComboBox) entry.getValue();
                Object selection = combo.getSelectedItem();
                if (selection != null) {
                    config.setString(null, entry.getKey(), selection.toString());
                }
            }
        }
    }
}
Also used : ConfigurationValueString(org.wikipediacleaner.utils.ConfigurationValueString) Configuration(org.wikipediacleaner.utils.Configuration) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) JTextField(javax.swing.JTextField)

Aggregations

ConfigurationValueString (org.wikipediacleaner.utils.ConfigurationValueString)4 JComboBox (javax.swing.JComboBox)3 JTextField (javax.swing.JTextField)3 Configuration (org.wikipediacleaner.utils.Configuration)3 JComponent (javax.swing.JComponent)2