OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 182
Line 1... Line 1...
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-2019 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.
Line 29... Line 29...
29
import java.awt.event.ComponentAdapter;
29
import java.awt.event.ComponentAdapter;
30
import java.awt.event.ComponentEvent;
30
import java.awt.event.ComponentEvent;
31
import java.beans.PropertyChangeEvent;
31
import java.beans.PropertyChangeEvent;
32
import java.beans.PropertyChangeListener;
32
import java.beans.PropertyChangeListener;
33
import java.io.File;
33
import java.io.File;
-
 
34
import java.util.function.Function;
34
 
35
 
35
import javax.swing.JFrame;
36
import javax.swing.JFrame;
36
import javax.swing.event.TableModelEvent;
37
import javax.swing.event.TableModelEvent;
37
import javax.swing.event.TableModelListener;
38
import javax.swing.event.TableModelListener;
38
 
39
 
Line 45... Line 46...
45
public class IListFrame extends JFrame {
46
public class IListFrame extends JFrame {
46
 
47
 
47
    public static final String SHORT_TITLE = "org.openconcerto.listframe.shortTitle";
48
    public static final String SHORT_TITLE = "org.openconcerto.listframe.shortTitle";
48
    private static final String FILE_STRUCT_VERSION = "20160923";
49
    private static final String FILE_STRUCT_VERSION = "20160923";
49
 
50
 
-
 
51
    private static Function<? super SQLElement, File> CONF_DIR_FUNCTION = (elem) -> {
-
 
52
        final Configuration conf = Configuration.getInstance();
-
 
53
        return conf == null ? null : conf.getConfDir();
-
 
54
    };
-
 
55
 
-
 
56
    static synchronized public final void setConfDirFunction(final Function<? super SQLElement, File> f) {
-
 
57
        CONF_DIR_FUNCTION = f;
-
 
58
    }
-
 
59
 
-
 
60
    static synchronized public final File getConfDir(final SQLElement elem) {
-
 
61
        if (CONF_DIR_FUNCTION == null)
-
 
62
            return null;
-
 
63
        return CONF_DIR_FUNCTION.apply(elem);
-
 
64
    }
-
 
65
 
50
    // windowState-20160923/IListFrame/ARTICLE.xml
66
    // windowState-20160923/IListFrame/ARTICLE.xml
51
    static public final File getConfigFile(final SQLElement elem, final Class<? extends JFrame> c) {
67
    static public final File getConfigFile(final SQLElement elem, final Class<? extends JFrame> c) {
52
        return getConfigFile(elem, null, c);
68
        return getConfigFile(elem, null, c);
53
    }
69
    }
54
 
70
 
Line 57... Line 73...
57
        return getConfigFile(comp.getElement(), comp, c);
73
        return getConfigFile(comp.getElement(), comp, c);
58
    }
74
    }
59
 
75
 
60
    static private final File getConfigFile(final SQLElement elem, final SQLComponent comp, final Class<? extends Window> c) {
76
    static private final File getConfigFile(final SQLElement elem, final SQLComponent comp, final Class<? extends Window> c) {
61
        final String compName = comp == null ? "" : "-" + comp.getCode();
77
        final String compName = comp == null ? "" : "-" + comp.getCode();
62
        return getConfigFile(c, elem.getCode() + compName);
78
        return getConfigFile(getConfDir(elem), c, elem.getCode() + compName);
63
    }
79
    }
64
 
80
 
65
    // windowState-20160923/WindowClass/code.xml
81
    // windowState-20160923/WindowClass/code.xml
66
    static public final File getConfigFile(final Class<? extends Window> c, final String code) {
82
    static public final File getConfigFile(final Class<? extends Window> c, final String code) {
67
        final Configuration conf = Configuration.getInstance();
83
        return getConfigFile(getConfDir(null), c, code);
-
 
84
    }
-
 
85
 
-
 
86
    static public final File getConfigFile(final File rootDir, final Class<? extends Window> c, final String code) {
68
        if (conf == null)
87
        if (rootDir == null)
69
            return null;
88
            return null;
70
        final File structFile = new File(conf.getConfDir(), "windowState-" + FILE_STRUCT_VERSION);
89
        final File structFile = new File(rootDir, "windowState-" + FILE_STRUCT_VERSION);
71
        return new File(structFile, c.getSimpleName() + File.separator + getConfigFileName(code));
90
        return new File(structFile, c.getSimpleName() + File.separator + getConfigFileName(code));
72
    }
91
    }
73
 
92
 
74
    static final String getConfigFileName(String code) {
93
    static final String getConfigFileName(String code) {
75
        if (StringUtils.isEmpty(code, true))
94
        if (StringUtils.isEmpty(code, true))