Statistics
| Revision:

root / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / gui / Panels / TableControlerPanel.java @ 3064

History | View | Annotate | Download (7.79 KB)

1
package com.iver.cit.gvsig.gui.Panels;
2

    
3
import java.awt.FlowLayout;
4

    
5
import javax.swing.ImageIcon;
6
import javax.swing.JButton;
7
import javax.swing.JComboBox;
8
import javax.swing.JLabel;
9
import javax.swing.JPanel;
10
import javax.swing.JTextField;
11

    
12
import com.iver.andami.PluginServices;
13
import com.iver.cit.gvsig.fmap.layers.FLyrPoints;
14

    
15
/**
16
 * Control para el manejo de tablas. No contiene eventos, estos deben 
17
 * ser manejados desde la clase que lo llame.
18
 * 
19
 * @author Nacho Brodin (brodin_ign@gva.es)
20
 *
21
 */
22
public class TableControlerPanel extends JPanel{
23
        
24
        private JButton bPrev = null;
25
        private JComboBox cPoint = null;
26
        private JButton bNext = null;
27
        private JButton bFirst = null;
28
        private JButton bLast = null;
29
        private JPanel pTableControl = null;
30
        private JLabel lPoints = null;
31
        private JLabel lNumberOfPoints = null;
32
        private JButton bNew = null;
33
        private JButton bDelPoint = null;
34
        private JButton bClear = null;
35
        
36
        /**
37
         * This is the default constructor
38
         */
39
        public TableControlerPanel() {
40
                super();
41
                initialize();
42
        }
43

    
44
        /**
45
         * This method initializes this
46
         * 
47
         * @return void
48
         */
49
        private void initialize() {                
50
                this.setPreferredSize(new java.awt.Dimension(290,22));
51
                FlowLayout flowLayout5 = new FlowLayout();
52
                flowLayout5.setHgap(0);
53
                flowLayout5.setVgap(0);
54
        
55
                this.setLayout(flowLayout5);
56
                
57
                lPoints = new JLabel();
58
                lPoints.setText(PluginServices.getText(this, "puntos"));
59
                this.add(lPoints, null);
60
                
61
                this.add(getBFirst(), null);
62
                this.add(getBPrev(), null);
63
                this.add(getCPoint(), null);
64
                this.add(getBNext(), null);
65
                this.add(getBLast(), null);
66
                this.add(getBNew(), null);
67
                this.add(getLNumberOfPoints(), null);
68
                this.add(getBDelPoint(), null);
69
                this.add(getBClear(), null);
70
        }
71
        
72
        
73
        /**
74
         * This method initializes jButton        
75
         *         
76
         * @return javax.swing.JButton        
77
         */    
78
        public JButton getBFirst() {
79
                if (bFirst == null) {
80
                        bFirst = new JButton();
81
                        bFirst.setPreferredSize(new java.awt.Dimension(22,22));
82
                        bFirst.setEnabled(false);
83
                        bFirst.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/first.png")));
84
                        bFirst.setToolTipText(PluginServices.getText(this, "primero"));
85
                }
86
                return bFirst;
87
        }
88
        
89
        /**
90
         * This method initializes jButton        
91
         *         
92
         * @return javax.swing.JButton        
93
         */    
94
        public JButton getBLast() {
95
                if (bLast == null) {
96
                        bLast = new JButton();
97
                        bLast.setPreferredSize(new java.awt.Dimension(22,22));
98
                        bLast.setEnabled(false);
99
                        bLast.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/last.png")));
100
                        bLast.setToolTipText(PluginServices.getText(this, "ultimo"));
101
                }
102
                return bLast;
103
        }
104
        
105
        /**
106
         * This method initializes bBefore        
107
         *         
108
         * @return javax.swing.JButton        
109
         */
110
        public JButton getBPrev() {
111
                if (bPrev == null) {
112
                        bPrev = new JButton();
113
                        bPrev.setText("");
114
                        bPrev.setEnabled(false);
115
                        bPrev.setPreferredSize(new java.awt.Dimension(22,22));
116
                        bPrev.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/prev.png")));
117
                        bPrev.setActionCommand("");
118
                        bPrev.setToolTipText(PluginServices.getText(this, "anterior"));
119
                }
120
                return bPrev;
121
        }
122

    
123
        /**
124
         * This method initializes bNext        
125
         *         
126
         * @return javax.swing.JButton        
127
         */
128
        public JButton getBNext() {
129
                if (bNext == null) {
130
                        bNext = new JButton();
131
                        bNext.setText("");
132
                        bNext.setEnabled(false);
133
                        bNext.setPreferredSize(new java.awt.Dimension(22,22));
134
                        bNext.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/next.png")));
135
                        bNext.setActionCommand("");
136
                        bNext.setToolTipText(PluginServices.getText(this, "siguiente"));
137
                }
138
                return bNext;
139
        }
140
        
141
        /**
142
         * Este m?todo inicializa el combo que contiene el n?mero de puntos.        
143
         *         
144
         * @return javax.swing.JComboBox        
145
         */
146
        public JComboBox getCPoint() {
147
                if (cPoint == null) {
148
                        cPoint = new JComboBox();
149
                        cPoint.setPreferredSize(new java.awt.Dimension(50,22));
150
                        
151
                }
152
                return cPoint;
153
        }
154

    
155
        /**
156
         * @return Returns the lNumberOfPoints.
157
         */
158
        public JLabel getLNumberOfPoints() {
159
                if(lNumberOfPoints == null){
160
                        lNumberOfPoints = new JLabel();
161
                        lNumberOfPoints.setText(PluginServices.getText(this, "de 0"));
162
                        lNumberOfPoints.setPreferredSize(new java.awt.Dimension(40,15));
163
                }
164
                return lNumberOfPoints;
165
        }
166
        
167
        /**
168
         * This method initializes jButton        
169
         *         
170
         * @return javax.swing.JButton        
171
         */    
172
        public JButton getBNew() {
173
                if (bNew == null) {
174
                        bNew = new JButton();
175
                        bNew.setPreferredSize(new java.awt.Dimension(22,22));
176
                        bNew.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/newpoint.png")));
177
                        bNew.setToolTipText(PluginServices.getText(this, "nuevo"));
178
                }
179
                return bNew;
180
        }
181
        
182
        /**
183
         * Este m?todo inicializa el bot?n del eliminar punto que har? que se elimine
184
         * el punto seleccionado.        
185
         *         
186
         * @return javax.swing.JButton        
187
         */
188
        public JButton getBDelPoint() {
189
                if (bDelPoint == null) {
190
                        bDelPoint = new JButton();
191
                        bDelPoint.setText("");
192
                        bDelPoint.setEnabled(false);
193
                        bDelPoint.setPreferredSize(new java.awt.Dimension(22,22));
194
                        bDelPoint.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/delone.png")));
195
                }
196
                return bDelPoint;
197
        }
198
        
199
        /**
200
         * Este m?todo inicializa el bot?n del clear que har? que se eliminen todos los
201
         * puntos seleccionados.        
202
         *         
203
         * @return javax.swing.JButton        
204
         */
205
        public JButton getBClear() {
206
                if (bClear == null) {
207
                        bClear = new JButton();
208
                        bClear.setText("");
209
                        bClear.setPreferredSize(new java.awt.Dimension(22,22));
210
                        bClear.setEnabled(false);
211
                        bClear.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/delall.png")));
212
                        bClear.setActionCommand("");
213
                }
214
                return bClear;
215
        }
216
        
217
        /**
218
         * Resetea el control al estado inicial. Limpia el combo, pone
219
         * el n?mero de elementos a 0 y desactiva las flechas.
220
         *
221
         */
222
        public void resetControls(){
223
                getCPoint().removeAllItems();
224
                getLNumberOfPoints().setText(PluginServices.getText(this, "de 0"));
225
                checkArrows();
226
        }
227
        
228
        /**
229
         * Elimina del control un elemento de una posici?n.
230
         * <UL>
231
         * <LI>Actualiza el combo</LI>
232
         * <LI>Actualiza el texto que dice el n?mero de elementos</LI>
233
         * <LI>Actualiza las flechas</LI>
234
         * </UL>
235
         * @param pos Posici?n del elemento a eliminar.
236
         */
237
        public void setNItems(int n){
238
                if(n < 1)
239
                        return;
240
                getCPoint().removeAllItems();
241
                for(int i=1;i<=n;i++){
242
                        getCPoint().addItem(String.valueOf(i));
243
                }
244
                getLNumberOfPoints().setText(PluginServices.getText(this, "de ") + " " + n);
245
                checkArrows();
246
        }
247
        
248
        /**
249
         * Selecciona un elemento del control
250
         * @param index
251
         */
252
        public void setSelectedIndex(int index){
253
                getCPoint().setSelectedIndex(index);
254
                checkArrows();
255
        }
256
        
257
        /**
258
         * Devuelve el punto seleccionado
259
         * @return Punto seleccionado.
260
         */
261
        public int getSelectedIndex(){
262
                return getCPoint().getSelectedIndex();
263
        }
264
        
265
        /**
266
         * Obtiene el n?mero de elementos en la lista.
267
         * @return N?mero de elementos
268
         */
269
        public int getItemCount(){
270
                return getCPoint().getItemCount();
271
        }
272
        
273
        /**
274
         * Obtiene el Objeto seleccionado como cadena de texto.
275
         * @return N?mero seleccionado
276
         */
277
        public String getSelectedItem(){
278
                return getCPoint().getSelectedItem().toString();
279
        }
280
        
281
        /**
282
         * Comprueba la posici?n del combo para ver si tiene que
283
         * habilitar o deshabilitar las flechas de delante y detr?s.
284
         */
285
        public void checkArrows(){
286
                if(getCPoint().getSelectedIndex() == -1){
287
                        getBPrev().setEnabled(false);
288
                        getBNext().setEnabled(false);
289
                        getBLast().setEnabled(false);
290
                        getBFirst().setEnabled(false);
291
                        return;
292
                }
293
                if(getCPoint().getSelectedIndex() == 0){
294
                        getBPrev().setEnabled(false);
295
                        getBFirst().setEnabled(false);
296
                }else{
297
                        getBPrev().setEnabled(true);
298
                        getBFirst().setEnabled(true);
299
                }
300
                
301
                if(getCPoint().getSelectedIndex() == (getCPoint().getItemCount() - 1) ){
302
                        getBNext().setEnabled(false);
303
                        getBLast().setEnabled(false);
304
                }else{
305
                        getBNext().setEnabled(true);
306
                        getBLast().setEnabled(true);
307
                }
308
        }
309
 }