OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 174 Rev 182
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.
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.light;
14
 package org.openconcerto.ui.light;
15
 
15
 
16
import org.openconcerto.utils.io.JSONConverter;
16
import org.openconcerto.utils.io.JSONConverter;
17
 
17
 
18
import net.minidev.json.JSONObject;
18
import net.minidev.json.JSONObject;
19
 
19
 
20
public class LightUITab extends LightUIPanel {
20
public class LightUITab extends LightUIPanel {
21
    private boolean load = false;
21
    private boolean load = false;
22
    private boolean forceReload = false;
22
    private boolean forceReload = false;
23
 
23
 
24
    public LightUITab(final String tabId, final String title) {
24
    public LightUITab(final String tabId, final String title) {
25
        super(tabId);
25
        super(tabId);
26
        this.setTitle(title);
26
        this.setTitle(title);
27
        this.setType(TYPE_TAB_ELEMENT);
27
        this.setType(TYPE_TAB_ELEMENT);
28
    }
28
    }
29
 
29
 
30
    public LightUITab(final JSONObject json) {
30
    public LightUITab(final JSONObject json) {
31
        super(json);
31
        super(json);
32
    }
32
    }
33
 
33
 
34
    public LightUITab(final LightUITab tab) {
34
    public LightUITab(final LightUITab tab) {
35
        super(tab);
35
        super(tab);
36
        this.load = tab.load;
36
        this.load = tab.load;
37
        this.forceReload = tab.forceReload;
37
        this.forceReload = tab.forceReload;
38
    }
38
    }
39
 
39
 
40
    public boolean isForceReload() {
40
    public boolean isForceReload() {
41
        return this.forceReload;
41
        return this.forceReload;
42
    }
42
    }
43
 
43
 
44
    public void setForceReload(final boolean forceReload) {
44
    public void setForceReload(final boolean forceReload) {
45
        this.forceReload = forceReload;
45
        this.forceReload = forceReload;
46
    }
46
    }
47
 
47
 
48
    public boolean isLoad() {
48
    public boolean isLoad() {
49
        return this.load;
49
        return this.load;
50
    }
50
    }
51
 
51
 
52
    public void setLoad(final boolean load) {
52
    public void setLoad(final boolean load) {
53
        this.load = load;
53
        this.load = load;
54
    }
54
    }
55
 
55
 
56
    @Override
56
    @Override
57
    public void copy(final LightUIElement element) {
57
    public void copy(final LightUIElement element) {
58
        if (!(element instanceof LightUITab)) {
58
        if (!(element instanceof LightUITab)) {
59
            throw new InvalidClassException(LightUITab.class.getName(), element.getClassName(), element.getId());
59
            throw new InvalidClassException(LightUITab.class.getName(), element.getClassName(), element.getId());
60
        }
60
        }
61
        super.copy(element);
61
        super.copy(element);
62
        final LightUITab tab = (LightUITab) element;
62
        final LightUITab tab = (LightUITab) element;
63
        this.forceReload = tab.forceReload;
63
        this.forceReload = tab.forceReload;
64
        this.load = tab.load;
64
        this.load = tab.load;
65
    }
65
    }
66
 
66
 
67
    @Override
67
    @Override
68
    public JSONObject toJSON() {
68
    public JSONObject toJSON() {
69
        final JSONObject json = super.toJSON();
69
        final JSONObject json = super.toJSON();
70
        if (this.load) {
70
        if (this.load) {
71
            json.put("load", true);
71
            json.put("load", true);
72
        }
72
        }
73
        if (this.forceReload) {
73
        if (this.forceReload) {
74
            json.put("force-reload", true);
74
            json.put("force-reload", true);
75
        }
75
        }
76
        return json;
76
        return json;
77
    }
77
    }
78
 
78
 
79
    @Override
79
    @Override
80
    public void fromJSON(JSONObject json) {
80
    public void fromJSON(JSONObject json) {
81
        super.fromJSON(json);
81
        super.fromJSON(json);
82
        this.load = (Boolean) JSONConverter.getParameterFromJSON(json, "load", Boolean.class, false);
82
        this.load = (Boolean) JSONConverter.getParameterFromJSON(json, "load", Boolean.class, false);
83
        this.forceReload = (Boolean) JSONConverter.getParameterFromJSON(json, "force-reload", Boolean.class, false);
83
        this.forceReload = (Boolean) JSONConverter.getParameterFromJSON(json, "force-reload", Boolean.class, false);
84
    }
84
    }
85
}
85
}