Commit 9ce62cd5 authored by Alexander Weigl's avatar Alexander Weigl
Browse files

add textareas to the settings dialog

parent d7304c3b
......@@ -23,9 +23,11 @@ import net.miginfocom.swing.MigLayout;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.util.List;
import java.util.Arrays;
import java.util.List;
/**
* Extension of {@link SimpleSettingsPanel} which uses {@link MigLayout} to
......@@ -218,6 +220,14 @@ public abstract class SettingsPanel extends SimpleSettingsPanel {
addRowWithHelp(helpText, label, component);
}
protected JTextArea addTextArea(String title, String text, String info, final Validator<String> validator) {
JTextArea field = createTextArea(text, validator);
addTitledComponent(title, field, info);
return field;
}
/**
* @param title
* @param text
......@@ -231,6 +241,7 @@ public abstract class SettingsPanel extends SimpleSettingsPanel {
return field;
}
protected JTextField addTextField(String title, String text, String info, final Validator<String> validator,
JComponent additionalActions) {
JTextField field = createTextField(text, validator);
......
......@@ -24,6 +24,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.JTextComponent;
import java.awt.*;
import java.text.Format;
......@@ -102,6 +103,13 @@ public class SimpleSettingsPanel extends JPanel {
return checkBox;
}
protected JTextArea createTextArea(String text, Validator<String> validator) {
JTextArea area = new JTextArea(text);
area.getDocument().addDocumentListener(new DocumentValidatorAdapter(area, validator));
return area;
}
protected JTextField createTextField(String text, final @Nullable Validator<String> validator) {
JTextField field = new JTextField(text);
field.getDocument().addDocumentListener(new DocumentValidatorAdapter(field, validator));
......@@ -161,10 +169,10 @@ public class SimpleSettingsPanel extends JPanel {
}
private class DocumentValidatorAdapter implements DocumentListener {
private final JTextField field;
private final JTextComponent field;
private final @Nullable Validator<String> validator;
private DocumentValidatorAdapter(JTextField field, @Nullable Validator<String> validator) {
private DocumentValidatorAdapter(JTextComponent field, @Nullable Validator<String> validator) {
this.field = field;
this.validator = validator;
}
......
......@@ -35,8 +35,8 @@ public class StandardUISettings extends SettingsPanel implements SettingsProvide
private final JCheckBox chkMinimizeInteraction;
private final JComboBox<String> spFontSizeTreeSequent;
private final JCheckBox chkEnsureSourceConsistency;
private final JTextField txtClutterRules;
private final JTextField txtClutterRuleSets;
private final JTextArea txtClutterRules;
private final JTextArea txtClutterRuleSets;
public StandardUISettings() {
setHeaderText(getDescription());
......@@ -59,15 +59,15 @@ public class StandardUISettings extends SettingsPanel implements SettingsProvide
chkShowWholeTacletCB =
addCheckBox("Show whole taclet", "Pretty-print whole Taclet including \n" +
"'name', 'find', 'varCond' and 'heuristics'", false, emptyValidator());
"'name', 'find', 'varCond' and 'heuristics'", false, emptyValidator());
chkShowUninstantiatedTaclet =
addCheckBox("Show uninstantiated taclet", "recommended for unexperienced users",
false, emptyValidator());
false, emptyValidator());
txtClutterRules = addTextField("Clutter rules", "", INFO_CLUTTER_RULE, emptyValidator());
txtClutterRuleSets =
addTextField("Clutter Rulesets", "", INFO_CLUTTER_RULESET, emptyValidator());
txtClutterRules = addTextArea("Clutter rules", "", INFO_CLUTTER_RULE, emptyValidator());
txtClutterRuleSets = addTextArea("Clutter Rulesets", "", INFO_CLUTTER_RULESET, emptyValidator());
chkPrettyPrint = addCheckBox("Pretty print terms", "", false, emptyValidator());
chkUseUnicode = addCheckBox("Use unicode", "", false, emptyValidator());
......@@ -96,8 +96,8 @@ public class StandardUISettings extends SettingsPanel implements SettingsProvide
GeneralSettings generalSettings = ProofIndependentSettings.DEFAULT_INSTANCE.getGeneralSettings();
txtClutterRules.setText(vs.clutterRules().value());
txtClutterRuleSets.setText(vs.clutterRuleSets().value());
txtClutterRules.setText(vs.clutterRules().value().replace(',', '\n'));
txtClutterRuleSets.setText(vs.clutterRuleSets().value().replace(',', '\n'));
spFontSizeGlobal.setValue(vs.getUIFontSizeFactor());
txtMaxTooltipLines.setValue(vs.getMaxTooltipLines());
......@@ -130,9 +130,8 @@ public class StandardUISettings extends SettingsPanel implements SettingsProvide
vs.setUIFontSizeFactor((Double) spFontSizeGlobal.getValue());
vs.setMaxTooltipLines((Integer) txtMaxTooltipLines.getValue());
vs.clutterRules().set(txtClutterRules.getText());
vs.clutterRuleSets().set(txtClutterRuleSets.getText());
vs.clutterRules().set(txtClutterRules.getText().replace('\n',','));
vs.clutterRuleSets().set(txtClutterRuleSets.getText().replace('\n',','));
vs.setShowWholeTaclet(chkShowWholeTacletCB.isSelected());
vs.setShowUninstantiatedTaclet(chkShowUninstantiatedTaclet.isSelected());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment