svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / Table.java @ 5503
History | View | Annotate | Download (46.2 KB)
1 | 1103 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 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 | 312 | fernando | package com.iver.cit.gvsig.gui; |
42 | |||
43 | 5075 | caballero | import java.awt.Color; |
44 | 4706 | caballero | import java.awt.Component; |
45 | 5075 | caballero | import java.awt.event.KeyAdapter; |
46 | import java.awt.event.KeyEvent; |
||
47 | import java.awt.event.KeyListener; |
||
48 | 4706 | caballero | import java.awt.event.MouseAdapter; |
49 | import java.awt.event.MouseEvent; |
||
50 | import java.beans.PropertyChangeEvent; |
||
51 | import java.beans.PropertyChangeListener; |
||
52 | import java.io.File; |
||
53 | import java.io.IOException; |
||
54 | import java.text.ParseException; |
||
55 | import java.util.BitSet; |
||
56 | import java.util.Enumeration; |
||
57 | import java.util.EventListener; |
||
58 | 5075 | caballero | import java.util.EventObject; |
59 | 4706 | caballero | |
60 | 5254 | caballero | import javax.swing.BorderFactory; |
61 | 5075 | caballero | import javax.swing.DefaultCellEditor; |
62 | 4706 | caballero | import javax.swing.DefaultListSelectionModel; |
63 | 5075 | caballero | import javax.swing.JComponent; |
64 | 4706 | caballero | import javax.swing.JFileChooser; |
65 | 5075 | caballero | import javax.swing.JFrame; |
66 | 4706 | caballero | import javax.swing.JLabel; |
67 | import javax.swing.JOptionPane; |
||
68 | import javax.swing.JPanel; |
||
69 | 5075 | caballero | import javax.swing.JTextField; |
70 | 4706 | caballero | import javax.swing.ListSelectionModel; |
71 | 5254 | caballero | import javax.swing.UIManager; |
72 | import javax.swing.border.Border; |
||
73 | 4706 | caballero | import javax.swing.event.ListSelectionEvent; |
74 | import javax.swing.event.ListSelectionListener; |
||
75 | import javax.swing.event.TableColumnModelEvent; |
||
76 | import javax.swing.event.TableColumnModelListener; |
||
77 | import javax.swing.table.AbstractTableModel; |
||
78 | import javax.swing.table.DefaultTableColumnModel; |
||
79 | 5254 | caballero | import javax.swing.table.TableCellRenderer; |
80 | 4706 | caballero | import javax.swing.table.TableColumn; |
81 | |||
82 | import org.apache.log4j.Logger; |
||
83 | |||
84 | 4060 | caballero | import com.hardcode.driverManager.DriverLoadException; |
85 | 1830 | fernando | import com.hardcode.gdbms.engine.data.driver.DriverException; |
86 | 2481 | fernando | import com.hardcode.gdbms.engine.values.Value; |
87 | 464 | fernando | import com.hardcode.gdbms.engine.values.ValueFactory; |
88 | 596 | fernando | import com.iver.andami.PluginServices; |
89 | 732 | fernando | import com.iver.andami.messages.NotificationManager; |
90 | 2710 | fjp | import com.iver.andami.ui.mdiFrame.MainFrame; |
91 | 596 | fernando | import com.iver.andami.ui.mdiManager.SingletonView; |
92 | import com.iver.andami.ui.mdiManager.ViewInfo; |
||
93 | 4060 | caballero | import com.iver.andami.ui.mdiManager.ViewListener; |
94 | 4726 | caballero | import com.iver.andami.ui.mdiManager.ViewTransform; |
95 | 464 | fernando | import com.iver.cit.gvsig.fmap.FMap; |
96 | 3996 | caballero | import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
97 | 4060 | caballero | import com.iver.cit.gvsig.fmap.core.DefaultRow; |
98 | import com.iver.cit.gvsig.fmap.core.IFeature; |
||
99 | import com.iver.cit.gvsig.fmap.core.IGeometry; |
||
100 | 3996 | caballero | import com.iver.cit.gvsig.fmap.core.IRow; |
101 | 3940 | caballero | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
102 | 5181 | caballero | import com.iver.cit.gvsig.fmap.edition.EditionEvent; |
103 | 3996 | caballero | import com.iver.cit.gvsig.fmap.edition.EditionException; |
104 | 4060 | caballero | import com.iver.cit.gvsig.fmap.edition.IEditableSource; |
105 | import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
||
106 | import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
||
107 | 4117 | caballero | import com.iver.cit.gvsig.fmap.edition.commands.CommandListener; |
108 | 4140 | caballero | import com.iver.cit.gvsig.fmap.edition.writers.dbf.DbfWriter; |
109 | 3996 | caballero | import com.iver.cit.gvsig.fmap.edition.writers.shp.ShpWriter; |
110 | 694 | fernando | import com.iver.cit.gvsig.fmap.layers.FLayer; |
111 | 3996 | caballero | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
112 | 4140 | caballero | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
113 | 464 | fernando | import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
114 | import com.iver.cit.gvsig.fmap.layers.SelectionEvent; |
||
115 | import com.iver.cit.gvsig.fmap.layers.SelectionListener; |
||
116 | 4706 | caballero | import com.iver.cit.gvsig.gui.tables.Column; |
117 | 3996 | caballero | import com.iver.cit.gvsig.gui.tables.EditionTable; |
118 | 2936 | caballero | import com.iver.cit.gvsig.gui.tables.PopupMenu; |
119 | 1221 | fernando | import com.iver.cit.gvsig.project.ProjectTable; |
120 | 3996 | caballero | import com.iver.utiles.SimpleFileFilter; |
121 | 2241 | fernando | import com.iver.utiles.swing.jtable.FieldSelectionEvent; |
122 | import com.iver.utiles.swing.jtable.FieldSelectionListener; |
||
123 | import com.iver.utiles.swing.jtable.SelectionHeaderSupport; |
||
124 | 464 | fernando | |
125 | 428 | fernando | /**
|
126 | * DOCUMENT ME!
|
||
127 | *
|
||
128 | * @author Fernando Gonz?lez Cort?s
|
||
129 | */
|
||
130 | 4060 | caballero | public class Table extends JPanel implements SingletonView, EditionTable, |
131 | 4726 | caballero | ViewListener,CommandListener, ViewTransform { |
132 | 428 | fernando | private static Logger logger = Logger.getLogger(Table.class.getName()); |
133 | private javax.swing.JScrollPane jScrollPane = null; |
||
134 | 5254 | caballero | protected javax.swing.JTable table = null; |
135 | 5133 | jorpiell | protected ProjectTable model = null; |
136 | 5118 | jorpiell | protected JLabel jLabelStatus = null; |
137 | 5133 | jorpiell | protected FMap fmap;
|
138 | 457 | fernando | private boolean updating = false; |
139 | private TableSelectionListener selectionListener = new TableSelectionListener(); |
||
140 | 4060 | caballero | private long numReg = 0; |
141 | 5133 | jorpiell | protected SelectionHeaderSupport headerSelectionSupport = new SelectionHeaderSupport(); |
142 | 2266 | fernando | private long[] orderIndexes = null; |
143 | private long[] orderIndexesInverted = null; |
||
144 | 4060 | caballero | private IRow[] rowsCopied = null; |
145 | 5037 | cesar | private ViewInfo m_viewInfo = null; |
146 | 4726 | caballero | private boolean isPalette=false; |
147 | 3940 | caballero | |
148 | 428 | fernando | /**
|
149 | * This is the default constructor
|
||
150 | */
|
||
151 | public Table() {
|
||
152 | super();
|
||
153 | initialize(); |
||
154 | } |
||
155 | 312 | fernando | |
156 | 428 | fernando | /**
|
157 | * DOCUMENT ME!
|
||
158 | *
|
||
159 | * @return DOCUMENT ME!
|
||
160 | */
|
||
161 | 457 | fernando | public ProjectTable getModel() {
|
162 | return model;
|
||
163 | 428 | fernando | } |
164 | 3940 | caballero | |
165 | 4060 | caballero | /**
|
166 | * DOCUMENT ME!
|
||
167 | *
|
||
168 | * @return DOCUMENT ME!
|
||
169 | */
|
||
170 | public BitSet getSelectedFieldIndices() { |
||
171 | 5286 | caballero | BitSet bs=headerSelectionSupport.getSelectedColumns();
|
172 | BitSet newbs=new BitSet(); |
||
173 | for (int i =1;i<bs.length();i++){ |
||
174 | if (bs.get(i))
|
||
175 | newbs.set(i-1);
|
||
176 | } |
||
177 | return newbs;
|
||
178 | 2241 | fernando | } |
179 | 4060 | caballero | |
180 | /**
|
||
181 | * DOCUMENT ME!
|
||
182 | *
|
||
183 | * @return DOCUMENT ME!
|
||
184 | */
|
||
185 | public int[] getSelectedRowIndices() { |
||
186 | return getTable().getSelectedRows();
|
||
187 | 2913 | caballero | } |
188 | 4060 | caballero | |
189 | /**
|
||
190 | * DOCUMENT ME!
|
||
191 | */
|
||
192 | 5134 | jorpiell | protected void refreshControls() { |
193 | 4060 | caballero | try {
|
194 | 2710 | fjp | MainFrame mF = PluginServices.getMainFrame(); |
195 | 3940 | caballero | |
196 | 4060 | caballero | if (mF != null) { |
197 | PluginServices.getMDIManager().getViewInfo(Table.this).setTitle(PluginServices.getText( |
||
198 | this, "Tabla") + ": " + model.getName()); |
||
199 | } |
||
200 | 3940 | caballero | |
201 | 4060 | caballero | if (model.getAssociatedTable() != null) { |
202 | this.fmap = ((FLayer) model.getAssociatedTable()).getFMap();
|
||
203 | } else {
|
||
204 | this.fmap = null; |
||
205 | } |
||
206 | 3940 | caballero | |
207 | 4060 | caballero | SelectableDataSource dataSource = (SelectableDataSource) model.getModelo() |
208 | .getRecordset(); |
||
209 | logger.debug("dataSource.start()");
|
||
210 | dataSource.start(); |
||
211 | 3940 | caballero | |
212 | 4706 | caballero | |
213 | ColumnModel cm=new ColumnModel();
|
||
214 | cm.setDataModel(model); |
||
215 | getTable().setColumnModel(cm); |
||
216 | |||
217 | 4060 | caballero | AbstractTableModel dataModel = new DataSourceDataModel(model); |
218 | 2241 | fernando | |
219 | 4060 | caballero | getTable().setModel(dataModel); |
220 | 4706 | caballero | TableColumn column = null; |
221 | for (int i = 0; i < model.getColumnCount(); i++) { |
||
222 | column = table.getColumnModel().getColumn(i); |
||
223 | int w=model.getColumn(i).getWidth();
|
||
224 | column.setPreferredWidth(w); //sport column is bigger
|
||
225 | 3940 | caballero | |
226 | 4706 | caballero | } |
227 | 5075 | caballero | headerSelectionSupport.setTableHeader(getTable().getTableHeader()); |
228 | 4060 | caballero | headerSelectionSupport.addFieldSelectionListener(new FieldSelectionListener() {
|
229 | public void fieldSelected(FieldSelectionEvent e) { |
||
230 | if (PluginServices.getMainFrame() != null) { |
||
231 | PluginServices.getMainFrame().enableControls(); |
||
232 | } |
||
233 | } |
||
234 | }); |
||
235 | 3940 | caballero | |
236 | 4060 | caballero | model.getModelo().getRecordset().addSelectionListener(selectionListener); |
237 | 3940 | caballero | |
238 | 4060 | caballero | updateSelection(); |
239 | } catch (DriverException e) {
|
||
240 | NotificationManager.addError("No se pudo leer la informaci?n", e);
|
||
241 | } catch (DriverLoadException e) {
|
||
242 | NotificationManager.addError("No se pudo leer la informaci?n", e);
|
||
243 | } |
||
244 | 1830 | fernando | } |
245 | 3940 | caballero | |
246 | 428 | fernando | /**
|
247 | * DOCUMENT ME!
|
||
248 | *
|
||
249 | 457 | fernando | * @param table DOCUMENT ME!
|
250 | 428 | fernando | */
|
251 | 694 | fernando | public void setModel(ProjectTable table) { |
252 | 1830 | fernando | model = table; |
253 | 457 | fernando | |
254 | 1830 | fernando | //Gesti?n del nombre de la ventana
|
255 | model.addPropertyChangeListener(new PropertyChangeListener() { |
||
256 | 4060 | caballero | public void propertyChange(PropertyChangeEvent evt) { |
257 | if (evt.getPropertyName().equals("name")) { |
||
258 | PluginServices.getMDIManager().getViewInfo(Table.this) |
||
259 | .setTitle(PluginServices.getText(this,
|
||
260 | "Tabla") + ": " + (String) evt.getNewValue()); |
||
261 | } else if (evt.getPropertyName().equals("model")) { |
||
262 | refreshControls(); |
||
263 | } |
||
264 | } |
||
265 | }); |
||
266 | 3940 | caballero | |
267 | 1830 | fernando | refreshControls(); |
268 | 5254 | caballero | TableColumn tc=getTable().getColumnModel().getColumn(0); |
269 | tc.setCellRenderer(new MyTableCellRenderer());
|
||
270 | 5379 | caballero | |
271 | |||
272 | 428 | fernando | } |
273 | 5254 | caballero | class MyTableCellRenderer extends JLabel implements TableCellRenderer { |
274 | final Border grayBorder = BorderFactory.createLineBorder(Color.darkGray); |
||
275 | 428 | fernando | |
276 | 5254 | caballero | MyTableCellRenderer() { |
277 | |||
278 | } |
||
279 | |||
280 | public Component getTableCellRendererComponent(javax.swing.JTable table, |
||
281 | Object value, boolean isSelected, boolean hasFocus, int row, |
||
282 | int col) {
|
||
283 | JLabel label=new JLabel(String.valueOf(row+1)); |
||
284 | label.setForeground(Color.blue);
|
||
285 | label.setOpaque(true);
|
||
286 | if (isSelected)
|
||
287 | label.setBackground(Color.yellow);
|
||
288 | else
|
||
289 | label.setBackground(UIManager.getColor("Button.background")); |
||
290 | |||
291 | label.setBorder(grayBorder); |
||
292 | return label;
|
||
293 | } |
||
294 | } |
||
295 | |||
296 | 428 | fernando | /**
|
297 | 457 | fernando | *
|
298 | */
|
||
299 | 5118 | jorpiell | public void updateSelection() { |
300 | 4060 | caballero | updating = true;
|
301 | 457 | fernando | |
302 | 4060 | caballero | try {
|
303 | DefaultListSelectionModel sm = (DefaultListSelectionModel) getTable() |
||
304 | .getSelectionModel(); |
||
305 | sm.clearSelection(); |
||
306 | |||
307 | BitSet bs = (model.getModelo().getRecordset()).getSelection();
|
||
308 | sm.setValueIsAdjusting(true);
|
||
309 | |||
310 | if (orderIndexes != null) { |
||
311 | for (int i = 0; i < orderIndexes.length; i++) { |
||
312 | if (bs.get(i)) {
|
||
313 | sm.addSelectionInterval((int) orderIndexesInverted[i],
|
||
314 | (int) orderIndexesInverted[i]);
|
||
315 | } |
||
316 | 2481 | fernando | } |
317 | 4060 | caballero | } else {
|
318 | for (int i = bs.nextSetBit(0); i >= 0; |
||
319 | i = bs.nextSetBit(i + 1)) {
|
||
320 | sm.addSelectionInterval(i, i); |
||
321 | } |
||
322 | 2481 | fernando | } |
323 | 4060 | caballero | |
324 | sm.setValueIsAdjusting(false);
|
||
325 | try {
|
||
326 | numReg = model.getModelo().getRowCount(); |
||
327 | } catch (IOException e) { |
||
328 | e.printStackTrace(); |
||
329 | 2266 | fernando | } |
330 | 4060 | caballero | |
331 | jLabelStatus.setText(" " +
|
||
332 | ((SelectableDataSource) model.getModelo().getRecordset()).getSelection() |
||
333 | .cardinality() + " / " + numReg + " " + |
||
334 | PluginServices.getText(this, "registros_seleccionados_total") + |
||
335 | ".");
|
||
336 | } catch (DriverIOException e) {
|
||
337 | e.printStackTrace(); |
||
338 | } catch (DriverLoadException e) {
|
||
339 | e.printStackTrace(); |
||
340 | 457 | fernando | } |
341 | |||
342 | updating = false;
|
||
343 | } |
||
344 | |||
345 | /**
|
||
346 | 428 | fernando | * This method initializes this
|
347 | */
|
||
348 | 5118 | jorpiell | protected void initialize() { |
349 | 428 | fernando | jLabelStatus = new JLabel(); |
350 | setLayout(new java.awt.BorderLayout());
|
||
351 | jLabelStatus.setText("");
|
||
352 | jLabelStatus.setName("");
|
||
353 | jLabelStatus.setPreferredSize(new java.awt.Dimension(100, 18)); |
||
354 | add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
||
355 | this.add(jLabelStatus, java.awt.BorderLayout.SOUTH);
|
||
356 | } |
||
357 | |||
358 | /**
|
||
359 | * This method initializes table
|
||
360 | *
|
||
361 | * @return javax.swing.JTable
|
||
362 | */
|
||
363 | 5254 | caballero | public javax.swing.JTable getTable() {
|
364 | 428 | fernando | if (table == null) { |
365 | 5254 | caballero | table = new javax.swing.JTable();
|
366 | 428 | fernando | table.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); |
367 | 457 | fernando | table.setSelectionModel(new DefaultListSelectionModel()); |
368 | 2913 | caballero | table.getTableHeader().addMouseListener(new MouseHandler());
|
369 | 5075 | caballero | table.addKeyListener(new TableKeyListener());
|
370 | 2936 | caballero | table.addMouseListener(new MouseRow());
|
371 | 5075 | caballero | table.setSelectionForeground(Color.blue);
|
372 | table.setSelectionBackground(Color.yellow);
|
||
373 | table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { |
||
374 | 457 | fernando | public void valueChanged(ListSelectionEvent e) { |
375 | 5075 | caballero | |
376 | if (updating) {
|
||
377 | return;
|
||
378 | 4060 | caballero | } |
379 | 3940 | caballero | |
380 | 4060 | caballero | SelectableDataSource dataModel = null;
|
381 | 3940 | caballero | |
382 | 4060 | caballero | try {
|
383 | dataModel = Table.this.model.getModelo() |
||
384 | .getRecordset(); |
||
385 | } catch (DriverLoadException e1) {
|
||
386 | e1.printStackTrace(); |
||
387 | } |
||
388 | |||
389 | DefaultListSelectionModel model = (DefaultListSelectionModel) table.getSelectionModel(); |
||
390 | 464 | fernando | BitSet selection = dataModel.getSelection();
|
391 | 428 | fernando | |
392 | 4060 | caballero | for (int i = e.getFirstIndex(); i <= e.getLastIndex(); |
393 | i++) { |
||
394 | if (orderIndexes != null) { |
||
395 | selection.set((int) orderIndexes[i],
|
||
396 | model.isSelectedIndex(i)); |
||
397 | } else {
|
||
398 | 2266 | fernando | selection.set(i, model.isSelectedIndex(i)); |
399 | } |
||
400 | 457 | fernando | } |
401 | |||
402 | if (e.getValueIsAdjusting() == false) { |
||
403 | 4060 | caballero | if (fmap != null) { |
404 | fmap.endAtomicEvent(); |
||
405 | } |
||
406 | |||
407 | 464 | fernando | dataModel.fireSelectionEvents(); |
408 | 4060 | caballero | } else {
|
409 | if (fmap != null) { |
||
410 | fmap.beginAtomicEvent(); |
||
411 | } |
||
412 | 457 | fernando | } |
413 | 4060 | caballero | |
414 | jLabelStatus.setText(" " + selection.cardinality() +
|
||
415 | " / " + numReg + " " + |
||
416 | PluginServices.getText(this,
|
||
417 | "registros_seleccionados_total") + "."); |
||
418 | 5075 | caballero | |
419 | 428 | fernando | } |
420 | }); |
||
421 | 4060 | caballero | |
422 | 5075 | caballero | JTextField tf=new JTextField(); |
423 | table.setDefaultEditor(Number.class, new DefaultEditor(tf)); |
||
424 | table.setDefaultEditor(String.class, new DefaultEditor(tf)); |
||
425 | table.setDefaultEditor(Object.class, new DefaultEditor(tf)); |
||
426 | 428 | fernando | } |
427 | |||
428 | return table;
|
||
429 | } |
||
430 | 5075 | caballero | protected class DefaultEditor extends DefaultCellEditor { |
431 | public Component getTableCellEditorComponent(javax.swing.JTable table, |
||
432 | Object value, boolean isSelected, int row, int column) { |
||
433 | JTextField tf=(JTextField)super.getTableCellEditorComponent(table, value, isSelected, |
||
434 | row, column); |
||
435 | if (isSelected){
|
||
436 | tf.setBackground(new Color(230,220,220)); |
||
437 | tf.selectAll(); |
||
438 | 428 | fernando | |
439 | 5075 | caballero | } |
440 | return tf;
|
||
441 | } |
||
442 | |||
443 | public DefaultEditor(JTextField tf) { |
||
444 | super(tf);
|
||
445 | 5379 | caballero | //MouseListener[] mouseListeners=getTable().getEditorComponent().getMouseListeners();
|
446 | // if (!mouseListeners[mouseListeners.length-1].getClass().equals(MouseRow.class)){
|
||
447 | tf.addMouseListener(new MouseRow());
|
||
448 | // }
|
||
449 | 5075 | caballero | getComponent().addKeyListener(new KeyAdapter() { |
450 | int keyPressed = 0; |
||
451 | |||
452 | public void keyPressed(KeyEvent ke) { |
||
453 | if (ke.getKeyCode() != KeyEvent.VK_TAB) |
||
454 | keyPressed++; |
||
455 | JTextField tf = (JTextField) getComponent(); |
||
456 | |||
457 | |||
458 | if (ke.getKeyCode() == KeyEvent.VK_RIGHT |
||
459 | || ke.getKeyCode() == KeyEvent.VK_ENTER) {
|
||
460 | int caretPosition = tf.getCaretPosition();
|
||
461 | if (caretPosition >= tf.getText().length()) {
|
||
462 | int x = table.getSelectedColumn();
|
||
463 | int y = table.getSelectedRow();
|
||
464 | if (x + 1 >= table.getColumnCount()) { |
||
465 | x = 0;
|
||
466 | y++; |
||
467 | } else {
|
||
468 | x++; |
||
469 | } |
||
470 | //table.changeSelection(y, x, false, true);
|
||
471 | //initEditField(x,y);
|
||
472 | getComponent().setEnabled(false);
|
||
473 | } |
||
474 | |||
475 | } else if (ke.getKeyCode() == KeyEvent.VK_LEFT) { |
||
476 | int caretPosition = tf.getCaretPosition();
|
||
477 | if (caretPosition <= 0) { |
||
478 | int x = table.getSelectedColumn();
|
||
479 | int y = table.getSelectedRow();
|
||
480 | if (x == 0) { |
||
481 | x = table.getColumnCount() - 1;
|
||
482 | if (y - 1 < 0) |
||
483 | y = table.getRowCount() - 1;
|
||
484 | else
|
||
485 | y--; |
||
486 | } else {
|
||
487 | x--; |
||
488 | } |
||
489 | //table.changeSelection(y, x, false, true);
|
||
490 | //initEditField(x,y);
|
||
491 | getComponent().setEnabled(false);
|
||
492 | } |
||
493 | |||
494 | } |
||
495 | } |
||
496 | |||
497 | public void keyReleased(KeyEvent ke) { |
||
498 | JComponent editor = (JComponent) DefaultEditor.this |
||
499 | .getComponent(); |
||
500 | if (editor instanceof JTextField) { |
||
501 | if (keyPressed == 0) { |
||
502 | ((JTextField) editor).setText(String.valueOf(ke |
||
503 | .getKeyChar())); |
||
504 | } |
||
505 | } |
||
506 | keyPressed--; |
||
507 | if (keyPressed < 0) |
||
508 | keyPressed = 0;
|
||
509 | getComponent().setEnabled(true);
|
||
510 | } |
||
511 | }); |
||
512 | |||
513 | } |
||
514 | |||
515 | public Object getCellEditorValue() { |
||
516 | String s = ((JTextField) (DefaultEditor.this.getComponent())) |
||
517 | .getText(); |
||
518 | getComponent().setEnabled(true);
|
||
519 | return s;
|
||
520 | } |
||
521 | |||
522 | public boolean isCellEditable(EventObject event) { |
||
523 | // IF NUMBER OF CLICKS IS LESS THAN THE CLICKCOUNTTOSTART RETURN
|
||
524 | // FALSE
|
||
525 | // FOR CELL EDITING.
|
||
526 | if (event instanceof MouseEvent) { |
||
527 | return ((MouseEvent) event).getClickCount() >= getClickCountToStart(); |
||
528 | } |
||
529 | |||
530 | return true; |
||
531 | } |
||
532 | } |
||
533 | |||
534 | |||
535 | |||
536 | |||
537 | 428 | fernando | /**
|
538 | 5075 | caballero | * This method initializes jScrollPane
|
539 | *
|
||
540 | * @return javax.swing.JScrollPane
|
||
541 | */
|
||
542 | 5118 | jorpiell | protected javax.swing.JScrollPane getJScrollPane() {
|
543 | 428 | fernando | if (jScrollPane == null) { |
544 | jScrollPane = new javax.swing.JScrollPane();
|
||
545 | jScrollPane.setViewportView(getTable()); |
||
546 | } |
||
547 | |||
548 | return jScrollPane;
|
||
549 | } |
||
550 | |||
551 | /**
|
||
552 | 5075 | caballero | * @see com.iver.mdiApp.ui.MDIManager.SingletonView#getViewModel()
|
553 | */
|
||
554 | 428 | fernando | public Object getViewModel() { |
555 | 457 | fernando | return model;
|
556 | 428 | fernando | } |
557 | |||
558 | /**
|
||
559 | 5075 | caballero | * This method is used to get <strong>an initial</strong> ViewInfo object
|
560 | * for this Table. It is not intended to retrieve the ViewInfo object in a
|
||
561 | * later time. <strong>Use PluginServices.getMDIManager().getViewInfo(view)
|
||
562 | * to retrieve the ViewInfo object at any time after the creation of the
|
||
563 | * object.
|
||
564 | *
|
||
565 | * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
||
566 | */
|
||
567 | 428 | fernando | public ViewInfo getViewInfo() {
|
568 | 5037 | cesar | if (m_viewInfo==null) { |
569 | m_viewInfo = new ViewInfo(ViewInfo.ICONIFIABLE |
|
||
570 | ViewInfo.MAXIMIZABLE | ViewInfo.RESIZABLE); |
||
571 | 5319 | caballero | m_viewInfo.setTitle(PluginServices.getText(this, "Tabla")+ " : " +model.getName()); |
572 | 5028 | cesar | m_viewInfo.setWidth(300);
|
573 | m_viewInfo.setHeight(200);
|
||
574 | 5037 | cesar | } |
575 | 428 | fernando | return m_viewInfo;
|
576 | } |
||
577 | |||
578 | /**
|
||
579 | 457 | fernando | * DOCUMENT ME!
|
580 | *
|
||
581 | 4060 | caballero | * @param indexes
|
582 | *
|
||
583 | * @throws IOException
|
||
584 | */
|
||
585 | public void setOrder(long[] indexes) throws IOException { |
||
586 | orderIndexes = indexes; |
||
587 | orderIndexesInverted = new long[orderIndexes.length]; |
||
588 | |||
589 | for (int i = 0; i < indexes.length; i++) { |
||
590 | orderIndexesInverted[(int) indexes[i]] = i;
|
||
591 | } |
||
592 | |||
593 | updating = true;
|
||
594 | ((DataSourceDataModel) getTable().getModel()).fireTableDataChanged(); |
||
595 | updating = false;
|
||
596 | updateSelection(); |
||
597 | } |
||
598 | |||
599 | /* public void startEditing() throws DriverException{
|
||
600 | // dw = model.getModelo().getDataWare(DataSourceFactory.DATA_WARE_COHERENT_ROW_ORDER);
|
||
601 | // dw.beginTrans();
|
||
602 | }
|
||
603 | */
|
||
604 | |||
605 | /**
|
||
606 | * DOCUMENT ME!
|
||
607 | */
|
||
608 | |||
609 | /* public void cancelEditing() throws DriverException {
|
||
610 | dw.rollBackTrans();
|
||
611 | dw = null;
|
||
612 | }
|
||
613 | */
|
||
614 | |||
615 | /**
|
||
616 | * DOCUMENT ME!
|
||
617 | */
|
||
618 | |||
619 | /* public void stopEditing() throws DriverException {
|
||
620 | // dw.commitTrans();
|
||
621 | // dw = null;
|
||
622 | // model.getModelo().stop();
|
||
623 | // model.getModelo().start();
|
||
624 | }
|
||
625 | */
|
||
626 | |||
627 | /**
|
||
628 | * DOCUMENT ME!
|
||
629 | */
|
||
630 | |||
631 | /* public boolean isEditing() {
|
||
632 | return dw != null;
|
||
633 | }
|
||
634 | */
|
||
635 | |||
636 | /**
|
||
637 | * Quita los campos seleccionados
|
||
638 | */
|
||
639 | public void clearSelectedFields() { |
||
640 | headerSelectionSupport.clearSelectedColumns(); |
||
641 | } |
||
642 | |||
643 | /**
|
||
644 | * DOCUMENT ME!
|
||
645 | *
|
||
646 | * @param index DOCUMENT ME!
|
||
647 | *
|
||
648 | * @return DOCUMENT ME!
|
||
649 | */
|
||
650 | public Value[] getValueRow(int index) { |
||
651 | DataSourceDataModel dsdm = (DataSourceDataModel) getTable().getModel(); |
||
652 | Value[] values = new Value[dsdm.getColumnCount()]; |
||
653 | |||
654 | for (int i = 0; i < dsdm.getColumnCount(); i++) { |
||
655 | values[i] = (Value) dsdm.getValueAt(index, i); |
||
656 | } |
||
657 | |||
658 | return values;
|
||
659 | } |
||
660 | |||
661 | /* private void refresh() throws DriverException{
|
||
662 | //dw.commitTrans();
|
||
663 | //model.getModelo().stop();
|
||
664 | //dw.beginTrans();
|
||
665 | //DataSourceDataModel dsdm=(DataSourceDataModel)getTable().getModel();
|
||
666 | //dsdm.fireTableDataChanged();
|
||
667 | }*/
|
||
668 | /* public void addEmptyRow() throws DriverException{
|
||
669 | ValueCollection valuePK=new ValueCollection();
|
||
670 | valuePK.setValues(new Value[]{ValueFactory.createValue(dw.getRowCount())});
|
||
671 | dw.insertEmptyRow(valuePK);
|
||
672 | refresh();
|
||
673 | }
|
||
674 | */
|
||
675 | /* public void copySelectedRows() throws DriverException{
|
||
676 | int[] sel=getSelectedRowIndices();
|
||
677 | for(int i=0;i<sel.length;i++){
|
||
678 | rowsCopied.add(getValueRow(sel[i]));
|
||
679 | }
|
||
680 | }
|
||
681 | */
|
||
682 | /* public void addSelectionToEnd() throws DriverException {
|
||
683 | for (int i=0;i<rowsCopied.size();i++){
|
||
684 | dw.insertFilledRow((Value[])rowsCopied.get(i));
|
||
685 | }
|
||
686 | refresh();
|
||
687 | }
|
||
688 | */
|
||
689 | /*public void delSelectionRow() throws DriverException{
|
||
690 | int[] sel=getSelectedRowIndices();
|
||
691 | for(int i=sel.length-1;i>=0;i--){
|
||
692 | dw.deleteRow(sel[i]);
|
||
693 | }
|
||
694 | refresh();
|
||
695 | }
|
||
696 | */
|
||
697 | /*public boolean isCopy(){
|
||
698 | return !rowsCopied.isEmpty();
|
||
699 | }
|
||
700 | */
|
||
701 | /*
|
||
702 | public void addSelectionToRow() throws DriverException {
|
||
703 | int[] sel=getSelectedRowIndices();
|
||
704 | dw.insertFilledRow((Value[])rowsCopied.get(i),sel[0]);
|
||
705 | refresh();
|
||
706 | }
|
||
707 | */
|
||
708 | public void startEditing() throws EditionException { |
||
709 | 5181 | caballero | getModel().getModelo().startEdition(EditionEvent.ALPHANUMERIC); |
710 | 5101 | caballero | //int row=table.getSelectedRow();
|
711 | //int column=table.getSelectedColumn();
|
||
712 | //if (row!=-1 && column!=-1)
|
||
713 | // initEditField(column,row);
|
||
714 | 5082 | caballero | |
715 | 5108 | caballero | // View[] views = (View[]) PluginServices.getMDIManager().getAllViews();
|
716 | //
|
||
717 | // for (int i=0 ; i<views.length ; i++){
|
||
718 | // if (views[i] instanceof com.iver.cit.gvsig.gui.View){
|
||
719 | // com.iver.cit.gvsig.gui.View view=(com.iver.cit.gvsig.gui.View)views[i];
|
||
720 | // FLayers layers =view.getMapControl().getMapContext().getLayers();
|
||
721 | // for (int j=0;j<layers.getLayersCount();j++){
|
||
722 | // if (layers.getLayer(j).equals(this.getModel().getAssociatedTable())){
|
||
723 | // view.showConsole();
|
||
724 | // ((FLyrVect)layers.getLayer(j)).setActive(true);
|
||
725 | // ((FLyrVect)layers.getLayer(j)).setEditing(true);
|
||
726 | // }
|
||
727 | // }
|
||
728 | // }
|
||
729 | // }
|
||
730 | 4060 | caballero | } |
731 | 5101 | caballero | private void initEditField(int[] x,int[] y){ |
732 | 5379 | caballero | if (getTable().getRowCount()>0){ |
733 | 5119 | caballero | if (isEditing()) {
|
734 | 5254 | caballero | |
735 | 5119 | caballero | if (x.length == 1 && y.length == 1) |
736 | table.editCellAt(y[0], x[0]); |
||
737 | JTextField tf = (JTextField) table.getEditorComponent(); |
||
738 | if (tf != null) { |
||
739 | tf.selectAll(); |
||
740 | 5254 | caballero | tf.requestFocus(); |
741 | 5119 | caballero | } |
742 | if (y.length > 0 && x.length > 0) { |
||
743 | getTable().setRowSelectionInterval(y[0], y[y.length - 1]); |
||
744 | getTable().setColumnSelectionInterval(x[0], x[x.length - 1]); |
||
745 | } |
||
746 | 5254 | caballero | |
747 | 5119 | caballero | } |
748 | 5379 | caballero | } |
749 | 5075 | caballero | } |
750 | 4060 | caballero | /**
|
751 | 5119 | caballero | * DOCUMENT ME!
|
752 | */
|
||
753 | 4060 | caballero | public void stopEditing() { |
754 | try {
|
||
755 | FLyrVect lyr = (FLyrVect) getModel().getAssociatedTable(); |
||
756 | |||
757 | if ((lyr != null) && |
||
758 | lyr.getSource() instanceof VectorialEditableAdapter) {
|
||
759 | JFileChooser jfc = new JFileChooser(); |
||
760 | SimpleFileFilter filterShp = new SimpleFileFilter("shp", |
||
761 | "Ficheros .shp");
|
||
762 | jfc.setFileFilter(filterShp); |
||
763 | |||
764 | if (jfc.showSaveDialog(
|
||
765 | (Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
||
766 | File newFile = jfc.getSelectedFile();
|
||
767 | |||
768 | //VectorialEditableAdapter vea = (VectorialEditableAdapter) layer.getSource();
|
||
769 | // File newFile = vea.getDriver().
|
||
770 | VectorialEditableAdapter vea = (VectorialEditableAdapter) lyr.getSource(); |
||
771 | 4140 | caballero | ShpWriter writer = (ShpWriter)LayerFactory.getWM().getWriter("Shape Writer");
|
772 | 4438 | fjp | writer.setFile(newFile); |
773 | writer.initialize(lyr); |
||
774 | 5181 | caballero | vea.stopEdition(writer,EditionEvent.ALPHANUMERIC); |
775 | 4060 | caballero | lyr.setSource(vea.getOriginalAdapter()); |
776 | lyr.setEditing(false);
|
||
777 | |||
778 | 5082 | caballero | |
779 | 5108 | caballero | // View[] views = (View[]) PluginServices.getMDIManager().getAllViews();
|
780 | //
|
||
781 | // for (int i=0 ; i<views.length ; i++){
|
||
782 | // if (views[i] instanceof com.iver.cit.gvsig.gui.View){
|
||
783 | // com.iver.cit.gvsig.gui.View view=(com.iver.cit.gvsig.gui.View)views[i];
|
||
784 | // FLayers layers =view.getMapControl().getMapContext().getLayers();
|
||
785 | // for (int j=0;j<layers.getLayersCount();j++){
|
||
786 | // if (layers.getLayer(i).equals(this.getModel().getAssociatedTable())){
|
||
787 | // view.showConsole();
|
||
788 | // ((FLyrVect)layers.getLayer(i)).setEditing(false);
|
||
789 | // }
|
||
790 | // }
|
||
791 | // }
|
||
792 | // }
|
||
793 | 5082 | caballero | |
794 | |||
795 | |||
796 | 4060 | caballero | ///vista.hideConsole();
|
797 | } |
||
798 | } else {
|
||
799 | 4117 | caballero | |
800 | JFileChooser jfc = new JFileChooser(); |
||
801 | SimpleFileFilter filterShp = new SimpleFileFilter("dbf", |
||
802 | "Ficheros .dbf");
|
||
803 | jfc.setFileFilter(filterShp); |
||
804 | |||
805 | if (jfc.showSaveDialog(
|
||
806 | (Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
||
807 | File newFile = jfc.getSelectedFile();
|
||
808 | |||
809 | IEditableSource ies=getModel().getModelo(); |
||
810 | 4140 | caballero | DbfWriter writer = (DbfWriter)LayerFactory.getWM().getWriter("DBF Writer");
|
811 | writer.initialize(newFile,getModel().getModelo()); |
||
812 | 5181 | caballero | ies.stopEdition(writer,EditionEvent.ALPHANUMERIC); |
813 | 4117 | caballero | |
814 | ///vista.hideConsole();
|
||
815 | } |
||
816 | |||
817 | /*
|
||
818 | 4060 | caballero | GdbmsWriter gdbmswriter = new GdbmsWriter(getModel().getModelo()
|
819 | .getRecordset()
|
||
820 | .getDataWare(DataSourceFactory.DATA_WARE_COHERENT_ROW_ORDER));
|
||
821 | gdbmswriter.preProcess();
|
||
822 | |||
823 | for (int i = 0; i < getModel().getModelo().getRowCount();
|
||
824 | i++) {
|
||
825 | gdbmswriter.process(getModel().getModelo().getRow(i));
|
||
826 | }
|
||
827 | |||
828 | gdbmswriter.postProcess();
|
||
829 | 4117 | caballero | */
|
830 | 4060 | caballero | } |
831 | |||
832 | //layer.setSource(getModel().getModelo().getOriginalAdapter());
|
||
833 | //layer.setEditing(false);
|
||
834 | //vista.hideConsole();
|
||
835 | //}
|
||
836 | } catch (Exception e) { |
||
837 | NotificationManager.addError("No se pudo guardar la edici?n", e);
|
||
838 | } |
||
839 | } |
||
840 | |||
841 | /**
|
||
842 | * DOCUMENT ME!
|
||
843 | *
|
||
844 | * @param index DOCUMENT ME!
|
||
845 | */
|
||
846 | public void hideColumns(int[] index) { |
||
847 | // TODO Auto-generated method stub
|
||
848 | } |
||
849 | |||
850 | /**
|
||
851 | * DOCUMENT ME!
|
||
852 | *
|
||
853 | * @param index DOCUMENT ME!
|
||
854 | */
|
||
855 | public void setUneditableColumns(int[] index) { |
||
856 | // TODO Auto-generated method stub
|
||
857 | } |
||
858 | |||
859 | /**
|
||
860 | * DOCUMENT ME!
|
||
861 | *
|
||
862 | * @param numColumns DOCUMENT ME!
|
||
863 | * @param values DOCUMENT ME!
|
||
864 | */
|
||
865 | public void setDefaultValues(int[] numColumns, Value[] values) { |
||
866 | // TODO Auto-generated method stub
|
||
867 | } |
||
868 | |||
869 | /**
|
||
870 | * DOCUMENT ME!
|
||
871 | *
|
||
872 | * @return DOCUMENT ME!
|
||
873 | */
|
||
874 | public Value getDefaultValue() {
|
||
875 | // TODO Auto-generated method stub
|
||
876 | return null; |
||
877 | } |
||
878 | |||
879 | /**
|
||
880 | * DOCUMENT ME!
|
||
881 | *
|
||
882 | * @return DOCUMENT ME!
|
||
883 | */
|
||
884 | public int[] getSelectedColumns() { |
||
885 | return null; |
||
886 | } |
||
887 | |||
888 | /**
|
||
889 | * DOCUMENT ME!
|
||
890 | *
|
||
891 | * @throws IOException DOCUMENT ME!
|
||
892 | */
|
||
893 | public void cancelEditing() throws IOException { |
||
894 | 5181 | caballero | getModel().getModelo().cancelEdition(EditionEvent.ALPHANUMERIC); |
895 | 5319 | caballero | //refresh();
|
896 | //refreshControls();
|
||
897 | 4060 | caballero | } |
898 | |||
899 | /**
|
||
900 | * DOCUMENT ME!
|
||
901 | *
|
||
902 | * @return DOCUMENT ME!
|
||
903 | */
|
||
904 | public boolean isEditing() { |
||
905 | return getModel().getModelo().isEditing();
|
||
906 | } |
||
907 | |||
908 | /**
|
||
909 | * DOCUMENT ME!
|
||
910 | */
|
||
911 | public void refresh() { |
||
912 | 5086 | caballero | int row=table.getSelectedRow();
|
913 | int column=table.getSelectedColumn();
|
||
914 | if (row!=-1 && column!=-1 && table.getEditorComponent()!=null){ |
||
915 | Value[] values=getValueRow(row);
|
||
916 | JTextField jtf=(JTextField)table.getEditorComponent(); |
||
917 | jtf.setText(values[column].toString()); |
||
918 | } |
||
919 | 4060 | caballero | updating = true;
|
920 | ((DataSourceDataModel) getTable().getModel()).fireTableDataChanged(); |
||
921 | 5075 | caballero | |
922 | 4060 | caballero | updating = false;
|
923 | updateSelection(); |
||
924 | 5254 | caballero | PluginServices.getMainFrame().enableControls(); |
925 | 5086 | caballero | |
926 | 4060 | caballero | } |
927 | |||
928 | /**
|
||
929 | * Add the rows that are passed like parameter and if parameter is null a
|
||
930 | * row is added empties.
|
||
931 | *
|
||
932 | * @param rows Rows to add or null.
|
||
933 | *
|
||
934 | * @throws DriverIOException
|
||
935 | * @throws IOException
|
||
936 | */
|
||
937 | public void addRow(IRow[] rows) throws DriverIOException, IOException { |
||
938 | try {
|
||
939 | if (rows == null) { |
||
940 | 4117 | caballero | if (getModel().getAssociatedTable()!=null){ |
941 | JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),"No se puede a?adir una fila a una tabla asociada a una capa."); |
||
942 | return;
|
||
943 | } |
||
944 | 4060 | caballero | IRow row; |
945 | 4117 | caballero | int numAttr=getModel().getModelo()
|
946 | .getRecordset() |
||
947 | .getFieldCount(); |
||
948 | Value[] values=new Value[numAttr]; |
||
949 | for (int i=0;i<numAttr;i++){ |
||
950 | values[i]=ValueFactory.createNullValue(); |
||
951 | } |
||
952 | row = new DefaultRow(values);
|
||
953 | 5181 | caballero | getModel().getModelo().addRow(row,"Fila en blanco",EditionEvent.ALPHANUMERIC);
|
954 | 4060 | caballero | } else {
|
955 | 4117 | caballero | getModel().getModelo().startComplexRow(); |
956 | 4060 | caballero | for (int i = 0; i < rows.length; i++) { |
957 | 5181 | caballero | getModel().getModelo().addRow(((IRowEdited) rows[i]).getLinkedRow(),"Pegar filas",EditionEvent.ALPHANUMERIC);
|
958 | 4060 | caballero | } |
959 | 4117 | caballero | getModel().getModelo().endComplexRow(); |
960 | 4060 | caballero | } |
961 | } catch (DriverException e) {
|
||
962 | // TODO Auto-generated catch block
|
||
963 | e.printStackTrace(); |
||
964 | } catch (DriverLoadException e) {
|
||
965 | // TODO Auto-generated catch block
|
||
966 | e.printStackTrace(); |
||
967 | } |
||
968 | |||
969 | refresh(); |
||
970 | 5101 | caballero | |
971 | 4060 | caballero | } |
972 | |||
973 | /**
|
||
974 | * Copy in the arraylist the rows that be selected just then.
|
||
975 | *
|
||
976 | * @throws DriverIOException
|
||
977 | * @throws IOException
|
||
978 | */
|
||
979 | public void copyRow() throws DriverIOException, IOException { |
||
980 | int[] index = getSelectedRowIndices(); |
||
981 | rowsCopied = new IRow[index.length];
|
||
982 | |||
983 | for (int i = 0; i < index.length; i++) { |
||
984 | rowsCopied[i] = getModel().getModelo().getRow(index[i]); |
||
985 | } |
||
986 | } |
||
987 | |||
988 | /**
|
||
989 | * Cut the rows that be selected just then.
|
||
990 | *
|
||
991 | * @throws DriverIOException
|
||
992 | * @throws IOException
|
||
993 | */
|
||
994 | public void cutRow() throws DriverIOException, IOException { |
||
995 | int[] index = getSelectedRowIndices(); |
||
996 | rowsCopied = new IRow[index.length];
|
||
997 | |||
998 | for (int i = 0; i < index.length; i++) { |
||
999 | rowsCopied[i] = getModel().getModelo().getRow(index[i]); |
||
1000 | } |
||
1001 | |||
1002 | removeRow(); |
||
1003 | } |
||
1004 | |||
1005 | /**
|
||
1006 | * Remove in the rows that be selected just then.
|
||
1007 | *
|
||
1008 | * @throws DriverIOException
|
||
1009 | * @throws IOException
|
||
1010 | */
|
||
1011 | public void removeRow() throws DriverIOException, IOException { |
||
1012 | 5119 | caballero | int[] index = getSelectedRowIndices(); |
1013 | 4117 | caballero | getModel().getModelo().startComplexRow(); |
1014 | 5379 | caballero | for (int i = index.length-1; i >=0; i--) { |
1015 | 5181 | caballero | getModel().getModelo().removeRow(index[i],"Eliminar fila", EditionEvent.ALPHANUMERIC);
|
1016 | 4060 | caballero | } |
1017 | 5119 | caballero | int[] sel={0}; |
1018 | 5379 | caballero | getTable().setEditingRow(0);
|
1019 | 5119 | caballero | initEditField(sel,sel); |
1020 | 5379 | caballero | |
1021 | 4117 | caballero | getModel().getModelo().endComplexRow(); |
1022 | 5101 | caballero | getTable().clearSelection(); |
1023 | 5119 | caballero | |
1024 | 4060 | caballero | refresh(); |
1025 | 5108 | caballero | //repaintAssociatedView();
|
1026 | 4060 | caballero | } |
1027 | |||
1028 | 5108 | caballero | // private void repaintAssociatedView(){
|
1029 | // View[] views = (View[]) PluginServices.getMDIManager().getAllViews();
|
||
1030 | //
|
||
1031 | // for (int i=0 ; i<views.length ; i++){
|
||
1032 | // if (views[i] instanceof com.iver.cit.gvsig.gui.View){
|
||
1033 | // com.iver.cit.gvsig.gui.View view=(com.iver.cit.gvsig.gui.View)views[i];
|
||
1034 | // FLayers layers =view.getMapControl().getMapContext().getLayers();
|
||
1035 | // for (int j=0;j<layers.getLayersCount();j++){
|
||
1036 | // if (layers.getLayer(j).equals(this.getModel().getAssociatedTable())){
|
||
1037 | // view.getMapControl().getMapContext().invalidate();
|
||
1038 | // }
|
||
1039 | // }
|
||
1040 | // }
|
||
1041 | // }
|
||
1042 | // }
|
||
1043 | 4060 | caballero | /**
|
1044 | * DOCUMENT ME!
|
||
1045 | */
|
||
1046 | public void addColumn() { |
||
1047 | // TODO Auto-generated method stub
|
||
1048 | refresh(); |
||
1049 | 5108 | caballero | //repaintAssociatedView();
|
1050 | 4060 | caballero | } |
1051 | |||
1052 | /**
|
||
1053 | * DOCUMENT ME!
|
||
1054 | */
|
||
1055 | public void removeColumn() { |
||
1056 | // TODO Auto-generated method stub
|
||
1057 | refresh(); |
||
1058 | 5108 | caballero | //repaintAssociatedView();
|
1059 | 4060 | caballero | } |
1060 | |||
1061 | /**
|
||
1062 | * Return if we have rows copied or not.
|
||
1063 | *
|
||
1064 | * @return True if we have rows copied.
|
||
1065 | */
|
||
1066 | public boolean isCopied() { |
||
1067 | return (rowsCopied != null); |
||
1068 | } |
||
1069 | |||
1070 | /**
|
||
1071 | * Paste the arraylist rows.
|
||
1072 | *
|
||
1073 | * @throws DriverIOException
|
||
1074 | * @throws IOException
|
||
1075 | */
|
||
1076 | public void pasteRow() throws DriverIOException, IOException { |
||
1077 | addRow(rowsCopied); |
||
1078 | 5108 | caballero | //repaintAssociatedView();
|
1079 | 4060 | caballero | } |
1080 | |||
1081 | /**
|
||
1082 | * DOCUMENT ME!
|
||
1083 | */
|
||
1084 | public void viewActivated() { |
||
1085 | //if (isEditing() && getModel().getModelo() instanceof VectorialEditableAdapter)
|
||
1086 | updateSelection(); |
||
1087 | } |
||
1088 | |||
1089 | /**
|
||
1090 | * DOCUMENT ME!
|
||
1091 | */
|
||
1092 | public void viewClosed() { |
||
1093 | // TODO Auto-generated method stub
|
||
1094 | } |
||
1095 | |||
1096 | /**
|
||
1097 | * DOCUMENT ME!
|
||
1098 | *
|
||
1099 | 457 | fernando | * @author Fernando Gonz?lez Cort?s
|
1100 | */
|
||
1101 | public class DataSourceDataModel extends AbstractTableModel { |
||
1102 | 3996 | caballero | //private SelectableDataSource dataSource;
|
1103 | 4060 | caballero | private IEditableSource des;
|
1104 | 2565 | fernando | private String[] aliases; |
1105 | private int[] mapping; |
||
1106 | 4060 | caballero | |
1107 | 457 | fernando | /**
|
1108 | * Crea un nuevo DataSourceDataModel.
|
||
1109 | *
|
||
1110 | 4060 | caballero | * @param pt DOCUMENT ME!
|
1111 | 457 | fernando | */
|
1112 | 2565 | fernando | public DataSourceDataModel(ProjectTable pt) {
|
1113 | 4060 | caballero | this.des = pt.getModelo();
|
1114 | |||
1115 | 3996 | caballero | //try {
|
1116 | 4060 | caballero | //dataSource = pt.getModelo().getRecordset();
|
1117 | //} catch (DriverLoadException e) {
|
||
1118 | // TODO Auto-generated catch block
|
||
1119 | // e.printStackTrace();
|
||
1120 | //}
|
||
1121 | 2565 | fernando | aliases = pt.getAliases(); |
1122 | mapping = pt.getMapping(); |
||
1123 | 457 | fernando | } |
1124 | |||
1125 | /**
|
||
1126 | 2936 | caballero | * Returns the name of the field.
|
1127 | 457 | fernando | *
|
1128 | 2936 | caballero | * @param col index of field
|
1129 | 457 | fernando | *
|
1130 | 2936 | caballero | * @return Name of field
|
1131 | 457 | fernando | */
|
1132 | public String getColumnName(int col) { |
||
1133 | 5254 | caballero | return aliases[mapping[col]];
|
1134 | 457 | fernando | } |
1135 | |||
1136 | /**
|
||
1137 | 2936 | caballero | * Returns the number of fields.
|
1138 | 457 | fernando | *
|
1139 | 2936 | caballero | * @return number of fields
|
1140 | 457 | fernando | */
|
1141 | public int getColumnCount() { |
||
1142 | 5286 | caballero | return mapping.length;
|
1143 | 457 | fernando | } |
1144 | |||
1145 | /**
|
||
1146 | 2936 | caballero | * Returns number of rows.
|
1147 | 457 | fernando | *
|
1148 | 2936 | caballero | * @return number of rows.
|
1149 | 457 | fernando | */
|
1150 | public int getRowCount() { |
||
1151 | try {
|
||
1152 | 4060 | caballero | return (int) des.getRowCount(); |
1153 | 3996 | caballero | } catch (DriverIOException e) {
|
1154 | 4060 | caballero | return 0; |
1155 | } catch (IOException e) { |
||
1156 | return 0; |
||
1157 | } |
||
1158 | 457 | fernando | } |
1159 | |||
1160 | /**
|
||
1161 | * DOCUMENT ME!
|
||
1162 | *
|
||
1163 | * @param row DOCUMENT ME!
|
||
1164 | * @param col DOCUMENT ME!
|
||
1165 | *
|
||
1166 | * @return DOCUMENT ME!
|
||
1167 | */
|
||
1168 | public Object getValueAt(int row, int col) { |
||
1169 | 5101 | caballero | |
1170 | 5254 | caballero | if (col==0){ |
1171 | return null; |
||
1172 | } |
||
1173 | col--; |
||
1174 | 4060 | caballero | |
1175 | 4808 | caballero | try {
|
1176 | if (orderIndexes != null) { |
||
1177 | 5254 | caballero | Object obj =null; |
1178 | |||
1179 | IRowEdited rowEdited=des.getRow((int)orderIndexes[row]);
|
||
1180 | 5286 | caballero | obj= rowEdited.getAttribute(mapping[col]); |
1181 | 5254 | caballero | return obj;
|
1182 | 4808 | caballero | } else {
|
1183 | 5101 | caballero | Object obj =null; |
1184 | 5254 | caballero | |
1185 | 5101 | caballero | IRowEdited rowEdited=des.getRow(row); |
1186 | 5286 | caballero | obj= rowEdited.getAttribute(mapping[col]); |
1187 | 5254 | caballero | //obj = sds.getFieldValue(row, col);
|
1188 | 4808 | caballero | return obj;
|
1189 | } |
||
1190 | 5254 | caballero | } catch (DriverIOException e1) {
|
1191 | return ValueFactory.createValue("").toString(); |
||
1192 | } catch (IOException e1) { |
||
1193 | return ValueFactory.createValue("").toString(); |
||
1194 | } |
||
1195 | 4808 | caballero | } |
1196 | 3996 | caballero | |
1197 | 4060 | caballero | /**
|
1198 | * DOCUMENT ME!
|
||
1199 | *
|
||
1200 | * @param rowIndex DOCUMENT ME!
|
||
1201 | * @param columnIndex DOCUMENT ME!
|
||
1202 | *
|
||
1203 | * @return DOCUMENT ME!
|
||
1204 | */
|
||
1205 | 2481 | fernando | public boolean isCellEditable(int rowIndex, int columnIndex) { |
1206 | 5254 | caballero | if (columnIndex==0) |
1207 | return false; |
||
1208 | |||
1209 | return isEditing();
|
||
1210 | 2481 | fernando | } |
1211 | 4060 | caballero | |
1212 | /**
|
||
1213 | * DOCUMENT ME!
|
||
1214 | *
|
||
1215 | * @param aValue DOCUMENT ME!
|
||
1216 | * @param rowIndex DOCUMENT ME!
|
||
1217 | * @param columnIndex DOCUMENT ME!
|
||
1218 | *
|
||
1219 | * @throws RuntimeException DOCUMENT ME!
|
||
1220 | */
|
||
1221 | 2481 | fernando | public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
1222 | 5254 | caballero | if (columnIndex==0) |
1223 | throw new UnsupportedOperationException("Row Number is a read-only column"); |
||
1224 | columnIndex--; |
||
1225 | Value v; |
||
1226 | 5379 | caballero | if (getValueAt(rowIndex,columnIndex+1)==null || getValueAt(rowIndex,columnIndex+1).toString().equals(aValue)) |
1227 | 5075 | caballero | return;
|
1228 | 2481 | fernando | try {
|
1229 | 4060 | caballero | v = ValueFactory.createValueByType(aValue.toString(), |
1230 | des.getRecordset().getFieldType(columnIndex)); |
||
1231 | |||
1232 | IRowEdited row = des.getRow(rowIndex); //.getAttribute(columnIndex);
|
||
1233 | Value[] values = row.getAttributes();
|
||
1234 | values[columnIndex] = v; |
||
1235 | |||
1236 | IRow newRow = null;
|
||
1237 | |||
1238 | if (row.getLinkedRow() instanceof IFeature) { |
||
1239 | IGeometry geometry = ((DefaultFeature) row.getLinkedRow()).getGeometry(); |
||
1240 | 5161 | caballero | newRow = new DefaultFeature(geometry, values,row.getID());
|
1241 | 4060 | caballero | } else {
|
1242 | 5161 | caballero | newRow = new DefaultRow(values,row.getID());
|
1243 | 4060 | caballero | } |
1244 | |||
1245 | 5181 | caballero | des.modifyRow(rowIndex, newRow,"Editar valor", EditionEvent.ALPHANUMERIC);
|
1246 | 2481 | fernando | } catch (DriverException e1) {
|
1247 | throw new RuntimeException(e1); |
||
1248 | } catch (ParseException e) { |
||
1249 | throw new RuntimeException(e); |
||
1250 | 3996 | caballero | } catch (DriverLoadException e) {
|
1251 | 4060 | caballero | throw new RuntimeException(e); |
1252 | } catch (DriverIOException e) {
|
||
1253 | throw new RuntimeException(e); |
||
1254 | } catch (IOException e) { |
||
1255 | throw new RuntimeException(e); |
||
1256 | 5075 | caballero | } catch (NumberFormatException e) { |
1257 | 5503 | cesar | /* NotificationManager.addError(PluginServices.-getText(this,"numero_incorrecto")+
|
1258 | "\n"+PluginServices.-getText(this,"fila")+" = "+rowIndex+
|
||
1259 | "\n"+PluginServices.-getText(this,"columna")+ " = "+columnIndex,e);
|
||
1260 | 5075 | caballero | */
|
1261 | } |
||
1262 | 2481 | fernando | } |
1263 | 457 | fernando | } |
1264 | 4706 | caballero | public class ColumnModel extends DefaultTableColumnModel{ |
1265 | private ProjectTable pt;
|
||
1266 | public ColumnModel() {
|
||
1267 | } |
||
1268 | 457 | fernando | |
1269 | 4706 | caballero | public void setDataModel(ProjectTable model) { |
1270 | this.pt=model;
|
||
1271 | } |
||
1272 | |||
1273 | public void addColumn(TableColumn tc) { |
||
1274 | super.addColumn(tc);
|
||
1275 | } |
||
1276 | |||
1277 | public TableColumn getColumn(int i) { |
||
1278 | TableColumn tc=super.getColumn(i); |
||
1279 | return tc;
|
||
1280 | } |
||
1281 | |||
1282 | public int getColumnCount() { |
||
1283 | return super.getColumnCount(); |
||
1284 | } |
||
1285 | |||
1286 | public void removeColumn(TableColumn arg0) { |
||
1287 | super.removeColumn(arg0);
|
||
1288 | } |
||
1289 | |||
1290 | public int getColumnIndex(Object arg0) { |
||
1291 | return super.getColumnIndex(arg0); |
||
1292 | } |
||
1293 | |||
1294 | public int getColumnIndexAtX(int arg0) { |
||
1295 | return super.getColumnIndexAtX(arg0); |
||
1296 | } |
||
1297 | |||
1298 | public int getColumnMargin() { |
||
1299 | return super.getColumnMargin(); |
||
1300 | } |
||
1301 | |||
1302 | public Enumeration getColumns() { |
||
1303 | return super.getColumns(); |
||
1304 | } |
||
1305 | |||
1306 | public int getTotalColumnWidth() { |
||
1307 | int w=0; |
||
1308 | for (int i=0;i<getColumnCount();i++){ |
||
1309 | w+=pt.getColumn(i).getWidth(); |
||
1310 | } |
||
1311 | return super.getTotalColumnWidth(); |
||
1312 | } |
||
1313 | |||
1314 | public void moveColumn(int arg0, int arg1) { |
||
1315 | 5254 | caballero | //super.moveColumn(arg0, arg1);
|
1316 | if (arg0==arg1){
|
||
1317 | super.moveColumn(arg0,arg1);
|
||
1318 | } |
||
1319 | 4706 | caballero | } |
1320 | |||
1321 | public void addColumnModelListener(TableColumnModelListener arg0) { |
||
1322 | super.addColumnModelListener(arg0);
|
||
1323 | } |
||
1324 | |||
1325 | protected ListSelectionModel createSelectionModel() { |
||
1326 | return super.createSelectionModel(); |
||
1327 | } |
||
1328 | |||
1329 | protected void fireColumnAdded(TableColumnModelEvent arg0) { |
||
1330 | super.fireColumnAdded(arg0);
|
||
1331 | } |
||
1332 | |||
1333 | protected void fireColumnMarginChanged() { |
||
1334 | super.fireColumnMarginChanged();
|
||
1335 | } |
||
1336 | |||
1337 | protected void fireColumnMoved(TableColumnModelEvent arg0) { |
||
1338 | super.fireColumnMoved(arg0);
|
||
1339 | } |
||
1340 | |||
1341 | protected void fireColumnRemoved(TableColumnModelEvent arg0) { |
||
1342 | super.fireColumnRemoved(arg0);
|
||
1343 | } |
||
1344 | |||
1345 | protected void fireColumnSelectionChanged(ListSelectionEvent arg0) { |
||
1346 | super.fireColumnSelectionChanged(arg0);
|
||
1347 | } |
||
1348 | |||
1349 | public TableColumnModelListener[] getColumnModelListeners() { |
||
1350 | return super.getColumnModelListeners(); |
||
1351 | } |
||
1352 | |||
1353 | public boolean getColumnSelectionAllowed() { |
||
1354 | return super.getColumnSelectionAllowed(); |
||
1355 | } |
||
1356 | |||
1357 | public EventListener[] getListeners(Class arg0) { |
||
1358 | return super.getListeners(arg0); |
||
1359 | } |
||
1360 | |||
1361 | public int getSelectedColumnCount() { |
||
1362 | return super.getSelectedColumnCount(); |
||
1363 | } |
||
1364 | |||
1365 | public int[] getSelectedColumns() { |
||
1366 | return super.getSelectedColumns(); |
||
1367 | } |
||
1368 | |||
1369 | public ListSelectionModel getSelectionModel() { |
||
1370 | return super.getSelectionModel(); |
||
1371 | } |
||
1372 | |||
1373 | public void propertyChange(PropertyChangeEvent arg0) { |
||
1374 | 5254 | caballero | try{
|
1375 | 4706 | caballero | super.propertyChange(arg0);
|
1376 | int w=((Integer)arg0.getNewValue()).intValue(); |
||
1377 | if (arg0.getSource() instanceof TableColumn && (w!=75)){ |
||
1378 | TableColumn tc=(TableColumn)arg0.getSource(); |
||
1379 | Column column=pt.getColumn(tc.getModelIndex()); |
||
1380 | column.setWidth(w); |
||
1381 | System.out.println("Index guardar = "+tc.getModelIndex()+" , "+"Anchura = "+w); |
||
1382 | } |
||
1383 | 5254 | caballero | }catch (Exception e) { |
1384 | System.out.println("PETA"); |
||
1385 | } |
||
1386 | 4706 | caballero | |
1387 | } |
||
1388 | protected void recalcWidthCache() { |
||
1389 | super.recalcWidthCache();
|
||
1390 | } |
||
1391 | |||
1392 | public void removeColumnModelListener(TableColumnModelListener arg0) { |
||
1393 | super.removeColumnModelListener(arg0);
|
||
1394 | } |
||
1395 | |||
1396 | public void setColumnMargin(int arg0) { |
||
1397 | super.setColumnMargin(arg0);
|
||
1398 | } |
||
1399 | |||
1400 | public void setColumnSelectionAllowed(boolean arg0) { |
||
1401 | super.setColumnSelectionAllowed(arg0);
|
||
1402 | } |
||
1403 | |||
1404 | public void setSelectionModel(ListSelectionModel arg0) { |
||
1405 | super.setSelectionModel(arg0);
|
||
1406 | } |
||
1407 | |||
1408 | public void valueChanged(ListSelectionEvent arg0) { |
||
1409 | super.valueChanged(arg0);
|
||
1410 | } |
||
1411 | |||
1412 | public int hashCode() { |
||
1413 | return super.hashCode(); |
||
1414 | } |
||
1415 | |||
1416 | protected void finalize() throws Throwable { |
||
1417 | super.finalize();
|
||
1418 | } |
||
1419 | |||
1420 | protected Object clone() throws CloneNotSupportedException { |
||
1421 | return super.clone(); |
||
1422 | } |
||
1423 | |||
1424 | public boolean equals(Object arg0) { |
||
1425 | return super.equals(arg0); |
||
1426 | } |
||
1427 | |||
1428 | public String toString() { |
||
1429 | return super.toString(); |
||
1430 | } |
||
1431 | } |
||
1432 | 2241 | fernando | /**
|
1433 | 4060 | caballero | * DOCUMENT ME!
|
1434 | *
|
||
1435 | * @author Vicente Caballero Navarro
|
||
1436 | 2241 | fernando | */
|
1437 | 4060 | caballero | public class TableSelectionListener implements SelectionListener { |
1438 | /**
|
||
1439 | * @see com.iver.cit.gvsig.fmap.layers.LegendListener#selectionChanged(com.iver.cit.gvsig.fmap.layers.LayerEvent)
|
||
1440 | */
|
||
1441 | public void selectionChanged(SelectionEvent e) { |
||
1442 | updateSelection(); |
||
1443 | Table.this.repaint(); |
||
1444 | 2266 | fernando | } |
1445 | 2241 | fernando | } |
1446 | 3940 | caballero | |
1447 | 2481 | fernando | /**
|
1448 | 4060 | caballero | * DOCUMENT ME!
|
1449 | 3940 | caballero | *
|
1450 | 4060 | caballero | * @author Vicente Caballero Navarro
|
1451 | 2481 | fernando | */
|
1452 | 4060 | caballero | private class MouseHandler extends MouseAdapter { |
1453 | /**
|
||
1454 | * DOCUMENT ME!
|
||
1455 | *
|
||
1456 | * @param e DOCUMENT ME!
|
||
1457 | */
|
||
1458 | public void mouseClicked(MouseEvent e) { |
||
1459 | 5379 | caballero | |
1460 | 4060 | caballero | /* JTableHeader h = (JTableHeader) e.getSource();
|
1461 | TableColumnModel columnModel = h.getColumnModel();
|
||
1462 | int viewColumn = columnModel.getColumnIndexAtX(e.getX());
|
||
1463 | int column = columnModel.getColumn(viewColumn).getModelIndex();
|
||
1464 | if (column != -1) {
|
||
1465 | }*/
|
||
1466 | } |
||
1467 | 2481 | fernando | } |
1468 | 5075 | caballero | /**
|
1469 | * DOCUMENT ME!
|
||
1470 | *
|
||
1471 | * @author Vicente Caballero Navarro
|
||
1472 | */
|
||
1473 | private class TableKeyListener implements KeyListener { |
||
1474 | 4060 | caballero | |
1475 | 5075 | caballero | public void keyPressed(KeyEvent arg0) { |
1476 | //JTextField tf=(JTextField)table.getEditorComponent();
|
||
1477 | //table.setCellSelectionEnabled(true);
|
||
1478 | //FocusManager fm = FocusManager.getCurrentManager();
|
||
1479 | //fm.focusPreviousComponent(table);
|
||
1480 | } |
||
1481 | |||
1482 | public void keyReleased(KeyEvent ke) { |
||
1483 | 5101 | caballero | int[] row=table.getSelectedRows(); |
1484 | int[] column=table.getSelectedColumns(); |
||
1485 | 5075 | caballero | initEditField(column,row); |
1486 | } |
||
1487 | |||
1488 | public void keyTyped(KeyEvent arg0) { |
||
1489 | // TODO Auto-generated method stub
|
||
1490 | |||
1491 | } |
||
1492 | |||
1493 | } |
||
1494 | |||
1495 | 2481 | fernando | /**
|
1496 | 4060 | caballero | * DOCUMENT ME!
|
1497 | 3940 | caballero | *
|
1498 | 4060 | caballero | * @author Vicente Caballero Navarro
|
1499 | 2481 | fernando | */
|
1500 | 4060 | caballero | private class MouseRow extends MouseAdapter { |
1501 | 5075 | caballero | public void mouseReleased(MouseEvent arg0) { |
1502 | super.mouseReleased(arg0);
|
||
1503 | 5101 | caballero | int[] row=table.getSelectedRows(); |
1504 | int[] column=table.getSelectedColumns(); |
||
1505 | 5075 | caballero | initEditField(column,row); |
1506 | } |
||
1507 | |||
1508 | /**
|
||
1509 | 4060 | caballero | * DOCUMENT ME!
|
1510 | *
|
||
1511 | * @param e DOCUMENT ME!
|
||
1512 | */
|
||
1513 | 2913 | caballero | public void mouseClicked(MouseEvent e) { |
1514 | 5075 | caballero | super.mouseClicked(e);
|
1515 | 5379 | caballero | |
1516 | |||
1517 | 5075 | caballero | PluginServices.getMainFrame().enableControls(); |
1518 | 3940 | caballero | |
1519 | 4060 | caballero | if (e.getButton() == MouseEvent.BUTTON3) { |
1520 | new PopupMenu(e.getPoint()); |
||
1521 | } |
||
1522 | 2913 | caballero | } |
1523 | } |
||
1524 | 4117 | caballero | |
1525 | 4140 | caballero | public void commandRepaint() { |
1526 | 4117 | caballero | refresh(); |
1527 | } |
||
1528 | 4128 | caballero | |
1529 | public void commandRefresh() { |
||
1530 | 4140 | caballero | commandRepaint(); |
1531 | 4128 | caballero | } |
1532 | 4726 | caballero | |
1533 | public void toPalette() { |
||
1534 | isPalette=true;
|
||
1535 | m_viewInfo = new ViewInfo(ViewInfo.ICONIFIABLE |
|
||
1536 | ViewInfo.MODELESSDIALOG | ViewInfo.RESIZABLE | ViewInfo.PALETTE); |
||
1537 | PluginServices.getMDIManager().changeViewInfo(this,getViewInfo());
|
||
1538 | } |
||
1539 | |||
1540 | public void restore() { |
||
1541 | isPalette=false;
|
||
1542 | m_viewInfo = new ViewInfo(ViewInfo.ICONIFIABLE |
|
||
1543 | ViewInfo.MAXIMIZABLE | ViewInfo.RESIZABLE); |
||
1544 | PluginServices.getMDIManager().changeViewInfo(this,getViewInfo());
|
||
1545 | } |
||
1546 | |||
1547 | public boolean isPalette() { |
||
1548 | return isPalette;
|
||
1549 | } |
||
1550 | 5075 | caballero | |
1551 | |||
1552 | private void addNumbers(){ |
||
1553 | TableColumn tc=new TableColumn(); |
||
1554 | tc.setWidth(40);
|
||
1555 | tc.setResizable(false);
|
||
1556 | getTable().addColumn(tc); |
||
1557 | } |
||
1558 | public static void main(String[] args) { |
||
1559 | JTextField tf=new JTextField("hola"); |
||
1560 | tf.selectAll(); |
||
1561 | JFrame frame=new JFrame(); |
||
1562 | frame.getContentPane().add(tf); |
||
1563 | frame.show(true);
|
||
1564 | } |
||
1565 | 312 | fernando | } |