Revision 4258

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toolListeners/PointSelectListener.java
101 101
                    FLyrAnnotation lyrAnnotation = (FLyrAnnotation) actives[i];
102 102

  
103 103
                    	lyrAnnotation.setSelectedEditing();
104

  
104
                    	lyrAnnotation.setInEdition(lyrAnnotation.getRecordset().getSelection().nextSetBit(0));
105 105
                    	FLabel fl=lyrAnnotation.getLabel(lyrAnnotation.getInEdition());
106 106
        				if (fl!=null){
107
        					lyrAnnotation.setInEdition(lyrAnnotation.getRecordset().getSelection().nextSetBit(0));
107

  
108 108
        					View vista=(View)PluginServices.getMDIManager().getActiveView();
109 109
        					TextFieldEdit tfe=new TextFieldEdit(lyrAnnotation);
110
        					tfe.show((Point)event.getPoint(),vista);
110
        					tfe.show((Point)event.getPoint(),vista.getMapControl());
111 111

  
112 112
        			/*		JPopupMenu popup=new JPopupMenu();
113 113

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Panels/MappingFieldsToAnotation.java
11 11
import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation;
12 12
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
13 13

  
14
import javax.swing.ButtonGroup;
14 15
import javax.swing.JComboBox;
15 16
import javax.swing.JLabel;
16 17
import javax.swing.JButton;
17 18
import javax.swing.JTextField;
18 19
import javax.swing.JCheckBox;
20
import javax.swing.JRadioButton;
19 21

  
20 22
public class MappingFieldsToAnotation extends JPanel implements View{
21 23

  
......
41 43
	private JPanel jPanel = null;
42 44
	private JLabel jLabel5 = null;
43 45
	private JTextField txtName = null;
44
	private JCheckBox chbPixels = null;
46
	//private JCheckBox chbPixels = null;
47
	private JRadioButton rbMapUnits = null;
48
	private JRadioButton rbPixels = null;
45 49
	/**
46 50
	 * This is the default constructor
47 51
	 */
......
114 118
					num++;
115 119
					mapText[i]=num;
116 120
				}
117
				cmbText.addItem("");
121
				//cmbText.addItem("- Defaulf -");
118 122
			} catch (DriverException e) {
119 123
				e.printStackTrace();
120 124
			}
......
142 146
					mapAngle[i]=num;
143 147
				}
144 148
			}
145
			cmbAngle.addItem("");
149
			cmbAngle.addItem("- Default -");
150
			cmbAngle.setSelectedItem("- Default -");
146 151
			} catch (DriverException e) {
147 152
				e.printStackTrace();
148 153
			}
......
164 169
				mapColor=new int[sds.getFieldCount()];
165 170
				int num=-1;
166 171
				for (int i = 0; i < sds.getFieldCount(); i++) {
167
					if (sds.getFieldType(i) == Types.VARCHAR){
172
					if (sds.getFieldType(i) == Types.DOUBLE){
168 173
						cmbColor.addItem(sds.getFieldName(i));
169 174
						num++;
170 175
						mapColor[i]=num;
171 176
					}
172 177
				}
173
				cmbColor.addItem("");
178
				cmbColor.addItem("- Default -");
179
				cmbColor.setSelectedItem("- Default -");
174 180
			} catch (DriverException e) {
175 181
				e.printStackTrace();
176 182
			}
......
196 202
						mapHeight[i]=num;
197 203
					}
198 204
				}
199
				cmbColor.addItem("");
205
				cmbHeight.addItem("- Default -");
206
				cmbHeight.setSelectedItem("- Default -");
200 207
			} catch (DriverException e) {
201 208
				e.printStackTrace();
202 209
			}
......
223 230
						mapFont[i]=num;
224 231
					}
225 232
				}
226
				cmbFont.addItem("");
233
				cmbFont.addItem("- Default -");
234
				cmbFont.setSelectedItem("- Default -");
227 235
			} catch (DriverException e) {
228 236
				e.printStackTrace();
229 237
			}
......
249 257
						mapping[0] = -1;
250 258
					else
251 259
						mapping[0] = mapText[getCmbText().getSelectedIndex()];
252
					if (getCmbAngle().getSelectedItem().equals(""))
260
					if (getCmbAngle().getSelectedItem().equals("- Default -"))
253 261
						mapping[1] = -1;
254 262
					else
255 263
						mapping[1] = mapAngle[getCmbAngle().getSelectedIndex()];
256
					if (getCmbColor().getSelectedItem().equals(""))
264
					if (getCmbColor().getSelectedItem().equals("- Default -"))
257 265
						mapping[2] = -1;
258 266
					else
259 267
						mapping[2] = mapColor[getCmbColor().getSelectedIndex()];
260
					if (getCmbHeight().getSelectedItem().equals(""))
268
					if (getCmbHeight().getSelectedItem().equals("- Default -"))
261 269
						mapping[3] = -1;
262 270
					else
263 271
						mapping[3] = mapHeight[getCmbHeight()
264 272
								.getSelectedIndex()];
265
					if (getCmbFont().getSelectedItem().equals(""))
273
					if (getCmbFont().getSelectedItem().equals("- Default -"))
266 274
						mapping[4] = -1;
267 275
					else
268 276
						mapping[4] = mapFont[getCmbFont().getSelectedIndex()];
269 277

  
270
					la.setInPixels(chbPixels.isSelected());
278
					la.setInPixels(rbPixels.isSelected());
271 279
					la.setMapping(mapping);
272 280
					la.setName(getTxtName().getText());
273 281
					PluginServices.getMDIManager().closeView(MappingFieldsToAnotation.this);
......
304 312
	private JPanel getJPanel() {
305 313
		if (jPanel == null) {
306 314
			jLabel5 = new JLabel();
307
			jLabel5.setBounds(new java.awt.Rectangle(13,13,228,22));
315
			jLabel5.setBounds(new java.awt.Rectangle(15,10,228,22));
308 316
			jLabel5.setText("nombre");
309 317
			jPanel = new JPanel();
310 318
			jPanel.setLayout(null);
311
			jPanel.setBounds(new java.awt.Rectangle(234,14,251,205));
319
			jPanel.setBounds(new java.awt.Rectangle(234,14,251,141));
312 320
			jPanel.add(jLabel5, null);
313 321
			jPanel.add(getTxtName(), null);
314
			jPanel.add(getChbPixels(), null);
322
			//jPanel.add(getChbPixels(), null);
323
			jPanel.add(getRbMapUnits(), null);
324
			jPanel.add(getRbPixels(), null);
325
			ButtonGroup bg=new ButtonGroup();
326
			bg.add(getRbMapUnits());
327
			bg.add(getRbPixels());
315 328
		}
316 329
		return jPanel;
317 330
	}
......
325 338
		if (txtName == null) {
326 339
			txtName = new JTextField();
327 340
			//txtName.setText(la.get.getName());
328
			txtName.setBounds(new java.awt.Rectangle(14,42,227,25));
341
			txtName.setBounds(new java.awt.Rectangle(15,42,227,22));
329 342
		}
330 343
		return txtName;
331 344
	}
......
335 348
	 *
336 349
	 * @return javax.swing.JCheckBox
337 350
	 */
338
	private JCheckBox getChbPixels() {
351
	/*private JCheckBox getChbPixels() {
339 352
		if (chbPixels == null) {
340 353
			chbPixels = new JCheckBox();
341
			chbPixels.setBounds(new java.awt.Rectangle(14,78,226,25));
354
			chbPixels.setBounds(new java.awt.Rectangle(15,138,226,25));
342 355
			chbPixels.setText("pixels");
343 356
		}
344 357
		return chbPixels;
345 358
	}
359
*/
360
	/**
361
	 * This method initializes rbMapUnits
362
	 *
363
	 * @return javax.swing.JRadioButton
364
	 */
365
	private JRadioButton getRbMapUnits() {
366
		if (rbMapUnits == null) {
367
			rbMapUnits = new JRadioButton();
368
			rbMapUnits.setBounds(new java.awt.Rectangle(15,74,167,22));
369
			rbMapUnits.setText("unidades_mapa");
370
		}
371
		return rbMapUnits;
372
	}
346 373

  
374
	/**
375
	 * This method initializes rbPixels
376
	 *
377
	 * @return javax.swing.JRadioButton
378
	 */
379
	private JRadioButton getRbPixels() {
380
		if (rbPixels == null) {
381
			rbPixels = new JRadioButton();
382
			rbPixels.setBounds(new java.awt.Rectangle(15,106,167,22));
383
			rbPixels.setText("pixels");
384
			rbPixels.setSelected(true);
385
		}
386
		return rbPixels;
387
	}
388

  
347 389
}  //  @jve:decl-index=0:visual-constraint="-150,10"
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Panels/TextFieldEdit.java
7 7
import java.awt.event.KeyEvent;
8 8
import java.awt.event.KeyListener;
9 9
import java.io.IOException;
10
import java.text.ParseException;
10 11

  
11 12
import javax.swing.BorderFactory;
12 13
import javax.swing.FocusManager;
......
19 20
import com.hardcode.gdbms.engine.instruction.SemanticException;
20 21
import com.hardcode.gdbms.engine.values.Value;
21 22
import com.hardcode.gdbms.engine.values.ValueFactory;
23
import com.iver.andami.PluginServices;
22 24
import com.iver.cit.gvsig.fmap.core.DefaultFeature;
23 25
import com.iver.cit.gvsig.fmap.core.DefaultRow;
24 26
import com.iver.cit.gvsig.fmap.core.IFeature;
......
28 30
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
29 31
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
30 32
import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation;
33
import com.iver.cit.gvsig.gui.View;
31 34

  
32 35

  
33 36
/**
......
35 38
 *
36 39
 * @author Vicente Caballero Navarro
37 40
 */
38
public class TextFieldEdit extends JPopupMenu implements KeyListener,FocusListener {
41
public class TextFieldEdit extends JPopupMenu implements KeyListener {
39 42
    private JTextField txt = new JTextField();
40 43
    private FLyrAnnotation lyr;
41 44
    /**
......
53 56
    private void initialize() {
54 57
        this.setSize(100, 20);
55 58
        txt.setPreferredSize(new Dimension(100, 20));
56
        txt.addKeyListener(this);
57
        this.addFocusListener(this);
59
        txt.addActionListener(new java.awt.event.ActionListener() {
60
        	public void actionPerformed(java.awt.event.ActionEvent e) {
61
        		 try {
62
        				VectorialEditableAdapter vea=(VectorialEditableAdapter)lyr.getSource();
63
        				int index=lyr.getInEdition();
64
        				IRowEdited row = vea.getRow(index); //.getAttribute(columnIndex);
65
        		        Value[] values = row.getAttributes();
66
        		        int type=vea.getRecordset().getFieldType(lyr.getMapping()[0]);
67
        		        values[lyr.getMapping()[0]] = ValueFactory.createValueByType(txt.getText(),type);
68

  
69
        		        IRow newRow = null;
70

  
71
        		        if (row.getLinkedRow() instanceof IFeature) {
72
        		            IGeometry geometry = ((DefaultFeature) row.getLinkedRow()).getGeometry();
73
        		            newRow = new DefaultFeature(geometry, values);
74
        		        } else {
75
        		            newRow = new DefaultRow(values);
76
        		        }
77

  
78

  
79
        					vea.modifyRow(index, newRow,"Editar valor de texto");
80
        				} catch (IOException e1) {
81
        					e1.printStackTrace();
82
        				} catch (DriverIOException e1) {
83
        					e1.printStackTrace();
84
        				} catch (DriverLoadException e1) {
85
        					e1.printStackTrace();
86
        				} catch (DriverException e1) {
87
        					e1.printStackTrace();
88
        				}  catch (ParseException e1) {
89
							e1.printStackTrace();
90
						}
91
        				View view=(View)PluginServices.getMDIManager().getActiveView();
92
        				TextFieldEdit.this.show(false);
93
        				view.getMapControl().drawMap(true);
94

  
95
        				PluginServices.getMainFrame().enableControls();
96
        	}
97
        });
58 98
        this.add(txt);
59 99
        this.setBorderPainted(false);
60 100
        this.setBorder(BorderFactory.createEmptyBorder());
......
67 107
     * @param component DOCUMENT ME!
68 108
     */
69 109
    public void show(Point p, JComponent component) {
70
        this.show(component, p.x + 100, p.y);
71

  
110
        this.show(component, p.x, p.y);
72 111
        FocusManager fm = FocusManager.getCurrentManager();
73 112
        fm.focusPreviousComponent(txt);
74 113
    }
......
79 118
	}
80 119

  
81 120
	public void keyReleased(KeyEvent arg0) {
82
		// TODO Auto-generated method stub
83

  
121
		 FocusManager fm = FocusManager.getCurrentManager();
122
	     fm.focusPreviousComponent(txt);
84 123
	}
85 124

  
86 125
	public void keyTyped(KeyEvent arg0) {
......
88 127

  
89 128
	}
90 129

  
91
	public void focusGained(FocusEvent arg0) {
92
		// TODO Auto-generated method stub
93

  
94
	}
95

  
96
	public void focusLost(FocusEvent arg0) {
97
		 try {
98
		VectorialEditableAdapter vea=(VectorialEditableAdapter)lyr.getSource();
99
		int index=lyr.getInEdition();
100
		IRowEdited row = vea.getRow(index); //.getAttribute(columnIndex);
101
        Value[] values = row.getAttributes();
102
        int type=vea.getRecordset().getFieldType(lyr.getMapping()[0]);
103
        values[lyr.getMapping()[0]] = ValueFactory.createValue(txt.getText(),type);
104

  
105
        IRow newRow = null;
106

  
107
        if (row.getLinkedRow() instanceof IFeature) {
108
            IGeometry geometry = ((DefaultFeature) row.getLinkedRow()).getGeometry();
109
            newRow = new DefaultFeature(geometry, values);
110
        } else {
111
            newRow = new DefaultRow(values);
112
        }
113

  
114

  
115
			vea.modifyRow(index, newRow,"Editar valor de texto");
116
		} catch (IOException e) {
117
			// TODO Auto-generated catch block
118
			e.printStackTrace();
119
		} catch (DriverIOException e) {
120
			// TODO Auto-generated catch block
121
			e.printStackTrace();
122
		} catch (DriverLoadException e) {
123
			// TODO Auto-generated catch block
124
			e.printStackTrace();
125
		} catch (DriverException e) {
126
			// TODO Auto-generated catch block
127
			e.printStackTrace();
128
		} catch (SemanticException e) {
129
			// TODO Auto-generated catch block
130
			e.printStackTrace();
131
		}
132

  
133
	}
134 130
}

Also available in: Unified diff