142 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
182 |
ilm |
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
142 |
ilm |
5 |
*
|
|
|
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
|
|
|
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.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.ui.light;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.utils.io.JSONConverter;
|
|
|
17 |
|
|
|
18 |
import net.minidev.json.JSONObject;
|
|
|
19 |
|
|
|
20 |
public class LightUIListRow extends LightUIPanel {
|
|
|
21 |
private Number rowId;
|
|
|
22 |
|
|
|
23 |
// Init from json constructor
|
|
|
24 |
public LightUIListRow(final JSONObject json) {
|
|
|
25 |
super(json);
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
// Clone constructor
|
|
|
29 |
public LightUIListRow(final LightUIListRow listItem) {
|
|
|
30 |
super(listItem);
|
|
|
31 |
this.rowId = listItem.rowId;
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
public LightUIListRow(final LightUIList parent, final Number rowId) {
|
|
|
35 |
super(parent.getId() + ".item.panel." + rowId.toString());
|
|
|
36 |
this.rowId = rowId;
|
|
|
37 |
this.setType(TYPE_LIST_ROW);
|
|
|
38 |
this.setFillHeight(false);
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
public LightUIListRow(final LightUIList parent, final Number id, final String label) {
|
|
|
42 |
this(parent, id);
|
|
|
43 |
|
|
|
44 |
final LightUILine line = new LightUILine();
|
|
|
45 |
line.addChild(new LightUILabel(this.getId() + ".label", label));
|
|
|
46 |
this.addChild(line);
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
public Number getRowId() {
|
|
|
50 |
return this.rowId;
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
@Override
|
|
|
54 |
public JSONObject toJSON() {
|
|
|
55 |
final JSONObject json = super.toJSON();
|
|
|
56 |
json.put("row-id", this.getRowId());
|
|
|
57 |
return json;
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
@Override
|
|
|
61 |
public void fromJSON(final JSONObject json) {
|
|
|
62 |
super.fromJSON(json);
|
|
|
63 |
this.rowId = JSONConverter.getParameterFromJSON(json, "row-id", Number.class);
|
|
|
64 |
}
|
|
|
65 |
}
|