OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 151 Rev 156
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.ui.light;
14
 package org.openconcerto.ui.light;
15
 
15
 
-
 
16
import java.io.IOException;
-
 
17
import java.io.ObjectInput;
-
 
18
import java.io.ObjectOutput;
16
import java.util.ArrayList;
19
import java.util.ArrayList;
17
import java.util.List;
20
import java.util.List;
18
 
21
 
19
import net.minidev.json.JSONArray;
22
import net.minidev.json.JSONArray;
20
import net.minidev.json.JSONObject;
23
import net.minidev.json.JSONObject;
21
 
24
 
22
public class LightUIRadioButtons extends LightUserControl {
25
public class LightUIRadioButtons extends LightUserControl {
23
    private final List<String> choices = new ArrayList<>();
26
    private final List<String> choices = new ArrayList<>();
24
 
27
 
-
 
28
    public LightUIRadioButtons() {
-
 
29
        // Serialization
-
 
30
    }
-
 
31
 
25
    // Init from json constructor
32
    // Init from json constructor
26
    public LightUIRadioButtons(final JSONObject json) {
33
    public LightUIRadioButtons(final JSONObject json) {
27
        super(json);
34
        super(json);
28
    }
35
    }
29
 
36
 
Line 84... Line 91...
84
            this.choices.add(o.toString());
91
            this.choices.add(o.toString());
85
        }
92
        }
86
    }
93
    }
87
 
94
 
88
    @Override
95
    @Override
89
    public JSONToLightUIConvertor getConvertor() {
96
    public void writeExternal(ObjectOutput out) throws IOException {
-
 
97
        super.writeExternal(out);
-
 
98
        out.writeInt(this.choices.size());
90
        return new JSONToLightUIConvertor() {
99
        for (String c : this.choices) {
-
 
100
            out.writeUTF(c);
-
 
101
        }
-
 
102
    }
-
 
103
 
91
            @Override
104
    @Override
-
 
105
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-
 
106
        super.readExternal(in);
-
 
107
        int size = in.readInt();
-
 
108
        this.choices.clear();
92
            public LightUIElement convert(final JSONObject json) {
109
        for (int i = 0; i < size; i++) {
93
                return new LightUIRadioButtons(json);
110
            this.choices.add(in.readUTF());
94
            }
111
        }
95
        };
-
 
96
    }
112
    }
97
 
113
 
98
    @Override
114
    @Override
99
    public void _setValueFromContext(Object value) {
115
    public void _setValueFromContext(Object value) {
100
        if (value instanceof Number) {
116
        if (value instanceof Number) {