OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 94 | 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
 
132 ilm 20
public abstract class LightUITabbed extends LightUIContainer implements IUserControlContainer {
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
53
    public void setValueFromContext(final Object value) {
54
        final JSONObject jsonContext = (JSONObject) JSONConverter.getObjectFromJSON(value, JSONObject.class);
55
        final int childCount = this.getChildrenCount();
56
        for (int i = 0; i < childCount; i++) {
57
            final LightUITab child = this.getChild(i, LightUITab.class);
58
            if (jsonContext.containsKey(child.getUUID())) {
59
                child.setValueFromContext(jsonContext.get(child.getUUID()));
60
            } else {
61
                System.out.println("LightUITabbed.setValueFromContext() - Context doesn't contains value for UUID: " + child.getUUID() + " ID: " + child.getId());
94 ilm 62
            }
63
        }
64
    }
65
}