Revision 4358
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.264/org.gvsig.vectorediting.app/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
|
|
3 |
<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"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<groupId>org.gvsig</groupId> |
|
6 |
<artifactId>org.gvsig.vectorediting.app</artifactId> |
|
7 |
<packaging>pom</packaging> |
|
8 |
<version>1.0.264</version> |
|
9 |
<name>${project.artifactId}</name> |
|
10 |
<description>This plugin add to gvSIG a tool to show Vectorediting messages</description> |
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.vectorediting</artifactId> |
|
14 |
<version>1.0.264</version> |
|
15 |
</parent> |
|
16 |
<dependencyManagement> |
|
17 |
<dependencies> |
|
18 |
|
|
19 |
</dependencies> |
|
20 |
</dependencyManagement> |
|
21 |
|
|
22 |
<modules> |
|
23 |
<module>org.gvsig.vectorediting.app.mainplugin</module> |
|
24 |
</modules> |
|
25 |
|
|
26 |
</project> |
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.264/org.gvsig.vectorediting.app/maven-howto.rst | ||
---|---|---|
1 |
|
|
2 |
================================== |
|
3 |
Usefull maven "howtos" and FAQs |
|
4 |
================================== |
|
5 |
|
|
6 |
.. contents:: |
|
7 |
|
|
8 |
How to reduce the process of "install" to run as fast as possible. |
|
9 |
------------------------------------------------------------------- |
|
10 |
|
|
11 |
Can reduce install execution skiping test execution and compilation, |
|
12 |
javadoc generation, test signature checking, license checking, and |
|
13 |
attach sources in jar. |
|
14 |
|
|
15 |
mvn -Danimal.sniffer.skip=true -Dmaven.test.skip=true -Dsource.skip=true -DskipTests -Dmaven.javadoc.skip=true install |
|
16 |
|
|
17 |
How to increment the build number of gvSIG plugins |
|
18 |
---------------------------------------------------- |
|
19 |
|
|
20 |
To increase the build number of gvSIG plugins, yo can do: |
|
21 |
|
|
22 |
mvn -Dincrease-build-number process-sources |
|
23 |
|
|
24 |
How to deploy a package of a gvSIG plugin |
|
25 |
-------------------------------------------- |
|
26 |
|
|
27 |
Yo can deploy the package of a gvSIG plugin with: |
|
28 |
|
|
29 |
mvn -Ddeploy-package -Duser=USER -Dpassword=PASSWORD install |
|
30 |
|
|
31 |
Notes: |
|
32 |
- Require that the gvsig.package.info.poolURL property that this set to the correct value. |
|
33 |
- The process uses WEBDAV to upload the packages, gvspkg and gvspki, and require |
|
34 |
access to write in the location specified by gvsig.package.info.poolURL |
|
35 |
- If "user" or "password" is not present, the process ask its each time it need. |
|
36 |
- If folder specified in gvsig.package.info.poolURL does not exist, the process try to create it. |
|
37 |
- The process create a file "addon-request.txt" in the target with the information to |
|
38 |
add to the ticket to request the update of the package in the main repository of |
|
39 |
packages of gvSIG. |
|
40 |
|
|
41 |
How to skip attach sources in jar from command line |
|
42 |
------------------------------------------------------ |
|
43 |
|
|
44 |
If in the project is enabled by default the generation of jar whith |
|
45 |
the sources of the project, you can disable this setting the property |
|
46 |
"source.skip" to true in the command line:: |
|
47 |
|
|
48 |
mvn -Dsource.skip=true install |
|
49 |
|
|
50 |
How to skip test compile from command line |
|
51 |
-------------------------------------------- |
|
52 |
|
|
53 |
You can skip the compilation of test setting the propety "maven.test.skip" |
|
54 |
to true in the command line:: |
|
55 |
|
|
56 |
mvn -Dmaven.test.skip=true install |
|
57 |
|
|
58 |
|
|
59 |
How to skip test execution from command line |
|
60 |
---------------------------------------------- |
|
61 |
|
|
62 |
You can skip the tests execution setting the propety "skipTests" to true |
|
63 |
in the command line:: |
|
64 |
|
|
65 |
mvn -DskipTests install |
|
66 |
|
|
67 |
How to skip javadoc generation from command line |
|
68 |
-------------------------------------------------- |
|
69 |
|
|
70 |
You can skip the javadoc generation setting the property |
|
71 |
"maven.javadoc.skip" to true in the command line:: |
|
72 |
|
|
73 |
mvn -Dmaven.javadoc.skip=true install |
|
74 |
|
|
75 |
How to skip test signature cheks from command line |
|
76 |
--------------------------------------------------- |
|
77 |
|
|
78 |
You can skip the signature check setting the property |
|
79 |
"animal.sniffer.skip" to true in the command line:: |
|
80 |
|
|
81 |
mvn -Danimal.sniffer.skip=true install |
|
82 |
|
|
83 |
How to install a project without install submodules |
|
84 |
---------------------------------------------------------- |
|
85 |
|
|
86 |
To install a project with submodules and only install the |
|
87 |
parent project without submodules use the option "--non-recursive" :: |
|
88 |
|
|
89 |
mvn --non-recursive install |
|
90 |
|
|
91 |
|
|
92 |
How to skip test compilation |
|
93 |
-------------------------------- |
|
94 |
|
|
95 |
To configure a project to don't run the compilation |
|
96 |
of test you can add to this pom the next configuration of |
|
97 |
the plugin "maven-compiler-plugin":: |
|
98 |
|
|
99 |
<build> |
|
100 |
<plugins> |
|
101 |
... |
|
102 |
<plugin> |
|
103 |
<!-- Skip compilation tests --> |
|
104 |
<groupId>org.apache.maven.plugins</groupId> |
|
105 |
<artifactId>maven-compiler-plugin</artifactId> |
|
106 |
<executions> |
|
107 |
<execution> |
|
108 |
<id>default-testCompile</id> |
|
109 |
<phase>process-test-sources</phase> |
|
110 |
<goals> |
|
111 |
<goal>testCompile</goal> |
|
112 |
</goals> |
|
113 |
<configuration> |
|
114 |
<skip>true</skip> |
|
115 |
</configuration> |
|
116 |
</execution> |
|
117 |
</executions> |
|
118 |
</plugin> |
|
119 |
... |
|
120 |
</plugins> |
|
121 |
</build> |
|
122 |
|
|
123 |
Skip test execution |
|
124 |
---------------------- |
|
125 |
|
|
126 |
To configure a project to don't run the execution |
|
127 |
of test you can add to this pom the next configuration of |
|
128 |
the plugin "maven-surefire-plugin":: |
|
129 |
|
|
130 |
|
|
131 |
<build> |
|
132 |
<plugins> |
|
133 |
... |
|
134 |
<plugin> |
|
135 |
<!-- Skip test execution --> |
|
136 |
<groupId>org.apache.maven.plugins</groupId> |
|
137 |
<artifactId>maven-surefire-plugin</artifactId> |
|
138 |
<configuration> |
|
139 |
<skipTests>true</skipTests> |
|
140 |
</configuration> |
|
141 |
</plugin> |
|
142 |
... |
|
143 |
</plugins> |
|
144 |
</build> |
|
145 |
|
|
146 |
Continue on test failure |
|
147 |
----------------------------- |
|
148 |
|
|
149 |
You can configure a project to continue on test execution |
|
150 |
failure. To do this add to the pom of the project the next |
|
151 |
configuration of plugin "maven-surefire-plugin" :: |
|
152 |
|
|
153 |
<build> |
|
154 |
<plugins> |
|
155 |
... |
|
156 |
<plugin> |
|
157 |
<!-- Continue on test failure --> |
|
158 |
<groupId>org.apache.maven.plugins</groupId> |
|
159 |
<artifactId>maven-surefire-plugin</artifactId> |
|
160 |
<configuration> |
|
161 |
<testFailureIgnore>true</testFailureIgnore> |
|
162 |
</configuration> |
|
163 |
</plugin> |
|
164 |
... |
|
165 |
</plugins> |
|
166 |
</build> |
|
167 |
|
|
168 |
|
|
169 |
Set java compatibility |
|
170 |
-------------------------- |
|
171 |
|
|
172 |
To set the compatibility with a java version add to the |
|
173 |
pom of the project the next configuration of plugin |
|
174 |
"maven-compiler-plugin" :: |
|
175 |
|
|
176 |
<build> |
|
177 |
<plugins> |
|
178 |
... |
|
179 |
<plugin> |
|
180 |
<!-- Set java compatibility --> |
|
181 |
<groupId>org.apache.maven.plugins</groupId> |
|
182 |
<artifactId>maven-compiler-plugin</artifactId> |
|
183 |
<configuration> |
|
184 |
<source>1.5</source> |
|
185 |
<target>1.5</target> |
|
186 |
<encoding>ISO-8859-1</encoding> |
|
187 |
</configuration> |
|
188 |
</plugin> |
|
189 |
... |
|
190 |
</plugins> |
|
191 |
</build> |
|
192 |
|
|
193 |
Packaging tests in jar |
|
194 |
------------------------ |
|
195 |
|
|
196 |
Test classes do not packaging in jar by default. |
|
197 |
To packing add to pom:: |
|
198 |
|
|
199 |
<build> |
|
200 |
<plugins> |
|
201 |
... |
|
202 |
<plugin> |
|
203 |
<!-- Packaging tests in jar --> |
|
204 |
<groupId>org.apache.maven.plugins</groupId> |
|
205 |
<artifactId>maven-jar-plugin</artifactId> |
|
206 |
<executions> |
|
207 |
<!-- Generates a jar file only with the test classes --> |
|
208 |
<execution> |
|
209 |
<goals> |
|
210 |
<goal>test-jar</goal> |
|
211 |
</goals> |
|
212 |
<configuration> |
|
213 |
<includes> |
|
214 |
<include>**/**</include> |
|
215 |
</includes> |
|
216 |
</configuration> |
|
217 |
</execution> |
|
218 |
</executions> |
|
219 |
</plugin> |
|
220 |
... |
|
221 |
</plugins> |
|
222 |
</build> |
|
223 |
|
|
224 |
How to set a dependency with tests jar |
|
225 |
----------------------------------------- |
|
226 |
|
|
227 |
You can set a dependency with a test jar adding to |
|
228 |
the declaration of the dependency the scope of |
|
229 |
test and the type of "test-jar":: |
|
230 |
|
|
231 |
<dependency> |
|
232 |
<groupId>...</groupId> |
|
233 |
<artifactId>...</artifactId> |
|
234 |
<type>test-jar</type> |
|
235 |
<scope>test</scope> |
|
236 |
</dependency> |
|
237 |
|
|
238 |
How use ant in maven |
|
239 |
------------------------- |
|
240 |
|
|
241 |
You can use ant embed in the pom of you project. |
|
242 |
To do this use:: |
|
243 |
|
|
244 |
<plugin> |
|
245 |
<artifactId>maven-antrun-plugin</artifactId> |
|
246 |
<version>1.7</version> |
|
247 |
<executions> |
|
248 |
<execution> |
|
249 |
<phase>generate-sources</phase> |
|
250 |
<configuration> |
|
251 |
<target> |
|
252 |
<echo>Hello world!</echo> |
|
253 |
</target> |
|
254 |
</configuration> |
|
255 |
<goals> |
|
256 |
<goal>run</goal> |
|
257 |
</goals> |
|
258 |
</execution> |
|
259 |
</executions> |
|
260 |
</plugin> |
|
261 |
|
|
262 |
Fail when execute "mvn deploy" with "No connector available" |
|
263 |
------------------------------------------------------------- |
|
264 |
|
|
265 |
When execute a "mvn deploy" fail with the error:: |
|
266 |
|
|
267 |
[INFO] ------------------------------------------------------------------------ |
|
268 |
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy |
|
269 |
(default-deploy) on project org.gvsig.desktop: Failed to deploy artifacts/metadata: |
|
270 |
No connector available to access repository gvsig-repository (dav:https://devel.gvsig.org/m2repo/j2se) |
|
271 |
of type default using the available factories WagonRepositoryConnectorFactory -> [Help 1] |
|
272 |
[ERROR] |
|
273 |
|
|
274 |
This happens to be configured the webdav wagon as an extension in the section "build":: |
|
275 |
|
|
276 |
... |
|
277 |
<build> |
|
278 |
<extensions> |
|
279 |
<extension> |
|
280 |
<groupId>org.apache.maven.wagon</groupId> |
|
281 |
<artifactId>wagon-webdav-jackrabbit</artifactId> |
|
282 |
<version>1.0-beta-7</version> |
|
283 |
</extension> |
|
284 |
</extensions> |
|
285 |
... |
|
286 |
|
|
287 |
Fail when execute "mvn release: prepare" with "svn command failed... Could not authenticate" |
|
288 |
------------------------------------------------------------------------------------------------ |
|
289 |
|
|
290 |
When running "mvn release: prepare" updates poms, compiles, and then |
|
291 |
fails with the following error :: |
|
292 |
|
|
293 |
[INFO] ------------------------------------------------------------------------ |
|
294 |
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.1:prepare |
|
295 |
(default-cli) on project org.gvsig.desktop: Unable to commit files |
|
296 |
[ERROR] Provider message: |
|
297 |
[ERROR] The svn command failed. |
|
298 |
[ERROR] Command output: |
|
299 |
[ERROR] svn: Commit failed (details follow): |
|
300 |
[ERROR] svn: MKACTIVITY of '/svn/gvsig-desktop/!svn/act/931a27bc-57e8-45d9-adcd-5a2cf54a7045': |
|
301 |
authorization failed: Could not authenticate to server: rejected Basic challenge (https://devel.gvsig.org) |
|
302 |
[ERROR] -> [Help 1] |
|
303 |
[ERROR] |
|
304 |
[ERROR] |
|
305 |
|
|
306 |
Apparently maven in linux system use the svn of system and if you're not |
|
307 |
authenticated when trying to access to the repository, svn fails. |
|
308 |
|
|
309 |
This is solved by executing a commit from the command line on |
|
310 |
some file of the project (only if you have not enabled the option |
|
311 |
"store-passwords = no" in $ HOME / .subversion / config). For example, you |
|
312 |
can add or remove at the end of "pom.xml" a blank line and then run |
|
313 |
from the command line :: |
|
314 |
|
|
315 |
svn ci -m "" pom.xml |
|
316 |
|
|
317 |
Another option that works on Windows in declaring the user and password in the command: |
|
318 |
|
|
319 |
mvn release:prepare -Dusername=[username] -Dpassword=[password] |
|
320 |
|
|
321 |
|
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.264/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Wed May 22 20:58:21 CEST 2024 |
|
2 |
buildNumber=275 |
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.264/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/test/resources/README.txt | ||
---|---|---|
1 |
==== |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
==== |
|
26 |
|
|
27 |
Put into this folder the resources needed by your test classes. |
|
28 |
|
|
29 |
This folder is added to the Tests classpath, so you can load any resources |
|
30 |
through the ClassLoader. |
|
31 |
|
|
32 |
By default, in this folder you can find an example of log4j configuration, |
|
33 |
prepared to log messages through the console, so logging works when you |
|
34 |
run your tests classes. |
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.264/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
28 |
|
|
29 |
<!-- |
|
30 |
Log4J configuration file for unit tests execution. |
|
31 |
--> |
|
32 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
33 |
|
|
34 |
<!-- Appender configuration to show logging messages through the console --> |
|
35 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
36 |
<layout class="org.apache.log4j.PatternLayout"> |
|
37 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
38 |
</layout> |
|
39 |
</appender> |
|
40 |
|
|
41 |
<!-- |
|
42 |
Activate logging messages of DEBUG level of higher only for the |
|
43 |
org.gvsig.tools packages. |
|
44 |
You can put full classes names or packages instead, to configure |
|
45 |
logging for all the classes and subpackages of the package. |
|
46 |
--> |
|
47 |
<category name="org.gvsig.tools"> |
|
48 |
<priority value="DEBUG" /> |
|
49 |
</category> |
|
50 |
<category name="org.gvsig.vectorediting"> |
|
51 |
<priority value="DEBUG" /> |
|
52 |
</category> |
|
53 |
|
|
54 |
<!-- |
|
55 |
By default, show only logging messages of INFO level or higher, |
|
56 |
through the previously configured CONSOLE appender. |
|
57 |
--> |
|
58 |
<root> |
|
59 |
<priority value="INFO" /> |
|
60 |
<appender-ref ref="CONSOLE" /> |
|
61 |
</root> |
|
62 |
</log4j:configuration> |
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.264/org.gvsig.vectorediting.app/org.gvsig.vectorediting.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.vectorediting.lib.api</include> |
|
44 |
<include>org.gvsig:org.gvsig.vectorediting.swing.api</include> |
|
45 |
<include>org.gvsig:org.gvsig.vectorediting.lib.impl</include> |
|
46 |
<include>org.gvsig:org.gvsig.vectorediting.swing.impl</include> |
|
47 |
<include>org.gvsig:org.gvsig.vectorediting.lib.spi</include> |
|
48 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.point</include> |
|
49 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.circlecr</include> |
|
50 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.circle3p</include> |
|
51 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.polyline</include> |
|
52 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.internalpolygon</include> |
|
53 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.line</include> |
|
54 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.arc</include> |
|
55 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.ellipse</include> |
|
56 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.regularpolygon</include> |
|
57 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.rectangle</include> |
|
58 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.spline</include> |
|
59 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.explode</include> |
|
60 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.move</include> |
|
61 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.rotate</include> |
|
62 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.duplicate</include> |
|
63 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.scale</include> |
|
64 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.splitline</include> |
|
65 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.simplify</include> |
|
66 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.multipoint</include> |
|
67 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.autopolygon</include> |
|
68 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.join</include> |
|
69 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.stretch</include> |
|
70 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.extendline</include> |
|
71 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.split</include> |
|
72 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.smoothline</include> |
|
73 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.trimline</include> |
|
74 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.rectangularmatrix</include> |
|
75 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.polarmatrix</include> |
|
76 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.editvertex</include> |
|
77 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.remove</include> |
|
78 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.converttopolyline</include> |
|
79 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.reversedirection</include> |
|
80 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.align</include> |
|
81 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.chamfer</include> |
|
82 |
</includes> |
|
83 |
</dependencySet> |
|
84 |
</dependencySets> |
|
85 |
|
|
86 |
</assembly> |
|
87 |
|
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.264/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/java/org/gvsig/vectorediting/app/mainplugin/EditingToolOptionsPanel.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.vectorediting.app.mainplugin; |
|
7 |
|
|
8 |
import java.awt.BorderLayout; |
|
9 |
import java.awt.FlowLayout; |
|
10 |
import java.awt.GridBagConstraints; |
|
11 |
import java.awt.GridBagLayout; |
|
12 |
import java.awt.event.ActionEvent; |
|
13 |
import java.awt.event.KeyEvent; |
|
14 |
import java.awt.event.KeyListener; |
|
15 |
import java.util.ArrayList; |
|
16 |
import java.util.HashMap; |
|
17 |
import java.util.List; |
|
18 |
import java.util.Map; |
|
19 |
import java.util.Objects; |
|
20 |
import javax.json.JsonObject; |
|
21 |
import javax.json.JsonValue; |
|
22 |
import javax.swing.ImageIcon; |
|
23 |
import javax.swing.JButton; |
|
24 |
import javax.swing.JCheckBoxMenuItem; |
|
25 |
import javax.swing.JLabel; |
|
26 |
import javax.swing.JPanel; |
|
27 |
import javax.swing.JTabbedPane; |
|
28 |
import javax.swing.JTextField; |
|
29 |
import javax.swing.SwingConstants; |
|
30 |
import javax.swing.SwingUtilities; |
|
31 |
import javax.swing.UIManager; |
|
32 |
import org.apache.commons.lang.StringUtils; |
|
33 |
import org.gvsig.featureform.swing.JFeatureForm; |
|
34 |
import org.gvsig.fmap.dal.DALLocator; |
|
35 |
import org.gvsig.fmap.dal.DataTypes; |
|
36 |
import org.gvsig.fmap.dal.exception.DataException; |
|
37 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
38 |
import org.gvsig.fmap.dal.feature.Feature; |
|
39 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
40 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
41 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
42 |
import org.gvsig.fmap.dal.feature.FeatureTypeDefinitionsManager; |
|
43 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
44 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
45 |
import org.gvsig.json.Json; |
|
46 |
import org.gvsig.tools.ToolsLocator; |
|
47 |
import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
|
48 |
import org.gvsig.tools.bookmarksandhistory.BookmarksAndHistoryManager; |
|
49 |
import org.gvsig.tools.dynform.DynFormDefinition; |
|
50 |
import org.gvsig.tools.dynform.DynFormFieldDefinition; |
|
51 |
import org.gvsig.tools.dynform.DynFormLocator; |
|
52 |
import org.gvsig.tools.dynform.DynFormManager; |
|
53 |
import org.gvsig.tools.dynform.JDynForm; |
|
54 |
import org.gvsig.tools.dynform.JDynFormField; |
|
55 |
import org.gvsig.tools.dynobject.DynClass; |
|
56 |
import org.gvsig.tools.dynobject.DynField_v2; |
|
57 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
|
58 |
import org.gvsig.tools.dynobject.DynStruct; |
|
59 |
import org.gvsig.tools.dynobject.DynStruct_v2; |
|
60 |
import org.gvsig.tools.dynobject.Tags; |
|
61 |
import org.gvsig.tools.i18n.I18nManager; |
|
62 |
import org.gvsig.tools.observer.Notification; |
|
63 |
import org.gvsig.tools.observer.Observable; |
|
64 |
import org.gvsig.tools.observer.Observer; |
|
65 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
66 |
import org.gvsig.tools.persistence.Persistent; |
|
67 |
import org.gvsig.tools.persistence.PersistentState; |
|
68 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
69 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
70 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
71 |
import org.gvsig.tools.swing.api.ToolsSwingUtils; |
|
72 |
import static org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue.ID_GETVALUE; |
|
73 |
import static org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue.ID_SETVALUE; |
|
74 |
import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController; |
|
75 |
import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController.BookmarkEvent; |
|
76 |
import org.gvsig.vectorediting.app.mainplugin.dynformfield.point.JDynFormFieldPointFactory; |
|
77 |
import org.gvsig.vectorediting.lib.api.EditingService; |
|
78 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameter; |
|
79 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameterOptions; |
|
80 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameterOptions.ParameterOption; |
|
81 |
import org.gvsig.vectorediting.swing.api.EditingContext; |
|
82 |
import org.slf4j.Logger; |
|
83 |
import org.slf4j.LoggerFactory; |
|
84 |
|
|
85 |
/** |
|
86 |
* |
|
87 |
* @author gvSIG Team |
|
88 |
*/ |
|
89 |
@SuppressWarnings("UseSpecificCatch") |
|
90 |
class EditingToolOptionsPanel extends JPanel { |
|
91 |
private static final Logger LOGGER = LoggerFactory.getLogger(EditingToolOptionsPanel.class); |
|
92 |
|
|
93 |
private static final String BOOKMARKSANDHISTORY_NAME = "EditingToolOptionsPanel"; |
|
94 |
|
|
95 |
private final EditingContext editingContext; |
|
96 |
private EditingService service; |
|
97 |
private JDynForm form; |
|
98 |
private DynStruct_v2 definition; |
|
99 |
private final Observer contextObserver = (Observable observable, Object notification) -> { |
|
100 |
doContextChanged((Notification) notification); |
|
101 |
}; |
|
102 |
private final Observer serviceObserver = (Observable observable, Object notification) -> { |
|
103 |
doServiceChanged((Notification) notification); |
|
104 |
}; |
|
105 |
private JFeatureForm featureform; |
|
106 |
private JButton applyDefaultValuesButton; |
|
107 |
private ImageIcon confirmIcon; |
|
108 |
|
|
109 |
private static final Map<String, JsonObject> defaultValues = new HashMap<>(); |
|
110 |
private JTabbedPane tab; |
|
111 |
private static int currentTab = 0; |
|
112 |
private JButton acceptOptionsButton; |
|
113 |
private JTextField txtBookmarkName; |
|
114 |
private JCheckBoxMenuItem keepWhenNullInMarkerMenuItem; |
|
115 |
|
|
116 |
private KeyListener keylistener = new KeyListener() { |
|
117 |
@Override |
|
118 |
public void keyTyped(KeyEvent e) { |
|
119 |
} |
|
120 |
|
|
121 |
@Override |
|
122 |
public void keyPressed(KeyEvent e) { |
|
123 |
switch (e.getKeyCode()) { |
|
124 |
case KeyEvent.VK_DOWN: |
|
125 |
case KeyEvent.VK_UP: |
|
126 |
case KeyEvent.VK_LEFT: |
|
127 |
case KeyEvent.VK_RIGHT: |
|
128 |
case KeyEvent.VK_PAGE_DOWN: |
|
129 |
case KeyEvent.VK_PAGE_UP: |
|
130 |
break; |
|
131 |
default: |
|
132 |
e.consume(); |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
@Override |
|
137 |
public void keyReleased(KeyEvent e) { |
|
138 |
} |
|
139 |
}; |
|
140 |
|
|
141 |
@SuppressWarnings(value = {"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) |
|
142 |
public EditingToolOptionsPanel(EditingContext editingContext) { |
|
143 |
this.setLayout(new BorderLayout()); |
|
144 |
this.txtBookmarkName = new JTextField(); |
|
145 |
this.txtBookmarkName.setBorder(null); |
|
146 |
this.txtBookmarkName.setBackground(UIManager.getColor(ToolsSwingManager.COLOR_PANEL_BACKGROUND)); |
|
147 |
this.txtBookmarkName.addKeyListener(keylistener); |
|
148 |
// this.txtBookmarkName.setFocusable(false); |
|
149 |
this.editingContext = editingContext; |
|
150 |
this.editingContext.addObserver(this.contextObserver); |
|
151 |
EditingService activeService = editingContext.getActiveService(); |
|
152 |
this.set(activeService); |
|
153 |
this.put(activeService); |
|
154 |
ToolsSwingUtils.ensureRowsCols(this, 20, 60,50,120); |
|
155 |
try { |
|
156 |
this.confirmIcon = ToolsSwingLocator.getIconThemeManager() |
|
157 |
.getCurrent().get("common-applychanges"); |
|
158 |
} catch(Exception ex) { |
|
159 |
|
|
160 |
} |
|
161 |
} |
|
162 |
|
|
163 |
private Bookmarks getBookmarks(FeatureStore store) { |
|
164 |
boolean useBookmarksByTable = true; // TODO: poner esto en preferencias de edicion. |
|
165 |
BookmarksAndHistoryManager manager = ToolsLocator.getBookmarksAndHistoryManager(); |
|
166 |
|
|
167 |
if( useBookmarksByTable ) { |
|
168 |
return manager.getBookmarksGroup(BOOKMARKSANDHISTORY_NAME+"_"+store.getName()); |
|
169 |
} else { |
|
170 |
return manager.getBookmarksGroup(BOOKMARKSANDHISTORY_NAME); |
|
171 |
} |
|
172 |
|
|
173 |
} |
|
174 |
|
|
175 |
private void set(EditingService service) { |
|
176 |
if(this.service == service && service != null) { |
|
177 |
return; |
|
178 |
} |
|
179 |
|
|
180 |
if (this.service != null) { |
|
181 |
this.service.deleteObserver(this.serviceObserver); |
|
182 |
} |
|
183 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
184 |
DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager(); |
|
185 |
if(this.tab != null){ |
|
186 |
currentTab = this.tab.getSelectedIndex(); |
|
187 |
} |
|
188 |
if (service == null) { |
|
189 |
this.removeAll(); |
|
190 |
this.tab = null; |
|
191 |
JLabel label = new JLabel( |
|
192 |
"<html><center>" + |
|
193 |
i18n.getTranslation("_Activate_an_editing_tool_to_see_your_options_here")+ |
|
194 |
"</center></html>" |
|
195 |
); |
|
196 |
label.setHorizontalAlignment(SwingConstants.CENTER); |
|
197 |
this.add(label, BorderLayout.CENTER); |
|
198 |
} else if( service != this.service ) { |
|
199 |
this.removeAll(); |
|
200 |
this.tab = null; |
|
201 |
FeatureStore store = service.getStore(); |
|
202 |
this.add(createHeader(store), BorderLayout.NORTH); |
|
203 |
|
|
204 |
this.tab = new JTabbedPane(); |
|
205 |
tab.setTabPlacement(JTabbedPane.BOTTOM); |
|
206 |
tab.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); |
|
207 |
|
|
208 |
this.add(tab, BorderLayout.CENTER); |
|
209 |
|
|
210 |
definition = this.getToolOptionsDefinition(service); |
|
211 |
if (definition != null) { |
|
212 |
DynFormManager dynFormManager = DynFormLocator.getDynFormManager(); |
|
213 |
form = dynFormManager.createJDynForm(definition); |
|
214 |
|
|
215 |
JPanel optionsPanel = new JPanel(); |
|
216 |
optionsPanel.setLayout(new BorderLayout()); |
|
217 |
optionsPanel.add(form.asJComponent(), BorderLayout.CENTER); |
|
218 |
JButton cancelButton = new JButton(i18n.getTranslation("_Cancel")); |
|
219 |
cancelButton.addActionListener((e) -> { |
|
220 |
editingContext.cancelActiveService(); |
|
221 |
}); |
|
222 |
this.acceptOptionsButton = new JButton(i18n.getTranslation("_Accept")); |
|
223 |
this.acceptOptionsButton.addActionListener((e) -> { |
|
224 |
applyOptions(); |
|
225 |
}); |
|
226 |
JPanel buttonsPanel = new JPanel(); |
|
227 |
buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0 )); |
|
228 |
buttonsPanel.add(this.acceptOptionsButton); |
|
229 |
buttonsPanel.add(cancelButton); |
|
230 |
optionsPanel.add(buttonsPanel, BorderLayout.PAGE_END); |
|
231 |
|
|
232 |
tab.add(i18n.getTranslation("_Options"), optionsPanel); |
|
233 |
|
|
234 |
this.form.addListener(new JDynForm.JDynFormListener() { |
|
235 |
@Override |
|
236 |
public void message(String message) { |
|
237 |
} |
|
238 |
|
|
239 |
@Override |
|
240 |
public void fieldChanged(JDynFormField field) { |
|
241 |
if (acceptOptionsButton != null) { |
|
242 |
acceptOptionsButton.setIcon(confirmIcon); |
|
243 |
} |
|
244 |
} |
|
245 |
}); |
|
246 |
} |
|
247 |
try { |
|
248 |
JsonObject xx = defaultValues.get(store.getFullName()); |
|
249 |
EditableFeature f = service.getDefaultFeatureValues(); |
|
250 |
if(xx != null){ |
|
251 |
f.copyFrom(xx); |
|
252 |
} |
|
253 |
DynFormDefinition formdef = this.createFormDefinition(service); |
|
254 |
this.featureform = dataSwingManager.createJFeatureForm(formdef); |
|
255 |
this.featureform.getDynForm().setContext(dataSwingManager.createFeaturesFormContext(store)); |
|
256 |
this.featureform.setFeature(f); |
|
257 |
JPanel valuesPanel = new JPanel(); |
|
258 |
valuesPanel.setLayout(new BorderLayout()); |
|
259 |
valuesPanel.add(featureform.asJComponent(), BorderLayout.CENTER); |
|
260 |
applyDefaultValuesButton = new JButton(i18n.getTranslation("_Apply")); |
|
261 |
applyDefaultValuesButton.addActionListener((e) -> { applyDefaultValues(); }); |
|
262 |
JButton resetDefaultValuesButton = new JButton(i18n.getTranslation("_Reset")); |
|
263 |
resetDefaultValuesButton.addActionListener((e) -> { |
|
264 |
resetDefaultValues(); |
|
265 |
}); |
|
266 |
|
|
267 |
Bookmarks bookmarks = this.getBookmarks(store); |
|
268 |
JButton bookmarksButton = new JButton("..."); |
|
269 |
BookmarksController bookmarksController = ToolsSwingLocator.getToolsSwingManager().createBookmarksController( |
|
270 |
bookmarks, |
|
271 |
bookmarksButton |
|
272 |
); |
|
273 |
bookmarksController.addMenuItem(this.getKeepWhenNullInMarkerMenuItem()); |
|
274 |
bookmarksController.addActionListener((ActionEvent e) -> { |
|
275 |
EditableFeature feature; |
|
276 |
EditingToolOptionsDefaultValueBookmark bookmark; |
|
277 |
BookmarkEvent<EditingToolOptionsDefaultValueBookmark> b = (BookmarkEvent<EditingToolOptionsDefaultValueBookmark>) e; |
|
278 |
switch (b.getID()) { |
|
279 |
case ID_GETVALUE: |
|
280 |
bookmark = new EditingToolOptionsDefaultValueBookmark(); |
|
281 |
bookmark.setDefaultValues(service.getDefaultFeatureValues()); |
|
282 |
bookmark.setKeepWhenNullInMarker(this.getKeepWhenNullInMarkerMenuItem().isSelected()); |
|
283 |
b.setCurrentValue(bookmark); |
|
284 |
break; |
|
285 |
case ID_SETVALUE: |
|
286 |
if (b.getCurrentValue() == null) { |
|
287 |
return; |
|
288 |
} |
|
289 |
bookmark = b.getCurrentValue(); |
|
290 |
this.getKeepWhenNullInMarkerMenuItem().setSelected(bookmark.getKeepWhenNullInMarker()); |
|
291 |
JsonObject bookmarkFeature = bookmark.getDefaultValues(); |
|
292 |
feature = service.getDefaultFeatureValues(); this.featureform.fetch(feature); |
|
293 |
boolean keepWhenNull = this.getKeepWhenNullInMarkerMenuItem().isSelected(); |
|
294 |
feature.copyFrom( |
|
295 |
bookmarkFeature, |
|
296 |
(FeatureAttributeDescriptor t) -> !(keepWhenNull && bookmarkFeature.getOrDefault(t.getName(), null)==null) |
|
297 |
); |
|
298 |
featureform.setFeature(feature); |
|
299 |
applyDefaultValues(); |
|
300 |
txtBookmarkName.setText(b.getBookmark().getName()); |
|
301 |
txtBookmarkName.setCaretPosition(0); |
|
302 |
break; |
|
303 |
|
|
304 |
} |
|
305 |
}); |
|
306 |
|
|
307 |
JPanel applyPanel = new JPanel(); |
|
308 |
applyPanel.setLayout(new FlowLayout(FlowLayout.RIGHT,4,0)); |
|
309 |
applyPanel.add(applyDefaultValuesButton); |
|
310 |
applyPanel.add(resetDefaultValuesButton); |
|
311 |
applyPanel.add(bookmarksButton); |
|
312 |
valuesPanel.add(applyPanel, BorderLayout.PAGE_END); |
|
313 |
|
|
314 |
tab.add(i18n.getTranslation("_Default_values"), valuesPanel ); |
|
315 |
|
|
316 |
featureform.getDynForm().addListener(new JDynForm.JDynFormListener() { |
|
317 |
@Override |
|
318 |
public void message(String message) { |
|
319 |
} |
|
320 |
|
|
321 |
@Override |
|
322 |
public void fieldChanged(JDynFormField field) { |
|
323 |
if(applyDefaultValuesButton != null){ |
|
324 |
applyDefaultValuesButton.setIcon(confirmIcon); |
|
325 |
} |
|
326 |
} |
|
327 |
}); |
|
328 |
|
|
329 |
} catch (Exception ex) { |
|
330 |
LOGGER.debug("Can't create panel",ex); |
|
331 |
} |
|
332 |
ToolsSwingUtils.ensureRowsCols(this, 8, 43, 25, 60); |
|
333 |
try { |
|
334 |
tab.setSelectedIndex(currentTab); |
|
335 |
} catch (Exception ex) { |
|
336 |
LOGGER.debug("Can't activate tab",ex); |
|
337 |
} |
|
338 |
service.addObserver(this.serviceObserver); |
|
339 |
} |
|
340 |
this.service = service; |
|
341 |
} |
|
342 |
|
|
343 |
private DynFormDefinition createFormDefinition(EditingService service) throws DataException { |
|
344 |
FeatureTypeDefinitionsManager featureTypeDefinitionsManager = DALLocator.getFeatureTypeDefinitionsManager(); |
|
345 |
|
|
346 |
FeatureStore store = service.getStore(); |
|
347 |
FeatureType featureType = store.getDefaultFeatureType(); |
|
348 |
DynClass dynClass = featureTypeDefinitionsManager.get(store,featureType); |
|
349 |
DynFormDefinition formdef = DynFormLocator.getDynFormManager().createDefinition(dynClass); |
|
350 |
for (FeatureAttributeDescriptor attr : featureType) { |
|
351 |
if( attr.isPrimaryKey() || attr.isReadOnly() ) { |
|
352 |
formdef.remove(attr.getName()); |
|
353 |
} |
|
354 |
} |
|
355 |
for (DynFormFieldDefinition fielddef : formdef) { |
|
356 |
if( fielddef.isMandatory() ) { |
|
357 |
fielddef.setMandatory(false); |
|
358 |
fielddef.setLabel("<html><b>"+fielddef.getLabel()+"</b></html>"); |
|
359 |
} |
|
360 |
} |
|
361 |
return formdef; |
|
362 |
} |
|
363 |
|
|
364 |
private DynStruct_v2 getToolOptionsDefinition(EditingService service) { |
|
365 |
if (service == null) { |
|
366 |
return null; |
|
367 |
} |
|
368 |
DynStruct_v2 def = (DynStruct_v2) ToolsLocator.getDynObjectManager().createDynClass( |
|
369 |
service.getName(), null |
|
370 |
); |
|
371 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
372 |
DynField_v2 field; |
|
373 |
Tags tags; |
|
374 |
List<ServiceParameterField> params = this.getServiceParameters(service); |
|
375 |
for (ServiceParameterField param : params) { |
|
376 |
switch(param.getType()) { |
|
377 |
case POSITION: |
|
378 |
field = (DynField_v2) def.addDynField(param.getFieldName(), DataTypes.GEOMETRY); |
|
379 |
field.setLabel(i18n.getTranslation(param.getName())); |
|
380 |
field.setDescription(i18n.getTranslation(param.getDescription())); |
|
381 |
field.setDefaultFieldValue(param.getDefaultValue()); |
|
382 |
tags = field.getTags(); |
|
383 |
tags.set("EditingContext", this.editingContext); |
|
384 |
tags.set("ParamType", param.getType()); |
|
385 |
field.setSubtype(JDynFormFieldPointFactory.NAME); |
|
386 |
field.setMandatory(false); |
|
387 |
break; |
|
388 |
case LIST_POSITIONS: |
|
389 |
field = (DynField_v2) def.addDynField(param.getFieldName(), DataTypes.GEOMETRY); |
|
390 |
field.setLabel(i18n.getTranslation(param.getName())); |
|
391 |
field.setDescription(i18n.getTranslation(param.getDescription())); |
|
392 |
field.setDefaultFieldValue(param.getDefaultValue()); |
|
393 |
tags = field.getTags(); |
|
394 |
tags.set("EditingContext", this.editingContext); |
|
395 |
tags.set("ParamType", param.getType()); |
|
396 |
field.setSubtype(JDynFormFieldPointFactory.NAME); |
|
397 |
field.setMandatory(false); |
|
398 |
break; |
|
399 |
case VALUE: |
|
400 |
field = (DynField_v2) def.addDynFieldDouble(param.getFieldName()); |
|
401 |
// field = (DynField_v2) def.addDynField(param.getFieldName(), param.getDataType()); |
|
402 |
if( param.isAditional() ) { |
|
403 |
field.setLabel(i18n.getTranslation("_Value")); |
|
404 |
} else { |
|
405 |
field.setLabel(i18n.getTranslation(param.getName())); |
|
406 |
} |
|
407 |
tags = field.getTags(); |
|
408 |
tags.set("ParamType", param.getType()); |
|
409 |
field.setDescription(i18n.getTranslation(param.getDescription())); |
|
410 |
field.setDefaultFieldValue(param.getDefaultValue()); |
|
411 |
field.setMandatory(false); |
|
412 |
break; |
|
413 |
|
|
414 |
case DISTANCE: |
|
415 |
field = (DynField_v2) def.addDynFieldDouble(param.getFieldName()); |
|
416 |
// field = (DynField_v2) def.addDynField(param.getFieldName(), param.getDataType()); |
|
417 |
if( param.isAditional() ) { |
|
418 |
field.setLabel(i18n.getTranslation("_Distance")); |
|
419 |
} else { |
|
420 |
field.setLabel(i18n.getTranslation(param.getName())); |
|
421 |
} |
|
422 |
tags = field.getTags(); |
|
423 |
tags.set("ParamType", param.getType()); |
|
424 |
field.setDescription(i18n.getTranslation(param.getDescription())); |
|
425 |
field.setDefaultFieldValue(param.getDefaultValue()); |
|
426 |
field.setMandatory(false); |
|
427 |
break; |
|
428 |
|
|
429 |
case OPTION: |
|
430 |
field = (DynField_v2) def.addDynField(param.getFieldName(), param.getDataType()); |
|
431 |
if( param.isAditional() ) { |
|
432 |
field.setLabel(i18n.getTranslation("_Options")); |
|
433 |
} else { |
|
434 |
field.setLabel(i18n.getTranslation(param.getName())); |
|
435 |
} |
|
436 |
field.setDescription(i18n.getTranslation(param.getDescription())); |
|
437 |
List<DynObjectValueItem> availableValues = new ArrayList<>(); |
|
438 |
availableValues.add(new DynObjectValueItem(null, " ")); |
|
439 |
if(param.getOptions() == null){ |
|
440 |
for (ParameterOption option : param.getOptions2()) { |
|
441 |
Object value = option.getValue(); |
|
442 |
String label = i18n.getTranslation(option.getLabel()); |
|
443 |
availableValues.add(new DynObjectValueItem(value, label)); |
|
444 |
} |
|
445 |
} else { |
|
446 |
for (Map.Entry<String, String> option : param.getOptions().entrySet()) { |
|
447 |
String value = option.getKey(); |
|
448 |
String label = i18n.getTranslation(option.getValue()); |
|
449 |
availableValues.add(new DynObjectValueItem(value, label)); |
|
450 |
} |
|
451 |
} |
|
452 |
tags = field.getTags(); |
|
453 |
tags.set("ParamType", param.getType()); |
|
454 |
field.setAvailableValues(availableValues); |
|
455 |
field.setDefaultFieldValue(param.getDefaultValue()); |
|
456 |
field.setMandatory(false); |
|
457 |
break; |
|
458 |
case GEOMETRY: |
|
459 |
case SELECTION: |
|
460 |
case CLIPBOARD: |
|
461 |
break; |
|
462 |
} |
|
463 |
} |
|
464 |
return def; |
|
465 |
} |
|
466 |
|
|
467 |
private void clear() { |
|
468 |
this.form.clear(); |
|
469 |
} |
|
470 |
|
|
471 |
private void put(EditingService service) { |
|
472 |
if(this.service != service || service == null) { |
|
473 |
return; |
|
474 |
} |
|
475 |
|
|
476 |
List<ServiceParameterField> params = this.getServiceParameters(service); |
|
477 |
for (ServiceParameterField param : params) { |
|
478 |
if(param.getIgnoreCurrentValue()){ |
|
479 |
this.form.setValue( |
|
480 |
param.getFieldName(), |
|
481 |
null |
|
482 |
); |
|
483 |
|
|
484 |
} else { |
|
485 |
this.form.setValue( |
|
486 |
param.getFieldName(), |
|
487 |
service.getValue(param.getParameters(),param.getType()) |
|
488 |
); |
|
489 |
} |
|
490 |
} |
|
491 |
} |
|
492 |
|
|
493 |
private boolean ignore_events = false; |
|
494 |
private void doServiceChanged(Notification notification) { |
|
495 |
if( ignore_events ) { |
|
496 |
return; |
|
497 |
} |
|
498 |
try { |
|
499 |
ignore_events = true; |
|
500 |
switch (notification.getType()) { |
|
501 |
case EditingService.PARAMETER_CHANGED2_NOTIFICATION: |
|
502 |
case EditingService.PARAMETER_CHANGED1_NOTIFICATION: |
|
503 |
this.put(this.editingContext.getActiveService()); |
|
504 |
break; |
|
505 |
case EditingService.ACTIVATE_NOTIFICATION: |
|
506 |
this.set(this.editingContext.getActiveService()); |
|
507 |
this.put(this.editingContext.getActiveService()); |
|
508 |
break; |
|
509 |
case EditingService.START_NOTIFICATION: |
|
510 |
// this.clear(); |
|
511 |
break; |
|
512 |
} |
|
513 |
} finally { |
|
514 |
ignore_events = false; |
|
515 |
} |
|
516 |
} |
|
517 |
|
|
518 |
private void doContextChanged(Notification notification) { |
|
519 |
if (ignore_events) { |
|
520 |
return; |
|
521 |
} |
|
522 |
try { |
|
523 |
ignore_events = true; |
|
524 |
switch (notification.getType()) { |
|
525 |
case EditingContext.CHANGE_SELECTED_TOOL_NOTIFICATION: |
|
526 |
EditingService activeService = this.editingContext.getActiveService(); |
|
527 |
this.set(activeService); |
|
528 |
if (activeService != null) { |
|
529 |
this.put(activeService); |
|
530 |
} |
|
531 |
break; |
|
532 |
|
|
533 |
} |
|
534 |
} finally { |
|
535 |
ignore_events = false; |
|
536 |
} |
|
537 |
} |
|
538 |
|
|
539 |
public void applyDefaultValues() { |
|
540 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
541 |
EditableFeature feature = this.service.getDefaultFeatureValues(); |
|
542 |
this.featureform.fetch(feature); |
|
543 |
this.applyDefaultValuesButton.setIcon(null); |
|
544 |
defaultValues.put(this.service.getStore().getFullName(), feature.toJson()); |
|
545 |
this.txtBookmarkName.setText(""); |
|
546 |
} |
|
547 |
|
|
548 |
public void resetDefaultValues() { |
|
549 |
try { |
|
550 |
FeatureStore store = this.service.getStore(); |
|
551 |
EditableFeature resetValues = store.createNewFeature(); |
|
552 |
EditableFeature feature = this.service.getDefaultFeatureValues(); |
|
553 |
feature.copyFrom(resetValues); |
|
554 |
|
|
555 |
this.featureform.setFeature(feature); |
|
556 |
applyDefaultValuesButton.setIcon(null); |
|
557 |
defaultValues.put(this.service.getStore().getFullName(), feature.toJson()); |
|
558 |
this.txtBookmarkName.setText(""); |
|
559 |
} catch (Exception ex) { |
|
560 |
LOGGER.warn("Can't reset default values",ex); |
|
561 |
} |
|
562 |
} |
|
563 |
|
|
564 |
public void applyOptions() { |
|
565 |
boolean ignore_events_save = this.ignore_events; |
|
566 |
try { |
|
567 |
this.ignore_events = true; |
|
568 |
List<ServiceParameterField> params = this.getServiceParameters(service); |
|
569 |
for (ServiceParameterField param : params) { |
|
570 |
Object value = this.form.getValue(param.getFieldName()); |
|
571 |
try { |
|
572 |
editingContext.setValue(param.getParameters(), value, false); |
|
573 |
} catch (Throwable th) { |
|
574 |
LOGGER.debug("Can't set service parameter '" + param.getName() + "' to '" + Objects.toString(value) + "'.", th); |
|
575 |
} |
|
576 |
} |
|
577 |
try { |
|
578 |
editingContext.nextParameter(); |
|
579 |
} catch (Exception ex) { |
|
580 |
LOGGER.debug("Can't apply service parameters.", ex); |
|
581 |
} |
|
582 |
this.acceptOptionsButton.setIcon(null); |
|
583 |
} finally { |
|
584 |
this.ignore_events = ignore_events_save; |
|
585 |
} |
|
586 |
this.put(service); |
|
587 |
} |
|
588 |
|
|
589 |
private static class ServiceParameterField { |
|
590 |
private final EditingServiceParameter param; |
|
591 |
private final EditingServiceParameter.TYPE type; |
|
592 |
private final String fieldName; |
|
593 |
private final boolean aditional; |
|
594 |
private boolean ignoreCurrentValue; |
|
595 |
|
|
596 |
public ServiceParameterField( |
|
597 |
EditingServiceParameter param, |
|
598 |
EditingServiceParameter.TYPE type, |
|
599 |
String fieldName, |
|
600 |
boolean aditional |
|
601 |
) { |
|
602 |
this.aditional = aditional; |
|
603 |
this.fieldName = fieldName; |
|
604 |
this.param = param; |
|
605 |
this.type = type; |
|
606 |
this.ignoreCurrentValue = false; |
|
607 |
} |
|
608 |
|
|
609 |
private EditingServiceParameter.TYPE getType() { |
|
610 |
return this.type; |
|
611 |
} |
|
612 |
|
|
613 |
private String getName() { |
|
614 |
return this.param.getName(); |
|
615 |
} |
|
616 |
|
|
617 |
private int getDataType() { |
|
618 |
return this.param.getDataType(); |
|
619 |
} |
|
620 |
|
|
621 |
private String getDescription() { |
|
622 |
return this.param.getDescription(); |
|
623 |
} |
|
624 |
|
|
625 |
private String getFieldName() { |
|
626 |
return this.fieldName; |
|
627 |
} |
|
628 |
|
|
629 |
private Object getDefaultValue() { |
|
630 |
return this.param.getDefaultValue(); |
|
631 |
} |
|
632 |
|
|
633 |
private Map<String, String> getOptions() { |
|
634 |
return this.param.getOptions(); |
|
635 |
} |
|
636 |
|
|
637 |
private EditingServiceParameterOptions getOptions2() { |
|
638 |
return this.param.getOptions2(); |
|
639 |
} |
|
640 |
|
|
641 |
private boolean isAditional() { |
|
642 |
return this.aditional; |
|
643 |
} |
|
644 |
|
|
645 |
private EditingServiceParameter getParameters() { |
|
646 |
return this.param; |
|
647 |
} |
|
648 |
|
|
649 |
public void setIgnoreCurrentValue(boolean ignoreCurrentValue) { |
|
650 |
this.ignoreCurrentValue = ignoreCurrentValue; |
|
651 |
} |
|
652 |
|
|
653 |
public boolean getIgnoreCurrentValue() { |
|
654 |
return this.ignoreCurrentValue; |
|
655 |
} |
|
656 |
} |
|
657 |
|
|
658 |
private List<ServiceParameterField> getServiceParameters(EditingService service) { |
|
659 |
List<ServiceParameterField>params = new ArrayList<>(); |
|
660 |
EditingServiceParameter.TYPE paramTypesOrdered[] = new EditingServiceParameter.TYPE[] { |
|
661 |
EditingServiceParameter.TYPE.POSITION, |
|
662 |
EditingServiceParameter.TYPE.LIST_POSITIONS, |
|
663 |
EditingServiceParameter.TYPE.VALUE, |
|
664 |
EditingServiceParameter.TYPE.DISTANCE, |
|
665 |
EditingServiceParameter.TYPE.OPTION, |
|
666 |
EditingServiceParameter.TYPE.GEOMETRY, |
|
667 |
EditingServiceParameter.TYPE.SELECTION, |
|
668 |
EditingServiceParameter.TYPE.CLIPBOARD |
|
669 |
}; |
|
670 |
int n = 0; |
|
671 |
for (EditingServiceParameter param : service.getParameters()) { |
|
672 |
int count = 0; |
|
673 |
for (int ntype = 0; ntype < paramTypesOrdered.length; ntype++) { |
|
674 |
EditingServiceParameter.TYPE type = paramTypesOrdered[ntype]; |
|
675 |
if( !param.getTypes().contains(type) ) { |
|
676 |
continue; |
|
677 |
} |
|
678 |
switch(type) { |
|
679 |
case POSITION: |
|
680 |
case LIST_POSITIONS: |
|
681 |
case DISTANCE: |
|
682 |
case GEOMETRY: |
|
683 |
case SELECTION: |
|
684 |
case CLIPBOARD: |
|
685 |
break; |
|
686 |
case VALUE: |
|
687 |
case OPTION: |
|
688 |
String name = String.format("param%02d%02d", n, ntype); |
|
689 |
ServiceParameterField serviceField = new ServiceParameterField(param, type, name, count>0); |
|
690 |
if(param.getTypes().contains(EditingServiceParameter.TYPE.LIST_POSITIONS)){ |
|
691 |
//Ver la herramienta Polyline |
|
692 |
serviceField.setIgnoreCurrentValue(true); |
|
693 |
} |
|
694 |
params.add(serviceField); |
|
695 |
count++; |
|
696 |
break; |
|
697 |
|
|
698 |
} |
|
699 |
} |
|
700 |
n++; |
|
701 |
} |
|
702 |
return params; |
|
703 |
} |
|
704 |
|
|
705 |
public static class EditingToolOptionsDefaultValueBookmark implements Persistent { |
|
706 |
|
|
707 |
private JsonObject values; |
|
708 |
private boolean keepWhenNullInMarker; |
|
709 |
private String label; |
|
710 |
|
|
711 |
public EditingToolOptionsDefaultValueBookmark() { |
|
712 |
|
|
713 |
} |
|
714 |
|
|
715 |
public JsonObject getDefaultValues() { |
|
716 |
return this.values; |
|
717 |
} |
|
718 |
|
|
719 |
public void setDefaultValues(Feature feature) { |
|
720 |
this.values = feature.toJson(); |
|
721 |
} |
|
722 |
|
|
723 |
@Override |
|
724 |
public String toString() { |
|
725 |
try { |
|
726 |
StringBuilder buffer = new StringBuilder(); |
|
727 |
boolean needcolon = false; |
|
728 |
for (JsonValue value : this.values.values()) { |
|
729 |
if( value!=null ) { |
|
730 |
String s = Json.toString(value); |
|
731 |
if( StringUtils.isNotBlank(s) ) { |
|
732 |
if( needcolon ) { |
|
733 |
buffer.append(","); |
|
734 |
} else { |
|
735 |
needcolon = true; |
|
736 |
} |
|
737 |
buffer.append(s); |
|
738 |
} |
|
739 |
} |
|
740 |
} |
|
741 |
return buffer.toString(); |
|
742 |
} catch(Exception ex) { |
|
743 |
return "default values"; |
|
744 |
} |
|
745 |
} |
|
746 |
|
|
747 |
@Override |
|
748 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
749 |
state.set("values", Objects.toString(this.values,null)); |
|
750 |
state.set("keepWhenNullInMarker",this.keepWhenNullInMarker); |
|
751 |
} |
|
752 |
|
|
753 |
@Override |
|
754 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
755 |
String json_s = state.getString("values"); |
|
756 |
if( StringUtils.isBlank(json_s) ) { |
|
757 |
this.values = null; |
|
758 |
} else { |
|
759 |
try { |
|
760 |
this.values = Json.createObject(json_s); |
|
761 |
} catch(Exception ex) { |
|
762 |
LOGGER.warn("Can't restore default value from persistence", ex); |
|
763 |
} |
|
764 |
} |
|
765 |
this.keepWhenNullInMarker = state.getBoolean("keepWhenNullInMarker", false); |
|
766 |
} |
|
767 |
|
|
768 |
public void setKeepWhenNullInMarker(boolean keepWhenNullInMarker) { |
|
769 |
this.keepWhenNullInMarker = keepWhenNullInMarker; |
|
770 |
} |
|
771 |
|
|
772 |
public boolean getKeepWhenNullInMarker() { |
|
773 |
return this.keepWhenNullInMarker; |
|
774 |
} |
|
775 |
} |
|
776 |
|
|
777 |
public static void registerPersistence() { |
|
778 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
779 |
if (manager.getDefinition("EditingToolOptionsDefaultValueBookmark") == null) { |
|
780 |
DynStruct definition = manager.addDefinition(EditingToolOptionsDefaultValueBookmark.class, |
|
781 |
"EditingToolOptionsDefaultValueBookmark", "EditingToolOptionsDefaultValueBookmark persistence definition", null, null); |
|
782 |
definition.addDynFieldString("values"); |
|
783 |
definition.addDynFieldBoolean("keepWhenNullInMarker").setMandatory(false); |
|
784 |
} |
|
785 |
} |
|
786 |
|
|
787 |
public JPanel createHeader(FeatureStore store) { |
|
788 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
789 |
|
|
790 |
String s = i18n.getTranslation("_unknown"); |
|
791 |
if( store != null ) { |
|
792 |
s = store.getName(); |
|
793 |
FeatureType ft = store.getDefaultFeatureTypeQuietly(); |
|
794 |
if( ft!=null ) { |
|
795 |
if( StringUtils.isNotBlank(ft.getLabel()) && !store.getName().equals(ft.getLabel()) ) { |
|
796 |
s = ft.getLabel() + " ("+store.getName()+")"; |
|
797 |
} |
|
798 |
} |
|
799 |
} |
|
800 |
final String storelabel = s; |
|
801 |
|
|
802 |
final JTextField txtTable = new JTextField(); |
|
803 |
final JTextField txtTool = new JTextField(); |
|
804 |
|
|
805 |
JLabel lblTable = new JLabel(i18n.getTranslation("_Table")+ ": "); |
|
806 |
JLabel lblTool = new JLabel(i18n.getTranslation("_Tool")+ ": "); |
|
807 |
|
|
808 |
txtTable.setBorder(null); |
|
809 |
txtTable.setBackground(UIManager.getColor(ToolsSwingManager.COLOR_PANEL_BACKGROUND)); |
|
810 |
// txtTable.setFocusable(false); |
|
811 |
|
|
812 |
txtTool.setBorder(null); |
|
813 |
txtTool.setBackground(UIManager.getColor(ToolsSwingManager.COLOR_PANEL_BACKGROUND)); |
|
814 |
// txtTool.setFocusable(false); |
|
815 |
|
|
816 |
txtTable.addKeyListener(keylistener); |
|
817 |
txtTool.addKeyListener(keylistener); |
|
818 |
|
|
819 |
JPanel panel = new JPanel(); |
|
820 |
panel.setLayout(new GridBagLayout()); |
|
821 |
GridBagConstraints c = new GridBagConstraints(); |
|
822 |
c.ipadx = 1; |
|
823 |
c.ipady = 1; |
|
824 |
c.fill = GridBagConstraints.HORIZONTAL; |
|
825 |
|
|
826 |
c.gridx = 0; |
|
827 |
c.gridy = 0; |
|
828 |
c.weightx = 0; |
|
829 |
panel.add(lblTable, c); |
|
830 |
c.gridx = 0; |
|
831 |
c.gridy = 1; |
|
832 |
c.weightx = 0; |
|
833 |
panel.add(lblTool, c); |
|
834 |
c.gridx = 1; |
|
835 |
c.gridy = 0; |
|
836 |
c.weightx = 1; |
|
837 |
panel.add(txtTable, c); |
|
838 |
c.gridx = 1; |
|
839 |
c.gridy = 1; |
|
840 |
c.weightx = 1; |
|
841 |
panel.add(txtTool, c); |
|
842 |
|
|
843 |
c.gridx = 0; |
|
844 |
c.gridy = 2; |
|
845 |
c.weightx = 1; |
|
846 |
c.gridwidth = 2; |
|
847 |
panel.add(this.txtBookmarkName, c); |
|
848 |
|
|
849 |
SwingUtilities.invokeLater(() -> { |
|
850 |
txtTable.setText(storelabel); |
|
851 |
txtTable.setCaretPosition(0); |
|
852 |
txtTool.setText(i18n.getTranslation(service.getDescription())); |
|
853 |
txtTool.setCaretPosition(0); |
|
854 |
}); |
|
855 |
|
|
856 |
return panel; |
|
857 |
} |
|
858 |
|
|
859 |
private JCheckBoxMenuItem getKeepWhenNullInMarkerMenuItem() { |
|
860 |
if( keepWhenNullInMarkerMenuItem == null ) { |
|
861 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
862 |
JCheckBoxMenuItem item = new JCheckBoxMenuItem(); |
|
863 |
item.setText(i18n.getTranslation("_Keep_when_null")); |
|
864 |
item.setToolTipText(i18n.getTranslation("_It_does_not_replace_the_default_values_when_the_marker_is_null")); |
|
865 |
keepWhenNullInMarkerMenuItem = item; |
|
866 |
} |
|
867 |
return keepWhenNullInMarkerMenuItem; |
|
868 |
} |
|
869 |
} |
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.264/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/java/org/gvsig/vectorediting/app/mainplugin/ServiceExtension.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2014 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 2 |
|
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.vectorediting.app.mainplugin; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.List; |
|
28 |
import org.gvsig.andami.plugins.Extension; |
|
29 |
import org.gvsig.app.ApplicationLocator; |
|
30 |
import org.gvsig.app.ApplicationManager; |
|
31 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
32 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
33 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
34 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
35 |
import org.gvsig.vectorediting.swing.api.EditingContext; |
|
36 |
import org.gvsig.vectorediting.swing.api.EditingSwingLocator; |
|
37 |
import org.gvsig.vectorediting.swing.api.EditingSwingManager; |
|
38 |
|
|
39 |
public class ServiceExtension extends Extension { |
|
40 |
|
|
41 |
@Override |
|
42 |
public void initialize() { |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
public void execute(String actionCommand) { |
|
47 |
IView view = getActiveView(); |
|
48 |
EditingSwingManager swingManager = |
|
49 |
EditingSwingLocator.getSwingManager(); |
|
50 |
|
|
51 |
if (view != null) { |
|
52 |
EditingContext editingContext = |
|
53 |
swingManager.getEditingContext(view.getMapControl()); |
|
54 |
editingContext.activateService(actionCommand); |
|
55 |
} |
|
56 |
|
|
57 |
} |
|
58 |
|
Also available in: Unified diff