49 |
49 |
import java.awt.event.MouseEvent;
|
50 |
50 |
import java.beans.PropertyChangeEvent;
|
51 |
51 |
import java.beans.PropertyChangeListener;
|
52 |
|
import java.io.File;
|
53 |
52 |
import java.io.IOException;
|
54 |
53 |
import java.text.ParseException;
|
55 |
54 |
import java.util.BitSet;
|
... | ... | |
81 |
80 |
import org.apache.log4j.Logger;
|
82 |
81 |
|
83 |
82 |
import com.hardcode.driverManager.DriverLoadException;
|
84 |
|
import com.hardcode.gdbms.engine.data.DataSourceFactory;
|
85 |
83 |
import com.hardcode.gdbms.engine.data.driver.DriverException;
|
86 |
84 |
import com.hardcode.gdbms.engine.values.Value;
|
87 |
85 |
import com.hardcode.gdbms.engine.values.ValueFactory;
|
... | ... | |
109 |
107 |
import com.iver.cit.gvsig.fmap.edition.IWriter;
|
110 |
108 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
|
111 |
109 |
import com.iver.cit.gvsig.fmap.edition.commands.CommandListener;
|
112 |
|
import com.iver.cit.gvsig.fmap.edition.writers.gdbms.GdbmsWriter;
|
113 |
110 |
import com.iver.cit.gvsig.fmap.layers.FLayer;
|
114 |
111 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
|
115 |
112 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
|
... | ... | |
593 |
590 |
updating = true;
|
594 |
591 |
((DataSourceDataModel) getTable().getModel()).fireTableDataChanged();
|
595 |
592 |
updating = false;
|
|
593 |
|
596 |
594 |
updateSelection();
|
597 |
595 |
}
|
598 |
596 |
|
... | ... | |
753 |
751 |
public void stopEditing() {
|
754 |
752 |
try {
|
755 |
753 |
this.stopEditingCell();
|
756 |
|
|
|
754 |
|
757 |
755 |
FLyrVect lyr = (FLyrVect) getModel().getAssociatedTable();
|
758 |
756 |
|
759 |
757 |
if ((lyr != null) &&
|
... | ... | |
773 |
771 |
IWriter writer = w.getWriter();
|
774 |
772 |
if (writer == null)
|
775 |
773 |
{
|
776 |
|
NotificationManager.addError("No existe driver de escritura para la tabla"
|
|
774 |
NotificationManager.addError("No existe driver de escritura para la tabla"
|
777 |
775 |
+ getModel().getName(), new EditionException());
|
778 |
776 |
}
|
779 |
777 |
else
|
780 |
778 |
{
|
781 |
779 |
ITableDefinition tableDef = ies.getTableDefinition();
|
782 |
780 |
writer.initialize(tableDef);
|
783 |
|
|
|
781 |
|
784 |
782 |
ies.stopEdition(writer,EditionEvent.ALPHANUMERIC);
|
785 |
|
}
|
|
783 |
}
|
786 |
784 |
}
|
787 |
785 |
|
788 |
786 |
/*
|
... | ... | |
799 |
797 |
|
800 |
798 |
gdbmswriter.postProcess();
|
801 |
799 |
*/
|
802 |
|
|
|
800 |
|
803 |
801 |
}
|
804 |
802 |
|
805 |
803 |
} catch (Exception e) {
|
... | ... | |
905 |
903 |
* @throws IOException
|
906 |
904 |
*/
|
907 |
905 |
public void addRow(IRow[] rows) throws DriverIOException, IOException {
|
908 |
|
try {
|
|
906 |
IEditableSource ies=getModel().getModelo();
|
|
907 |
try {
|
909 |
908 |
if (rows == null) {
|
|
909 |
|
910 |
910 |
if (getModel().getAssociatedTable()!=null){
|
911 |
911 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),"No se puede a?adir una fila a una tabla asociada a una capa.");
|
912 |
912 |
return;
|
... | ... | |
920 |
920 |
values[i]=ValueFactory.createNullValue();
|
921 |
921 |
}
|
922 |
922 |
row = new DefaultRow(values);
|
923 |
|
getModel().getModelo().addRow(row,"Fila en blanco",EditionEvent.ALPHANUMERIC);
|
|
923 |
ies.addRow(row,"Fila en blanco",EditionEvent.ALPHANUMERIC);
|
924 |
924 |
} else {
|
925 |
|
getModel().getModelo().startComplexRow();
|
|
925 |
ies.startComplexRow();
|
926 |
926 |
for (int i = 0; i < rows.length; i++) {
|
927 |
|
getModel().getModelo().addRow(((IRowEdited) rows[i]).getLinkedRow(),"Pegar filas",EditionEvent.ALPHANUMERIC);
|
|
927 |
ies.addRow(((IRowEdited) rows[i]).getLinkedRow(),"Pegar filas",EditionEvent.ALPHANUMERIC);
|
928 |
928 |
}
|
929 |
|
getModel().getModelo().endComplexRow();
|
|
929 |
ies.endComplexRow();
|
930 |
930 |
}
|
931 |
931 |
} catch (DriverException e) {
|
932 |
932 |
// TODO Auto-generated catch block
|
... | ... | |
1141 |
1141 |
return null;
|
1142 |
1142 |
}
|
1143 |
1143 |
col--;
|
1144 |
|
|
|
1144 |
int numRow;
|
|
1145 |
if (orderIndexes != null && row < orderIndexes.length) {
|
|
1146 |
numRow=(int)orderIndexes[row];
|
|
1147 |
}else {
|
|
1148 |
numRow=row;
|
|
1149 |
}
|
1145 |
1150 |
try {
|
1146 |
|
if (orderIndexes != null) {
|
1147 |
|
Object obj =null;
|
1148 |
|
|
1149 |
|
IRowEdited rowEdited=des.getRow((int)orderIndexes[row]);
|
1150 |
|
obj= rowEdited.getAttribute(mapping[col]);
|
|
1151 |
Object obj =null;
|
|
1152 |
IRowEdited rowEdited=des.getRow(numRow);
|
|
1153 |
obj= rowEdited.getAttribute(mapping[col]);
|
1151 |
1154 |
return obj;
|
1152 |
|
} else {
|
1153 |
|
Object obj =null;
|
1154 |
|
|
1155 |
|
IRowEdited rowEdited=des.getRow(row);
|
1156 |
|
obj= rowEdited.getAttribute(mapping[col]);
|
1157 |
|
//obj = sds.getFieldValue(row, col);
|
1158 |
|
return obj;
|
1159 |
|
}
|
1160 |
|
} catch (DriverIOException e1) {
|
1161 |
|
return ValueFactory.createValue("").toString();
|
1162 |
|
} catch (IOException e1) {
|
1163 |
|
return ValueFactory.createValue("").toString();
|
1164 |
|
}
|
|
1155 |
} catch (DriverIOException e1) {
|
|
1156 |
return ValueFactory.createValue("").toString();
|
|
1157 |
} catch (IOException e1) {
|
|
1158 |
return ValueFactory.createValue("").toString();
|
|
1159 |
}
|
1165 |
1160 |
}
|
1166 |
1161 |
|
1167 |
1162 |
/**
|
... | ... | |
1193 |
1188 |
throw new UnsupportedOperationException("Row Number is a read-only column");
|
1194 |
1189 |
columnIndex--;
|
1195 |
1190 |
Value v;
|
1196 |
|
if (getValueAt(rowIndex,columnIndex+1)==null || getValueAt(rowIndex,columnIndex+1).toString().equals(aValue))
|
|
1191 |
int numRow;
|
|
1192 |
if (orderIndexes != null) {
|
|
1193 |
numRow=(int)orderIndexes[rowIndex];
|
|
1194 |
}else {
|
|
1195 |
numRow=rowIndex;
|
|
1196 |
}
|
|
1197 |
if (getValueAt(rowIndex,columnIndex+1)==null || getValueAt(rowIndex,columnIndex+1).toString().equals(aValue))
|
1197 |
1198 |
return;
|
1198 |
1199 |
try {
|
1199 |
1200 |
v = ValueFactory.createValueByType(aValue.toString(),
|
1200 |
1201 |
des.getRecordset().getFieldType(columnIndex));
|
1201 |
1202 |
|
1202 |
|
IRowEdited row = des.getRow(rowIndex); //.getAttribute(columnIndex);
|
|
1203 |
IRowEdited row = des.getRow(numRow); //.getAttribute(columnIndex);
|
1203 |
1204 |
Value[] values = row.getAttributes();
|
1204 |
1205 |
values[columnIndex] = v;
|
1205 |
1206 |
|
... | ... | |
1212 |
1213 |
newRow = new DefaultRow(values,row.getID());
|
1213 |
1214 |
}
|
1214 |
1215 |
|
1215 |
|
des.modifyRow(rowIndex, newRow,"Editar valor", EditionEvent.ALPHANUMERIC);
|
|
1216 |
des.modifyRow(numRow, newRow,"Editar valor", EditionEvent.ALPHANUMERIC);
|
1216 |
1217 |
} catch (DriverException e1) {
|
1217 |
1218 |
throw new RuntimeException(e1);
|
1218 |
1219 |
} catch (ParseException e) {
|
... | ... | |
1533 |
1534 |
frame.getContentPane().add(tf);
|
1534 |
1535 |
frame.show(true);
|
1535 |
1536 |
}
|
1536 |
|
|
|
1537 |
|
1537 |
1538 |
public void stopEditingCell() {
|
1538 |
1539 |
if (table.isEditing()) {
|
1539 |
1540 |
// TODO: finalizar la edicion de la columna
|
1540 |
1541 |
this.table.getCellEditor().stopCellEditing();
|
1541 |
1542 |
this.refresh();
|
1542 |
1543 |
}
|
1543 |
|
|
|
1544 |
|
1544 |
1545 |
}
|
1545 |
|
|
|
1546 |
|
1546 |
1547 |
public void cancelEditingCell() {
|
1547 |
1548 |
if (table.isEditing()) {
|
1548 |
1549 |
// TODO: finalizar la edicion de la columna
|
1549 |
1550 |
this.table.getCellEditor().cancelCellEditing();
|
1550 |
1551 |
this.refresh();
|
1551 |
1552 |
}
|
1552 |
|
|
|
1553 |
|
1553 |
1554 |
}
|
1554 |
1555 |
}
|