Revision 8056 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/gui/Table.java
Table.java | ||
---|---|---|
77 | 77 |
|
78 | 78 |
import com.hardcode.driverManager.DriverLoadException; |
79 | 79 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
80 |
import com.hardcode.gdbms.engine.values.ComplexValue; |
|
80 | 81 |
import com.hardcode.gdbms.engine.values.Value; |
81 | 82 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
82 | 83 |
import com.iver.andami.PluginServices; |
... | ... | |
223 | 224 |
getModel().createAlias(); |
224 | 225 |
|
225 | 226 |
getTable().setModel(dataModel); |
227 |
|
|
226 | 228 |
// TableColumn column = null; |
227 | 229 |
// for (int i = 0; i < model.getColumnCount(); i++) { |
228 | 230 |
// column = table.getColumnModel().getColumn(i); |
... | ... | |
232 | 234 |
// |
233 | 235 |
// } |
234 | 236 |
// |
237 |
for (int i=0;i<dataModel.getColumnCount();i++) { |
|
238 |
if (dataModel.getColumnClass(i).equals(ComplexValue.class)) { |
|
239 |
TableColumn tc=getTable().getColumnModel().getColumn(i); |
|
240 |
ValueComplexRenderer vcr=new ValueComplexRenderer(); |
|
241 |
tc.setCellRenderer(vcr); |
|
242 |
ValueComplexEditor vce=new ValueComplexEditor(); |
|
243 |
tc.setCellEditor(vce); |
|
244 |
} |
|
245 |
} |
|
235 | 246 |
// TableColumn tc=getTable().getColumnModel().getColumn(0); |
236 | 247 |
// tc.setCellRenderer(new MyTableCellRenderer()); |
237 | 248 |
|
... | ... | |
345 | 356 |
} |
346 | 357 |
|
347 | 358 |
jLabelStatus.setText(" " + |
348 |
( model.getModelo().getRecordset()).getSelection()
|
|
359 |
(model.getModelo().getRecordset()).getSelection() |
|
349 | 360 |
.cardinality() + " / " + numReg + " " + |
350 | 361 |
PluginServices.getText(this, "registros_seleccionados_total") + |
351 | 362 |
"."); |
... | ... | |
600 | 611 |
* |
601 | 612 |
* @throws IOException |
602 | 613 |
*/ |
603 |
public void setOrder(long[] indexes) {
|
|
614 |
public void setOrder(long[] indexes){ |
|
604 | 615 |
orderIndexes = indexes; |
605 | 616 |
orderIndexesInverted = new long[orderIndexes.length]; |
606 | 617 |
|
... | ... | |
1175 | 1186 |
// if (col==0) |
1176 | 1187 |
// return " "; |
1177 | 1188 |
// col--; |
1178 |
return pt.getAliases()[col]; |
|
1179 |
// int i=pt.getMapping()[col]; |
|
1180 |
// return pt.getAliases()[i]; |
|
1189 |
int i=pt.getMapping()[col]; |
|
1190 |
return pt.getAliases()[i]; |
|
1181 | 1191 |
} |
1182 | 1192 |
|
1183 | 1193 |
/** |
... | ... | |
1251 | 1261 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
1252 | 1262 |
// if (columnIndex==0) |
1253 | 1263 |
// return false; |
1254 |
|
|
1264 |
try { |
|
1265 |
if (getModel().getModelo().getRecordset().getFieldValue(0,columnIndex).getClass().equals(ComplexValue.class)) |
|
1266 |
return true; |
|
1267 |
} catch (DriverLoadException e) { |
|
1268 |
e.printStackTrace(); |
|
1269 |
} catch (DriverException e) { |
|
1270 |
e.printStackTrace(); |
|
1271 |
} |
|
1255 | 1272 |
return isEditing(); |
1256 | 1273 |
} |
1257 | 1274 |
|
... | ... | |
1313 | 1330 |
*/ |
1314 | 1331 |
} |
1315 | 1332 |
} |
1333 |
|
|
1334 |
public Class getColumnClass(int columnIndex) { |
|
1335 |
try { |
|
1336 |
return pt.getModelo().getRecordset().getFieldValue(0,columnIndex).getClass(); |
|
1337 |
} catch (DriverLoadException e) { |
|
1338 |
e.printStackTrace(); |
|
1339 |
} catch (DriverException e) { |
|
1340 |
e.printStackTrace(); |
|
1341 |
} |
|
1342 |
return null; |
|
1343 |
} |
|
1316 | 1344 |
} |
1317 | 1345 |
public class ColumnModel extends DefaultTableColumnModel{ |
1318 | 1346 |
private ProjectTable pt; |
... | ... | |
1329 | 1357 |
return super.getTotalColumnWidth(); |
1330 | 1358 |
} |
1331 | 1359 |
|
1332 |
public void moveColumn(int columnIndex, int newIndex) { |
|
1333 |
String[] aliases = getModel().getAliases(); |
|
1334 |
if (columnIndex != newIndex) { |
|
1335 |
String aux = aliases[getModel().getMapping()[columnIndex]]; |
|
1336 |
aliases[getModel().getMapping()[columnIndex]] = aliases[getModel().getMapping()[newIndex]]; |
|
1337 |
aliases[getModel().getMapping()[newIndex]] = aux; |
|
1338 |
/*int[] mapping = getModel().getMapping(); |
|
1339 |
int mappedColumnIndex = mapping[columnIndex]; |
|
1340 |
int mappedNewIndex = mapping[newIndex]; |
|
1341 |
mapping[columnIndex] = mappedNewIndex; |
|
1342 |
mapping[newIndex] = mappedColumnIndex; |
|
1343 |
String aux = aliases[mappedColumnIndex]; |
|
1344 |
aliases[mappedColumnIndex] = aliases[mappedNewIndex]; |
|
1345 |
aliases[mappedNewIndex] = aux; |
|
1346 |
*/ |
|
1360 |
public void moveColumn(int arg0, int arg1) { |
|
1361 |
//super.moveColumn(arg0, arg1); |
|
1362 |
if (arg0==arg1){ |
|
1363 |
super.moveColumn(arg0,arg1); |
|
1347 | 1364 |
} |
1348 |
super.moveColumn(columnIndex, newIndex); |
|
1349 |
|
|
1350 | 1365 |
} |
1351 | 1366 |
|
1352 | 1367 |
|
... | ... | |
1378 | 1393 |
public void selectionChanged(SelectionEvent e) { |
1379 | 1394 |
updateSelection(); |
1380 | 1395 |
Table.this.repaint(); |
1396 |
//((ValueComplexRenderer)Table.this.getTable().getColumnModel().getColumn(getSelectedFieldIndices().nextSetBit(0)).getCellRenderer()).getValue(); |
|
1381 | 1397 |
} |
1382 | 1398 |
} |
1383 | 1399 |
|
... | ... | |
1486 | 1502 |
return isPalette; |
1487 | 1503 |
} |
1488 | 1504 |
|
1489 |
|
|
1490 |
// private void addNumbers(){ |
|
1491 |
// TableColumn tc=new TableColumn(); |
|
1492 |
// tc.setWidth(40); |
|
1493 |
// tc.setResizable(false); |
|
1494 |
// getTable().addColumn(tc); |
|
1495 |
// } |
|
1496 | 1505 |
public static void main(String[] args) { |
1497 | 1506 |
JTextField tf=new JTextField("hola"); |
1498 | 1507 |
tf.selectAll(); |
Also available in: Unified diff