Revision 5159
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.topology</artifactId> |
|
6 |
<version>1.0.84</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.topology.swing</artifactId> |
|
9 |
<packaging>pom</packaging> |
|
10 |
<name>${project.artifactId}</name> |
|
11 |
<modules> |
|
12 |
<module>org.gvsig.topology.swing.api</module> |
|
13 |
<module>org.gvsig.topology.swing.impl</module> |
|
14 |
</modules> |
|
15 |
</project> |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.api/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.topology.swing</artifactId> |
|
6 |
<version>1.0.84</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.topology.swing.api</artifactId> |
|
9 |
<name>${project.artifactId}</name> |
|
10 |
<dependencies> |
|
11 |
<dependency> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.topology.lib.api</artifactId> |
|
14 |
</dependency> |
|
15 |
<dependency> |
|
16 |
<groupId>org.gvsig</groupId> |
|
17 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
18 |
</dependency> |
|
19 |
</dependencies> |
|
20 |
</project> |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.api/src/main/java/org/gvsig/topology/swing/api/TopologySwingLocator.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.topology.swing.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.locator.AbstractLocator; |
|
27 |
import org.gvsig.tools.locator.Locator; |
|
28 |
import org.gvsig.tools.locator.LocatorException; |
|
29 |
|
|
30 |
@SuppressWarnings("rawtypes") |
|
31 |
public class TopologySwingLocator extends AbstractLocator { |
|
32 |
|
|
33 |
private static final String LOCATOR_NAME = "TopologySwingLocator"; |
|
34 |
|
|
35 |
public static final String TOPOLOGY_SWING_MANAGER_NAME = |
|
36 |
"org.gvsig.topology.swing.manager"; |
|
37 |
|
|
38 |
private static final String TOPOLOGY_SWING_MANAGER_DESCRIPTION = |
|
39 |
"Topology Swing Manager of gvSIG"; |
|
40 |
|
|
41 |
private static final TopologySwingLocator instance = new TopologySwingLocator(); |
|
42 |
|
|
43 |
private TopologySwingLocator() { |
|
44 |
|
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* Return the singleton instance. |
|
49 |
* |
|
50 |
* @return the singleton instance |
|
51 |
*/ |
|
52 |
public static TopologySwingLocator getInstance() { |
|
53 |
return instance; |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public String getLocatorName() { |
|
58 |
return LOCATOR_NAME; |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Return a reference to TopologyManager. |
|
63 |
* |
|
64 |
* @return a reference to TopologyManager |
|
65 |
* @throws LocatorException |
|
66 |
* if there is no access to the class or the class cannot be |
|
67 |
* instantiated |
|
68 |
* @see Locator#get(String) |
|
69 |
*/ |
|
70 |
public static TopologySwingManager getTopologySwingManager() |
|
71 |
throws LocatorException { |
|
72 |
return (TopologySwingManager) getInstance().get(TOPOLOGY_SWING_MANAGER_NAME); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* Registers the Class implementing the TopologyManager interface. |
|
77 |
* |
|
78 |
* @param clazz |
|
79 |
* implementing the TopologyManager interface |
|
80 |
*/ |
|
81 |
public static void registerTopologySwingManager(Class clazz) { |
|
82 |
getInstance().register(TOPOLOGY_SWING_MANAGER_NAME, |
|
83 |
TOPOLOGY_SWING_MANAGER_DESCRIPTION, clazz); |
|
84 |
} |
|
85 |
|
|
86 |
public static void registerDefaultTopologySwingManager(Class clazz) { |
|
87 |
getInstance().registerDefault(TOPOLOGY_SWING_MANAGER_NAME, |
|
88 |
TOPOLOGY_SWING_MANAGER_DESCRIPTION, clazz); |
|
89 |
} |
|
90 |
|
|
91 |
|
|
92 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.api/src/main/java/org/gvsig/topology/swing/api/TopologySwingServices.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.topology.swing.api; |
|
25 |
|
|
26 |
import javax.swing.ImageIcon; |
|
27 |
import javax.swing.ListModel; |
|
28 |
import javax.swing.tree.TreeModel; |
|
29 |
import javax.swing.tree.TreePath; |
|
30 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
32 |
import org.gvsig.fmap.geom.Geometry; |
|
33 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
34 |
import org.gvsig.fmap.geom.primitive.Point; |
|
35 |
import org.gvsig.topology.lib.api.TopologyServices; |
|
36 |
|
|
37 |
/** |
|
38 |
* |
|
39 |
* @author jjdelcerro |
|
40 |
*/ |
|
41 |
public interface TopologySwingServices extends TopologyServices { |
|
42 |
|
|
43 |
public ListModel getTablesListModel(); |
|
44 |
|
|
45 |
public interface WorkingAreaChangedListener { |
|
46 |
|
|
47 |
public void workingAreaChanged(Envelope workingArea); |
|
48 |
} |
|
49 |
|
|
50 |
public TreeModel getDataSetTreeModel(); |
|
51 |
|
|
52 |
public void zoomTo(Envelope envelope); |
|
53 |
|
|
54 |
public void centerTo(Point point); |
|
55 |
|
|
56 |
public Envelope getWorkingArea(); |
|
57 |
|
|
58 |
public void addWorkingAreaChangedListener(WorkingAreaChangedListener listener); |
|
59 |
|
|
60 |
public void removeWorkingAreaChangedListener(WorkingAreaChangedListener listener); |
|
61 |
|
|
62 |
public void refreshView(); |
|
63 |
|
|
64 |
public void addError(Geometry geom); |
|
65 |
|
|
66 |
public void setShowFormWhenEdit(boolean showFormWhenEdit); |
|
67 |
|
|
68 |
public ImageIcon getTreeIcon(TreeModel model, Object item); |
|
69 |
|
|
70 |
public void selectFeature(FeatureStore store, FeatureReference ref); |
|
71 |
|
|
72 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.api/src/main/java/org/gvsig/topology/swing/api/TopologySwingLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.topology.swing.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.ToolsLibrary; |
|
27 |
import org.gvsig.tools.library.AbstractLibrary; |
|
28 |
import org.gvsig.tools.library.LibraryException; |
|
29 |
import org.gvsig.topology.lib.api.TopologyLibrary; |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
* @author jjdelcerro |
|
34 |
*/ |
|
35 |
public class TopologySwingLibrary extends AbstractLibrary { |
|
36 |
|
|
37 |
@Override |
|
38 |
public void doRegistration() { |
|
39 |
super.doRegistration(); |
|
40 |
registerAsAPI(TopologySwingLibrary.class); |
|
41 |
this.require(ToolsLibrary.class); |
|
42 |
this.require(TopologyLibrary.class); |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
protected void doInitialize() throws LibraryException { |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
protected void doPostInitialize() throws LibraryException { |
|
51 |
} |
|
52 |
|
|
53 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.api/src/main/java/org/gvsig/topology/swing/api/JTopologyPlanProperties.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.topology.swing.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.swing.api.Component; |
|
27 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @author jjdelcerro |
|
32 |
*/ |
|
33 |
public interface JTopologyPlanProperties extends Component { |
|
34 |
public static final String CONFIGURABLE_PANEL_ID = "TopologyPlanPropertiesPanel"; |
|
35 |
|
|
36 |
public void put(TopologyPlan plan); |
|
37 |
|
|
38 |
public TopologyPlan fetch(TopologyPlan plan); |
|
39 |
|
|
40 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.api/src/main/java/org/gvsig/topology/swing/api/TopologySwingManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.topology.swing.api; |
|
25 |
|
|
26 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
* @author jjdelcerro |
|
31 |
*/ |
|
32 |
public interface TopologySwingManager { |
|
33 |
|
|
34 |
public void setDefaultServices(TopologySwingServices services); |
|
35 |
|
|
36 |
public TopologySwingServices getDefaultServices(); |
|
37 |
|
|
38 |
public JTopologyPlanProperties createJTopologyPlan(); |
|
39 |
|
|
40 |
public JTopologyReport createJTopologyReport(TopologyPlan plan); |
|
41 |
|
|
42 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.api/src/main/java/org/gvsig/topology/swing/api/JTopologyReport.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.topology.swing.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.swing.api.Component; |
|
27 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @author jjdelcerro |
|
32 |
*/ |
|
33 |
public interface JTopologyReport extends Component { |
|
34 |
|
|
35 |
public void put(TopologyPlan plan); |
|
36 |
|
|
37 |
|
|
38 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.topology.swing.api.TopologySwingLibrary |
|
0 | 2 |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.impl/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.topology.swing</artifactId> |
|
6 |
<version>1.0.84</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.topology.swing.impl</artifactId> |
|
9 |
<name>${project.artifactId}</name> |
|
10 |
<dependencies> |
|
11 |
<dependency> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.topology.lib.api</artifactId> |
|
14 |
<scope>compile</scope> |
|
15 |
</dependency> |
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.topology.swing.api</artifactId> |
|
19 |
<scope>compile</scope> |
|
20 |
</dependency> |
|
21 |
<dependency> |
|
22 |
<groupId>com.jeta</groupId> |
|
23 |
<artifactId>formsrt</artifactId> |
|
24 |
<scope>compile</scope> |
|
25 |
</dependency> |
|
26 |
<dependency> |
|
27 |
<groupId>com.jgoodies</groupId> |
|
28 |
<artifactId>jgoodies-forms</artifactId> |
|
29 |
<scope>compile</scope> |
|
30 |
</dependency> |
|
31 |
<dependency> |
|
32 |
<groupId>org.gvsig</groupId> |
|
33 |
<artifactId>org.gvsig.tools.dynform.api</artifactId> |
|
34 |
<scope>compile</scope> |
|
35 |
</dependency> |
|
36 |
<dependency> |
|
37 |
<groupId>org.gvsig</groupId> |
|
38 |
<artifactId>org.gvsig.fmap.dal.swing.api</artifactId> |
|
39 |
<scope>compile</scope> |
|
40 |
</dependency> |
|
41 |
</dependencies> |
|
42 |
</project> |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.impl/src/main/java/org/gvsig/topology/swing/impl/DefaultJTopologyReport.java | ||
---|---|---|
1 |
package org.gvsig.topology.swing.impl; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.event.ActionEvent; |
|
5 |
import java.awt.event.ActionListener; |
|
6 |
import java.awt.event.MouseAdapter; |
|
7 |
import java.awt.event.MouseEvent; |
|
8 |
import java.net.URL; |
|
9 |
import java.util.ArrayList; |
|
10 |
import java.util.HashSet; |
|
11 |
import java.util.List; |
|
12 |
import java.util.Set; |
|
13 |
import javax.swing.DefaultComboBoxModel; |
|
14 |
import javax.swing.DefaultListSelectionModel; |
|
15 |
import javax.swing.ImageIcon; |
|
16 |
import javax.swing.JComponent; |
|
17 |
import javax.swing.JMenuItem; |
|
18 |
import javax.swing.JOptionPane; |
|
19 |
import javax.swing.JPopupMenu; |
|
20 |
import javax.swing.JTable; |
|
21 |
import javax.swing.ListSelectionModel; |
|
22 |
import javax.swing.SwingUtilities; |
|
23 |
import javax.swing.event.ChangeEvent; |
|
24 |
import javax.swing.event.ChangeListener; |
|
25 |
import javax.swing.event.ListSelectionEvent; |
|
26 |
import javax.swing.event.TableModelEvent; |
|
27 |
import javax.swing.event.TableModelListener; |
|
28 |
import javax.swing.table.TableModel; |
|
29 |
import org.apache.commons.io.FilenameUtils; |
|
30 |
import org.apache.commons.lang3.StringUtils; |
|
31 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
|
32 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
33 |
import org.gvsig.expressionevaluator.GeometryExpressionBuilder; |
|
34 |
import org.gvsig.expressionevaluator.GeometryExpressionUtils; |
|
35 |
import org.gvsig.featureform.swing.CreateJFeatureFormException; |
|
36 |
import org.gvsig.fmap.dal.DataStore; |
|
37 |
import org.gvsig.fmap.dal.exception.DataException; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
39 |
import org.gvsig.fmap.geom.Geometry; |
|
40 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
41 |
import org.gvsig.tools.ToolsLocator; |
|
42 |
import org.gvsig.tools.dynform.DynFormLocator; |
|
43 |
import org.gvsig.tools.dynform.JDynForm; |
|
44 |
import org.gvsig.tools.dynobject.DynObject; |
|
45 |
import org.gvsig.tools.i18n.I18nManager; |
|
46 |
import org.gvsig.tools.observer.Observable; |
|
47 |
import org.gvsig.tools.service.ServiceException; |
|
48 |
import org.gvsig.tools.swing.api.ListElement; |
|
49 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
50 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
51 |
import org.gvsig.tools.swing.api.task.TaskStatusController; |
|
52 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
53 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
54 |
import org.gvsig.tools.task.TaskStatus; |
|
55 |
import org.gvsig.topology.lib.api.TopologyLocator; |
|
56 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
57 |
import org.gvsig.topology.lib.api.TopologyReport; |
|
58 |
import org.gvsig.topology.lib.api.TopologyReportLine; |
|
59 |
import org.gvsig.topology.lib.api.TopologyReportLineSet; |
|
60 |
import org.gvsig.topology.lib.api.TopologyRule; |
|
61 |
import org.gvsig.topology.lib.api.TopologyRuleAction; |
|
62 |
import org.gvsig.topology.lib.api.TopologyRuleFactory; |
|
63 |
import org.gvsig.topology.swing.api.JTopologyReport; |
|
64 |
import org.gvsig.topology.swing.api.TopologySwingLocator; |
|
65 |
import org.gvsig.topology.swing.api.TopologySwingServices; |
|
66 |
import org.gvsig.topology.swing.api.TopologySwingServices.WorkingAreaChangedListener; |
|
67 |
import org.slf4j.Logger; |
|
68 |
import org.slf4j.LoggerFactory; |
|
69 |
|
|
70 |
import org.gvsig.featureform.swing.JFeaturesForm; |
|
71 |
import org.gvsig.fmap.dal.feature.Feature; |
|
72 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
73 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
74 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
75 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
76 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
77 |
import org.gvsig.tools.swing.api.ToolsSwingUtils; |
|
78 |
|
|
79 |
/** |
|
80 |
* |
|
81 |
* @author jjdelcerro |
|
82 |
*/ |
|
83 |
@SuppressWarnings("UseSpecificCatch") |
|
84 |
public class DefaultJTopologyReport |
|
85 |
extends DefaultJTopologyReportView |
|
86 |
implements JTopologyReport { |
|
87 |
|
|
88 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultJTopologyReport.class); |
|
89 |
private ListSelectionModel selection; |
|
90 |
|
|
91 |
private class TopologyRuleActionParametersListener implements ActionListener { |
|
92 |
|
|
93 |
private final TopologyRule rule; |
|
94 |
private final List<TopologyReportLine> lines; |
|
95 |
private final TopologyRuleAction action; |
|
96 |
private final JDynForm form; |
|
97 |
|
|
98 |
public TopologyRuleActionParametersListener( |
|
99 |
TopologyRule rule, |
|
100 |
List<TopologyReportLine> lines, |
|
101 |
TopologyRuleAction action, |
|
102 |
JDynForm form |
|
103 |
) { |
|
104 |
this.action = action; |
|
105 |
this.lines = lines; |
|
106 |
this.rule = rule; |
|
107 |
this.form = form; |
|
108 |
} |
|
109 |
|
|
110 |
@Override |
|
111 |
public void actionPerformed(ActionEvent e) { |
|
112 |
doExecuteRuleAction(rule, lines, action, form); |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
private class TopologyRuleActionListener implements ActionListener { |
|
117 |
|
|
118 |
private final TopologyRule rule; |
|
119 |
private final List<TopologyReportLine> lines; |
|
120 |
private final TopologyRuleAction action; |
|
121 |
|
|
122 |
public TopologyRuleActionListener( |
|
123 |
TopologyRule rule, |
|
124 |
List<TopologyReportLine> lines, |
|
125 |
TopologyRuleAction action |
|
126 |
) { |
|
127 |
this.action = action; |
|
128 |
this.lines = lines; |
|
129 |
this.rule = rule; |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public void actionPerformed(ActionEvent e) { |
|
134 |
if (this.action.hasParameters()) { |
|
135 |
doShowActionParametersPanel(this.rule, this.lines, this.action); |
|
136 |
} else { |
|
137 |
doExecuteRuleAction(rule, lines, action, null); |
|
138 |
} |
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
private ReportTable linesModel; |
|
143 |
private final TopologySwingServices services; |
|
144 |
private TaskStatusController taskStatusController; |
|
145 |
private TopologyPlan plan; |
|
146 |
private WorkingAreaChangedListener workingAreaChangedListener; |
|
147 |
|
|
148 |
public DefaultJTopologyReport(TopologyPlan plan) { |
|
149 |
this.services = TopologySwingLocator.getTopologySwingManager().getDefaultServices(); |
|
150 |
this.initComponents(); |
|
151 |
} |
|
152 |
|
|
153 |
private void initComponents() { |
|
154 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
155 |
this.selection = this.tblErrors.getSelectionModel(); |
|
156 |
this.linesModel = new ReportTable(); |
|
157 |
|
|
158 |
this.workingAreaChangedListener = (Envelope workingArea) -> { |
|
159 |
doUpdateFilter(); |
|
160 |
}; |
|
161 |
this.tblErrors.setModel(this.linesModel); |
|
162 |
this.tblErrors.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); |
|
163 |
|
|
164 |
this.btnZoomGeometry.addActionListener((ActionEvent e) -> { |
|
165 |
doZoomGeometry(); |
|
166 |
}); |
|
167 |
this.btnZoomError.addActionListener((ActionEvent e) -> { |
|
168 |
doZoomError(); |
|
169 |
}); |
|
170 |
this.btnCenterGeometry.addActionListener((ActionEvent e) -> { |
|
171 |
doCenterGeometry(); |
|
172 |
}); |
|
173 |
this.btnCenterError.addActionListener((ActionEvent e) -> { |
|
174 |
doCenterError(); |
|
175 |
}); |
|
176 |
this.btnRefresh.addActionListener((ActionEvent e) -> { |
|
177 |
doExecutePlan(); |
|
178 |
}); |
|
179 |
this.tblErrors.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> { |
|
180 |
doRowSelected(); |
|
181 |
}); |
|
182 |
this.tblErrors.addMouseListener(new MouseAdapter() { |
|
183 |
@Override |
|
184 |
public void mouseClicked(MouseEvent e) { |
|
185 |
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { |
|
186 |
doCenterError(); |
|
187 |
} |
|
188 |
} |
|
189 |
}); |
|
190 |
|
|
191 |
this.btnActions.addActionListener((ActionEvent e) -> { |
|
192 |
doSelectAction(); |
|
193 |
}); |
|
194 |
this.btnParametersCancel.addActionListener((ActionEvent e) -> { |
|
195 |
tabData.setEnabledAt(0, true); |
|
196 |
tabData.setEnabledAt(1, false); |
|
197 |
tabData.setSelectedIndex(0); |
|
198 |
pnlParameters.removeAll(); |
|
199 |
}); |
|
200 |
this.btnShowErrors.addActionListener((ActionEvent e) -> { |
|
201 |
doUpdateFilter(); |
|
202 |
}); |
|
203 |
this.btnShowExceptions.addActionListener((ActionEvent e) -> { |
|
204 |
doUpdateFilter(); |
|
205 |
}); |
|
206 |
this.btnVisibleExtentOnly.addActionListener((ActionEvent e) -> { |
|
207 |
doUpdateFilter(); |
|
208 |
}); |
|
209 |
this.btnShowFormWhenEdit.addActionListener((ActionEvent e) -> { |
|
210 |
services.setShowFormWhenEdit(btnShowFormWhenEdit.isSelected()); |
|
211 |
}); |
|
212 |
this.btnEraseErrorMarks.addActionListener((ActionEvent e) -> { |
|
213 |
services.addError(null); |
|
214 |
}); |
|
215 |
DefaultComboBoxModel<ListElement<TopologyRuleFactory>> modelRules = new DefaultComboBoxModel<>(); |
|
216 |
modelRules.addElement(new ListElement<>(i18n.getTranslation("_Any_rule"), (TopologyRuleFactory) null)); |
|
217 |
List<TopologyRuleFactory> factories = TopologyLocator.getTopologyManager().getRuleFactories(); |
|
218 |
for (TopologyRuleFactory factory : factories) { |
|
219 |
modelRules.addElement(new ListElement<>(factory.getName(), factory)); |
|
220 |
} |
|
221 |
this.cboRules.setModel(modelRules); |
|
222 |
this.cboRules.addActionListener((ActionEvent e) -> { |
|
223 |
// Llama al invokeLater para poder debugguear |
|
224 |
SwingUtilities.invokeLater(() -> { |
|
225 |
doUpdateFilter(); |
|
226 |
}); |
|
227 |
}); |
|
228 |
|
|
229 |
this.btnShowForm.addActionListener((ActionEvent e) -> { |
|
230 |
showErrorForm(); |
|
231 |
}); |
|
232 |
|
|
233 |
this.taskStatusController = ToolsSwingLocator.getTaskStatusSwingManager().createTaskStatusController( |
|
234 |
null, |
|
235 |
this.lblTaskStatusTitle, |
|
236 |
this.lblTaskStatusMessage, |
|
237 |
this.pbTaskStatusProgress, |
|
238 |
this.btnTaskStatusCancel, |
|
239 |
null |
|
240 |
); |
|
241 |
this.translate(); |
|
242 |
ToolsSwingUtils.ensureRowsCols(this, 10, 80, 20, 100); |
|
243 |
|
|
244 |
this.btnShowErrors.setSelected(false); |
|
245 |
this.btnShowExceptions.setSelected(false); |
|
246 |
this.btnVisibleExtentOnly.setSelected(false); |
|
247 |
|
|
248 |
this.tabData.setEnabledAt(1, false); |
|
249 |
|
|
250 |
} |
|
251 |
|
|
252 |
@Override |
|
253 |
public ImageIcon loadImage(String imageName) { |
|
254 |
String name = FilenameUtils.getBaseName(imageName); |
|
255 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
|
256 |
if (theme.exists(name)) { |
|
257 |
return theme.get(name); |
|
258 |
} |
|
259 |
URL url = this.getClass().getResource("/" + imageName); |
|
260 |
if (url == null) { |
|
261 |
return null; |
|
262 |
} |
|
263 |
return new ImageIcon(url); |
|
264 |
} |
|
265 |
|
|
266 |
private void translate() { |
|
267 |
ToolsSwingManager tsm = ToolsSwingLocator.getToolsSwingManager(); |
|
268 |
tsm.translate(this.btnActions); |
|
269 |
tsm.translate(this.btnCenterError); |
|
270 |
tsm.translate(this.btnCenterGeometry); |
|
271 |
tsm.translate(this.btnRefresh); |
|
272 |
tsm.translate(this.btnShowErrors); |
|
273 |
tsm.translate(this.btnShowExceptions); |
|
274 |
tsm.translate(this.btnZoomError); |
|
275 |
tsm.translate(this.btnZoomGeometry); |
|
276 |
tsm.translate(this.btnEraseErrorMarks); |
|
277 |
tsm.translate(this.btnVisibleExtentOnly); |
|
278 |
tsm.translate(this.btnParametersAccept); |
|
279 |
tsm.translate(this.btnParametersCancel); |
|
280 |
tsm.translate(this.btnShowFormWhenEdit); |
|
281 |
tsm.translate(this.lblShow); |
|
282 |
tsm.translate(this.tabData); |
|
283 |
tsm.translate(this.btnShowForm); |
|
284 |
} |
|
285 |
|
|
286 |
@Override |
|
287 |
public void put(TopologyPlan plan) { |
|
288 |
this.plan = plan; |
|
289 |
this.taskStatusController.bind(this.plan.getTaskStatus()); |
|
290 |
this.plan.getTaskStatus().addObserver((Observable o, Object o1) -> { |
|
291 |
doTaskStatusUpdated(o, o1); |
|
292 |
}); |
|
293 |
this.linesModel.setReport(plan.getReport()); |
|
294 |
} |
|
295 |
|
|
296 |
@Override |
|
297 |
public JComponent asJComponent() { |
|
298 |
return this; |
|
299 |
} |
|
300 |
|
|
301 |
private void doUpdateFilter() { |
|
302 |
this.linesModel.setFilter(this.getFilter()); |
|
303 |
} |
|
304 |
|
|
305 |
private String getFilter() { |
|
306 |
GeometryExpressionBuilder builder = GeometryExpressionUtils.createExpressionBuilder(); |
|
307 |
TopologyRuleFactory ruleFactory = (TopologyRuleFactory) ListElement.getSelected(cboRules); |
|
308 |
if (ruleFactory != null) { |
|
309 |
builder.set( |
|
310 |
builder.eq( |
|
311 |
builder.column(TopologyReport.RULE_ID), |
|
312 |
builder.constant(ruleFactory.getId()) |
|
313 |
) |
|
314 |
); |
|
315 |
} |
|
316 |
if (this.btnShowErrors.isSelected()) { |
|
317 |
if (btnShowExceptions.isSelected()) { |
|
318 |
builder.and( |
|
319 |
builder.or( |
|
320 |
builder.column(TopologyReport.IS_ERROR), |
|
321 |
builder.column(TopologyReport.IS_EXCEPTION) |
|
322 |
) |
|
323 |
); |
|
324 |
} else { |
|
325 |
builder.and( |
|
326 |
builder.column(TopologyReport.IS_ERROR) |
|
327 |
); |
|
328 |
} |
|
329 |
} else if (btnShowExceptions.isSelected()) { |
|
330 |
builder.and( |
|
331 |
builder.column(TopologyReport.IS_EXCEPTION) |
|
332 |
); |
|
333 |
} |
|
334 |
if (this.btnVisibleExtentOnly.isSelected()) { |
|
335 |
Envelope workingArea = this.services.getWorkingArea(); |
|
336 |
if (workingArea != null) { |
|
337 |
builder.and( |
|
338 |
builder.ST_Intersects( |
|
339 |
builder.column(TopologyReport.GEOMETRY), |
|
340 |
builder.geometry(workingArea.getGeometry()) |
|
341 |
) |
|
342 |
); |
|
343 |
} |
|
344 |
this.services.addWorkingAreaChangedListener(this.workingAreaChangedListener); |
|
345 |
} else { |
|
346 |
this.services.removeWorkingAreaChangedListener(this.workingAreaChangedListener); |
|
347 |
} |
|
348 |
if (builder.value() == null) { |
|
349 |
return null; |
|
350 |
} |
|
351 |
return builder.toString(); |
|
352 |
} |
|
353 |
|
|
354 |
private void doExecutePlan() { |
|
355 |
Thread th = new Thread(() -> { |
|
356 |
plan.execute(); |
|
357 |
}, "TopologyPlan-" + plan.getName()); |
|
358 |
th.start(); |
|
359 |
} |
|
360 |
|
|
361 |
private void doTaskStatusUpdated(final Observable observable, final Object notification) { |
|
362 |
if (observable != null && !(observable instanceof TaskStatus)) { |
|
363 |
return; |
|
364 |
} |
|
365 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
366 |
SwingUtilities.invokeLater(() -> { |
|
367 |
doTaskStatusUpdated(observable, notification); |
|
368 |
}); |
|
369 |
return; |
|
370 |
} |
|
371 |
TaskStatus taskStatus = (TaskStatus) observable; |
|
372 |
if (taskStatus == null || !taskStatus.isRunning()) { |
|
373 |
this.lblTaskStatusTitle.setVisible(false); |
|
374 |
this.lblTaskStatusMessage.setVisible(false); |
|
375 |
this.pbTaskStatusProgress.setVisible(false); |
|
376 |
this.btnTaskStatusCancel.setVisible(false); |
|
377 |
this.btnRefresh.setEnabled(true); |
|
378 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
379 |
message(i18n.getTranslation("_Errors") + ": " + this.linesModel.getRowCount()); |
|
380 |
return; |
|
381 |
} |
|
382 |
if (!this.pbTaskStatusProgress.isVisible()) { |
|
383 |
this.lblTaskStatusTitle.setVisible(true); |
|
384 |
this.lblTaskStatusMessage.setVisible(true); |
|
385 |
this.pbTaskStatusProgress.setVisible(true); |
|
386 |
this.btnTaskStatusCancel.setVisible(true); |
|
387 |
this.btnRefresh.setEnabled(false); |
|
388 |
} |
|
389 |
} |
|
390 |
|
|
391 |
private void message(String msg) { |
|
392 |
this.lblTaskStatusTitle.setText(msg); |
|
393 |
this.lblTaskStatusTitle.setVisible(true); |
|
394 |
} |
|
395 |
|
|
396 |
private void doSelectAction() { |
|
397 |
int n = this.tblErrors.getSelectedRow(); |
|
398 |
if (n < 0) { |
|
399 |
return; |
|
400 |
} |
|
401 |
if(this.linesModel.getRowCount() < 1) { |
|
402 |
return; |
|
403 |
} |
|
404 |
int[] selectedRows = this.tblErrors.getSelectedRows(); |
|
405 |
TopologyRule rule = this.linesModel.getLine(selectedRows[0]).getRule(); |
|
406 |
List<TopologyRuleAction> actions = rule.getActions(); |
|
407 |
if (actions == null || actions.isEmpty()) { |
|
408 |
return; |
|
409 |
} |
|
410 |
List<TopologyReportLine> lines = new ArrayList<>(); |
|
411 |
for (int selectedRow : selectedRows) { |
|
412 |
TopologyReportLine line = this.linesModel.getLine(selectedRow); |
|
413 |
if (line.getRule() == rule) { |
|
414 |
lines.add(line); |
|
415 |
} |
|
416 |
} |
|
417 |
JPopupMenu menu = new JPopupMenu(); |
|
418 |
for (TopologyRuleAction action : actions) { |
|
419 |
JMenuItem item; |
|
420 |
if (action.hasParameters()) { |
|
421 |
item = new JMenuItem(action.getName() + "..."); |
|
422 |
} else { |
|
423 |
item = new JMenuItem(action.getName()); |
|
424 |
} |
|
425 |
item.addActionListener(new TopologyRuleActionListener(rule, lines, action)); |
|
426 |
if (lines.size() > 1 && action.hasParameters()) { |
|
427 |
item.setEnabled(false); |
|
428 |
} |
|
429 |
menu.add(item); |
|
430 |
} |
|
431 |
menu.show(this.btnActions, 0, this.btnActions.getHeight()); |
|
432 |
} |
|
433 |
|
|
434 |
private void doExecuteRuleAction( |
|
435 |
TopologyRule rule, |
|
436 |
List<TopologyReportLine> lines, |
|
437 |
TopologyRuleAction action, |
|
438 |
JDynForm form |
|
439 |
) { |
|
440 |
DynObject parameters = null; |
|
441 |
if (form != null) { |
|
442 |
parameters = action.createParameters(); |
|
443 |
if (parameters != null) { |
|
444 |
form.getValues(parameters); |
|
445 |
} |
|
446 |
} |
|
447 |
for (TopologyReportLine line : lines) { |
|
448 |
action.execute(rule, line, parameters); |
|
449 |
} |
|
450 |
this.tabData.setEnabledAt(0, true); |
|
451 |
this.tabData.setEnabledAt(1, false); |
|
452 |
this.tabData.setSelectedIndex(0); |
|
453 |
this.pnlParameters.removeAll(); |
|
454 |
this.services.addError(null); |
|
455 |
} |
|
456 |
|
|
457 |
private void doShowActionParametersPanel( |
|
458 |
TopologyRule rule, |
|
459 |
List<TopologyReportLine> lines, |
|
460 |
TopologyRuleAction action |
|
461 |
) { |
|
462 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
463 |
this.tabData.setEnabledAt(0, false); |
|
464 |
this.tabData.setEnabledAt(1, true); |
|
465 |
this.tabData.setSelectedIndex(1); |
|
466 |
|
|
467 |
try { |
|
468 |
JDynForm form = null; |
|
469 |
this.lblActionTitle.setText( |
|
470 |
"<html>" |
|
471 |
+ i18n.getTranslation("_Rule") + ": <b>" |
|
472 |
+ rule.getName() + "</b>, " |
|
473 |
+ i18n.getTranslation("_Action") + ": <b>" |
|
474 |
+ action.getName() + "</b></html>" |
|
475 |
); |
|
476 |
this.lblActionDescription.setText("<html>" + action.getShortDescription() + "</html>"); |
|
477 |
DynObject parameters = action.createParameters(); |
|
478 |
if (parameters != null) { |
|
479 |
form = DynFormLocator.getDynFormManager().createJDynForm(parameters); |
|
480 |
if (form != null) { |
|
481 |
this.pnlParameters.setLayout(new BorderLayout()); |
|
482 |
this.pnlParameters.removeAll(); |
|
483 |
this.pnlParameters.add(form.asJComponent(), BorderLayout.CENTER); |
|
484 |
this.pnlParameters.revalidate(); |
|
485 |
this.pnlParameters.repaint(); |
|
486 |
} |
|
487 |
} |
|
488 |
this.btnParametersAccept.addActionListener( |
|
489 |
new TopologyRuleActionParametersListener(rule, lines, action, form) |
|
490 |
); |
|
491 |
} catch (Exception ex) { |
|
492 |
LOGGER.warn("Can't show action parameters panel.", ex); |
|
493 |
} |
|
494 |
} |
|
495 |
|
|
496 |
private void doZoomGeometry() { |
|
497 |
int n = this.tblErrors.getSelectedRow(); |
|
498 |
if (n < 0) { |
|
499 |
return; |
|
500 |
} |
|
501 |
TopologyReportLine line = this.linesModel.getLine(n); |
|
502 |
Geometry geom = line.getGeometry(); |
|
503 |
if( geom!=null ) { |
|
504 |
this.services.zoomTo(geom.getEnvelope()); |
|
505 |
} |
|
506 |
} |
|
507 |
|
|
508 |
private void doZoomError() { |
|
509 |
int n = this.tblErrors.getSelectedRow(); |
|
510 |
if (n < 0) { |
|
511 |
return; |
|
512 |
} |
|
513 |
TopologyReportLine line = this.linesModel.getLine(n); |
|
514 |
Geometry geom = line.getError(); |
|
515 |
if (geom == null) { |
|
516 |
services.addError(null); |
|
517 |
geom = line.getGeometry(); |
|
518 |
if( geom!=null ) { |
|
519 |
this.services.zoomTo(geom.getEnvelope()); |
|
520 |
} |
|
521 |
} else { |
|
522 |
services.addError(geom); |
|
523 |
this.services.zoomTo(geom.getEnvelope()); |
|
524 |
} |
|
525 |
} |
|
526 |
|
|
527 |
private void doCenterGeometry() { |
|
528 |
try { |
|
529 |
int n = this.tblErrors.getSelectedRow(); |
|
530 |
if (n < 0) { |
|
531 |
return; |
|
532 |
} |
|
533 |
doRowSelected(); |
|
534 |
TopologyReportLine line = this.linesModel.getLine(n); |
|
535 |
Geometry geom = line.getGeometry(); |
|
536 |
if( geom!=null ) { |
|
537 |
this.services.centerTo(geom.centroid()); |
|
538 |
} |
|
539 |
} catch (Exception ex) { |
|
540 |
LOGGER.warn("Can't center topology error", ex); |
|
541 |
} |
|
542 |
} |
|
543 |
|
|
544 |
private void doCenterError() { |
|
545 |
try { |
|
546 |
int n = this.tblErrors.getSelectedRow(); |
|
547 |
if (n < 0) { |
|
548 |
return; |
|
549 |
} |
|
550 |
doRowSelected(); |
|
551 |
TopologyReportLine line = this.linesModel.getLine(n); |
|
552 |
Geometry geom = line.getError(); |
|
553 |
if (geom == null) { |
|
554 |
services.addError(null); |
|
555 |
geom = line.getGeometry(); |
|
556 |
} else { |
|
557 |
services.addError(geom); |
|
558 |
} |
|
559 |
if( geom!=null ) { |
|
560 |
this.services.centerTo(geom.centroid()); |
|
561 |
} |
|
562 |
} catch (Exception ex) { |
|
563 |
LOGGER.warn("Can't center topology error", ex); |
|
564 |
} |
|
565 |
} |
|
566 |
|
|
567 |
private void doRowSelected() { |
|
568 |
try { |
|
569 |
int n = this.tblErrors.getSelectedRow(); |
|
570 |
if (n < 0) { |
|
571 |
return; |
|
572 |
} |
|
573 |
TopologyReportLine line = this.linesModel.getLine(n); |
|
574 |
if (line.getFeature1() == null && line.getFeature2() == null) { |
|
575 |
return; |
|
576 |
} |
|
577 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
578 |
this.services.addError(null); |
|
579 |
if(line.getDataSet1() != null) { |
|
580 |
FeatureStore store1 = line.getDataSet1().getFeatureStore(); |
|
581 |
if (line.getFeature1() != null) { |
|
582 |
this.services.selectFeature(store1, line.getFeature1()); |
|
583 |
} |
|
584 |
} |
|
585 |
if (line.getDataSet2() != null) { |
|
586 |
FeatureStore store2 = line.getDataSet2().getFeatureStore(); |
|
587 |
if (line.getFeature2() != null) { |
|
588 |
this.services.selectFeature(store2, line.getFeature2()); |
|
589 |
} |
|
590 |
} |
|
591 |
message(i18n.getTranslation("_Errors") + ": " + this.linesModel.getRowCount()+" "+line.getDescription()); |
|
592 |
} catch (Exception ex) { |
|
593 |
LOGGER.warn("Can't select topology error", ex); |
|
594 |
} |
|
595 |
} |
|
596 |
|
|
597 |
private class ReportTable implements TableModel { |
|
598 |
|
|
599 |
private TopologyReport report; |
|
600 |
private TopologyReportLineSet lines; |
|
601 |
private final String[] columnNames; |
|
602 |
private final Class[] columnClasses; |
|
603 |
private final Set<TableModelListener> tableListeners; |
|
604 |
private final ChangeListener reportListener; |
|
605 |
private String lastFilter; |
|
606 |
|
|
607 |
public ReportTable() { |
|
608 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
609 |
this.report = null; |
|
610 |
this.lines = null; |
|
611 |
this.tableListeners = new HashSet<>(); |
|
612 |
this.columnNames = new String[]{ |
|
613 |
"", |
|
614 |
i18n.getTranslation("_Rule"), |
|
615 |
i18n.getTranslation("_Dataset1"), |
|
616 |
i18n.getTranslation("_Dataset2"), |
|
617 |
i18n.getTranslation("_Exception"), |
|
618 |
i18n.getTranslation("_Description") |
|
619 |
}; |
|
620 |
this.columnClasses = new Class[]{ |
|
621 |
Integer.class, |
|
622 |
String.class, |
|
623 |
String.class, |
|
624 |
String.class, |
|
625 |
Boolean.class, |
|
626 |
String.class |
|
627 |
}; |
|
628 |
this.reportListener = new ChangeListener() { |
|
629 |
@Override |
|
630 |
public void stateChanged(final ChangeEvent e) { |
|
631 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
632 |
SwingUtilities.invokeLater(() -> { |
|
633 |
stateChanged(e); |
|
634 |
}); |
|
635 |
return; |
|
636 |
} |
|
637 |
fireTableChanged(); |
|
638 |
} |
|
639 |
}; |
|
640 |
} |
|
641 |
|
|
642 |
public void setReport(TopologyReport report) { |
|
643 |
if (this.report != null) { |
|
644 |
this.report.removeChangeListener(this.reportListener); |
|
645 |
} |
|
646 |
this.report = report; |
|
647 |
this.lines = this.report; |
|
648 |
this.lines.addChangeListener(this.reportListener); |
|
649 |
} |
|
650 |
|
|
651 |
public void setFilter(String filter) { |
|
652 |
if (StringUtils.equals(filter, this.lastFilter)) { |
|
653 |
return; |
|
654 |
} |
|
655 |
this.lines = this.report.getLineSet(filter); |
|
656 |
this.lines.addChangeListener(this.reportListener); |
|
657 |
this.lastFilter = filter; |
|
658 |
this.fireTableChanged(); |
|
659 |
} |
|
660 |
|
|
661 |
public TopologyReport getReport() { |
|
662 |
return this.report; |
|
663 |
} |
|
664 |
|
|
665 |
@Override |
|
666 |
public int getRowCount() { |
|
667 |
if (this.lines == null) { |
|
668 |
return 0; |
|
669 |
} |
|
670 |
return this.lines.size(); |
|
671 |
} |
|
672 |
|
|
673 |
@Override |
|
674 |
public int getColumnCount() { |
|
675 |
return 6; |
|
676 |
} |
|
677 |
|
|
678 |
@Override |
|
679 |
public String getColumnName(int columnIndex) { |
|
680 |
return this.columnNames[columnIndex]; |
|
681 |
} |
|
682 |
|
|
683 |
@Override |
|
684 |
public Class<?> getColumnClass(int columnIndex) { |
|
685 |
return this.columnClasses[columnIndex]; |
|
686 |
} |
|
687 |
|
|
688 |
@Override |
|
689 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
690 |
return false; |
|
691 |
} |
|
692 |
|
|
693 |
@Override |
|
694 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
695 |
if (this.lines == null) { |
|
696 |
return ""; |
|
697 |
} |
|
698 |
TopologyReportLine line = this.lines.get(rowIndex); |
|
699 |
switch (columnIndex) { |
|
700 |
case 0: |
|
701 |
return rowIndex; |
|
702 |
case 1: |
|
703 |
return line.getRule().getName(); |
|
704 |
case 2: |
|
705 |
return line.getDataSet1().getName(); |
|
706 |
case 3: |
|
707 |
if (line.getDataSet2() == null) { |
|
708 |
return ""; |
|
709 |
} |
|
710 |
return line.getDataSet2().getName(); |
|
711 |
case 4: |
|
712 |
return line.isException(); |
|
713 |
case 5: |
|
714 |
return line.getDescription(); |
|
715 |
default: |
|
716 |
return "???"; |
|
717 |
} |
|
718 |
} |
|
719 |
|
|
720 |
@Override |
|
721 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
722 |
} |
|
723 |
|
|
724 |
@Override |
|
725 |
public void addTableModelListener(TableModelListener l) { |
|
726 |
this.tableListeners.add(l); |
|
727 |
} |
|
728 |
|
|
729 |
@Override |
|
730 |
public void removeTableModelListener(TableModelListener l) { |
|
731 |
this.tableListeners.remove(l); |
|
732 |
} |
|
733 |
|
|
734 |
private void fireTableChanged() { |
|
735 |
saveCurrentSelection(); |
|
736 |
for (TableModelListener tableListener : this.tableListeners) { |
|
737 |
tableListener.tableChanged(new TableModelEvent(this)); |
|
738 |
} |
|
739 |
restoreCurrentSelection(); |
|
740 |
} |
|
741 |
|
|
742 |
public TopologyReportLine getLine(int lineNum) { |
|
743 |
return this.lines.get(lineNum); |
|
744 |
} |
|
745 |
|
|
746 |
} |
|
747 |
|
|
748 |
private void saveCurrentSelection() { |
|
749 |
this.tblErrors.setSelectionModel(new DefaultListSelectionModel()); |
|
750 |
} |
|
751 |
|
|
752 |
private void restoreCurrentSelection() { |
|
753 |
this.tblErrors.setSelectionModel(this.selection); |
|
754 |
} |
|
755 |
|
|
756 |
|
|
757 |
private void showErrorForm() { |
|
758 |
//Muestra el formulario del dataset con la feature en la que se ha producido el error |
|
759 |
int n = this.tblErrors.getSelectedRow(); |
|
760 |
if (n < 0) { |
|
761 |
return; |
|
762 |
} |
|
763 |
TopologyReportLine line = this.linesModel.getLine(n); |
|
764 |
DataStore store = line.getDataSet1().getStore(); |
|
765 |
JFeaturesForm form; |
|
766 |
try { |
|
767 |
FeatureStore fStore = (FeatureStore) store; |
|
768 |
FeatureType fType = fStore.getDefaultFeatureType(); |
|
769 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
|
770 |
FeatureAttributeDescriptor[] pk = fType.getPrimaryKey(); |
|
771 |
|
|
772 |
if (pk==null) { |
|
773 |
//FIXME : Presentar mensaje al usuario. Como poner ventanas en JAVA |
|
774 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
775 |
String message = i18n.getTranslation("_The_report_cant show._The_table_dont_have_primary_key"); |
|
776 |
String title = i18n.getTranslation("_No_primary_key"); |
|
777 |
ToolsSwingLocator.getThreadSafeDialogsManager().messageDialog (message, |
|
778 |
title, |
|
779 |
JOptionPane.WARNING_MESSAGE); |
|
780 |
return; |
|
781 |
} |
|
782 |
|
|
783 |
Feature feature = line.getFeature1().getFeature(); |
|
784 |
for (FeatureAttributeDescriptor attr : pk) { |
|
785 |
builder.and( |
|
786 |
builder.eq( |
|
787 |
builder.variable(attr.getName()), |
|
788 |
builder.constant(feature.get(attr.getName())) |
|
789 |
) |
|
790 |
); |
|
791 |
} |
|
792 |
String filter = builder.toString(); |
|
793 |
|
|
794 |
|
|
795 |
form = this.createform(fStore); |
|
796 |
FeatureQuery query = fStore.createFeatureQuery(); //, null, true); // |
|
797 |
query.setFilter(filter); |
|
798 |
|
|
799 |
|
|
800 |
form.setQuery(query); |
|
801 |
form.showForm(WindowManager.MODE.WINDOW); |
|
802 |
} catch (Exception ex) { |
|
803 |
LOGGER.warn("Can't create form", ex); |
|
804 |
} |
|
805 |
} |
|
806 |
|
|
807 |
private JFeaturesForm createform(FeatureStore featureStore) throws CreateJFeatureFormException, ServiceException, DataException { |
|
808 |
final DataSwingManager swingManager = DALSwingLocator.getSwingManager(); |
|
809 |
final JFeaturesForm form = swingManager.createJFeaturesForm(featureStore); |
|
810 |
form.getFormset().setAllowDelete(true); |
|
811 |
form.getFormset().setAllowNew(true); |
|
812 |
ToolsSwingUtils.ensureRowsCols(form.asJComponent(), 15, 80, 22, 110); |
|
813 |
return form; |
|
814 |
} |
|
815 |
|
|
816 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.impl/src/main/java/org/gvsig/topology/swing/impl/TopologySwingImplLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.topology.swing.impl; |
|
25 |
|
|
26 |
import java.net.URL; |
|
27 |
import org.gvsig.configurableactions.ConfigurableActionsMamager; |
|
28 |
import org.gvsig.tools.ToolsLibrary; |
|
29 |
import org.gvsig.tools.library.AbstractLibrary; |
|
30 |
import org.gvsig.tools.library.LibraryException; |
|
31 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
32 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
33 |
import org.gvsig.tools.util.ToolsUtilLocator; |
|
34 |
import org.gvsig.topology.lib.api.TopologyLibrary; |
|
35 |
import org.gvsig.topology.lib.api.TopologyLocator; |
|
36 |
import org.gvsig.topology.lib.api.TopologyManager; |
|
37 |
import static org.gvsig.topology.swing.api.JTopologyPlanProperties.CONFIGURABLE_PANEL_ID; |
|
38 |
import org.gvsig.topology.swing.api.TopologySwingLibrary; |
|
39 |
import org.gvsig.topology.swing.api.TopologySwingLocator; |
|
40 |
import org.gvsig.topology.swing.api.TopologySwingManager; |
|
41 |
import org.gvsig.topology.swing.impl.DefaultJTopologyPlanProperties.CopyTopologyPlanToClipboardAction; |
|
42 |
|
|
43 |
/** |
|
44 |
* |
|
45 |
* @author jjdelcerro |
|
46 |
*/ |
|
47 |
public class TopologySwingImplLibrary extends AbstractLibrary { |
|
48 |
|
|
49 |
@Override |
|
50 |
public void doRegistration() { |
|
51 |
super.doRegistration(); |
|
52 |
registerAsImplementationOf(TopologySwingLibrary.class); |
|
53 |
this.require(ToolsLibrary.class); |
|
54 |
this.require(TopologyLibrary.class); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
protected void doInitialize() throws LibraryException { |
|
59 |
TopologySwingLocator.registerDefaultTopologySwingManager(DefaultTopologySwingManager.class); |
|
60 |
|
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
protected void doPostInitialize() throws LibraryException { |
|
65 |
String[][] iconNames = new String[][] { |
|
66 |
new String[] { "layertypes", "layer-type-point" }, |
|
67 |
new String[] { "layertypes", "layer-type-line" }, |
|
68 |
new String[] { "layertypes", "layer-type-polygon" }, |
|
69 |
new String[] { "layertypes", "layer-type-multipoint" }, |
|
70 |
new String[] { "layertypes", "layer-type-multiline" }, |
|
71 |
new String[] { "layertypes", "layer-type-multipolygon" } |
|
72 |
}; |
|
73 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
|
74 |
for (String[] icon : iconNames) { |
|
75 |
URL url = this.getClass().getResource("images/layertypes/"+icon[1]+".png"); |
|
76 |
theme.registerDefault("topology", icon[0], icon[1], null, url); |
|
77 |
} |
|
78 |
|
|
79 |
iconNames = new String[][] { |
|
80 |
new String[] { "action", "table-show-form" }, |
|
81 |
new String[] { "topology", "topology-plan-dataset-add" }, |
|
82 |
new String[] { "topology", "topology-plan-dataset-remove" }, |
|
83 |
new String[] { "topology", "topology-plan-rule-add" }, |
|
84 |
new String[] { "topology", "topology-plan-rule-edit" }, |
|
85 |
new String[] { "topology", "topology-plan-rule-remove" }, |
|
86 |
new String[] { "topology", "topology-report-actions" }, |
|
87 |
new String[] { "topology", "topology-report-center-error" }, |
|
88 |
new String[] { "topology", "topology-report-center-geometry" }, |
|
89 |
new String[] { "topology", "topology-report-erase-errors" }, |
|
90 |
new String[] { "topology", "topology-report-filter-errors" }, |
|
91 |
new String[] { "topology", "topology-report-filter-exceptions" }, |
|
92 |
new String[] { "topology", "topology-report-filter-visible-extent" }, |
|
93 |
new String[] { "topology", "topology-report-refresh" }, |
|
94 |
new String[] { "topology", "topology-report-show-form" }, |
|
95 |
new String[] { "topology", "topology-report-zoom-error" }, |
|
96 |
new String[] { "topology", "topology-report-zoom-geometry" } |
|
97 |
}; |
|
98 |
for (String[] icon : iconNames) { |
|
99 |
URL url = this.getClass().getResource("images/"+icon[1]+".png"); |
|
100 |
theme.registerDefault("topology", icon[0], icon[1], null, url); |
|
101 |
} |
|
102 |
ConfigurableActionsMamager cfgActionsManager = ToolsUtilLocator.getConfigurableActionsMamager(); |
|
103 |
cfgActionsManager.addConfigurableAction(CONFIGURABLE_PANEL_ID, new CopyTopologyPlanToClipboardAction()); |
|
104 |
} |
|
105 |
|
|
106 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.84/org.gvsig.topology.swing/org.gvsig.topology.swing.impl/src/main/java/org/gvsig/topology/swing/impl/DefaultJTopologyPlanPropertiesView.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<object classname="com.jeta.forms.store.memento.FormPackage"> |
|
4 |
<at name="fileversion"> |
|
5 |
<object classname="com.jeta.forms.store.memento.FormsVersion2"> |
|
6 |
<at name="major">2</at> |
|
7 |
<at name="minor">0</at> |
|
8 |
<at name="sub">0</at> |
|
9 |
</object> |
|
10 |
</at> |
|
11 |
<at name="form"> |
|
12 |
<object classname="com.jeta.forms.store.memento.FormMemento"> |
|
13 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
14 |
<at name="cellconstraints"> |
|
15 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
16 |
<at name="column">1</at> |
|
17 |
<at name="row">1</at> |
|
18 |
<at name="colspan">1</at> |
|
19 |
<at name="rowspan">1</at> |
|
20 |
<at name="halign">default</at> |
|
21 |
<at name="valign">default</at> |
|
22 |
<at name="insets" object="insets">0,0,0,0</at> |
|
23 |
</object> |
|
24 |
</at> |
|
25 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
|
26 |
</super> |
|
27 |
<at name="id">/home/fdiaz/projects/gvSIG/org.gvsig.topology/org.gvsig.topology.swing/org.gvsig.topology.swing.impl/src/main/java/org/gvsig/topology/swing/impl/DefaultJTopologyPlanPropertiesView.xml</at> |
|
28 |
<at name="rowspecs">CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE</at> |
|
29 |
<at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE</at> |
|
30 |
<at name="components"> |
|
31 |
<object classname="java.util.LinkedList"> |
|
32 |
<item > |
|
33 |
<at name="value"> |
|
34 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
35 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
36 |
<at name="cellconstraints"> |
|
37 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
38 |
<at name="column">2</at> |
|
39 |
<at name="row">3</at> |
|
40 |
<at name="colspan">1</at> |
|
41 |
<at name="rowspan">1</at> |
|
42 |
<at name="halign">default</at> |
|
43 |
<at name="valign">default</at> |
|
44 |
<at name="insets" object="insets">0,0,0,0</at> |
|
45 |
</object> |
|
46 |
</at> |
|
47 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
48 |
</super> |
|
49 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
50 |
<at name="beanclass">com.jeta.forms.components.label.JETALabel</at> |
|
51 |
<at name="beanproperties"> |
|
52 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
53 |
<at name="classname">com.jeta.forms.components.label.JETALabel</at> |
|
54 |
<at name="properties"> |
|
55 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
56 |
<at name="border"> |
|
57 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
58 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
59 |
<at name="name">border</at> |
|
60 |
</super> |
|
61 |
<at name="borders"> |
|
62 |
<object classname="java.util.LinkedList"> |
|
63 |
<item > |
|
64 |
<at name="value"> |
|
65 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
66 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
67 |
<at name="name">border</at> |
|
68 |
</super> |
|
69 |
</object> |
|
70 |
</at> |
|
71 |
</item> |
|
72 |
</object> |
|
73 |
</at> |
|
74 |
</object> |
|
75 |
</at> |
|
76 |
<at name="name">lblName</at> |
|
77 |
<at name="width">62</at> |
|
78 |
<at name="text">_Name</at> |
|
79 |
<at name="fill"> |
|
80 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
|
81 |
<at name="name">fill</at> |
|
82 |
</object> |
|
83 |
</at> |
|
84 |
<at name="height">14</at> |
|
85 |
</object> |
|
86 |
</at> |
|
87 |
</object> |
|
88 |
</at> |
Also available in: Unified diff