svn-gvsig-desktop / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / propertiespanel / TestPropertiesPanel.java @ 11578
History | View | Annotate | Download (3.2 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 |
PropertyStruct property = new PropertyStruct();
|
56 |
property.setTextLabel("Combo");
|
57 |
property.setKey("combo1");
|
58 |
property.setOldValue(new Integer(1)); |
59 |
Object[] types = {new Integer(PropertiesComponent.TYPE_COMBO), lista}; |
60 |
property.setExtras(types); |
61 |
pd.addPropertyStruct(property); |
62 |
/*
|
63 |
pd = new PropertiesPanel(pd.getProperties());
|
64 |
pd.put("hola", new Boolean(true));
|
65 |
pd.put("hola", "adios");
|
66 |
pd.put("hola", new Integer(3));
|
67 |
pd.put("hola", lista);
|
68 |
*/
|
69 |
} |
70 |
frame.getContentPane().add(pd); |
71 |
frame.show(); |
72 |
frame.pack(); |
73 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
74 |
} |
75 |
|
76 |
public static void main(String[] args) { |
77 |
try {
|
78 |
UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel"); |
79 |
} catch (Exception e) { |
80 |
System.err.println("No se puede cambiar al LookAndFeel"); |
81 |
} |
82 |
|
83 |
new TestPropertiesPanel();
|
84 |
} |
85 |
|
86 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
87 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
88 |
ArrayList values = pd.getValues();
|
89 |
System.out.println("-----"); |
90 |
for (int i=0; i<values.size(); i++) { |
91 |
System.out.println(((PropertyStruct)values.get(i)).getKey()
|
92 |
+ ": '" + ((PropertyStruct)values.get(i)).getOldValue().toString()
|
93 |
+ "', '" + ((PropertyStruct)values.get(i)).getNewValue().toString() + "'"); |
94 |
} |
95 |
} |
96 |
|
97 |
} |
98 |
} |