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());
}
}
}
}
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++;
}
}
}
}
}
Aggregations