root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / table / models / ROIsTableModel.java @ 15939
History | View | Annotate | Download (1.61 KB)
1 | 14100 | gsdiego | package org.gvsig.gui.beans.table.models; |
---|---|---|---|
2 | |||
3 | import java.awt.Color; |
||
4 | |||
5 | import javax.swing.JButton; |
||
6 | import javax.swing.table.DefaultTableModel; |
||
7 | |||
8 | import org.gvsig.gui.beans.table.models.IModel; |
||
9 | |||
10 | public class ROIsTableModel extends DefaultTableModel implements IModel { |
||
11 | private static final long serialVersionUID = 8716862990277121681L; |
||
12 | |||
13 | |||
14 | 15939 | gsdiego | private static boolean[] canEdit = new boolean[] { true, false, false, false, true, false }; |
15 | private static Class[] types = new Class[] { String.class, Integer.class, Integer.class, Integer.class, JButton.class, Integer.class }; |
||
16 | 14142 | gsdiego | private static Color[] colors = new Color[] {Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW, Color.MAGENTA, Color.CYAN, |
17 | Color.ORANGE, Color.PINK, Color.WHITE, Color.BLACK}; |
||
18 | 14100 | gsdiego | |
19 | public ROIsTableModel(String[] columnNames) { |
||
20 | 15939 | gsdiego | super(new Object[0][6], columnNames); |
21 | 14100 | gsdiego | } |
22 | |||
23 | /*
|
||
24 | * (non-Javadoc)
|
||
25 | * @see org.gvsig.gui.beans.table.models.IModel#getNewLine()
|
||
26 | */
|
||
27 | public Object[] getNewLine() { |
||
28 | 14142 | gsdiego | Color color = null; |
29 | if (this.getRowCount() < colors.length) { |
||
30 | color = colors[this.getRowCount()];
|
||
31 | 14100 | gsdiego | } |
32 | 14142 | gsdiego | else{
|
33 | color = new Color((float)Math.random(),(float)Math.random(),(float)Math.random()); |
||
34 | } |
||
35 | 15939 | gsdiego | return new Object[] {"", new Integer(0), new Integer(0), new Integer(0), color, new Integer(0)}; |
36 | 14100 | gsdiego | } |
37 | |||
38 | /*
|
||
39 | * (non-Javadoc)
|
||
40 | * @see javax.swing.table.AbstractTableModel#getColumnClass(int)
|
||
41 | */
|
||
42 | public Class getColumnClass(int columnIndex) { |
||
43 | return types [columnIndex];
|
||
44 | } |
||
45 | |||
46 | /*
|
||
47 | * (non-Javadoc)
|
||
48 | * @see javax.swing.table.DefaultTableModel#isCellEditable(int, int)
|
||
49 | */
|
||
50 | public boolean isCellEditable(int rowIndex, int columnIndex) { |
||
51 | return canEdit [columnIndex];
|
||
52 | } |
||
53 | } |