OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 67 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 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.erp.panel;
15
 
16
import org.openconcerto.sql.Configuration;
17
import org.openconcerto.sql.model.SQLField;
18
import org.openconcerto.sql.model.SQLRow;
67 ilm 19
import org.openconcerto.sql.model.SQLRowAccessor;
18 ilm 20
 
19 ilm 21
import java.util.List;
22
 
18 ilm 23
import javax.swing.tree.DefaultMutableTreeNode;
24
 
25
public class ITreeSelectionNode extends DefaultMutableTreeNode {
26
 
83 ilm 27
    private SQLRowAccessor row;
18 ilm 28
 
67 ilm 29
    public ITreeSelectionNode(SQLRowAccessor row) {
18 ilm 30
        this.row = row;
31
    }
32
 
33
    public String toString() {
34
 
35
        if (this.row == null) {
36
            return "";
37
        } else {
83 ilm 38
            List<SQLField> fields = Configuration.getInstance().getShowAs().getFieldExpand(this.row.getTable());
39
            if (fields == null) {
40
                throw new IllegalStateException("no field to expand for table " + this.row.getTable());
41
            }
18 ilm 42
            StringBuffer result = new StringBuffer();
83 ilm 43
            for (SQLField s : fields) {
18 ilm 44
                result.append(this.row.getObject(s.getName()).toString() + " ");
45
            }
46
            return result.toString().trim();
47
        }
48
    }
49
 
50
    public int getId() {
51
        return this.row == null ? 1 : this.row.getID();
52
    }
53
 
54
    public void setRow(SQLRow row) {
55
        this.row = row;
56
    }
57
}