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 39... Line 39...
39
    }
39
    }
40
 
40
 
41
    public RowSelectionSpec(final JSONObject json) {
41
    public RowSelectionSpec(final JSONObject json) {
42
        this.fromJSON(json);
42
        this.fromJSON(json);
43
    }
43
    }
44
    
44
 
45
    public RowSelectionSpec(String tableId) {
45
    public RowSelectionSpec(String tableId) {
46
        this(tableId, new ArrayList<Number>());
46
        this(tableId, new ArrayList<Number>(0));
47
    }
47
    }
48
 
48
 
49
    public RowSelectionSpec(final String tableId, final List<Number> selectedIds) {
49
    public RowSelectionSpec(final String tableId, final List<Number> selectedIds) {
50
        this.tableId = tableId;
50
        this.tableId = tableId;
-
 
51
        this.ids = new ArrayList<>(selectedIds);
51
        this.ids = selectedIds;
52
        this.ids.addAll(selectedIds);
52
    }
53
    }
53
 
54
 
54
    public final List<Number> getIds() {
55
    public final List<Number> getIds() {
55
        return this.ids;
56
        return this.ids;
56
    }
57
    }
57
    
58
 
58
    public final void setIds(List<Number> ids) {
59
    public final void setIds(List<Number> ids) {
59
        this.ids = ids;
60
        this.ids.clear();
-
 
61
        this.ids.addAll(ids);
-
 
62
    }
-
 
63
 
-
 
64
    public void clear() {
-
 
65
        this.ids.clear();
60
    }
66
    }
61
 
67
 
62
    public String getTableId() {
68
    public String getTableId() {
63
        return this.tableId;
69
        return this.tableId;
64
    }
70
    }
65
    
71
 
66
    public boolean hasSelectedId(){
72
    public boolean hasSelectedId() {
67
        return this.getIds() != null && !this.getIds().isEmpty();
73
        return !this.getIds().isEmpty();
68
    }
74
    }
69
 
75
 
70
    @Override
76
    @Override
71
    public String toString() {
77
    public String toString() {
72
        final StringBuilder r = new StringBuilder("RowSelectionSpec: ").append(this.tableId).append(" : ");
78
        final StringBuilder r = new StringBuilder("RowSelectionSpec: ").append(this.tableId).append(" : ");
Line 111... Line 117...
111
 
117
 
112
    @Override
118
    @Override
113
    public void fromJSON(JSONObject json) {
119
    public void fromJSON(JSONObject json) {
114
        this.tableId = JSONConverter.getParameterFromJSON(json, "table-id", String.class);
120
        this.tableId = JSONConverter.getParameterFromJSON(json, "table-id", String.class);
115
        final JSONArray jsonIds = JSONConverter.getParameterFromJSON(json, "ids", JSONArray.class);
121
        final JSONArray jsonIds = JSONConverter.getParameterFromJSON(json, "ids", JSONArray.class);
116
        this.ids = new ArrayList<Number>();
122
        this.ids = new ArrayList<>(jsonIds.size());
117
        for (final Object jsonId : jsonIds) {
123
        for (final Object jsonId : jsonIds) {
118
            this.ids.add(JSONConverter.getObjectFromJSON(jsonId, Number.class));
124
            this.ids.add(JSONConverter.getObjectFromJSON(jsonId, Number.class));
119
        }
125
        }
120
    }
126
    }
121
 
127