OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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