Statistics
| Revision:

root / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / propertiespanel / TestPropertiesPanel.java @ 11562

History | View | Annotate | Download (2.86 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19
package org.gvsig.gui.beans.propertiespanel;
20

    
21
import java.util.ArrayList;
22

    
23
import javax.swing.JFrame;
24
import javax.swing.UIManager;
25

    
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
27
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
28
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
29

    
30
public class TestPropertiesPanel implements ButtonsPanelListener {
31
        JFrame frame = null;
32
        PropertiesPanel pd = null;
33
        
34
        public TestPropertiesPanel() {
35
                initialize();
36
        }
37

    
38
        public void initialize() {
39
                frame = new JFrame();
40
                pd = new PropertiesPanel();
41

    
42
                pd.addButtonPressedListener(this);
43
                pd.addValue("Protocolo", "protocolo", "", null);
44
                pd.addValue("Integer", "var1", new Integer(50), null);
45
                {
46
                        Object[] types = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(50)};
47
                        pd.addValue("Slider", "slider1", new Integer(25), types); // Slider
48
                }
49
                pd.addValue("Activo", "check1", new Boolean(true), null); // Slider
50
                {
51
                        ArrayList lista = new ArrayList();
52
                        lista.add("Primer elemento");
53
                        lista.add("Segundo elemento");
54
                        lista.add("Tercer elemento");
55
                        Object[] types = {new Integer(PropertiesComponent.TYPE_COMBO), lista};
56
                        pd.addValue("Combo", "combo1", new Integer(1), types); // Combo
57
                }
58

    
59
                frame.getContentPane().add(pd);
60
                frame.show();
61
                frame.pack();
62
                frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
63
        }
64

    
65
        public static void main(String[] args) {
66
                try {
67
                        UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
68
                } catch (Exception e) {
69
                        System.err.println("No se puede cambiar al LookAndFeel");
70
                }
71
                
72
                new TestPropertiesPanel();
73
        }
74

    
75
        public void actionButtonPressed(ButtonsPanelEvent e) {
76
                if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
77
                        ArrayList values = pd.getValues();
78
                        System.out.println("-----");
79
                        for (int i=0; i<values.size(); i++) {
80
                                System.out.println(((PropertyStruct)values.get(i)).key
81
                                                + ": '" + ((PropertyStruct)values.get(i)).oldValue.toString()
82
                                                + "', '" + ((PropertyStruct)values.get(i)).newValue.toString() + "'");
83
                        }
84
                }
85
                
86
        }
87
}