Revision 9122
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/java/org/gvsig/topology/app/mainplugin/TopologyExtension.java | ||
---|---|---|
41 | 41 |
import org.gvsig.app.ApplicationLocator; |
42 | 42 |
import org.gvsig.app.ApplicationManager; |
43 | 43 |
import org.gvsig.app.project.Project; |
44 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
45 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
44 | 46 |
import org.gvsig.configurableactions.ConfigurableActionsMamager; |
45 | 47 |
import org.gvsig.filedialogchooser.FileDialogChooser; |
46 | 48 |
import org.gvsig.filedialogchooser.FileDialogChooserManager; |
49 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
50 |
import org.gvsig.fmap.mapcontext.layers.vectorial.VectorLayer; |
|
47 | 51 |
import org.gvsig.json.Json; |
48 | 52 |
import org.gvsig.tools.ToolsLocator; |
49 | 53 |
import org.gvsig.tools.i18n.I18nManager; |
... | ... | |
89 | 93 |
IconThemeHelper.registerIcon("topology", "topology-plan", "document-view-tree-icon", this); |
90 | 94 |
IconThemeHelper.registerIcon("topology", "topology-plan", "topology-tree-folder", this); |
91 | 95 |
IconThemeHelper.registerIcon("topology", "topology-plan", "topology-tree-project", this); |
96 |
IconThemeHelper.registerIcon("action", "tools-topology-checklayer", this); |
|
92 | 97 |
|
93 | 98 |
ConfigurableActionsMamager cfgActionsManager = ToolsUtilLocator.getConfigurableActionsMamager(); |
94 | 99 |
cfgActionsManager.addConfigurableAction(JTopologyPlanProperties.CONFIGURABLE_PANEL_ID, new SaveTopologyPlan()); |
... | ... | |
170 | 175 |
plan.execute(); |
171 | 176 |
}, "TopologyPlan-"+ plan.getName()); |
172 | 177 |
th.start(); |
178 |
|
|
179 |
} else if( StringUtils.equalsIgnoreCase("tools-topology-checklayer", action) ) { |
|
180 |
checkCurrentLayer(); |
|
173 | 181 |
} |
174 | 182 |
} |
175 | 183 |
|
... | ... | |
346 | 354 |
} |
347 | 355 |
} |
348 | 356 |
} |
357 |
|
|
358 |
private void checkCurrentLayer() { |
|
359 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
360 |
|
|
361 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
362 |
if( viewdoc == null ) { |
|
363 |
application.messageDialog( |
|
364 |
"There must be an active layer in the active View.", |
|
365 |
"Check geometries", |
|
366 |
JOptionPane.WARNING_MESSAGE |
|
367 |
); |
|
368 |
} |
|
369 |
FLayer[] activeLayers = viewdoc.getMapContext().getLayers().getActives(); |
|
370 |
if( activeLayers==null || activeLayers.length!=1 || !(activeLayers[0] instanceof VectorLayer) ) { |
|
371 |
application.messageDialog( |
|
372 |
"There must be an active vector layer in the active View.", |
|
373 |
"Check geometries", |
|
374 |
JOptionPane.WARNING_MESSAGE |
|
375 |
); |
|
376 |
return; |
|
377 |
} |
|
378 |
VectorLayer layer = (VectorLayer) activeLayers[0]; |
|
379 |
|
|
380 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
381 |
TopologyManager manager = TopologyLocator.getTopologyManager(); |
|
382 |
TopologySwingManager swingManager = TopologySwingLocator.getTopologySwingManager(); |
|
383 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
384 |
|
|
385 |
AppTopologyServices services = new AppTopologyServices(); |
|
386 |
manager.setDefaultServices(services); |
|
387 |
swingManager.setDefaultServices(services); |
|
388 |
|
|
389 |
TopologyPlan plan = manager.createTopologyPlan(); |
|
390 |
plan.setName(i18n.getTranslation("_Validate_geometries")); |
|
391 |
plan.addDataSet(layer.getName(), layer.getFeatureStore()); |
|
392 |
plan.addRule(TopologyManager.RULE_GEOMETRYISVALID_ID, layer.getName(), null, 0); |
|
393 |
plan.addRule(TopologyManager.RULE_GEOMETRYMUSTNOTBENULL_ID, layer.getName(), null, 0); |
|
394 |
|
|
395 |
JTopologyReport panel = swingManager.createJTopologyReport(plan); |
|
396 |
panel.put(plan); |
|
397 |
winManager.showWindow( |
|
398 |
panel.asJComponent(), |
|
399 |
ToolsSwingUtils.makeTitle("_Topology_plan_error_inspector", plan.getName(), layer.getName()), |
|
400 |
WindowManager.MODE.TOOL |
|
401 |
); |
|
402 |
|
|
403 |
Thread th = new Thread(() -> { |
|
404 |
plan.execute(); |
|
405 |
}, "TopologyPlan-"+ plan.getName()); |
|
406 |
th.start(); |
|
407 |
} |
|
349 | 408 |
} |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
73 | 73 |
_The_verification_expression_was_not_met=No se ha cumplido la expresi\u00f3n de verificaci\u00f3n. |
74 | 74 |
_Name_of_the_rule=Nombre de la regla |
75 | 75 |
|
76 |
_Validate_geometries=Validar geometr\u00edas |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
71 | 71 |
_Message_to_show_if_check_fail=Message to show if check fail. |
72 | 72 |
_The_verification_expression_was_not_met=The verification expression was not met. |
73 | 73 |
_Name_of_the_rule=Name of the rule |
74 |
|
|
75 |
_Validate_geometries=Validate geometries |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
38 | 38 |
icon="tools-topology-execute" |
39 | 39 |
accelerator="" |
40 | 40 |
/> |
41 |
<action |
|
42 |
name="tools-topology-checklayer" |
|
43 |
label="_Validate_geometries" |
|
44 |
position="000657000000" |
|
45 |
tooltip="_Validate_geometries" |
|
46 |
action-command="tools-topology-checklayer" |
|
47 |
icon="tools-topology-checklayer" |
|
48 |
accelerator="" |
|
49 |
/> |
|
41 | 50 |
|
42 | 51 |
<menu text="tools/_Topology" |
43 | 52 |
position="908300000" |
... | ... | |
46 | 55 |
name="tools-topology-create-or-modify"/> |
47 | 56 |
<menu text="tools/_Topology/_Execute_plan" |
48 | 57 |
name="tools-topology-execute"/> |
58 |
<menu text="Layer/_Validate_geometries" |
|
59 |
name="tools-topology-checklayer"/> |
|
60 |
|
|
49 | 61 |
|
50 | 62 |
<!-- |
51 | 63 |
<tool-bar name="topology" position="2000"> |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyManager.java | ||
---|---|---|
32 | 32 |
*/ |
33 | 33 |
public interface TopologyManager { |
34 | 34 |
|
35 |
public static final String RULE_GEOMETRYISVALID_ID = "GeometryIsValid"; |
|
36 |
public static final String RULE_GEOMETRYMUSTNOTBENULL_ID = "GeometryMustNotBeNull"; |
|
37 |
|
|
35 | 38 |
public static int TOPOLOGY_PLAN_STATUS_NOT_EXECUTED = -1; |
36 | 39 |
public static int TOPOLOGY_PLAN_STATUS_PASSED = 0; |
37 | 40 |
public static int TOPOLOGY_PLAN_STATUS_NOT_PASSED = 1; |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/GeometryIsValidFactory.java | ||
---|---|---|
38 | 38 |
@SuppressWarnings("UseSpecificCatch") |
39 | 39 |
public class GeometryIsValidFactory extends AbstractTopologyRuleFactory { |
40 | 40 |
|
41 |
public static final String NAME = "GeometryIsValid";
|
|
41 |
public static final String NAME = TopologyManager.RULE_GEOMETRYISVALID_ID;
|
|
42 | 42 |
|
43 | 43 |
public GeometryIsValidFactory() { |
44 | 44 |
super( |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/GeometryMustNotBeNullRuleFactory.java | ||
---|---|---|
38 | 38 |
@SuppressWarnings("UseSpecificCatch") |
39 | 39 |
public class GeometryMustNotBeNullRuleFactory extends AbstractTopologyRuleFactory { |
40 | 40 |
|
41 |
public static final String NAME = "GeometryMustNotBeNull";
|
|
41 |
public static final String NAME = TopologyManager.RULE_GEOMETRYMUSTNOTBENULL_ID;
|
|
42 | 42 |
|
43 | 43 |
public GeometryMustNotBeNullRuleFactory() { |
44 | 44 |
super( |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.swing/org.gvsig.topology.swing.impl/src/main/java/org/gvsig/topology/swing/impl/DefaultJTopologyReport.java | ||
---|---|---|
239 | 239 |
null |
240 | 240 |
); |
241 | 241 |
this.translate(); |
242 |
ToolsSwingUtils.ensureRowsCols(this, 10, 80, 20, 100);
|
|
242 |
ToolsSwingUtils.ensureRowsCols(this, 10, 100, 20, 150);
|
|
243 | 243 |
|
244 | 244 |
this.btnShowErrors.setSelected(false); |
245 | 245 |
this.btnShowExceptions.setSelected(false); |
Also available in: Unified diff