root / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / propertiespanel / TestPropertiesPanel2.java @ 17972
History | View | Annotate | Download (3.36 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 org.gvsig.gui.beans.TestUI; |
25 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
26 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
27 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
28 |
|
29 |
public class TestPropertiesPanel2 implements ButtonsPanelListener, PropertiesComponentListener { |
30 |
TestUI frame = null;
|
31 |
PropertiesPanel pd = null;
|
32 |
|
33 |
public TestPropertiesPanel2() {
|
34 |
initialize(); |
35 |
} |
36 |
|
37 |
public void initialize() { |
38 |
frame = new TestUI("TestPropertiesPanel2"); |
39 |
pd = new PropertiesPanel();
|
40 |
|
41 |
pd.addButtonPressedListener(this);
|
42 |
pd.addValue("Protocolo", "protocolo", "", null); |
43 |
pd.addValue("Integer", "var1", new Integer(50), null); |
44 |
{ |
45 |
Object[] types = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(-255), new Integer(255)}; |
46 |
pd.addValue("Slider", "slider1", new Integer(25), types); // Slider |
47 |
Object[] types2 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(50)}; |
48 |
pd.addValue("Slider", "slider2", new Integer(25), types2); // Slider |
49 |
Object[] types3 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(100)}; |
50 |
pd.addValue("Slider", "slider3", new Integer(25), types3); // Slider |
51 |
} |
52 |
pd.addValue("Activo", "check1", new Boolean(true), null); // Slider |
53 |
{ |
54 |
ArrayList lista = new ArrayList(); |
55 |
lista.add("Primer elemento");
|
56 |
lista.add("Segundo elemento");
|
57 |
lista.add("Tercer elemento");
|
58 |
PropertyStruct property = new PropertyStruct();
|
59 |
property.setTextLabel("Combo");
|
60 |
property.setKey("combo1");
|
61 |
property.setOldValue(new Integer(1)); |
62 |
Object[] types = {new Integer(PropertiesComponent.TYPE_COMBO), lista}; |
63 |
property.setExtras(types); |
64 |
pd.addPropertyStruct(property); |
65 |
|
66 |
pd = new PropertiesPanel(pd.getProperties());
|
67 |
} |
68 |
frame.getContentPane().add(pd); |
69 |
frame.pack(); |
70 |
pd.addStateChangedListener(this);
|
71 |
frame.setVisible(true);
|
72 |
} |
73 |
|
74 |
public static void main(String[] args) { |
75 |
new TestPropertiesPanel2();
|
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 |
} |