Revision 3554

View differences:

branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/TimeDimension.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1.2.4  2006-01-05 23:15:53  jaume
46
* Revision 1.1.2.5  2006-01-09 18:10:38  jaume
47
* casi con el time dimension
48
*
49
* Revision 1.1.2.4  2006/01/05 23:15:53  jaume
47 50
* *** empty log message ***
48 51
*
49 52
* Revision 1.1.2.3  2006/01/04 18:09:02  jaume
......
137 140
    public TimeDimension(String _units, String _unitSymbol, String _dimensionExpression) {
138 141
        this.unit = _units;
139 142
        this.unitSymbol = _unitSymbol;
140
        this.dimensionExpression = _dimensionExpression;
143
        setExpression(_dimensionExpression);
141 144
    }
142 145

  
143 146
    public String getName() {
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/panels/WMSParamsPanel.java
466 466
                myNode.addDimension(dim.getName(), dim.getUnit(), dim.getUnitSymbol(), dim.getExpression());
467 467
            }
468 468
            model.addLayerBranch(myNode);
469
    		model.addLayerBranch(node);
470 469
    	}
471 470
    	getDimensionTree().setModel(model);
471
        
472 472
        getDimensionTree().repaint();
473 473
    }
474 474
    /**
......
488 488
            myNode.setName(node.getName());
489 489
            myNode.setTitle(node.getTitle());
490 490

  
491
            if (node.getStyles()==null)
492
                continue;
493

  
491 494
            for (int j = 0; j < node.getStyles().size(); j++) {
492 495
                FMapWMSStyle sty = (FMapWMSStyle) node.getStyles().get(j);
493 496
                myNode.addStyle(sty.name, sty.title, sty.styleAbstract);
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/panels/StyleTree.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1.2.3  2006-01-05 23:15:53  jaume
46
* Revision 1.1.2.4  2006-01-09 18:10:38  jaume
47
* casi con el time dimension
48
*
49
* Revision 1.1.2.3  2006/01/05 23:15:53  jaume
47 50
* *** empty log message ***
48 51
*
49 52
* Revision 1.1.2.2  2006/01/04 18:09:02  jaume
......
64 67

  
65 68
import java.awt.Color;
66 69
import java.awt.Component;
67
import java.util.ArrayList;
68 70
import java.util.Hashtable;
69 71
import java.util.Iterator;
70 72
import java.util.Vector;
......
89 91
 * bi-dimensional string array containing the layer name and the selected style name.
90 92
 * </p>
91 93
 * <p>
92
 * Keep in mind that although is similar to LayersTree it is not the same.
94
 * Keep in mind that although it's similar to LayersTree it is not the same.
93 95
 * It does not use the same instances of the WMSLayerNode that LayerTreeModel
94 96
 * because it allows to repeat layers. So, each layer is a completely new 
95
 * WMSLayerNode containing same properties but no same parent (which is always
97
 * WMSLayerNode containing same properties but not the same parent (which is always
96 98
 * the tree root) and each style is a completely new FMapStyle containing same
97 99
 * properties but its parent is one of the layers of the StylesTree and not one
98 100
 * of those of the Layers tree.
99 101
 * </p>
100 102
 * 
101
 * @author jaume
103
 * @author jaume dominguez faus
102 104
 *
103 105
 */
104 106
public class StyleTree extends JTree {
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/panels/DimensionTree.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1.2.3  2006-01-05 23:15:53  jaume
46
* Revision 1.1.2.4  2006-01-09 18:10:38  jaume
47
* casi con el time dimension
48
*
49
* Revision 1.1.2.3  2006/01/05 23:15:53  jaume
47 50
* *** empty log message ***
48 51
*
49 52
* Revision 1.1.2.2  2006/01/04 18:09:02  jaume
......
63 66
import java.awt.event.ActionEvent;
64 67
import java.awt.event.ActionListener;
65 68
import java.util.EventObject;
69
import java.util.Hashtable;
66 70

  
67 71
import javax.swing.JButton;
68 72
import javax.swing.JLabel;
......
79 83
import com.iver.cit.gvsig.fmap.layers.IFMapWMSDimension;
80 84
import com.iver.cit.gvsig.fmap.layers.TimeDimension;
81 85
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode;
86
import com.iver.cit.gvsig.gui.beans.BeanListener;
87
import com.iver.cit.gvsig.gui.beans.panels.EditionPanel;
82 88
/**
83 89
 * @author jaume
84 90
 *
85 91
 */
86 92
public class DimensionTree extends JTree {
87 93
	private int rowHeight = 28;
94
    private EditionPanel ep = null;
95
    private IFMapWMSDimension current = null;
96
    
88 97
    public DimensionTree(){
89 98
        super();
90 99
        initialize();
......
94 103
        setToggleClickCount(1);
95 104
        setRowHeight(rowHeight);
96 105
        setCellRenderer(new DimensionTreeCellRenderer());
97
        setCellEditor(new DimensionTreeCellEditor());
106
        ep = new EditionPanel();
107
        ep.addListener(new BeanListener(){
108

  
109
            public void beanValueChanged(Object value) {
110
                Object[] obj = (Object[]) value;
111
                Integer min = (Integer) obj[0];
112
                Integer max = (Integer) obj[1];
113
                String expression = (String) obj[2];
114
                
115
                DimensionTreeModel model = (DimensionTreeModel) getModel();
116
                model.setMin(current, min);
117
                model.setMax(current, max);
118
                model.setExpr(current, expression);
119
            }
120
            
121
        });
122
        
123
        addMouseListener(new java.awt.event.MouseAdapter() { 
124
            public void mouseClicked(java.awt.event.MouseEvent e) {
125
                TreePath tp = getSelectionPath();
126
                if (tp == null)
127
                    return;
128
                Object[] objects = tp.getPath();
129
                if (!(objects[objects.length-1] instanceof IFMapWMSDimension))
130
                    return;
131
                current = (IFMapWMSDimension) objects[objects.length-1];
132
                
133
                // Build the edition panel.
134
                DimensionTreeModel model = (DimensionTreeModel) getModel();
135
                ep.setProperties(current, model.getMin(current), model.getMax(current));
136
                PluginServices.getMDIManager().addView(ep);
137
            }
138
        });
98 139
    }
99 140
    
100 141
    private class DimensionTreeCellRenderer implements TreeCellRenderer {
......
118 159
    	}
119 160
    }
120 161
    
121
    private class DimensionTreeCellEditor implements TreeCellEditor {
122
    	IFMapWMSDimension dim;
123
    	public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
124
    		if (!leaf){
125
    			JTree t = new JTree();
126
    			Component branchComponent = t.getCellEditor().getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row); 
127
    			return branchComponent;
128
    		} else {
129
    			JPanel leafComponent = new JPanel();
130
    			leafComponent.setBackground(Color.WHITE);
131
    			JButton btn = new JButton();
132
    			btn.setBounds(0, 0, 40, rowHeight);
133
    			btn.setText(PluginServices.getText(this, "edit"));
134
    			dim = (IFMapWMSDimension) value;
135
    			btn.addActionListener(new ActionListener(){
136
    				public void actionPerformed(ActionEvent e) {
137
    					System.out.println("aaaa"+dim.getExpression());
138
    					
139
    				}
140
    			});
141
    			leafComponent.add(btn);
142
    			JLabel lbl =new JLabel(((TimeDimension) value).getName());
143
    			leafComponent.add(lbl);
144
    			return leafComponent;
145
    		}
146
    	}
147
    	
148
		public void cancelCellEditing() {
149
			// TODO Auto-generated method stub
150
			
151
		}
152

  
153
		public boolean stopCellEditing() {
154
			// TODO Auto-generated method stub
155
			return false;
156
		}
157

  
158
		public Object getCellEditorValue() {
159
			// TODO Auto-generated method stub
160
			return null;
161
		}
162

  
163
		public boolean isCellEditable(EventObject anEvent) {
164
			// TODO Auto-generated method stub
165
			return false;
166
		}
167

  
168
		public boolean shouldSelectCell(EventObject anEvent) {
169
			// TODO Auto-generated method stub
170
			return false;
171
		}
172

  
173
		public void addCellEditorListener(CellEditorListener l) {
174
			// TODO Auto-generated method stub
175
			
176
		}
177

  
178
		public void removeCellEditorListener(CellEditorListener l) {
179
			// TODO Auto-generated method stub
180
			
181
		}
182
    	
183
    }
184 162
}
185 163

  
186 164
class DimensionTreeModel implements TreeModel {
187
    
165
    Hashtable lowLimits   = new Hashtable();
166
    Hashtable highLimits  = new Hashtable();
167
    Hashtable expressions = new Hashtable();
188 168

  
189 169
	WMSLayerNode root;
190 170

  
191 171
	public DimensionTreeModel(WMSLayerNode root){
192 172
        this.root = root;
173
/**
174
     * @param currentDimensionNode
175
     * @param min
176
     */
177
          
193 178
        
194 179
    }
180
    /**
181
     * @param currentDimensionNode
182
     * @param min
183
     */
184
    public void setMin(IFMapWMSDimension currentDimensionNode, Integer val) {
185
        lowLimits.put(currentDimensionNode, val);
186
    }
187
    /**
188
     * @param currentDimensionNode
189
     * @param min
190
     */
191
    public void setMax(IFMapWMSDimension currentDimensionNode, Integer val) {
192
        highLimits.put(currentDimensionNode, val);
193
    }
194
    /**
195
     * @param currentDimensionNode
196
     * @param min
197
     */
198
    public void setExpr(IFMapWMSDimension currentDimensionNode, String val) {
199
        expressions.put(currentDimensionNode, val);
200
    }
201
    
195 202
    public Object getRoot() {
196 203
        return root;
197 204
    }
......
260 267
        myNode.setParent((WMSLayerNode) getRoot());
261 268
        ((WMSLayerNode)getRoot()).getChildren().add(myNode);
262 269
    }
270
    
271
    public Integer getMin(IFMapWMSDimension dim){
272
        Integer min = (Integer) lowLimits.get(dim);
273
        if (min == null)
274
            min = new Integer(1);
275
        return min;
276
    }
277
    
278
    public Integer getMax(IFMapWMSDimension dim){
279
        Integer max = (Integer) highLimits.get(dim);
280
        if (max == null)
281
            max = new Integer(dim.valueCount());
282
       
283
        return max;
284
    }
263 285
}
264 286

  
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/beans/SamplePanel.java
43 43
 *
44 44
 * $Id$
45 45
 * $Log$
46
 * Revision 1.1.2.2  2006-01-02 18:08:01  jaume
46
 * Revision 1.1.2.3  2006-01-09 18:10:38  jaume
47
 * casi con el time dimension
48
 *
49
 * Revision 1.1.2.2  2006/01/02 18:08:01  jaume
47 50
 * Tree de estilos
48 51
 *
49 52
 * Revision 1.1.2.1  2005/12/30 08:56:19  jaume
......
95 98

  
96 99
    private ItemBrowser getItemBrowser(){
97 100
        if (itemBrowser == null){
98
            itemBrowser = new ItemBrowser(1, 20);
101
            itemBrowser = new ItemBrowser();
99 102
            itemBrowser.addListener(new BeanListener() {
100 103
                public void beanValueChanged(Object value) {
101 104
                    System.err.println("Captured value: "+value);
102 105
                }
103 106
            });
104
            itemBrowser.setItemCount(20);
107
            itemBrowser.setItemCount(359);
105 108
        }
106 109
        return itemBrowser;
107 110
    }
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/beans/panels/ItemBrowser.java
43 43
 *
44 44
 * $Id$
45 45
 * $Log$
46
 * Revision 1.1.2.2  2006-01-02 18:08:01  jaume
46
 * Revision 1.1.2.3  2006-01-09 18:10:38  jaume
47
 * casi con el time dimension
48
 *
49
 * Revision 1.1.2.2  2006/01/02 18:08:01  jaume
47 50
 * Tree de estilos
48 51
 *
49 52
 * Revision 1.1.2.1  2005/12/30 08:56:19  jaume
......
60 63
import java.awt.event.ActionListener;
61 64

  
62 65
import javax.swing.JButton;
63
import javax.swing.JFrame;
64 66
import javax.swing.JPanel;
65 67
import javax.swing.JSlider;
66 68
import javax.swing.JTextField;
......
88 90
    private int itemCount;
89 91
    private int lowLimit;
90 92
    private int currentValue;
93
    private boolean editing = true;
91 94
    /**
92 95
     * This is the default constructor. Creates a new instance of ItemBrowser with
93 96
     * zero items.
......
113 116
     * @return void
114 117
     */
115 118
    private void initialize(int lowIndex, int itemCount) {
116
        this.itemCount = itemCount;
119
        setItemCount(itemCount);
117 120
        this.lowLimit = lowIndex;
118 121
        this.currentValue = lowLimit;
119 122
        this.setLayout(null);
120
        this.setSize(279, 63);
123
        this.setSize(190, 50);
121 124
        this.add(getSliderPanel(), null);
122 125
        this.add(getButtonsPanel(), null);
123 126
    }
......
133 136
    		buttonsPanel.setLayout(null);
134 137
    		buttonsPanel.setName("buttonsPanel");
135 138
    		buttonsPanel.setPreferredSize(new java.awt.Dimension(173,50));
136
    		buttonsPanel.setBounds(0, 35, 278, 28);
139
    		buttonsPanel.setBounds(5, 25, 180, 25);
137 140
    		buttonsPanel.add(getBtnFastBackward(), null);
138 141
    		buttonsPanel.add(getBtnBackward(), null);
139 142
    		buttonsPanel.add(getTxtItemCountDisplay(), null);
......
151 154
    private JButton getBtnFastBackward() {
152 155
    	if (btnFastBackward == null) {
153 156
    		btnFastBackward = new JButton();
154
    		btnFastBackward.setBounds(53, 0, 20, 24);
157
    		btnFastBackward.setBounds(2, 1, 20, 24);
155 158
            btnFastBackward.setEnabled(itemCount!=0);
156 159
            btnFastBackward.addActionListener(new ActionListener() {
157 160
                public void actionPerformed(ActionEvent e) {
158 161
                    if (currentValue != lowLimit){
159
                        setValue(lowLimit);
162
                        setValue(lowLimit, true);
160 163
                    }
161 164
                }});
162 165
    	}
......
171 174
    private JButton getBtnBackward() {
172 175
    	if (btnBackward == null) {
173 176
    		btnBackward = new JButton();
174
    		btnBackward.setBounds(73, 0, 20, 24);
177
    		btnBackward.setBounds(21, 1, 20, 24);
175 178
            btnBackward.setEnabled(itemCount!=0);
176 179
            btnBackward.addActionListener(new ActionListener() {
177 180
                public void actionPerformed(ActionEvent e) {
178 181
                    if (currentValue > lowLimit ){
179
                        setValue(currentValue-1);
182
                        setValue(currentValue-1, true);
180 183
                    }
181 184
                }});
182 185
    	}
......
193 196
    		txtItemCountDisplay = new JTextField();
194 197
            txtItemCountDisplay.setEnabled(itemCount!=0);
195 198
            txtItemCountDisplay.setHorizontalAlignment(javax.swing.JTextField.CENTER);
196
    		txtItemCountDisplay.setBounds(93, 0, 94, 23);
199
    		txtItemCountDisplay.setBounds(43, 2, 94, 23);
197 200
            txtItemCountDisplay.setText(lowLimit+" / "+itemCount);
198 201
            txtItemCountDisplay.addMouseListener(new java.awt.event.MouseAdapter() { 
199 202
            	public void mouseClicked(java.awt.event.MouseEvent e) {    
......
207 210
                    try {
208 211
                        int v = Integer.parseInt(txtItemCountDisplay.getText());
209 212
                        v = (v>itemCount) ? itemCount : v;
210
                        setValue(v);
213
                        setValue(v, true);
211 214
                    } catch (Exception ex){
212 215
                        refreshText(currentValue);
213 216
                    }
......
222 225
     * This, sets the bean value and triggers an event that can be captured
223 226
     * by a listener.
224 227
     * @param number
228
     * @param fireEvent, if true then this method will fire the event. If false,
229
     * then the value will be changed silently.
230
     * 
225 231
     */
226
    private void setValue(int number) {
232
    public void setValue(int number, boolean fireEvent) {
227 233
        if (number < lowLimit)
228 234
            number = lowLimit;
229 235
        if (number > itemCount)
230 236
            number = itemCount;
231 237
        if (number!=currentValue){
232 238
            currentValue = number;
233
            int normalizedValue = (int) ((number / (float) itemCount)*100);
239
            int normalizedValue = (int) ((currentValue / (float) itemCount)*100);
234 240
            refreshText(currentValue);
235 241
            refreshSlider(normalizedValue);
236
            callStateChanged(new Integer(currentValue));
242
            if (fireEvent)
243
                callStateChanged(new Integer(currentValue));
237 244
        }
238 245
    }
239 246

  
......
241 248
     * @param normalizedValue
242 249
     */
243 250
    private void refreshSlider(int normalizedValue) {
244
        slider.setValue(normalizedValue);
251
        getSlider().setValue(normalizedValue);
245 252
    }
246 253

  
247 254
    /**
......
261 268
    private JButton getBtnForward() {
262 269
    	if (btnForward == null) {
263 270
    		btnForward = new JButton();
264
    		btnForward.setBounds(186, 0, 20, 24);
271
    		btnForward.setBounds(139, 1, 20, 24);
265 272
            btnForward.setEnabled(itemCount!=0);
266 273
            btnForward.addActionListener(new ActionListener() {
267 274
                public void actionPerformed(ActionEvent e) {
268 275
                    if (currentValue < itemCount){
269
                        setValue(currentValue+1);
276
                        setValue(currentValue+1, true);
270 277
                    }
271 278
                }});
272 279
    	}
......
281 288
    private JButton getBtnFastForward() {
282 289
    	if (btnFastForward == null) {
283 290
    		btnFastForward = new JButton();
284
    		btnFastForward.setBounds(205, 0, 20, 24);
291
    		btnFastForward.setBounds(158, 1, 20, 24);
285 292
            btnFastForward.setEnabled(itemCount!=0);
286 293
            btnFastForward.addActionListener(new ActionListener() {
287 294
                public void actionPerformed(ActionEvent e) {
288 295
                    if (currentValue < itemCount){
289
                        setValue(itemCount);
296
                        setValue(itemCount, true);
290 297
                    }
291 298
                }});
292 299
    	}
......
301 308
    private JPanel getSliderPanel() {
302 309
    	if (sliderPanel == null) {
303 310
    		sliderPanel = new JPanel();
311
            sliderPanel.setLayout(null);
304 312
    		sliderPanel.setName("sliderPanel");
305
    		sliderPanel.setBounds(0, 0, 278, 34);
306
    		sliderPanel.add(getSlider(), null);
313
    		sliderPanel.setBounds(5, 0, 181, 26);
307 314
            sliderPanel.setEnabled(false);
315
            sliderPanel.add(getSlider(), null);
308 316
    	}
309 317
    	return sliderPanel;
310 318
    }
......
318 326
    	if (slider == null) {
319 327
    		slider = new JSlider();
320 328
            slider.setValue(0);
329
            slider.setSize(180, 24);
330
            slider.setLocation(0, 1);
321 331
            slider.setEnabled(itemCount!=0);
332
            slider.addMouseListener(new java.awt.event.MouseAdapter() { 
333
                public void mousePressed(java.awt.event.MouseEvent e) {
334
                    editing = false;
335
                }
336
            	public void mouseReleased(java.awt.event.MouseEvent e) {    
337
            	    editing = true;
338
            	}
339
            });
322 340
    		slider.addChangeListener(new javax.swing.event.ChangeListener() { 
323 341
    			public void stateChanged(javax.swing.event.ChangeEvent e) {
324
                    float factor = ((float) slider.getValue() / 100);
325
                    int value = (int) (factor * itemCount);
326
                    setValue(value);
327
    			}
342
                    int value = (int) (getSlider().getValue() * itemCount * 0.01);
343
                    
344
                    if (editing && value!=currentValue){
345
                        setValue(value, false);
346
                    }
347
                    refreshText(value);
348
                    
349
                    callStateChanged(new Integer(value));
350
                }
328 351
    		});
329 352
    	}
330 353
    	return slider;
......
333 356
    
334 357
    public void setItemCount(int count){
335 358
        itemCount = count;
336
        getSliderPanel().setEnabled(count != 0);
359
        getSlider().setEnabled(count != 0);
337 360
        getBtnFastBackward().setEnabled(count != 0);
338 361
        getBtnBackward().setEnabled(count != 0);
339 362
        getTxtItemCountDisplay().setEnabled(count != 0);
340 363
        getBtnForward().setEnabled(count != 0);
341 364
        getBtnFastForward().setEnabled(count != 0);
342 365
    }
343
    
344
    public static void main(String[] args){
345
        JFrame frame = new JFrame();
346
        frame.getContentPane().add(new ItemBrowser(1, 20));
347
        frame.setBounds(0, 0, 279, 63);
348
        
349
        frame.pack();
350
        frame.show();
351
    }
352
}  
366
}  //  @jve:decl-index=0:visual-constraint="10,15"
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/beans/panels/EditionPanel.java
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$
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"
0 295

  

Also available in: Unified diff