21 |
21 |
*/
|
22 |
22 |
package org.gvsig.republicadominicana.catastro.app.mainplugin;
|
23 |
23 |
|
24 |
|
import java.awt.Dimension;
|
25 |
24 |
import java.awt.GridBagConstraints;
|
|
25 |
import java.net.URI;
|
26 |
26 |
import java.util.Collections;
|
|
27 |
import java.util.List;
|
|
28 |
import java.util.logging.Level;
|
|
29 |
import java.util.logging.Logger;
|
27 |
30 |
import org.apache.commons.collections.CollectionUtils;
|
28 |
31 |
import org.apache.commons.lang3.StringUtils;
|
29 |
32 |
import org.gvsig.andami.plugins.Extension;
|
... | ... | |
31 |
34 |
import org.gvsig.app.ApplicationManager;
|
32 |
35 |
import org.gvsig.app.project.documents.view.ViewDocument;
|
33 |
36 |
import org.gvsig.app.project.documents.view.ViewManager;
|
|
37 |
import org.gvsig.desktopopen.DesktopOpen;
|
|
38 |
import org.gvsig.fmap.dal.exception.DataException;
|
|
39 |
import org.gvsig.fmap.dal.feature.Feature;
|
34 |
40 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
|
35 |
41 |
import org.gvsig.fmap.dal.feature.FeatureStore;
|
36 |
42 |
import org.gvsig.fmap.dal.feature.FeatureType;
|
... | ... | |
49 |
55 |
import org.gvsig.tools.arguments.Arguments;
|
50 |
56 |
import org.gvsig.tools.dispose.DisposeUtils;
|
51 |
57 |
import org.gvsig.tools.swing.api.ToolsSwingUtils;
|
|
58 |
import org.gvsig.tools.util.ToolsUtilLocator;
|
52 |
59 |
|
53 |
60 |
|
54 |
61 |
/**
|
... | ... | |
143 |
150 |
@Override
|
144 |
151 |
public void execute(String actionCommand, Object[] args) {
|
145 |
152 |
Arguments arguments = Arguments.create(args);
|
|
153 |
FeatureStore store = null;
|
146 |
154 |
switch (actionCommand) {
|
147 |
155 |
case "tools-rdcatastro-searchbycadastralreference":
|
148 |
|
FeatureStore store = (FeatureStore) arguments.get("store", FeatureStore.class, null);
|
|
156 |
store = (FeatureStore) arguments.get("store", FeatureStore.class, null);
|
149 |
157 |
if(store == null) {
|
150 |
158 |
store = this.getActiveOnlineStore();
|
151 |
159 |
showSearchByCadastralReferenceDialog(
|
... | ... | |
160 |
168 |
);
|
161 |
169 |
}
|
162 |
170 |
break;
|
|
171 |
case "tools-rdcatastro-showcadastralreferenceinbrowser":
|
|
172 |
store = (FeatureStore) arguments.get("store", FeatureStore.class, null);
|
|
173 |
boolean mustDisposeStore = false;
|
|
174 |
try {
|
|
175 |
if (store == null) {
|
|
176 |
store = this.getActiveOnlineStore();
|
|
177 |
mustDisposeStore = true;
|
|
178 |
}
|
|
179 |
FeatureStore selection = (FeatureStore) store.getSelection();
|
|
180 |
if (selection == null || selection.size64() != 1) {
|
|
181 |
return;
|
|
182 |
};
|
|
183 |
List<Feature> feats = selection.getFeatures();
|
|
184 |
Feature feat = feats.get(0);
|
|
185 |
String cadastralReference = feat.getString(RDCATASTRO_CADASTRAL_REFERENCE_FIELD_NAME);
|
|
186 |
if (StringUtils.isBlank(cadastralReference)) {
|
|
187 |
return;
|
|
188 |
}
|
|
189 |
} catch (DataException ex) {
|
|
190 |
logger.warn("Can't show in browser.", ex);
|
|
191 |
} finally {
|
|
192 |
if (mustDisposeStore) {
|
|
193 |
DisposeUtils.dispose(store);
|
|
194 |
}
|
|
195 |
}
|
|
196 |
break;
|
|
197 |
|
163 |
198 |
}
|
164 |
199 |
}
|
165 |
200 |
|
... | ... | |
181 |
216 |
} finally {
|
182 |
217 |
DisposeUtils.disposeQuietly(store);
|
183 |
218 |
}
|
|
219 |
} else if (StringUtils.equals(action, "tools-rdcatastro-showcadastralreferenceinbrowser")) {
|
|
220 |
FeatureStore store = null;
|
|
221 |
try { //FIXME:
|
|
222 |
store = getActiveOnlineStore();
|
|
223 |
if(store == null) {
|
|
224 |
return false;
|
|
225 |
}
|
|
226 |
FeatureStore selection = (FeatureStore) store.getSelection();
|
|
227 |
return selection != null && selection.size64() == 1;
|
|
228 |
} catch (Throwable th) {
|
|
229 |
logger.warn("Can't check if is enabled online action '" + action + "'", th);
|
|
230 |
return false;
|
|
231 |
} finally {
|
|
232 |
DisposeUtils.disposeQuietly(store);
|
|
233 |
}
|
184 |
234 |
}
|
|
235 |
|
185 |
236 |
return isEnabled();
|
186 |
237 |
}
|
187 |
238 |
|
... | ... | |
264 |
315 |
);
|
265 |
316 |
}
|
266 |
317 |
|
|
318 |
private void showCadastralReferenceInBrowser(String cadastralReference) {
|
|
319 |
|
|
320 |
try {
|
|
321 |
String url = "https://catastrord.gvsig-services.com/spa/inmuebles"+cadastralReference;
|
|
322 |
DesktopOpen desktop = ToolsUtilLocator.getToolsUtilManager().createDesktopOpen();
|
|
323 |
desktop.browse(new URI(url));
|
|
324 |
|
|
325 |
|
|
326 |
} catch (Throwable th) {
|
|
327 |
logger.warn("Can't show in browser'", th);
|
|
328 |
return;
|
|
329 |
}
|
|
330 |
}
|
267 |
331 |
}
|