175 |
175 |
*/
|
176 |
176 |
public BitSet getSelectedFieldIndices() {
|
177 |
177 |
BitSet bs=headerSelectionSupport.getSelectedColumns();
|
178 |
|
BitSet newbs=new BitSet();
|
179 |
|
for (int i =1;i<bs.length();i++){
|
180 |
|
if (bs.get(i))
|
181 |
|
newbs.set(i-1);
|
182 |
|
}
|
183 |
|
return newbs;
|
|
178 |
// BitSet newbs=new BitSet();
|
|
179 |
// for (int i =1;i<bs.length();i++){
|
|
180 |
// if (bs.get(i))
|
|
181 |
// newbs.set(i-1);
|
|
182 |
// }
|
|
183 |
// return newbs;
|
|
184 |
return bs;
|
184 |
185 |
}
|
185 |
186 |
|
186 |
187 |
/**
|
... | ... | |
222 |
223 |
getTable().setColumnModel(cm);
|
223 |
224 |
|
224 |
225 |
AbstractTableModel dataModel = new DataSourceDataModel(model);
|
|
226 |
|
|
227 |
getModel().createAlias();
|
225 |
228 |
|
226 |
229 |
getTable().setModel(dataModel);
|
227 |
230 |
// TableColumn column = null;
|
... | ... | |
882 |
885 |
public void cancelEditing() throws IOException {
|
883 |
886 |
this.cancelEditingCell();
|
884 |
887 |
getModel().getModelo().cancelEdition(EditionEvent.ALPHANUMERIC);
|
885 |
|
getModel().setAliases(antAliases);
|
886 |
|
getModel().setMapping(antMapping);
|
887 |
|
getModel().recalculateColumnsFromAliases();
|
|
888 |
if (antAliases != null)
|
|
889 |
{
|
|
890 |
getModel().setAliases(antAliases);
|
|
891 |
getModel().setMapping(antMapping);
|
|
892 |
getModel().recalculateColumnsFromAliases();
|
|
893 |
}
|
|
894 |
else
|
|
895 |
{
|
|
896 |
System.err.println("Algo ha ido mal con antAliases");
|
|
897 |
}
|
888 |
898 |
//refresh();
|
889 |
899 |
refreshControls();
|
890 |
900 |
}
|
... | ... | |
1067 |
1077 |
BitSet selectedFields = getSelectedFieldIndices();
|
1068 |
1078 |
SelectableDataSource sds = edAdapter.getRecordset();
|
1069 |
1079 |
edAdapter.startComplexRow();
|
|
1080 |
FieldDescription[] auxFlds = sds.getFieldsDescription();
|
1070 |
1081 |
for(int i=selectedFields.nextSetBit(0); i>=0; i=selectedFields.nextSetBit(i+1)) {
|
1071 |
|
FieldDescription fld = sds.getFieldsDescription()[i];
|
|
1082 |
FieldDescription fld = auxFlds[i];
|
1072 |
1083 |
edAdapter.removeField(fld.getFieldAlias());
|
1073 |
1084 |
}
|
1074 |
1085 |
if (getTable().getCellEditor() != null)
|
... | ... | |
1137 |
1148 |
*/
|
1138 |
1149 |
public class DataSourceDataModel extends AbstractTableModel {
|
1139 |
1150 |
//private SelectableDataSource dataSource;
|
1140 |
|
private IEditableSource des;
|
1141 |
|
private String[] aliases;
|
1142 |
|
private int[] mapping;
|
|
1151 |
ProjectTable pt;
|
1143 |
1152 |
|
1144 |
1153 |
/**
|
1145 |
1154 |
* Crea un nuevo DataSourceDataModel.
|
... | ... | |
1147 |
1156 |
* @param pt DOCUMENT ME!
|
1148 |
1157 |
*/
|
1149 |
1158 |
public DataSourceDataModel(ProjectTable pt) {
|
1150 |
|
this.des = pt.getModelo();
|
|
1159 |
this.pt = pt;
|
1151 |
1160 |
|
1152 |
1161 |
//try {
|
1153 |
1162 |
//dataSource = pt.getModelo().getRecordset();
|
... | ... | |
1155 |
1164 |
// TODO Auto-generated catch block
|
1156 |
1165 |
// e.printStackTrace();
|
1157 |
1166 |
//}
|
1158 |
|
aliases = pt.getAliases();
|
1159 |
|
mapping = pt.getMapping();
|
1160 |
1167 |
}
|
1161 |
1168 |
|
1162 |
1169 |
/**
|
... | ... | |
1170 |
1177 |
// if (col==0)
|
1171 |
1178 |
// return " ";
|
1172 |
1179 |
// col--;
|
1173 |
|
int i=mapping[col];
|
1174 |
|
return aliases[i];
|
|
1180 |
int i=pt.getMapping()[col];
|
|
1181 |
return pt.getAliases()[i];
|
1175 |
1182 |
}
|
1176 |
1183 |
|
1177 |
1184 |
/**
|
... | ... | |
1180 |
1187 |
* @return number of fields
|
1181 |
1188 |
*/
|
1182 |
1189 |
public int getColumnCount() {
|
1183 |
|
return mapping.length;
|
|
1190 |
return pt.getColumnCount();
|
1184 |
1191 |
}
|
1185 |
1192 |
|
1186 |
1193 |
/**
|
... | ... | |
1190 |
1197 |
*/
|
1191 |
1198 |
public int getRowCount() {
|
1192 |
1199 |
try {
|
|
1200 |
IEditableSource des = pt.getModelo();
|
1193 |
1201 |
return (int) des.getRowCount();
|
1194 |
1202 |
} catch (DriverIOException e) {
|
1195 |
1203 |
return 0;
|
... | ... | |
1219 |
1227 |
numRow=row;
|
1220 |
1228 |
}
|
1221 |
1229 |
try {
|
|
1230 |
IEditableSource des = pt.getModelo();
|
1222 |
1231 |
Object obj =null;
|
1223 |
1232 |
IRowEdited rowEdited=des.getRow(numRow);
|
1224 |
|
obj= rowEdited.getAttribute(mapping[col]);
|
|
1233 |
obj= rowEdited.getAttribute(pt.getMapping()[col]);
|
1225 |
1234 |
return obj;
|
1226 |
1235 |
} catch (DriverIOException e1) {
|
1227 |
1236 |
return ValueFactory.createValue("").toString();
|
... | ... | |
1239 |
1248 |
* @return DOCUMENT ME!
|
1240 |
1249 |
*/
|
1241 |
1250 |
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
1242 |
|
if (columnIndex==0)
|
1243 |
|
return false;
|
|
1251 |
// if (columnIndex==0)
|
|
1252 |
// return false;
|
1244 |
1253 |
|
1245 |
1254 |
return isEditing();
|
1246 |
1255 |
}
|
... | ... | |
1268 |
1277 |
if (getValueAt(rowIndex,columnIndex)==null || getValueAt(rowIndex,columnIndex).toString().equals(aValue))
|
1269 |
1278 |
return;
|
1270 |
1279 |
try {
|
|
1280 |
IEditableSource des = pt.getModelo();
|
1271 |
1281 |
v = ValueFactory.createValueByType(aValue.toString(),
|
1272 |
1282 |
des.getRecordset().getFieldType(columnIndex));
|
1273 |
1283 |
IRowEdited row = des.getRow(numRow); //.getAttribute(columnIndex);
|
... | ... | |
1517 |
1527 |
|
1518 |
1528 |
public void afterFieldEditEvent(AfterFieldEditEvent e) {
|
1519 |
1529 |
try {
|
1520 |
|
getModel().createAlias();
|
|
1530 |
// getModel().createAlias();
|
1521 |
1531 |
clearSelectedFields();
|
1522 |
|
refresh();
|
|
1532 |
// refresh();
|
1523 |
1533 |
refreshControls();
|
1524 |
1534 |
// ((DataSourceDataModel) getTable().getModel()).fireTableDataChanged();
|
1525 |
1535 |
} catch (DriverLoadException e1) {
|
1526 |
1536 |
// TODO Auto-generated catch block
|
1527 |
1537 |
e1.printStackTrace();
|
1528 |
|
} catch (DriverException e1) {
|
|
1538 |
/* } catch (DriverException e1) {
|
1529 |
1539 |
// TODO Auto-generated catch block
|
1530 |
|
e1.printStackTrace();
|
|
1540 |
e1.printStackTrace(); */
|
1531 |
1541 |
}
|
1532 |
1542 |
|
1533 |
1543 |
}
|