Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / propertiespanel / TestPropertiesPanel.java @ 11788

History | View | Annotate | Download (3.73 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
import java.util.EventObject;
23

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

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

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

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

    
43
                pd.addButtonPressedListener(this);
44
                pd.addValue("Protocolo", "protocolo", "", null);
45
                pd.addValue("Integer", "var1", new Integer(50), null);
46
                {
47
                        Object[] types = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(-255), new Integer(255)};
48
                        pd.addValue("Slider", "slider1", new Integer(25), types); // Slider
49
                        Object[] types2 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(50)};
50
                        pd.addValue("Slider", "slider2", new Integer(25), types2); // Slider
51
                        Object[] types3 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(100)};
52
                        pd.addValue("Slider", "slider3", new Integer(25), types3); // Slider
53
                }
54
                pd.addValue("Activo", "check1", new Boolean(true), null); // Slider
55
                {
56
                        ArrayList lista = new ArrayList();
57
                        lista.add("Primer elemento");
58
                        lista.add("Segundo elemento");
59
                        lista.add("Tercer elemento");
60
                        PropertyStruct property = new PropertyStruct();
61
                        property.setTextLabel("Combo");
62
                        property.setKey("combo1");
63
                        property.setOldValue(new Integer(1));
64
                        Object[] types = {new Integer(PropertiesComponent.TYPE_COMBO), lista};
65
                        property.setExtras(types);
66
                        pd.addPropertyStruct(property);
67
/*
68
                        pd = new PropertiesPanel(pd.getProperties());
69
                        pd.put("hola", new Boolean(true));
70
                        pd.put("hola", "adios");
71
                        pd.put("hola", new Integer(3));
72
                        pd.put("hola", lista);
73
*/
74
                }
75
                frame.getContentPane().add(pd);
76
                frame.show();
77
                frame.pack();
78
                frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
79
                pd.addStateChangedListener(this);
80
        }
81

    
82
        public static void main(String[] args) {
83
                try {
84
                        UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
85
                } catch (Exception e) {
86
                        System.err.println("No se puede cambiar al LookAndFeel");
87
                }
88
                
89
                new TestPropertiesPanel();
90
        }
91

    
92
        public void actionButtonPressed(ButtonsPanelEvent e) {
93
                if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
94
                        ArrayList values = pd.getValues();
95
                        System.out.println("-----");
96
                        for (int i=0; i<values.size(); i++) {
97
                                System.out.println(((PropertyStruct)values.get(i)).getKey()
98
                                                + ": '" + ((PropertyStruct)values.get(i)).getOldValue().toString()
99
                                                + "', '" + ((PropertyStruct)values.get(i)).getNewValue().toString() + "'");
100
                        }
101
                }
102
        }
103

    
104
        public void actionChangeProperties(EventObject e) {
105
                System.out.println("Ha cambiado");
106
        }
107
}