OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 144 | 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 LightUIFileUpload extends LightUserControl {
21
    private static final String SEND_FILE_URL_JSON_KEY = "send-file-url";
22
 
23
    private String sendFileUrl;
24
 
156 ilm 25
    public LightUIFileUpload() {
142 ilm 26
    }
27
 
28
    public LightUIFileUpload(final LightUIFileUpload file) {
29
        super(file);
30
    }
31
 
32
    public LightUIFileUpload(final String id, final String sendFileUrl) {
33
        super(id);
34
        this.setType(LightUIElement.TYPE_FILE_UPLOAD);
35
 
36
        this.sendFileUrl = sendFileUrl;
37
    }
38
 
39
    @Override
40
    protected void copy(LightUIElement element) {
41
        super.copy(element);
42
        if (!(element instanceof LightUIFileUpload)) {
43
            throw new InvalidClassException(this.getClassName(), element.getClassName(), element.getId());
44
        }
45
        final LightUIFileUpload files = (LightUIFileUpload) element;
46
        this.sendFileUrl = files.sendFileUrl;
47
    }
48
 
49
    @Override
50
    public void fromJSON(final JSONObject json) {
51
        super.fromJSON(json);
52
 
53
        this.sendFileUrl = JSONConverter.getParameterFromJSON(json, SEND_FILE_URL_JSON_KEY, String.class);
54
    }
55
 
56
    @Override
57
    public JSONObject toJSON() {
58
        final JSONObject json = super.toJSON();
59
        json.put(SEND_FILE_URL_JSON_KEY, this.sendFileUrl);
60
        return json;
61
    }
62
 
63
    @Override
64
    public void _setValueFromContext(final Object value) {
65
        this.setValue((String) value);
66
    }
67
 
68
    @Override
69
    public Object getValueForContext() {
70
        return this.getValue();
71
    }
72
}