OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 73 Rev 156
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.ui.preferences;
14
 package org.openconcerto.ui.preferences;
15
 
15
 
-
 
16
import org.openconcerto.utils.FileUtils;
-
 
17
 
-
 
18
import java.io.File;
-
 
19
import java.io.IOException;
-
 
20
 
16
public class EmailProps extends AbstractProps {
21
public class EmailProps extends AbstractProps {
17
    public static final int DEFAULT = 0;
22
    public static final int DEFAULT = 0;
18
    public static final int THUNDERBIRD = 1;
23
    public static final int THUNDERBIRD = 1;
19
    public static final int OUTLOOK = 2;
24
    public static final int OUTLOOK = 2;
20
    protected static EmailProps instance;
25
    protected static EmailProps instance;
21
    private String propsFileName = null;
26
    private String propsFileName = null;
-
 
27
    private static String DEFAULT_FILE = "./Configuration/Email.properties";
-
 
28
    private String defaultPropsFileName = DEFAULT_FILE;
22
 
29
 
23
    public synchronized static EmailProps getInstance() {
30
    public synchronized static EmailProps getInstance() {
24
        if (instance == null) {
31
        if (instance == null) {
25
            instance = new EmailProps();
32
            instance = new EmailProps();
26
        }
33
        }
27
        return instance;
34
        return instance;
28
    }
35
    }
29
 
36
 
30
    @Override
37
    @Override
31
    protected String getPropsFileName() {
38
    protected String getPropsFileName() {
32
        if (this.propsFileName == null) {
39
        if (this.propsFileName == null) {
33
            return "./Configuration/Email.properties";
40
            return getDefaultPropsFileName();
34
        } else {
41
        } else {
35
            return this.propsFileName;
42
            return this.propsFileName;
36
        }
43
        }
37
    }
44
    }
38
 
45
 
-
 
46
    public void setDefaultPropsFileName(String defaultPropsFileName) {
-
 
47
        this.defaultPropsFileName = defaultPropsFileName;
-
 
48
    }
-
 
49
 
-
 
50
    protected String getDefaultPropsFileName() {
-
 
51
        if (this.defaultPropsFileName == null) {
-
 
52
            return DEFAULT_FILE;
-
 
53
        } else {
-
 
54
            return defaultPropsFileName;
-
 
55
        }
-
 
56
    }
-
 
57
 
39
    public void setPropsFileName(String propsFileName) {
58
    public void setPropsFileName(String propsFileName) {
40
        this.propsFileName = propsFileName;
59
        this.propsFileName = propsFileName;
-
 
60
        final File file = new File(getPropsFileName());
-
 
61
        final File fileDefault = new File(getDefaultPropsFileName());
-
 
62
        if (!file.exists() && fileDefault.exists()) {
-
 
63
            try {
-
 
64
                FileUtils.copyFile(fileDefault, file);
-
 
65
            } catch (IOException e) {
-
 
66
                // TODO Auto-generated catch block
-
 
67
                e.printStackTrace();
-
 
68
            }
-
 
69
        }
41
        load();
70
        load();
42
    }
71
    }
43
 
72
 
44
    public String getThunderbirdPath() {
73
    public String getThunderbirdPath() {
45
        final String stringProperty = this.getStringProperty("thunderbird.path");
74
        final String stringProperty = this.getStringProperty("thunderbird.path");
46
        if (stringProperty.trim().length() == 0) {
75
        if (stringProperty.trim().length() == 0) {
47
            return "C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe";
76
            return "C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe";
48
        }
77
        }
49
        return stringProperty;
78
        return stringProperty;
50
    }
79
    }
51
 
80
 
52
    public void setThunderbirdPath(String text) {
81
    public void setThunderbirdPath(String text) {
53
        this.setProperty("thunderbird.path", text);
82
        this.setProperty("thunderbird.path", text);
54
    }
83
    }
55
 
84
 
56
    public int getMode() {
85
    public int getMode() {
57
        return this.getIntProperty("mode");
86
        return this.getIntProperty("mode");
58
    }
87
    }
59
 
88
 
60
    public void setMode(int mode) {
89
    public void setMode(int mode) {
61
        this.setProperty("mode", String.valueOf(mode));
90
        this.setProperty("mode", String.valueOf(mode));
62
    }
91
    }
63
 
92
 
64
    public void setTitle(String text) {
93
    public void setTitle(String text) {
65
        this.setProperty("title", String.valueOf(text));
94
        this.setProperty("title", String.valueOf(text));
66
    }
95
    }
67
 
96
 
68
    public String getTitle() {
97
    public String getTitle() {
69
        return this.getStringProperty("title");
98
        return this.getStringProperty("title");
70
    }
99
    }
71
 
100
 
72
    public void setHeader(String text) {
101
    public void setHeader(String text) {
73
        this.setProperty("header", String.valueOf(text));
102
        this.setProperty("header", String.valueOf(text));
74
    }
103
    }
75
 
104
 
76
    public String getHeader() {
105
    public String getHeader() {
77
        return this.getStringProperty("header");
106
        return this.getStringProperty("header");
78
    }
107
    }
79
 
108
 
80
    public void setFooter(String text) {
109
    public void setFooter(String text) {
81
        this.setProperty("footer", String.valueOf(text));
110
        this.setProperty("footer", String.valueOf(text));
82
    }
111
    }
83
 
112
 
84
    public void setEncodingCharsetName(String charset) {
113
    public void setEncodingCharsetName(String charset) {
85
        this.setProperty("encoding", charset);
114
        this.setProperty("encoding", charset);
86
    }
115
    }
87
 
116
 
88
    public String getFooter() {
117
    public String getFooter() {
89
        return this.getStringProperty("footer");
118
        return this.getStringProperty("footer");
90
    }
119
    }
91
 
120
 
92
    public String getEncodingCharsetName() {
121
    public String getEncodingCharsetName() {
93
        String charset = "UTF-8";
122
        String charset = "UTF-8";
94
        String tmp = this.getStringProperty("encoding");
123
        String tmp = this.getStringProperty("encoding");
95
        if (tmp.trim().length() > 0) {
124
        if (tmp.trim().length() > 0) {
96
            charset = tmp;
125
            charset = tmp;
97
        }
126
        }
98
        return charset;
127
        return charset;
99
    }
128
    }
100
 
129
 
101
    @Override
130
    @Override
102
    protected int getDefautIntValue() {
131
    protected int getDefautIntValue() {
103
        return DEFAULT;
132
        return DEFAULT;
104
    }
133
    }
105
 
134
 
106
}
135
}