OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
83 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 java.awt.Color;
17
import java.io.Serializable;
18
import java.util.ArrayList;
19
import java.util.List;
20
 
156 ilm 21
import net.minidev.json.JSONObject;
22
 
83 ilm 23
public class TreeItem implements Serializable {
24
    /**
25
     *
26
     */
27
    private static final long serialVersionUID = 8087661728014786832L;
28
    private String id;
29
    private String label;
30
    private List<TreeItem> children;
31
    private boolean isSelected;
32
    private Color color;
33
    private boolean expanded;
34
    private String iconId;
35
 
36
    public TreeItem() {
37
    }
38
 
156 ilm 39
    public TreeItem(JSONObject o) {
40
        // TODO json..
41
    }
42
 
83 ilm 43
    public TreeItem(String id, String label) {
44
        this.id = id;
45
        this.label = label;
46
    }
47
 
48
    public final String getId() {
142 ilm 49
        return this.id;
83 ilm 50
    }
51
 
52
    public final void setId(String id) {
53
        this.id = id;
54
    }
55
 
56
    public String getLabel() {
142 ilm 57
        return this.label;
83 ilm 58
    }
59
 
60
    public void setLabel(String label) {
61
        this.label = label;
62
    }
63
 
64
    public TreeItem getChild(int i) {
142 ilm 65
        return this.children.get(i);
83 ilm 66
    }
67
 
68
    public int getChildCount() {
142 ilm 69
        return this.children.size();
83 ilm 70
    }
71
 
72
    public final List<TreeItem> getChildren() {
142 ilm 73
        return this.children;
83 ilm 74
    }
75
 
76
    public final void addChild(TreeItem item) {
77
        if (this.children == null) {
78
            this.children = new ArrayList<TreeItem>();
79
        }
80
        this.children.add(item);
81
    }
82
 
83
    public final void addChildren(List<TreeItem> items) {
84
        if (this.children == null) {
85
            this.children = new ArrayList<TreeItem>();
86
        }
87
        this.children.addAll(items);
88
    }
89
 
90
    public final void setChildren(List<TreeItem> children) {
91
        this.children = children;
92
    }
93
 
94
    public final boolean hasChildren() {
95
        return this.children != null && !this.children.isEmpty();
96
    }
97
 
98
    public final boolean isSelected() {
142 ilm 99
        return this.isSelected;
83 ilm 100
    }
101
 
102
    public final void setSelected(boolean isSelected) {
103
        this.isSelected = isSelected;
104
    }
105
 
106
    public final Color getColor() {
142 ilm 107
        return this.color;
83 ilm 108
    }
109
 
110
    public final void setColor(Color color) {
111
        this.color = color;
112
    }
113
 
114
    public final boolean isExpanded() {
142 ilm 115
        return this.expanded;
83 ilm 116
    }
117
 
118
    public final void setExpanded(boolean expanded) {
119
        this.expanded = expanded;
120
    }
121
 
122
    public final String getIconId() {
142 ilm 123
        return this.iconId;
83 ilm 124
    }
125
 
126
    public final void setRightIconId(String iconId) {
127
        this.iconId = iconId;
128
    }
129
 
130
}