Revision 1225
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<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"> |
|
3 |
|
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.scripting.lib</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.91</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<modules> |
|
15 |
<module>org.gvsig.scripting.lib.api</module> |
|
16 |
<module>org.gvsig.scripting.lib.impl</module> |
|
17 |
</modules> |
|
18 |
</project> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/resources/org/gvsig/scripting/impl/scripts/hola.py | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
def main(): |
|
4 |
print 'hola' |
|
5 |
|
|
6 |
def hola(name): |
|
7 |
return 'hola %s' % name |
|
8 |
|
|
9 |
def adios(): |
|
10 |
print 'adios' |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/resources/org/gvsig/scripting/impl/scripts/hola2.dlg | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<!-- generated by ThinG, the Thinlet GUI editor --> |
|
3 |
<panel> |
|
4 |
<button text="hola" action="click"/> |
|
5 |
</panel> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/resources/org/gvsig/scripting/impl/scripts/hola2.py | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
def click(): |
|
4 |
print 'click' |
|
5 |
|
|
6 |
def main(): |
|
7 |
print 'hola' |
|
8 |
|
|
9 |
def hola(name): |
|
10 |
return 'hola %s' % name |
|
11 |
|
|
12 |
def adios(): |
|
13 |
print 'adios' |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/resources/README.txt | ||
---|---|---|
1 |
#set( $symbol_pound = '#' ) |
|
2 |
#set( $symbol_dollar = '$' ) |
|
3 |
#set( $symbol_escape = '\' ) |
|
4 |
Put into this folder the resources needed by your test classes. |
|
5 |
|
|
6 |
This folder is added to the Tests classpath, so you can load any resources |
|
7 |
through the ClassLoader. |
|
8 |
|
|
9 |
By default, in this folder you can find an example of log4j configuration, |
|
10 |
prepared to log messages through the console, so logging works when you |
|
11 |
run your tests classes. |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
DefaultExampleManager class. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.scripting.impl.DefaultExampleManager"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
|
|
26 |
<!-- |
|
27 |
By default, show only logging messages of INFO level or higher, |
|
28 |
through the previously configured CONSOLE appender. |
|
29 |
--> |
|
30 |
<root> |
|
31 |
<priority value="INFO" /> |
|
32 |
<appender-ref ref="CONSOLE" /> |
|
33 |
</root> |
|
34 |
</log4j:configuration> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/java/README.txt | ||
---|---|---|
1 |
#set( $symbol_pound = '#' ) |
|
2 |
#set( $symbol_dollar = '$' ) |
|
3 |
#set( $symbol_escape = '\' ) |
|
4 |
For each class you are going to test, create one Test class with the same |
|
5 |
name as the class to test, ending with Test. |
|
6 |
|
|
7 |
For example, the unit tests of the "ExampleLibrary" class are performed |
|
8 |
by the "ExampleLibraryTest" class. |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/javadoc/overview.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.scripting package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>TODO: Example library overview.</p> |
|
11 |
|
|
12 |
<p>See the <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#overviewcomment">Javadoc Tool documentation about the overview file</a></p> |
|
13 |
|
|
14 |
</body> |
|
15 |
</html> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.scripting.impl.ScriptingDefaultImplLibrary |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/org/gvsig/scripting/apihelp/api.hs | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' ?> |
|
2 |
<!DOCTYPE helpset |
|
3 |
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN" |
|
4 |
"http://java.sun.com/products/javahelp/helpset_1_0.dtd"> |
|
5 |
|
|
6 |
<?TestTarget this is data for the test target ?> |
|
7 |
|
|
8 |
<helpset version="1.0"> |
|
9 |
|
|
10 |
<!-- title --> |
|
11 |
<title>ScriptingFramework API</title> |
|
12 |
|
|
13 |
<!-- maps --> |
|
14 |
<maps> |
|
15 |
<homeID>main</homeID> |
|
16 |
<mapref location="api.jhm"/> |
|
17 |
</maps> |
|
18 |
|
|
19 |
<!-- views --> |
|
20 |
<view> |
|
21 |
<name>TOC</name> |
|
22 |
<label>TOC</label> |
|
23 |
<type>javax.help.TOCView</type> |
|
24 |
<data>toc.xml</data> |
|
25 |
</view> |
|
26 |
|
|
27 |
<view> <name>Index</name> |
|
28 |
<label>Indice</label> |
|
29 |
<type>javax.help.IndexView</type> |
|
30 |
<data>index.xml</data> |
|
31 |
</view> |
|
32 |
|
|
33 |
<view> |
|
34 |
<name>Search</name> |
|
35 |
<label>Busqueda</label> |
|
36 |
<type>javax.help.SearchView</type> |
|
37 |
</view> |
|
38 |
|
|
39 |
|
|
40 |
<view> |
|
41 |
<name>Favorites</name> |
|
42 |
<label>Favoritos</label> |
|
43 |
<type>javax.help.FavoritesView</type> |
|
44 |
</view> |
|
45 |
|
|
46 |
<presentation default="true" displayviewimages="false"> |
|
47 |
<name>main window</name> |
|
48 |
<size width="700" height="400" /> |
|
49 |
<location x="200" y="200" /> |
|
50 |
<title>gvSIG - Ayuda en linea</title> |
|
51 |
<image>toplevelfolder</image> |
|
52 |
<toolbar> |
|
53 |
<helpaction image="action.back">javax.help.BackAction</helpaction> |
|
54 |
<helpaction image="action.forward">javax.help.ForwardAction</helpaction> |
|
55 |
<helpaction image="homeIcon">javax.help.HomeAction</helpaction> |
|
56 |
<helpaction image="reloadIcon">javax.help.ReloadAction</helpaction> |
|
57 |
<helpaction image="addBookmarkIcon">javax.help.FavoritesAction</helpaction> |
|
58 |
</toolbar> |
|
59 |
</presentation> |
|
60 |
</helpset> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/org/gvsig/scripting/apihelp/toc.xml | ||
---|---|---|
1 |
<!DOCTYPE toc |
|
2 |
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 1.0//EN" |
|
3 |
"http://java.sun.com/products/javahelp/toc_1_0.dtd"> |
|
4 |
|
|
5 |
<toc version="1.0"> |
|
6 |
|
|
7 |
</toc> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/org/gvsig/scripting/apihelp/api.jhm | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' ?> |
|
2 |
<!DOCTYPE map |
|
3 |
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN" |
|
4 |
"http://java.sun.com/products/javahelp/map_1_0.dtd"> |
|
5 |
|
|
6 |
<map version="1.0"> |
|
7 |
</map> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/org/gvsig/scripting/apihelp/index.xml | ||
---|---|---|
1 |
<!DOCTYPE index |
|
2 |
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Index Version 1.0//EN" |
|
3 |
"http://java.sun.com/products/javahelp/index_1_0.dtd"> |
|
4 |
<index version="1.0"> |
|
5 |
</index> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/org/gvsig/scripting/langs/python/init.txt | ||
---|---|---|
1 |
|
|
2 |
__file__ = script.getResource(script.getId()+".py").getAbsolutePath() |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/org/gvsig/scripting/langs/python/new_template.txt | ||
---|---|---|
1 |
# encoding: utf-8 |
|
2 |
|
|
3 |
import gvsig |
|
4 |
|
|
5 |
def main(*args): |
|
6 |
|
|
7 |
#Remove this lines and add here your code |
|
8 |
|
|
9 |
print "hola mundo" |
|
10 |
pass |
|
11 |
|
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/org/gvsig/scripting/langs/r/new_template.txt | ||
---|---|---|
1 |
|
|
2 |
main <- function() { |
|
3 |
|
|
4 |
cat( "Hello\n" ); |
|
5 |
|
|
6 |
} |
|
7 |
|
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/org/gvsig/scripting/langs/scala/new_template.txt | ||
---|---|---|
1 |
|
|
2 |
import java.lang.Runnable |
|
3 |
|
|
4 |
new Runnable() { |
|
5 |
def run() { |
|
6 |
println("Hello, World!") |
|
7 |
} |
|
8 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/org/gvsig/scripting/langs/groovy/new_template.txt | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
def main() { |
|
4 |
|
|
5 |
printf "hola\n" |
|
6 |
|
|
7 |
} |
|
8 |
|
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/org/gvsig/scripting/langs/ecmascript/new_template.txt | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
function main() { |
|
5 |
|
|
6 |
print("hola\n"); |
|
7 |
|
|
8 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/thing/generate.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<!-- jEdit settings: :tabSize=4:indentSize=4:noTabs=true:folding=explicit:collapseFolds=1: --> |
|
3 |
|
|
4 |
<panel columns="1" |
|
5 |
bottom="12" left="12" right="12" top="12" gap="12" |
|
6 |
init="init(cbGenerateInterface, cbGenerateHandler, cbGenerateAsThinlet, cbGenerateMain, tInterfaceName, tHandlerName, tPackageName, tOutputDir, tPreview, bOk)" |
|
7 |
weightx="1" weighty="1" |
|
8 |
> |
|
9 |
<panel border="true" bottom="6" columns="3" font=" bold" gap="6" left="6" right="6" text="Generate" top="6" weightx="1"> |
|
10 |
<checkbox action="checkboxChanged(this)" mnemonic="0" name="cbGenerateInterface" text="Interface for Handler class" weightx="1"/> |
|
11 |
<label for="tInterfaceName" mnemonic="1" text="Interface Name:"/> |
|
12 |
<textfield perform="textfieldChanged(this)" name="tInterfaceName" weightx="4"/> |
|
13 |
<checkbox action="checkboxChanged(this)" mnemonic="0" name="cbGenerateHandler" selected="true" text="Handler class" weightx="1"/> |
|
14 |
<label for="tHandlerName" mnemonic="1" text="Class Name:"/> |
|
15 |
<textfield perform="textfieldChanged(this)" name="tHandlerName" weightx="4"/> |
|
16 |
<panel/> |
|
17 |
<label for="tPackageName" mnemonic="0" text="Package Name:"/> |
|
18 |
<textfield perform="textfieldChanged(this)" name="tPackageName" weightx="4"/> |
|
19 |
<panel colspan="3" gap="6" weightx="1"> |
|
20 |
<label for="tOutputDir" mnemonic="7" text="Output Directory:"/> |
|
21 |
<textfield name="tOutputDir" weightx="1"/> |
|
22 |
<button action="buttonOutputDirClicked()" text="..." tooltip="Select Output Directory"/> |
|
23 |
</panel> |
|
24 |
</panel> |
|
25 |
<panel border="true" bottom="6" columns="1" font=" bold" gap="6" left="6" right="6" text="Handler Options" top="6"> |
|
26 |
<checkbox action="checkboxChanged(this)" mnemonic="13" name="cbGenerateAsThinlet" text="Handler is a Thinlet"/> |
|
27 |
<checkbox action="checkboxChanged(this)" mnemonic="9" name="cbGenerateMain" text="Generate main()"/> |
|
28 |
</panel> |
|
29 |
<panel border="true" bottom="6" font=" bold" gap="6" left="6" right="6" text="Preview" top="6" weightx="1" weighty="1"> |
|
30 |
<textarea editable="false" font="Monospaced 11" name="tPreview" weightx="1" weighty="1"/> |
|
31 |
</panel> |
|
32 |
<panel gap="6" halign="right" weightx="1"> |
|
33 |
<button action="ok()" icon="icons/ok.gif" mnemonic="0" name="bOk" text="Ok" valign="bottom" weighty="1"/> |
|
34 |
<button action="close()" icon="icons/cancel.gif" mnemonic="0" name="bCancel" text="Cancel" type="cancel" valign="bottom" weighty="1"/> |
|
35 |
</panel> |
|
36 |
</panel> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/thing/settings.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<!-- jEdit settings: :tabSize=4:indentSize=4:noTabs=true:folding=explicit:collapseFolds=1: --> |
|
3 |
|
|
4 |
<panel border="true" bottom="12" columns="2" gap="20" left="12" right="12" top="12" weightx="1" weighty="1"> |
|
5 |
<label icon="icons/thing.gif" rowspan="3" valign="top"/> |
|
6 |
<panel border="true" bottom="6" font="bold" gap="6" left="6" right="6" text="Icons" top="6"> |
|
7 |
<label for="tIconpath" mnemonic="0" text="Icon Path:"/> |
|
8 |
<textfield name="tIconpath" weightx="1"/> |
|
9 |
<button action="chooseDir(tIconpath, tIconpath.text)" name="bChoose" text="..." tooltip="Choose directory"/> |
|
10 |
</panel> |
|
11 |
<panel border="true" bottom="6" columns="3" font="bold" gap="6" left="6" right="6" text="XML Output" top="6" weightx="1" weighty="1"> |
|
12 |
<label for="rbIndentSpace" mnemonic="1" text="Indent Char:"/> |
|
13 |
<checkbox group="indentChar" halign="left" name="rbIndentSpace" selected="true" text="Space"/> |
|
14 |
<checkbox group="indentChar" halign="left" name="rbIndentTab" text="Tab"/> |
|
15 |
<label for="spIndentSize" mnemonic="7" text="Indent Size:"/> |
|
16 |
<spinbox colspan="2" end="1" halign="left" maximum="100" minimum="1" name="spIndentSize" start="1" text="4"/> |
|
17 |
<label for="tCustomHeader" mnemonic="7" text="Custom Header:" valign="top"/> |
|
18 |
<textarea colspan="3" height="80" name="tCustomHeader" weightx="1" weighty="1" width="300"/> |
|
19 |
</panel> |
|
20 |
<panel gap="6" halign="right" weightx="1"> |
|
21 |
<button action="ok(tIconpath.text, spIndentSize.text, rbIndentSpace.selected, rbIndentTab.selected, tCustomHeader.text)" icon="icons/ok.gif" mnemonic="0" name="bOk" text="Ok" valign="bottom" weighty="1"/> |
|
22 |
<button action="close()" icon="icons/cancel.gif" mnemonic="0" name="bCancel" text="Cancel" type="cancel" valign="bottom" weighty="1"/> |
|
23 |
</panel> |
|
24 |
</panel> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/thing/version.properties | ||
---|---|---|
1 |
# ThinG version number |
|
2 |
version=0.1 |
|
3 |
|
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/thing/generator.properties | ||
---|---|---|
1 |
# jEdit settings: |
|
2 |
# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: |
|
3 |
# |
|
4 |
# Templates for the ThinG Generator. |
|
5 |
# |
|
6 |
# Important: |
|
7 |
# When changing any of the templates, please keep in mind: |
|
8 |
# - leading whitespace must be enclosed in quotes '...' |
|
9 |
# - brackets '{' and '}' must be enclosed in quotes unless they denote a parameter |
|
10 |
# - end-of-lines are always denoted with '\n'. The generator may change this |
|
11 |
# into the OS specific line separator such as '\r\n' on Windows or '\r' on Mac. |
|
12 |
|
|
13 |
|
|
14 |
# 0: current date (java.util.Date instance) |
|
15 |
file.header.firstline=\ |
|
16 |
// Generated by ThinG on {0,date} {0,time}.\n\ |
|
17 |
\n |
|
18 |
|
|
19 |
|
|
20 |
# 0: "<package-spec>", e.g. "foo.bar.baz" |
|
21 |
file.header.package=\ |
|
22 |
package {0};\n\ |
|
23 |
\n |
|
24 |
|
|
25 |
|
|
26 |
# 0: additional import statement, e.g. "import thinlet.FrameLauncher;" or "" |
|
27 |
# 1: JavaDoc comment |
|
28 |
file.header=\ |
|
29 |
import thinlet.Thinlet;\n\ |
|
30 |
{0}\ |
|
31 |
\n\ |
|
32 |
\n\ |
|
33 |
/**\n\ |
|
34 |
' '* {1}\n\ |
|
35 |
' '*/\n |
|
36 |
|
|
37 |
|
|
38 |
file.footer=\ |
|
39 |
'}'\n |
|
40 |
|
|
41 |
|
|
42 |
# 0: "<classname>" |
|
43 |
# 1: "[ extends Thinlet]" |
|
44 |
# 2: "[ implements <interfacename>]" |
|
45 |
handler.signature=\ |
|
46 |
public class {0}{1}{2}\n\ |
|
47 |
'{'\n |
|
48 |
|
|
49 |
|
|
50 |
# 0: "<interfacename>" |
|
51 |
interface.signature=\ |
|
52 |
public interface {0}\n\ |
|
53 |
'{'\n |
|
54 |
|
|
55 |
|
|
56 |
# 0: "<classname>" |
|
57 |
# 1: "<thinlet-filename>" |
|
58 |
class.asThinlet.constructor=\ |
|
59 |
\n\ |
|
60 |
' '/**\n\ |
|
61 |
' '* Create a new {0} instance.\n\ |
|
62 |
' '*/\n\ |
|
63 |
' 'public {0}() throws java.io.IOException\n\ |
|
64 |
' {'\n\ |
|
65 |
' 'add(parse("{1}"));\n\ |
|
66 |
' }'\n\ |
|
67 |
\n |
|
68 |
|
|
69 |
|
|
70 |
# 0: JavaDoc comment for the method. |
|
71 |
method.javadoc.header=\ |
|
72 |
\n\ |
|
73 |
' '/**\n\ |
|
74 |
' '* {0}\n |
|
75 |
|
|
76 |
|
|
77 |
method.javadoc.param.intro=\ |
|
78 |
' '*\n |
|
79 |
|
|
80 |
|
|
81 |
# 1: "<parameter-name>" |
|
82 |
# 2: JavaDoc comment for the parameter |
|
83 |
method.javadoc.param=\ |
|
84 |
' '* @param {0} {1}\n |
|
85 |
|
|
86 |
|
|
87 |
method.javadoc.footer=\ |
|
88 |
' '*/\n |
|
89 |
|
|
90 |
|
|
91 |
# 0: full method signature, e.g. "mymethod(String param1, int param2)" |
|
92 |
method.body.interface=\ |
|
93 |
' 'public void {0};\n\ |
|
94 |
\n |
|
95 |
|
|
96 |
|
|
97 |
# 0: full method signature, e.g. "mymethod(String param1, int param2)" |
|
98 |
method.body.handler=\ |
|
99 |
' 'public void {0}\n\ |
|
100 |
' {'\n\ |
|
101 |
' }'\n\ |
|
102 |
\n |
|
103 |
|
|
104 |
|
|
105 |
# 0: "<classname>" |
|
106 |
main.asThinlet=\ |
|
107 |
\n\ |
|
108 |
' '/**\n\ |
|
109 |
' '* Show a test frame with the Thinlet contents.\n\ |
|
110 |
' '*\n\ |
|
111 |
' '* @param args ignored.\n\ |
|
112 |
' '*/\n\ |
|
113 |
' 'public static void main(String[] args) throws java.io.IOException\n\ |
|
114 |
' {'\n\ |
|
115 |
' 'new FrameLauncher("{0}", new {0}(), 400, 400);\n\ |
|
116 |
' }'\n\ |
|
117 |
\n |
|
118 |
|
|
119 |
|
|
120 |
# 0: "<classname>" |
|
121 |
# 1: "<thinlet-filename>" |
|
122 |
main.notAsThinlet=\ |
|
123 |
\n\ |
|
124 |
' '/**\n\ |
|
125 |
' '* Show a test frame with the Thinlet contents.\n\ |
|
126 |
' '*\n\ |
|
127 |
' '* @param args ignored.\n\ |
|
128 |
' '*/\n\ |
|
129 |
' 'public static void main(String[] args) throws java.io.IOException\n\ |
|
130 |
' {'\n\ |
|
131 |
' 'class MyThinlet extends Thinlet\n\ |
|
132 |
' {'\n\ |
|
133 |
' 'public MyThinlet() throws java.io.IOException\n\ |
|
134 |
' {'\n\ |
|
135 |
' 'add(parse("{1}", new {0}()));\n\ |
|
136 |
' }'\n\ |
|
137 |
' };'\n\ |
|
138 |
' 'new FrameLauncher("{0}", new MyThinlet(), 400, 400);\n\ |
|
139 |
' }'\n\ |
|
140 |
\n |
|
141 |
|
|
142 |
|
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/thing/componentchooser.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<!-- jEdit settings: :tabSize=4:indentSize=4:noTabs=true:folding=explicit:collapseFolds=1: --> |
|
3 |
|
|
4 |
<panel bottom="12" columns="1" left="12" right="12" top="12" weightx="1" weighty="1"> |
|
5 |
<list colspan="2" name="list" line="false" weightx="1" weighty="1" action="selectionChanged(this, lSelected)" perform="close()"/> |
|
6 |
<panel gap="6" top="12" weightx="1"> |
|
7 |
<label text="Selected:"/> |
|
8 |
<label name="lSelected" text="null"/> |
|
9 |
<panel weightx="1"/> |
|
10 |
<button name="bOk" text="Ok" icon="icons/ok.gif" mnemonic="0" type="default" action="ok()"/> |
|
11 |
<button name="bCancel" text="Cancel" icon="icons/cancel.gif" mnemonic="0" type="cancel" action="close()"/> |
|
12 |
</panel> |
|
13 |
</panel> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/thing/thing.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<!-- jEdit settings: :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: --> |
|
3 |
|
|
4 |
<panel columns="1" gap="4"> |
|
5 |
|
|
6 |
<menubar weightx="1"> |
|
7 |
<menu text="File" mnemonic="0"> |
|
8 |
<menuitem text="New" mnemonic="0" icon="icons/empty_menu.gif" accelerator="ctrl N" action="menu_file_new()"/> |
|
9 |
<menuitem text="Open..." mnemonic="0" icon="icons/empty_menu.gif" accelerator="ctrl O" action="menu_file_open()"/> |
|
10 |
<separator/> |
|
11 |
<menuitem text="Reload" mnemonic="0" icon="icons/empty_menu.gif" accelerator="ctrl R" action="menu_file_reload()"/> |
|
12 |
<separator/> |
|
13 |
<menuitem text="Save" mnemonic="0" icon="icons/empty_menu.gif" accelerator="ctrl S" action="menu_file_save()"/> |
|
14 |
<menuitem text="Save As..." mnemonic="5" icon="icons/empty_menu.gif" action="menu_file_save_as()"/> |
|
15 |
<separator/> |
|
16 |
<menuitem text="Exit" mnemonic="0" icon="icons/empty_menu.gif" accelerator="alt F4" action="menu_file_exit()"/> |
|
17 |
</menu> |
|
18 |
<menu text="Edit" mnemonic="0"> |
|
19 |
<menuitem text="Cut" name="menu_edit_cut" mnemonic="0" accelerator="ctrl X" icon="icons/edit_cut.gif" action="menu_edit_cut()"/> |
|
20 |
<menuitem text="Copy" name="menu_edit_copy" mnemonic="1" accelerator="ctrl C" icon="icons/edit_copy.gif" action="menu_edit_copy()"/> |
|
21 |
<menuitem text="Paste" name="menu_edit_paste" mnemonic="0" accelerator="ctrl V" icon="icons/edit_paste.gif" action="menu_edit_paste()"/> |
|
22 |
<menuitem text="Paste from system clipboard" name="menu_edit_paste_systemcb" mnemonic="1" accelerator="ctrl shift V" icon="icons/empty_menu.gif" action="menu_edit_paste_systemcb()"/> |
|
23 |
<menuitem text="Delete" name="menu_edit_delete" mnemonic="0" icon="icons/edit_delete.gif" action="menu_edit_delete()"/> |
|
24 |
<separator/> |
|
25 |
<menuitem text="Settings..." mnemonic="0" icon="icons/empty_menu.gif" action="menu_edit_settings()"/> |
|
26 |
</menu> |
|
27 |
<menu text="Tools" mnemonic="0"> |
|
28 |
<menuitem text="Generate Handler Stub Source..." name="menu_tools_generate" mnemonic="0" accelerator="ctrl G" icon="icons/empty_menu.gif" action="menu_tools_generate()"/> |
|
29 |
</menu> |
|
30 |
<menu text="Help" mnemonic="0"> |
|
31 |
<menuitem text="About Thing..." mnemonic="0" icon="icons/thing_small.gif" action="menu_help_about()"/> |
|
32 |
</menu> |
|
33 |
</menubar> |
|
34 |
|
|
35 |
<panel name="toolbar" weightx="1" gap="-1"> |
|
36 |
|
|
37 |
<!-- top level components --> |
|
38 |
<button name="tb_add_panel" property="classname=panel" icon="icons/panel.gif" tooltip="Create new panel" action="addComponent(this)"/> |
|
39 |
<button name="tb_add_dialog" property="classname=dialog" icon="icons/dialog.gif" tooltip="Create new dialog" action="addComponent(this)"/> |
|
40 |
<button name="tb_add_desktop" property="classname=desktop" icon="icons/desktop.gif" tooltip="Create new desktop" action="addComponent(this)"/> |
|
41 |
<button name="tb_add_splitpane" property="classname=splitpane" icon="icons/splitpane.gif" tooltip="Create new splitpane" action="addComponent(this)"/> |
|
42 |
<button name="tb_add_tabbedpane" property="classname=tabbedpane" icon="icons/tabbedpane.gif" tooltip="Create new tabbedpane" action="addComponent(this)"/> |
|
43 |
|
|
44 |
<!-- menu components --> |
|
45 |
<button name="tb_add_menubar" property="classname=menubar" icon="icons/menubar.gif" tooltip="Create new menubar" action="addComponent(this)"/> |
|
46 |
<button name="tb_add_menu" property="classname=menu" icon="icons/menu.gif" tooltip="Create new menu" action="addComponent(this)"/> |
|
47 |
<button name="tb_add_menuitem" property="classname=menuitem" icon="icons/menuitem.gif" tooltip="Create new menuitem" action="addComponent(this)"/> |
|
48 |
<button name="tb_add_checkboxmenuitem" property="classname=checkboxmenuitem" icon="icons/checkboxmenuitem.gif" tooltip="Create new checkboxmenuitem" action="addComponent(this)"/> |
|
49 |
|
|
50 |
<!-- components --> |
|
51 |
<button name="tb_add_label" property="classname=label" icon="icons/label.gif" tooltip="Create new label" action="addComponent(this)"/> |
|
52 |
<button name="tb_add_button" property="classname=button" icon="icons/button.gif" tooltip="Create new button" action="addComponent(this)"/> |
|
53 |
<button name="tb_add_togglebutton" property="classname=togglebutton" icon="icons/togglebutton.gif" tooltip="Create new togglebutton" action="addComponent(this)"/> |
|
54 |
<button name="tb_add_checkbox" property="classname=checkbox" icon="icons/checkbox.gif" tooltip="Create new checkbox" action="addComponent(this)"/> |
|
55 |
<button name="tb_add_textfield" property="classname=textfield" icon="icons/textfield.gif" tooltip="Create new textfield" action="addComponent(this)"/> |
|
56 |
<button name="tb_add_combobox" property="classname=combobox" icon="icons/combobox.gif" tooltip="Create new combobox" action="addComponent(this)"/> |
|
57 |
<button name="tb_add_passwordfield" property="classname=passwordfield" icon="icons/passwordfield.gif" tooltip="Create new passwordfield" action="addComponent(this)"/> |
|
58 |
<button name="tb_add_spinbox" property="classname=spinbox" icon="icons/spinbox.gif" tooltip="Create new spinbox" action="addComponent(this)"/> |
|
59 |
<button name="tb_add_progressbar" property="classname=progressbar" icon="icons/progressbar.gif" tooltip="Create new progressbar" action="addComponent(this)"/> |
|
60 |
<button name="tb_add_slider" property="classname=slider" icon="icons/slider.gif" tooltip="Create new slider" action="addComponent(this)"/> |
|
61 |
<button name="tb_add_separator" property="classname=separator" icon="icons/separator.gif" tooltip="Create new separator" action="addComponent(this)"/> |
|
62 |
<button name="tb_add_list" property="classname=list" icon="icons/list.gif" tooltip="Create new list" action="addComponent(this)"/> |
|
63 |
<button name="tb_add_table" property="classname=table" icon="icons/table.gif" tooltip="Create new table" action="addComponent(this)"/> |
|
64 |
<button name="tb_add_textarea" property="classname=textarea" icon="icons/textarea.gif" tooltip="Create new textarea" action="addComponent(this)"/> |
|
65 |
<button name="tb_add_tree" property="classname=tree" icon="icons/tree.gif" tooltip="Create new tree" action="addComponent(this)"/> |
|
66 |
|
|
67 |
<!-- list items --> |
|
68 |
<button name="tb_add_choice" property="classname=choice" icon="icons/choice.gif" tooltip="Create new choice" action="addComponent(this)"/> |
|
69 |
<button name="tb_add_item" property="classname=item" icon="icons/item.gif" tooltip="Create new item" action="addComponent(this)"/> |
|
70 |
<button name="tb_add_node" property="classname=node" icon="icons/node.gif" tooltip="Create new node" action="addComponent(this)"/> |
|
71 |
<button name="tb_add_tab" property="classname=tab" icon="icons/tab.gif" tooltip="Create new tab" action="addComponent(this)"/> |
|
72 |
|
|
73 |
<!-- table components --> |
|
74 |
<button name="tb_add_row" property="classname=row" icon="icons/row.gif" tooltip="Create new row" action="addComponent(this)"/> |
|
75 |
<button name="tb_add_cell" property="classname=cell" icon="icons/cell.gif" tooltip="Create new cell" action="addComponent(this)"/> |
|
76 |
<button name="tb_add_header" property="classname=header" icon="icons/header.gif" tooltip="Create new header" action="addComponent(this)"/> |
|
77 |
<button name="tb_add_column" property="classname=column" icon="icons/column.gif" tooltip="Create new column" action="addComponent(this)"/> |
|
78 |
|
|
79 |
<!-- other --> |
|
80 |
<button name="tb_add_popupmenu" property="classname=popupmenu" icon="icons/popupmenu.gif" tooltip="Create new popupmenu" action="addComponent(this)"/> |
|
81 |
|
|
82 |
<!-- later --> |
|
83 |
<!-- |
|
84 |
<button name="tb_add_bean" property="classname=bean" icon="icons/bean.gif" tooltip="Create new bean" action="addComponent(this)" enabled="false"/> |
|
85 |
--> |
|
86 |
|
|
87 |
<!-- placeholder in case there are no buttons add all --> |
|
88 |
<separator height="30" width="1"/> |
|
89 |
</panel> |
|
90 |
|
|
91 |
<!-- main workarea --> |
|
92 |
<panel left="4" right="4" weightx="1" weighty="1"> |
|
93 |
<splitpane orientation="horizontal" divider="200" weightx="1" weighty="1"> |
|
94 |
|
|
95 |
<!-- left splitpane: component tree and properties table --> |
|
96 |
<splitpane orientation="vertical"> |
|
97 |
<panel columns="1" weightx="1" weighty="1"> |
|
98 |
<tree name="tree" angle="true" line="false" selection="single" weightx="1" weighty="1" action="treeSelectionChanged()"/> |
|
99 |
<panel top="3" bottom="3" gap="2" scrollable="true"> |
|
100 |
<button name="tb_edit_copy" icon="icons/edit_copy.gif" tooltip="Copy selected component to internal ThinG clipboard and system clipboard" action="menu_edit_copy()"/> |
|
101 |
<button name="tb_edit_cut" icon="icons/edit_cut.gif" tooltip="Cut selected component to internal ThinG clipboard and system clipboard" action="menu_edit_cut()"/> |
|
102 |
<button name="tb_edit_paste" icon="icons/edit_paste.gif" tooltip="Paste component from internal ThinG clipboard below selected component" action="menu_edit_paste()"/> |
|
103 |
<button name="tb_edit_delete" icon="icons/edit_delete.gif" tooltip="Remove selected component" action="menu_edit_delete()"/> |
|
104 |
<separator/> |
|
105 |
<button name="tb_edit_moveup" icon="icons/edit_moveup.gif" tooltip="Move selected component up" action="moveComponentUp()"/> |
|
106 |
<button name="tb_edit_movedown" icon="icons/edit_movedown.gif" tooltip="Move selected component down" action="moveComponentDown()"/> |
|
107 |
</panel> |
|
108 |
</panel> |
|
109 |
<panel columns="1" gap="5"> |
|
110 |
<table name="props" selection="single" weightx="1" weighty="1" action="tableSelectionChanged()"> |
|
111 |
<header> |
|
112 |
<column name="props_key" text="Property" width="80" sort="ascent"/> |
|
113 |
<column name="props_value" text="Value"/> |
|
114 |
</header> |
|
115 |
</table> |
|
116 |
<panel name="propedit" columns="3" gap="5" weightx="1" border="true" top="5" left="5" bottom="5" right="5"> |
|
117 |
<label name="propedit_name" text=""/> |
|
118 |
<panel name="propedit_panel" gap="5" weightx="1"/> |
|
119 |
<button name="propedit_reset" text="Reset" tooltip="Reset to default value" font="10" valign="center" enabled="false" action="propEditReset()"/> |
|
120 |
</panel> |
|
121 |
</panel> |
|
122 |
</splitpane> |
|
123 |
|
|
124 |
<!-- right splitpane: preview panel --> |
|
125 |
<tabbedpane name="tabs" placement="top" selected="1" action="tabSelected(this.selected)"> |
|
126 |
<!-- Attention: because of an obscure bug in Thinlet.getNextFocusable(), --> |
|
127 |
<!-- the tab "XML" must be the first one! If it is not the first panel, Thinlet --> |
|
128 |
<!-- runs into an endless loop when the user navigates from the "Preview" tab --> |
|
129 |
<!-- to the "XML" tab, trying to set the next focusable component. --> |
|
130 |
<tab text="XML" mnemonic="0"> |
|
131 |
<panel weightx="1" weighty="1"> |
|
132 |
<textarea name="serialize" editable="false" weightx="1" weighty="1"/> |
|
133 |
</panel> |
|
134 |
</tab> |
|
135 |
<tab text="Preview" mnemonic="0"> |
|
136 |
<panel name="preview" border="true" scrollable="true" weightx="1" weighty="1"/> |
|
137 |
</tab> |
|
138 |
</tabbedpane> |
|
139 |
|
|
140 |
</splitpane> |
|
141 |
</panel> |
|
142 |
|
|
143 |
<!-- status bar at bottom --> |
|
144 |
<textfield name="statusbar" editable="false" text="ThinG" weightx="1"/> |
|
145 |
|
|
146 |
</panel> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your library classes. |
|
2 |
|
|
3 |
This folder is added to the runtime classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, into this folder you can find some examples of resource bundle |
|
7 |
property files that may be used by your library classes. |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/java/org/gvsig/scripting/Main.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
|
|
4 |
public interface Main { |
|
5 |
public Object main(Object args[]); |
|
6 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/java/org/gvsig/scripting/impl/DefaultScriptingDialog.java | ||
---|---|---|
1 |
package org.gvsig.scripting.impl; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
import java.io.BufferedWriter; |
|
6 |
import java.io.File; |
|
7 |
import java.io.FileWriter; |
|
8 |
import java.io.IOException; |
|
9 |
import java.io.Writer; |
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.List; |
|
12 |
|
|
13 |
import org.apache.commons.io.FileUtils; |
|
14 |
import org.gvsig.scripting.ExecuteErrorException; |
|
15 |
import org.gvsig.scripting.ScriptingDialog; |
|
16 |
import org.gvsig.scripting.ScriptingFolder; |
|
17 |
import org.gvsig.scripting.ScriptingManager; |
|
18 |
import org.gvsig.scripting.swing.api.JThinlet; |
|
19 |
import org.gvsig.scripting.swing.api.ScriptingSwingLocator; |
|
20 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
|
21 |
import org.ini4j.Ini; |
|
22 |
import org.slf4j.Logger; |
|
23 |
import org.slf4j.LoggerFactory; |
|
24 |
|
|
25 |
public class DefaultScriptingDialog extends DefaultScriptingScript implements ScriptingDialog, ActionListener { |
|
26 |
|
|
27 |
private static final Logger logger = LoggerFactory.getLogger(DefaultScriptingDialog.class); |
|
28 |
private int showMode; |
|
29 |
|
|
30 |
public DefaultScriptingDialog(ScriptingFolder parent, ScriptingManager manager, String id) { |
|
31 |
super(parent, ScriptingManager.UNIT_DIALOG, manager, id); |
|
32 |
this.setMainName("onload"); |
|
33 |
this.showMode = MODE_WINDOW; |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public void runAsTask(Object[] args) { |
|
38 |
// Los dialogos no se ejecutan en otro hilo. |
|
39 |
this.run(args); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public Object run(Object args[]) { |
|
44 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
45 |
|
|
46 |
JThinlet thinlet = uimanager.createJThinlet(); |
|
47 |
thinlet.addActionListener(this); |
|
48 |
thinlet.load(this.getFileResource(".dlg")); |
|
49 |
|
|
50 |
this.put("dialog", thinlet.getThinlet()); |
|
51 |
|
|
52 |
this.compile(); |
|
53 |
try { |
|
54 |
this.invokeFunction(this.getMainName(), args); |
|
55 |
} catch (ExecuteErrorException ex) { |
|
56 |
Throwable e = ex.getCause(); |
|
57 |
if (e instanceof NoSuchMethodException) { |
|
58 |
// When running from the composer messages of stdout shows in the console tab. |
|
59 |
System.out.println("Code of dialog do not has function '" + this.getMainName() + "'."); |
|
60 |
} else { |
|
61 |
throw ex; |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
switch (this.getShowMode()) { |
|
66 |
case MODE_WINDOW: |
|
67 |
// When running from the composer messages of stdout shows in the console tab. |
|
68 |
System.out.println("Showing dialog as window " + this.getName() + "."); |
|
69 |
uimanager.showWindow(thinlet, this.getName()); |
|
70 |
break; |
|
71 |
case MODE_TOOL: |
|
72 |
// When running from the composer messages of stdout shows in the console tab. |
|
73 |
System.out.println("Showing dialog as tool " + this.getName() + "."); |
|
74 |
uimanager.showTool(thinlet, this.getName()); |
|
75 |
break; |
|
76 |
default: |
|
77 |
// When running from the composer messages of stdout shows in the console tab. |
|
78 |
System.out.println("Showing dialog as dialog " + this.getName() + "."); |
|
79 |
uimanager.showDialog(thinlet, this.getName()); |
|
80 |
break; |
|
81 |
} |
|
82 |
return null; |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
protected void loadInf(Ini prefs) { |
|
87 |
super.loadInf(prefs); |
|
88 |
this.showMode = Integer.parseInt(getInfValue(prefs, "Dialog", "showMode", MODE_WINDOW).toString()); |
|
89 |
} |
|
90 |
|
|
91 |
@Override |
|
92 |
protected void save(Ini prefs) { |
|
93 |
super.save(prefs); |
|
94 |
prefs.put("Dialog", "showMode", this.showMode); |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public String[] getIconNames() { |
|
99 |
return new String[]{ |
|
100 |
"scripting-icon-dialog", |
|
101 |
"scripting-icon-dialog" |
|
102 |
}; |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
public void actionPerformed(ActionEvent arg0) { |
|
107 |
try { |
|
108 |
this.invokeFunction(arg0.getActionCommand(), null); |
|
109 |
} catch (Throwable e) { |
|
110 |
// Ignore, invokeFunction handle error it self. |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
|
115 |
public File getDialogFile() { |
|
116 |
return this.getFileResource(".dlg"); |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public List<File> getFiles() { |
|
121 |
List<File> l = new ArrayList<>(); |
|
122 |
l.add(this.getResource(".dlg")); |
|
123 |
l.add(this.getResource(this.getExtension())); |
|
124 |
return l; |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public int getShowMode() { |
|
129 |
return this.showMode; |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public void setShowMode(int mode) { |
|
134 |
this.showMode = mode; |
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public boolean remove() { |
|
139 |
boolean r = super.remove(); |
|
140 |
File folder = this.getParent().getFile(); |
|
141 |
File f = new File(folder, this.getId() + ".dlg"); |
|
142 |
try { |
|
143 |
FileUtils.forceDelete(f); |
|
144 |
} catch (IOException e) { |
|
145 |
logger.warn("Can't remove dialog file '" + f.getAbsolutePath() + "'.", e); |
|
146 |
r = false; |
|
147 |
} |
|
148 |
return r; |
|
149 |
} |
|
150 |
|
|
151 |
@Override |
|
152 |
public void create(ScriptingFolder folder, String id, String language) { |
|
153 |
super.create(folder, id, language); |
|
154 |
|
|
155 |
File fileDlg = this.getResource(this.getId() + ".dlg"); |
|
156 |
try { |
|
157 |
fileDlg.createNewFile(); |
|
158 |
} catch (IOException e) { |
|
159 |
logger.warn("Can't create the dialog in '" + fileDlg.getAbsolutePath() + "'.", e); |
|
160 |
} |
|
161 |
|
|
162 |
// Escribimos en el fichero '.dlg' lo mi?nimo para que pueda ejecutarse |
|
163 |
Writer output; |
|
164 |
try { |
|
165 |
output = new BufferedWriter(new FileWriter(fileDlg)); |
|
166 |
output.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<panel/>"); |
|
167 |
output.close(); |
|
168 |
} catch (IOException e) { |
|
169 |
logger.warn("Can't write xml code of the dialog to '" + fileDlg.getAbsolutePath() + "'.", e); |
|
170 |
} |
|
171 |
|
|
172 |
this.save(); |
|
173 |
} |
|
174 |
|
|
175 |
@Override |
|
176 |
public String getMimeType() { |
|
177 |
return "text"; |
|
178 |
} |
|
179 |
|
|
180 |
@Override |
|
181 |
public boolean move(ScriptingFolder target) { |
|
182 |
File dlgfile = this.getFileResource(".dlg"); |
|
183 |
if( !super.move(target) ) { |
|
184 |
return false; |
|
185 |
} |
|
186 |
try { |
|
187 |
FileUtils.moveFileToDirectory(dlgfile, target.getFile(),true); |
|
188 |
} catch (IOException ex) { |
|
189 |
logger.info("Can't move script '"+this.getId()+"' to '"+target.getFile().getAbsolutePath()+"', "+ex.getMessage(),ex); |
|
190 |
return false; |
|
191 |
} |
|
192 |
return true; |
|
193 |
} |
|
194 |
|
|
195 |
@Override |
|
196 |
public boolean rename(String newId) { |
|
197 |
File dlgfile = this.getFileResource(".dlg"); |
|
198 |
if( !super.rename(newId) ) { |
|
199 |
return false; |
|
200 |
} |
|
201 |
try { |
|
202 |
ScriptingFolder target = this.getParent(); |
|
203 |
FileUtils.moveFile(dlgfile, new File(target.getFile(),newId+".dlg")); |
|
204 |
} catch (IOException ex) { |
|
205 |
logger.info("Can't rename script '"+this.getId()+"' to '"+newId+"', "+ex.getMessage(),ex); |
|
206 |
return false; |
|
207 |
} |
|
208 |
return true; |
|
209 |
|
|
210 |
} |
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/java/org/gvsig/scripting/impl/AbstractScript.java | ||
---|---|---|
1 |
package org.gvsig.scripting.impl; |
|
2 |
|
|
3 |
import org.apache.commons.lang3.BooleanUtils; |
|
4 |
import org.apache.commons.lang3.StringUtils; |
|
5 |
import org.gvsig.scripting.ScriptingBaseScript; |
|
6 |
import org.gvsig.scripting.ScriptingFolder; |
|
7 |
import org.gvsig.scripting.ScriptingManager; |
|
8 |
import org.ini4j.Ini; |
|
9 |
|
|
10 |
public abstract class AbstractScript extends AbstractUnit implements ScriptingBaseScript{ |
|
11 |
protected boolean enabled; |
|
12 |
protected String isolationGroup; |
|
13 |
|
|
14 |
public AbstractScript(ScriptingFolder parent, String typename, ScriptingManager manager, String id) { |
|
15 |
super(parent, typename, manager, id); |
|
16 |
this.enabled = true; |
|
17 |
this.isolationGroup = null; |
|
18 |
} |
|
19 |
|
|
20 |
@Override |
|
21 |
public boolean isEnabled() { |
|
22 |
return this.enabled; |
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
public void setEnabled(boolean enabled) { |
|
27 |
firePropertyChangeListener("enabled", enabled, this.enabled); |
|
28 |
this.enabled = enabled; |
|
29 |
} |
|
30 |
|
|
31 |
|
|
32 |
@Override |
|
33 |
public String getIsolationGroup() { |
|
34 |
return this.isolationGroup; |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public void setIsolationGroup(String group) { |
|
39 |
firePropertyChangeListener("isolationGroup", group, this.isolationGroup); |
|
40 |
this.isolationGroup = group; |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected void save(Ini prefs){ |
|
45 |
prefs.put("Script", "enable", BooleanUtils.toStringTrueFalse(this.enabled)); |
|
46 |
prefs.put("Script", "isolationGroup", this.isolationGroup); |
|
47 |
super.save(prefs); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
protected void loadInf(Ini prefs){ |
|
52 |
super.loadInf(prefs); |
|
53 |
this.enabled = this.getInfBoolean(prefs,"Script","enable", true); |
|
54 |
this.isolationGroup = this.getInfString(prefs,"Script","isolationGroup", null); |
|
55 |
if( StringUtils.isEmpty(this.isolationGroup) ) { |
|
56 |
this.isolationGroup = null; |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
|
|
61 |
public void registerDataFolder(String id) { |
|
62 |
this.getManager().registerDataFolder(this.getParent(), id); |
|
63 |
} |
|
64 |
|
|
65 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/java/org/gvsig/scripting/impl/MutableURLClassLoader.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.scripting.impl; |
|
3 |
|
|
4 |
import java.io.File; |
|
5 |
import java.io.IOException; |
|
6 |
import java.io.InputStream; |
|
7 |
import java.net.URL; |
|
8 |
import java.net.URLClassLoader; |
|
9 |
import java.util.ArrayList; |
|
10 |
import java.util.Arrays; |
|
11 |
import java.util.Enumeration; |
|
12 |
import java.util.List; |
|
13 |
import org.apache.commons.lang3.StringUtils; |
|
14 |
import org.slf4j.Logger; |
|
15 |
import org.slf4j.LoggerFactory; |
|
16 |
|
|
17 |
|
|
18 |
public class MutableURLClassLoader extends URLClassLoader { |
|
19 |
protected static final Logger logger = LoggerFactory.getLogger(MutableURLClassLoader.class); |
|
20 |
|
|
21 |
public MutableURLClassLoader(List<URL> urls, ClassLoader parent) { |
|
22 |
super(urls.toArray(new URL[urls.size()]),parent); |
|
23 |
} |
|
24 |
|
|
25 |
public void addUrls(List<URL> urls) { |
|
26 |
List<URL> currentsURLs = new ArrayList<>(); |
|
27 |
currentsURLs.addAll(Arrays.asList(this.getURLs())); |
|
28 |
|
|
29 |
for (URL url : urls) { |
|
30 |
if( ! currentsURLs.contains(url) ) { |
|
31 |
this.addURL(url); |
|
32 |
currentsURLs.add(url); |
|
33 |
} |
|
34 |
} |
|
35 |
} |
|
36 |
|
|
37 |
public boolean needRecompile(String name, URL url) { |
|
38 |
if( url!=null && name.endsWith("$py.class") ) { |
|
39 |
if( StringUtils.equalsIgnoreCase(url.getProtocol(),"file") ) { |
|
40 |
String path = url.getPath(); |
|
41 |
File binary = new File(path); |
|
42 |
File source = new File(StringUtils.left(path, path.length()-9)+".py"); |
|
43 |
if( !binary.exists() || org.apache.commons.io.FileUtils.isFileNewer(source, binary) ) { |
|
44 |
return true; |
|
45 |
} |
|
46 |
} |
|
47 |
} |
|
48 |
return false; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public URL getResource(String name) { |
|
53 |
// Para acceder a esto desde python |
|
54 |
// import sys |
|
55 |
// print sys.getClassLoader().getResource("pylint/utils$py.class") |
|
56 |
|
|
57 |
URL x = super.getResource(name); |
|
58 |
if( needRecompile(name, x) ) { |
|
59 |
logger.trace("getResoure("+name+") -> null (need recompile)."); |
|
60 |
return null; |
|
61 |
} |
|
62 |
logger.trace("getResoure("+name+") -> "+x); |
|
63 |
return x; |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public InputStream getResourceAsStream(String name) { |
|
68 |
URL url = super.getResource(name); |
|
69 |
if( needRecompile(name, url) ) { |
|
70 |
logger.trace("getResourceAsStream("+name+") -> null (need recompile)."); |
|
71 |
return null; |
|
72 |
} |
|
73 |
InputStream x = super.getResourceAsStream(name); |
|
74 |
logger.trace("getResourceAsStream("+name+") -> "+(x==null? "null":"(stream)")); |
|
75 |
return x; |
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
public Enumeration<URL> getResources(String name) throws IOException { |
|
80 |
Enumeration<URL> urls = super.getResources(name); |
|
81 |
logger.info("getResources("+name+") -> "+(urls==null? "null":urls)); |
|
82 |
return urls; |
|
83 |
} |
|
84 |
|
|
85 |
public String getResourcePath(String name) { |
|
86 |
if( name.startsWith("__pyclasspath__/") ) { |
|
87 |
name = name.substring(16); |
|
88 |
} |
|
89 |
URL url = this.getResource(name); |
|
90 |
if( url == null ) { |
|
91 |
return name; |
|
92 |
} |
|
93 |
File f = org.apache.commons.io.FileUtils.toFile(url); |
|
94 |
return f.getAbsolutePath(); |
|
95 |
} |
|
96 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/java/org/gvsig/scripting/impl/ScriptingInstallerProvider.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.impl; |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
import java.io.IOException; |
|
27 |
import java.io.InputStream; |
|
28 |
import java.util.Iterator; |
|
29 |
import org.apache.commons.io.FileUtils; |
|
30 |
|
|
31 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
32 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
|
33 |
import org.gvsig.installer.lib.spi.InstallPackageProviderServices; |
|
34 |
import org.gvsig.installer.lib.spi.InstallerProviderLocator; |
|
35 |
import org.gvsig.installer.lib.spi.InstallerProviderManager; |
|
36 |
import org.gvsig.installer.lib.spi.execution.InstallPackageProvider; |
|
37 |
import org.gvsig.scripting.ScriptingLocator; |
|
38 |
import org.gvsig.scripting.ScriptingManager; |
|
39 |
import org.gvsig.tools.service.spi.AbstractProvider; |
|
40 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
41 |
|
|
42 |
public class ScriptingInstallerProvider extends AbstractProvider |
|
43 |
implements InstallPackageProvider { |
|
44 |
|
|
45 |
public ScriptingInstallerProvider(ProviderServices providerServices) { |
|
46 |
super(providerServices); |
|
47 |
} |
|
48 |
|
|
49 |
public void install(File applicationDirectory, InputStream inputStream, |
|
50 |
PackageInfo packageInfo) throws InstallPackageServiceException { |
|
51 |
|
|
52 |
ScriptingManager scriptingManager = ScriptingLocator.getManager(); |
|
53 |
|
|
54 |
File target = scriptingManager.getRootUserFolder(); |
|
55 |
target = new File(target,"addons"); |
|
56 |
|
|
57 |
try { |
|
58 |
if( ! target.exists() ) { |
|
59 |
FileUtils.forceMkdir(target); |
|
60 |
} |
|
61 |
InstallerProviderManager installerProviderManager = |
|
62 |
InstallerProviderLocator.getProviderManager(); |
|
63 |
InstallPackageProviderServices installerProviderServices = |
|
64 |
installerProviderManager.createInstallerProviderServices(); |
|
65 |
|
|
66 |
installerProviderServices.decompress(inputStream, target); |
|
67 |
|
|
68 |
// Ajustamos las fechas de modificacion de los ficheros de forma que |
|
69 |
// los fuentes sean mas nuevos que los binarios. |
|
70 |
// Esto forzara que se recompilen la primera vez que se ejecuten. |
|
71 |
// Si no hacemos esto y las fecha de los binarios son futuras, aunque |
|
72 |
// se editen y cambien los fuentes nunca se reccompilaran. |
|
73 |
Iterator<File> it = FileUtils.iterateFiles(target, new String[] {"class"}, true); |
|
74 |
while( it.hasNext() ) { |
|
75 |
File f = it.next(); |
|
76 |
try { |
|
77 |
FileUtils.touch(f); |
|
78 |
} catch (IOException e) { |
|
79 |
// Do nothing |
|
80 |
} |
|
81 |
} |
|
82 |
it = FileUtils.iterateFiles(target, new String[] {"py","r","scala","groovy"}, true); |
|
83 |
while( it.hasNext() ) { |
|
84 |
File f = it.next(); |
|
85 |
try { |
|
86 |
FileUtils.touch(f); |
|
87 |
} catch (IOException e) { |
|
88 |
// Do nothing |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
} catch (Exception e) { |
|
93 |
throw new InstallPackageServiceException(e); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
public void installLater(File applicationDirectory, |
|
98 |
InputStream inputStream, PackageInfo packageInfo) |
|
99 |
throws InstallPackageServiceException, IOException { |
|
100 |
// TODO Auto-generated method stub |
|
101 |
|
|
102 |
} |
|
103 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.91/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/java/org/gvsig/scripting/impl/DefaultScriptingScript.java | ||
---|---|---|
1 |
package org.gvsig.scripting.impl; |
|
2 |
|
|
3 |
import groovy.lang.GroovyClassLoader; |
|
4 |
import groovy.util.GroovyScriptEngine; |
|
5 |
import java.io.File; |
|
6 |
import java.io.IOException; |
|
7 |
import java.io.InputStream; |
|
8 |
import java.io.PrintStream; |
|
9 |
import java.io.Writer; |
|
10 |
import java.net.URL; |
|
11 |
import java.nio.charset.Charset; |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.Arrays; |
|
14 |
import java.util.HashSet; |
|
15 |
import java.util.LinkedHashSet; |
|
16 |
import java.util.List; |
|
17 |
import java.util.Set; |
|
18 |
|
|
19 |
import javax.script.Compilable; |
|
20 |
import javax.script.CompiledScript; |
|
21 |
import javax.script.Invocable; |
|
22 |
import javax.script.ScriptEngine; |
|
23 |
import javax.script.ScriptException; |
|
24 |
import org.apache.commons.io.Charsets; |
|
25 |
|
|
26 |
import org.apache.commons.io.FileUtils; |
|
27 |
import org.apache.commons.io.FilenameUtils; |
|
28 |
import org.apache.commons.io.IOUtils; |
|
29 |
import org.apache.commons.lang3.StringUtils; |
|
30 |
import org.apache.commons.lang3.exception.ExceptionUtils; |
|
31 |
import org.gvsig.scripting.CompileErrorException; |
|
32 |
import org.gvsig.scripting.ExecuteErrorException; |
|
33 |
import org.gvsig.scripting.Main; |
|
34 |
import org.gvsig.scripting.ScriptingBaseScript; |
|
35 |
import org.gvsig.scripting.ScriptingFolder; |
|
36 |
import org.gvsig.scripting.ScriptingManager; |
|
37 |
import org.gvsig.scripting.ScriptingScript; |
|
38 |
import org.gvsig.scripting.ScriptingUnit; |
|
39 |
import org.gvsig.tools.dispose.Disposable; |
|
40 |
import org.gvsig.tools.observer.Observer; |
|
41 |
import org.gvsig.tools.observer.impl.DelegateWeakReferencingObservable; |
|
42 |
import org.gvsig.tools.task.AbstractMonitorableTask; |
|
43 |
import org.ini4j.Ini; |
|
44 |
import org.python.core.Py; |
|
45 |
import org.python.core.PyException; |
|
46 |
import org.python.core.PyString; |
|
47 |
import org.python.core.PySystemState; |
|
48 |
import org.python.core.PyTraceback; |
|
49 |
import org.python.core.imp; |
|
50 |
import org.python.jsr223.MyPyScriptEngine; |
|
51 |
import org.slf4j.Logger; |
|
52 |
import org.slf4j.LoggerFactory; |
|
53 |
|
|
54 |
@SuppressWarnings({"EqualsAndHashcode", "UseSpecificCatch"}) |
|
55 |
public class DefaultScriptingScript extends AbstractScript implements |
|
56 |
ScriptingScript { |
|
57 |
|
|
58 |
@SuppressWarnings("FieldNameHidesFieldInSuperclass") |
|
59 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultScriptingScript.class); |
|
60 |
protected String langName; |
|
61 |
protected String extension = null; |
|
62 |
protected String librarySuffix = null; |
|
63 |
protected ScriptEngine engine = null; |
|
64 |
protected CompiledScript compiledCode; |
|
65 |
protected boolean useSysPath; |
|
66 |
|
|
67 |
private String code = null; |
|
68 |
private String mainName = "main"; |
|
69 |
private final DelegateWeakReferencingObservable delegatedObservable; |
|
70 |
private OutputWriter stdout; |
|
71 |
private OutputWriter stderr; |
|
72 |
|
|
73 |
public static class OutputWriter extends Writer { |
|
74 |
|
|
75 |
private final Set<Writer> writers = new HashSet<>(); |
|
76 |
private final PrintStream out; |
|
77 |
|
|
78 |
private OutputWriter(PrintStream out) { |
|
79 |
this.out = out; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public void write(char[] cbuf, int off, int len) throws IOException { |
|
84 |
try { |
|
85 |
byte[] buf = new String(cbuf).getBytes(Charset.forName("UTF-8")); |
|
86 |
out.write(buf, off, len); |
|
87 |
} catch (Exception ex) { |
|
88 |
LOGGER.warn("Can't output",ex); |
|
89 |
} |
|
90 |
for (Writer writer : writers) { |
|
91 |
try { |
|
92 |
writer.write(cbuf, off, len); |
|
93 |
} catch (Exception ex) { |
|
94 |
LOGGER.warn("Can't output",ex); |
|
95 |
} |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public void flush() throws IOException { |
|
101 |
try { |
|
102 |
out.flush(); |
|
103 |
} catch (Exception ex) { |
|
104 |
LOGGER.warn("Can't flush",ex); |
|
105 |
} |
|
106 |
for (Writer writer : writers) { |
|
107 |
try { |
|
108 |
writer.flush(); |
|
109 |
} catch (Exception ex) { |
|
110 |
LOGGER.warn("Can't flush",ex); |
|
111 |
} |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
@Override |
|
116 |
public void close() throws IOException { |
|
117 |
} |
|
118 |
|
|
119 |
private void addWriter(Writer out) { |
|
120 |
this.writers.add(out); |
|
121 |
} |
|
122 |
|
|
123 |
private void removeWriter(Writer out) { |
|
124 |
this.writers.remove(out); |
|
125 |
} |
|
126 |
|
|
127 |
} |
|
128 |
|
|
129 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
|
130 |
protected DefaultScriptingScript(ScriptingFolder parent, String typename, ScriptingManager manager, String id) { |
|
131 |
super(parent, typename, manager, id); |
|
132 |
this.useSysPath = false; |
|
133 |
this.setLangName("python"); |
|
134 |
this.setSaved(true); |
|
135 |
this.delegatedObservable = new DelegateWeakReferencingObservable(this); |
|
136 |
this.stdout = new OutputWriter(System.out); |
|
137 |
this.stderr = new OutputWriter(System.err); |
|
138 |
} |
|
139 |
|
|
140 |
public DefaultScriptingScript(ScriptingFolder parent, ScriptingManager manager, String id) { |
|
141 |
this(parent, ScriptingManager.UNIT_SCRIPT, manager, id); |
|
142 |
} |
|
143 |
|
|
144 |
public DefaultScriptingScript(ScriptingFolder parent, ScriptingManager manager, String id, String langName) { |
|
145 |
this(parent, ScriptingManager.UNIT_SCRIPT, manager, id); |
|
146 |
if( !StringUtils.isBlank(langName) ) { |
|
147 |
this.setLangName(langName); |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
@Override |
|
152 |
public int hashCode() { |
|
153 |
File f = this.getFile(); |
|
154 |
if( f!=null ) { |
|
155 |
return "#$FILE$#".hashCode() + f.getAbsolutePath().hashCode(); |
|
156 |
} |
|
157 |
String s = this.getId(); |
|
158 |
if( s != null ) { |
|
159 |
return "#$ID$#".hashCode() + s.hashCode(); |
|
160 |
} |
|
161 |
s = this.getCode(); |
|
162 |
if( s != null ) { |
|
163 |
return "#$CODE$#".hashCode() + s.hashCode(); |
|
164 |
} |
|
165 |
return super.hashCode(); |
|
166 |
} |
|
167 |
@Override |
|
168 |
public void addStdoutWriter(Writer out) { |
|
169 |
this.stdout.addWriter(out); |
|
170 |
} |
|
171 |
|
|
172 |
@Override |
|
173 |
public void addStderrWriter(Writer err) { |
|
174 |
this.stderr.addWriter(err); |
|
175 |
} |
|
176 |
|
|
177 |
@Override |
|
178 |
public void removeStdoutWriter(Writer out) { |
|
179 |
this.stdout.removeWriter(out); |
|
180 |
} |
|
181 |
|
|
182 |
@Override |
|
183 |
public void removeStderrWriter(Writer err) { |
|
184 |
this.stdout.removeWriter(err); |
|
185 |
} |
|
186 |
|
|
187 |
public Object __getattr__(String name) { |
|
188 |
try { |
|
189 |
ScriptEngine theEngine = this.getEngine(); |
|
190 |
this.compile(); |
|
191 |
return theEngine.get(name); |
|
192 |
} catch(Exception ex) { |
|
193 |
return null; |
|
194 |
} |
|
195 |
} |
|
196 |
|
|
197 |
public void __setattr__(String name, Object value) { |
|
198 |
ScriptEngine theEngine = this.getEngine(); |
|
199 |
this.compile(); |
|
200 |
theEngine.put(name, value); |
|
201 |
} |
|
202 |
|
|
203 |
public Object __call__() { |
|
204 |
return this.run(); |
|
205 |
} |
|
206 |
|
|
207 |
public Object __call__(Object[] args) { |
|
208 |
return this.run(args); |
|
209 |
} |
|
210 |
|
|
211 |
public OutputWriter getStdout() { |
|
212 |
return this.stdout; |
|
213 |
} |
|
214 |
|
|
215 |
public OutputWriter getStderr() { |
|
216 |
return this.stderr; |
|
217 |
} |
|
218 |
|
|
219 |
protected void notifyErrors(Exception exception, String command) { |
|
220 |
this.delegatedObservable.notifyObservers(new BaseScriptingNotifycation( |
|
221 |
this, BaseScriptingNotifycation.RUNTIME_ERROR_NOTIFICATION, |
|
222 |
command, exception)); |
|
223 |
} |
|
224 |
|
|
225 |
|
|
226 |
@Override |
|
227 |
public String getCode() { |
|
228 |
if (this.code == null) { |
|
229 |
File f = null; |
|
230 |
try { |
|
231 |
f = this.getFileResource(this.extension); |
|
232 |
Charset encoding = Charsets.toCharset(EncodingUtils.getEncoding(f)); |
|
233 |
this.code = FileUtils.readFileToString(f, encoding); |
|
234 |
} catch (IOException e) { |
|
235 |
String fname = (f == null) ? "(null)" : f.getAbsolutePath(); |
|
236 |
LOGGER.warn("Can't load code from file '" + fname + "'."); |
|
237 |
} |
Also available in: Unified diff