OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 142 Rev 156
Line 14... Line 14...
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
import org.openconcerto.utils.io.Transferable;
17
import org.openconcerto.utils.io.Transferable;
18
 
18
 
-
 
19
import java.io.Externalizable;
-
 
20
import java.io.IOException;
-
 
21
import java.io.ObjectInput;
-
 
22
import java.io.ObjectOutput;
-
 
23
 
19
import net.minidev.json.JSONObject;
24
import net.minidev.json.JSONObject;
20
 
25
 
21
public class LightUIComboBoxElement implements Transferable {
26
public class LightUIComboBoxElement implements Transferable, Externalizable {
22
    /**
27
    /**
23
     * ID of row, must be unique for a LightUIComboBox. It's represent the SQLRow ID when the
28
     * ID of row, must be unique for a LightUIComboBox. It's represent the SQLRow ID when the
24
     * LightUICombo is attach to a field in database
29
     * LightUICombo is attach to a field in database
25
     */
30
     */
26
    private Integer id = null;
31
    private Integer id = null;
27
 
32
 
28
    private String value1 = null;
33
    private String value1 = null;
29
    private String value2 = null;
34
    private String value2 = null;
30
    private String icon = null;
35
    private String icon = null;
31
 
36
 
-
 
37
    public LightUIComboBoxElement() {
-
 
38
        // Serialization
-
 
39
    }
-
 
40
 
32
    public LightUIComboBoxElement(final JSONObject json) {
41
    public LightUIComboBoxElement(final JSONObject json) {
33
        this.fromJSON(json);
42
        this.fromJSON(json);
34
    }
43
    }
35
 
44
 
36
    public LightUIComboBoxElement(final int id) {
45
    public LightUIComboBoxElement(final int id) {
37
        this.id = id;
46
        this.id = id;
38
    }
47
    }
39
    
48
 
40
    public LightUIComboBoxElement(final int id, final String value1) {
49
    public LightUIComboBoxElement(final int id, final String value1) {
41
        this.id = id;
50
        this.id = id;
42
        this.value1 = value1;
51
        this.value1 = value1;
43
    }
52
    }
44
    
53
 
45
    public LightUIComboBoxElement(final int id, final String value1, final String value2) {
54
    public LightUIComboBoxElement(final int id, final String value1, final String value2) {
46
        this.id = id;
55
        this.id = id;
47
        this.value1 = value1;
56
        this.value1 = value1;
48
        this.value2 = value2;
57
        this.value2 = value2;
49
    }
58
    }
Line 106... Line 115...
106
        return json;
115
        return json;
107
    }
116
    }
108
 
117
 
109
    @Override
118
    @Override
110
    public void fromJSON(final JSONObject json) {
119
    public void fromJSON(final JSONObject json) {
111
        this.id = (Integer) JSONConverter.getParameterFromJSON(json, "id", Integer.class);
120
        this.id = JSONConverter.getParameterFromJSON(json, "id", Integer.class);
112
        this.value1 = (String) JSONConverter.getParameterFromJSON(json, "value1", String.class);
121
        this.value1 = JSONConverter.getParameterFromJSON(json, "value1", String.class);
113
        this.value2 = (String) JSONConverter.getParameterFromJSON(json, "value2", String.class);
122
        this.value2 = JSONConverter.getParameterFromJSON(json, "value2", String.class);
114
        this.icon = (String) JSONConverter.getParameterFromJSON(json, "icon", String.class);
123
        this.icon = JSONConverter.getParameterFromJSON(json, "icon", String.class);
-
 
124
    }
-
 
125
 
-
 
126
    @Override
-
 
127
    public void writeExternal(ObjectOutput out) throws IOException {
-
 
128
        // TODO : value1,value2 et icon -> "" par défaut
-
 
129
        if (value1 == null)
-
 
130
            value1 = "";
-
 
131
        if (value2 == null)
-
 
132
            value2 = "";
-
 
133
        if (icon == null)
-
 
134
            icon = "";
-
 
135
        out.writeInt(id);
-
 
136
        out.writeUTF(value1);
-
 
137
        out.writeUTF(value2);
-
 
138
        out.writeUTF(icon);
-
 
139
    }
-
 
140
 
-
 
141
    @Override
-
 
142
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-
 
143
        this.id = in.readInt();
-
 
144
        this.value1 = in.readUTF();
-
 
145
        this.value2 = in.readUTF();
-
 
146
        this.icon = in.readUTF();
-
 
147
 
-
 
148
    }
-
 
149
 
-
 
150
    @Override
-
 
151
    public String toString() {
-
 
152
        return id + ":" + value1 + ":" + value2;
115
    }
153
    }
116
}
154
}