Revision 6259

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/TableEditRemoveColumnExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig;
42

  
43
import com.iver.andami.PluginServices;
44
import com.iver.andami.plugins.Extension;
45
import com.iver.andami.ui.mdiManager.View;
46
import com.iver.cit.gvsig.gui.Table;
47

  
48

  
49
/**
50
 * DOCUMENT ME!
51
 *
52
 * @author Vicente Caballero Navarro
53
 */
54
public class TableEditRemoveColumnExtension extends Extension {
55
    /**
56
     * @see com.iver.andami.plugins.IExtension#initialize()
57
     */
58
    public void initialize() {
59
    }
60

  
61
    /**
62
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
63
     */
64
    public void execute(String actionCommand) {
65
        if ("REMOVECOLUMN".equals(actionCommand)) {
66
            View v = PluginServices.getMDIManager().getActiveView();
67
            ((Table) v).removeColumn();
68

  
69
        }
70
    }
71

  
72
    /**
73
     * @see com.iver.andami.plugins.IExtension#isEnabled()
74
     */
75
    public boolean isEnabled() {
76
    	View v = PluginServices.getMDIManager().getActiveView();
77

  
78
        if (v == null) {
79
            return false;
80
        }
81

  
82
        if (v.getClass() == Table.class) {
83
            return (((Table) v).isEditing()) && ((Table) v).getSelectedFieldIndices().cardinality()>0;
84
        }
85

  
86
        return false;
87
    }
88

  
89
    /**
90
     * @see com.iver.andami.plugins.IExtension#isVisible()
91
     */
92
    public boolean isVisible() {
93
        View v = PluginServices.getMDIManager().getActiveView();
94

  
95
        if (v == null) {
96
            return false;
97
        } else if (v instanceof Table && ((Table) v).isEditing()) {
98
            return true;
99
        } else {
100
            return false;
101
        }
102
    }
103
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/TableFieldOperations.java
34 34
		View v = PluginServices.getMDIManager().getActiveView();
35 35

  
36 36
		if (v != null) {
37
			if (v.getClass() == Table.class) {
37
			if (v instanceof Table) {
38 38

  
39 39
			    Table table = (Table) v;
40 40

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/TableEditChangeColumnsExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig;
42

  
43
import java.sql.Types;
44

  
45
import com.hardcode.gdbms.engine.values.ValueFactory;
46
import com.iver.andami.PluginServices;
47
import com.iver.andami.plugins.Extension;
48
import com.iver.andami.ui.mdiManager.View;
49
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
50
import com.iver.cit.gvsig.gui.Table;
51

  
52

  
53
/**
54
 * DOCUMENT ME!
55
 *
56
 * @author Vicente Caballero Navarro
57
 */
58
public class TableEditChangeColumnsExtension extends Extension {
59
    /**
60
     * @see com.iver.andami.plugins.IExtension#initialize()
61
     */
62
    public void initialize() {
63
    }
64

  
65
    /**
66
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
67
     */
68
    public void execute(String actionCommand) {
69
        View v = PluginServices.getMDIManager().getActiveView();
70
        Table t = (Table) v;
71
        if ("REMOVECOLUMN".equals(actionCommand)) {
72
            t.removeColumn();
73

  
74
        }
75
        if ("ADDCOLUMN".equals(actionCommand)) {
76
        	FieldDescription newField = new FieldDescription();
77
        	newField.setDefaultValue(ValueFactory.createValue("default"));
78
        	newField.setFieldName("prueba");
79
        	newField.setFieldType(Types.VARCHAR);
80
        	newField.setFieldLength(20);
81

  
82
            t.addColumn(newField);
83
        }
84
        if ("RENAMECOLUMN".equals(actionCommand)) {
85
        	// TODO RENAME
86
            // t.addColumn();
87
        }
88
        
89
    }
90

  
91
    /**
92
     * @see com.iver.andami.plugins.IExtension#isEnabled()
93
     */
94
    public boolean isEnabled() {
95
    	View v = PluginServices.getMDIManager().getActiveView();
96

  
97
        if (v == null) {
98
            return false;
99
        }
100

  
101
        if (v instanceof Table) {
102
            return (((Table) v).isEditing()) && ((Table) v).getSelectedFieldIndices().cardinality()>0;
103
        }
104

  
105
        return false;
106
    }
107

  
108
    /**
109
     * @see com.iver.andami.plugins.IExtension#isVisible()
110
     */
111
    public boolean isVisible() {
112
        View v = PluginServices.getMDIManager().getActiveView();
113

  
114
        if (v == null) {
115
            return false;
116
        } else if (v instanceof Table && ((Table) v).isEditing()) {
117
            return true;
118
        } else {
119
            return false;
120
        }
121
    }
122
}
0 123

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/TableEditInsertExtension.java
78 78
			}
79 79
        }
80 80

  
81
        if ("INSERTCOLUMN".equals(actionCommand)) {
82
            View v = PluginServices.getMDIManager().getActiveView();
83
                ((Table) v).addColumn();
84
        }
85 81
    }
86 82

  
87 83
    /**
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Table.java
50 50
import java.beans.PropertyChangeEvent;
51 51
import java.beans.PropertyChangeListener;
52 52
import java.io.IOException;
53
import java.sql.Types;
53 54
import java.text.ParseException;
54 55
import java.util.BitSet;
55 56
import java.util.Enumeration;
......
97 98
import com.iver.cit.gvsig.fmap.core.IGeometry;
98 99
import com.iver.cit.gvsig.fmap.core.IRow;
99 100
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
101
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
100 102
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition;
103
import com.iver.cit.gvsig.fmap.edition.EditableAdapter;
101 104
import com.iver.cit.gvsig.fmap.edition.EditionEvent;
102 105
import com.iver.cit.gvsig.fmap.edition.EditionException;
103 106
import com.iver.cit.gvsig.fmap.edition.IEditableSource;
......
218 221
			    column = table.getColumnModel().getColumn(i);
219 222
			    int w=model.getColumn(i).getWidth();
220 223
			    column.setPreferredWidth(w); //sport column is bigger
224
			    System.err.println("Table.Dentro de refreshControls. column=" + column.toString());
221 225

  
222 226
			}
223 227
			headerSelectionSupport.setTableHeader(getTable().getTableHeader());
......
851 855
    /**
852 856
     * DOCUMENT ME!
853 857
     *
854
     * @return DOCUMENT ME!
855
     */
856
    public int[] getSelectedColumns() {
857
        return null;
858
    }
859

  
860
    /**
861
     * DOCUMENT ME!
862
     *
863 858
     * @throws IOException DOCUMENT ME!
864 859
     */
865 860
    public void cancelEditing() throws IOException {
......
1021 1016
    /**
1022 1017
     * DOCUMENT ME!
1023 1018
     */
1024
    public void addColumn() {
1025
        // TODO Auto-generated method stub
1026
        refresh();
1027
        //repaintAssociatedView();
1019
    public void addColumn(FieldDescription newField) {
1020
    	EditableAdapter edAdapter = (EditableAdapter) getModel().getModelo();
1021
    	try {
1022
			edAdapter.addField(newField);
1023
			if (getTable().getCellEditor() != null)
1024
				getTable().getCellEditor().cancelCellEditing();
1025
	
1026
	        refresh();
1027
	        refreshControls();
1028
		} catch (EditionException e) {
1029
			e.printStackTrace();
1030
			NotificationManager.addError(e);
1031
		}
1032

  
1028 1033
    }
1029 1034

  
1030 1035
    /**
1031 1036
     * DOCUMENT ME!
1032 1037
     */
1033 1038
    public void removeColumn() {
1034
        // TODO Auto-generated method stub
1035
        refresh();
1036
        //repaintAssociatedView();
1039
    	EditableAdapter edAdapter = (EditableAdapter) getModel().getModelo();
1040
    	try {
1041
    		BitSet selectedFields = getSelectedFieldIndices();
1042
    		SelectableDataSource sds = edAdapter.getRecordset();
1043
    		edAdapter.startComplexRow();
1044
    		for(int i=selectedFields.nextSetBit(0); i>=0; i=selectedFields.nextSetBit(i+1)) {
1045
    			FieldDescription fld = sds.getFieldsDescription()[i];
1046
    			edAdapter.removeField(fld.getFieldAlias());
1047
    		}
1048
    		if (getTable().getCellEditor() != null)
1049
				getTable().getCellEditor().cancelCellEditing();
1050
	
1051
	        edAdapter.endComplexRow(PluginServices.getText(this, "remove_fields"));
1052
	
1053
	        getModel().setModel(edAdapter); // Para que se recalculen los campos. TODO: Limpiear todo esto 
1054
	        refresh();
1055
	        refreshControls();
1056
		} catch (EditionException e) {
1057
			e.printStackTrace();
1058
			NotificationManager.addError(e);
1059
		} catch (DriverException e) {
1060
			e.printStackTrace();
1061
			NotificationManager.addError(e);
1062
		} catch (IOException e) {
1063
			e.printStackTrace();
1064
			NotificationManager.addError(e);
1065
		} catch (DriverIOException e) {
1066
			e.printStackTrace();
1067
			NotificationManager.addError(e);
1068
		}
1069

  
1037 1070
    }
1038 1071

  
1039 1072
    /**
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/tables/EditionTable.java
5 5
import com.hardcode.gdbms.engine.values.Value;
6 6
import com.iver.cit.gvsig.fmap.core.IRow;
7 7
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
8
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
8 9
import com.iver.cit.gvsig.fmap.edition.EditionException;
9 10

  
10 11
import javax.swing.JPanel;
......
61 62
     *
62 63
     * @return DOCUMENT ME!
63 64
     */
64
    public int[] getSelectedColumns();
65
    // public int[] getSelectedColumns();
65 66

  
66 67
    /**
67 68
     * DOCUMENT ME!
......
84 85
    public void copyRow() throws DriverIOException, IOException;
85 86
    public void cutRow() throws DriverIOException, IOException;
86 87
    public void removeRow() throws DriverIOException, IOException;
87
    public void addColumn();
88
    public void addColumn(FieldDescription fld);
88 89
    public void removeColumn();
89 90
    public boolean isCopied();
90 91
    public void pasteRow() throws DriverIOException, IOException;
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LayerFactory.java
201 201

  
202 202
    public static FLayer createLayer(String layerName, VectorialDriver d,
203 203
            IProjection proj) throws DriverException {
204
            //TODO Comprobar si hay un adaptador ya
205
            VectorialDefaultAdapter adapter = new VectorialDefaultAdapter();
204
    		VectorialAdapter adapter = null;
205
            if (d instanceof VectorialFileDriver)
206
            {            	
207
            	adapter = new VectorialFileAdapter(((VectorialFileDriver)d).getFile());
208
            }
209
            else
210
            {
211
            	adapter = new VectorialDefaultAdapter();
212
            }
206 213
            adapter.setDriver((VectorialDriver) d);
207 214

  
208 215
            FLyrVect capa = new FLyrVect();
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLayers.java
423 423
    			        	}
424 424
    			        	else */
425 425

  
426
    			        	if (lyr.isCachingDrawnLayers())
426
     			        	if (lyr.isCachingDrawnLayers())
427 427
    			        	{
428 428
    			        		// if ((bNeedRecalculateCache) || (lyr.getCacheImageDrawnLayers()==null))
429 429
    			        		// {
......
433 433
    			        			BufferedImage buff = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
434 434
    			        			WritableRaster w = buff.getRaster(); 
435 435
    			        			image.copyData(w);
436
//    			        			Graphics2D gAux = buff.createGraphics();
437
//    			        			gAux.drawString(lyr.getName(), 50,50);
438 436
    			        			lyr.setCacheImageDrawnLayers(buff);
439 437
    			        			System.err.println("RECALCULO LA CACHE CON LO QUE HABIA ANTES DE " + lyr.getName());
440 438
    			        		}
......
453 451
	    			        			}
454 452
	    			        		}
455 453
//    			        		}
456
    			        	}
454
    			        	} 
457 455
    			        	// Si la capa est? "sucia" o alguna de las de abajo est? sucia
458 456
    			        	// hay que volver a dibujar.
459 457
   			        		if (lyr.isDirty() || bNeedRecalculateCache)
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/SelectableDataSource.java
91 91
		dataSource = ds;
92 92
		dataSource.start();
93 93
		// Creamos el mapping de campos externos que no muestran el PK.
94
		mapExternalFields();
95

  
96

  
97
	}
98

  
99
	/**
100
	 * @throws DriverException
101
	 */
102
	public void mapExternalFields() throws DriverException {
94 103
		int numExternalFields = 0;
95 104
		for (int i=0; i < dataSource.getFieldCount(); i++)
96 105
		{
......
107 116
				mapping[j++] = i;
108 117
				
109 118
		}
110

  
111

  
112 119
	}
113 120

  
114 121
	public static SelectableDataSource createSelectableDataSource(XMLEntity xml) throws NoSuchTableException, ParseException, DriverLoadException, DriverException, SemanticException, IOException, XMLException{
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/shp/IndexedShpDriver.java
983 983
	{
984 984
		return this;
985 985
	}
986

  
987
	public ITableDefinition getTableDefinition() {
988
		return shpWriter.getTableDefinition();
989
	}
986 990
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dbf/DBFDriver.java
371 371

  
372 372
	}
373 373

  
374
	public ITableDefinition getTableDefinition() {
375
		return dbfWriter.getTableDefinition();
376
	}
377

  
374 378
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dxf/DXFMemoryDriver.java
885 885
		return this;
886 886
	}
887 887

  
888
	public ITableDefinition getTableDefinition() {
889
		return dxfWriter.getTableDefinition();
890
	}
891

  
888 892
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/ShpStrategy.java
207 207
			// SpatialCache cache = lyr.createSpatialCache();
208 208
			lyr.getSpatialCache().clearAll();
209 209
			SpatialCache cache = lyr.getSpatialCache();
210
			// lyr.setSpatialCacheEnabled(true);
211 210
			int i;
212 211
			for (int aux = 0; aux < sc; aux++) {
213 212
				// Salimos si alguien cancela
......
238 237

  
239 238
					if (bPoint
240 239
							|| ((bounds.getHeight() > viewPort.getDist1pixel()) || (bounds
241
									.getWidth() > viewPort.getDist1pixel()))) {
240
									.getWidth() > viewPort.getDist1pixel()))) { 
242 241
						geom = adapter.getShape(i);
243 242

  
244 243
						// PRUEBA DE VELOCIDAD
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/dxf/DxfWriter.java
91 91
	 * @throws EditionException
92 92
	 */
93 93
	public void initialize(ITableDefinition lyrDef) throws EditionException {
94
		super.initialize(lyrDef);
94 95
		fieldsDesc = lyrDef.getFieldsDesc();
95 96
	}
96 97

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/shp/ShpWriter.java
151 151
	 */
152 152
	public void initialize(ITableDefinition lyrDef) throws EditionException
153 153
	{
154
		super.initialize(lyrDef);
154 155
		myHeader = DbaseFileHeaderNIO.createDbaseHeader(lyrDef.getFieldsDesc());
155 156
		try {
156 157
			initialize(shpFile, ((ILayerDefinition)lyrDef).getShapeType());
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/shp/MultiShpWriter.java
260 260
	public String getName() {
261 261
		return "MULTI File Writer";
262 262
	}
263

  
264
	public ITableDefinition getTableDefinition() {
265
		return layerDefinition;
266
	}
263 267
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/dbf/DbfWriter.java
156 156

  
157 157
	public void initialize(ITableDefinition tableDefinition)
158 158
			throws EditionException {
159
		super.initialize(tableDefinition);
159 160
		originalFields = tableDefinition.getFieldsDesc();
160 161
		myHeader = DbaseFileHeaderNIO.createDbaseHeader(tableDefinition
161 162
				.getFieldsDesc());
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/JdbcWriter.java
161 161
	public void setWriteAll(boolean writeAll) {
162 162
		bWriteAll = writeAll;
163 163
	}
164
	public void initialize(ITableDefinition tableDefinition) throws EditionException {
165
		// TODO Auto-generated method stub
166
		
167
	}
168 164

  
169 165
	public void close() throws SQLException
170 166
	{
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/AbstractWriter.java
2 2

  
3 3
import java.util.Properties;
4 4

  
5
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition;
5 6
import com.iver.cit.gvsig.fmap.edition.EditionException;
6 7
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
7 8
import com.iver.cit.gvsig.fmap.edition.IWriter;
8 9

  
9 10
public abstract class AbstractWriter implements IWriter {
10 11
	protected Properties capabilities = new Properties();
12
	protected ITableDefinition tableDef;
11 13
	
12 14
	/**
13 15
	 * A developer can use this Properties for his own purposes. For example, to
......
31 33

  
32 34
	// public abstract boolean canWriteGeometry(int gvSIGgeometryType);
33 35
	public abstract boolean canWriteAttribute(int sqlType);
36
	
37
	public void initialize(ITableDefinition tableDefinition) throws EditionException {
38
		this.tableDef = tableDefinition;
39
		
40
	}
34 41

  
42
	public ITableDefinition getTableDefinition() {
43
		return tableDef;
44
	}
45

  
46

  
35 47
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/commands/AddFieldCommand.java
44 44

  
45 45
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
46 46
import com.iver.cit.gvsig.fmap.edition.EditableAdapter;
47
import com.iver.cit.gvsig.fmap.edition.EditionException;
47 48
import com.iver.cit.gvsig.fmap.edition.InternalField;
48 49

  
49 50
public class AddFieldCommand extends AbstractCommand {
......
59 60
	
60 61

  
61 62
	public void undo() throws DriverIOException, IOException {
62
		edAdapter.undoAddField(field);
63
		try {
64
			edAdapter.undoAddField(field);
65
		} catch (EditionException e) {
66
			// TODO Auto-generated catch block
67
			e.printStackTrace();
68
		}
63 69
	}
64 70

  
65 71
	public void redo() throws DriverIOException, IOException {
66
		edAdapter.doAddField(field);
72
		try {
73
			edAdapter.doAddField(field);
74
		} catch (EditionException e) {
75
			// TODO Auto-generated catch block
76
			e.printStackTrace();
77
		}
67 78
		
68 79
	}
69 80

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/commands/RemoveFieldCommand.java
44 44

  
45 45
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
46 46
import com.iver.cit.gvsig.fmap.edition.EditableAdapter;
47
import com.iver.cit.gvsig.fmap.edition.EditionException;
47 48
import com.iver.cit.gvsig.fmap.edition.InternalField;
48 49

  
49 50
public class RemoveFieldCommand extends AbstractCommand {
......
59 60
	
60 61

  
61 62
	public void undo() throws DriverIOException, IOException {
62
		edAdapter.undoRemoveField(field);
63
		try {
64
			edAdapter.undoRemoveField(field);
65
		} catch (EditionException e) {
66
			// TODO Auto-generated catch block
67
			e.printStackTrace();
68
		}
63 69
	}
64 70

  
65 71
	public void redo() throws DriverIOException, IOException {
66
		edAdapter.doRemoveField(field);
72
		try {
73
			edAdapter.doRemoveField(field);
74
		} catch (EditionException e) {
75
			// TODO Auto-generated catch block
76
			e.printStackTrace();
77
		}
67 78
		
68 79
	}
69 80

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/IWriter.java
27 27

  
28 28
	public abstract boolean canWriteAttribute(int sqlType);
29 29

  
30

  
31
	// TODO: Quiz?s sea necesario algo como esto
32 30
	public void initialize(ITableDefinition tableDefinition) throws EditionException ;
33 31

  
32
	public ITableDefinition getTableDefinition();
34 33

  
35

  
36 34
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditableAdapter.java
162 162
			field.setFieldIndex(i);
163 163
			actualFields.put(field.getFieldId(), field);
164 164
		}
165
		fieldsChanged();
165
		try {
166
			fieldsChanged();
167
		} catch (EditionException e) {
168
			e.printStackTrace();
169
			throw new DriverException(e);
170
		}
166 171
		
167 172
	}
168 173

  
169
	private void fieldsChanged() {
174
	private void fieldsChanged() throws EditionException {
170 175
		listInternalFields.add(actualFields);
171 176
		actualIndexFields = listInternalFields.size()-1;
177
		try {
178
			getRecordset().mapExternalFields();
179
		} catch (DriverLoadException e) {
180
			e.printStackTrace();
181
			throw new EditionException(e);
182
		} catch (DriverException e) {
183
			e.printStackTrace();
184
			throw new EditionException(e);
185
		}
172 186
	}
173 187

  
174 188
	/**
......
872 886
		public Value getFieldValue(long rowIndex, int fieldId)
873 887
				throws DriverException {
874 888
			// Si no est? en el fichero de expansi?n
875
			Integer integer = new Integer(getCalculatedIndex(rowIndex));
889
			// Integer integer = new Integer(getCalculatedIndex(rowIndex));
876 890

  
891

  
877 892
			try {
878
				if (!relations.containsKey(integer)) {
879
					return ods.getFieldValue(rowIndex, fieldId);
880
				} else {
881
					int num = ((Integer) relations.get(integer)).intValue();
882
					DefaultRowEdited feat = (DefaultRowEdited) expansionFile
883
							.getRow(num);
884

  
885
					if (feat == null) {
886
						return null;
887
					}
888

  
889
					return feat.getAttribute(fieldId);
890
				}
891
			} catch (DriverException e) {
893
				IRow row = getRow((int)rowIndex);
894
				return row.getAttribute(fieldId);
895
//				if (!relations.containsKey(integer)) {
896
//					return ods.getFieldValue(rowIndex, fieldId);
897
//				} else {
898
//					int num = ((Integer) relations.get(integer)).intValue();
899
//					DefaultRowEdited feat = (DefaultRowEdited) expansionFile
900
//							.getRow(num);
901
//
902
//					if (feat == null) {
903
//						return null;
904
//					}
905
//
906
//					return feat.getAttribute(fieldId);
907
//				}
908
//			} catch (DriverException e) {
909
//				e.printStackTrace();
910
//				throw new DriverException(e);
911
			} catch (IOException e) {
892 912
				e.printStackTrace();
893 913
				throw new DriverException(e);
894
			} catch (IOException e) {
914
			} catch (DriverIOException e) {
895 915
				e.printStackTrace();
896 916
				throw new DriverException(e);
897 917
			}
......
916 936
		 * @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldCount()
917 937
		 */
918 938
		public int getFieldCount() throws DriverException {
919
			// TODO Por ahora, no dejamos que se a?adan campos
920
			return ods.getFieldCount();
939
			return actualFields.size();
921 940
		}
922 941

  
923 942
		/*
......
926 945
		 * @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldName(int)
927 946
		 */
928 947
		public String getFieldName(int fieldId) throws DriverException {
929
			return ods.getFieldName(fieldId);
948
			
949
			for (Iterator iter = actualFields.values().iterator(); iter.hasNext();) {
950
				InternalField fld = (InternalField) iter.next();
951
				if (fld.getFieldIndex() == fieldId)
952
					return fld.getFieldDesc().getFieldAlias();
953
				
954
			}
955
			throw new DriverException("FieldId " + fieldId + " not found ");
956
			// return null;
957
			// return ods.getFieldName(fieldId);
930 958
		}
931 959

  
932 960
		/*
......
953 981
		 * @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldType(int)
954 982
		 */
955 983
		public int getFieldType(int i) throws DriverException {
984
			for (Iterator iter = actualFields.values().iterator(); iter.hasNext();) {
985
				InternalField fld = (InternalField) iter.next();
986
				if (fld.getFieldIndex() == i)
987
					return fld.getFieldDesc().getFieldType();
988
				
989
			}
990
			
956 991
			return ods.getFieldType(i);
957 992
		}
958 993

  
959 994
		public int getFieldWidth(int i) throws DriverException {
995
			for (Iterator iter = actualFields.values().iterator(); iter.hasNext();) {
996
				InternalField fld = (InternalField) iter.next();
997
				if (fld.getFieldIndex() == i)
998
					return fld.getFieldDesc().getFieldLength();
999
				
1000
			}
1001

  
960 1002
			return ods.getFieldWidth(i);
961 1003
		}
962 1004
	}
......
1176 1218
	public void removeField(String fieldName) throws EditionException {
1177 1219

  
1178 1220
		InternalField fld = findFieldByName(fieldName);
1221
		if (fld == null)
1222
			throw new EditionException("Field " + fieldName + " not found when removing field");
1179 1223
		Command command = new RemoveFieldCommand(this, fld);
1180 1224
		if (complex) {
1181 1225
			commands.add(command);
......
1198 1242
		return null;
1199 1243
	}
1200 1244

  
1201
	public void undoRemoveField(InternalField field) {
1245
	public void undoRemoveField(InternalField field) throws EditionException {
1202 1246
		field.setDeleted(false);
1203 1247
		field.setFieldIndex(actualFields.size());
1204 1248
		actualFields.put(field.getFieldId(), field);
1205 1249
		fieldsChanged();
1206 1250
	}
1207 1251

  
1208
	public void doRemoveField(InternalField field) {
1252
	public void doRemoveField(InternalField field) throws EditionException {
1209 1253
		field.setDeleted(true);
1210 1254
		actualFields.remove(field.getFieldId());
1211 1255
		fieldsChanged();
......
1247 1291

  
1248 1292
	}
1249 1293

  
1250
	public void undoAddField(InternalField field) {
1294
	public void undoAddField(InternalField field) throws EditionException {
1251 1295
		field.setDeleted(true);
1252 1296
		
1253 1297
		actualFields.remove(field.getFieldId());
......
1255 1299
		
1256 1300
	}
1257 1301

  
1258
	public void doAddField(InternalField field) {
1302
	public void doAddField(InternalField field) throws EditionException {
1259 1303
		field.setDeleted(false);
1260 1304
		field.setFieldIndex(actualFields.size());
1261 1305
		actualFields.put(field.getFieldId(), field);

Also available in: Unified diff