OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 18 | Rev 28 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 25
Line 11... Line 11...
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.erp.generationDoc.DocumentLocalStorageManager;
16
import org.openconcerto.erp.generationDoc.SheetXml;
17
import org.openconcerto.erp.generationDoc.SheetXml;
17
import org.openconcerto.erp.utils.FileUtility;
18
import org.openconcerto.erp.utils.FileUtility;
18
import org.openconcerto.ui.DefaultGridBagConstraints;
19
import org.openconcerto.ui.DefaultGridBagConstraints;
19
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
20
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
20
import org.openconcerto.utils.Tuple2;
21
import org.openconcerto.utils.Tuple2;
Line 236... Line 237...
236
    @Override
237
    @Override
237
    public void restoreToDefaults() {
238
    public void restoreToDefaults() {
238
        final Color foregroundColor = UIManager.getColor("TextField.foreground");
239
        final Color foregroundColor = UIManager.getColor("TextField.foreground");
239
 
240
 
240
        for (final Entry<String, JTextField> entry : this.mapKeyTextOO.entrySet()) {
241
        for (final Entry<String, JTextField> entry : this.mapKeyTextOO.entrySet()) {
241
            final File f = new File(SheetXml.getLocationForTuple(Tuple2.create("GetDefault", this.mapKeyLabel.get(entry.getKey())), false));
242
            final File f = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory("Default");
242
            final JTextField textField = entry.getValue();
243
            final JTextField textField = entry.getValue();
243
            if (f.exists()) {
244
            if (f.exists()) {
244
                textField.setForeground(foregroundColor);
245
                textField.setForeground(foregroundColor);
245
            } else {
246
            } else {
246
                textField.setForeground(Color.RED);
247
                textField.setForeground(Color.RED);
Line 252... Line 253...
252
                e.printStackTrace();
253
                e.printStackTrace();
253
            }
254
            }
254
        }
255
        }
255
 
256
 
256
        for (final Entry<String, JTextField> entry : this.mapKeyTextPDF.entrySet()) {
257
        for (final Entry<String, JTextField> entry : this.mapKeyTextPDF.entrySet()) {
257
            final File f = new File(SheetXml.getLocationForTuple(Tuple2.create("GetDefault", this.mapKeyLabel.get(entry.getKey())), true));
258
            final File f = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory("Default");
258
            final JTextField textField = entry.getValue();
259
            final JTextField textField = entry.getValue();
259
            if (f.exists()) {
260
            if (f.exists()) {
260
                textField.setForeground(foregroundColor);
261
                textField.setForeground(foregroundColor);
261
            } else {
262
            } else {
262
                textField.setForeground(Color.RED);
263
                textField.setForeground(Color.RED);
263
            }
264
            }
264
            try {
265
            try {
265
                textField.setText(f.getCanonicalPath());
266
                textField.setText(f.getCanonicalPath());
266
            } catch (IOException e) {
267
            } catch (IOException e) {
267
                // TODO Auto-generated catch block
-
 
268
                e.printStackTrace();
268
                e.printStackTrace();
269
            }
269
            }
270
        }
270
        }
271
    }
271
    }
272
 
272
 
Line 279... Line 279...
279
        }
279
        }
280
    }
280
    }
281
 
281
 
282
    private void updateTextFields(final Map<String, JTextField> map, final String format) throws IOException {
282
    private void updateTextFields(final Map<String, JTextField> map, final String format) throws IOException {
283
        final Color foregroundColor = UIManager.getColor("TextField.foreground");
283
        final Color foregroundColor = UIManager.getColor("TextField.foreground");
-
 
284
        final DocumentLocalStorageManager storage = DocumentLocalStorageManager.getInstance();
284
        for (final Entry<String, JTextField> entry : map.entrySet()) {
285
        for (final Entry<String, JTextField> entry : map.entrySet()) {
-
 
286
            final File f;
-
 
287
            if (format.equalsIgnoreCase("PDF")) {
-
 
288
                f = storage.getPDFOutputDirectory(entry.getKey());
-
 
289
            } else {
285
            final File f = new File(SheetXml.getLocationForTuple(Tuple2.create(entry.getKey(), this.mapKeyLabel.get(entry.getKey())), format.equalsIgnoreCase("PDF")));
290
                f = storage.getDocumentOutputDirectory(entry.getKey());
-
 
291
            }
286
            final JTextField textField = entry.getValue();
292
            final JTextField textField = entry.getValue();
287
            if (f.exists()) {
293
            if (f.exists()) {
288
                textField.setForeground(foregroundColor);
294
                textField.setForeground(foregroundColor);
289
            } else {
295
            } else {
290
                textField.setForeground(Color.RED);
296
                textField.setForeground(Color.RED);