Revision 895
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.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 |
<artifactId>org.gvsig.scripting.app</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.scripting</artifactId> |
|
11 |
<version>2.3.46</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<modules> |
|
15 |
<module>org.gvsig.scripting.app.mainplugin</module> |
|
16 |
</modules> |
|
17 |
</project> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/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 |
<artifactId>org.gvsig.scripting.app.mainplugin</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<description><![CDATA[ |
|
9 |
This plugin provides support for scripting to gvSIG. |
|
10 |
Among other things it contains: |
|
11 |
|
|
12 |
- The gvSIG scripting engine |
|
13 |
- The gvSIG script editor |
|
14 |
- Script engines for: |
|
15 |
- Jython |
|
16 |
- Groovy |
|
17 |
- javascript |
|
18 |
- Renjin |
|
19 |
|
|
20 |
- The script install module for the add-on manager. |
|
21 |
- Utilities to generate packages of complements with our scripts. |
|
22 |
- Python libraries as: |
|
23 |
- Six - Utilities for writing code that runs on Python 2 and 3 |
|
24 |
- PyLint - Python source code analyzer |
|
25 |
- Pygments - syntax highlighting package |
|
26 |
- CSSUtils - CSS Cascading Style Sheets library |
|
27 |
- Docutils - Python Documentation Utilities |
|
28 |
- geopy - client for several popular geocoding web services |
|
29 |
- PyInliner - CSS-to-inline-styles conversion tool for HTML |
|
30 |
- Statistics - functions for calculating statistics of data |
|
31 |
- Cartodb - simple CartoDB client to perform requests against the CartoDB API |
|
32 |
|
|
33 |
- Java libraries to use from scripting like: |
|
34 |
- Abeille forms deseigner |
|
35 |
- jOpenDocument |
|
36 |
- JNumeric |
|
37 |
- CSSBox |
|
38 |
|
|
39 |
|
|
40 |
This plugin can be configured to be preinstalled automatically, allowing |
|
41 |
"Script" type plugins to be installed during the application installation process. |
|
42 |
To do this, the following entries must be added to the "packages.properties" |
|
43 |
of gvspks:: |
|
44 |
|
|
45 |
installers=scripts |
|
46 |
installer.scripts.initializer=org.gvsig.scripting.app.extension.ScriptsInstallerInitializer |
|
47 |
installer.scripts.package.code=org.gvsig.scripting.app.mainplugin |
|
48 |
installer.scripts.factory.name=Script |
|
49 |
installer.scripts.libs=lib |
|
50 |
|
|
51 |
If the "installers" entry already exists, add "scripts" to the end separating |
|
52 |
it with a space. |
|
53 |
|
|
54 |
]]></description> |
|
55 |
<parent> |
|
56 |
<groupId>org.gvsig</groupId> |
|
57 |
<artifactId>org.gvsig.scripting.app</artifactId> |
|
58 |
<version>2.3.46</version> |
|
59 |
</parent> |
|
60 |
<dependencies> |
|
61 |
<dependency> |
|
62 |
<groupId>org.gvsig</groupId> |
|
63 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
64 |
<scope>compile</scope> |
|
65 |
</dependency> |
|
66 |
<dependency> |
|
67 |
<groupId>org.gvsig</groupId> |
|
68 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
69 |
<type>test-jar</type> |
|
70 |
<scope>test</scope> |
|
71 |
</dependency> |
|
72 |
<dependency> |
|
73 |
<groupId>org.gvsig</groupId> |
|
74 |
<artifactId>org.gvsig.i18n</artifactId> |
|
75 |
<scope>compile</scope> |
|
76 |
</dependency> |
|
77 |
<dependency> |
|
78 |
<groupId>org.gvsig</groupId> |
|
79 |
<artifactId>org.gvsig.andami</artifactId> |
|
80 |
<scope>compile</scope> |
|
81 |
</dependency> |
|
82 |
<dependency> |
|
83 |
<groupId>org.gvsig</groupId> |
|
84 |
<artifactId>org.gvsig.app.document.table.app.mainplugin</artifactId> |
|
85 |
<scope>compile</scope> |
|
86 |
</dependency> |
|
87 |
<dependency> |
|
88 |
<groupId>org.gvsig</groupId> |
|
89 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
90 |
<scope>compile</scope> |
|
91 |
</dependency> |
|
92 |
<dependency> |
|
93 |
<groupId>org.gvsig</groupId> |
|
94 |
<artifactId>org.gvsig.tools.swing.impl</artifactId> |
|
95 |
<scope>compile</scope> |
|
96 |
</dependency> |
|
97 |
<dependency> |
|
98 |
<groupId>org.gvsig</groupId> |
|
99 |
<artifactId>org.gvsig.about.api</artifactId> |
|
100 |
<scope>compile</scope> |
|
101 |
</dependency> |
|
102 |
<dependency> |
|
103 |
<groupId>org.gvsig</groupId> |
|
104 |
<artifactId>org.gvsig.scripting.lib.api</artifactId> |
|
105 |
<scope>compile</scope> |
|
106 |
</dependency> |
|
107 |
<dependency> |
|
108 |
<groupId>org.gvsig</groupId> |
|
109 |
<artifactId>org.gvsig.scripting.swing.api</artifactId> |
|
110 |
<scope>compile</scope> |
|
111 |
</dependency> |
|
112 |
<dependency> |
|
113 |
<groupId>org.gvsig</groupId> |
|
114 |
<artifactId>org.gvsig.scripting.lib.impl</artifactId> |
|
115 |
<scope>compile</scope> |
|
116 |
</dependency> |
|
117 |
<dependency> |
|
118 |
<groupId>org.gvsig</groupId> |
|
119 |
<artifactId>org.gvsig.scripting.swing.impl</artifactId> |
|
120 |
<scope>compile</scope> |
|
121 |
</dependency> |
|
122 |
|
|
123 |
<!-- force adding --> |
|
124 |
<dependency> |
|
125 |
<groupId>org.ini4j</groupId> |
|
126 |
<artifactId>ini4j</artifactId> |
|
127 |
<scope>runtime</scope> |
|
128 |
</dependency> |
|
129 |
<dependency> |
|
130 |
<groupId>net.sourceforge.thinlet</groupId> |
|
131 |
<artifactId>thinlet</artifactId> |
|
132 |
<scope>runtime</scope> |
|
133 |
</dependency> |
|
134 |
<dependency> |
|
135 |
<groupId>org.gvsig</groupId> |
|
136 |
<artifactId>org.gvsig.scripting.thing</artifactId> |
|
137 |
<scope>runtime</scope> |
|
138 |
</dependency> |
|
139 |
<dependency> |
|
140 |
<groupId>com.jeta</groupId> |
|
141 |
<artifactId>abeille</artifactId> |
|
142 |
<type>tar.gz</type> |
|
143 |
<scope>runtime</scope> |
|
144 |
</dependency> |
|
145 |
<dependency> |
|
146 |
<groupId>org.jopendocument</groupId> |
|
147 |
<artifactId>jOpenDocument</artifactId> |
|
148 |
<scope>runtime</scope> |
|
149 |
</dependency> |
|
150 |
<dependency> |
|
151 |
<groupId>com.github.tbekolay.jnumeric</groupId> |
|
152 |
<artifactId>jnumeric</artifactId> |
|
153 |
<scope>runtime</scope> |
|
154 |
</dependency> |
|
155 |
|
|
156 |
<dependency> |
|
157 |
<groupId>org.apache.tika</groupId> |
|
158 |
<artifactId>tika-core</artifactId> |
|
159 |
<scope>runtime</scope> |
|
160 |
</dependency> |
|
161 |
|
|
162 |
<dependency> |
|
163 |
<groupId>org.python</groupId> |
|
164 |
<artifactId>${jython.artifactId}</artifactId> |
|
165 |
<scope>runtime</scope> |
|
166 |
</dependency> |
|
167 |
<dependency> |
|
168 |
<groupId>org.codehaus.groovy</groupId> |
|
169 |
<artifactId>groovy-all</artifactId> |
|
170 |
<scope>runtime</scope> |
|
171 |
</dependency> |
|
172 |
<dependency> |
|
173 |
<groupId>org.renjin</groupId> |
|
174 |
<artifactId>renjin-script-engine</artifactId> |
|
175 |
<classifier>jar-with-dependencies</classifier> |
|
176 |
<scope>runtime</scope> |
|
177 |
</dependency> |
|
178 |
|
|
179 |
<dependency> |
|
180 |
<groupId>org.scala-lang</groupId> |
|
181 |
<artifactId>scala-dist</artifactId> |
|
182 |
<scope>runtime</scope> |
|
183 |
</dependency> |
|
184 |
<dependency> |
|
185 |
<groupId>org.scala-lang</groupId> |
|
186 |
<artifactId>scala-compiler</artifactId> |
|
187 |
<scope>runtime</scope> |
|
188 |
</dependency> |
|
189 |
<dependency> |
|
190 |
<groupId>org.scala-lang</groupId> |
|
191 |
<artifactId>scala-library</artifactId> |
|
192 |
<scope>runtime</scope> |
|
193 |
</dependency> |
|
194 |
<dependency> |
|
195 |
<groupId>org.scala-lang</groupId> |
|
196 |
<artifactId>scala-reflect</artifactId> |
|
197 |
<scope>runtime</scope> |
|
198 |
</dependency> |
|
199 |
<dependency> |
|
200 |
<groupId>org.scala-lang</groupId> |
|
201 |
<artifactId>scalap</artifactId> |
|
202 |
<scope>runtime</scope> |
|
203 |
</dependency> |
|
204 |
<dependency> |
|
205 |
<groupId>jline</groupId> |
|
206 |
<artifactId>jline</artifactId> |
|
207 |
<scope>runtime</scope> |
|
208 |
</dependency> |
|
209 |
<dependency> |
|
210 |
<groupId>net.sf.cssbox</groupId> |
|
211 |
<artifactId>swingbox</artifactId> |
|
212 |
<scope>runtime</scope> |
|
213 |
</dependency> |
|
214 |
<dependency> |
|
215 |
<groupId>net.sf.cssbox</groupId> |
|
216 |
<artifactId>cssbox</artifactId> |
|
217 |
<scope>runtime</scope> |
|
218 |
</dependency> |
|
219 |
|
|
220 |
<dependency> |
|
221 |
<groupId>net.sourceforge.nekohtml</groupId> |
|
222 |
<artifactId>nekohtml</artifactId> |
|
223 |
<scope>runtime</scope> |
|
224 |
</dependency> |
|
225 |
<dependency> |
|
226 |
<groupId>net.sf.cssbox</groupId> |
|
227 |
<artifactId>jstyleparser</artifactId> |
|
228 |
<scope>runtime</scope> |
|
229 |
</dependency> |
|
230 |
<dependency> |
|
231 |
<groupId>org.antlr</groupId> |
|
232 |
<artifactId>antlr-runtime</artifactId> |
|
233 |
<!-- Ojo que forzamos una version en concreto --> |
|
234 |
<version>3.5.2</version> |
|
235 |
</dependency> |
|
236 |
</dependencies> |
|
237 |
|
|
238 |
|
|
239 |
<properties> |
|
240 |
<gvsig.package.info.name>Scripting framework</gvsig.package.info.name> |
|
241 |
<gvsig.package.info.dependencies>required: org.gvsig.app.document.table.app.mainplugin -ge 2</gvsig.package.info.dependencies> |
|
242 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-scripting/pool</gvsig.package.info.poolURL> |
|
243 |
<gvsig.package.info.sourcesURL>https://devel.gvsig.org/svn/gvsig-scripting</gvsig.package.info.sourcesURL> |
|
244 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
245 |
<gvsig.package.info.categories>Development</gvsig.package.info.categories> |
|
246 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
247 |
|
|
248 |
</properties> |
|
249 |
|
|
250 |
<build> |
|
251 |
<plugins> |
|
252 |
|
|
253 |
<plugin> |
|
254 |
<groupId>org.apache.maven.plugins</groupId> |
|
255 |
<artifactId>maven-dependency-plugin</artifactId> |
|
256 |
<executions> |
|
257 |
<execution> |
|
258 |
<id>unpack</id> |
|
259 |
<phase>process-sources</phase> |
|
260 |
<goals> |
|
261 |
<goal>unpack</goal> |
|
262 |
</goals> |
|
263 |
<configuration> |
|
264 |
<artifactItems> |
|
265 |
<artifactItem> |
|
266 |
<groupId>com.jeta</groupId> |
|
267 |
<artifactId>abeille</artifactId> |
|
268 |
<version>2.1.0.M3</version> |
|
269 |
<type>tar.gz</type> |
|
270 |
<overWrite>true</overWrite> |
|
271 |
<outputDirectory>target/abeille</outputDirectory> |
|
272 |
</artifactItem> |
|
273 |
</artifactItems> |
|
274 |
</configuration> |
|
275 |
</execution> |
|
276 |
</executions> |
|
277 |
</plugin> |
|
278 |
|
|
279 |
</plugins> |
|
280 |
</build> |
|
281 |
|
|
282 |
</project> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Wed Jul 26 00:28:55 CEST 2017 |
|
2 |
buildNumber=100 |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/test/java/org/gvsig/scripting/app/extension/AppTest.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
package org.gvsig.scripting.app.extension; |
|
24 |
|
|
25 |
import junit.framework.Test; |
|
26 |
import junit.framework.TestCase; |
|
27 |
import junit.framework.TestSuite; |
|
28 |
|
|
29 |
/** |
|
30 |
* Unit test for simple App. |
|
31 |
*/ |
|
32 |
public class AppTest |
|
33 |
extends TestCase |
|
34 |
{ |
|
35 |
/** |
|
36 |
* Create the test case |
|
37 |
* |
|
38 |
* @param testName name of the test case |
|
39 |
*/ |
|
40 |
public AppTest( String testName ) |
|
41 |
{ |
|
42 |
super( testName ); |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* @return the suite of tests being tested |
|
47 |
*/ |
|
48 |
public static Test suite() |
|
49 |
{ |
|
50 |
return new TestSuite( AppTest.class ); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* Rigourous Test :-) |
|
55 |
*/ |
|
56 |
public void testApp() |
|
57 |
{ |
|
58 |
assertTrue( true ); |
|
59 |
} |
|
60 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptLaunchExtension.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app.extension; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Arrays; |
|
6 |
import java.util.List; |
|
7 |
import javax.swing.JOptionPane; |
|
8 |
import org.gvsig.andami.PluginsLocator; |
|
9 |
import org.gvsig.andami.PluginsManager; |
|
10 |
import org.gvsig.andami.plugins.Extension; |
|
11 |
import org.gvsig.app.ApplicationLocator; |
|
12 |
import org.gvsig.app.ApplicationManager; |
|
13 |
import org.gvsig.scripting.ScriptingLocator; |
|
14 |
import org.gvsig.scripting.ScriptingManager; |
|
15 |
import org.gvsig.scripting.ScriptingScript; |
|
16 |
import org.slf4j.Logger; |
|
17 |
import org.slf4j.LoggerFactory; |
|
18 |
|
|
19 |
public class ScriptLaunchExtension extends Extension { |
|
20 |
|
|
21 |
private static final Logger logger = LoggerFactory.getLogger(ScriptLaunchExtension.class); |
|
22 |
|
|
23 |
@Override |
|
24 |
public void initialize() { |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
public boolean isEnabled() { |
|
29 |
return true; |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public boolean isVisible() { |
|
34 |
return true; |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public boolean canQueryByAction() { |
|
39 |
return true; |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public void execute(String action) { |
|
44 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
45 |
ScriptingScript script = getScript(action); |
|
46 |
if( script == null ) { |
|
47 |
application.messageDialog( |
|
48 |
"Can't locate script '"+action+"'", |
|
49 |
"Warning", |
|
50 |
JOptionPane.WARNING_MESSAGE |
|
51 |
); |
|
52 |
return; |
|
53 |
} |
|
54 |
try { |
|
55 |
script.runAsTask(null); |
|
56 |
} catch (Throwable th) { |
|
57 |
logger.warn("Can't execute '" + action + "' script.", th); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public void execute(String action, Object[] args) { |
|
63 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
64 |
ScriptingScript script = getScript(action); |
|
65 |
if( script == null ) { |
|
66 |
application.messageDialog( |
|
67 |
"Can't locate script '"+action+"'", |
|
68 |
"Warning", |
|
69 |
JOptionPane.WARNING_MESSAGE |
|
70 |
); |
|
71 |
return; |
|
72 |
} |
|
73 |
try { |
|
74 |
script.runAsTask(args); |
|
75 |
} catch (Throwable th) { |
|
76 |
logger.warn("Can't execute '" + action + "' script.", th); |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public boolean isVisible(String action) { |
|
82 |
ScriptingScript script = getScript(action); |
|
83 |
try { |
|
84 |
Boolean value = (Boolean) script.invokeFunction("isVisible", null); |
|
85 |
return value; |
|
86 |
} catch (Throwable th) { |
|
87 |
logger.warn("Can't execute isVisible in '" + action + "' script.", th); |
|
88 |
} |
|
89 |
return false; |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public boolean isEnabled(String action) { |
|
94 |
ScriptingScript script = getScript(action); |
|
95 |
try { |
|
96 |
Boolean value = (Boolean) script.invokeFunction("isEnabled", null); |
|
97 |
return value; |
|
98 |
} catch (Throwable th) { |
|
99 |
logger.warn("Can't execute isEnabled in '" + action + "' script.", th); |
|
100 |
} |
|
101 |
return false; |
|
102 |
} |
|
103 |
|
|
104 |
private ScriptingScript getScript(String scriptpathname) { |
|
105 |
final ScriptingManager manager = ScriptingLocator.getManager(); |
|
106 |
final PluginsManager pluginManager = PluginsLocator.getManager(); |
|
107 |
|
|
108 |
File scriptfile; |
|
109 |
ScriptingScript script; |
|
110 |
|
|
111 |
String s = manager.getRootUserFolder().getAbsolutePath().replace("\\", "/"); |
|
112 |
scriptfile = new File(s+"/"+scriptpathname); |
|
113 |
if (scriptfile.exists()) { |
|
114 |
script = (ScriptingScript) manager.getScript(scriptfile); |
|
115 |
return script; |
|
116 |
} |
|
117 |
|
|
118 |
final List<File> pluginsFolders = new ArrayList<>(); |
|
119 |
for (File f : pluginManager.getPluginsFolders()) { |
|
120 |
pluginsFolders.addAll(Arrays.asList(f.listFiles())); |
|
121 |
} |
|
122 |
|
|
123 |
for (File pluginFolder : pluginsFolders) { |
|
124 |
s = pluginFolder.getAbsolutePath().replace("\\", "/"); |
|
125 |
scriptfile = new File(s+"/scripting/scripts/"+scriptpathname); |
|
126 |
if (scriptfile.exists()) { |
|
127 |
script = (ScriptingScript) manager.getScript(scriptfile); |
|
128 |
return script; |
|
129 |
} |
|
130 |
} |
|
131 |
return (ScriptingScript) manager.getScript(scriptpathname); |
|
132 |
} |
|
133 |
|
|
134 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptingExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
package org.gvsig.scripting.app.extension; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import java.io.InputStream; |
|
27 |
import java.nio.file.FileVisitOption; |
|
28 |
import static java.nio.file.FileVisitOption.FOLLOW_LINKS; |
|
29 |
import java.nio.file.FileVisitResult; |
|
30 |
import java.nio.file.Files; |
|
31 |
import java.nio.file.Path; |
|
32 |
import java.nio.file.Paths; |
|
33 |
import java.nio.file.SimpleFileVisitor; |
|
34 |
import java.nio.file.attribute.BasicFileAttributes; |
|
35 |
import java.text.MessageFormat; |
|
36 |
import java.util.ArrayList; |
|
37 |
import java.util.Arrays; |
|
38 |
import java.util.Collections; |
|
39 |
import java.util.Comparator; |
|
40 |
import java.util.EnumSet; |
|
41 |
import java.util.List; |
|
42 |
|
|
43 |
import javax.swing.JOptionPane; |
|
44 |
import javax.swing.SwingUtilities; |
|
45 |
import org.apache.commons.io.FileUtils; |
|
46 |
import org.apache.commons.io.IOUtils; |
|
47 |
import org.apache.commons.lang3.StringUtils; |
|
48 |
|
|
49 |
import org.gvsig.andami.IconThemeHelper; |
|
50 |
import org.gvsig.andami.PluginServices; |
|
51 |
import org.gvsig.andami.PluginsLocator; |
|
52 |
import org.gvsig.andami.PluginsManager; |
|
53 |
import org.gvsig.andami.plugins.Extension; |
|
54 |
import org.gvsig.app.ApplicationLocator; |
|
55 |
import org.gvsig.app.ApplicationManager; |
|
56 |
import org.gvsig.scripting.ScriptingBaseScript; |
|
57 |
import org.gvsig.scripting.ScriptingFolder; |
|
58 |
import org.gvsig.scripting.ScriptingLocator; |
|
59 |
import org.gvsig.scripting.ScriptingManager; |
|
60 |
import org.gvsig.scripting.ScriptingScript; |
|
61 |
import org.gvsig.scripting.ScriptingUnit; |
|
62 |
import org.gvsig.scripting.swing.api.JScriptingComposer; |
|
63 |
import org.gvsig.scripting.swing.api.ScriptingSwingLocator; |
|
64 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
|
65 |
import static org.gvsig.scripting.swing.api.ScriptingUIManager.SCRIPT_COMPOSER_AUTORUN; |
|
66 |
import org.gvsig.tools.dynobject.DynObject; |
|
67 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
68 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
69 |
import org.gvsig.tools.swing.impl.windowmanager.DefaultWindowManager; |
|
70 |
import org.slf4j.Logger; |
|
71 |
import org.slf4j.LoggerFactory; |
|
72 |
import org.gvsig.tools.ToolsLocator; |
|
73 |
import org.gvsig.tools.exception.BaseException; |
|
74 |
import org.gvsig.tools.i18n.I18nManager; |
|
75 |
import org.gvsig.tools.script.Script; |
|
76 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
77 |
import org.gvsig.tools.util.Invocable; |
|
78 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
79 |
import org.gvsig.tools.visitor.Visitor; |
|
80 |
|
|
81 |
public class ScriptingExtension extends Extension { |
|
82 |
|
|
83 |
private static final Logger logger = LoggerFactory.getLogger(ScriptingExtension.class); |
|
84 |
|
|
85 |
private PluginServices plugin = null; |
|
86 |
|
|
87 |
/* |
|
88 |
* la funcion log y las constantes estan pensadas para usarlas desde los scripts. |
|
89 |
*/ |
|
90 |
public static final int INFO = 0; |
|
91 |
public static final int TRACE = 1; |
|
92 |
public static final int WARN = 2; |
|
93 |
public static final int ERROR = 3; |
|
94 |
private static boolean composer_initialized = false; |
|
95 |
|
|
96 |
public static void log(String message) { |
|
97 |
log(INFO, message, null); |
|
98 |
} |
|
99 |
|
|
100 |
public static void log(int level, String message) { |
|
101 |
log(level, message, null); |
|
102 |
} |
|
103 |
|
|
104 |
public static void log(int level, String message, Throwable th) { |
|
105 |
switch( level ) { |
|
106 |
case TRACE: |
|
107 |
logger.trace(message, th); |
|
108 |
break; |
|
109 |
case ERROR: |
|
110 |
logger.error(message, th); |
|
111 |
break; |
|
112 |
case WARN: |
|
113 |
logger.warn(message, th); |
|
114 |
break; |
|
115 |
default: |
|
116 |
case INFO: |
|
117 |
logger.info(message, th); |
|
118 |
break; |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public PluginServices getPlugin() { |
|
124 |
if( this.plugin == null ) { |
|
125 |
this.plugin = PluginsLocator.getManager().getPlugin(ScriptingExtension.class); |
|
126 |
} |
|
127 |
return this.plugin; |
|
128 |
} |
|
129 |
|
|
130 |
@Override |
|
131 |
public void execute(String actionCommand) { |
|
132 |
this.execute(actionCommand, null); |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public void execute(String command, Object[] args) { |
|
137 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
138 |
WindowManager winmanager = ToolsSwingLocator.getWindowManager(); |
|
139 |
|
|
140 |
if( "tools-scripting-launcher".equalsIgnoreCase(command) ) { |
|
141 |
winmanager.showWindow(uimanager.createLauncher().asJComponent(), uimanager.getTranslation("Scripting_Launcher"), WindowManager.MODE.TOOL); |
|
142 |
|
|
143 |
} else if( "tools-scripting-composer".equalsIgnoreCase(command) ) { |
|
144 |
if( composer_initialized ) { |
|
145 |
showScriptingComposer(); |
|
146 |
} else { |
|
147 |
Thread th = new Thread(new StartupAndShowScriptingComposer(), "StartupAndShowScriptingComposer"); |
|
148 |
th.start(); |
|
149 |
} |
|
150 |
|
|
151 |
} else { |
|
152 |
ScriptingBaseScript script = uimanager.getManager().getScript(command); |
|
153 |
if( script != null ) { |
|
154 |
script.run(args); |
|
155 |
} else { |
|
156 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
157 |
application.messageDialog("Can't locate script '" + command + "'.", "ScriptLaunch", JOptionPane.OK_OPTION); |
|
158 |
} |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
private void showScriptingComposer() { |
|
163 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
164 |
WindowManager winmanager = ToolsSwingLocator.getWindowManager(); |
|
165 |
|
|
166 |
DynObject preferences = getPlugin().getPluginProperties(); |
|
167 |
Boolean composerUseHisWindowManager = (Boolean) preferences.getDynValue("ComposerUseHisWindowManager"); |
|
168 |
ScriptingUIManager uiManager = ScriptingSwingLocator.getUIManager(); |
|
169 |
if( composerUseHisWindowManager ) { |
|
170 |
winmanager = new DefaultWindowManager(); |
|
171 |
uiManager.setWindowManager(winmanager); |
|
172 |
} |
|
173 |
JScriptingComposer composer = uimanager.createComposer(); |
|
174 |
uiManager.showWindow( |
|
175 |
composer.asJComponent(), |
|
176 |
uimanager.getTranslation("Scripting_Composer") |
|
177 |
); |
|
178 |
} |
|
179 |
|
|
180 |
private class StartupAndShowScriptingComposer implements Runnable { |
|
181 |
|
|
182 |
@Override |
|
183 |
public void run() { |
|
184 |
SimpleTaskStatus status = ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus("Script composer startup"); |
|
185 |
status.setIndeterminate(); |
|
186 |
status.setAutoremove(true); |
|
187 |
status.add(); |
|
188 |
final ApplicationManager application = ApplicationLocator.getManager(); |
|
189 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
190 |
try { |
|
191 |
logger.info("Searching autorun scripts..."); |
|
192 |
application.message( |
|
193 |
i18nManager.getTranslation("_Searching_autorun_scripts_Xhorizontal_ellipsisX"), |
|
194 |
JOptionPane.INFORMATION_MESSAGE |
|
195 |
); |
|
196 |
ScriptingManager manager = ScriptingLocator.getManager(); |
|
197 |
final List<ScriptingScript> autoruns = new ArrayList<>(); |
|
198 |
|
|
199 |
Visitor visitor = new Visitor() { |
|
200 |
|
|
201 |
@Override |
|
202 |
public void visit(Object o) throws VisitCanceledException, BaseException { |
|
203 |
ScriptingUnit unit = (ScriptingUnit) o; |
|
204 |
if( unit instanceof ScriptingScript && SCRIPT_COMPOSER_AUTORUN.equalsIgnoreCase(unit.getId()) ) { |
|
205 |
ScriptingScript autorun = (ScriptingScript) unit; |
|
206 |
if( autorun.isEnabled() ) { |
|
207 |
autoruns.add(autorun); |
|
208 |
} else { |
|
209 |
logger.info("Skip scautorun script '" + autorun.getFile().getAbsolutePath() + "'."); |
|
210 |
} |
|
211 |
} |
|
212 |
} |
|
213 |
}; |
|
214 |
manager.getSystemFolder().accept(visitor); |
|
215 |
manager.getUserFolder().accept(visitor); |
|
216 |
if( !autoruns.isEmpty() ) { |
|
217 |
status.setRangeOfValues(0, autoruns.size()); |
|
218 |
int n=0; |
|
219 |
for (ScriptingScript autorun : autoruns) { |
|
220 |
status.setCurValue(n++); |
|
221 |
try { |
|
222 |
logger.info("running autorun script '" + autorun.getFile().getAbsolutePath() + "."); |
|
223 |
application.message( |
|
224 |
i18nManager.getTranslation( |
|
225 |
"_Running_autorun_script_from_XnameX", |
|
226 |
new String[]{ |
|
227 |
autorun.getFile().getParentFile().getName()} |
|
228 |
), |
|
229 |
JOptionPane.INFORMATION_MESSAGE |
|
230 |
); |
|
231 |
} catch (Exception ex) { |
|
232 |
// Ignore it |
|
233 |
} |
|
234 |
try { |
|
235 |
autorun.run(); |
|
236 |
} catch (Exception ex) { |
|
237 |
logger.warn("Can't execute autorun from '" + autorun.getFile().getAbsolutePath() + "'.", ex); |
|
238 |
} |
|
239 |
} |
|
240 |
} |
|
241 |
} catch(Throwable th) { |
|
242 |
|
|
243 |
} finally { |
|
244 |
logger.info("Running autorun scripts terminated."); |
|
245 |
application.message("", JOptionPane.INFORMATION_MESSAGE); |
|
246 |
status.terminate(); |
|
247 |
composer_initialized = true; |
|
248 |
} |
|
249 |
|
|
250 |
SwingUtilities.invokeLater(new Runnable() { |
|
251 |
@Override |
|
252 |
public void run() { |
|
253 |
showScriptingComposer(); |
|
254 |
} |
|
255 |
}); |
|
256 |
} |
|
257 |
} |
|
258 |
|
|
259 |
@Override |
|
260 |
public void initialize() { |
|
261 |
IconThemeHelper.registerIcon("action", "tools-scripting-launcher", this); |
|
262 |
IconThemeHelper.registerIcon("action", "tools-scripting-composer", this); |
|
263 |
IconThemeHelper.registerIcon("action", "tools-scripting-console-jython", this); |
|
264 |
|
|
265 |
initPaths(); |
|
266 |
Thread th = new Thread(new Runnable() { |
|
267 |
@Override |
|
268 |
public void run() { |
|
269 |
preloadPythonEngine(); |
|
270 |
} |
|
271 |
}, "ScriptEnginesInitializer"); |
|
272 |
th.start(); |
|
273 |
try { |
|
274 |
th.join(3000); // force change to other thread |
|
275 |
} catch (InterruptedException ex) { |
|
276 |
// Ignore. |
|
277 |
} |
|
278 |
} |
|
279 |
|
|
280 |
private void preloadPythonEngine() { |
|
281 |
ScriptingManager manager = (ScriptingManager) ScriptingLocator.getManager(); |
|
282 |
synchronized (manager) { |
|
283 |
String respath = "/scripting/langs/python/preload.py"; |
|
284 |
InputStream res = this.getClass().getResourceAsStream(respath); |
|
285 |
if( res != null ) { |
|
286 |
logger.info("Scan for script engines"); |
|
287 |
List<String> lines; |
|
288 |
try { |
|
289 |
lines = IOUtils.readLines(res); |
|
290 |
String code = StringUtils.join(lines, "\n"); |
|
291 |
logger.info("Preload python script engine"); |
|
292 |
Script script = manager.createScript( |
|
293 |
"preload", |
|
294 |
code, |
|
295 |
ScriptingManager.PYTHON_LANGUAGE_NAME |
|
296 |
); |
|
297 |
logger.info("Preload python modules"); |
|
298 |
script.invokeFunction("main", null); |
|
299 |
|
|
300 |
} catch (Exception ex) { |
|
301 |
logger.warn("Can't run preload script for python.", ex); |
|
302 |
} |
|
303 |
logger.info("Preload of script engines finished"); |
|
304 |
} |
|
305 |
} |
|
306 |
} |
|
307 |
|
|
308 |
private void addLinkToPreviousVersion(ScriptingManager manager) { |
|
309 |
|
|
310 |
String contents = "[Unit]\n" |
|
311 |
+ "type = Folder\n" |
|
312 |
+ "name = Previous version\n" |
|
313 |
+ "description =\n" |
|
314 |
+ "createdBy =\n" |
|
315 |
+ "version =\n" |
|
316 |
+ "\n" |
|
317 |
+ "[Folder]\n" |
|
318 |
+ "path = ../../org.gvsig.scripting.app.extension/scripts\n\n\n"; |
|
319 |
File previousVersion = new File(manager.getUserFolder().getFile(), "previous_version.inf"); |
|
320 |
if( !previousVersion.exists() ) { |
|
321 |
try { |
|
322 |
FileUtils.writeStringToFile(previousVersion, contents); |
|
323 |
} catch (IOException ex) { |
|
324 |
logger.warn("Can't create ScriptingFolder file in '" + previousVersion.getAbsolutePath() + "'.", ex); |
|
325 |
} |
|
326 |
} |
|
327 |
} |
|
328 |
|
|
329 |
private void initPaths() { |
|
330 |
ScriptingManager manager = ScriptingLocator.getManager(); |
|
331 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
332 |
|
|
333 |
File home = this.getPlugin().getPluginHomeFolder(); |
|
334 |
manager.setHomeFolder(home); |
|
335 |
|
|
336 |
this.addLinkToPreviousVersion(manager); |
|
337 |
|
|
338 |
List<File> pluginsFolders = new ArrayList<>(); |
|
339 |
for( File f : pluginManager.getPluginsFolders() ) { |
|
340 |
pluginsFolders.addAll(Arrays.asList(f.listFiles())); |
|
341 |
} |
|
342 |
|
|
343 |
for( File pluginFolder : pluginsFolders ) { |
|
344 |
File scriptsFolder = new File(pluginFolder, "scripting/scripts"); |
|
345 |
if( scriptsFolder.exists() ) { |
|
346 |
manager.registerSystemFolder(pluginFolder.getName(), scriptsFolder); |
|
347 |
} |
|
348 |
File libFolder = new File(pluginFolder, "scripting/lib"); |
|
349 |
if( libFolder.exists() ) { |
|
350 |
manager.addLibFolder(libFolder); |
|
351 |
} |
|
352 |
} |
|
353 |
manager.setPackagesFolder(pluginManager.getInstallFolder()); |
|
354 |
|
|
355 |
File localAddonRepositoryFolder = new File(manager.getRootUserFolder(), "addons"); |
|
356 |
if( !localAddonRepositoryFolder.exists() ) { |
|
357 |
try { |
|
358 |
FileUtils.forceMkdir(localAddonRepositoryFolder); |
|
359 |
} catch (IOException ex) { |
|
360 |
logger.info("Can't create addons folder in '" + localAddonRepositoryFolder.getAbsolutePath() + "'.", ex); |
|
361 |
} |
|
362 |
} |
|
363 |
File initAddonFile = new File(localAddonRepositoryFolder, "__init__.py"); |
|
364 |
if( !initAddonFile.exists() ) { |
|
365 |
try { |
|
366 |
FileUtils.touch(initAddonFile); |
|
367 |
} catch (IOException ex) { |
|
368 |
logger.info("Can't create addons __init__ file in '" + localAddonRepositoryFolder.getAbsolutePath() + "'.", ex); |
|
369 |
} |
|
370 |
} |
|
371 |
} |
|
372 |
|
|
373 |
@Override |
|
374 |
public void postInitialize() { |
|
375 |
super.postInitialize(); |
|
376 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
377 |
pluginManager.addStartupTask( |
|
378 |
"ExecuteAutorunScripts", |
|
379 |
new ExecuteAutorunScriptsOnStartup(), |
|
380 |
true, |
|
381 |
600 |
|
382 |
); |
|
383 |
|
|
384 |
Invocable initializer = new ScriptsInstallerInitializer(); |
|
385 |
initializer.call(this.getPlugin().getPluginName()); |
|
386 |
} |
|
387 |
|
|
388 |
@Override |
|
389 |
public boolean isEnabled() { |
|
390 |
return true; |
|
391 |
} |
|
392 |
|
|
393 |
@Override |
|
394 |
public boolean isVisible() { |
|
395 |
return true; |
|
396 |
} |
|
397 |
|
|
398 |
private static class ExecuteAutorunScriptsOnStartup implements Runnable { |
|
399 |
|
|
400 |
@Override |
|
401 |
public void run() { |
|
402 |
Thread th = new Thread(new ExecuteAutorunScripts()); |
|
403 |
th.start(); |
|
404 |
} |
|
405 |
} |
|
406 |
|
|
407 |
private static class ExecuteAutorunScripts implements Runnable { |
|
408 |
|
|
409 |
@Override |
|
410 |
public void run() { |
|
411 |
final ScriptingManager manager = ScriptingLocator.getManager(); |
|
412 |
manager.loadEngines(); |
|
413 |
|
|
414 |
final PluginsManager pluginManager = PluginsLocator.getManager(); |
|
415 |
final ApplicationManager application = ApplicationLocator.getManager(); |
|
416 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
417 |
|
|
418 |
final List<ScriptingBaseScript> autoruns = new ArrayList<>(); |
|
419 |
|
|
420 |
try { |
|
421 |
List<File> pluginsFolders = new ArrayList<>(); |
|
422 |
for( File f : pluginManager.getPluginsFolders() ) { |
|
423 |
pluginsFolders.addAll(Arrays.asList(f.listFiles())); |
|
424 |
} |
|
425 |
|
|
426 |
application.message( |
|
427 |
i18nManager.getTranslation("_Searching_autorun_scripts_Xhorizontal_ellipsisX"), |
|
428 |
JOptionPane.INFORMATION_MESSAGE |
|
429 |
); |
|
430 |
for( File pluginFolder : pluginsFolders ) { |
|
431 |
File autorun_file = new File(pluginFolder, "scripting/scripts/autorun.inf"); |
|
432 |
if( autorun_file.exists() ) { |
|
433 |
ScriptingBaseScript autorun = manager.getScript(autorun_file); |
|
434 |
if( autorun.isEnabled() ) { |
|
435 |
autoruns.add(autorun); |
|
436 |
} else { |
|
437 |
logger.info("Skip autorun script '" + autorun_file.getAbsolutePath() + "'."); |
|
438 |
} |
|
439 |
} |
|
440 |
} |
|
441 |
|
|
442 |
SimpleFileVisitor<Path> visitor = new SimpleFileVisitor<Path>() { |
|
443 |
@Override |
|
444 |
public FileVisitResult visitFile(Path path, BasicFileAttributes bfa) throws IOException { |
|
445 |
File file = path.toFile(); |
|
446 |
if( "autorun.inf".equalsIgnoreCase(file.getName()) ) { |
|
447 |
if( file.exists() ) { |
|
448 |
ScriptingBaseScript autorun = manager.getScript(file); |
|
449 |
if( autorun.isEnabled() ) { |
|
450 |
autoruns.add(autorun); |
|
451 |
} else { |
|
452 |
logger.info("Skip autorun script '" + file.getAbsolutePath() + "'."); |
|
453 |
} |
|
454 |
} |
|
455 |
} |
|
456 |
return FileVisitResult.CONTINUE; |
|
457 |
} |
|
458 |
}; |
|
459 |
try { |
|
460 |
EnumSet<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS); |
|
461 |
Files.walkFileTree(Paths.get(manager.getRootUserFolder().toURI()), opts, Integer.MAX_VALUE, visitor); |
|
462 |
List<ScriptingFolder> folders = manager.getAlternativeUserFolders(); |
|
463 |
for( ScriptingFolder folder : folders ) { |
|
464 |
Files.walkFileTree(Paths.get(folder.getFile().toURI()), opts, Integer.MAX_VALUE, visitor); |
|
465 |
} |
|
466 |
} catch (Exception ex) { |
|
467 |
logger.warn("Can't execute autoruns in home.", ex); |
|
468 |
} |
|
469 |
|
|
470 |
Collections.sort(autoruns, new Comparator<ScriptingBaseScript>() { |
|
471 |
|
|
472 |
@Override |
|
473 |
public int compare(ScriptingBaseScript o1, ScriptingBaseScript o2) { |
|
474 |
return getScriptOrderKey(o2).compareToIgnoreCase(getScriptOrderKey(o1)); |
|
475 |
} |
|
476 |
}); |
|
477 |
|
|
478 |
for( ScriptingBaseScript autorun : autoruns ) { |
|
479 |
try { |
|
480 |
logger.info("running autorun script '" + autorun.getFile().getAbsolutePath() + "' (" + getScriptOrderKey(autorun) + ", " + autorun.getIsolationGroup() + ")."); |
|
481 |
application.message( |
|
482 |
i18nManager.getTranslation( |
|
483 |
"_Running_autorun_script_from_XnameX", |
|
484 |
new String[]{ |
|
485 |
autorun.getFile().getParentFile().getName()} |
|
486 |
), |
|
487 |
JOptionPane.INFORMATION_MESSAGE |
|
488 |
); |
|
489 |
} catch (Exception ex) { |
|
490 |
// Ignore it |
|
491 |
} |
|
492 |
try { |
|
493 |
autorun.run(); |
|
494 |
} catch (Exception ex) { |
|
495 |
logger.warn("Can't execute autorun from '" + autorun.getFile().getAbsolutePath() + "'.", ex); |
|
496 |
} |
|
497 |
} |
|
498 |
|
|
499 |
} finally { |
|
500 |
logger.info("Running autorun scripts terminated."); |
|
501 |
application.message("", JOptionPane.INFORMATION_MESSAGE); |
|
502 |
} |
|
503 |
} |
|
504 |
|
|
505 |
private String getScriptOrderKey(ScriptingBaseScript o) { |
|
506 |
int groupOrder = 500; |
|
507 |
String groupName = "default"; |
|
508 |
int scriptOrder = 500; |
|
509 |
String s = o.getProperty("autorun.group.order"); |
|
510 |
if( s != null ) { |
|
511 |
try { |
|
512 |
groupOrder = Integer.parseInt(s); |
|
513 |
} catch (Exception ex) { |
|
514 |
// Do nothing. |
|
515 |
} |
|
516 |
} |
|
517 |
s = o.getProperty("autorun.group.name"); |
|
518 |
if( s != null ) { |
|
519 |
groupName = s; |
|
520 |
} |
|
521 |
s = o.getProperty("autorun.order"); |
|
522 |
if( s != null ) { |
|
523 |
try { |
|
524 |
scriptOrder = Integer.parseInt(s); |
|
525 |
} catch (Exception ex) { |
|
526 |
// Do nothing. |
|
527 |
} |
|
528 |
} |
|
529 |
String key = MessageFormat.format( |
|
530 |
"{0,number,000000}.{1}.{2,number,000000}", |
|
531 |
groupOrder, |
|
532 |
groupName, |
|
533 |
scriptOrder |
|
534 |
); |
|
535 |
return key; |
|
536 |
} |
|
537 |
} |
|
538 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptsInstallerInitializer.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app.extension; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import org.apache.commons.io.FileUtils; |
|
5 |
import org.gvsig.andami.PluginsLocator; |
|
6 |
import org.gvsig.andami.PluginsManager; |
|
7 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
8 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
9 |
import org.gvsig.installer.lib.spi.InstallerProviderLocator; |
|
10 |
import org.gvsig.scripting.ScriptingLocator; |
|
11 |
import org.gvsig.scripting.ScriptingManager; |
|
12 |
import org.gvsig.tools.service.spi.ProviderFactory; |
|
13 |
import org.gvsig.tools.service.spi.ProviderManager; |
|
14 |
import org.gvsig.tools.util.Invocable; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
public class ScriptsInstallerInitializer implements Invocable { |
|
19 |
|
|
20 |
private static final Logger LOG = LoggerFactory.getLogger(ScriptsInstallerInitializer.class); |
|
21 |
|
|
22 |
@Override |
|
23 |
public Object call(Object... args) { |
|
24 |
try { |
|
25 |
String pluginName = (String) args[0]; |
|
26 |
|
|
27 |
ProviderManager providerManager = InstallerProviderLocator.getProviderManager(); |
|
28 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
29 |
ScriptingManager manager = ScriptingLocator.getManager(); |
|
30 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
|
31 |
|
|
32 |
File home = FileUtils.getFile(pluginManager.getApplicationHomeFolder(),"plugins",pluginName); |
|
33 |
|
|
34 |
manager.setHomeFolder(home); |
|
35 |
manager.setPackagesFolder(pluginManager.getInstallFolder()); |
|
36 |
|
|
37 |
File localAddonRepositoryFolder = new File(manager.getRootUserFolder(), "addons"); |
|
38 |
|
|
39 |
ProviderFactory factory = manager.getInstallerFactory(); |
|
40 |
providerManager.addProviderFactory(factory); |
|
41 |
|
|
42 |
installerManager.setDefaultLocalAddonRepository( |
|
43 |
localAddonRepositoryFolder, |
|
44 |
factory.getName() |
|
45 |
); |
|
46 |
|
|
47 |
return true; |
|
48 |
|
|
49 |
} catch (Exception ex) { |
|
50 |
LOG.warn("Problems initializing scripts installer.",ex); |
|
51 |
return false; |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/gvsigsh | ||
---|---|---|
1 |
#!/bin/sh |
|
2 |
|
|
3 |
#set -x |
|
4 |
|
|
5 |
cd $(dirname $0) |
|
6 |
|
|
7 |
if [ -f lib/org.gvsig.andami-2* ] ; then |
|
8 |
GVSIG_HOME=`dirname "$0"` |
|
9 |
else |
|
10 |
if [ -f lib/org.gvsig.scripting.main-* ] ; then |
|
11 |
GVSIG_HOME=`dirname "$0"`/../../.. |
|
12 |
else |
|
13 |
echo "Can't locate gvSIG installation folder" |
|
14 |
exit 1 |
|
15 |
fi |
|
16 |
fi |
|
17 |
|
|
18 |
cd "${GVSIG_HOME}" |
|
19 |
GVSIG_HOME=$PWD |
|
20 |
|
|
21 |
for d in gvSIG/extensiones/org.gvsig.app/lib \ |
|
22 |
gvSIG/extensiones/org.gvsig.scripting.app.extension/lib \ |
|
23 |
gvSIG/extensiones/org.gvsig.geometry.app.generalpath/lib \ |
|
24 |
gvSIG/extensiones/org.gvsig.projection.app.proj4j/lib \ |
|
25 |
gvSIG/extensiones/org.gvsig.projection.app.jcrs/lib ; |
|
26 |
do |
|
27 |
for i in $d/*.jar ; do |
|
28 |
LIBRARIES="$LIBRARIES:$i" |
|
29 |
done |
|
30 |
for i in $d/*.zip ; do |
|
31 |
LIBRARIES="$LIBRARIES:$i" |
|
32 |
done |
|
33 |
done |
|
34 |
|
|
35 |
GVSIG_LAUNCHER=org.gvsig.scripting.main.Main |
|
36 |
GVSIG_CLASSPATH="$LIBRARIES" |
|
37 |
GVSIG_PARAMS=" --plugins-folder=gvSIG/extensiones $@" |
|
38 |
. ./gvSIG.sh |
|
39 |
|
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/plugin-persistence.def | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<!-- |
|
3 |
Definitions of plugin persistence org.gvsig.scripting.app.mainplugin. |
|
4 |
--> |
|
5 |
<definitions> |
|
6 |
<version>1.0.0</version> |
|
7 |
<classes> |
|
8 |
<class name="org.gvsig.scripting.app.mainplugin"> |
|
9 |
<description>Persistence of scripting plugin</description> |
|
10 |
<fields> |
|
11 |
<field name="ComposerUseHisWindowManager" type="boolean" mandatory="true" defaultValue="true"> |
|
12 |
<description>When true the composer use his window manager instead of the gvSIG Window manager.</description> |
|
13 |
</field> |
|
14 |
</fields> |
|
15 |
</class> |
|
16 |
</classes> |
|
17 |
</definitions> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
1 |
_Scripting=Scripting |
|
2 |
_Show_scripting_launcher=Abrir lanzador de scripts |
|
3 |
_Show_scripting_composer=Abrir editor de scripts |
|
4 |
_Show_scripting_jython_console=Abrir consola Jython |
|
5 |
|
|
6 |
User=Usuario |
|
7 |
System=Sistema |
|
8 |
|
|
9 |
Accept=Aceptar |
|
10 |
Cancel=Cancelar |
|
11 |
Apply=Aplicar |
|
12 |
|
|
13 |
Retrieving_data=Recibiendo datos... |
|
14 |
|
|
15 |
File=Fichero |
|
16 |
New=Nuevo |
|
17 |
Close_document=Cerrar documento |
|
18 |
Close_all_documents=Cerrar todos los documentos |
|
19 |
Run=Ejecutar |
|
20 |
Save=Guardar |
|
21 |
Close=Cerrar |
|
22 |
Close_current_tab=Cerrar pesta\u00f1a actual |
|
23 |
Open_edition_mode=Abrir modo edici\u00f3n |
|
24 |
Run_selected_script=Ejecutar script seleccionado |
|
25 |
Delete_selected_script=Borrar script seleccionado |
|
26 |
Refresh_directories=Actualizar carpetas |
|
27 |
Move_files=Mover ficheros |
|
28 |
Set_file_preferences=Editar preferencias de fichero |
|
29 |
|
|
30 |
|
|
31 |
Edit=Editar |
|
32 |
Cut=Cortar |
|
33 |
Copy=Copiar |
|
34 |
Paste=Pegar |
|
35 |
Select_all=Seleccionar todo |
|
36 |
|
|
37 |
Tools=Herramientas |
|
38 |
Launcher=Lanzador de scripts |
|
39 |
Scripting_Launcher=Lanzador de scripts |
|
40 |
Scripting_Composer=Editor de scripts |
|
41 |
Jython_Console=Consola Jython |
|
42 |
Import_JavaDoc=Importar JavaDoc |
|
43 |
JavaDoc=Ayuda de Java (JavaDoc) |
|
44 |
Remove_JavaDoc=Eliminar JavaDoc |
|
45 |
Help_contents=Contenido de la ayuda |
|
46 |
About_scripts_editor=Acerca del editor de scripts |
|
47 |
Get_help=Ayuda |
|
48 |
Help=Ayuda |
|
49 |
_Package_script=Empaquetar script... |
|
50 |
_Package_help=Empaquetar ayuda... |
|
51 |
|
|
52 |
Problems=Errores |
|
53 |
Console=Consola |
|
54 |
|
|
55 |
Description=Descripci\u00f3n |
|
56 |
Resource=Recurso |
|
57 |
Location=Ubicaci\u00f3n |
|
58 |
|
|
59 |
no_line=sin l\u00ednea |
|
60 |
Line=L\u00ednea |
|
61 |
|
|
62 |
Welcome_message=Bienvenido al entorno de scripting |
|
63 |
|
|
64 |
Error_opening_in_edition_mode_title=Error al abrir fichero |
|
65 |
Error_opening_in_edition_mode=No se pudo abrir el fichero en modo edici\u00f3n |
|
66 |
|
|
67 |
New_Script=Nuevo elemento |
|
68 |
New_Script_Description=Crea un nuevo script, di\u00e1logo, proyecto, directorio |
|
69 |
|
|
70 |
Deleting_JavaDocs_successfully_title=Operaci\u00f3n realizada con \u00e9xito |
|
71 |
Deleting_JavaDocs_successfully=Eliminaci\u00f3n de los JavaDocs exitosa |
|
72 |
|
|
73 |
Import_JavaDoc_title=Importar JavaDocs desde los directorios de sistema al ScriptingFramework JavaDoc |
|
74 |
Remove_JavaDoc_title=Eliminar JavaDocs del ScriptingFramework JavaDoc |
|
75 |
|
|
76 |
projects_modified_title=Proyectos sin guardar |
|
77 |
projects_modified=Algunos proyectos han sido modificados.\u00bfSalvar cambios? |
|
78 |
project_modified=ha sido modificado.\u00bfSalvar cambios? |
|
79 |
|
|
80 |
Delete_all_title=Borrar el documento |
|
81 |
Delete_all_message=Esta acci\u00f3n elimina el documento o el directorio con todo su contenido. \u00bf Desea continuar ? |
|
82 |
|
|
83 |
About_us_title=Informaci\u00f3n de todos los contribuidores al proyecto gvSIG |
|
84 |
|
|
85 |
Success=Operaci\u00f3n realizada con \u00e9xito |
|
86 |
Error=Error |
|
87 |
Error_renaming=Inesperado error renombrando el fichero |
|
88 |
Error_moving=Inesperado error moviendo el fichero |
|
89 |
Error_help=Selecciona una ayuda |
|
90 |
Rename_succesfully=Renombrado del fichero realizado con \u00e9xito |
|
91 |
Select_first=Debe seleccionar un fichero primero |
|
92 |
help_key=No hay ayuda para el texto |
|
93 |
|
|
94 |
|
|
95 |
script_filesystem=script en el \u00e1rbol de directorio |
|
96 |
Move=Mover |
|
97 |
move_desc=Cambia la ubicaci\u00f3n del fichero seleccionado |
|
98 |
Rename=Renombrar |
|
99 |
rename_desc=Cambia el nombre y otras propiedades del fichero seleccionado |
|
100 |
Moving_succesfully=Reubicaci\u00f3n del fichero realizado con \u00e9xito |
|
101 |
|
|
102 |
Dialog=Di\u00e1logo |
|
103 |
Code=C\u00f3digo |
|
104 |
Properties=Propiedades |
|
105 |
|
|
106 |
current_name=Nombre actual |
|
107 |
new_name=Nuevo name |
|
108 |
rename_name_title=Cambiar el nombre del fichero |
|
109 |
more_properties=M\u00e1s propiedades |
|
110 |
|
|
111 |
Javadoc_remove=Selecciona el JavaDoc a eliminar |
|
112 |
no_Javadoc_remove=No hay JavaDoc para eliminar |
|
113 |
|
|
114 |
Name=Nombre |
|
115 |
Version=Versi\u00f3n |
|
116 |
Created_by=Creado por |
|
117 |
Description=Descripci\u00f3n |
|
118 |
Type=Tipo |
|
119 |
Language=Lenguaje |
|
120 |
Author=Autor |
|
121 |
Move_from=Mover desde |
|
122 |
Move_to=Destino |
|
123 |
Browse=Abrir |
|
124 |
Import_from=Importar desde |
|
125 |
|
|
126 |
Name_blank=El nombre no puede estar en blanco |
|
127 |
Name_exists=Este nombre ya existe. Debe elegir otro |
|
128 |
Import_success=Los JavaDocs se han importado satisfactoriamente |
|
129 |
JavaDoc_Error=Selecciona JavaDoc a importar |
|
130 |
|
|
131 |
go_to_line_Xhorizontal_ellipsisX=Ir a la l\u00ednea\u2026 |
|
132 |
find_Xhorizontal_ellipsisX=Buscar\u2026 |
|
133 |
replace_Xhorizontal_ellipsisX=Reemplazar\u2026 |
|
134 |
_Searching_autorun_scripts_Xhorizontal_ellipsisX=Buscando scripts de autoarranque... |
|
135 |
_Running_autorun_script_from_XnameX=Ejecutando script de autoarranque desde "{0}" |
|
136 |
_The_script_XscriptnameX_is_modified=El script "{0}" ha sido modificado. |
|
137 |
_Save_changes_XquestionX=\u00bf Guardar cambios ? |
|
138 |
_Do_you_want_to_save_changes_XquestionX=\u00bf Desea guardar los cambios ? |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
1 |
_Scripting=Scripting |
|
2 |
_Show_scripting_launcher=Show scripting launcher |
|
3 |
_Show_scripting_composer=Show scripting composer |
|
4 |
_Show_scripting_jython_console=Show Jython console |
|
5 |
|
|
6 |
User=User |
|
7 |
System=System |
|
8 |
|
|
9 |
Accept=Accept |
|
10 |
Cancel=Cancel |
|
11 |
Apply=Apply |
|
12 |
|
|
13 |
Retrieving_data=Retrieving data... |
|
14 |
|
|
15 |
File=File |
|
16 |
New=New |
|
17 |
Close_document=Close document |
|
18 |
Close_all_documents=Cloase all documents |
|
19 |
Run=Run |
|
20 |
Save=Save |
|
21 |
Close=Close |
|
22 |
Close_current_tab=Close current tab |
|
23 |
Open_edition_mode=Open edition mode |
|
24 |
Run_selected_script=Run selected script |
|
25 |
Delete_selected_script=Delete selected script |
|
26 |
Refresh_directories=Refresh directories |
|
27 |
Move_files=Move files |
|
28 |
Set_file_preferences=Set file preferences |
|
29 |
_Running_autorun_script_from_XnameX=Running autorun script from {0} |
|
30 |
|
|
31 |
Edit=Edit |
|
32 |
Cut=Cut |
|
33 |
Copy=Copy |
|
34 |
Paste=Paste |
|
35 |
Select_all=Select all |
|
36 |
|
|
37 |
Tools=Tools |
|
38 |
Launcher=Scripting Launcher |
|
39 |
Scripting_Launcher=Scripting Launcher |
|
40 |
Scripting_Composer=Scripting Composer |
|
41 |
Jython_Console=Jython console |
|
42 |
Import_JavaDoc=Import JavaDoc |
|
43 |
JavaDoc=Java Help (JavaDoc) |
|
44 |
Remove_JavaDoc=Remove JavaDoc |
|
45 |
Help_contents=Help contents |
|
46 |
About_scripts_editor=About scripts editor |
|
47 |
Get_help=Help |
|
48 |
Help=Help |
|
49 |
_Package_script=Package script... |
|
50 |
_Package_help=Package help... |
|
51 |
|
|
52 |
Problems=Errors |
|
53 |
Console=Console |
|
54 |
|
|
55 |
Description=Description |
|
56 |
Resource=Resource |
|
57 |
Location=Location |
|
58 |
|
|
59 |
no_line=no line |
|
60 |
Line=Line |
|
61 |
|
|
62 |
Welcome_message=Welcome to the scripting framework |
|
63 |
|
|
64 |
Error_opening_in_edition_mode_title=Error opening file in edition mode |
|
65 |
Error_opening_in_edition_mode=The file can't be opened in edition mode |
|
66 |
|
|
67 |
New_Script=New element |
|
68 |
New_Script_Description=Create a new script, dialog, project, directory |
|
69 |
|
|
70 |
Deleting_JavaDocs_successfully_title=Operation successful |
|
71 |
Deleting_JavaDocs_successfully=Deleting JavaDocs successfully |
|
72 |
|
|
73 |
Import_JavaDoc_title=Import JavaDocs from filesystem to ScriptingFramework JavaDoc |
|
74 |
Remove_JavaDoc_title=Remove JavaDocs from ScriptingFramework JavaDoc |
|
75 |
|
|
76 |
projects_modified_title=Projects without saving |
|
77 |
projects_modified=Some projects have been modified. Save changes? |
|
78 |
project_modified=has been modified. Save changes? |
|
79 |
|
|
80 |
Delete_all_title=Delete document |
|
81 |
Delete_all_message=This action removes the document or directory with all its content. Do you wish to continue ? |
|
82 |
|
|
83 |
About_us_title=Information about all the gvSIG's contributors |
|
84 |
|
|
85 |
Success=Operation done successfully |
|
86 |
Error=Error |
|
87 |
Error_renaming=Unexpected error renaming the file |
|
88 |
Error_moving=Unexpected error moving the file |
|
89 |
Error_help=Select help |
|
90 |
Rename_succesfully=Renaming successfully |
|
91 |
Select_first=Select a file first |
|
92 |
help_key=There isn't any help to this text |
|
93 |
|
|
94 |
|
|
95 |
script_filesystem=script filesystem |
|
96 |
Move=Move |
|
97 |
move_desc=Change location of selected file |
|
98 |
Rename=Rename |
|
99 |
rename_desc=Change the name and more properties of the selected file |
|
100 |
Moving_succesfully=File moved succesfully |
|
101 |
|
|
102 |
Dialog=Dialog |
|
103 |
Code=Code |
|
104 |
Properties=Properties |
|
105 |
|
|
106 |
current_name=Current name |
|
107 |
new_name=New name |
|
108 |
rename_name_title=Change filename |
|
109 |
more_properties=more properties |
|
110 |
|
|
111 |
Javadoc_remove=Choose JavaDoc to delete |
|
112 |
no_Javadoc_remove=There's no JavaDoc to delete |
|
113 |
|
|
114 |
Name=Name |
|
115 |
Version=Version |
|
116 |
Created_by=Create by |
|
117 |
Description=Description |
|
118 |
Type=Type |
|
119 |
Language=Language |
|
120 |
Author=Author |
|
121 |
Move_from=Move from |
|
122 |
Move_to=Move to |
|
123 |
Browse=Browse |
|
124 |
Import_from=Import from |
|
125 |
|
|
126 |
Name_blank=Name can't be blank |
|
127 |
Name_exists=This name already exists. Choose another one |
|
128 |
Import_success=JavaDocs imported successfully |
|
129 |
JavaDoc_Error=Select JavaDoc to import |
|
130 |
|
|
131 |
|
|
132 |
go_to_line_Xhorizontal_ellipsisX=Go To Line\u2026 |
|
133 |
find_Xhorizontal_ellipsisX=Find\u2026 |
|
134 |
replace_Xhorizontal_ellipsisX=Replace\u2026 |
|
135 |
|
|
136 |
_Searching_autorun_scripts_Xhorizontal_ellipsisX=Searching autorun scripts... |
|
137 |
_Running_autorun_script_from_XnameX=Running autorun script from "{0}" |
|
138 |
_The_script_XscriptnameX_is_modified=The script "{0}" has been modified. |
|
139 |
_Save_changes_XquestionX=Save changes ? |
|
140 |
_Do_you_want_to_save_changes_XquestionX=Do you want to save changes ? |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.46/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/License_Chalkwork_icons.txt | ||
---|---|---|
1 |
---------------------------------------------- |
|
2 |
CHALKWORK BASIC |
|
3 |
by Dave Shea |
|
4 |
mezzoblue.com/icons/chalkwork/basic |
|
5 |
---------------------------------------------- |
|
6 |
CHALKWORK COMMERCE |
|
7 |
by Dave Shea |
|
8 |
mezzoblue.com/icons/chalkwork/commerce |
|
9 |
---------------------------------------------- |
|
10 |
CHALKWORK EDITING CONTROLS |
|
11 |
by Dave Shea |
|
12 |
mezzoblue.com/icons/chalkwork/editing-controls |
|
13 |
---------------------------------------------- |
|
14 |
CHALKWORK INFORMATION MANAGEMENT |
|
15 |
by Dave Shea |
|
16 |
mezzoblue.com/icons/chalkwork/information-management |
|
17 |
---------------------------------------------- |
Also available in: Unified diff