Statistics
| Revision:

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

History | View | Annotate | Download (4.47 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.propertiespanel;
43

    
44
import java.awt.Toolkit;
45
import java.util.ArrayList;
46
import java.util.EventObject;
47

    
48
import org.gvsig.gui.beans.TestUI;
49
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
50
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
51
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
52

    
53
public class TestPropertiesPanel implements ButtonsPanelListener, PropertiesComponentListener {
54
        TestUI frame = null;
55
        PropertiesPanel pd = null;
56

    
57
        public TestPropertiesPanel() {
58
                initialize();
59
        }
60

    
61
        public void initialize() {
62
                Toolkit.getDefaultToolkit().setDynamicLayout(true);
63
                frame = new TestUI("TestPropertiesPanel");
64
                pd = new PropertiesPanel();
65

    
66
                pd.addButtonPressedListener(this);
67
                pd.addValue("Protocolo", "protocolo", "", null);
68
                pd.addValue("Integer", "var1", new Integer(50), null);
69
                {
70
                        Object[] types = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(-255), new Integer(255)};
71
                        pd.addValue("Slider", "slider1", new Integer(25), types); // Slider
72
                        Object[] types2 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(50)};
73
                        pd.addValue("Slider", "slider2", new Integer(25), types2); // Slider
74
                        Object[] types3 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(100)};
75
                        pd.addValue("Slider", "slider3", new Double(25), types3); // Slider
76
                }
77
                pd.addValue("Activo", "check1", new Boolean(true), null); // Slider
78
                {
79
                        ArrayList lista = new ArrayList();
80
                        lista.add("Primer elemento");
81
                        lista.add("Segundo elemento");
82
                        lista.add("Tercer elemento");
83
                        PropertyStruct property = new PropertyStruct();
84
                        property.setTextLabel("Combo");
85
                        property.setKey("combo1");
86
                        property.setOldValue(new Integer(1));
87
                        Object[] types = {new Integer(PropertiesComponent.TYPE_COMBO), lista};
88
                        property.setExtras(types);
89
                        pd.addPropertyStruct(property);
90
                }
91
                frame.getContentPane().add(pd);
92
                frame.pack();
93
                pd.addStateChangedListener(this);
94
                frame.setVisible(true);
95
        }
96

    
97
        public static void main(String[] args) {
98
                new TestPropertiesPanel();
99
        }
100

    
101
        public void actionButtonPressed(ButtonsPanelEvent e) {
102
                if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
103
                        ArrayList values = pd.getValues();
104
                        System.out.println("-----");
105
                        for (int i=0; i<values.size(); i++) {
106
                                System.out.println(((PropertyStruct)values.get(i)).getKey()
107
                                                + ": '" + ((PropertyStruct)values.get(i)).getOldValue().toString()
108
                                                + "', '" + ((PropertyStruct)values.get(i)).getNewValue().toString() + "'");
109
                                System.out.println(pd.getComponentUI(((PropertyStruct)values.get(i)).getKey()).toString());
110
                        }
111
                }
112
        }
113

    
114
        public void actionChangeProperties(EventObject e) {
115
                System.out.println("Ha cambiado");
116
                System.out.println(pd.getProperties().get("slider3"));
117
        }
118
}