svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / panels / TextFieldEdit.java @ 40558
History | View | Annotate | Download (4.77 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.gui.panels; |
25 |
|
26 |
import java.awt.Dimension; |
27 |
import java.awt.event.KeyEvent; |
28 |
import java.awt.event.KeyListener; |
29 |
import java.awt.geom.Point2D; |
30 |
|
31 |
import javax.swing.BorderFactory; |
32 |
import javax.swing.FocusManager; |
33 |
import javax.swing.JComponent; |
34 |
import javax.swing.JPopupMenu; |
35 |
import javax.swing.JTextField; |
36 |
|
37 |
|
38 |
/**
|
39 |
* DOCUMENT ME!
|
40 |
*
|
41 |
* @author Vicente Caballero Navarro
|
42 |
*/
|
43 |
//TODO comentado para que compile
|
44 |
public class TextFieldEdit extends JPopupMenu implements KeyListener { |
45 |
private JTextField txt = new JTextField(); |
46 |
// private FLyrAnnotation lyr;
|
47 |
/**
|
48 |
* This is the default constructor
|
49 |
*/
|
50 |
// public TextFieldEdit(FLyrAnnotation lyr) {
|
51 |
// super();
|
52 |
// this.lyr=lyr;
|
53 |
// initialize();
|
54 |
// }
|
55 |
|
56 |
/**
|
57 |
* This method initializes this
|
58 |
*/
|
59 |
private void initialize() { |
60 |
this.setSize(100, 20); |
61 |
txt.setPreferredSize(new Dimension(100, 20)); |
62 |
// txt.addActionListener(new java.awt.event.ActionListener() {
|
63 |
// public void actionPerformed(java.awt.event.ActionEvent e) {
|
64 |
// try {
|
65 |
// VectorialEditableAdapter vea=(VectorialEditableAdapter)lyr.getSource();
|
66 |
// int index=lyr.getInEdition();
|
67 |
// IRowEdited row = vea.getRow(index); //.getAttribute(columnIndex);
|
68 |
// Value[] values = row.getAttributes();
|
69 |
// int columnText=lyr.getMapping().getColumnText();
|
70 |
// int type=vea.getRecordset().getFieldType(columnText);
|
71 |
// values[columnText] = ValueFactory.createValueByType(txt.getText(),type);
|
72 |
//
|
73 |
// IRow newRow = null;
|
74 |
//
|
75 |
// if (row.getLinkedRow() instanceof IFeature) {
|
76 |
// IGeometry geometry = ((DefaultFeature) row.getLinkedRow()).getGeometry();
|
77 |
// newRow = new DefaultFeature(geometry, values);
|
78 |
// } else {
|
79 |
// newRow = new DefaultRow(values);
|
80 |
// }
|
81 |
//
|
82 |
//
|
83 |
// vea.modifyRow(index, newRow,"Editar valor de texto", EditionEvent.GRAPHIC);
|
84 |
// } catch (ReadDriverException e1) {
|
85 |
// e1.printStackTrace();
|
86 |
// } catch (ParseException e1) {
|
87 |
// e1.printStackTrace();
|
88 |
// } catch (NumberFormatException e1) {
|
89 |
// NotificationManager.addError("no_es_de_tipo_numerico",e1);
|
90 |
// } catch (ValidateRowException e1) {
|
91 |
// e1.printStackTrace();
|
92 |
// }
|
93 |
// View view=(View)PluginServices.getMDIManager().getActiveWindow();
|
94 |
// TextFieldEdit.this.show(false);
|
95 |
// // view.getMapControl().drawMap(true);
|
96 |
// lyr.setDirty(true);
|
97 |
// view.getMapControl().rePaintDirtyLayers();
|
98 |
//
|
99 |
// PluginServices.getMainFrame().enableControls();
|
100 |
// }
|
101 |
// });
|
102 |
this.add(txt);
|
103 |
this.setBorderPainted(false); |
104 |
this.setBorder(BorderFactory.createEmptyBorder()); |
105 |
} |
106 |
|
107 |
/**
|
108 |
* DOCUMENT ME!
|
109 |
*
|
110 |
* @param p DOCUMENT ME!
|
111 |
* @param component DOCUMENT ME!
|
112 |
*/
|
113 |
public void show(Point2D p, JComponent component) { |
114 |
|
115 |
// VectorialEditableAdapter vea=(VectorialEditableAdapter)lyr.getSource();
|
116 |
// int index=lyr.getInEdition();
|
117 |
// Value value=null;
|
118 |
// try {
|
119 |
// int columnText=lyr.getMapping().getColumnText();
|
120 |
// value = vea.getRecordset().getFieldValue(index,columnText);
|
121 |
// txt.setText(value.toString());
|
122 |
// } catch (ReadDriverException e) {
|
123 |
// e.printStackTrace();
|
124 |
// }
|
125 |
|
126 |
this.show(component, (int)p.getX(), (int)p.getY()-20); |
127 |
FocusManager fm = FocusManager.getCurrentManager(); |
128 |
fm.focusPreviousComponent(txt); |
129 |
} |
130 |
|
131 |
public void keyPressed(KeyEvent arg0) { |
132 |
// TODO Auto-generated method stub
|
133 |
|
134 |
} |
135 |
|
136 |
public void keyReleased(KeyEvent arg0) { |
137 |
FocusManager fm = FocusManager.getCurrentManager(); |
138 |
fm.focusPreviousComponent(txt); |
139 |
} |
140 |
|
141 |
public void keyTyped(KeyEvent arg0) { |
142 |
// TODO Auto-generated method stub
|
143 |
|
144 |
} |
145 |
|
146 |
} |