Statistics
| Revision:

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

History | View | Annotate | Download (3.35 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

    
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, PropertiesComponentListener {
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(-255), new Integer(255)};
47
                        pd.addValue("Slider", "slider1", new Integer(25), types); // Slider
48
                        Object[] types2 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(50)};
49
                        pd.addValue("Slider", "slider2", new Integer(25), types2); // Slider
50
                        Object[] types3 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(100)};
51
                        pd.addValue("Slider", "slider3", new Integer(25), types3); // Slider
52
                }
53
                pd.addValue("Activo", "check1", new Boolean(true), null); // Slider
54
                {
55
                        ArrayList lista = new ArrayList();
56
                        lista.add("Primer elemento");
57
                        lista.add("Segundo elemento");
58
                        lista.add("Tercer elemento");
59
                        PropertyStruct property = new PropertyStruct();
60
                        property.setTextLabel("Combo");
61
                        property.setKey("combo1");
62
                        property.setOldValue(new Integer(1));
63
                        Object[] types = {new Integer(PropertiesComponent.TYPE_COMBO), lista};
64
                        property.setExtras(types);
65
                        pd.addPropertyStruct(property);
66
                }
67
                frame.getContentPane().add(pd);
68
                frame.pack();
69
                frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
70
                pd.addStateChangedListener(this);
71
                frame.setVisible(true);
72
        }
73

    
74
        public static void main(String[] args) {
75
                new TestPropertiesPanel();
76
        }
77

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

    
90
        public void actionChangeProperties(EventObject e) {
91
                System.out.println("Ha cambiado");
92
        }
93
}