OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Go to most recent revision | 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
    public LightUIElement clone() {
42
        return new LightUIFileUploadWithSelection(this);
43
    }
44
 
45
    @Override
46
    protected void copy(LightUIElement element) {
47
        super.copy(element);
48
        if (!(element instanceof LightUIFileUploadWithSelection)) {
49
            throw new InvalidClassException(this.getClassName(), element.getClassName(), element.getId());
50
        }
51
 
52
        final LightUIFileUploadWithSelection files = (LightUIFileUploadWithSelection) element;
53
        this.tableId = files.tableId;
54
    }
55
 
56
    @Override
57
    public void fromJSON(final JSONObject json) {
58
        super.fromJSON(json);
59
 
60
        this.tableId = JSONConverter.getParameterFromJSON(json, TABLE_ID_JSON_KEY, String.class);
61
    }
62
 
63
    @Override
64
    public JSONObject toJSON() {
65
        final JSONObject json = super.toJSON();
66
        json.put(TABLE_ID_JSON_KEY, this.tableId);
67
        return json;
68
    }
69
}