svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / table / gui / tablemodel / ColumnModel.java @ 25065
History | View | Annotate | Download (1.72 KB)
1 |
package com.iver.cit.gvsig.project.documents.table.gui.tablemodel; |
---|---|
2 |
|
3 |
import java.beans.PropertyChangeEvent; |
4 |
|
5 |
import javax.swing.table.DefaultTableColumnModel; |
6 |
import javax.swing.table.TableColumn; |
7 |
|
8 |
import org.gvsig.project.document.table.FeatureTableDocument; |
9 |
|
10 |
import com.iver.andami.messages.NotificationManager; |
11 |
|
12 |
public class ColumnModel extends DefaultTableColumnModel{ |
13 |
private FeatureTableDocument pt;
|
14 |
public ColumnModel(FeatureTableDocument pt) {
|
15 |
this.pt = pt;
|
16 |
} |
17 |
|
18 |
|
19 |
public int getTotalColumnWidth() { |
20 |
// int w=0;
|
21 |
// for (int i=0;i<getColumnCount();i++){
|
22 |
// w+=pt.getColumn(i).getWidth();
|
23 |
// }
|
24 |
//System.out.println("Total width ="+super.getTotalColumnWidth());
|
25 |
return super.getTotalColumnWidth(); |
26 |
} |
27 |
|
28 |
public void moveColumn(int arg0, int arg1) { |
29 |
//super.moveColumn(arg0, arg1);
|
30 |
if (arg0==arg1){
|
31 |
super.moveColumn(arg0,arg1);
|
32 |
} |
33 |
} |
34 |
|
35 |
|
36 |
public void propertyChange(PropertyChangeEvent arg0) { |
37 |
try{
|
38 |
super.propertyChange(arg0);
|
39 |
int w=((Integer)arg0.getNewValue()).intValue(); |
40 |
if (arg0.getSource() instanceof TableColumn && (w!=75)){ |
41 |
TableColumn tc=(TableColumn)arg0.getSource(); |
42 |
Column column=pt.getColumn(tc.getModelIndex()); |
43 |
column.setWidth(w); |
44 |
//System.out.println("Index guardar = "+tc.getModelIndex()+" , "+"Anchura = "+w);
|
45 |
} |
46 |
}catch (Exception e) { |
47 |
NotificationManager.addError("change_columns_size",e);
|
48 |
} |
49 |
|
50 |
} |
51 |
|
52 |
|
53 |
public TableColumn getColumn(int columnIndex) { |
54 |
TableColumn column= super.getColumn(columnIndex); |
55 |
int widht=pt.getColumn(columnIndex).getWidth();
|
56 |
//System.err.println("width= "+widht);
|
57 |
column.setWidth(widht); |
58 |
return column;
|
59 |
} |
60 |
|
61 |
|
62 |
public int getColumnCount() { |
63 |
if (super.getColumnCount()<pt.getMapping().length) |
64 |
return super.getColumnCount(); |
65 |
return pt.getMapping().length;
|
66 |
} |
67 |
} |