root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / gui / panels / TextFieldEdit.java @ 23383
History | View | Annotate | Download (4.74 KB)
1 | 6117 | jaume | package com.iver.cit.gvsig.gui.panels; |
---|---|---|---|
2 | |||
3 | import java.awt.Dimension; |
||
4 | import java.awt.event.KeyEvent; |
||
5 | import java.awt.event.KeyListener; |
||
6 | import java.awt.geom.Point2D; |
||
7 | import java.text.ParseException; |
||
8 | |||
9 | import javax.swing.BorderFactory; |
||
10 | import javax.swing.FocusManager; |
||
11 | import javax.swing.JComponent; |
||
12 | import javax.swing.JPopupMenu; |
||
13 | import javax.swing.JTextField; |
||
14 | |||
15 | 23383 | vcaballero | //import org.gvsig.fmap.core.features.DefaultFeature;
|
16 | //import org.gvsig.fmap.core.features.DefaultRow;
|
||
17 | //import org.gvsig.fmap.core.features.IFeature;
|
||
18 | //import org.gvsig.fmap.core.features.IRow;
|
||
19 | //import org.gvsig.fmap.core.features.IRowEdited;
|
||
20 | //import org.gvsig.fmap.core.geometries.IGeometry;
|
||
21 | //import org.gvsig.fmap.drivers.exceptions.ValidateRowException;
|
||
22 | //import org.gvsig.fmap.drivers.writing.EditionEvent;
|
||
23 | //import org.gvsig.fmap.drivers.writing.adapters.VectorialEditableAdapter;
|
||
24 | //import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrAnnotation;
|
||
25 | //
|
||
26 | //import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
|
||
27 | //import com.hardcode.gdbms.engine.values.Value;
|
||
28 | //import com.hardcode.gdbms.engine.values.ValueFactory;
|
||
29 | 6117 | jaume | import com.iver.andami.PluginServices; |
30 | import com.iver.andami.messages.NotificationManager; |
||
31 | 7304 | caballero | import com.iver.cit.gvsig.project.documents.view.gui.View; |
32 | 6117 | jaume | |
33 | |||
34 | /**
|
||
35 | * DOCUMENT ME!
|
||
36 | *
|
||
37 | * @author Vicente Caballero Navarro
|
||
38 | */
|
||
39 | 23383 | vcaballero | //TODO comentado para que compile
|
40 | 6117 | jaume | public class TextFieldEdit extends JPopupMenu implements KeyListener { |
41 | private JTextField txt = new JTextField(); |
||
42 | 23383 | vcaballero | // private FLyrAnnotation lyr;
|
43 | 6117 | jaume | /**
|
44 | * This is the default constructor
|
||
45 | */
|
||
46 | 23383 | vcaballero | // public TextFieldEdit(FLyrAnnotation lyr) {
|
47 | // super();
|
||
48 | // this.lyr=lyr;
|
||
49 | // initialize();
|
||
50 | // }
|
||
51 | 6117 | jaume | |
52 | /**
|
||
53 | * This method initializes this
|
||
54 | */
|
||
55 | private void initialize() { |
||
56 | this.setSize(100, 20); |
||
57 | txt.setPreferredSize(new Dimension(100, 20)); |
||
58 | 23383 | vcaballero | // txt.addActionListener(new java.awt.event.ActionListener() {
|
59 | // public void actionPerformed(java.awt.event.ActionEvent e) {
|
||
60 | // try {
|
||
61 | // VectorialEditableAdapter vea=(VectorialEditableAdapter)lyr.getSource();
|
||
62 | // int index=lyr.getInEdition();
|
||
63 | // IRowEdited row = vea.getRow(index); //.getAttribute(columnIndex);
|
||
64 | // Value[] values = row.getAttributes();
|
||
65 | // int columnText=lyr.getMapping().getColumnText();
|
||
66 | // int type=vea.getRecordset().getFieldType(columnText);
|
||
67 | // values[columnText] = 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", EditionEvent.GRAPHIC);
|
||
80 | // } catch (ReadDriverException e1) {
|
||
81 | // e1.printStackTrace();
|
||
82 | // } catch (ParseException e1) {
|
||
83 | // e1.printStackTrace();
|
||
84 | // } catch (NumberFormatException e1) {
|
||
85 | // NotificationManager.addError("no_es_de_tipo_numerico",e1);
|
||
86 | // } catch (ValidateRowException e1) {
|
||
87 | // e1.printStackTrace();
|
||
88 | // }
|
||
89 | // View view=(View)PluginServices.getMDIManager().getActiveWindow();
|
||
90 | // TextFieldEdit.this.show(false);
|
||
91 | // // view.getMapControl().drawMap(true);
|
||
92 | // lyr.setDirty(true);
|
||
93 | // view.getMapControl().rePaintDirtyLayers();
|
||
94 | //
|
||
95 | // PluginServices.getMainFrame().enableControls();
|
||
96 | // }
|
||
97 | // });
|
||
98 | 6117 | jaume | this.add(txt);
|
99 | this.setBorderPainted(false); |
||
100 | this.setBorder(BorderFactory.createEmptyBorder()); |
||
101 | } |
||
102 | |||
103 | /**
|
||
104 | * DOCUMENT ME!
|
||
105 | *
|
||
106 | * @param p DOCUMENT ME!
|
||
107 | * @param component DOCUMENT ME!
|
||
108 | */
|
||
109 | public void show(Point2D p, JComponent component) { |
||
110 | |||
111 | 23383 | vcaballero | // VectorialEditableAdapter vea=(VectorialEditableAdapter)lyr.getSource();
|
112 | // int index=lyr.getInEdition();
|
||
113 | // Value value=null;
|
||
114 | // try {
|
||
115 | // int columnText=lyr.getMapping().getColumnText();
|
||
116 | // value = vea.getRecordset().getFieldValue(index,columnText);
|
||
117 | // txt.setText(value.toString());
|
||
118 | // } catch (ReadDriverException e) {
|
||
119 | // e.printStackTrace();
|
||
120 | // }
|
||
121 | 6117 | jaume | |
122 | this.show(component, (int)p.getX(), (int)p.getY()-20); |
||
123 | FocusManager fm = FocusManager.getCurrentManager(); |
||
124 | fm.focusPreviousComponent(txt); |
||
125 | } |
||
126 | |||
127 | public void keyPressed(KeyEvent arg0) { |
||
128 | // TODO Auto-generated method stub
|
||
129 | |||
130 | } |
||
131 | |||
132 | public void keyReleased(KeyEvent arg0) { |
||
133 | FocusManager fm = FocusManager.getCurrentManager(); |
||
134 | fm.focusPreviousComponent(txt); |
||
135 | } |
||
136 | |||
137 | public void keyTyped(KeyEvent arg0) { |
||
138 | // TODO Auto-generated method stub
|
||
139 | |||
140 | } |
||
141 | |||
142 | } |