Revision 31946 branches/v2_0_0_prep/extensions/extGeocoding/src/org/gvsig/geocoding/extension/ResultsGeocodingExtension.java
ResultsGeocodingExtension.java | ||
---|---|---|
38 | 38 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
39 | 39 |
import org.gvsig.app.extension.ProjectExtension; |
40 | 40 |
import org.gvsig.app.project.Project; |
41 |
import org.gvsig.app.project.ProjectFactory; |
|
42 |
import org.gvsig.app.project.documents.table.FeatureTableDocument; |
|
43 |
import org.gvsig.app.project.documents.view.gui.View; |
|
41 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
42 |
import org.gvsig.app.project.documents.table.TableManager; |
|
43 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
44 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
45 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
44 | 46 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
45 | 47 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
46 | 48 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
... | ... | |
92 | 94 |
shpstore.addObserver(control.getGResPanel()); |
93 | 95 |
control.getGResPanel().setSelectedStore(shpstore); |
94 | 96 |
// Get table all results relate with the layer |
95 |
FeatureTableDocument table = loadTableAllResultsGeocodingLayer();
|
|
97 |
TableDocument table = loadTableAllResultsGeocodingLayer(); |
|
96 | 98 |
FeatureStore allstore = table.getStore(); |
97 | 99 |
control.getGResPanel().setAllStore(allstore); |
98 | 100 |
// show panel |
... | ... | |
134 | 136 |
|
135 | 137 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
136 | 138 |
// Visible when there are views in the window |
137 |
if (window instanceof View) { |
|
139 |
if (window instanceof IView) {
|
|
138 | 140 |
return true; |
139 | 141 |
} |
140 | 142 |
return false; |
... | ... | |
149 | 151 |
FLyrVect lyr = getSelectedVectLayer(); |
150 | 152 |
if (lyr != null) { |
151 | 153 |
Object obj = lyr.getProperty(GeocodingExtTags.GEOCODINGPROPERTY); |
152 |
if (obj instanceof FeatureTableDocument) {
|
|
154 |
if (obj instanceof TableDocument) { |
|
153 | 155 |
return true; |
154 | 156 |
} |
155 | 157 |
return false; |
... | ... | |
180 | 182 |
Project project = ((ProjectExtension) PluginServices |
181 | 183 |
.getExtension(ProjectExtension.class)).getProject(); |
182 | 184 |
|
183 |
FeatureTableDocument table = ProjectFactory.createTable(lyr |
|
184 |
.getName(), store); |
|
185 |
TableManager tmanager = new TableManager(); |
|
185 | 186 |
|
186 |
project.addDocument(table); |
|
187 |
TableDocument table = (TableDocument) tmanager |
|
188 |
.createDocument(); |
|
189 |
table.setName(lyr.getName()); |
|
190 |
table.setStore(store); |
|
187 | 191 |
|
188 |
IWindow window = table.createWindow(); |
|
189 |
if (window == null) { |
|
192 |
project.add(table); |
|
193 |
|
|
194 |
FeatureTableDocumentPanel t = new FeatureTableDocumentPanel( |
|
195 |
table); |
|
196 |
t.getModel().setModified(true); |
|
197 |
|
|
198 |
if (t == null) { |
|
190 | 199 |
JOptionPane.showMessageDialog( |
191 | 200 |
(Component) PluginServices.getMainFrame(), |
192 | 201 |
PluginServices.getText(this, |
193 | 202 |
"error_opening_the_document")); |
194 | 203 |
} |
195 |
PluginServices.getMDIManager().addWindow(window);
|
|
204 |
PluginServices.getMDIManager().addWindow(t);
|
|
196 | 205 |
return store; |
197 | 206 |
} |
198 | 207 |
} catch (Exception e) { |
... | ... | |
205 | 214 |
|
206 | 215 |
private FLyrVect getSelectedVectLayer() { |
207 | 216 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
208 |
if (window instanceof View) { |
|
209 |
View vi = (View) window;
|
|
217 |
if (window instanceof IView) {
|
|
218 |
DefaultViewPanel vi = (DefaultViewPanel) window;
|
|
210 | 219 |
FLayers lyrs = vi.getMapControl().getMapContext().getLayers(); |
211 | 220 |
if (lyrs != null && lyrs.getLayersCount() > 0) { |
212 | 221 |
if (lyrs.getActives().length > 0) { |
... | ... | |
223 | 232 |
private FLyrVect getSelectedGeocodingVectLayer() { |
224 | 233 |
IWindow[] window = PluginServices.getMDIManager().getOrderedWindows(); |
225 | 234 |
for (int i = 0; i < window.length; i++) { |
226 |
if (window[i] instanceof View) { |
|
227 |
View vi = (View) window[i];
|
|
235 |
if (window[i] instanceof IView) {
|
|
236 |
DefaultViewPanel vi = (DefaultViewPanel) window[i];
|
|
228 | 237 |
FLayers lyrs = vi.getMapControl().getMapContext().getLayers(); |
229 | 238 |
if (lyrs != null && lyrs.getLayersCount() > 0) { |
230 | 239 |
if (lyrs.getActives().length > 0) { |
... | ... | |
247 | 256 |
return null; |
248 | 257 |
} |
249 | 258 |
|
250 |
private FeatureTableDocument loadTableAllResultsGeocodingLayer() {
|
|
259 |
private TableDocument loadTableAllResultsGeocodingLayer() { |
|
251 | 260 |
FLyrVect lyr = getSelectedGeocodingVectLayer(); |
252 |
FeatureTableDocument table = (FeatureTableDocument) lyr
|
|
261 |
TableDocument table = (TableDocument) lyr
|
|
253 | 262 |
.getProperty(GeocodingExtTags.GEOCODINGPROPERTY); |
254 | 263 |
return table; |
255 | 264 |
} |
256 |
|
|
265 |
|
|
257 | 266 |
/** |
258 | 267 |
* |
259 | 268 |
*/ |
Also available in: Unified diff