OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 151 | Rev 182 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 151 Rev 180
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.preferences;
14
 package org.openconcerto.erp.preferences;
15
 
15
 
16
import org.openconcerto.laf.LAFUtils;
16
import org.openconcerto.laf.LAFUtils;
17
import org.openconcerto.ui.DefaultGridBagConstraints;
17
import org.openconcerto.ui.DefaultGridBagConstraints;
18
import org.openconcerto.ui.table.AlternateTableCellRenderer;
18
import org.openconcerto.ui.table.AlternateTableCellRenderer;
19
import org.openconcerto.ui.warning.JLabelWarning;
19
import org.openconcerto.ui.warning.JLabelWarning;
20
import org.openconcerto.utils.ExceptionHandler;
20
import org.openconcerto.utils.ExceptionHandler;
21
 
21
 
22
import java.awt.Color;
22
import java.awt.Color;
23
import java.awt.GridBagConstraints;
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
24
import java.awt.GridBagLayout;
25
import java.awt.GridLayout;
25
import java.awt.GridLayout;
26
import java.awt.event.MouseAdapter;
26
import java.awt.event.MouseAdapter;
27
import java.awt.event.MouseEvent;
27
import java.awt.event.MouseEvent;
28
import java.util.ArrayList;
28
import java.util.ArrayList;
29
import java.util.Collections;
29
import java.util.Collections;
30
import java.util.Enumeration;
30
import java.util.Enumeration;
31
import java.util.List;
31
import java.util.List;
32
import java.util.Properties;
32
import java.util.Properties;
33
 
33
 
34
import javax.swing.BorderFactory;
34
import javax.swing.BorderFactory;
35
import javax.swing.JComboBox;
35
import javax.swing.JComboBox;
36
import javax.swing.JLabel;
36
import javax.swing.JLabel;
37
import javax.swing.JPanel;
37
import javax.swing.JPanel;
38
import javax.swing.UIManager;
38
import javax.swing.UIManager;
39
import javax.swing.UIManager.LookAndFeelInfo;
39
import javax.swing.UIManager.LookAndFeelInfo;
40
import javax.swing.UnsupportedLookAndFeelException;
40
import javax.swing.UnsupportedLookAndFeelException;
41
import javax.swing.border.LineBorder;
41
import javax.swing.border.LineBorder;
42
 
42
 
-
 
43
import com.formdev.flatlaf.FlatLightLaf;
-
 
44
 
43
public class UIPreferencePanel extends DefaultLocalPreferencePanel {
45
public class UIPreferencePanel extends DefaultLocalPreferencePanel {
44
 
46
 
45
    private static final String UI_PROPERTIES = "ui.properties";
47
    private static final String UI_PROPERTIES = "ui.properties";
46
    private static final String ALTERNATE_COLOR_BLUE = "ui.list.alternate.color.blue";
48
    private static final String ALTERNATE_COLOR_BLUE = "ui.list.alternate.color.blue";
47
    private static final String ALTERNATE_COLOR_GREEN = "ui.list.alternate.color.green";
49
    private static final String ALTERNATE_COLOR_GREEN = "ui.list.alternate.color.green";
48
    private static final String ALTERNATE_COLOR_RED = "ui.list.alternate.color.red";
50
    private static final String ALTERNATE_COLOR_RED = "ui.list.alternate.color.red";
49
    private static final String UI_DPI = "ui.default.dpi";
51
    private static final String UI_DPI = "ui.default.dpi";
50
    private static final String UI_LOOK = "ui.look";
52
    private static final String UI_LOOK = "ui.look";
51
    private JLabel selectedButton;
53
    private JLabel selectedButton;
52
    private JComboBox comboLook, comboDPI;
54
    private JComboBox comboLook, comboDPI;
53
 
55
 
54
    public UIPreferencePanel() {
56
    public UIPreferencePanel() {
55
        super("Interface graphique", UI_PROPERTIES);
57
        super("Interface graphique", UI_PROPERTIES);
56
    }
58
    }
57
 
59
 
58
    @Override
60
    @Override
59
    public void uiInit() {
61
    public void uiInit() {
60
        this.setLayout(new GridBagLayout());
62
        this.setLayout(new GridBagLayout());
61
        final GridBagConstraints c = new DefaultGridBagConstraints();
63
        final GridBagConstraints c = new DefaultGridBagConstraints();
62
        c.fill = GridBagConstraints.NONE;
64
        c.fill = GridBagConstraints.NONE;
63
        this.add(new JLabel("Look"), c);
65
        this.add(new JLabel("Look"), c);
64
        comboLook = new JComboBox(new String[] { "natif du système", "Nimbus" });
66
        comboLook = new JComboBox(new String[] { "natif du système", "Nimbus", "Flat" });
65
        String look = this.properties.getProperty(UI_LOOK);
67
        String look = this.properties.getProperty(UI_LOOK);
66
        if (look != null && !look.equals("system")) {
68
        if (look != null && look.equals("nimbus")) {
67
            comboLook.setSelectedIndex(1);
69
            comboLook.setSelectedIndex(1);
-
 
70
        } else if (look != null && look.equals("flat")) {
-
 
71
            comboLook.setSelectedIndex(2);
68
        } else {
72
        } else {
69
            comboLook.setSelectedIndex(0);
73
            comboLook.setSelectedIndex(0);
70
        }
74
        }
71
 
75
 
72
        c.gridx++;
76
        c.gridx++;
73
        this.add(comboLook, c);
77
        this.add(comboLook, c);
74
 
78
 
75
        c.gridy++;
79
        c.gridy++;
76
        c.gridx = 0;
80
        c.gridx = 0;
77
        this.add(new JLabel("High DPI"), c);
81
        this.add(new JLabel("High DPI"), c);
78
        this.comboDPI = new JComboBox(new String[] { "Désactivé", "x1.3", "x2", "x3", "x4" });
82
        this.comboDPI = new JComboBox(new String[] { "Désactivé", "x1.3", "x2", "x3", "x4" });
79
        String dpi = this.properties.getProperty(UI_DPI);
83
        String dpi = this.properties.getProperty(UI_DPI);
80
        if (dpi != null && !dpi.equals("1")) {
84
        if (dpi != null && !dpi.equals("1")) {
81
            comboDPI.setSelectedIndex(Float.valueOf(dpi).intValue());
85
            comboDPI.setSelectedIndex(Float.valueOf(dpi).intValue());
82
        }
86
        }
83
 
87
 
84
        c.gridx++;
88
        c.gridx++;
85
        this.add(comboDPI, c);
89
        this.add(comboDPI, c);
86
 
90
 
87
        final JLabel labelAlternate = new JLabel("Couleur de fond dans les liste pour l'alternance");
91
        final JLabel labelAlternate = new JLabel("Couleur de fond dans les liste pour l'alternance");
88
        c.gridx = 0;
92
        c.gridx = 0;
89
        c.gridwidth = 2;
93
        c.gridwidth = 2;
90
        c.gridy++;
94
        c.gridy++;
91
        this.add(labelAlternate, c);
95
        this.add(labelAlternate, c);
92
        List<Color> colors = new ArrayList<Color>();
96
        List<Color> colors = new ArrayList<Color>();
93
        // Gris
97
        // Gris
94
        int col = 245;
98
        int col = 245;
95
        colors.add(new Color(col, col, col));
99
        colors.add(new Color(col, col, col));
96
        col -= 10;
100
        col -= 10;
97
        colors.add(new Color(col, col, col));
101
        colors.add(new Color(col, col, col));
98
        col -= 10;
102
        col -= 10;
99
        colors.add(new Color(col, col, col));
103
        colors.add(new Color(col, col, col));
100
        col -= 10;
104
        col -= 10;
101
        colors.add(new Color(col, col, col));
105
        colors.add(new Color(col, col, col));
102
        // Bleu petrole
106
        // Bleu petrole
103
        colors.add(new Color(232, 232, 240));
107
        colors.add(new Color(232, 232, 240));
104
        colors.add(new Color(206, 206, 222));
108
        colors.add(new Color(206, 206, 222));
105
        colors.add(new Color(180, 180, 205));
109
        colors.add(new Color(180, 180, 205));
106
        colors.add(new Color(154, 154, 188));
110
        colors.add(new Color(154, 154, 188));
107
 
111
 
108
        // Bleus
112
        // Bleus
109
        colors.add(new Color(224, 240, 247));
113
        colors.add(new Color(224, 240, 247));
110
        colors.add(new Color(190, 222, 239));
114
        colors.add(new Color(190, 222, 239));
111
        colors.add(new Color(155, 205, 230));
115
        colors.add(new Color(155, 205, 230));
112
        colors.add(new Color(120, 188, 221));
116
        colors.add(new Color(120, 188, 221));
113
 
117
 
114
        // Bleus vert
118
        // Bleus vert
115
        colors.add(new Color(217, 240, 247));
119
        colors.add(new Color(217, 240, 247));
116
        colors.add(new Color(173, 222, 239));
120
        colors.add(new Color(173, 222, 239));
117
        colors.add(new Color(130, 205, 230));
121
        colors.add(new Color(130, 205, 230));
118
        colors.add(new Color(87, 188, 221));
122
        colors.add(new Color(87, 188, 221));
119
        // Bleus Ciel
123
        // Bleus Ciel
120
        colors.add(new Color(224, 247, 240));
124
        colors.add(new Color(224, 247, 240));
121
        colors.add(new Color(190, 239, 222));
125
        colors.add(new Color(190, 239, 222));
122
        colors.add(new Color(155, 230, 205));
126
        colors.add(new Color(155, 230, 205));
123
        colors.add(new Color(120, 221, 188));
127
        colors.add(new Color(120, 221, 188));
124
        // Violet
128
        // Violet
125
        colors.add(new Color(240, 217, 232));
129
        colors.add(new Color(240, 217, 232));
126
        colors.add(new Color(222, 173, 206));
130
        colors.add(new Color(222, 173, 206));
127
        colors.add(new Color(205, 130, 180));
131
        colors.add(new Color(205, 130, 180));
128
        colors.add(new Color(188, 87, 154));
132
        colors.add(new Color(188, 87, 154));
129
 
133
 
130
        // Marrons
134
        // Marrons
131
        colors.add(new Color(240, 224, 217));
135
        colors.add(new Color(240, 224, 217));
132
        colors.add(new Color(222, 190, 173));
136
        colors.add(new Color(222, 190, 173));
133
        colors.add(new Color(205, 155, 130));
137
        colors.add(new Color(205, 155, 130));
134
        colors.add(new Color(188, 120, 87));
138
        colors.add(new Color(188, 120, 87));
135
 
139
 
136
        final JPanel colorPanel = new JPanel();
140
        final JPanel colorPanel = new JPanel();
137
        colorPanel.setBorder(new LineBorder(Color.white, 2));
141
        colorPanel.setBorder(new LineBorder(Color.white, 2));
138
        colorPanel.setOpaque(true);
142
        colorPanel.setOpaque(true);
139
        colorPanel.setBackground(Color.WHITE);
143
        colorPanel.setBackground(Color.WHITE);
140
        colorPanel.setLayout(new GridLayout(colors.size() / 4, 4, 2, 2));
144
        colorPanel.setLayout(new GridLayout(colors.size() / 4, 4, 2, 2));
141
        final JLabel[] buttonsAlternate = new JLabel[colors.size()];
145
        final JLabel[] buttonsAlternate = new JLabel[colors.size()];
142
 
146
 
143
        for (int i = 0; i < colors.size(); i++) {
147
        for (int i = 0; i < colors.size(); i++) {
144
            final Color color = colors.get(i);
148
            final Color color = colors.get(i);
145
            final JLabel button = new JLabel("    label test   ");
149
            final JLabel button = new JLabel("    label test   ");
146
            button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
150
            button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
147
            buttonsAlternate[i] = button;
151
            buttonsAlternate[i] = button;
148
            button.addMouseListener(new MouseAdapter() {
152
            button.addMouseListener(new MouseAdapter() {
149
                @Override
153
                @Override
150
                public void mouseClicked(MouseEvent e) {
154
                public void mouseClicked(MouseEvent e) {
151
                    selectButton(button);
155
                    selectButton(button);
152
                }
156
                }
153
            });
157
            });
154
            button.setOpaque(true);
158
            button.setOpaque(true);
155
            button.setBackground(color);
159
            button.setBackground(color);
156
            colorPanel.add(button);
160
            colorPanel.add(button);
157
        }
161
        }
158
        c.gridy++;
162
        c.gridy++;
159
 
163
 
160
        final String cRed = properties.getProperty(ALTERNATE_COLOR_RED);
164
        final String cRed = properties.getProperty(ALTERNATE_COLOR_RED);
161
        final String cGreen = properties.getProperty(ALTERNATE_COLOR_GREEN);
165
        final String cGreen = properties.getProperty(ALTERNATE_COLOR_GREEN);
162
        final String cBlue = properties.getProperty(ALTERNATE_COLOR_BLUE);
166
        final String cBlue = properties.getProperty(ALTERNATE_COLOR_BLUE);
163
        int r = -1, g = -1, b = -1;
167
        int r = -1, g = -1, b = -1;
164
        if (cRed != null) {
168
        if (cRed != null) {
165
            r = Integer.parseInt(cRed);
169
            r = Integer.parseInt(cRed);
166
        }
170
        }
167
        if (cGreen != null) {
171
        if (cGreen != null) {
168
            g = Integer.parseInt(cGreen);
172
            g = Integer.parseInt(cGreen);
169
        }
173
        }
170
        if (cBlue != null) {
174
        if (cBlue != null) {
171
            b = Integer.parseInt(cBlue);
175
            b = Integer.parseInt(cBlue);
172
 
176
 
173
        }
177
        }
174
        selectButton(buttonsAlternate[1]);
178
        selectButton(buttonsAlternate[1]);
175
        // Select the saved color setting
179
        // Select the saved color setting
176
        if (r >= 0 && g >= 0 && b >= 0) {
180
        if (r >= 0 && g >= 0 && b >= 0) {
177
            final Color expectedColor = new Color(r, g, b);
181
            final Color expectedColor = new Color(r, g, b);
178
            for (int i = 0; i < buttonsAlternate.length; i++) {
182
            for (int i = 0; i < buttonsAlternate.length; i++) {
179
                final JLabel jLabel = buttonsAlternate[i];
183
                final JLabel jLabel = buttonsAlternate[i];
180
                if (jLabel.getBackground().equals(expectedColor)) {
184
                if (jLabel.getBackground().equals(expectedColor)) {
181
                    selectButton(jLabel);
185
                    selectButton(jLabel);
182
                    break;
186
                    break;
183
                }
187
                }
184
            }
188
            }
185
        }
189
        }
186
 
190
 
187
        this.add(colorPanel, c);
191
        this.add(colorPanel, c);
188
        c.gridy++;
192
        c.gridy++;
189
        c.weightx = 1;
193
        c.weightx = 1;
190
        c.weighty = 1;
194
        c.weighty = 1;
191
        c.anchor = GridBagConstraints.NORTHWEST;
195
        c.anchor = GridBagConstraints.NORTHWEST;
192
        this.add(new JLabelWarning("Les modifications d'interface nécessitent un redémarrage du logiciel."), c);
196
        this.add(new JLabelWarning("Les modifications d'interface nécessitent un redémarrage du logiciel."), c);
193
    }
197
    }
194
 
198
 
195
    private void selectButton(JLabel button) {
199
    private void selectButton(JLabel button) {
196
        if (button != this.selectedButton) {
200
        if (button != this.selectedButton) {
197
            if (selectedButton != null) {
201
            if (selectedButton != null) {
198
                this.selectedButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
202
                this.selectedButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
199
            }
203
            }
200
            button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
204
            button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
201
            this.selectedButton = button;
205
            this.selectedButton = button;
202
        }
206
        }
203
    }
207
    }
204
 
208
 
205
    @Override
209
    @Override
206
    public void storeValues() {
210
    public void storeValues() {
207
        final Color background = this.selectedButton.getBackground();
211
        final Color background = this.selectedButton.getBackground();
208
        properties.setProperty(ALTERNATE_COLOR_RED, String.valueOf(background.getRed()));
212
        properties.setProperty(ALTERNATE_COLOR_RED, String.valueOf(background.getRed()));
209
        properties.setProperty(ALTERNATE_COLOR_GREEN, String.valueOf(background.getGreen()));
213
        properties.setProperty(ALTERNATE_COLOR_GREEN, String.valueOf(background.getGreen()));
210
        properties.setProperty(ALTERNATE_COLOR_BLUE, String.valueOf(background.getBlue()));
214
        properties.setProperty(ALTERNATE_COLOR_BLUE, String.valueOf(background.getBlue()));
211
        AlternateTableCellRenderer.setDefaultMap(Collections.singletonMap(Color.WHITE, background));
215
        AlternateTableCellRenderer.setDefaultMap(Collections.singletonMap(Color.WHITE, background));
212
        if (this.comboLook.getSelectedIndex() == 0) {
216
        if (this.comboLook.getSelectedIndex() == 0) {
213
            properties.setProperty(UI_LOOK, "system");
217
            properties.setProperty(UI_LOOK, "system");
214
        } else {
218
        } else if (this.comboLook.getSelectedIndex() == 1) {
215
            properties.setProperty(UI_LOOK, "nimbus");
219
            properties.setProperty(UI_LOOK, "nimbus");
-
 
220
        } else {
-
 
221
            properties.setProperty(UI_LOOK, "flat");
216
        }
222
        }
217
 
223
 
218
        if (this.comboDPI.getSelectedIndex() == 1) {
224
        if (this.comboDPI.getSelectedIndex() == 1) {
219
            properties.setProperty(UI_DPI, "1.3");
225
            properties.setProperty(UI_DPI, "1.3");
220
        } else if (this.comboDPI.getSelectedIndex() == 2) {
226
        } else if (this.comboDPI.getSelectedIndex() == 2) {
221
            properties.setProperty(UI_DPI, "2");
227
            properties.setProperty(UI_DPI, "2");
222
        } else if (this.comboDPI.getSelectedIndex() == 3) {
228
        } else if (this.comboDPI.getSelectedIndex() == 3) {
223
            properties.setProperty(UI_DPI, "3");
229
            properties.setProperty(UI_DPI, "3");
224
        } else if (this.comboDPI.getSelectedIndex() == 4) {
230
        } else if (this.comboDPI.getSelectedIndex() == 4) {
225
            properties.setProperty(UI_DPI, "4");
231
            properties.setProperty(UI_DPI, "4");
226
        } else {
232
        } else {
227
            properties.setProperty(UI_DPI, "1");
233
            properties.setProperty(UI_DPI, "1");
228
        }
234
        }
229
 
235
 
230
        super.storeValues();
236
        super.storeValues();
231
    }
237
    }
232
 
238
 
233
    private static void useNimbusLF() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
239
    private static void useNimbusLF() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
234
        UIManager.setLookAndFeel(getNimbusClassName());
240
        UIManager.setLookAndFeel(getNimbusClassName());
235
        UIManager.put("control", new Color(240, 240, 240));
241
        UIManager.put("control", new Color(240, 240, 240));
236
        UIManager.put("Table.showGrid", Boolean.TRUE);
242
        UIManager.put("Table.showGrid", Boolean.TRUE);
237
        UIManager.put("FormattedTextField.background", new Color(240, 240, 240));
243
        UIManager.put("FormattedTextField.background", new Color(240, 240, 240));
238
        UIManager.put("Table.alternateRowColor", Color.WHITE);
244
        UIManager.put("Table.alternateRowColor", Color.WHITE);
239
    }
245
    }
240
 
246
 
241
    // only available from sun's release 6u10
247
    // only available from sun's release 6u10
242
    public static String getNimbusClassName() {
248
    public static String getNimbusClassName() {
243
        // http://java.sun.com/javase/6/docs/technotes/guides/jweb/otherFeatures/nimbus_laf.html
249
        // http://java.sun.com/javase/6/docs/technotes/guides/jweb/otherFeatures/nimbus_laf.html
244
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
250
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
245
            if ("Nimbus".equals(info.getName())) {
251
            if ("Nimbus".equals(info.getName())) {
246
                return info.getClassName();
252
                return info.getClassName();
247
            }
253
            }
248
        }
254
        }
249
        return null;
255
        return null;
250
    }
256
    }
251
 
257
 
252
    public static void initUIFromPreferences() {
258
    public static void initUIFromPreferences() {
253
        Properties properties;
259
        Properties properties;
254
        try {
260
        try {
255
            properties = getPropertiesFromFile(UI_PROPERTIES);
261
            properties = getPropertiesFromFile(UI_PROPERTIES);
256
            final String cRed = properties.getProperty(ALTERNATE_COLOR_RED);
262
            final String cRed = properties.getProperty(ALTERNATE_COLOR_RED);
257
            final String cGreen = properties.getProperty(ALTERNATE_COLOR_GREEN);
263
            final String cGreen = properties.getProperty(ALTERNATE_COLOR_GREEN);
258
            final String cBlue = properties.getProperty(ALTERNATE_COLOR_BLUE);
264
            final String cBlue = properties.getProperty(ALTERNATE_COLOR_BLUE);
259
            int r = -1, g = -1, b = -1;
265
            int r = -1, g = -1, b = -1;
260
            if (cRed != null) {
266
            if (cRed != null) {
261
                r = Integer.parseInt(cRed);
267
                r = Integer.parseInt(cRed);
262
            }
268
            }
263
            if (cGreen != null) {
269
            if (cGreen != null) {
264
                g = Integer.parseInt(cGreen);
270
                g = Integer.parseInt(cGreen);
265
            }
271
            }
266
            if (cBlue != null) {
272
            if (cBlue != null) {
267
                b = Integer.parseInt(cBlue);
273
                b = Integer.parseInt(cBlue);
268
            }
274
            }
269
            if (r >= 0 && g >= 0 && b >= 0) {
275
            if (r >= 0 && g >= 0 && b >= 0) {
270
                AlternateTableCellRenderer.setDefaultMap(Collections.singletonMap(Color.WHITE, new Color(r, g, b)));
276
                AlternateTableCellRenderer.setDefaultMap(Collections.singletonMap(Color.WHITE, new Color(r, g, b)));
271
            }
277
            }
272
 
278
 
273
            final String look = properties.getProperty(UI_LOOK);
279
            final String look = properties.getProperty(UI_LOOK);
274
            final String nimbusClassName = getNimbusClassName();
280
            final String nimbusClassName = getNimbusClassName();
275
 
-
 
276
            if (look != null && look.equals("system")) {
281
            if (look != null && look.equals("flat")) {
-
 
282
                FlatLightLaf.install();
-
 
283
            } else if (look != null && look.equals("system")) {
277
                useSystemLF();
284
                useSystemLF();
278
            } else if (look != null && look.equals("nimbus")) {
285
            } else if (look != null && look.equals("nimbus")) {
279
                useNimbusLF();
286
                useNimbusLF();
280
            } else if (nimbusClassName == null || !System.getProperty("os.name", "??").toLowerCase().contains("linux")) {
287
            } else if (nimbusClassName == null || !System.getProperty("os.name", "??").toLowerCase().contains("linux")) {
281
                useSystemLF();
288
                useSystemLF();
282
            } else {
289
            } else {
283
                useNimbusLF();
290
                FlatLightLaf.install();
284
            }
291
            }
285
            final String dpi = properties.getProperty(UI_DPI);
292
            final String dpi = properties.getProperty(UI_DPI);
286
            if (dpi != null && dpi.length() > 0 && !dpi.equalsIgnoreCase("1")) {
293
            if (dpi != null && dpi.length() > 0 && !dpi.equalsIgnoreCase("1")) {
287
                setUIFont(Float.valueOf(dpi));
294
                setUIFont(Float.valueOf(dpi));
288
                UIManager.put("dpi.scale", Float.valueOf(dpi));
295
                UIManager.put("dpi.scale", Float.valueOf(dpi));
289
            } else {
296
            } else {
290
                UIManager.put("dpi.scale", Float.valueOf(1));
297
                UIManager.put("dpi.scale", Float.valueOf(1));
291
            }
298
            }
292
        } catch (Exception e) {
299
        } catch (Exception e) {
293
            ExceptionHandler.handle("Unable to restore UI preferences", e);
300
            ExceptionHandler.handle("Unable to restore UI preferences", e);
294
        }
301
        }
295
    }
302
    }
296
 
303
 
297
    public static void setUIFont(float factor) {
304
    public static void setUIFont(float factor) {
298
        Enumeration<Object> keys = UIManager.getDefaults().keys();
305
        Enumeration<Object> keys = UIManager.getDefaults().keys();
299
 
306
 
300
        while (keys.hasMoreElements()) {
307
        while (keys.hasMoreElements()) {
301
            Object key = keys.nextElement();
308
            Object key = keys.nextElement();
302
            Object value = UIManager.get(key);
309
            Object value = UIManager.get(key);
303
            if (value instanceof javax.swing.plaf.FontUIResource) {
310
            if (value instanceof javax.swing.plaf.FontUIResource) {
304
                javax.swing.plaf.FontUIResource r = (javax.swing.plaf.FontUIResource) value;
311
                javax.swing.plaf.FontUIResource r = (javax.swing.plaf.FontUIResource) value;
305
 
312
 
306
                UIManager.put(key, r.deriveFont(r.getSize() * factor));
313
                UIManager.put(key, r.deriveFont(r.getSize() * factor));
307
            }
314
            }
308
        }
315
        }
309
    }
316
    }
310
 
317
 
311
    private static void useSystemLF() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
318
    private static void useSystemLF() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
312
        LAFUtils.setLookAndFeel();
319
        LAFUtils.setLookAndFeel();
313
    }
320
    }
314
}
321
}