Revision 27756 branches/v2_0_0_prep/extensions/extGeocoding/src/org/gvsig/geocoding/extension/RelateGeocodingResultsExtension.java
RelateGeocodingResultsExtension.java | ||
---|---|---|
33 | 33 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
34 | 34 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
35 | 35 |
import org.gvsig.geocoding.gui.relation.RelatePanel; |
36 |
import org.gvsig.geocoding.utils.GeocoUtils; |
|
37 | 36 |
import org.gvsig.project.document.table.FeatureTableDocument; |
38 | 37 |
import org.slf4j.Logger; |
39 | 38 |
import org.slf4j.LoggerFactory; |
... | ... | |
57 | 56 |
IPreferenceExtension { |
58 | 57 |
|
59 | 58 |
private static final String RELATEGEOCODING = "RELATEGEOCODING"; |
60 |
|
|
59 |
|
|
61 | 60 |
private static final String GEOCODINGRESULTS = "GEOCODINGRESULTS"; |
62 | 61 |
|
63 | 62 |
private static final Logger log = LoggerFactory |
64 | 63 |
.getLogger(RelateGeocodingResultsExtension.class); |
65 | 64 |
|
65 |
private GeocoController control = null; |
|
66 |
|
|
66 | 67 |
/** |
67 | 68 |
* execute |
68 | 69 |
*/ |
69 | 70 |
public void execute(String actionCommand) { |
70 | 71 |
|
71 | 72 |
if (actionCommand.equalsIgnoreCase(RELATEGEOCODING)) { |
73 |
|
|
74 |
GeocodingExtension mainExt = (GeocodingExtension) PluginServices |
|
75 |
.getExtension(GeocodingExtension.class); |
|
76 |
control = mainExt.getControl(); |
|
77 |
// ahow panel extension |
|
72 | 78 |
RelatePanel repanel = new RelatePanel(); |
73 | 79 |
PluginServices.getMDIManager().addWindow(repanel); |
74 | 80 |
repanel.setVisible(true); |
... | ... | |
89 | 95 |
*/ |
90 | 96 |
public boolean isEnabled() { |
91 | 97 |
|
92 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
93 |
if (window instanceof View) { |
|
94 |
View vi = (View)window; |
|
95 |
FLayers lyrs = vi.getMapControl().getMapContext().getLayers(); |
|
96 |
int cant = lyrs.getLayersCount(); |
|
97 |
if (lyrs != null && lyrs.getLayersCount() > 0) { |
|
98 |
if (lyrs.getActives().length > 0) { |
|
99 |
FLayer lyr = lyrs.getActives()[0]; |
|
100 |
if (lyr instanceof FLyrVect) { |
|
101 |
FLyrVect ly = (FLyrVect)lyr; |
|
102 |
Object obj = ly.getProperty(GEOCODINGRESULTS); |
|
103 |
List<FeatureTableDocument> tables = GeocoUtils.getListgvSIGTables(); |
|
104 |
//TODO validar obj != null |
|
105 |
if(tables.size()>0){ |
|
106 |
return true; |
|
107 |
} |
|
108 |
} |
|
109 |
} |
|
110 |
} |
|
111 |
} |
|
98 |
// IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
99 |
// if (window instanceof View) { |
|
100 |
// View vi = (View) window; |
|
101 |
// FLayers lyrs = vi.getMapControl().getMapContext().getLayers(); |
|
102 |
// int cant = lyrs.getLayersCount(); |
|
103 |
// if (lyrs != null && lyrs.getLayersCount() > 0) { |
|
104 |
// if (lyrs.getActives().length > 0) { |
|
105 |
// FLayer lyr = lyrs.getActives()[0]; |
|
106 |
// if (lyr instanceof FLyrVect) { |
|
107 |
// FLyrVect ly = (FLyrVect) lyr; |
|
108 |
// List<FeatureTableDocument> tables = control |
|
109 |
// .getListgvSIGTables(); |
|
110 |
// Object obj = ly.getProperty(GEOCODINGRESULTS); |
|
111 |
// if (obj instanceof FeatureTableDocument |
|
112 |
// && tables.size() > 0) { |
|
113 |
// return true; |
|
114 |
// } |
|
115 |
// } |
|
116 |
// } |
|
117 |
// } |
|
118 |
// } |
|
112 | 119 |
return false; |
113 | 120 |
} |
114 | 121 |
|
Also available in: Unified diff