OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 94 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
94 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
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;
132 ilm 17
 
94 ilm 18
import net.minidev.json.JSONObject;
19
 
132 ilm 20
public class LightUIButtonWithSelectionContext extends LightUIButton {
94 ilm 21
 
132 ilm 22
    RowSelectionSpec tableSelection;
23
 
24
    public LightUIButtonWithSelectionContext(final JSONObject json) {
25
        super(json);
94 ilm 26
    }
132 ilm 27
 
28
    public LightUIButtonWithSelectionContext(final String id, final RowSelectionSpec tableSelection) {
29
        super(id, LightUIElement.TYPE_BUTTON_WITH_SELECTION_CONTEXT);
30
        this.tableSelection = tableSelection;
31
    }
32
 
33
    public LightUIButtonWithSelectionContext(final LightUIButtonWithSelectionContext button) {
34
        super(button);
35
    }
36
 
37
    public RowSelectionSpec getTableSelection() {
38
        return this.tableSelection;
39
    }
40
 
41
    @Override
42
    protected void copy(final LightUIElement element) {
43
        super.copy(element);
44
 
45
        if (!(element instanceof LightUIButtonWithSelectionContext)) {
46
            throw new InvalidClassException(LightUIButtonWithSelectionContext.class.getName(), element.getClassName(), element.getId());
47
        }
48
        final LightUIButtonWithSelectionContext button = (LightUIButtonWithSelectionContext) element;
49
        this.tableSelection = button.tableSelection;
50
    }
51
 
52
    @Override
53
    public void fromJSON(final JSONObject json) {
94 ilm 54
        super.fromJSON(json);
132 ilm 55
 
56
        this.tableSelection = (RowSelectionSpec) JSONConverter.getParameterFromJSON(json, "table-selection", RowSelectionSpec.class);
94 ilm 57
    }
132 ilm 58
 
59
    @Override
60
    public JSONObject toJSON() {
94 ilm 61
        final JSONObject json = super.toJSON();
132 ilm 62
        json.put("table-selection", this.tableSelection.toJSON());
94 ilm 63
        return json;
64
    }
65
}