Statistics
| Revision:

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

History | View | Annotate | Download (4.5 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
package org.gvsig.gui.beans.listview;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.Dimension;
28
import java.awt.GridBagConstraints;
29
import java.awt.event.ActionEvent;
30
import java.awt.event.ActionListener;
31

    
32
import javax.swing.JButton;
33
import javax.swing.JCheckBox;
34
import javax.swing.JFrame;
35
import javax.swing.JPanel;
36
import javax.swing.JScrollPane;
37
/**
38
 * @version 28/06/2007
39
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
40
 */
41
public class TestListView implements ActionListener {
42
        private JFrame jFrame = null;
43
        private JScrollPane jScrollPane = null;
44
        private ListViewComponent listViewComponent = null;
45
        JButton botonAdd = null;
46
        JButton botonDel = null;
47
        JCheckBox multiselect = null;
48
        JCheckBox enabled = null;
49

    
50
        public TestListView() {
51
                initialize();
52
        }
53

    
54
        private void initialize() {
55
                jFrame = new JFrame();
56
                jScrollPane = new JScrollPane();
57

    
58
                listViewComponent = new ListViewComponent();
59
                listViewComponent.setEditable(true);
60
                jScrollPane.setViewportView(listViewComponent);
61

    
62
                for (int i=0; i<1000; i++) {
63
                        ListViewItem item = new ListViewItem(new RampPainter(), "Prueba-" + i);
64
                        listViewComponent.addItem(item, true);
65
                }
66

    
67
                JPanel jpane = new JPanel();
68
                jpane.setLayout(new BorderLayout());
69
                jpane.add(jScrollPane, BorderLayout.CENTER);
70

    
71
                JPanel jPanel1 = new JPanel();
72
                jPanel1.setLayout(new java.awt.GridBagLayout());
73

    
74
                jpane.add(jPanel1, BorderLayout.SOUTH);
75

    
76
                botonAdd = new JButton("Add");
77
                botonAdd.addActionListener(this);
78
                GridBagConstraints gridBagConstraints = new GridBagConstraints();
79
                gridBagConstraints.insets = new java.awt.Insets(5, 5, 2, 2);
80
                jPanel1.add(botonAdd, gridBagConstraints);
81

    
82
                botonDel = new JButton("Del");
83
                botonDel.addActionListener(this);
84
                gridBagConstraints = new java.awt.GridBagConstraints();
85
                gridBagConstraints.gridx = 1;
86
                gridBagConstraints.gridy = 0;
87
                gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 5);
88
                jPanel1.add(botonDel, gridBagConstraints);
89

    
90
                multiselect = new JCheckBox("MultiSelect");
91
                multiselect.addActionListener(this);
92
                gridBagConstraints = new java.awt.GridBagConstraints();
93
                gridBagConstraints.gridx = 0;
94
                gridBagConstraints.gridy = 1;
95
                gridBagConstraints.gridwidth = 2;
96
                gridBagConstraints.insets = new java.awt.Insets(2, 5, 5, 5);
97
                jPanel1.add(multiselect, gridBagConstraints);
98

    
99
                enabled = new JCheckBox("Activo");
100
                enabled.addActionListener(this);
101
                enabled.setSelected(true);
102
                gridBagConstraints = new java.awt.GridBagConstraints();
103
                gridBagConstraints.gridx = 0;
104
                gridBagConstraints.gridy = 2;
105
                gridBagConstraints.gridwidth = 2;
106
                gridBagConstraints.insets = new java.awt.Insets(2, 5, 5, 5);
107
                jPanel1.add(enabled, gridBagConstraints);
108

    
109
                jFrame.setSize(new Dimension(192, 300));
110
                jFrame.setContentPane(jpane);
111

    
112
                jFrame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
113
                jFrame.setVisible(true);
114
        }
115

    
116
        /**
117
         * @param args
118
         */
119
        public static void main(String[] args) {
120
                new TestListView();
121
        }
122

    
123
        int id = 0;
124
        /*
125
         * (non-Javadoc)
126
         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
127
         */
128
        public void actionPerformed(ActionEvent e) {
129
                if (e.getSource() == botonAdd) {
130
                        ListViewItem item = new ListViewItem(new RampPainter(), "Prueba");
131
                        listViewComponent.addItem(item);
132
                        return;
133
                }
134

    
135
                if (e.getSource() == botonDel) {
136
                        listViewComponent.removeSelecteds();
137
                        return;
138
                }
139

    
140
                if (e.getSource() == multiselect) {
141
                        listViewComponent.setMultiSelect(multiselect.isSelected());
142
                        return;
143
                }
144

    
145
                if (e.getSource() == enabled) {
146
                        listViewComponent.setEnabled(enabled.isSelected());
147
                        jScrollPane.setEnabled(enabled.isSelected());
148
                        return;
149
                }
150
        }
151
}