Search in sources :

Example 1 with ConfigurationValueInteger

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

the class OptionsPanel method defaultValuesInteger.

/**
 * Restore all integer options to their default values.
 */
private void defaultValuesInteger() {
    for (Entry<ConfigurationValueInteger, Object> entry : integerValues.entrySet()) {
        if ((entry.getValue() != null) && (entry.getKey() != null)) {
            if (entry.getValue() instanceof JSpinner) {
                JSpinner spinner = (JSpinner) entry.getValue();
                SpinnerModel model = spinner.getModel();
                model.setValue(Integer.valueOf(entry.getKey().getDefaultValue()));
            }
            if (entry.getValue() instanceof ButtonGroup) {
                ButtonGroup group = (ButtonGroup) entry.getValue();
                setButtonGroupSelection(group, entry.getKey().getDefaultValue());
            }
        }
    }
}
Also used : ConfigurationValueInteger(org.wikipediacleaner.utils.ConfigurationValueInteger) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner) SpinnerModel(javax.swing.SpinnerModel)

Example 2 with ConfigurationValueInteger

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

the class OptionsPanel method applyInteger.

/**
 * Apply new values to the integer options.
 */
private void applyInteger() {
    Configuration config = Configuration.getConfiguration();
    for (Entry<ConfigurationValueInteger, Object> entry : integerValues.entrySet()) {
        if ((entry.getValue() != null) && (entry.getKey() != null)) {
            if (entry.getValue() instanceof JSpinner) {
                JSpinner spinner = (JSpinner) entry.getValue();
                Object value = spinner.getValue();
                if (value instanceof Integer) {
                    Integer intValue = (Integer) value;
                    config.setInt(null, entry.getKey(), intValue.intValue());
                }
            }
            if (entry.getValue() instanceof ButtonGroup) {
                ButtonGroup group = (ButtonGroup) entry.getValue();
                int count = 0;
                Enumeration<AbstractButton> buttons = group.getElements();
                while (buttons.hasMoreElements()) {
                    AbstractButton button = buttons.nextElement();
                    if (group.isSelected(button.getModel())) {
                        config.setInt(null, entry.getKey(), count);
                    }
                    count++;
                }
            }
        }
    }
}
Also used : ConfigurationValueInteger(org.wikipediacleaner.utils.ConfigurationValueInteger) ConfigurationValueInteger(org.wikipediacleaner.utils.ConfigurationValueInteger) AbstractButton(javax.swing.AbstractButton) Configuration(org.wikipediacleaner.utils.Configuration) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner)

Aggregations

ButtonGroup (javax.swing.ButtonGroup)2 JSpinner (javax.swing.JSpinner)2 ConfigurationValueInteger (org.wikipediacleaner.utils.ConfigurationValueInteger)2 AbstractButton (javax.swing.AbstractButton)1 SpinnerModel (javax.swing.SpinnerModel)1 Configuration (org.wikipediacleaner.utils.Configuration)1