Statistics
| Revision:

root / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / ui / ShowResultsPanel.java @ 3017

History | View | Annotate | Download (8.46 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2004 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
* For more information, contact:
20
*
21
*  Generalitat Valenciana
22
*   Conselleria d'Infraestructures i Transport
23
*   Av. Blasco Ib??ez, 50
24
*   46010 VALENCIA
25
*   SPAIN
26
*
27
*      +34 963862235
28
*   gvsig@gva.es
29
*      www.gvsig.gva.es
30
*
31
*    or
32
*
33
*   IVER T.I. S.A
34
*   Salamanca 50
35
*   46005 Valencia
36
*   Spain
37
*
38
*   +34 963163400
39
*   dac@iver.es
40
*/
41
package es.gva.cit.gazetteer.ui;
42

    
43
import es.gva.cit.gazetteer.querys.Feature;
44

    
45
import javax.swing.BoxLayout;
46
import javax.swing.DefaultListModel;
47
import javax.swing.JButton;
48
import javax.swing.JLabel;
49
import javax.swing.JPanel;
50
import javax.swing.JScrollPane;
51

    
52

    
53
import javax.swing.JList;
54

    
55
/**
56
 * @author Jorge Piera Llodra (piera_jor@gva.es)
57
 */
58
public class ShowResultsPanel extends JPanel {
59
    private Feature[] features;      
60
    private JPanel descriptionPanel = null;
61
    private JPanel linksPanel = null;
62
    private JPanel jPanel = null;
63
    private JButton mapButton = null; //  @jve:decl-index=0:
64
    private JScrollPane descriptionScroll = null; //  @jve:decl-index=0:
65
    private JLabel jLabel1 = null;
66
    private JPanel jPanel1 = null;
67
    private JPanel nextLastPanel = null;
68
    private JButton lastButton = null;
69
    private JLabel textLabel = null;
70
    private JButton nextButton = null;
71
    private int numPages;
72
        
73
        private JButton closeButton = null;
74
        private DefaultListModel listModel = null;
75
        private JList descriptionList = null;
76
   
77
    public ShowResultsPanel(Feature[] features,int numPages,int recordsByPage) {
78
        super();   
79
        this.features = features;
80
        this.numPages = numPages;
81
        initialize(recordsByPage);
82
    }
83

    
84
    /**
85
     * This method initializes this
86
     *
87
     * @return void
88
     */
89
    private void initialize(int recordsByPage) {
90
        this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
91
        this.setSize(703, 264);
92
        this.add(getNextLastPanel(), null);
93
        this.add(getJPanel1(), null);
94
        this.add(getDescriptionPanel(), null);
95
        this.add(getJPanel(), null);
96
        this.add(getLinksPanel(), null);
97
        actualizaLabel(1,recordsByPage);
98
        
99
    }
100
    /**
101
     * It loads the feature list
102
     *
103
     */
104
    private void loadList(int first,int last){
105
        if (features.length < last)
106
            last = features.length - 1;
107
            
108
             listModel.removeAllElements();
109
        
110
        int index = 0;
111
        for (int i=first ; i<=last ; i++)
112
            if (i < features.length){
113
                listModel.add(index,features[i]);
114
                index++;
115
            }        
116
    }
117

    
118
    /**
119
     * Actualiza el valor de la cadena de taexto que muestra los resultados
120
     * @param number
121
     * Registro actual
122
     */
123
    public void actualizaLabel(int number,int recordsByPage) {
124
        textLabel.setText("Resultados: " +String.valueOf(features.length) + ". P?gina: " + String.valueOf(number) + " de " +
125
            String.valueOf(this.numPages));
126
        loadList((number * recordsByPage) - recordsByPage,(number * recordsByPage)-1);
127
    }
128

    
129
    /**
130
     * @param mapButton The mapButton to set.
131
     */
132
    public void setMapButton(JButton mapButton) {
133
        this.mapButton = mapButton;
134
    }
135

    
136
    /**
137
     * This method initializes jPanel
138
     *
139
     * @return javax.swing.JPanel
140
     */
141
    private JPanel getDescriptionPanel() {
142
        if (descriptionPanel == null) {
143
            jLabel1 = new JLabel();
144
            descriptionPanel = new JPanel();
145
            descriptionPanel.setLayout(new BoxLayout(descriptionPanel,
146
                    BoxLayout.X_AXIS));
147
            descriptionPanel.setPreferredSize(new java.awt.Dimension(600, 200));
148
            jLabel1.setText("");
149
            jLabel1.setPreferredSize(new java.awt.Dimension(40, 0));
150
            descriptionPanel.add(getDescriptionScroll(), null);
151

    
152
            
153
        }
154

    
155
        return descriptionPanel;
156
    }
157

    
158
    /**
159
     * This method initializes jPanel
160
     *
161
     * @return javax.swing.JPanel
162
     */
163
    private JPanel getLinksPanel() {
164
        if (linksPanel == null) {
165
            linksPanel = new JPanel();
166
            linksPanel.add(getMapButton(), null);
167
            linksPanel.add(getCloseButton(), null);
168
        }
169

    
170
        return linksPanel;
171
    }
172

    
173
    /**
174
     * This method initializes jPanel
175
     *
176
     * @return javax.swing.JPanel
177
     */
178
    private JPanel getJPanel() {
179
        if (jPanel == null) {
180
            jPanel = new JPanel();
181
        }
182

    
183
        return jPanel;
184
    }
185

    
186
    /**
187
     * This method initializes jButton 1
188
     *
189
     * @return javax.swing.JButton
190
     */
191
    public JButton getMapButton() {
192
        if (mapButton == null) {
193
            mapButton = new JButton();
194
            mapButton.setText("Cargar");
195
            mapButton.setPreferredSize(new java.awt.Dimension(102, 26));
196
        }
197

    
198
        return mapButton;
199
    }
200

    
201
    /**
202
     * This method initializes jScrollPane
203
     *
204
     * @return javax.swing.JScrollPane
205
     */
206
    public JScrollPane getDescriptionScroll() {
207
        if (descriptionScroll == null) {
208
            descriptionScroll = new JScrollPane();
209
            descriptionScroll.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
210
            descriptionScroll.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
211
            descriptionScroll.setPreferredSize(new java.awt.Dimension(400, 150));
212
            descriptionScroll.setViewportView(getDescriptionList());
213
        }
214

    
215
        return descriptionScroll;
216
    }
217
     
218
    
219
    
220

    
221
   
222
    /**
223
     * This method initializes jPanel1
224
     *
225
     * @return javax.swing.JPanel
226
     */
227
    private JPanel getJPanel1() {
228
        if (jPanel1 == null) {
229
            jPanel1 = new JPanel();
230
        }
231

    
232
        return jPanel1;
233
    }
234

    
235
    /**
236
     * This method initializes jPanel2
237
     *
238
     * @return javax.swing.JPanel
239
     */
240
    private JPanel getNextLastPanel() {
241
        if (nextLastPanel == null) {
242
            textLabel = new JLabel();
243
            nextLastPanel = new JPanel();
244
            textLabel.setText("JLabel");
245
            nextLastPanel.add(getLastButton(), null);
246
            nextLastPanel.add(textLabel, null);
247
            nextLastPanel.add(getNextButton(), null);
248
        }
249

    
250
        return nextLastPanel;
251
    }
252

    
253
    /**
254
     * This method initializes jButton
255
     *
256
     * @return javax.swing.JButton
257
     */
258
    public JButton getLastButton() {
259
        if (lastButton == null) {
260
            lastButton = new JButton();
261
            lastButton.setText("Anterior");
262
            lastButton.setEnabled(false);
263
        }
264

    
265
        return lastButton;
266
    }
267

    
268
    /**
269
     * This method initializes jButton
270
     *
271
     * @return javax.swing.JButton
272
     */
273
    public JButton getNextButton() {
274
        if (nextButton == null) {
275
            nextButton = new JButton();
276
            nextButton.setText("Siguiente");
277

    
278
            if (this.numPages < 2) {
279
                nextButton.setEnabled(false);
280
            }
281
        }
282

    
283
        return nextButton;
284
    }
285
    
286

    
287
  
288
        /**
289
         * This method initializes jButton        
290
         *         
291
         * @return javax.swing.JButton        
292
         */    
293
        public JButton getCloseButton() {
294
                if (closeButton == null) {
295
                        closeButton = new JButton();
296
                        closeButton.setText("Cerrar");
297
                        closeButton.setPreferredSize(new java.awt.Dimension(102,26));
298
                }
299
                return closeButton;
300
        }
301
                
302
        /**
303
         * This method initializes jList        
304
         *         
305
         * @return javax.swing.JList        
306
         */    
307
        private JList getDescriptionList() {
308
                if (descriptionList == null) {
309
                    listModel = new DefaultListModel();
310
                    descriptionList = new JList(listModel);
311
                }
312
                return descriptionList;
313
        }
314
        
315
        public Feature getFeature(){
316
            if (descriptionList.getSelectedIndex() == -1)
317
                return null;
318
            return (Feature) listModel.getElementAt(descriptionList.getSelectedIndex());
319
        }
320
  } //  @jve:decl-index=0:visual-constraint="107,10"