OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
142 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;
17
 
18
import net.minidev.json.JSONObject;
19
 
20
public class LightUIFileUploadWithSelection extends LightUIFileUpload {
21
 
22
    private static final String TABLE_ID_JSON_KEY = "table-id";
23
    private String tableId;
24
 
156 ilm 25
    public LightUIFileUploadWithSelection() {
142 ilm 26
    }
27
 
28
    public LightUIFileUploadWithSelection(final LightUIFileUploadWithSelection file) {
29
        super(file);
30
    }
31
 
32
    public LightUIFileUploadWithSelection(final String id, final String tableId, final String sendFileUrl) {
33
        super(id, sendFileUrl);
34
        this.setType(LightUIElement.TYPE_FILE_UPLOAD_WITH_SELECTION);
35
        this.setGridWidth(1);
36
 
37
        this.tableId = tableId;
38
    }
39
 
40
    @Override
41
    protected void copy(LightUIElement element) {
42
        super.copy(element);
43
        if (!(element instanceof LightUIFileUploadWithSelection)) {
44
            throw new InvalidClassException(this.getClassName(), element.getClassName(), element.getId());
45
        }
46
 
47
        final LightUIFileUploadWithSelection files = (LightUIFileUploadWithSelection) element;
48
        this.tableId = files.tableId;
49
    }
50
 
51
    @Override
52
    public void fromJSON(final JSONObject json) {
53
        super.fromJSON(json);
54
 
55
        this.tableId = JSONConverter.getParameterFromJSON(json, TABLE_ID_JSON_KEY, String.class);
56
    }
57
 
58
    @Override
59
    public JSONObject toJSON() {
60
        final JSONObject json = super.toJSON();
61
        json.put(TABLE_ID_JSON_KEY, this.tableId);
62
        return json;
63
    }
64
}