Statistics
| Revision:

svn-gvsig-desktop / branches / gvSIG_WMSv2 / extensions / extWMS / src / com / iver / cit / gvsig / gui / panels / EditionPanel.java @ 3592

History | View | Annotate | Download (8.86 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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

    
42
/* CVS MESSAGES:
43
*
44
* $Id: EditionPanel.java 3592 2006-01-11 12:20:50Z jaume $
45
* $Log$
46
* Revision 1.1.2.2  2006-01-11 12:20:30  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.1.2.1  2006/01/10 13:11:38  jaume
50
* *** empty log message ***
51
*
52
* Revision 1.1.2.2  2006/01/10 11:33:31  jaume
53
* Time dimension working against Jet Propulsion Laboratory's WMS server
54
*
55
* Revision 1.1.2.1  2006/01/09 18:10:38  jaume
56
* casi con el time dimension
57
*
58
*
59
*/
60
/**
61
 * 
62
 */
63
package com.iver.cit.gvsig.gui.panels;
64

    
65
import java.awt.Component;
66
import java.awt.GridLayout;
67
import java.awt.event.ActionEvent;
68
import java.awt.event.ActionListener;
69

    
70
import javax.swing.JLabel;
71
import javax.swing.JPanel;
72

    
73
import com.iver.andami.PluginServices;
74
import com.iver.andami.ui.mdiFrame.JButton;
75
import com.iver.andami.ui.mdiManager.View;
76
import com.iver.andami.ui.mdiManager.ViewInfo;
77
import com.iver.cit.gvsig.fmap.layers.IFMapWMSDimension;
78
import com.iver.cit.gvsig.gui.beans.DefaultBean;
79
import com.iver.cit.gvsig.gui.beans.listeners.BeanListener;
80
import com.iver.cit.gvsig.gui.beans.Pager;
81

    
82
/**
83
 * @author jaume
84
 *
85
 */
86
public class EditionPanel extends DefaultBean implements View {
87
    private Integer min;
88
    private Integer max;
89
    private IFMapWMSDimension dim;
90
    private ViewInfo mViewInfo;
91
    private JPanel minPanel     = null;
92
    private JPanel maxPanel    = null;
93
    private JPanel btnPanel   = null;
94
    private JButton btnOk     = null;
95
    private JButton btnCancel = null;
96
    private Pager minBrowser = null;
97
    private Pager maxBrowser = null;
98
    private JLabel lblPeriod = null;
99
    private JLabel lblPeriod1 = null;
100
    private JLabel lblMin = null;
101
    private JLabel lblMin1 = null;
102
    private JLabel lblMax1;
103
    private JLabel lblMax;
104
    
105
    public EditionPanel(){
106
        super();
107
        initialize();
108
    }
109
    
110
    private void initialize() {
111
        GridLayout gridLayout = new GridLayout();
112
        gridLayout.setRows(5);
113
        gridLayout.setColumns(1);
114
        this.setSize(195, 255);
115
        this.setLayout(gridLayout);
116
        this.add(getMinPanel(), null);
117
        this.add(getMinBrowser(), null);
118
        this.add(getMaxPanel(), null);
119
        this.add(getMaxBrowser(), null);
120
        this.add(getBtnPanel(), null);
121
    }
122

    
123
    /**
124
     * @return
125
     */
126
    private Pager getMaxBrowser() {
127
        if (maxBrowser==null){
128
            maxBrowser = new Pager();
129
            maxBrowser.addListener(new BeanListener(){
130
                public void beanValueChanged(Object value) {
131
                    max = (Integer) value;
132
                    lblMax1.setText(dim.valueAt(max.intValue()));
133
                }
134
            });
135
        }
136
        return maxBrowser;
137
    }
138

    
139
    /**
140
     * @return
141
     */
142
    private Pager getMinBrowser() {
143
        if (minBrowser==null){
144
            minBrowser = new Pager();
145
            minBrowser.addListener(new BeanListener() {
146

    
147
                public void beanValueChanged(Object value) {
148
                    min = (Integer) value;
149
                    lblMin1.setText(dim.valueAt(min.intValue()));
150
                }
151
                
152
            });
153
        }
154
        return minBrowser;
155
    }
156

    
157
    /**
158
     * @return
159
     */
160
    private JPanel getBtnPanel() {
161
        if (btnPanel == null){
162
            btnPanel = new JPanel();
163
            GridLayout gridLayout = new GridLayout();
164
            gridLayout.setRows(1);
165
            gridLayout.setColumns(1);
166
            getBtnPanel().add(getBtnOk());
167
            getBtnPanel().add(getBtnCancel());
168
            
169
        }
170
        return btnPanel;
171
    }
172

    
173
    /**
174
     * @return
175
     */
176
    private Component getBtnOk() {
177
        if (btnOk == null){
178
            btnOk = new JButton();
179
            btnOk.setText(PluginServices.getText(this, "aceptar"));
180
            btnOk.setBounds(40, 5, 20, 60);
181
            btnOk.addActionListener(new ActionListener() {
182
                public void actionPerformed(ActionEvent e) {
183
                    execute("OK");
184
                }
185

    
186
            });
187
        }
188
        return btnOk;    }
189

    
190
    /**
191
     * @return
192
     */
193
    private JButton getBtnCancel() {
194
        if (btnCancel == null){
195
            btnCancel = new JButton();
196
            btnCancel.setText(PluginServices.getText(this, "cancelar"));
197
            btnCancel.setBounds(105, 5, 20, 60);
198
            btnCancel.addActionListener(new ActionListener() {
199
                public void actionPerformed(ActionEvent e) {
200
                    execute("Cancel");
201
                }
202
            });
203
        }
204
        return btnCancel;
205
    }
206

    
207
    public ViewInfo getViewInfo() {
208
        if (mViewInfo == null)
209
        {
210
            mViewInfo=new ViewInfo(ViewInfo.MODALDIALOG);
211
            mViewInfo.setWidth(195);
212
            mViewInfo.setHeight(255);
213
        }
214
        return mViewInfo;
215
    }
216

    
217
    public void setProperties(IFMapWMSDimension _dim, Integer _min, Integer _max){
218
        min = _min;
219
        max = _max;
220
        dim = _dim;
221
        
222
        getViewInfo().setTitle(PluginServices.getText(this, "edit")+" "+dim.getName());
223

    
224
        getMinBrowser().setItemCount(dim.valueCount());
225
        getMinBrowser().setValue(min.intValue(), false);
226

    
227
        getMaxBrowser().setItemCount(dim.valueCount());
228
        getMaxBrowser().setValue(max.intValue(), false);
229
        
230
        lblMin1.setText(dim.valueAt(min.intValue()));
231
        lblMax1.setText(dim.valueAt(max.intValue()));
232
        
233
    }
234

    
235

    
236
    
237
    /**
238
     * This method initializes jPanel        
239
     *         
240
     * @return javax.swing.JPanel        
241
     */    
242
    private JPanel getMinPanel() {
243
            if (minPanel == null) {
244
                    lblMin1 = new JLabel();
245
                    lblMin1.setText("");
246
                    lblMin1.setFont(new java.awt.Font("MS Sans Serif", java.awt.Font.BOLD, 11));
247
                    lblMin1.setBounds(52, 32, 138, 15);
248
                    lblMin = new JLabel();
249
                    lblMin.setText(PluginServices.getText(this, "from"));
250
                    lblMin.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
251
                    lblMin.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
252
                    lblMin.setBounds(5, 32, 41, 15);
253
                    minPanel = new JPanel();
254
                    minPanel.setLayout(null);
255
                    minPanel.add(lblMin, null);
256
                    minPanel.add(lblMin1, null);
257
            lblPeriod1 = new JLabel();
258
            lblPeriod1.setText("");
259
            lblPeriod1.setFont(new java.awt.Font("MS Sans Serif", java.awt.Font.BOLD, 11));
260
            lblPeriod1.setBounds(52, 3, 138, 15);
261
            lblPeriod = new JLabel();
262
            lblPeriod.setText(PluginServices.getText(this, "period"));
263
            lblPeriod.setBounds(5, 3, 41, 15);
264
            
265
            minPanel.add(lblPeriod, null);
266
            minPanel.add(lblPeriod1, null);
267
            }
268
            return minPanel;
269
    }
270

    
271
    /**
272
     * This method initializes jPanel1        
273
     *         
274
     * @return javax.swing.JPanel        
275
     */    
276
    private JPanel getMaxPanel() {
277
            if (maxPanel == null) {
278
            lblMax1 = new JLabel();
279
            
280
            lblMax1.setBounds(52, 14, 138, 15);
281
            lblMax1.setFont(new java.awt.Font("MS Sans Serif", java.awt.Font.BOLD, 11));
282
            lblMax = new JLabel();
283
            lblMax.setText(PluginServices.getText(this, "to"));
284
            lblMax.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
285
            lblMax.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
286
            lblMax.setBounds(5, 14, 41, 15);
287
            
288
                    maxPanel = new JPanel();
289
                    maxPanel.setLayout(null);
290
            maxPanel.add(lblMax1);
291
            maxPanel.add(lblMax);
292
            }
293
            return maxPanel;
294
    }
295
    
296
    private void execute(String actionCommand) {
297
        if (actionCommand.equals("OK")){
298
            Object[] value = new Object[3];
299
            value[0] = min;
300
            value[1] = max;
301
            value[2] = lblMin1.getText()+"/"+lblMax1.getText();
302
            callValueChanged(value);
303
        }
304
        PluginServices.getMDIManager().closeView(this);        
305
    }
306

    
307
}  //  @jve:decl-index=0:visual-constraint="10,10"