Revision 4430
trunk/extensions/extCAD/config/config.xml | ||
---|---|---|
17 | 17 |
<menu text="Vista/new_theme/new_postgis" action-command="POSTGIS"/> |
18 | 18 |
</extension> |
19 | 19 |
|
20 |
<extension class-name="com.iver.cit.gvsig.StopEditingToShp"
|
|
21 |
description="Extensi?n encargada de terminar la edici?n sobre la capa activa y guardarla en un shapefile."
|
|
20 |
<extension class-name="com.iver.cit.gvsig.StopEditing" |
|
21 |
description="Extensi?n encargada de terminar la edici?n sobre la capa activa y guardarla sobre s? misma."
|
|
22 | 22 |
active="true"> |
23 |
<menu text="Capa/terminar_edicion/shp" action-command="STOPEDITING"/>
|
|
23 |
<menu text="Capa/terminar_edicion" action-command="STOPEDITING"/> |
|
24 | 24 |
</extension> |
25 |
<extension class-name="com.iver.cit.gvsig.StopEditingToGT2Shp" |
|
25 |
<!-- <extension class-name="com.iver.cit.gvsig.StopEditingToGT2Shp"
|
|
26 | 26 |
description="Extensi?n encargada de terminar la edici?n sobre la capa activa y guardarla sobre s? misma si es un shapefile." |
27 | 27 |
active="true"> |
28 | 28 |
<menu text="Capa/terminar_edicion/GT2shp" action-command="STOPEDITING"/> |
29 |
</extension> |
|
29 |
</extension> -->
|
|
30 | 30 |
<extension class-name="com.iver.cit.gvsig.RedoViewExtension" |
31 | 31 |
description="Extensi?n encargada de rehacer la edici?n sobre la capa activa." |
32 | 32 |
active="true"> |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/EditionUtilities.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
3 | 5 |
import com.iver.andami.PluginServices; |
4 | 6 |
import com.iver.cit.gvsig.fmap.FMap; |
7 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
5 | 8 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
6 | 9 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
7 | 10 |
import com.iver.cit.gvsig.gui.View; |
... | ... | |
60 | 63 |
return status; |
61 | 64 |
} |
62 | 65 |
|
66 |
public static FLayer[] getActiveAndEditedLayers() |
|
67 |
{ |
|
68 |
int status = EDITION_STATUS_NO_EDITION; |
|
69 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
|
70 |
.getActiveView(); |
|
71 |
if (f == null) |
|
72 |
return null; |
|
73 |
|
|
74 |
if (f.getClass() == View.class) { |
|
75 |
View vista = (View) f; |
|
76 |
ProjectView model = vista.getModel(); |
|
77 |
FMap mapa = model.getMapContext(); |
|
78 |
|
|
79 |
ArrayList resul = new ArrayList(); |
|
80 |
|
|
81 |
FLayers capas = mapa.getLayers(); |
|
82 |
|
|
83 |
int numActiveVectorial = 0; |
|
84 |
int numActiveVectorialEditable = 0; |
|
85 |
for (int i = 0; i < capas.getLayersCount(); i++) { |
|
86 |
if (capas.getLayer(i) instanceof FLyrVect && |
|
87 |
capas.getLayer(i).isActive()) { |
|
88 |
numActiveVectorial++; |
|
89 |
if (capas.getLayer(i).isEditing()) |
|
90 |
{ |
|
91 |
numActiveVectorialEditable++; |
|
92 |
resul.add(capas.getLayer(i)); |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
96 |
return (FLayer[]) resul.toArray(new FLayer[0]); |
|
97 |
|
|
98 |
} |
|
99 |
|
|
100 |
return null; |
|
101 |
} |
|
102 |
|
|
63 | 103 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/StopEditing.java | ||
---|---|---|
6 | 6 |
|
7 | 7 |
import javax.swing.JFileChooser; |
8 | 8 |
|
9 |
import com.hardcode.driverManager.Driver; |
|
9 | 10 |
import com.iver.andami.PluginServices; |
10 | 11 |
import com.iver.andami.plugins.Extension; |
11 | 12 |
import com.iver.cit.gvsig.fmap.DriverException; |
12 | 13 |
import com.iver.cit.gvsig.fmap.FMap; |
13 | 14 |
import com.iver.cit.gvsig.fmap.MapControl; |
14 | 15 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
16 |
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
|
15 | 17 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
16 | 18 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
17 | 19 |
import com.iver.cit.gvsig.fmap.edition.writers.shp.ShpWriter; |
... | ... | |
20 | 22 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
21 | 23 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
22 | 24 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
25 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
|
23 | 26 |
import com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter; |
24 | 27 |
import com.iver.cit.gvsig.gui.View; |
25 | 28 |
import com.iver.cit.gvsig.project.ProjectView; |
26 | 29 |
import com.iver.utiles.SimpleFileFilter; |
27 | 30 |
|
28 |
|
|
29 |
|
|
30 |
|
|
31 | 31 |
/** |
32 | 32 |
* @author Francisco Jos? |
33 |
* |
|
34 |
* Cuando un tema se pone en edici?n, puede que su driver |
|
35 |
* implemente ISpatialWriter. En ese caso, es capaz |
|
36 |
* de guardarse sobre s? mismo. Si no lo implementa, esta |
|
37 |
* opci?n estar? deshabilitada y la ?nica posibilidad |
|
38 |
* de guardar este tema ser? "Guardando como..." |
|
33 |
* |
|
34 |
* Cuando un tema se pone en edici?n, puede que su driver implemente |
|
35 |
* ISpatialWriter. En ese caso, es capaz de guardarse sobre s? mismo. Si no lo |
|
36 |
* implementa, esta opci?n estar? deshabilitada y la ?nica posibilidad de |
|
37 |
* guardar este tema ser? "Guardando como..." |
|
39 | 38 |
*/ |
40 | 39 |
public class StopEditing implements Extension { |
41 |
private View vista; |
|
40 |
private View vista; |
|
41 |
|
|
42 | 42 |
/** |
43 |
* @see com.iver.andami.plugins.Extension#inicializar()
|
|
44 |
*/
|
|
45 |
public void inicializar() {
|
|
46 |
}
|
|
43 |
* @see com.iver.andami.plugins.Extension#inicializar()
|
|
44 |
*/
|
|
45 |
public void inicializar() {
|
|
46 |
}
|
|
47 | 47 |
|
48 |
/**
|
|
49 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String)
|
|
50 |
*/
|
|
51 |
public void execute(String s) {
|
|
52 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
|
|
53 |
.getActiveView();
|
|
48 |
/**
|
|
49 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String)
|
|
50 |
*/
|
|
51 |
public void execute(String s) {
|
|
52 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
|
|
53 |
.getActiveView();
|
|
54 | 54 |
|
55 |
vista = (View) f;
|
|
55 |
vista = (View) f;
|
|
56 | 56 |
|
57 |
ProjectView model = vista.getModel(); |
|
58 |
FMap mapa = model.getMapContext(); |
|
59 |
FLayers layers = mapa.getLayers(); |
|
60 |
if (s.equals("STOPEDITING")) |
|
61 |
{ |
|
62 |
FLayer[] actives = layers.getActives(); |
|
63 |
// TODO: Comprobar que solo hay una activa, o al menos |
|
64 |
// que solo hay una en edici?n que est? activa, etc, etc |
|
65 |
for (int i = 0; i < actives.length; i++) |
|
66 |
{ |
|
67 |
if (actives[i] instanceof FLyrVect && |
|
68 |
actives[i].isEditing()) |
|
69 |
{ |
|
70 |
FLyrVect lv = (FLyrVect) actives[i]; |
|
71 |
MapControl mapControl = (MapControl) vista.getMapControl(); |
|
72 |
stopEditing(lv,mapControl); |
|
57 |
ProjectView model = vista.getModel(); |
|
58 |
FMap mapa = model.getMapContext(); |
|
59 |
FLayers layers = mapa.getLayers(); |
|
60 |
if (s.equals("STOPEDITING")) { |
|
61 |
FLayer[] actives = layers.getActives(); |
|
62 |
// TODO: Comprobar que solo hay una activa, o al menos |
|
63 |
// que solo hay una en edici?n que est? activa, etc, etc |
|
64 |
for (int i = 0; i < actives.length; i++) { |
|
65 |
if (actives[i] instanceof FLyrVect && actives[i].isEditing()) { |
|
66 |
FLyrVect lv = (FLyrVect) actives[i]; |
|
67 |
MapControl mapControl = (MapControl) vista.getMapControl(); |
|
68 |
stopEditing(lv, mapControl); |
|
73 | 69 |
|
74 |
return;
|
|
75 |
}
|
|
76 |
}
|
|
77 |
}
|
|
78 |
PluginServices.getMainFrame().enableControls();
|
|
79 |
}
|
|
70 |
return;
|
|
71 |
}
|
|
72 |
}
|
|
73 |
}
|
|
74 |
PluginServices.getMainFrame().enableControls();
|
|
75 |
}
|
|
80 | 76 |
|
81 |
/** |
|
82 |
* @see com.iver.andami.plugins.Extension#isEnabled() |
|
83 |
*/ |
|
84 |
public boolean isEnabled() { |
|
85 |
return true; |
|
77 |
/** |
|
78 |
* @see com.iver.andami.plugins.Extension#isEnabled() |
|
79 |
*/ |
|
80 |
public boolean isEnabled() { |
|
81 |
FLayer[] lyrs = EditionUtilities.getActiveAndEditedLayers(); |
|
82 |
if (lyrs == null) return false; |
|
83 |
FLyrVect lyrVect = (FLyrVect) lyrs[0]; |
|
84 |
VectorialEditableAdapter vea = (VectorialEditableAdapter) lyrVect.getSource(); |
|
85 |
|
|
86 |
if (vea.getDriver() instanceof ISpatialWriter) |
|
87 |
return true; |
|
88 |
else |
|
89 |
return false; |
|
86 | 90 |
} |
87 |
|
|
88 |
/** |
|
89 |
* DOCUMENT ME! |
|
90 |
*/ |
|
91 |
public void stopEditing(FLyrVect layer,MapControl mapControl) { |
|
91 |
/** |
|
92 |
* DOCUMENT ME! |
|
93 |
*/ |
|
94 |
public void stopEditing(FLyrVect layer,MapControl mapControl) { |
|
92 | 95 |
VectorialEditableAdapter vea = (VectorialEditableAdapter) layer.getSource(); |
93 |
VectorialFileAdapter vfa = (VectorialFileAdapter) vea.getOriginalAdapter(); |
|
94 |
File theFile = vfa.getFile();
|
|
96 |
|
|
97 |
ISpatialWriter writer = (ISpatialWriter) vea.getDriver();
|
|
95 | 98 |
|
96 |
// File newFile = vea.getDriver(). |
|
97 |
|
|
98 |
ShpWriter writer= (ShpWriter)LayerFactory.getWM().getWriter("Shape Writer"); |
|
99 | 99 |
try { |
100 |
writer.initialize(theFile,layer);
|
|
100 |
writer.initialize(vea);
|
|
101 | 101 |
vea.stopEdition(writer); |
102 | 102 |
vea.getCommandRecord().removeCommandListener(mapControl); |
103 | 103 |
|
104 | 104 |
layer.setEditing(false); |
105 | 105 |
vista.hideConsole(); |
106 |
} catch (IOException e) { |
|
107 |
// TODO Auto-generated catch block |
|
108 |
e.printStackTrace(); |
|
109 |
} catch (DriverException e) { |
|
110 |
// TODO Auto-generated catch block |
|
111 |
e.printStackTrace(); |
|
112 | 106 |
} catch (EditionException e) { |
113 | 107 |
// TODO Auto-generated catch block |
114 | 108 |
e.printStackTrace(); |
115 | 109 |
} |
116 | 110 |
|
117 | 111 |
} |
112 |
/** |
|
113 |
* @see com.iver.andami.plugins.Extension#isVisible() |
|
114 |
*/ |
|
115 |
public boolean isVisible() { |
|
116 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) |
|
117 |
return true; |
|
118 |
else |
|
119 |
return false; |
|
118 | 120 |
|
119 |
/** |
|
120 |
* @see com.iver.andami.plugins.Extension#isVisible() |
|
121 |
*/ |
|
122 |
public boolean isVisible() { |
|
123 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) |
|
124 |
return true; |
|
125 |
else |
|
126 |
return false; |
|
127 |
|
|
128 |
} |
|
121 |
} |
|
129 | 122 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/shp/ShpWriter.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.geom.Rectangle2D; |
4 | 4 |
import java.io.File; |
5 |
import java.io.FileInputStream; |
|
5 | 6 |
import java.io.IOException; |
6 | 7 |
import java.io.RandomAccessFile; |
7 | 8 |
import java.nio.channels.FileChannel; |
... | ... | |
11 | 12 |
import com.iver.cit.gvsig.fmap.DriverException; |
12 | 13 |
import com.iver.cit.gvsig.fmap.core.FShape; |
13 | 14 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
15 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
14 | 16 |
import com.iver.cit.gvsig.fmap.drivers.LayerDefinition; |
15 | 17 |
import com.iver.cit.gvsig.fmap.drivers.shp.DbaseFileHeaderNIO; |
16 | 18 |
import com.iver.cit.gvsig.fmap.drivers.shp.DbaseFileWriterNIO; |
... | ... | |
19 | 21 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
20 | 22 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
21 | 23 |
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
24 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
|
22 | 25 |
import com.iver.cit.gvsig.fmap.edition.writers.AbstractWriter; |
23 | 26 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
24 | 27 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
25 | 28 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
29 |
import com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter; |
|
30 |
import com.iver.utiles.bigfile.BigByteBuffer2; |
|
26 | 31 |
|
27 | 32 |
public class ShpWriter extends AbstractWriter implements ISpatialWriter { |
28 | 33 |
private String shpPath; |
29 | 34 |
private String shxPath; |
30 | 35 |
private String dbfPath; |
36 |
|
|
37 |
private File shpFile; |
|
31 | 38 |
|
32 | 39 |
private SHPFileWrite shpWrite; |
33 | 40 |
private DbaseFileWriterNIO dbfWrite; |
... | ... | |
43 | 50 |
// private FLyrVect lyrVect; |
44 | 51 |
private FBitSet selection = null; |
45 | 52 |
|
46 |
private void setFile(File f)
|
|
53 |
public void setFile(File f)
|
|
47 | 54 |
{ |
48 | 55 |
shpPath = f.getAbsolutePath(); |
49 | 56 |
|
... | ... | |
52 | 59 |
|
53 | 60 |
String strFichDbf = f.getAbsolutePath().replaceAll("\\.shp", ".dbf"); |
54 | 61 |
dbfPath = strFichDbf.replaceAll("\\.SHP", ".DBF"); |
62 |
|
|
63 |
shpFile = f; |
|
55 | 64 |
} |
56 | 65 |
|
57 | 66 |
private WritableByteChannel getWriteChannel(String path) |
... | ... | |
109 | 118 |
myHeader = DbaseFileHeaderNIO.createDbaseHeader(lyrDef.getFieldsDesc()); |
110 | 119 |
initialize(shpFile, lyrDef.getShapeType()); |
111 | 120 |
} |
121 |
|
|
122 |
/** |
|
123 |
* To be used when you need to write to another existing shp file. |
|
124 |
* It is used inside IndexedShpDriver. |
|
125 |
* @param shpFile |
|
126 |
* @throws IOException |
|
127 |
* @throws IOException |
|
128 |
* @throws DriverException |
|
129 |
*/ |
|
130 |
public void initialize(VectorialEditableAdapter vea) throws EditionException |
|
131 |
{ |
|
132 |
try { |
|
133 |
SelectableDataSource sds = vea.getRecordset(); |
|
134 |
myHeader = DbaseFileHeaderNIO.createDbaseHeader(sds); |
|
135 |
initialize(shpFile, vea.getShapeType()); |
|
136 |
} catch (IOException e) { |
|
137 |
e.printStackTrace(); |
|
138 |
throw new EditionException(e); |
|
139 |
} catch (DriverIOException e) { |
|
140 |
e.printStackTrace(); |
|
141 |
throw new EditionException(e); |
|
142 |
} |
|
143 |
|
|
144 |
|
|
145 |
} |
|
146 |
|
|
112 | 147 |
/* public ShpWriter(File shpFile, FLyrVect lyrVect, FBitSet selection) throws IOException, DriverException |
113 | 148 |
{ |
114 | 149 |
SelectableDataSource sds = lyrVect.getRecordset(); |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/ISpatialWriter.java | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package com.iver.cit.gvsig.fmap.edition; |
5 | 5 |
|
6 |
import java.io.IOException; |
|
7 |
|
|
6 | 8 |
/** |
7 | 9 |
* @author fjp |
8 | 10 |
* |
... | ... | |
10 | 12 |
public interface ISpatialWriter extends IWriter { |
11 | 13 |
|
12 | 14 |
public abstract boolean canWriteGeometry(int gvSIGgeometryType); |
15 |
|
|
16 |
public void initialize(VectorialEditableAdapter vea) throws EditionException; |
|
13 | 17 |
|
14 | 18 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/shp/IndexedShpDriver.java | ||
---|---|---|
63 | 63 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
64 | 64 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
65 | 65 |
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
66 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
|
66 | 67 |
import com.iver.cit.gvsig.fmap.edition.writers.shp.ShpWriter; |
67 | 68 |
import com.iver.utiles.bigfile.BigByteBuffer2; |
68 | 69 |
|
... | ... | |
908 | 909 |
public void setShpWriter(ShpWriter shpWriter) { |
909 | 910 |
this.shpWriter = shpWriter; |
910 | 911 |
} |
912 |
|
|
913 |
public void initialize(VectorialEditableAdapter vea) throws EditionException { |
|
914 |
shpWriter.setFile(file); |
|
915 |
shpWriter.initialize(vea); |
|
916 |
|
|
917 |
} |
|
911 | 918 |
|
912 | 919 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/shp/DbaseFileHeaderNIO.java | ||
---|---|---|
77 | 77 |
import com.hardcode.gdbms.engine.data.DataSource; |
78 | 78 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
79 | 79 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
80 |
import com.iver.utiles.bigfile.BigByteBuffer; |
|
80 |
import com.iver.utiles.bigfile.BigByteBuffer2;
|
|
81 | 81 |
import com.vividsolutions.jts.geom.Geometry; |
82 | 82 |
|
83 | 83 |
|
... | ... | |
508 | 508 |
* |
509 | 509 |
* @throws IOException DOCUMENT ME! |
510 | 510 |
*/ |
511 |
public void readHeader(BigByteBuffer in) throws IOException { |
|
511 |
public void readHeader(BigByteBuffer2 in) throws IOException {
|
|
512 | 512 |
// type of file. |
513 | 513 |
myFileType = in.get(); |
514 | 514 |
|
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/shp/DbaseFileNIO.java | ||
---|---|---|
47 | 47 |
import java.nio.channels.FileChannel; |
48 | 48 |
|
49 | 49 |
import com.iver.utiles.bigfile.BigByteBuffer; |
50 |
import com.iver.utiles.bigfile.BigByteBuffer2; |
|
50 | 51 |
|
51 | 52 |
|
52 | 53 |
/** |
... | ... | |
58 | 59 |
private DbaseFileHeaderNIO myHeader; |
59 | 60 |
private FileInputStream fin; |
60 | 61 |
private FileChannel channel; |
61 |
private BigByteBuffer buffer; |
|
62 |
private BigByteBuffer2 buffer;
|
|
62 | 63 |
|
63 | 64 |
/** |
64 | 65 |
* Retrieve number of records in the DbaseFile |
... | ... | |
351 | 352 |
channel = fin.getChannel(); |
352 | 353 |
|
353 | 354 |
// buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); |
354 |
buffer = new BigByteBuffer(channel, FileChannel.MapMode.READ_ONLY); |
|
355 |
buffer = new BigByteBuffer2(channel, FileChannel.MapMode.READ_ONLY);
|
|
355 | 356 |
|
356 | 357 |
// create the header to contain the header information. |
357 | 358 |
myHeader = new DbaseFileHeaderNIO(); |
... | ... | |
367 | 368 |
fin.close(); |
368 | 369 |
channel.close(); |
369 | 370 |
} |
371 |
|
|
372 |
/** |
|
373 |
* @return Returns the DbaseFileHeaderNIO. |
|
374 |
*/ |
|
375 |
public DbaseFileHeaderNIO getDBaseHeader() { |
|
376 |
return myHeader; |
|
377 |
} |
|
370 | 378 |
} |
Also available in: Unified diff