Revision 6620
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.66/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 |
<groupId>org.gvsig</groupId> |
|
4 |
<artifactId>org.gvsig.vcsgis</artifactId> |
|
5 |
<version>1.0.66</version> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<description /> |
|
9 |
<parent> |
|
10 |
<groupId>org.gvsig</groupId> |
|
11 |
<artifactId>org.gvsig.desktop</artifactId> |
|
12 |
<version>2.0.376</version> |
|
13 |
</parent> |
|
14 |
|
|
15 |
<properties> |
|
16 |
<org.gvsig.h2spatial.provider>org.gvsig.h2spatial.h2gis132.provider</org.gvsig.h2spatial.provider> |
|
17 |
<org.gvsig.topology.version>1.0.111</org.gvsig.topology.version> |
|
18 |
<org.gvsig.oracle.version>2.0.92</org.gvsig.oracle.version> |
|
19 |
<org.gvsig.postgresql.version>2.0.213</org.gvsig.postgresql.version> |
|
20 |
</properties> |
|
21 |
|
|
22 |
<url>https://devel.gvsig.org/sites/org.gvsig.vcsgis/${project.version}</url> |
|
23 |
<scm> |
|
24 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.66</connection> |
|
25 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.66</developerConnection> |
|
26 |
<url>https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.66</url> |
|
27 |
</scm> |
|
28 |
|
|
29 |
<repositories> |
|
30 |
<repository> |
|
31 |
<id>gvsig-public-http-repository</id> |
|
32 |
<name>gvSIG maven public HTTP repository</name> |
|
33 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
34 |
<releases> |
|
35 |
<enabled>true</enabled> |
|
36 |
<updatePolicy>daily</updatePolicy> |
|
37 |
<checksumPolicy>warn</checksumPolicy> |
|
38 |
</releases> |
|
39 |
<snapshots> |
|
40 |
<enabled>true</enabled> |
|
41 |
<updatePolicy>daily</updatePolicy> |
|
42 |
<checksumPolicy>warn</checksumPolicy> |
|
43 |
</snapshots> |
|
44 |
</repository> |
|
45 |
</repositories> |
|
46 |
|
|
47 |
<distributionManagement> |
|
48 |
<site> |
|
49 |
<id>gvsig-repository</id> |
|
50 |
<url>dav:https://devel.gvsig.org/download/projects/gvsig-vcsgis/pool/${project.artifactId}/${project.version}</url> |
|
51 |
</site> |
|
52 |
</distributionManagement> |
|
53 |
|
|
54 |
<build> |
|
55 |
<pluginManagement> |
|
56 |
<plugins> |
|
57 |
|
|
58 |
<plugin> |
|
59 |
<groupId>org.apache.maven.plugins</groupId> |
|
60 |
<artifactId>maven-compiler-plugin</artifactId> |
|
61 |
<configuration> |
|
62 |
<encoding>UTF-8</encoding> |
|
63 |
</configuration> |
|
64 |
</plugin> |
|
65 |
</plugins> |
|
66 |
</pluginManagement> |
|
67 |
<plugins> |
|
68 |
<plugin> |
|
69 |
<groupId>org.apache.maven.plugins</groupId> |
|
70 |
<artifactId>maven-release-plugin</artifactId> |
|
71 |
<configuration> |
|
72 |
<tagBase>https://devel.gvsig.org/svn/gvsig-projects-pool/${project.artifactId}/tags</tagBase> |
|
73 |
</configuration> |
|
74 |
</plugin> |
|
75 |
</plugins> |
|
76 |
</build> |
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
<dependencyManagement> |
|
81 |
<dependencies> |
|
82 |
<dependency> |
|
83 |
<groupId>org.apache.maven.plugins</groupId> |
|
84 |
<artifactId>maven-war-plugin</artifactId> |
|
85 |
<version>3.2.3</version> |
|
86 |
<type>maven-plugin</type> |
|
87 |
</dependency> |
|
88 |
<dependency> |
|
89 |
<groupId>org.apache.tomcat</groupId> |
|
90 |
<artifactId>tomcat-servlet-api</artifactId> |
|
91 |
<version>9.0.45</version> |
|
92 |
</dependency> |
|
93 |
<dependency> |
|
94 |
<groupId>javax.servlet</groupId> |
|
95 |
<artifactId>javax.servlet-api</artifactId> |
|
96 |
<version>3.1.0</version> |
|
97 |
</dependency> |
|
98 |
<dependency> |
|
99 |
<groupId>org.eclipse.jetty</groupId> |
|
100 |
<artifactId>jetty-server</artifactId> |
|
101 |
<version>9.4.34.v20201102</version> |
|
102 |
</dependency> |
|
103 |
<dependency> |
|
104 |
<groupId>org.eclipse.jetty</groupId> |
|
105 |
<artifactId>jetty-servlet</artifactId> |
|
106 |
<version>9.4.34.v20201102</version> |
|
107 |
</dependency> |
|
108 |
<dependency> |
|
109 |
<groupId>org.eclipse.jetty</groupId> |
|
110 |
<artifactId>jetty-webapp</artifactId> |
|
111 |
<version>9.4.34.v20201102</version> |
|
112 |
<exclusions> |
|
113 |
<exclusion> |
|
114 |
<groupId>javax.servlet</groupId> |
|
115 |
<artifactId>servlet-api</artifactId> |
|
116 |
</exclusion> |
|
117 |
</exclusions> |
|
118 |
</dependency> |
|
119 |
<dependency> |
|
120 |
<groupId>org.eclipse.jetty</groupId> |
|
121 |
<artifactId>jetty-util</artifactId> |
|
122 |
<version>9.4.34.v20201102</version> |
|
123 |
</dependency> |
|
124 |
<dependency> |
|
125 |
<groupId>org.eclipse.jetty</groupId> |
|
126 |
<artifactId>jetty-io</artifactId> |
|
127 |
<version>9.4.34.v20201102</version> |
|
128 |
</dependency> |
|
129 |
<dependency> |
|
130 |
<groupId>org.eclipse.jetty</groupId> |
|
131 |
<artifactId>jetty-jndi</artifactId> |
|
132 |
<version>9.4.34.v20201102</version> |
|
133 |
</dependency> |
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
<dependency> |
|
139 |
<groupId>org.gvsig</groupId> |
|
140 |
<artifactId>org.gvsig.topology</artifactId> |
|
141 |
<version>${org.gvsig.topology.version}</version> |
|
142 |
<type>pom</type> |
|
143 |
<scope>import</scope> |
|
144 |
</dependency> |
|
145 |
<dependency> |
|
146 |
<groupId>org.gvsig</groupId> |
|
147 |
<artifactId>${org.gvsig.h2spatial.provider}</artifactId> |
|
148 |
</dependency> |
|
149 |
<dependency> |
|
150 |
<groupId>org.gvsig</groupId> |
|
151 |
<artifactId>org.gvsig.oracle</artifactId> |
|
152 |
<version>${org.gvsig.oracle.version}</version> |
|
153 |
<type>pom</type> |
|
154 |
<scope>import</scope> |
|
155 |
</dependency> |
|
156 |
<dependency> |
|
157 |
<groupId>org.gvsig</groupId> |
|
158 |
<artifactId>org.gvsig.postgresql</artifactId> |
|
159 |
<version>${org.gvsig.postgresql.version}</version> |
|
160 |
<type>pom</type> |
|
161 |
<scope>import</scope> |
|
162 |
</dependency> |
|
163 |
<dependency> |
|
164 |
<groupId>org.gvsig</groupId> |
|
165 |
<artifactId>org.gvsig.vcsgis.lib.api</artifactId> |
|
166 |
<version>1.0.66</version> |
|
167 |
</dependency> |
|
168 |
<dependency> |
|
169 |
<groupId>org.gvsig</groupId> |
|
170 |
<artifactId>org.gvsig.vcsgis.lib.impl</artifactId> |
|
171 |
<version>1.0.66</version> |
|
172 |
</dependency> |
|
173 |
<dependency> |
|
174 |
<groupId>org.gvsig</groupId> |
|
175 |
<artifactId>org.gvsig.vcsgis.lib.impl</artifactId> |
|
176 |
<scope>test</scope> |
|
177 |
<type>test-jar</type> |
|
178 |
<version>1.0.66</version> |
|
179 |
</dependency> |
|
180 |
<dependency> |
|
181 |
<groupId>org.gvsig</groupId> |
|
182 |
<artifactId>org.gvsig.vcsgis.swing.api</artifactId> |
|
183 |
<version>1.0.66</version> |
|
184 |
</dependency> |
|
185 |
<dependency> |
|
186 |
<groupId>org.gvsig</groupId> |
|
187 |
<artifactId>org.gvsig.vcsgis.swing.impl</artifactId> |
|
188 |
<version>1.0.66</version> |
|
189 |
</dependency> |
|
190 |
<dependency> |
|
191 |
<groupId>org.gvsig</groupId> |
|
192 |
<artifactId>org.gvsig.vcsgis.tomcat.webapp</artifactId> |
|
193 |
<version>1.0.66</version> |
|
194 |
<type>war</type> |
|
195 |
</dependency> |
|
196 |
|
|
197 |
</dependencies> |
|
198 |
</dependencyManagement> |
|
199 |
|
|
200 |
<modules> |
|
201 |
<module>org.gvsig.vcsgis.lib</module> |
|
202 |
<module>org.gvsig.vcsgis.swing</module> |
|
203 |
<module>org.gvsig.vcsgis.app</module> |
|
204 |
<module>org.gvsig.vcsgis.tomcat</module> |
|
205 |
</modules> |
|
206 |
</project> |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.66/org.gvsig.vcsgis.app/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.vcsgis</artifactId> |
|
6 |
<version>1.0.66</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.vcsgis.app</artifactId> |
|
9 |
<packaging>pom</packaging> |
|
10 |
<name>${project.artifactId}</name> |
|
11 |
<modules> |
|
12 |
<module>org.gvsig.vcsgis.app.mainplugin</module> |
|
13 |
<module>org.gvsig.vcsgis.app.server</module> |
|
14 |
</modules> |
|
15 |
|
|
16 |
</project> |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.66/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 gvSIG |
|
2 |
Association. This program is free software; you can redistribute it and/or modify |
|
3 |
it under the terms of the GNU General Public License as published by the Free Software |
|
4 |
Foundation; either version 3 of the License, or (at your option) any later version. |
|
5 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
6 |
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
7 |
PURPOSE. See the GNU General Public License for more details. You should have received |
|
8 |
a copy of the GNU General Public License along with this program; if not, write to |
|
9 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
|
10 |
USA. For any additional information, do not hesitate to contact us at info AT gvsig.com, |
|
11 |
or visit our website www.gvsig.com. --> |
|
12 |
<assembly> |
|
13 |
<id>gvsig-plugin-package</id> |
|
14 |
<formats> |
|
15 |
<format>zip</format> |
|
16 |
</formats> |
|
17 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
18 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
19 |
<files> |
|
20 |
<file> |
|
21 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
22 |
<outputDirectory>lib</outputDirectory> |
|
23 |
</file> |
|
24 |
<file> |
|
25 |
<source>target/package.info</source> |
|
26 |
</file> |
|
27 |
</files> |
|
28 |
|
|
29 |
<fileSets> |
|
30 |
<fileSet> |
|
31 |
<directory>src/main/resources-plugin</directory> |
|
32 |
<outputDirectory>.</outputDirectory> |
|
33 |
</fileSet> |
|
34 |
</fileSets> |
|
35 |
|
|
36 |
|
|
37 |
<dependencySets> |
|
38 |
<dependencySet> |
|
39 |
<useProjectArtifact>false</useProjectArtifact> |
|
40 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
41 |
<outputDirectory>lib</outputDirectory> |
|
42 |
<includes> |
|
43 |
<include>org.gvsig:org.gvsig.vcsgis.lib.api</include> |
|
44 |
<include>org.gvsig:org.gvsig.vcsgis.lib.impl</include> |
|
45 |
<include>org.gvsig:org.gvsig.vcsgis.swing.api</include> |
|
46 |
<include>org.gvsig:org.gvsig.vcsgis.swing.impl</include> |
|
47 |
<include>javax.servlet:javax.servlet-api</include> |
|
48 |
|
|
49 |
</includes> |
|
50 |
</dependencySet> |
|
51 |
</dependencySets> |
|
52 |
|
|
53 |
</assembly> |
|
54 |
|
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.66/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/VCSGisDialogsHelper.java | ||
---|---|---|
1 |
/* |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2020 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, see <https://www.gnu.org/licenses/>. |
|
18 |
* |
|
19 |
* For any additional information, do not hesitate to contact us |
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
21 |
*/ |
|
22 |
|
|
23 |
package org.gvsig.vcsgis.app; |
|
24 |
|
|
25 |
import java.awt.event.ActionEvent; |
|
26 |
import java.awt.event.ComponentAdapter; |
|
27 |
import java.awt.event.ComponentEvent; |
|
28 |
import java.util.HashMap; |
|
29 |
import java.util.Map; |
|
30 |
import javax.swing.JPanel; |
|
31 |
import javax.swing.SwingUtilities; |
|
32 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
33 |
import org.gvsig.andami.ui.mdiManager.MDIManager; |
|
34 |
import org.gvsig.app.ApplicationLocator; |
|
35 |
import org.gvsig.tools.ToolsLocator; |
|
36 |
import org.gvsig.tools.i18n.I18nManager; |
|
37 |
import org.gvsig.tools.swing.api.Component; |
|
38 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
39 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
40 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
41 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
42 |
import org.gvsig.vcsgis.swing.VCSGisPanel; |
|
43 |
import org.slf4j.Logger; |
|
44 |
import org.slf4j.LoggerFactory; |
|
45 |
|
|
46 |
/** |
|
47 |
* |
|
48 |
* @author gvSIG Team |
|
49 |
*/ |
|
50 |
public class VCSGisDialogsHelper { |
|
51 |
private static final Logger LOGGER = LoggerFactory.getLogger(VCSGisDialogsHelper.class); |
|
52 |
|
|
53 |
public static class VCSGisDialogInfo { |
|
54 |
|
|
55 |
private VCSGisPanel panel; |
|
56 |
private final String name; |
|
57 |
private final String title; |
|
58 |
private String header; |
|
59 |
private String okLabel; |
|
60 |
private boolean closed; |
|
61 |
private Runnable action; |
|
62 |
private Dialog dialog; |
|
63 |
private boolean autoclose; |
|
64 |
|
|
65 |
public VCSGisDialogInfo(String name, VCSGisPanel thePanel, String title) { |
|
66 |
this.name = name; |
|
67 |
this.panel = thePanel; |
|
68 |
this.title = title; |
|
69 |
this.closed = true; |
|
70 |
this.autoclose = false; |
|
71 |
|
|
72 |
this.panel.asJComponent().addComponentListener(new ComponentAdapter() { |
|
73 |
@Override |
|
74 |
public void componentHidden(ComponentEvent e) { |
|
75 |
closed = true; |
|
76 |
} |
|
77 |
}); |
|
78 |
} |
|
79 |
|
|
80 |
public VCSGisDialogInfo(String name, VCSGisPanel thePanel, String title, String header, String okLabel) { |
|
81 |
this(name, thePanel, title); |
|
82 |
this.header = header; |
|
83 |
this.okLabel = okLabel; |
|
84 |
} |
|
85 |
|
|
86 |
private void performDialogAction() { |
|
87 |
action.run(); |
|
88 |
} |
|
89 |
|
|
90 |
public void setAction(Runnable action) { |
|
91 |
this.action = action; |
|
92 |
} |
|
93 |
|
|
94 |
public Component getPanel() { |
|
95 |
return this.panel; |
|
96 |
} |
|
97 |
|
|
98 |
public boolean isClosed() { |
|
99 |
return this.closed; |
|
100 |
} |
|
101 |
|
|
102 |
public String getName() { |
|
103 |
return this.name; |
|
104 |
} |
|
105 |
|
|
106 |
public void setAutoclose(boolean autoclose) { |
|
107 |
this.autoclose = autoclose; |
|
108 |
} |
|
109 |
|
|
110 |
private Dialog createDialog() { |
|
111 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
112 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
113 |
|
|
114 |
Dialog theDialog = winManager.createDialog( |
|
115 |
this.panel.asJComponent(), |
|
116 |
i18n.getTranslation(title), |
|
117 |
i18n.getTranslation(header), |
|
118 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
119 |
); |
|
120 |
theDialog.setAutoclose(false); |
|
121 |
|
|
122 |
this.panel.setDialog(theDialog); |
|
123 |
theDialog.setButtonLabel( |
|
124 |
WindowManager_v2.BUTTON_OK, |
|
125 |
i18n.getTranslation(okLabel) |
|
126 |
); |
|
127 |
theDialog.setButtonLabel( |
|
128 |
WindowManager_v2.BUTTON_CANCEL, |
|
129 |
i18n.getTranslation("_Close") |
|
130 |
); |
|
131 |
if (this.panel.isProcessing()) { |
|
132 |
theDialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false); |
|
133 |
} |
|
134 |
theDialog.addActionListener((ActionEvent e) -> { |
|
135 |
switch (theDialog.getAction()) { |
|
136 |
case WindowManager_v2.BUTTON_OK: |
|
137 |
Thread task = new Thread(() -> { |
|
138 |
if(this.autoclose){ |
|
139 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false); |
|
140 |
} |
|
141 |
performDialogAction(); |
|
142 |
if(this.autoclose){ |
|
143 |
close(); |
|
144 |
} |
|
145 |
}, "VCSGis" + name); |
|
146 |
task.start(); |
|
147 |
break; |
|
148 |
case WindowManager_v2.BUTTON_CANCEL: |
|
149 |
close(); |
|
150 |
break; |
|
151 |
} |
|
152 |
}); |
|
153 |
return theDialog; |
|
154 |
} |
|
155 |
|
|
156 |
public void show() { |
|
157 |
if (!this.closed) { |
|
158 |
MDIManager manager = ApplicationLocator.getApplicationManager().getUIManager(); |
|
159 |
manager.moveToFrom(manager.getWindow((JPanel) this.panel.asJComponent())); |
|
160 |
return; |
|
161 |
} |
|
162 |
this.closed = false; |
|
163 |
if( this.action==null ) { |
|
164 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
165 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
166 |
winManager.showWindow( |
|
167 |
this.panel.asJComponent(), |
|
168 |
i18n.getTranslation(this.title), |
|
169 |
WindowManager.MODE.WINDOW |
|
170 |
); |
|
171 |
} else { |
|
172 |
this.dialog = this.createDialog(); |
|
173 |
this.dialog.show(WindowManager.MODE.WINDOW); |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
private void close() { |
|
178 |
if (this.closed || this.dialog == null) { |
|
179 |
this.panel = null; |
|
180 |
this.dialog = null; |
|
181 |
return; |
|
182 |
} |
|
183 |
if(!SwingUtilities.isEventDispatchThread()){ |
|
184 |
SwingUtilities.invokeLater(this::close); |
|
185 |
return; |
|
186 |
} |
|
187 |
this.dialog.asJComponent().setVisible(false); |
|
188 |
this.panel = null; |
|
189 |
this.dialog = null; |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
private Map<String, VCSGisDialogInfo> dialogsInfo; |
|
194 |
|
|
195 |
public VCSGisDialogInfo getDialog(String name) { |
|
196 |
if (this.dialogsInfo == null) { |
|
197 |
return null; |
|
198 |
} |
|
199 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
200 |
return info; |
|
201 |
} |
|
202 |
|
|
203 |
public VCSGisDialogInfo getOrCreateDialog(String name, VCSGisPanel panel, String title, String header, String okLabel, Runnable action) { |
|
204 |
if (this.dialogsInfo == null) { |
|
205 |
this.dialogsInfo = new HashMap<>(); |
|
206 |
} |
|
207 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
208 |
if (info == null || info.isClosed() ) { |
|
209 |
info = new VCSGisDialogInfo(name, panel, title, header, okLabel); |
|
210 |
info.setAction(action); |
|
211 |
this.dialogsInfo.put(name, info); |
|
212 |
} |
|
213 |
return info; |
|
214 |
} |
|
215 |
|
|
216 |
public VCSGisDialogInfo getOrCreateDialog(String name, VCSGisPanel panel, String title) { |
|
217 |
if (this.dialogsInfo == null) { |
|
218 |
this.dialogsInfo = new HashMap<>(); |
|
219 |
} |
|
220 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
221 |
if (info == null || info.isClosed()) { |
|
222 |
info = new VCSGisDialogInfo(name, panel, title); |
|
223 |
this.dialogsInfo.put(name, info); |
|
224 |
} |
|
225 |
return info; |
|
226 |
} |
|
227 |
|
|
228 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.66/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/addlayer/AbstractWizardVCSGis.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.addlayer; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Component; |
|
5 |
import java.awt.Cursor; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.net.URL; |
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.Collection; |
|
10 |
import java.util.HashMap; |
|
11 |
import java.util.List; |
|
12 |
import java.util.Map; |
|
13 |
import java.util.function.Function; |
|
14 |
import java.util.function.Predicate; |
|
15 |
import javax.swing.ImageIcon; |
|
16 |
import javax.swing.JButton; |
|
17 |
import javax.swing.JCheckBox; |
|
18 |
import javax.swing.JComboBox; |
|
19 |
import javax.swing.JComponent; |
|
20 |
import javax.swing.JLabel; |
|
21 |
import javax.swing.JList; |
|
22 |
import javax.swing.JOptionPane; |
|
23 |
import javax.swing.JTextField; |
|
24 |
import javax.swing.SwingUtilities; |
|
25 |
import javax.swing.UIManager; |
|
26 |
import javax.swing.event.ChangeEvent; |
|
27 |
import org.apache.commons.io.FilenameUtils; |
|
28 |
import org.apache.commons.lang3.StringUtils; |
|
29 |
import org.gvsig.app.gui.WizardPanel; |
|
30 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
|
31 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
|
32 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
33 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
34 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
35 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
36 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
37 |
import org.gvsig.geodb.TableInfo; |
|
38 |
import org.gvsig.geodb.TableInfoController; |
|
39 |
import org.gvsig.tools.ToolsLocator; |
|
40 |
import org.gvsig.tools.i18n.I18nManager; |
|
41 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
42 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
43 |
import org.gvsig.tools.swing.api.ToolsSwingUtils; |
|
44 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
|
45 |
import org.gvsig.tools.swing.api.task.TaskStatusController; |
|
46 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
|
47 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
48 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
49 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
50 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
51 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
52 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
53 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_OK; |
|
54 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
55 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
|
56 |
import org.gvsig.vcsgis.swing.VCSGisEntitySelectorController; |
|
57 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_BEGIN_PROCESSING_ID; |
|
58 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_CHECK_ID; |
|
59 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_END_PROCESSING_ID; |
|
60 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_RELOAD_ID; |
|
61 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_SELECT_ID; |
|
62 |
import org.gvsig.vcsgis.swing.VCSGisJInitWorkspace; |
|
63 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
|
64 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
|
65 |
import org.gvsig.vcsgis.swing.VCSGisSwingServices; |
|
66 |
import org.slf4j.Logger; |
|
67 |
import org.slf4j.LoggerFactory; |
|
68 |
|
|
69 |
/** |
|
70 |
* |
|
71 |
* @author jjdelcerro |
|
72 |
*/ |
|
73 |
@SuppressWarnings("UseSpecificCatch") |
|
74 |
public abstract class AbstractWizardVCSGis extends WizardPanel { |
|
75 |
|
|
76 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractWizardVCSGis.class); |
|
77 |
|
|
78 |
protected WizardVCSGisViewExtended view; |
|
79 |
private PickerController<VCSGisWorkspace> workspacePicker; |
|
80 |
protected Map<String, TableInfo> tablesInfo = null; |
|
81 |
private boolean processing; |
|
82 |
private TaskStatusController taskStatusController; |
|
83 |
private TableInfoController tableInfoController; |
|
84 |
private VCSGisEntitySelectorController entitySelector; |
|
85 |
|
|
86 |
private class VCSGisTableInfoController extends TableInfoController { |
|
87 |
|
|
88 |
public VCSGisTableInfoController(JButton btnDeselectAllColumns, JButton btnSelectAllColumns, JList lstColumns, JTextField txtName, JComboBox cboIdField, JComboBox cboGeometryField, JTextField txtProjection, JButton btnProjection, JTextField txtFilter, JButton btnFilter, JButton btnFilterBookmarks, JButton btnFilterHistory, JButton btnAdvancedProperties, JLabel lblReadOnlyNotification, JComponent pnlCfgActions, JButton btnChangeViewProjection, JCheckBox visible) { |
|
89 |
super(btnDeselectAllColumns, btnSelectAllColumns, lstColumns, txtName, cboIdField, cboGeometryField, txtProjection, btnProjection, txtFilter, btnFilter, btnFilterBookmarks, btnFilterHistory, btnAdvancedProperties, lblReadOnlyNotification, pnlCfgActions, btnChangeViewProjection, visible); |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public void put(TableInfo tableInfo) { |
|
94 |
if( tableInfo!=null ) { |
|
95 |
Boolean v = tableInfo.getVisible(); |
|
96 |
if( v == null ) { |
|
97 |
VCSGisEntity entity = ((VCSGisTableInfo)tableInfo).getEntity(); |
|
98 |
if( entity!=null ) { |
|
99 |
String category = getCategory(entity); |
|
100 |
boolean defaultVisibility = entity.getCategoryTags(category).getBoolean("visibility",true); |
|
101 |
tableInfo.setVisible(defaultVisibility); |
|
102 |
} |
|
103 |
} |
|
104 |
} |
|
105 |
super.put(tableInfo); |
|
106 |
} |
|
107 |
|
|
108 |
} |
|
109 |
|
|
110 |
public AbstractWizardVCSGis() { |
|
111 |
initComponents(); |
|
112 |
} |
|
113 |
|
|
114 |
private static void waitCursor(Component component, Runnable action) { |
|
115 |
Cursor saved_cursor = component.getCursor(); |
|
116 |
try { |
|
117 |
component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
|
118 |
action.run(); |
|
119 |
} finally { |
|
120 |
component.setCursor(saved_cursor); |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
private void initComponents() { |
|
125 |
DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager(); |
|
126 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
127 |
ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
|
128 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
129 |
|
|
130 |
this.view = new WizardVCSGisViewExtended(); |
|
131 |
// this.view.txtRepositoryInfo.setVisible(false); |
|
132 |
|
|
133 |
this.entitySelector = swingManager.createEntitySelectorController( |
|
134 |
this.view.treeTables, |
|
135 |
this.view.txtTablesFilter, |
|
136 |
this.view.btnTablesFilter); |
|
137 |
|
|
138 |
Predicate<VCSGisEntity> entitySelectorFilter = VCSGisEntitySelectorController.ALL_ENTITIES; |
|
139 |
|
|
140 |
if(this.requireGeometry()){ |
|
141 |
entitySelectorFilter = (VCSGisEntity t) -> (StringUtils.isNotBlank(t.getGeometryFieldName())); |
|
142 |
} |
|
143 |
|
|
144 |
this.entitySelector.setFilter(entitySelectorFilter); |
|
145 |
this.entitySelector.setViewFilter(entitySelectorFilter); |
|
146 |
this.entitySelector.setLabelEntityFormatter(this.getLabelEntityFormatter()); |
|
147 |
|
|
148 |
this.entitySelector.setChecksEnabled(true); |
|
149 |
|
|
150 |
TaskStatusSwingManager taskStatusManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
|
151 |
|
|
152 |
this.taskStatusController = taskStatusManager.createTaskStatusController( |
|
153 |
this.view.lblStatusTitle, |
|
154 |
this.view.lblStatusMessages, |
|
155 |
this.view.pbStatus |
|
156 |
); |
|
157 |
this.taskStatusController.setShowCancelButton(false); |
|
158 |
this.taskStatusController.setShowRemoveTaskButton(false); |
|
159 |
this.taskStatusController.bind(ToolsLocator.getTaskStatusManager()); |
|
160 |
|
|
161 |
toolsSwingManager.translate(this.view.lblColumns); |
|
162 |
toolsSwingManager.translate(this.view.lblWorkspace); |
|
163 |
toolsSwingManager.translate(this.view.lblFilter); |
|
164 |
toolsSwingManager.translate(this.view.lblGeometryField); |
|
165 |
toolsSwingManager.translate(this.view.lblIdField); |
|
166 |
toolsSwingManager.translate(this.view.lblName); |
|
167 |
toolsSwingManager.translate(this.view.lblProjection); |
|
168 |
toolsSwingManager.translate(this.view.lblTable); |
|
169 |
toolsSwingManager.translate(this.view.cboWorkspaces); |
|
170 |
toolsSwingManager.translate(this.view.btnAddWorkspace); |
|
171 |
toolsSwingManager.translate(this.view.btnCheckout); |
|
172 |
toolsSwingManager.translate(this.view.btnInitWorkspace); |
|
173 |
toolsSwingManager.translate(this.view.chkMaintainStructureInToC); |
|
174 |
toolsSwingManager.translate(this.view.btnTablesCheckAll); |
|
175 |
toolsSwingManager.translate(this.view.btnTablesUncheckAll); |
|
176 |
toolsSwingManager.translate(this.view.btnTablesCollapseAll); |
|
177 |
toolsSwingManager.translate(this.view.btnTablesExpandAll); |
|
178 |
toolsSwingManager.translate(this.view.chkCheckScale); |
|
179 |
toolsSwingManager.translate(this.view.chkAddToCWhenLoadingAll); |
|
180 |
toolsSwingManager.translate(this.view.tabTableInfo); |
|
181 |
toolsSwingManager.translate(this.view.lblVisible); |
|
182 |
|
|
183 |
this.view.btnInitWorkspace.setText(toHTML(this.view.btnInitWorkspace.getText())); |
|
184 |
// toolsSwingManager.translate(this.view.txtRepositoryInfo); |
|
185 |
|
|
186 |
toolsSwingManager.addClearButton(this.view.txtName); |
|
187 |
toolsSwingManager.setDefaultPopupMenu(this.view.txtName); |
|
188 |
|
|
189 |
this.view.btnInitWorkspace.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
190 |
this.view.btnAddWorkspace.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
191 |
|
|
192 |
this.workspacePicker = swingManager.createWorkspacePickerController( |
|
193 |
this.view.cboWorkspaces, |
|
194 |
this.view.btnAddWorkspace |
|
195 |
); |
|
196 |
|
|
197 |
this.workspacePicker.addChangeListener((ChangeEvent e) -> { |
|
198 |
waitCursor(this, () -> { |
|
199 |
doChangeWorkspace(); |
|
200 |
doUpdateComponents(); |
|
201 |
}); |
|
202 |
}); |
|
203 |
|
|
204 |
this.entitySelector.addActionListener((ActionEvent e) -> { |
|
205 |
switch(e.getID()){ |
|
206 |
case ACTION_RELOAD_ID: |
|
207 |
doReloadTablesInfo(); |
|
208 |
break; |
|
209 |
case ACTION_BEGIN_PROCESSING_ID: |
|
210 |
case ACTION_END_PROCESSING_ID: |
|
211 |
doUpdateComponents(); |
|
212 |
break; |
|
213 |
case ACTION_SELECT_ID: |
|
214 |
doChangeTableSelected(); |
|
215 |
break; |
|
216 |
case ACTION_CHECK_ID: |
|
217 |
doChangeTableChecked(); |
|
218 |
doUpdateComponents(); |
|
219 |
break; |
|
220 |
|
|
221 |
} |
|
222 |
}); |
|
223 |
this.view.btnTablesCheckAll.addActionListener((ActionEvent e) -> { |
|
224 |
// this.entitySelector.checkAll(); |
|
225 |
waitCursor(this, () -> { |
|
226 |
List<String> entityCodes = new ArrayList<>(); |
|
227 |
Collection<VCSGisEntity> entities = entitySelector.getEntities(); |
|
228 |
for (VCSGisEntity entity : entities) { |
|
229 |
if( entity instanceof VCSGisWorkspaceEntity ){ |
|
230 |
entityCodes.add(entity.getEntityCode()); |
|
231 |
} |
|
232 |
} |
|
233 |
entitySelector.setCheck(entityCodes, true); |
|
234 |
}); |
|
235 |
}); |
|
236 |
|
|
237 |
this.view.btnTablesUncheckAll.addActionListener((ActionEvent e) -> { |
|
238 |
this.entitySelector.clearChecks(); |
|
239 |
}); |
|
240 |
|
|
241 |
this.view.btnTablesCollapseAll.addActionListener((ActionEvent e) -> { |
|
242 |
this.entitySelector.collapseAll(); |
|
243 |
}); |
|
244 |
|
|
245 |
this.view.btnTablesExpandAll.addActionListener((ActionEvent e) -> { |
|
246 |
this.entitySelector.expandAll(); |
|
247 |
}); |
|
248 |
|
|
249 |
this.view.btnInitWorkspace.addActionListener((ActionEvent e) -> { |
|
250 |
doShowInitWorkspace(); |
|
251 |
}); |
|
252 |
|
|
253 |
this.view.btnCheckout.addActionListener((ActionEvent e) -> { |
|
254 |
doCheckout(); |
|
255 |
}); |
|
256 |
|
|
257 |
this.tableInfoController = new VCSGisTableInfoController( |
|
258 |
this.view.btnDeselectAllColumns, |
|
259 |
this.view.btnSelectAllColumns, |
|
260 |
this.view.lstColumns, |
|
261 |
this.view.txtName, |
|
262 |
this.view.cboIdField, |
|
263 |
this.view.cboGeometryField, |
|
264 |
this.view.txtProjection, |
|
265 |
this.view.btnProjection, |
|
266 |
this.view.txtFilter, |
|
267 |
this.view.btnFilter, |
|
268 |
this.view.btnFilterBookmarks, |
|
269 |
this.view.btnFilterHistory, |
|
270 |
this.view.btnAdvancedProperties, |
|
271 |
this.view.lblReadOnlyNotification, |
|
272 |
null, |
|
273 |
this.view.btnChangeViewProjection, |
|
274 |
this.view.chkVisible |
|
275 |
); |
|
276 |
this.view.btnChangeViewProjection.setVisible(this.requireGeometry()); |
|
277 |
|
|
278 |
this.view.btnInitWorkspace.setBackground(UIManager.getColor("Panel.background")); |
|
279 |
// this.view.txtRepositoryInfo.setBackground(UIManager.getColor("Panel.background")); |
|
280 |
|
|
281 |
this.clearTables(); |
|
282 |
|
|
283 |
this.view.chkMaintainStructureInToC.setVisible(false); |
|
284 |
this.view.chkMaintainStructureInToC.setSelected(true); |
|
285 |
|
|
286 |
this.view.chkCheckScale.setSelected(true); |
|
287 |
|
|
288 |
this.view.chkAddToCWhenLoadingAll.setSelected(true); |
|
289 |
|
|
290 |
this.setLayout(new BorderLayout()); |
|
291 |
this.add(this.view, BorderLayout.CENTER); |
|
292 |
|
|
293 |
ToolsSwingUtils.ensureRowsCols(this, 22, 90, 25, 100); |
|
294 |
doUpdateComponents(); |
|
295 |
} |
|
296 |
|
|
297 |
protected abstract boolean requireGeometry(); |
|
298 |
|
|
299 |
protected boolean maintainStructureInToC() { |
|
300 |
return this.view.chkMaintainStructureInToC.isSelected(); |
|
301 |
} |
|
302 |
|
|
303 |
protected void setVidibleMaintainStructureInToC(boolean visible) { |
|
304 |
this.view.chkMaintainStructureInToC.setVisible(visible); |
|
305 |
} |
|
306 |
|
|
307 |
protected Collection<TableInfo> getTablesInformation() { |
|
308 |
this.updateTableInfoFromUI(); |
|
309 |
if( this.tablesInfo == null ) { |
|
310 |
this.tablesInfo = new HashMap<>(); |
|
311 |
} |
|
312 |
return this.tablesInfo.values(); |
|
313 |
} |
|
314 |
|
|
315 |
private void clearTables() { |
|
316 |
this.entitySelector.clear(); |
|
317 |
this.tableInfoController.clear(); |
|
318 |
} |
|
319 |
|
|
320 |
private void doChangeWorkspace() { |
|
321 |
if (notInSwingThreadInvokeLater(this::doChangeWorkspace)) { |
|
322 |
return; |
|
323 |
} |
|
324 |
|
|
325 |
VCSGisWorkspace workspace = workspacePicker.get(); |
|
326 |
|
|
327 |
this.entitySelector.setWorkspace(workspace); |
|
328 |
// if (workspace == null) { |
|
329 |
// this.view.txtRepositoryInfo.setText(""); |
|
330 |
// return; |
|
331 |
// } |
|
332 |
// |
|
333 |
// this.view.txtRepositoryInfo.setText(workspace.getRepository().getLabel()); |
|
334 |
} |
|
335 |
|
|
336 |
private TableInfo getTableInfo(VCSGisEntity entity){ |
|
337 |
Collection<TableInfo> tablesInformation = getTablesInformation(); |
|
338 |
for (TableInfo tableInfo : tablesInformation) { |
|
339 |
VCSGisEntity tableInfoEntity = (VCSGisEntity) tableInfo.getProperty("entity"); |
|
340 |
if(tableInfoEntity!=null && StringUtils.equals(tableInfoEntity.getEntityCode(), entity.getEntityCode())){ |
|
341 |
return tableInfo; |
|
342 |
} |
|
343 |
} |
|
344 |
return null; |
|
345 |
} |
|
346 |
|
|
347 |
private void doChangeTableSelected() { |
|
348 |
if( notInSwingThreadInvokeLater(() -> {doChangeTableSelected();}) ) { |
|
349 |
return; |
|
350 |
} |
|
351 |
|
|
352 |
VCSGisEntity selected = this.entitySelector.getSelectedEntity(); |
|
353 |
if(selected == null){ |
|
354 |
this.tableInfoController.put(null); |
|
355 |
return; |
|
356 |
} |
|
357 |
TableInfo tableInfo = getTableInfo(selected); |
|
358 |
if (tableInfo != null) { |
|
359 |
this.updateTableInfoFromUI(); |
|
360 |
this.tableInfoController.put(tableInfo); |
|
361 |
this.tableInfoController.setEnabled(true); |
|
362 |
} else { |
|
363 |
this.tableInfoController.clear(); |
|
364 |
this.tableInfoController.setEnabled(false); |
|
365 |
} |
|
366 |
|
|
367 |
showMessage(""); |
|
368 |
doUpdateComponents(); |
|
369 |
} |
|
370 |
|
|
371 |
private void doChangeTableChecked() { |
|
372 |
List<VCSGisEntity> checkedEntities = this.entitySelector.getCheckedEntities(); |
|
373 |
List<String> entityCodes = new ArrayList<>(); |
|
374 |
for (VCSGisEntity checkedEntity : checkedEntities) { |
|
375 |
if( checkedEntity!=null && !(checkedEntity instanceof VCSGisWorkspaceEntity)){ |
|
376 |
entityCodes.add(checkedEntity.getEntityCode()); |
|
377 |
} |
|
378 |
} |
|
379 |
this.entitySelector.setCheck(entityCodes, false); |
|
380 |
|
|
381 |
Collection<TableInfo> tablesInformation = getTablesInformation(); |
|
382 |
for (TableInfo tableInfo : tablesInformation) { |
|
383 |
VCSGisEntity tableInfoEntity = (VCSGisEntity) tableInfo.getProperty("entity"); |
|
384 |
tableInfo.setSelected(checkedEntities.contains(tableInfoEntity)); |
|
385 |
} |
|
386 |
this.checkFinishable(); |
|
387 |
} |
|
388 |
|
|
389 |
|
|
390 |
private void updateTableInfoFromUI() { |
|
391 |
String previousId = this.tableInfoController.getId(); |
|
392 |
if (previousId == null) { |
|
393 |
return; |
|
394 |
} |
|
395 |
|
|
396 |
if (this.tablesInfo != null && !this.tablesInfo.isEmpty()) { |
|
397 |
TableInfo previousInfo = this.tablesInfo.get(previousId); |
|
398 |
if (previousInfo != null) { |
|
399 |
this.tableInfoController.fetch(previousInfo); |
|
400 |
} |
|
401 |
} |
|
402 |
} |
|
403 |
|
|
404 |
@Override |
|
405 |
public void initWizard() { |
|
406 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
407 |
setTabName(i18n.getTranslation("_VCSGis")); |
|
408 |
} |
|
409 |
|
|
410 |
@Override |
|
411 |
public boolean areSettingsValid() { |
|
412 |
if(processing){ |
|
413 |
return false; |
|
414 |
} |
|
415 |
boolean hasInvalidValues = false; |
|
416 |
boolean hasSelectedTables = false; |
|
417 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
|
418 |
if (tableInfo.isSelected()) { |
|
419 |
hasSelectedTables = true; |
|
420 |
if (!tableInfo.hasValidValues()) { |
|
421 |
hasInvalidValues = true; |
|
422 |
} |
|
423 |
} |
|
424 |
} |
|
425 |
return hasSelectedTables && !hasInvalidValues; |
|
426 |
} |
|
427 |
|
|
428 |
@Override |
|
429 |
public DataStoreParameters[] getParameters() { |
|
430 |
int sz = 0; |
|
431 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
|
432 |
if( tableInfo.isSelected() ) { |
|
433 |
sz++; |
|
434 |
} |
|
435 |
} |
|
436 |
if( sz == 0 ) { |
|
437 |
return null; |
|
438 |
} |
|
439 |
DataStoreParameters[] dbParameters = new DataStoreParameters[sz]; |
|
440 |
int n = 0; |
|
441 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
|
442 |
if( tableInfo.isSelected() ) { |
|
443 |
dbParameters[n++] = tableInfo.getParameters(); |
|
444 |
} |
|
445 |
} |
|
446 |
return dbParameters; |
|
447 |
} |
|
448 |
|
|
449 |
@Override |
|
450 |
public void execute() { |
|
451 |
executeWizard(); |
|
452 |
} |
|
453 |
|
|
454 |
@Override |
|
455 |
public void close() { |
|
456 |
|
|
457 |
} |
|
458 |
|
|
459 |
protected void checkFinishable() { |
|
460 |
boolean finishable = areSettingsValid(); |
|
461 |
callStateChanged(finishable); |
|
462 |
} |
|
463 |
|
|
464 |
private void doUpdateComponents() { |
|
465 |
VCSGisEntity entity = this.entitySelector.getSelectedEntity(); |
|
466 |
|
|
467 |
boolean theProcessing = this.processing || this.entitySelector.isProcessing(); |
|
468 |
|
|
469 |
VCSGisWorkspace ws = getWorkspace(); |
|
470 |
if(entity == null){ |
|
471 |
this.view.btnCheckout.setEnabled(false); |
|
472 |
this.tableInfoController.setEnabled(false); |
|
473 |
} else if(entity instanceof VCSGisWorkspaceEntity){ |
|
474 |
this.view.btnCheckout.setEnabled(false); |
|
475 |
this.tableInfoController.setEditable(!theProcessing && ws != null); |
|
476 |
this.tableInfoController.setEnabled(ws != null); |
|
477 |
} else { //Entidad de repositorio |
|
478 |
this.view.btnCheckout.setEnabled(!theProcessing && ws != null); |
|
479 |
this.tableInfoController.setEnabled(false); |
|
480 |
} |
|
481 |
|
|
482 |
this.entitySelector.setEnabled(!theProcessing && ws != null); |
|
483 |
this.view.btnTablesCheckAll.setEnabled(this.entitySelector.isEnabled()); |
|
484 |
this.view.btnTablesUncheckAll.setEnabled(this.entitySelector.isEnabled()); |
|
485 |
this.view.btnTablesCollapseAll.setEnabled(this.entitySelector.isEnabled()); |
|
486 |
this.view.btnTablesExpandAll.setEnabled(this.entitySelector.isEnabled()); |
|
487 |
this.workspacePicker.setEnabled(!theProcessing); |
|
488 |
this.view.btnInitWorkspace.setEnabled(!theProcessing); |
|
489 |
// this.view.txtRepositoryInfo.setEnabled(!theProcessing && ws != null); |
|
490 |
this.setVisibleStatus(theProcessing); |
|
491 |
this.checkFinishable(); |
|
492 |
} |
|
493 |
|
|
494 |
private void doShowInitWorkspace() { |
|
495 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
496 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
497 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
498 |
|
|
499 |
final VCSGisJInitWorkspace panelInitWorkspace = swingManager.createInitWorkspacePanel(); |
|
500 |
final Dialog dialogInitWorkspace = winManager.createDialog( |
|
501 |
panelInitWorkspace.asJComponent(), |
|
502 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy"), |
|
503 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy"), |
|
504 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
505 |
); |
|
506 |
|
|
507 |
panelInitWorkspace.setDialog(dialogInitWorkspace); |
|
508 |
dialogInitWorkspace.setButtonLabel( |
|
509 |
WindowManager_v2.BUTTON_OK, |
|
510 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy") |
|
511 |
); |
|
512 |
dialogInitWorkspace.addActionListener((ActionEvent e) -> { |
|
513 |
switch (dialogInitWorkspace.getAction()) { |
|
514 |
case WindowManager_v2.BUTTON_OK: |
|
515 |
int r = panelInitWorkspace.initializeWorkspace(); |
|
516 |
if (r != 0) { |
|
517 |
String message = "_Cant_initialize_workingcopy_{0}"; |
|
518 |
|
|
519 |
StringBuilder compoundMessage = new StringBuilder(); |
|
520 |
String[] messageArgs = new String[]{panelInitWorkspace.getWorkspaceName()}; |
|
521 |
|
|
522 |
compoundMessage.append(i18nManager.getTranslation( |
|
523 |
message, |
|
524 |
messageArgs |
|
525 |
)); |
|
526 |
|
|
527 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
528 |
dialogsManager.messageDialog( |
|
529 |
compoundMessage.toString(), |
|
530 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy"), |
|
531 |
JOptionPane.WARNING_MESSAGE |
|
532 |
); |
|
533 |
} |
|
534 |
|
|
535 |
break; |
|
536 |
|
|
537 |
} |
|
538 |
}); |
|
539 |
dialogInitWorkspace.show(WindowManager.MODE.DIALOG); |
|
540 |
} |
|
541 |
|
|
542 |
public VCSGisWorkspace getWorkspace() { |
|
543 |
return this.workspacePicker.get(); |
|
544 |
} |
|
545 |
|
|
546 |
private void doReloadTablesInfo() { |
|
547 |
if (notInSwingThreadInvokeLater(() -> { doReloadTablesInfo(); })) { |
|
548 |
return; |
|
549 |
} |
|
550 |
|
|
551 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
552 |
|
|
553 |
try { |
|
554 |
Collection<VCSGisEntity> entities = this.entitySelector.getEntities(); |
|
555 |
for (VCSGisEntity entity : entities) { |
|
556 |
if (entity instanceof VCSGisWorkspaceEntity) { |
|
557 |
JDBCStoreParameters parameters = getWorkspace().getExplorer().get(entity.getEntityName()); |
|
558 |
TableInfo tableInfo = new VCSGisTableInfo(entity, parameters, this.requireGeometry(), false); |
|
559 |
if(StringUtils.isNotBlank(entity.getLabel()) ) { |
|
560 |
tableInfo.setDocumentName(entity.getLabel()); |
|
561 |
} |
|
562 |
tableInfo.setProperty("entity", entity); |
|
563 |
this.tablesInfo.put(tableInfo.getId(), tableInfo); |
|
564 |
} |
|
565 |
} |
|
566 |
|
|
567 |
} catch (Exception e) { |
|
568 |
LOGGER.warn("_Cant_update_layers_list", e); |
|
569 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
570 |
dialogs.messageDialog( |
|
571 |
i18n.getTranslation("_Cant_update_layers_list") + "\n" + e.getMessage(), |
|
572 |
i18n.getTranslation("_Add_layer"), |
|
573 |
JOptionPane.WARNING_MESSAGE |
|
574 |
); |
|
575 |
} |
|
576 |
} |
|
577 |
|
|
578 |
private void doCheckout() { |
|
579 |
VCSGisWorkspace workspace = getWorkspace(); |
|
580 |
if (workspace == null) { |
|
581 |
return; |
|
582 |
} |
|
583 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
584 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
585 |
VCSGisEntity rEntity = this.entitySelector.getSelectedEntity(); |
|
586 |
if(rEntity== null || rEntity instanceof VCSGisWorkspaceEntity){ |
|
587 |
return; |
|
588 |
} |
|
589 |
final String entityName = rEntity.getEntityName(); |
|
590 |
Thread task = new Thread(() -> { |
|
591 |
try { |
|
592 |
processing = true; |
|
593 |
doUpdateComponents(); |
|
594 |
|
|
595 |
showMessage(i18n.getTranslation("_Checking_out")); |
|
596 |
int res = workspace.checkout( |
|
597 |
entityName, |
|
598 |
null, |
|
599 |
this.getTaskStatusController().getSimpleTaskStatus() |
|
600 |
); |
|
601 |
if (res != ERR_OK) { |
|
602 |
LOGGER.warn("_Cant_checkout_table"); |
|
603 |
dialogs.messageDialog( |
|
604 |
i18n.getTranslation("_Cant_checkout_table") + "\n" + workspace.getErrorMessage(res), |
|
605 |
i18n.getTranslation("_Add_table"), |
|
606 |
JOptionPane.WARNING_MESSAGE |
|
607 |
); |
|
608 |
return; |
|
609 |
} |
|
610 |
downloadAndRegisterResources(entityName); |
|
611 |
showMessage(i18n.getTranslation("_Checkout_finished")); |
|
612 |
JDBCStoreParameters parameters = getWorkspace().getExplorer().get(entityName); |
|
613 |
TableInfo tableInfo = new VCSGisTableInfo(workspace.getWorkspaceEntity(entityName), parameters, this.requireGeometry(), false); |
|
614 |
this.tablesInfo.put(tableInfo.getId(), tableInfo); |
|
615 |
doPostCheckout(entityName); |
|
616 |
} catch (Exception e) { |
|
617 |
LOGGER.warn("_Cant_add_table"); |
|
618 |
dialogs.messageDialog( |
|
619 |
i18n.getTranslation("_Cant_add_table") + "\n" + e.getMessage(), |
|
620 |
i18n.getTranslation("_Add_table"), |
|
621 |
JOptionPane.WARNING_MESSAGE |
|
622 |
); |
|
623 |
} finally { |
|
624 |
processing = false; |
|
625 |
doUpdateComponents(); |
|
626 |
} |
|
627 |
}, "VCSGisAddTableCheckout"); |
|
628 |
processing = true; |
|
629 |
doUpdateComponents(); |
|
630 |
task.start(); |
|
631 |
} |
|
632 |
|
|
633 |
private void doPostCheckout(String entityName) { |
|
634 |
if (notInSwingThreadInvokeLater(() -> { doPostCheckout(entityName); })) { |
|
635 |
return; |
|
636 |
} |
|
637 |
VCSGisWorkspace workspace = getWorkspace(); |
|
638 |
if (workspace == null) { |
|
639 |
return; |
|
640 |
} |
|
641 |
|
|
642 |
doChangeWorkspace(); |
|
643 |
this.entitySelector.setSelectedEntity(workspace.getWorkspaceEntity(entityName)); |
|
644 |
doChangeTableSelected(); |
|
645 |
} |
|
646 |
|
|
647 |
private void showMessage(String message) { |
|
648 |
if( notInSwingThreadInvokeLater(() -> {showMessage(message);}) ) { |
|
649 |
return; |
|
650 |
} |
|
651 |
this.view.lblStatusMessages.setText(message); |
|
652 |
} |
|
653 |
|
|
654 |
public boolean isProcessing() { |
|
655 |
return processing; |
|
656 |
} |
|
657 |
|
|
658 |
public void setVisibleStatus(boolean visible) { |
|
659 |
if( notInSwingThreadInvokeLater(() -> {setVisibleStatus(visible);}) ) { |
|
660 |
return; |
|
661 |
} |
|
662 |
this.view.lblStatusTitle.setVisible(visible); |
|
663 |
this.view.pbStatus.setVisible(visible); |
|
664 |
this.view.lblStatusMessages.setVisible(true); |
|
665 |
} |
|
666 |
|
|
667 |
public TaskStatusController getTaskStatusController() { |
|
668 |
return this.taskStatusController; |
|
669 |
} |
|
670 |
|
|
671 |
public static boolean notInSwingThreadInvokeLater(Runnable x) { |
|
672 |
if( SwingUtilities.isEventDispatchThread() ) { |
|
673 |
return false; |
|
674 |
} |
|
675 |
SwingUtilities.invokeLater(x); |
|
676 |
return true; |
|
677 |
} |
|
678 |
|
|
679 |
protected static class WizardVCSGisViewExtended extends AbstractWizardVCSGisView { |
|
680 |
|
|
681 |
@Override |
|
682 |
public ImageIcon loadImage(String imageName) { |
|
683 |
String name = FilenameUtils.getBaseName(imageName); |
|
684 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
|
685 |
if (theme.exists(name)) { |
|
686 |
return theme.get(name); |
|
687 |
} |
|
688 |
URL url = WizardVCSGisViewExtended.class.getResource("images/" + name + ".png"); |
|
689 |
if (url == null) { |
|
690 |
return null; |
|
691 |
} |
|
692 |
return new ImageIcon(url); |
|
693 |
} |
|
694 |
} |
|
695 |
|
|
696 |
private String toHTML(String s) { |
|
697 |
s = StringUtils.replace(s, "\n", "<br>"); |
|
698 |
s = StringUtils.replace(s, "<html>", ""); |
|
699 |
s = StringUtils.replace(s, "</html>", ""); |
|
700 |
s = "<html>"+s+"</html>"; |
|
701 |
return s; |
|
702 |
} |
|
703 |
|
|
704 |
protected void downloadAndRegisterResources(String tableName) { |
|
705 |
VCSGisWorkspace workspace = getWorkspace(); |
|
706 |
VCSGisWorkspaceEntity entity = workspace.getWorkspaceEntityByName(tableName); |
|
707 |
if(entity == null){ |
|
708 |
return; |
|
709 |
} |
|
710 |
VCSGisEntity lEntity = workspace.getEntity(entity.getEntityCode()); |
|
711 |
String resources = lEntity.getResources(); |
|
712 |
if (StringUtils.isNotBlank(resources)) { |
|
713 |
try { |
|
714 |
if (!workspace.existsInWorkspace(resources)) { |
|
715 |
workspace.checkout( |
|
716 |
resources, |
|
717 |
null |
|
718 |
); |
|
719 |
} |
|
720 |
} catch (Exception e) { |
|
721 |
LOGGER.warn("Can't checkout resources table '" + resources + "'", e); |
|
722 |
} |
|
723 |
workspace.getExplorer().setCustomResources(entity.getEntityName(), resources,true); |
|
724 |
} |
|
725 |
|
|
726 |
} |
|
727 |
|
|
728 |
@Override |
|
729 |
public void setMapContext(MapContext mapContext) { |
|
730 |
super.setMapContext(mapContext); |
|
731 |
this.tableInfoController.setMapContext(mapContext); |
|
732 |
} |
|
733 |
|
|
734 |
protected Function<VCSGisEntity,String> getLabelEntityFormatter() { |
|
735 |
return null; |
|
736 |
|
|
737 |
} |
|
738 |
|
|
739 |
protected boolean getCheckScale() { |
|
740 |
return this.view.chkCheckScale.isSelected(); |
|
741 |
} |
|
742 |
|
|
743 |
protected boolean getAddToCWhenLoadingAll() { |
|
744 |
return this.view.chkAddToCWhenLoadingAll.isSelected(); |
|
745 |
} |
|
746 |
|
|
747 |
protected String getCategory(VCSGisEntity entity) { |
|
748 |
return this.entitySelector.getCategory(entity); |
|
749 |
} |
|
750 |
|
|
751 |
protected void registerDataModelRepository(VCSGisWorkspace workspace, String dataModelName) { |
|
752 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
753 |
VCSGisSwingServices services = swingManager.getDefaultServices(); |
|
754 |
|
|
755 |
workspace.registerDataModelRepository(dataModelName); |
|
756 |
services.connectedToModel(workspace, dataModelName); |
|
757 |
} |
|
758 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.66/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/addlayer/LayersWithGroup.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.vcsgis.app.addlayer; |
|
7 |
|
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.Collection; |
|
10 |
import java.util.Iterator; |
|
11 |
import java.util.LinkedHashMap; |
|
12 |
import java.util.List; |
|
13 |
import java.util.Map; |
|
14 |
import org.apache.commons.lang.StringUtils; |
|
15 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
16 |
import org.gvsig.fmap.dal.exception.DataException; |
|
17 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
18 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
19 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
20 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
21 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
22 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
23 |
import org.gvsig.tools.util.IsEmpty; |
|
24 |
|
|
25 |
/** |
|
26 |
* |
|
27 |
* @author jjdelcerro |
|
28 |
*/ |
|
29 |
public class LayersWithGroup implements Iterable<FLayer>, IsEmpty { |
|
30 |
|
|
31 |
// private final VCSGisWorkspace workspace; |
|
32 |
private final Map<String, FLayer> treelayers; |
|
33 |
private final List<FLayer> layers; |
|
34 |
private final MapContext mapContext; |
|
35 |
|
|
36 |
public LayersWithGroup(MapContext mapContext) { |
|
37 |
// this.workspace = workspace; |
|
38 |
this.treelayers = new LinkedHashMap<>(); |
|
39 |
this.layers = new ArrayList<>(); |
|
40 |
this.mapContext = mapContext; |
|
41 |
} |
|
42 |
|
|
43 |
public synchronized void add(String groupName, String layerName, FLayer layer) { |
|
44 |
// layer.setVisible(true); |
|
45 |
layers.add(layer); |
|
46 |
if (StringUtils.isBlank(layerName)) { |
|
47 |
treelayers.put(layer.getName(), layer); |
|
48 |
return; |
|
49 |
} |
|
50 |
if (StringUtils.isBlank(groupName)) { |
|
51 |
treelayers.put(layerName, layer); |
|
52 |
return; |
|
53 |
} |
|
54 |
FLayers group = (FLayers) treelayers.get("$$" + groupName); |
|
55 |
if (group == null) { |
|
56 |
group = new FLayers(); |
|
57 |
group.setMapContext(this.mapContext); |
|
58 |
group.setName(groupName); |
|
59 |
group.setParentLayer(mapContext.getLayers()); |
|
60 |
treelayers.put("$$" + groupName, group); |
|
61 |
} |
|
62 |
group.add(layer); |
|
63 |
} |
|
64 |
|
|
65 |
public synchronized void updateMapContext(boolean maintainStructureInToC, boolean replaceLayerIfExists) { |
|
66 |
this.updateMapControl(null, maintainStructureInToC, replaceLayerIfExists); |
|
67 |
} |
|
68 |
|
|
69 |
public static final int UPDATE_MODE_REPLACE_LAYER_IF_EXISTS = 0; |
|
70 |
public static final int UPDATE_MODE_ADD_DUPLICATES = 1; |
|
71 |
public static final int UPDATE_MODE_SKIP_DUPLICATES = 2; |
|
72 |
|
|
73 |
public synchronized void updateMapControl(MapControl mapControl, boolean maintainStructureInToC, boolean replaceLayerIfExists) { |
|
74 |
updateMapControl(mapControl, maintainStructureInToC, UPDATE_MODE_REPLACE_LAYER_IF_EXISTS); |
|
75 |
} |
|
76 |
|
|
77 |
public synchronized void updateMapControl(MapControl mapControl, boolean maintainStructureInToC, int updateMode) { |
|
78 |
mapContext.beginAtomicEvent(); |
|
79 |
try { |
|
80 |
if (maintainStructureInToC) { |
|
81 |
FLayers layersToC = mapContext.getLayers(); |
|
82 |
for (FLayer aLayer : this) { |
|
83 |
if (aLayer == null) { |
|
84 |
continue; |
|
85 |
} |
|
86 |
if (aLayer instanceof FLayers) { |
|
87 |
FLayers group = (FLayers) aLayer; |
|
88 |
FLayer groupToC = layersToC.getLayer(aLayer.getName()); |
|
89 |
if (groupToC instanceof FLayers) { |
|
90 |
for (FLayer l : group) { |
|
91 |
FLyrVect ltoc = getLayer((FLayers)groupToC, (FLyrVect) l); |
|
92 |
switch(updateMode) { |
|
93 |
case UPDATE_MODE_REPLACE_LAYER_IF_EXISTS: |
|
94 |
if( ltoc == null ) { |
|
95 |
((FLayers) groupToC).add(l); |
|
96 |
} else { |
|
97 |
refreshLayer(ltoc); |
|
98 |
} |
|
99 |
break; |
|
100 |
case UPDATE_MODE_ADD_DUPLICATES: |
|
101 |
((FLayers) groupToC).add(l); |
|
102 |
break; |
|
103 |
case UPDATE_MODE_SKIP_DUPLICATES: |
|
104 |
if( ltoc == null ) { |
|
105 |
((FLayers) groupToC).add(l); |
|
106 |
} |
|
107 |
break; |
|
108 |
} |
|
109 |
// if( replaceLayerIfExists ) { |
|
110 |
// FLyrVect ltoc = getLayer((FLayers)groupToC, (FLyrVect) l); |
|
111 |
// if( ltoc != null ) { |
|
112 |
// refreshLayer(ltoc); |
|
113 |
// continue; |
|
114 |
// } |
|
115 |
// } |
|
116 |
// ((FLayers) groupToC).add(l); |
|
117 |
} |
|
118 |
} else { |
|
119 |
group.setVisible(true); |
|
120 |
addLayer(mapControl, group); |
|
121 |
} |
|
122 |
} else { |
|
123 |
FLyrVect ltoc = getLayer(layersToC, (FLyrVect) aLayer); |
|
124 |
switch(updateMode) { |
|
125 |
case UPDATE_MODE_REPLACE_LAYER_IF_EXISTS: |
|
126 |
if( ltoc == null ) { |
|
127 |
aLayer.setVisible(true); |
|
128 |
addLayer(mapControl, aLayer); |
|
129 |
} else { |
|
130 |
refreshLayer(ltoc); |
|
131 |
} |
|
132 |
break; |
|
133 |
case UPDATE_MODE_ADD_DUPLICATES: |
|
134 |
aLayer.setVisible(true); |
|
135 |
addLayer(mapControl, aLayer); |
|
136 |
break; |
|
137 |
case UPDATE_MODE_SKIP_DUPLICATES: |
|
138 |
if( ltoc == null ) { |
|
139 |
aLayer.setVisible(true); |
|
140 |
addLayer(mapControl, aLayer); |
|
141 |
} |
|
142 |
break; |
|
143 |
} |
|
144 |
// if( replaceLayerIfExists ) { |
|
145 |
// FLyrVect ltoc = getLayer(layersToC, (FLyrVect) aLayer); |
|
146 |
// if( ltoc != null ) { |
|
147 |
// refreshLayer(ltoc); |
|
148 |
// continue; |
|
149 |
// } |
|
150 |
// } |
|
151 |
// aLayer.setVisible(true); |
|
152 |
// addLayer(mapControl, aLayer); |
|
153 |
} |
|
154 |
} |
|
155 |
} else { |
|
156 |
for (FLayer aLayer : this.allLayers()) { |
|
157 |
addLayer(mapControl, aLayer); |
|
158 |
} |
|
159 |
} |
|
160 |
} finally { |
|
161 |
mapContext.endAtomicEvent(); |
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
private void refreshLayer(FLyrVect layer) { |
|
166 |
try { |
|
167 |
FeatureStore store = layer.getFeatureStore(); |
|
168 |
if( store!=null ) { |
|
169 |
store.refresh(); |
|
170 |
} |
|
171 |
} catch (DataException ex) { |
|
172 |
|
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
private FLyrVect getLayer(FLayers group, FLyrVect layer) { |
|
177 |
FeatureStore store = ((FLyrVect) layer).getFeatureStore(); |
|
178 |
DataStoreParameters params = ((FLyrVect) layer).getDataStoreParameters(); |
|
179 |
for (FLayer layer1 : group) { |
|
180 |
if( layer1 instanceof FLyrVect ) { |
|
181 |
FeatureStore store1 = ((FLyrVect) layer1).getFeatureStore(); |
|
182 |
if( store1==null || store == null ) { |
|
183 |
if( ((FLyrVect)layer1).getDataStoreParameters().isTheSameStore(params) ) { |
|
184 |
return (FLyrVect) layer1; |
|
185 |
} |
|
186 |
} else { |
|
187 |
if( StringUtils.equals(store1.getFullName(), store.getFullName() )) { |
|
188 |
return (FLyrVect) layer1; |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
return null; |
|
194 |
} |
|
195 |
|
|
196 |
private void addLayer(MapControl mapControl, FLayer layer) { |
|
197 |
if( mapControl != null ) { |
|
198 |
mapControl.addLayer(layer); |
|
199 |
return; |
|
200 |
} |
|
201 |
this.mapContext.getLayers().add(layer); |
|
202 |
if( !this.mapContext.hasActiveLayers() ) { |
|
203 |
layer.setActive(true); |
|
204 |
} |
|
205 |
} |
|
206 |
|
|
207 |
public synchronized void disposeLayers() { |
|
208 |
for (FLayer layer : this) { |
|
209 |
layer.dispose(); |
Also available in: Unified diff