Statistics
| Revision:

root / branches / CatalogYNomenclator_v1_1_0_1005 / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / ui / search / SearchUpperPanel.java @ 12552

History | View | Annotate | Download (9.84 KB)

1

    
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package es.gva.cit.catalogClient.ui.search;
43
import java.awt.Dimension;
44
import java.awt.event.ActionListener;
45

    
46
import javax.swing.ImageIcon;
47
import javax.swing.JPanel;
48

    
49
import org.gvsig.i18n.Messages;
50

    
51
import es.gva.cit.catalogClient.querys.Query;
52
import es.gva.cit.catalogClient.querys.Search;
53
import es.gva.cit.catalogClient.utils.CatalogConstants;
54

    
55
/**
56
 * @author Jorge Piera Llodra (piera_jor@gva.es)
57
 */
58
public class SearchUpperPanel extends JPanel {
59
         private javax.swing.JCheckBox areaCheckBox;
60
            private javax.swing.JPanel areaPanel;
61
            private javax.swing.JPanel leftPanel;
62
            private javax.swing.JButton resizeButton;
63
            private javax.swing.JPanel resizePanel;
64
            private javax.swing.JComboBox serviceCombo;
65
            private javax.swing.JLabel serviceLabel;
66
            private javax.swing.JPanel servicePanel;
67
            private javax.swing.JLabel titleLabel;
68
            private javax.swing.JPanel titlePanel;
69
            private javax.swing.JTextField titleText;
70

    
71
        /** Creates new form upperPanel */
72
        public SearchUpperPanel() {
73
                initComponents();
74
                initLabels();
75
                initDefaultValues();
76
        }
77

    
78
        /** This method is called from within the constructor to
79
         * initialize the form.
80
         * WARNING: Do NOT modify this code. The content of this method is
81
         * always regenerated by the Form Editor.
82
         */
83
        // <editor-fold defaultstate="collapsed" desc=" C?digo Generado  ">                          
84
        private void initComponents() {
85
                 java.awt.GridBagConstraints gridBagConstraints;
86

    
87
                leftPanel = new javax.swing.JPanel();
88
                areaPanel = new javax.swing.JPanel();
89
                areaCheckBox = new javax.swing.JCheckBox();
90
                resizePanel = new javax.swing.JPanel();
91
                resizeButton = new javax.swing.JButton();
92
                servicePanel = new javax.swing.JPanel();
93
                serviceLabel = new javax.swing.JLabel();
94
                serviceCombo = new javax.swing.JComboBox();
95
                titlePanel = new javax.swing.JPanel();
96
                titleLabel = new javax.swing.JLabel();
97
                titleText = new javax.swing.JTextField();
98

    
99
                setLayout(new java.awt.GridBagLayout());
100

    
101
                leftPanel.setLayout(new java.awt.GridBagLayout());
102

    
103
                areaPanel.setLayout(new java.awt.GridBagLayout());
104

    
105
                areaCheckBox.setText("jCheckBox1");
106
                areaCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
107
                areaCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
108
                gridBagConstraints = new java.awt.GridBagConstraints();
109
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
110
                gridBagConstraints.weightx = 1.0;
111
                gridBagConstraints.insets = new java.awt.Insets(20, 2, 2, 2);
112
                areaPanel.add(areaCheckBox, gridBagConstraints);
113

    
114
                gridBagConstraints = new java.awt.GridBagConstraints();
115
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
116
                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
117
                gridBagConstraints.weightx = 0.8;
118
                leftPanel.add(areaPanel, gridBagConstraints);
119

    
120
                resizePanel.setLayout(new java.awt.GridBagLayout());
121

    
122
                resizeButton.setText("jButton1");
123
                resizeButton.setPreferredSize(new java.awt.Dimension(18, 18));
124
          
125
                gridBagConstraints = new java.awt.GridBagConstraints();
126
                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
127
                gridBagConstraints.weightx = 1.0;
128
                gridBagConstraints.insets = new java.awt.Insets(20, 2, 2, 5);
129
                resizePanel.add(resizeButton, gridBagConstraints);
130

    
131
                gridBagConstraints = new java.awt.GridBagConstraints();
132
                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
133
                gridBagConstraints.weightx = 0.2;
134
                leftPanel.add(resizePanel, gridBagConstraints);
135

    
136
                gridBagConstraints = new java.awt.GridBagConstraints();
137
                gridBagConstraints.gridx = 1;
138
                gridBagConstraints.gridy = 1;
139
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
140
                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
141
                gridBagConstraints.weightx = 0.5;
142
                gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 2);
143
                add(leftPanel, gridBagConstraints);
144

    
145
                servicePanel.setLayout(new java.awt.GridBagLayout());
146

    
147
                serviceLabel.setText("jLabel1");
148
                gridBagConstraints = new java.awt.GridBagConstraints();
149
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
150
                gridBagConstraints.weightx = 1.0;
151
                gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 2);
152
                servicePanel.add(serviceLabel, gridBagConstraints);
153

    
154
                serviceCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
155
                gridBagConstraints = new java.awt.GridBagConstraints();
156
                gridBagConstraints.gridx = 0;
157
                gridBagConstraints.gridy = 1;
158
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
159
                gridBagConstraints.weightx = 1.0;
160
                gridBagConstraints.insets = new java.awt.Insets(2, 5, 5, 2);
161
                servicePanel.add(serviceCombo, gridBagConstraints);
162

    
163
                gridBagConstraints = new java.awt.GridBagConstraints();
164
                gridBagConstraints.gridx = 0;
165
                gridBagConstraints.gridy = 0;
166
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
167
                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
168
                gridBagConstraints.weightx = 0.5;
169
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 5);
170
                add(servicePanel, gridBagConstraints);
171

    
172
                titlePanel.setLayout(new java.awt.GridBagLayout());
173

    
174
                titleLabel.setText("jLabel1");
175
                gridBagConstraints = new java.awt.GridBagConstraints();
176
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
177
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
178
                gridBagConstraints.weightx = 1.0;
179
                gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 2);
180
                titlePanel.add(titleLabel, gridBagConstraints);
181

    
182
                titleText.setText("jTextField1");
183
                gridBagConstraints = new java.awt.GridBagConstraints();
184
                gridBagConstraints.gridx = 0;
185
                gridBagConstraints.gridy = 1;
186
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
187
                gridBagConstraints.weightx = 1.0;
188
                gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 2);
189
                titlePanel.add(titleText, gridBagConstraints);
190

    
191
                gridBagConstraints = new java.awt.GridBagConstraints();
192
                gridBagConstraints.gridx = 0;
193
                gridBagConstraints.gridy = 1;
194
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
195
                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
196
                gridBagConstraints.weightx = 0.5;
197
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 5);
198
                add(titlePanel, gridBagConstraints);
199
        }// </editor-fold> 
200

    
201
        /**
202
         * Initializae some components with their default values
203
         */
204
        private void initDefaultValues(){
205
                serviceCombo.removeAllItems();
206
        }
207
        
208
        /**
209
         * Rewrite the labels
210
         */
211
        private void initLabels(){
212
                titleText.setText("");
213
                titleLabel.setText(Messages.getText("title"));
214
                areaCheckBox.setText(Messages.getText("restrictArea"));
215
                resizeButton.setPreferredSize(new Dimension(CatalogConstants.RESIZE_WINDOW_BUTTON_SIZE, 
216
                                CatalogConstants.RESIZE_WINDOW_BUTTON_SIZE));
217
                setDownIcon();
218
        }
219

    
220
        /**
221
         * Add a listener for the buttons
222
         * @param listener
223
         * Listener to add
224
         */
225
        public void addActionListener(ActionListener listener){
226
                resizeButton.addActionListener(listener);
227
                resizeButton.setActionCommand("resize");
228
        }
229

    
230
        /**
231
         * Sets the up triangle icon (to minimize)
232
         */
233
        public void setUpIcon() {        
234
                resizeButton.setIcon(new ImageIcon("./gvSIG/extensiones/es.gva.cit.gvsig.catalogClient/images/up.png"));
235
        } 
236

    
237
        /**
238
         * Sets the down triangle icon (to maximize)
239
         */
240
        public void setDownIcon() {        
241
                resizeButton.setIcon(new ImageIcon("./gvSIG/extensiones/es.gva.cit.gvsig.catalogClient/images/down.png"));
242
        } 
243
        
244
        /**
245
         * @return if the are check is clicked
246
         */
247
    public boolean isRestrictAreaClicked() {        
248
        return areaCheckBox.isSelected();
249
    } 
250
    
251
    /**
252
     * @return the title 
253
     */
254
    public String getTitle(){
255
            if (titleText.getText().equals("")){
256
                    return null;
257
            }
258
            return titleText.getText();
259
    }
260

    
261
    /**
262
     * Adds a new service
263
     * @param service
264
     */
265
    public void addService(Search service){
266
            serviceCombo.addItem(service);
267
    }
268
    
269
    /**
270
     * @return the service
271
     */
272
        public Search getService() {
273
                return (Search)serviceCombo.getSelectedItem();
274
         }
275

    
276
        /**
277
         * @return if the area checkbox is clicked
278
         */
279
        public boolean getRestrictAreaClicked() {
280
                return areaCheckBox.isSelected();
281
        }
282
}