Skip to content

Commit

Permalink
Add all installed LaFs to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
FliegendeWurst authored and jwiesler committed Mar 8, 2023
1 parent 755a04a commit ca4c859
Showing 1 changed file with 16 additions and 12 deletions.
Expand Up @@ -7,9 +7,7 @@
import de.uka.ilkd.key.settings.ViewSettings;

import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand All @@ -29,14 +27,12 @@ public class StandardUISettings extends SettingsPanel implements SettingsProvide
/**
* Labels for the selectable look and feels. Must be kept in sync with {@link #LAF_CLASSES}.
*/
private static final String[] LAF_LABELS = new String[] { "System", "Metal" };
private static final List<String> LAF_LABELS = new ArrayList<>(List.of("System"));
/**
* Classnames corresponding to the labels in {@link #LAF_LABELS}.
*/
private static final String[] LAF_CLASSES = new String[] {
UIManager.getSystemLookAndFeelClassName(),
MetalLookAndFeel.class.getName()
};
private static final List<String> LAF_CLASSES =
new ArrayList<>(List.of(UIManager.getSystemLookAndFeelClassName()));

private final JComboBox<String> lookAndFeel;
private final JSpinner spFontSizeGlobal;
Expand All @@ -60,7 +56,15 @@ public class StandardUISettings extends SettingsPanel implements SettingsProvide
public StandardUISettings() {
setHeaderText(getDescription());

lookAndFeel = createSelection(LAF_LABELS, emptyValidator());
// load all available look and feels
if (LAF_LABELS.size() == 1) {
for (UIManager.LookAndFeelInfo it : UIManager.getInstalledLookAndFeels()) {
LAF_LABELS.add(it.getName());
LAF_CLASSES.add(it.getClassName());
}
}

lookAndFeel = createSelection(LAF_LABELS.toArray(new String[0]), emptyValidator());
addTitledComponent("Look and feel: ", lookAndFeel, LOOK_AND_FEEL_INFO);

spFontSizeGlobal =
Expand Down Expand Up @@ -126,8 +130,8 @@ public JComponent getPanel(MainWindow window) {
txtClutterRules.setText(vs.clutterRules().value().replace(',', '\n'));
txtClutterRuleSets.setText(vs.clutterRuleSets().value().replace(',', '\n'));

for (int i = 0; i < LAF_CLASSES.length; i++) {
if (LAF_CLASSES[i].equals(vs.getLookAndFeel())) {
for (int i = 0; i < LAF_CLASSES.size(); i++) {
if (LAF_CLASSES.get(i).equals(vs.getLookAndFeel())) {
lookAndFeel.setSelectedIndex(i);
break;
}
Expand Down Expand Up @@ -161,7 +165,7 @@ public void applySettings(MainWindow window) throws InvalidSettingsInputExceptio
ViewSettings vs = ProofIndependentSettings.DEFAULT_INSTANCE.getViewSettings();
GeneralSettings gs = ProofIndependentSettings.DEFAULT_INSTANCE.getGeneralSettings();

vs.setLookAndFeel(LAF_CLASSES[lookAndFeel.getSelectedIndex()]);
vs.setLookAndFeel(LAF_CLASSES.get(lookAndFeel.getSelectedIndex()));
vs.setUIFontSizeFactor((Double) spFontSizeGlobal.getValue());
vs.setMaxTooltipLines((Integer) txtMaxTooltipLines.getValue());

Expand Down

0 comments on commit ca4c859

Please sign in to comment.