root / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / propertiespanel / TestPropertiesPanel2.java @ 12623
History | View | Annotate | Download (3.41 KB)
1 | 12012 | bsanchez | /* 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 TestPropertiesPanel2 implements ButtonsPanelListener, PropertiesComponentListener { |
||
31 | JFrame frame = null; |
||
32 | PropertiesPanel pd = null;
|
||
33 | |||
34 | public TestPropertiesPanel2() {
|
||
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 | 12121 | bsanchez | ArrayList lista = new ArrayList(); |
56 | 12012 | bsanchez | 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 | pd = new PropertiesPanel(pd.getProperties());
|
||
68 | } |
||
69 | frame.getContentPane().add(pd); |
||
70 | frame.pack(); |
||
71 | frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
||
72 | pd.addStateChangedListener(this);
|
||
73 | 12107 | bsanchez | frame.setVisible(true);
|
74 | 12012 | bsanchez | } |
75 | |||
76 | public static void main(String[] args) { |
||
77 | new TestPropertiesPanel2();
|
||
78 | } |
||
79 | |||
80 | public void actionButtonPressed(ButtonsPanelEvent e) { |
||
81 | if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
||
82 | ArrayList values = pd.getValues();
|
||
83 | System.out.println("-----"); |
||
84 | for (int i=0; i<values.size(); i++) { |
||
85 | System.out.println(((PropertyStruct)values.get(i)).getKey()
|
||
86 | + ": '" + ((PropertyStruct)values.get(i)).getOldValue().toString()
|
||
87 | + "', '" + ((PropertyStruct)values.get(i)).getNewValue().toString() + "'"); |
||
88 | } |
||
89 | } |
||
90 | } |
||
91 | |||
92 | public void actionChangeProperties(EventObject e) { |
||
93 | System.out.println("Ha cambiado"); |
||
94 | } |
||
95 | } |