Statistics
| Revision:

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

History | View | Annotate | Download (8.25 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 3554 2006-01-09 18:10:38Z jaume $
45
* $Log$
46
* Revision 1.1.2.1  2006-01-09 18:10:38  jaume
47
* casi con el time dimension
48
*
49
*
50
*/
51
/**
52
 * 
53
 */
54
package com.iver.cit.gvsig.gui.beans.panels;
55

    
56
import java.awt.Component;
57
import java.awt.GridLayout;
58
import java.awt.event.ActionEvent;
59
import java.awt.event.ActionListener;
60

    
61
import javax.swing.JLabel;
62
import javax.swing.JPanel;
63

    
64
import com.iver.andami.PluginServices;
65
import com.iver.andami.ui.mdiFrame.JButton;
66
import com.iver.andami.ui.mdiManager.View;
67
import com.iver.andami.ui.mdiManager.ViewInfo;
68
import com.iver.cit.gvsig.fmap.layers.IFMapWMSDimension;
69
import com.iver.cit.gvsig.gui.beans.BeanListener;
70
import com.iver.cit.gvsig.gui.beans.DefaultBean;
71

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

    
114
    /**
115
     * @return
116
     */
117
    private ItemBrowser getMaxBrowser() {
118
        if (maxBrowser==null){
119
            maxBrowser = new ItemBrowser();
120
            maxBrowser.addListener(new BeanListener(){
121

    
122
                public void beanValueChanged(Object value) {
123
                    max = (Integer) value;
124
                    lblMax1.setText(dim.valueAt(max.intValue()));
125
                }
126
                
127
            });
128
        }
129
        return maxBrowser;
130
    }
131

    
132
    /**
133
     * @return
134
     */
135
    private ItemBrowser getMinBrowser() {
136
        if (minBrowser==null){
137
            minBrowser = new ItemBrowser();
138
            minBrowser.addListener(new BeanListener() {
139

    
140
                public void beanValueChanged(Object value) {
141
                    min = (Integer) value;
142
                    lblMin1.setText(dim.valueAt(min.intValue()));
143
                }
144
                
145
            });
146
        }
147
        return minBrowser;
148
    }
149

    
150
    /**
151
     * @return
152
     */
153
    private JPanel getBtnPanel() {
154
        if (btnPanel == null){
155
            btnPanel = new JPanel();
156
            GridLayout gridLayout = new GridLayout();
157
            gridLayout.setRows(1);
158
            gridLayout.setColumns(1);
159
            getBtnPanel().add(getBtnOk());
160
            getBtnPanel().add(getBtnCancel());
161
            
162
        }
163
        return btnPanel;
164
    }
165

    
166
    /**
167
     * @return
168
     */
169
    private Component getBtnOk() {
170
        if (btnOk == null){
171
            btnOk = new JButton();
172
            btnOk.setText(PluginServices.getText(this, "aceptar"));
173
            btnOk.setBounds(40, 5, 20, 60);
174
            btnOk.addActionListener(new ActionListener() {
175
                public void actionPerformed(ActionEvent e) {
176
                    execute("OK");
177
                }
178

    
179
            });
180
        }
181
        return btnOk;    }
182

    
183
    /**
184
     * @return
185
     */
186
    private JButton getBtnCancel() {
187
        if (btnCancel == null){
188
            btnCancel = new JButton();
189
            btnCancel.setText(PluginServices.getText(this, "cancelar"));
190
            btnCancel.setBounds(105, 5, 20, 60);
191
            btnCancel.addActionListener(new ActionListener() {
192
                public void actionPerformed(ActionEvent e) {
193
                    execute("Cancel");
194
                }
195
            });
196
        }
197
        return btnCancel;
198
    }
199

    
200
    public ViewInfo getViewInfo() {
201
        if (mViewInfo == null)
202
        {
203
            mViewInfo=new ViewInfo(ViewInfo.MODALDIALOG);
204
            mViewInfo.setWidth(195);
205
            mViewInfo.setHeight(255);
206
        }
207
        return mViewInfo;
208
    }
209

    
210
    public void setProperties(IFMapWMSDimension _dim, Integer _min, Integer _max){
211
        min = _min;
212
        max = _max;
213
        dim = _dim;
214
        
215
        getViewInfo().setTitle(PluginServices.getText(this, "edit")+" "+dim.getName());
216

    
217
        getMinBrowser().setItemCount(dim.valueCount());
218
        getMinBrowser().setValue(min.intValue(), false);
219

    
220
        getMaxBrowser().setItemCount(dim.valueCount());
221
        getMaxBrowser().setValue(max.intValue(), false);
222
        
223
        lblMin1.setText(dim.valueAt(min.intValue()));
224
        lblMax1.setText(dim.valueAt(max.intValue()));
225
        
226
    }
227

    
228

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

    
262
    /**
263
     * This method initializes jPanel1        
264
     *         
265
     * @return javax.swing.JPanel        
266
     */    
267
    private JPanel getMaxPanel() {
268
            if (maxPanel == null) {
269
            lblMax1 = new JLabel();
270
            
271
            lblMax1.setBounds(52, 14, 138, 15);
272
            lblMax1.setFont(new java.awt.Font("MS Sans Serif", java.awt.Font.BOLD, 11));
273
            lblMax = new JLabel();
274
            lblMax.setText(PluginServices.getText(this, "to"));
275
            lblMax.setBounds(5, 14, 41, 15);
276
            
277
                    maxPanel = new JPanel();
278
                    maxPanel.setLayout(null);
279
            maxPanel.add(lblMax1);
280
            maxPanel.add(lblMax);
281
            }
282
            return maxPanel;
283
    }
284
    
285
    private void execute(String actionCommand) {
286
        if (actionCommand.equals("OK")){
287
            System.out.println("OK pressed.");
288
        } else if (actionCommand.equals("Cancel")){
289
            PluginServices.getMDIManager().closeView(this);
290
        }
291
        
292
    }
293

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