Revision 21359 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/gui/Table.java
Table.java | ||
---|---|---|
71 | 71 |
import javax.swing.table.TableColumn; |
72 | 72 |
|
73 | 73 |
import org.apache.log4j.Logger; |
74 |
import org.gvsig.data.ReadException; |
|
75 |
import org.gvsig.data.WriteException; |
|
76 |
import org.gvsig.data.vectorial.FeatureAttributeDescriptor; |
|
77 |
import org.gvsig.data.vectorial.FeatureStore; |
|
74 | 78 |
import org.gvsig.fmap.core.features.DefaultRow; |
75 | 79 |
import org.gvsig.fmap.core.features.IRow; |
76 | 80 |
import org.gvsig.fmap.core.features.IRowEdited; |
... | ... | |
101 | 105 |
import org.gvsig.fmap.mapcontext.layers.SelectionEvent; |
102 | 106 |
import org.gvsig.fmap.mapcontext.layers.SelectionListener; |
103 | 107 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
108 |
import org.gvsig.util.observer.Observable; |
|
109 |
import org.gvsig.util.observer.Observer; |
|
104 | 110 |
|
105 | 111 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
106 | 112 |
import com.hardcode.gdbms.driver.exceptions.WriteDriverException; |
... | ... | |
130 | 136 |
* @author Fernando Gonz?lez Cort?s |
131 | 137 |
*/ |
132 | 138 |
public class Table extends JPanel implements SingletonWindow, EditionTable, |
133 |
IWindowListener,CommandListener, IWindowTransform, IEditionListener {
|
|
139 |
IWindowListener,Observer, IWindowTransform, IEditionListener {
|
|
134 | 140 |
private static Logger logger = Logger.getLogger(Table.class.getName()); |
135 | 141 |
private javax.swing.JScrollPane jScrollPane = null; |
136 | 142 |
protected javax.swing.JTable table = null; |
... | ... | |
247 | 253 |
model.getModelo().getRecordset().addSelectionListener(selectionListener); |
248 | 254 |
|
249 | 255 |
updateSelection(); |
250 |
} catch (ReadDriverException e) {
|
|
256 |
} catch (ReadException e) { |
|
251 | 257 |
NotificationManager.addError("No se pudo leer la informaci?n", e); |
252 | 258 |
} |
253 | 259 |
} |
... | ... | |
273 | 279 |
} |
274 | 280 |
}); |
275 | 281 |
|
276 |
IEditableSource ies=getModel().getModelo(); |
|
277 |
ies.addEditionListener(this); |
|
282 |
FeatureStore fs=getModel().getModelo(); |
|
283 |
fs.addObserver(this); |
|
284 |
// ies.addEditionListener(this); |
|
278 | 285 |
|
279 | 286 |
refreshControls(); |
280 | 287 |
|
... | ... | |
846 | 853 |
* @throws DriverIOException |
847 | 854 |
* @throws IOException |
848 | 855 |
*/ |
849 |
public void addRow(IRow[] rows) throws ValidateRowException, ReadDriverException, ExpansionFileWriteException {
|
|
856 |
public void addRow(IRow[] rows) throws ReadException {
|
|
850 | 857 |
IEditableSource ies=getModel().getModelo(); |
851 | 858 |
if (rows == null) { |
852 | 859 |
|
... | ... | |
887 | 894 |
* @throws DriverIOException |
888 | 895 |
* @throws IOException |
889 | 896 |
*/ |
890 |
public void copyRow() throws ReadDriverException, ExpansionFileReadException {
|
|
897 |
public void copyRow() throws ReadException { |
|
891 | 898 |
int[] index = getSelectedRowIndices(); |
892 | 899 |
rowsCopied = new IRow[index.length]; |
893 | 900 |
|
... | ... | |
904 | 911 |
* @throws DriverIOException |
905 | 912 |
* @throws IOException |
906 | 913 |
*/ |
907 |
public void cutRow() throws ReadDriverException, ExpansionFileReadException {
|
|
914 |
public void cutRow() throws ReadException { |
|
908 | 915 |
int[] index = getSelectedRowIndices(); |
909 | 916 |
rowsCopied = new IRow[index.length]; |
910 | 917 |
|
... | ... | |
923 | 930 |
* @throws DriverIOException |
924 | 931 |
* @throws IOException |
925 | 932 |
*/ |
926 |
public void removeRow() throws ReadDriverException, ExpansionFileReadException{
|
|
933 |
public void removeRow() throws ReadException{ |
|
927 | 934 |
int[] index = getSelectedRowIndices(); |
928 | 935 |
getModel().getModelo().startComplexRow(); |
929 | 936 |
for (int i = index.length-1; i >=0; i--) { |
... | ... | |
961 | 968 |
/** |
962 | 969 |
* DOCUMENT ME! |
963 | 970 |
*/ |
964 |
public void addColumn(FieldDescription newField) {
|
|
965 |
EditableAdapter edAdapter = (EditableAdapter) getModel().getModelo();
|
|
971 |
public void addColumn(FeatureAttributeDescriptor newField) {
|
|
972 |
FeatureStore featureStore = getModel().getModelo();
|
|
966 | 973 |
try { |
967 |
edAdapter.addField(newField); |
|
968 |
} catch (ReadDriverException e) { |
|
974 |
featureStore.startEditing(); |
|
975 |
featureStore.getDefaultFeatureType().add(newField); |
|
976 |
// edAdapter.addField(newField); |
|
977 |
} catch (ReadException e) { |
|
969 | 978 |
e.printStackTrace(); |
970 | 979 |
NotificationManager.addError(e); |
971 | 980 |
} |
972 | 981 |
if (getTable().getCellEditor() != null) |
973 | 982 |
getTable().getCellEditor().cancelCellEditing(); |
974 |
getModel().setModel(edAdapter); // Para que se recalculen los campos. TODO: Limpiear todo esto
|
|
983 |
getModel().setModel(featureStore); // Para que se recalculen los campos. TODO: Limpiear todo esto
|
|
975 | 984 |
// refresh(); |
976 | 985 |
refreshControls(); |
977 | 986 |
} |
... | ... | |
980 | 989 |
* DOCUMENT ME! |
981 | 990 |
*/ |
982 | 991 |
public void removeColumn() { |
983 |
EditableAdapter edAdapter = (EditableAdapter) getModel().getModelo();
|
|
992 |
FeatureStore featureStore = getModel().getModelo();
|
|
984 | 993 |
try { |
985 | 994 |
BitSet selectedFields = getSelectedFieldIndices(); |
986 |
SelectableDataSource sds = edAdapter.getRecordset(); |
|
987 |
edAdapter.startComplexRow(); |
|
988 |
FieldDescription[] auxFlds = sds.getFieldsDescription(); |
|
995 |
// SelectableDataSource sds = edAdapter.getRecordset(); |
|
996 |
// edAdapter.startComplexRow(); |
|
997 |
featureStore.startEditing(); |
|
998 |
FeatureAttributeDescriptor[] fads=(FeatureAttributeDescriptor[])featureStore.getDefaultFeatureType().toArray(new FeatureAttributeDescriptor[0]); |
|
999 |
// FieldDescription[] auxFlds = sds.getFieldsDescription(); |
|
989 | 1000 |
for(int i=selectedFields.nextSetBit(0); i>=0; i=selectedFields.nextSetBit(i+1)) { |
990 |
FieldDescription fld = auxFlds[i]; |
|
991 |
edAdapter.removeField(fld.getFieldAlias()); |
|
1001 |
FeatureAttributeDescriptor fld = fads[i]; |
|
1002 |
featureStore.getDefaultFeatureType().remove(i); |
|
1003 |
// edAdapter.removeField(fld.getFieldAlias()); |
|
1004 |
|
|
992 | 1005 |
} |
993 | 1006 |
if (getTable().getCellEditor() != null) |
994 | 1007 |
getTable().getCellEditor().cancelCellEditing(); |
995 | 1008 |
|
996 |
edAdapter.endComplexRow(PluginServices.getText(this, "remove_fields")); |
|
1009 |
// edAdapter.endComplexRow(PluginServices.getText(this, "remove_fields"));
|
|
997 | 1010 |
clearSelectedFields(); |
998 |
getModel().setModel(edAdapter); // Para que se recalculen los campos. TODO: Limpiear todo esto
|
|
1011 |
getModel().setModel(featureStore); // Para que se recalculen los campos. TODO: Limpiear todo esto
|
|
999 | 1012 |
// refresh(); |
1000 | 1013 |
refreshControls(); |
1001 |
} catch (ReadDriverException e) {
|
|
1014 |
} catch (ReadException e) { |
|
1002 | 1015 |
e.printStackTrace(); |
1003 | 1016 |
NotificationManager.addError(e); |
1004 |
} catch (WriteDriverException e) {
|
|
1017 |
} catch (WriteException e) { |
|
1005 | 1018 |
e.printStackTrace(); |
1006 | 1019 |
NotificationManager.addError(e); |
1007 | 1020 |
} |
... | ... | |
1026 | 1039 |
* @throws DriverIOException |
1027 | 1040 |
* @throws IOException |
1028 | 1041 |
*/ |
1029 |
public void pasteRow() throws ValidateRowException, ReadDriverException, ExpansionFileWriteException {
|
|
1042 |
public void pasteRow() throws ReadException {
|
|
1030 | 1043 |
addRow(rowsCopied); |
1031 | 1044 |
//repaintAssociatedView(); |
1032 | 1045 |
} |
... | ... | |
1141 | 1154 |
*/ |
1142 | 1155 |
} |
1143 | 1156 |
|
1144 |
public void commandRepaint() { |
|
1145 |
refresh(); |
|
1146 |
} |
|
1157 |
// public void commandRepaint() { |
|
1158 |
// refresh(); |
|
1159 |
// } |
|
1160 |
// |
|
1161 |
// public void commandRefresh() { |
|
1162 |
// commandRepaint(); |
|
1163 |
// } |
|
1147 | 1164 |
|
1148 |
public void commandRefresh() { |
|
1149 |
commandRepaint(); |
|
1150 |
} |
|
1151 |
|
|
1152 | 1165 |
public void toPalette() { |
1153 | 1166 |
isPalette=true; |
1154 | 1167 |
m_viewInfo.toPalette(true); |
... | ... | |
1226 | 1239 |
// ((DataSourceDataModel) getTable().getModel()).fireTableDataChanged(); |
1227 | 1240 |
|
1228 | 1241 |
} |
1242 |
|
|
1243 |
public void update(Observable observable, Object notification) { |
|
1244 |
refresh(); |
|
1245 |
} |
|
1229 | 1246 |
} |
Also available in: Unified diff