Revision 33379
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/extension/TableRowsOperations.java | ||
---|---|---|
8 | 8 |
import org.gvsig.fmap.dal.exception.DataException; |
9 | 9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
10 | 10 |
|
11 |
|
|
12 |
|
|
13 | 11 |
/** |
14 | 12 |
* DOCUMENT ME! |
15 |
* |
|
13 |
*
|
|
16 | 14 |
* @author Vicente Caballero Navarro |
15 |
* @author gvSIG team |
|
17 | 16 |
*/ |
18 | 17 |
public class TableRowsOperations extends Extension { |
19 |
private FeatureTableDocumentPanel table; |
|
18 |
|
|
20 | 19 |
/** |
21 | 20 |
* DOCUMENT ME! |
22 | 21 |
*/ |
... | ... | |
42 | 41 |
* @param actionCommand DOCUMENT ME! |
43 | 42 |
*/ |
44 | 43 |
public void execute(String actionCommand) { |
44 |
FeatureTableDocumentPanel tableDocument = getTableDocument(); |
|
45 | 45 |
if (actionCommand.compareTo("SELECTIONUP") == 0) { |
46 |
showsSelectedRows(table);
|
|
46 |
showsSelectedRows(tableDocument);
|
|
47 | 47 |
} |
48 | 48 |
if (actionCommand.compareTo("INVERTSELECTION") == 0) { |
49 |
invertSelection(table);
|
|
49 |
invertSelection(tableDocument);
|
|
50 | 50 |
} |
51 |
table.getModel().setModified(true);
|
|
51 |
tableDocument.getModel().setModified(true);
|
|
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
/** |
... | ... | |
57 | 57 |
*/ |
58 | 58 |
private void invertSelection(FeatureTableDocumentPanel table) { |
59 | 59 |
try { |
60 |
FeatureStore fs = table.getModel().getStore();
|
|
60 |
FeatureStore fs = getTableDocument().getModel().getStore();
|
|
61 | 61 |
fs.getFeatureSelection().reverse(); |
62 | 62 |
} catch (DataException e) { |
63 | 63 |
e.printStackTrace(); |
... | ... | |
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
private void showsSelectedRows(FeatureTableDocumentPanel table) { |
69 |
// long[] mapping=null; |
|
70 |
// try { |
|
71 |
// FeatureStore fs=table.getModel().getModel(); |
|
72 |
// mapping = new long[fs.getDataCollection().size()]; |
|
73 |
// |
|
74 |
// FeatureCollection selectedRows=(FeatureCollection)fs.getSelection(); |
|
75 |
// |
|
76 |
// |
|
77 |
// int m=0; |
|
78 |
// for (int i = selectedRows.nextSetBit(0); i >= 0; |
|
79 |
// i = selectedRows.nextSetBit(i + 1)) { |
|
80 |
// mapping[m]=i; |
|
81 |
// m++; |
|
82 |
// } |
|
83 |
// for (int i = 0; i < mapping.length; |
|
84 |
// i++) { |
|
85 |
// if (!selectedRows.get(i)) { |
|
86 |
// mapping[m]=i; |
|
87 |
// m++; |
|
88 |
// } |
|
89 |
// } |
|
90 |
// FIXME |
|
91 |
// table.setOrder("SELECTEDUP"); |
|
92 |
// } catch (ReadException e) { |
|
93 |
// e.printStackTrace(); |
|
94 |
// } |
|
95 |
|
|
69 |
table.setSelectionUp(true); |
|
96 | 70 |
} |
71 |
|
|
97 | 72 |
/** |
98 | 73 |
* DOCUMENT ME! |
99 | 74 |
* |
100 | 75 |
* @return DOCUMENT ME! |
101 | 76 |
*/ |
102 | 77 |
public boolean isEnabled() { |
103 |
try { |
|
104 |
return !table.getModel().getStore().getFeatureSelection().isEmpty(); |
|
105 |
} catch (DataException e) { |
|
106 |
NotificationManager.addError(e); |
|
78 |
FeatureTableDocumentPanel tableDocument = getTableDocument(); |
|
79 |
|
|
80 |
if (tableDocument != null) { |
|
81 |
try { |
|
82 |
return !tableDocument.getModel() |
|
83 |
.getStore() |
|
84 |
.getFeatureSelection() |
|
85 |
.isEmpty(); |
|
86 |
} catch (DataException e) { |
|
87 |
NotificationManager.addError(e); |
|
88 |
} |
|
107 | 89 |
} |
108 | 90 |
|
109 | 91 |
return false; |
110 | 92 |
} |
111 | 93 |
|
112 |
// protected boolean doIsEnabled(Table table) { |
|
113 |
// try { |
|
114 |
// BitSet indices = table.getSelectedFieldIndices(); |
|
115 |
// |
|
116 |
// System.out.println("TableNumericFieldOperations.isEnabled: Tabla: " |
|
117 |
// + table.getModel().getModelo().getName()); |
|
118 |
// |
|
119 |
// if (indices.cardinality() == 1) { |
|
120 |
// int type = table.getModel().getModelo().getRecordset() |
|
121 |
// .getFieldType(indices.nextSetBit(0)); |
|
122 |
// if ((type == Types.BIGINT) || (type == Types.DECIMAL) |
|
123 |
// || (type == Types.DOUBLE) || (type == Types.FLOAT) |
|
124 |
// || (type == Types.INTEGER) || (type == Types.SMALLINT) |
|
125 |
// || (type == Types.TINYINT) || (type == Types.REAL) |
|
126 |
// || (type == Types.NUMERIC)) { |
|
127 |
// return true; |
|
128 |
// } |
|
129 |
// |
|
130 |
// } |
|
131 |
// } catch (ReadException e) { |
|
132 |
// e.printStackTrace(); |
|
133 |
// } |
|
134 |
// |
|
135 |
// return false; |
|
136 |
// } |
|
137 |
|
|
138 | 94 |
/** |
139 | 95 |
* DOCUMENT ME! |
140 | 96 |
* |
141 | 97 |
* @return DOCUMENT ME! |
142 | 98 |
*/ |
143 | 99 |
public boolean isVisible() { |
144 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
100 |
return getTableDocument() != null; |
|
101 |
} |
|
102 |
|
|
103 |
private FeatureTableDocumentPanel getTableDocument() { |
|
104 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
145 | 105 |
if (v != null && v instanceof FeatureTableDocumentPanel) { |
146 |
table=(FeatureTableDocumentPanel)v; |
|
147 |
return true; |
|
106 |
return (FeatureTableDocumentPanel) v; |
|
148 | 107 |
} |
149 |
|
|
150 |
return false; |
|
151 |
} |
|
108 |
return null; |
|
109 |
} |
|
152 | 110 |
} |
Also available in: Unified diff