Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / treelist / TestTreeList.java @ 40561

History | View | Annotate | Download (3.45 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
25
*
26
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
27
*
28
* This program is free software; you can redistribute it and/or
29
* modify it under the terms of the GNU General Public License
30
* as published by the Free Software Foundation; either version 2
31
* of the License, or (at your option) any later version.
32
*
33
* This program is distributed in the hope that it will be useful,
34
* but WITHOUT ANY WARRANTY; without even the implied warranty of
35
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36
* GNU General Public License for more details.
37
*
38
* You should have received a copy of the GNU General Public License
39
* along with this program; if not, write to the Free Software
40
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
41
*/
42
package org.gvsig.gui.beans.treelist;
43

    
44
import java.util.Hashtable;
45

    
46
import javax.swing.ListModel;
47

    
48
import org.gvsig.gui.beans.TestUI;
49
import org.gvsig.gui.beans.treelist.event.TreeListChangeEvent;
50
import org.gvsig.gui.beans.treelist.listeners.TreeListChangeListener;
51

    
52
public class TestTreeList implements TreeListChangeListener {
53
        private int               w     = 200;
54
        private int               h     = 380;
55
        private TestUI            frame = new TestUI("TestTreeList");
56
        private TreeListContainer tlist;
57

    
58
        public TestTreeList() {
59
                tlist = new TreeListContainer();
60

    
61
                tlist.addClass("uno", 0);
62
                tlist.addClass("dos", 1);
63
                tlist.addClass("tres", 2);
64
                tlist.addClass("cuatro", 3);
65
                tlist.addEntry("uno-uno","uno","1-1");
66
                tlist.addEntry("uno-dos","uno","1-2");
67
                tlist.addEntry("uno-tres","uno","1-3");
68
                tlist.addEntry("tres-uno","tres","3-1");
69
                tlist.addEntry("tres-dos","tres","3-2");
70
                tlist.addEntry("cuatro-uno","cuatro","4-1");
71
                tlist.addEntry("cuatro-dos","cuatro","4-2");
72
                tlist.addEntry("cuatro-tres","cuatro","4-3");
73
                tlist.addEntry("cuatro-cuatro","cuatro","4-4");
74
                tlist.addEntry("cuatro-cinco","cuatro","4-5");
75
                tlist.addEntry("cuatro-seis","cuatro","4-6");
76

    
77
                tlist.getTree().expandRow(0);
78
                tlist.addChangeSelectionListener(this);
79

    
80
                frame.getContentPane().add(tlist);
81
                frame.setSize(w, h);
82
                frame.setVisible(true);
83
        }
84

    
85
        public static void main(String[] args) {
86
                new TestTreeList();
87
        }
88

    
89
        public void actionChangeSelection(TreeListChangeEvent e) {
90
                System.out.println("-");
91
                ListModel list = tlist.getListModel();
92
                for (int i=0; i<list.getSize(); i++) {
93
                        Hashtable prueba = tlist.getMap();
94
                        System.out.println(prueba.get(list.getElementAt(i)));
95
                        System.out.println(list.getElementAt(i));
96
                }
97
        }
98
}