root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / gui / panels / TextFieldEdit.java @ 24962
History | View | Annotate | Download (3.84 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 | |||
8 | import javax.swing.BorderFactory; |
||
9 | import javax.swing.FocusManager; |
||
10 | import javax.swing.JComponent; |
||
11 | import javax.swing.JPopupMenu; |
||
12 | import javax.swing.JTextField; |
||
13 | |||
14 | |||
15 | /**
|
||
16 | * DOCUMENT ME!
|
||
17 | *
|
||
18 | * @author Vicente Caballero Navarro
|
||
19 | */
|
||
20 | 23383 | vcaballero | //TODO comentado para que compile
|
21 | 6117 | jaume | public class TextFieldEdit extends JPopupMenu implements KeyListener { |
22 | private JTextField txt = new JTextField(); |
||
23 | 23383 | vcaballero | // private FLyrAnnotation lyr;
|
24 | 6117 | jaume | /**
|
25 | * This is the default constructor
|
||
26 | */
|
||
27 | 23383 | vcaballero | // public TextFieldEdit(FLyrAnnotation lyr) {
|
28 | // super();
|
||
29 | // this.lyr=lyr;
|
||
30 | // initialize();
|
||
31 | // }
|
||
32 | 6117 | jaume | |
33 | /**
|
||
34 | * This method initializes this
|
||
35 | */
|
||
36 | private void initialize() { |
||
37 | this.setSize(100, 20); |
||
38 | txt.setPreferredSize(new Dimension(100, 20)); |
||
39 | 23383 | vcaballero | // txt.addActionListener(new java.awt.event.ActionListener() {
|
40 | // public void actionPerformed(java.awt.event.ActionEvent e) {
|
||
41 | // try {
|
||
42 | // VectorialEditableAdapter vea=(VectorialEditableAdapter)lyr.getSource();
|
||
43 | // int index=lyr.getInEdition();
|
||
44 | // IRowEdited row = vea.getRow(index); //.getAttribute(columnIndex);
|
||
45 | // Value[] values = row.getAttributes();
|
||
46 | // int columnText=lyr.getMapping().getColumnText();
|
||
47 | // int type=vea.getRecordset().getFieldType(columnText);
|
||
48 | // values[columnText] = ValueFactory.createValueByType(txt.getText(),type);
|
||
49 | //
|
||
50 | // IRow newRow = null;
|
||
51 | //
|
||
52 | // if (row.getLinkedRow() instanceof IFeature) {
|
||
53 | // IGeometry geometry = ((DefaultFeature) row.getLinkedRow()).getGeometry();
|
||
54 | // newRow = new DefaultFeature(geometry, values);
|
||
55 | // } else {
|
||
56 | // newRow = new DefaultRow(values);
|
||
57 | // }
|
||
58 | //
|
||
59 | //
|
||
60 | // vea.modifyRow(index, newRow,"Editar valor de texto", EditionEvent.GRAPHIC);
|
||
61 | // } catch (ReadDriverException e1) {
|
||
62 | // e1.printStackTrace();
|
||
63 | // } catch (ParseException e1) {
|
||
64 | // e1.printStackTrace();
|
||
65 | // } catch (NumberFormatException e1) {
|
||
66 | // NotificationManager.addError("no_es_de_tipo_numerico",e1);
|
||
67 | // } catch (ValidateRowException e1) {
|
||
68 | // e1.printStackTrace();
|
||
69 | // }
|
||
70 | // View view=(View)PluginServices.getMDIManager().getActiveWindow();
|
||
71 | // TextFieldEdit.this.show(false);
|
||
72 | // // view.getMapControl().drawMap(true);
|
||
73 | // lyr.setDirty(true);
|
||
74 | // view.getMapControl().rePaintDirtyLayers();
|
||
75 | //
|
||
76 | // PluginServices.getMainFrame().enableControls();
|
||
77 | // }
|
||
78 | // });
|
||
79 | 6117 | jaume | this.add(txt);
|
80 | this.setBorderPainted(false); |
||
81 | this.setBorder(BorderFactory.createEmptyBorder()); |
||
82 | } |
||
83 | |||
84 | /**
|
||
85 | * DOCUMENT ME!
|
||
86 | *
|
||
87 | * @param p DOCUMENT ME!
|
||
88 | * @param component DOCUMENT ME!
|
||
89 | */
|
||
90 | public void show(Point2D p, JComponent component) { |
||
91 | |||
92 | 23383 | vcaballero | // VectorialEditableAdapter vea=(VectorialEditableAdapter)lyr.getSource();
|
93 | // int index=lyr.getInEdition();
|
||
94 | // Value value=null;
|
||
95 | // try {
|
||
96 | // int columnText=lyr.getMapping().getColumnText();
|
||
97 | // value = vea.getRecordset().getFieldValue(index,columnText);
|
||
98 | // txt.setText(value.toString());
|
||
99 | // } catch (ReadDriverException e) {
|
||
100 | // e.printStackTrace();
|
||
101 | // }
|
||
102 | 6117 | jaume | |
103 | this.show(component, (int)p.getX(), (int)p.getY()-20); |
||
104 | FocusManager fm = FocusManager.getCurrentManager(); |
||
105 | fm.focusPreviousComponent(txt); |
||
106 | } |
||
107 | |||
108 | public void keyPressed(KeyEvent arg0) { |
||
109 | // TODO Auto-generated method stub
|
||
110 | |||
111 | } |
||
112 | |||
113 | public void keyReleased(KeyEvent arg0) { |
||
114 | FocusManager fm = FocusManager.getCurrentManager(); |
||
115 | fm.focusPreviousComponent(txt); |
||
116 | } |
||
117 | |||
118 | public void keyTyped(KeyEvent arg0) { |
||
119 | // TODO Auto-generated method stub
|
||
120 | |||
121 | } |
||
122 | |||
123 | } |