Statistics
| Revision:

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

History | View | Annotate | Download (5.12 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
package org.gvsig.gui.beans.propertiespanel;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.Component;
28
import java.util.ArrayList;
29
import java.util.Properties;
30

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

    
43
        /**
44
         * Constructor de la calse
45
         */
46
        public PropertiesPanel() {
47
                super(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY);
48
                propertiesComponent = new PropertiesComponent();
49
                initialize();
50
        }
51

    
52
        /**
53
         * Constructor para poder pasarle un ArrayList de PropertyStruct
54
         * @param values
55
         */
56
        public PropertiesPanel(ArrayList values) {
57
                super(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY);
58
                propertiesComponent = new PropertiesComponent(values);
59
                initialize();
60
        }
61

    
62
        /**
63
         * Constructor para poder pasarle un Properties
64
         * @param values
65
         */
66
        public PropertiesPanel(Properties properties) {
67
                super(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY);
68
                propertiesComponent = new PropertiesComponent(properties);
69
                initialize();
70
        }
71

    
72
        /**
73
         * A?ade un PropertyStruct al componente
74
         * @param property
75
         */
76
        public void addPropertyStruct(PropertyStruct property) {
77
                propertiesComponent.addPropertyStruct(property);
78
        }
79

    
80
        /**
81
         * Creaci?n de la ventana con sus componentes
82
         */
83
        private void initialize() {
84
                this.setLayout(new BorderLayout(0, 0));
85
                this.add(propertiesComponent, BorderLayout.CENTER);
86
        }
87

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

    
107
        /**
108
         * A?ade una clave valor al panel de propiedades.
109
         * @param key
110
         * @param value
111
         */
112
        public void put(Object key, Object value) {
113
                propertiesComponent.put(key, value);
114
        }
115

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

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

    
149
        /**
150
         * A?adir el disparador de cuando se pulsa un bot?n.
151
         * @param listener
152
         */
153
        public void addStateChangedListener(PropertiesComponentListener listener) {
154
                propertiesComponent.addStateChangedListener(listener);
155
        }
156

    
157
        /**
158
         * Borrar el disparador de eventos de los botones.
159
         * @param listener
160
         */
161
        public void removeStateChangedListener(PropertiesComponentListener listener) {
162
                propertiesComponent.removeStateChangedListener(listener);
163
        }
164

    
165
        /**
166
         * Devuelve el PropertiesComponent que contiene este panel.
167
         * @return PropertiesComponent
168
         */
169
        public PropertiesComponent getPropertiesComponent(){
170
                return propertiesComponent;
171
        }
172
}