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