svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / EditionUtilities.java @ 5070
History | View | Annotate | Download (3.44 KB)
1 |
package com.iver.cit.gvsig; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
|
5 |
import com.iver.andami.PluginServices; |
6 |
import com.iver.cit.gvsig.fmap.DriverException; |
7 |
import com.iver.cit.gvsig.fmap.FMap; |
8 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
9 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
10 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
11 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
12 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
13 |
import com.iver.cit.gvsig.gui.View; |
14 |
import com.iver.cit.gvsig.project.ProjectView; |
15 |
import com.iver.utiles.NumberUtilities; |
16 |
|
17 |
/**
|
18 |
* @author fjp
|
19 |
*
|
20 |
* Clase con m?todos muy ?tiles a la hora de hacer nuevas extensiones, y otras
|
21 |
* cosas que puedan ser gen?ricas para este plugin.
|
22 |
*
|
23 |
*/
|
24 |
public class EditionUtilities { |
25 |
|
26 |
public static final int EDITION_STATUS_NO_EDITION = 0; |
27 |
public static final int EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE = 1; |
28 |
public static final int EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE = 2; |
29 |
public static final int EDITION_STATUS_MULTIPLE_VECTORIAL_LAYER_ACTIVE = 3; |
30 |
public static final int EDITION_STATUS_MULTIPLE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE = 4; |
31 |
public static int getEditionStatus() |
32 |
{ |
33 |
int status = EDITION_STATUS_NO_EDITION;
|
34 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
35 |
.getActiveView(); |
36 |
if (f == null) |
37 |
return status;
|
38 |
|
39 |
if (f.getClass() == View.class) { |
40 |
View vista = (View) f; |
41 |
ProjectView model = vista.getModel(); |
42 |
FMap mapa = model.getMapContext(); |
43 |
|
44 |
FLayers capas = mapa.getLayers(); |
45 |
|
46 |
int numActiveVectorial = 0; |
47 |
int numActiveVectorialEditable = 0; |
48 |
for (int i = 0; i < capas.getLayersCount(); i++) { |
49 |
if (capas.getLayer(i) instanceof FLyrVect && |
50 |
capas.getLayer(i).isActive()) { |
51 |
numActiveVectorial++; |
52 |
if (capas.getLayer(i).isEditing())
|
53 |
numActiveVectorialEditable++; |
54 |
} |
55 |
} |
56 |
if (numActiveVectorialEditable == 1) |
57 |
return EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE;
|
58 |
if (numActiveVectorialEditable > 1) |
59 |
return EDITION_STATUS_MULTIPLE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE;
|
60 |
if (numActiveVectorial == 1) |
61 |
return EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE;
|
62 |
if (numActiveVectorial > 1) |
63 |
return EDITION_STATUS_MULTIPLE_VECTORIAL_LAYER_ACTIVE;
|
64 |
|
65 |
} |
66 |
|
67 |
return status;
|
68 |
} |
69 |
|
70 |
public static FLayer[] getActiveAndEditedLayers() |
71 |
{ |
72 |
int status = EDITION_STATUS_NO_EDITION;
|
73 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
74 |
.getActiveView(); |
75 |
if (f == null) |
76 |
return null; |
77 |
|
78 |
if (f.getClass() == View.class) { |
79 |
View vista = (View) f; |
80 |
ProjectView model = vista.getModel(); |
81 |
FMap mapa = model.getMapContext(); |
82 |
|
83 |
ArrayList resul = new ArrayList(); |
84 |
|
85 |
FLayers capas = mapa.getLayers(); |
86 |
|
87 |
int numActiveVectorial = 0; |
88 |
int numActiveVectorialEditable = 0; |
89 |
for (int i = 0; i < capas.getLayersCount(); i++) { |
90 |
if (capas.getLayer(i) instanceof FLyrVect && |
91 |
capas.getLayer(i).isActive()) { |
92 |
numActiveVectorial++; |
93 |
if (capas.getLayer(i).isEditing())
|
94 |
{ |
95 |
numActiveVectorialEditable++; |
96 |
resul.add(capas.getLayer(i)); |
97 |
} |
98 |
} |
99 |
} |
100 |
return (FLayer[]) resul.toArray(new FLayer[0]); |
101 |
|
102 |
} |
103 |
|
104 |
return null; |
105 |
} |
106 |
|
107 |
} |