Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / propertiespanel / PropertiesPanel.java @ 14175

History | View | Annotate | Download (5.02 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.awt.BorderLayout;
22
import java.awt.Component;
23
import java.util.ArrayList;
24
import java.util.Properties;
25

    
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
27
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
28
/**
29
 * Panel para crear un cuadro de propiedades de configuracion standard.
30
 * Tiene botones de aceptar, cancelar y aplicar.
31
 * @version 19/04/2007
32
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
33
 */
34
public class PropertiesPanel extends DefaultButtonsPanel {
35
        private static final long serialVersionUID = 372118344763661890L;
36
        PropertiesComponent propertiesComponent = null;
37

    
38
        /**
39
         * Constructor de la calse
40
         */
41
        public PropertiesPanel() {
42
                super(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY);
43
                propertiesComponent = new PropertiesComponent();
44
                initialize();
45
        }
46

    
47
        /**
48
         * Constructor para poder pasarle un ArrayList de PropertyStruct
49
         * @param values
50
         */
51
        public PropertiesPanel(ArrayList values) {
52
                super(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY);
53
                propertiesComponent = new PropertiesComponent(values);
54
                initialize();
55
        }
56

    
57
        /**
58
         * Constructor para poder pasarle un Properties
59
         * @param values
60
         */
61
        public PropertiesPanel(Properties properties) {
62
                super(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY);
63
                propertiesComponent = new PropertiesComponent(properties);
64
                initialize();
65
        }
66

    
67
        /**
68
         * A?ade un PropertyStruct al componente
69
         * @param property
70
         */
71
        public void addPropertyStruct(PropertyStruct property) {
72
                propertiesComponent.addPropertyStruct(property);
73
        }
74

    
75
        /**
76
         * Creaci?n de la ventana con sus componentes
77
         */
78
        private void initialize() {
79
                this.setLayout(new BorderLayout(0, 0));
80
                this.add(propertiesComponent, BorderLayout.CENTER);
81
        }
82

    
83
        /**
84
         * A?ade una clave/valor al panel de propiedades.<br>
85
         * <br>
86
         * El componente seleccionado dependera del instanceof del valor y las
87
         * opciones extras que se pongan. Por ejemplo: para el instanceof de un String
88
         * siempre se usara un JTextField, en cambio, para un Integer, se podran usar
89
         * 3 tipos, el JSlider, JComboBox y JSpinner. Estos tipos se especifican en el
90
         * array extras, poniendolo siempre en la posicion 0. En la posici?n 1 y 2 de
91
         * un JSlider se puede especificar el m?nimo y el m?ximo del Slider.
92
         *
93
         * @param textLabel
94
         * @param key
95
         * @param value
96
         * @param extras
97
         */
98
        public void addValue(String textLabel, String key, Object value, Object[] extras) {
99
                propertiesComponent.addValue(textLabel, key, value, extras);
100
        }
101

    
102
        /**
103
         * A?ade una clave valor al panel de propiedades.
104
         * @param key
105
         * @param value
106
         */
107
        public void put(Object key, Object value) {
108
                propertiesComponent.put(key, value);
109
        }
110

    
111
        /**
112
         * Obtener todos los valores de la ventana, esto ser? un
113
         * <code><b>ArrayList</b></code> que contendr? elementos de tipo
114
         * <code><b>PropertyStruct</b></code>, pudiendo tener el valor antes de
115
         * ser modificado y el nuevo valor.
116
         *
117
         * @see <code>PropertyStruct</code>
118
         *
119
         * @return ArrayList de elementos de tipo <code>PropertyStruct</code>
120
         */
121
        public ArrayList getValues() {
122
                return propertiesComponent.getValues();
123
        }
124

    
125
        /**
126
         * Obtener todos los valores de la ventana en formato java.util.Properties
127
         * @return
128
         */
129
        public Properties getProperties() {
130
                return propertiesComponent.getProperties();
131
        }
132
        
133
        /**
134
         * Devuelve el componente del interfaz que trata esa variable, hay que tener
135
         * cuidado, puede devolver null o un componente distinto al esperado si se
136
         * mod?fica esta clase.
137
         * @param name
138
         * @return
139
         */
140
        public Component getComponentUI(String name) {
141
                return propertiesComponent.getComponentUI(name);
142
        }
143

    
144
        /**
145
         * A?adir el disparador de cuando se pulsa un bot?n.
146
         * @param listener
147
         */
148
        public void addStateChangedListener(PropertiesComponentListener listener) {
149
                propertiesComponent.addStateChangedListener(listener);
150
        }
151

    
152
        /**
153
         * Borrar el disparador de eventos de los botones.
154
         * @param listener
155
         */
156
        public void removeStateChangedListener(PropertiesComponentListener listener) {
157
                propertiesComponent.removeStateChangedListener(listener);
158
        }
159

    
160
        /**
161
         * Devuelve el PropertiesComponent que contiene este panel.
162
         * @return PropertiesComponent
163
         */
164
        public PropertiesComponent getPropertiesComponent(){
165
                return propertiesComponent;
166
        }
167
}