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
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
 
132 ilm 16
import org.openconcerto.utils.io.JSONConverter;
94 ilm 17
 
18
import net.minidev.json.JSONObject;
19
 
156 ilm 20
public class LightUITabbed extends LightUserControlContainer {
21
 
22
    public LightUITabbed() {
23
    }
24
 
94 ilm 25
    // Init from json constructor
26
    public LightUITabbed(final JSONObject json) {
132 ilm 27
        super(json);
94 ilm 28
    }
132 ilm 29
 
94 ilm 30
    // Clone constructor
31
    public LightUITabbed(final LightUITabbed tabbedElement) {
32
        super(tabbedElement);
33
    }
132 ilm 34
 
94 ilm 35
    public LightUITabbed(final String id) {
132 ilm 36
        super(id);
94 ilm 37
        this.setType(TYPE_TABBED_UI);
132 ilm 38
        this.setWeightX(1);
39
        this.setFillWidth(true);
94 ilm 40
    }
132 ilm 41
 
42
    /**
43
     * This function allow dynamic load of tab. If the loading of one tab take a while, you can load
44
     * others after or in other thread
45
     *
46
     * @param tabId: id of tab which you want to load. The tab id must match with a tab contained in
47
     *        childs
48
     */
156 ilm 49
    public void loadTab(final String tabId) {
50
    }
132 ilm 51
 
52
    @Override
53
    public void setValue(final String value) {
54
        super.setValue(value);
94 ilm 55
    }
132 ilm 56
 
57
    @Override
142 ilm 58
    public void _setValueFromContext(final Object value) {
132 ilm 59
        final JSONObject jsonContext = (JSONObject) JSONConverter.getObjectFromJSON(value, JSONObject.class);
142 ilm 60
        if (jsonContext == null) {
61
            System.err.println("LightUITabbed.setValueFromContext() - json is null for this panel: " + this.getId());
62
        } else {
63
            final int childCount = this.getChildrenCount();
64
            for (int i = 0; i < childCount; i++) {
65
                final LightUITab child = this.getChild(i, LightUITab.class);
66
                if (jsonContext.containsKey(child.getUUID())) {
67
                    child._setValueFromContext(jsonContext.get(child.getUUID()));
68
                } else {
69
                    System.out.println("LightUITabbed.setValueFromContext() - Context doesn't contains value for UUID: " + child.getUUID() + " ID: " + child.getId());
70
                }
94 ilm 71
            }
72
        }
73
    }
74
}