Revision 1522

View differences:

org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/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</artifactId>
6
    <packaging>pom</packaging>
7
    <version>2.3.148</version>
8
    <name>${project.artifactId}</name>
9
    <description>Scripting Framework for gvSIG</description>
10
    <url>http://devel.gvsig.org/sites/org.gvsig.scripting/${project.version}</url>
11

  
12
    <parent>
13
        <groupId>org.gvsig</groupId>
14
        <artifactId>org.gvsig.desktop</artifactId>
15
        <version>2.0.345</version>
16
    </parent>
17

  
18
    <scm>
19
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-scripting/org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148</connection>
20
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-scripting/org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148</developerConnection>
21
        <url>https://devel.gvsig.org/svn/gvsig-scripting/org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148</url>
22
    </scm>
23
    <developers>
24
        <developer>
25
            <id>jjdelcerro</id>
26
            <name>Joaquín José del Cerro</name>
27
            <email>jjdelcerro@gvsig.org</email>
28
            <roles>
29
                <role>Architect</role>
30
                <role>Developer</role>
31
            </roles>
32
        </developer>
33
        <developer>
34
            <id>jbadia</id>
35
            <name>José Badía</name>
36
            <email>badia_jos@gva.es</email>
37
            <roles>
38
                <role>Developer</role>
39
            </roles>
40
        </developer>
41
    </developers>
42

  
43
    <distributionManagement>
44
        <site>
45
            <id>gvsig-repository</id>
46
            <url>dav:https://devel.gvsig.org/sites/org.gvsig.scripting/${project.version}</url>
47
        </site>
48
    </distributionManagement>
49
    <repositories>
50
        <repository>
51
            <id>gvsig-public-http-repository</id>
52
            <name>gvSIG maven public HTTP repository</name>
53
            <url>http://devel.gvsig.org/m2repo/j2se</url>
54
            <releases>
55
                <enabled>true</enabled>
56
                <updatePolicy>daily</updatePolicy>
57
                <checksumPolicy>warn</checksumPolicy>
58
            </releases>
59
            <snapshots>
60
                <enabled>true</enabled>
61
                <updatePolicy>daily</updatePolicy>
62
                <checksumPolicy>warn</checksumPolicy>
63
            </snapshots>
64
        </repository>
65
        <repository>
66
            <id>bedatadriven</id>
67
            <name>bedatadriven public repo</name>
68
            <url>http://nexus.bedatadriven.com/content/groups/public/</url>
69
        </repository>
70
    </repositories>
71
    <build>
72
        <plugins>
73
            <plugin>
74
                <groupId>org.apache.maven.plugins</groupId>
75
                <artifactId>maven-release-plugin</artifactId>
76
                <configuration>
77
                    <tagBase>https://devel.gvsig.org/svn/gvsig-scripting/org.gvsig.scripting/tags</tagBase>
78
                </configuration>
79
            </plugin>
80

  
81
        </plugins>
82
    </build>
83

  
84
    <dependencyManagement>
85
        <dependencies>
86
            <dependency>
87
                <groupId>org.gvsig</groupId>
88
                <artifactId>org.gvsig.scripting.lib.api</artifactId>
89
                <version>2.3.148</version>
90
            </dependency>
91
            <dependency>
92
                <groupId>org.gvsig</groupId>
93
                <artifactId>org.gvsig.scripting.swing.api</artifactId>
94
                <version>2.3.148</version>
95
            </dependency>
96
            <dependency>
97
                <groupId>org.gvsig</groupId>
98
                <artifactId>org.gvsig.scripting.lib.impl</artifactId>
99
                <version>2.3.148</version>
100
            </dependency>
101
            <dependency>
102
                <groupId>org.gvsig</groupId>
103
                <artifactId>org.gvsig.scripting.swing.impl</artifactId>
104
                <version>2.3.148</version>
105
            </dependency>
106

  
107
            <dependency>
108
                <groupId>org.gvsig</groupId>
109
                <artifactId>org.gvsig.scripting.main</artifactId>
110
                <version>2.3.148</version>
111
            </dependency>
112

  
113
            <dependency>
114
                <groupId>org.gvsig</groupId>
115
                <artifactId>org.gvsig.scripting.thing</artifactId>
116
                <version>2.3.148</version>
117
            </dependency>
118

  
119
            <dependency>
120
                <groupId>org.gvsig</groupId>
121
                <artifactId>org.gvsig.scripting.app.mainplugin</artifactId>
122
                <version>2.3.148</version>
123
            </dependency>
124

  
125
            <dependency>
126
              <groupId>com.github.tbekolay.jnumeric</groupId>
127
              <artifactId>jnumeric</artifactId>
128
              <version>0.1</version>
129
            </dependency>
130

  
131
            <dependency>
132
                <groupId>org.renjin</groupId>
133
                <artifactId>renjin-script-engine</artifactId>
134
                <version>0.9.2644</version>
135
                <classifier>jar-with-dependencies</classifier>
136
            </dependency>
137
            
138
            <!--
139
            <dependency>
140
                <groupId>org.scala-lang</groupId>
141
                <artifactId>scala-dist</artifactId>
142
                <version>2.12.0-M2</version>
143
                <scope>runtime</scope>
144
                <exclusions>
145
                    <exclusion>
146
                        <groupId>org.scala-lang</groupId>
147
                        <artifactId>scala-library-all</artifactId>
148
                    </exclusion>
149
                </exclusions>            
150
            </dependency>
151
            <dependency>
152
                <groupId>org.scala-lang</groupId>
153
                <artifactId>scala-compiler</artifactId>
154
                <version>2.12.0-M2</version>
155
            </dependency>
156
            <dependency>
157
                <groupId>org.scala-lang</groupId>
158
                <artifactId>scala-library</artifactId>
159
                <version>2.12.0-M2</version>
160
            </dependency>
161
            <dependency>
162
                <groupId>org.scala-lang</groupId>
163
                <artifactId>scala-reflect</artifactId>
164
                <version>2.12.0-M2</version>
165
            </dependency>
166
            <dependency>
167
                <groupId>org.scala-lang</groupId>
168
                <artifactId>scalap</artifactId>
169
                <version>2.12.0-M2</version>
170
            </dependency>
171
            <dependency>
172
                <groupId>jline</groupId>
173
                <artifactId>jline</artifactId>
174
                <version>2.12.1</version>
175
            </dependency>
176
            -->
177
            
178
            <dependency>
179
                <groupId>com.jeta</groupId>
180
                <artifactId>abeille</artifactId>
181
                <version>2.1.0.M3</version>
182
                <type>tar.gz</type>
183
            </dependency>
184

  
185
            <dependency>
186
                <groupId>org.apache.tika</groupId>
187
                <artifactId>tika-core</artifactId>
188
                <version>1.12</version>
189
            </dependency>            
190
            <dependency>
191
                <groupId>net.sf.cssbox</groupId>
192
                <artifactId>swingbox</artifactId>
193
                <version>1.1</version>
194
            </dependency>
195
            <dependency>
196
                <groupId>net.sf.cssbox</groupId>
197
                <artifactId>cssbox</artifactId>
198
                <version>4.7</version>
199
            </dependency>
200
            <dependency>
201
                <groupId>net.sourceforge.nekohtml</groupId>
202
                <artifactId>nekohtml</artifactId>
203
                <version>1.9.21</version>
204
            </dependency>
205
            <dependency>
206
                <groupId>net.sf.cssbox</groupId>
207
                <artifactId>jstyleparser</artifactId>
208
                <version>1.18</version>
209
            </dependency>
210
            <dependency>
211
                <groupId>org.eclipse.jgit</groupId>
212
                <artifactId>org.eclipse.jgit</artifactId>
213
                <version>4.9.0.201710071750-r</version>
214
            </dependency>                    
215
                            
216
        </dependencies>
217
    </dependencyManagement>
218

  
219
    <modules>
220
        <module>org.gvsig.scripting.thing</module>
221
        <module>org.gvsig.scripting.lib</module>
222
        <module>org.gvsig.scripting.swing</module>
223
        <module>org.gvsig.scripting.main</module>
224
        <module>org.gvsig.scripting.app</module>
225
    </modules>
226
</project>
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/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.api</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.scripting.lib.api</name>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.scripting.lib</artifactId>
11
		<version>2.3.148</version>
12
	</parent>
13
	<dependencies>
14
		<dependency>
15
			<groupId>org.gvsig</groupId>
16
			<artifactId>org.gvsig.tools.lib</artifactId>
17
			<scope>compile</scope>
18
		</dependency>
19
		<dependency>
20
			<groupId>org.gvsig</groupId>
21
			<artifactId>org.gvsig.tools.lib</artifactId>
22
			<type>test-jar</type>
23
			<scope>test</scope>
24
		</dependency>
25
		<dependency>
26
			<groupId>org.gvsig</groupId>
27
			<artifactId>org.gvsig.i18n</artifactId>
28
			<scope>compile</scope>
29
		</dependency>
30
		<dependency>
31
			<groupId>javax.help</groupId>
32
			<artifactId>javahelp</artifactId>
33
			<scope>compile</scope>
34
		</dependency>
35
	</dependencies>
36
	<build>
37
		<plugins>
38
			<plugin>
39
				<groupId>org.apache.maven.plugins</groupId>
40
				<artifactId>maven-jar-plugin</artifactId>
41
				<configuration>
42
				</configuration>
43
				<executions>
44
					<!--
45
						Generates a jar file only with the test classes
46
					-->
47
					<execution>
48
						<goals>
49
							<goal>test-jar</goal>
50
						</goals>
51
					</execution>
52
				</executions>
53
			</plugin>
54
		</plugins>
55
	</build>
56
</project>
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/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.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/resources/org/gvsig/scripting/i18n/text.properties
1
# Resource bundle texts for the Spanish language locale (es)
2
Example.returns_value=devuelve el valor
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/resources/org/gvsig/scripting/i18n/text_en.properties
1
# Resource bundle texts for the English language locale (en)
2
Example.returns_value=returns value
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/resources/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.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/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.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.scripting.ScriptingLibrary
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingExternalFile.java
1
package org.gvsig.scripting;
2

  
3
import java.io.File;
4

  
5

  
6
public interface ScriptingExternalFile extends ScriptingUnit {
7
    
8
    public File getExternalFile();
9

  
10
    public String getMimeType();
11

  
12
    public void setContents(String text);
13

  
14
    public String getContentsAsText();
15
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingText.java
1
package org.gvsig.scripting;
2

  
3
/**
4
 * <p>
5
 * Interface that represents a unit with text.</p>
6
 *
7
 * @see ScriptingUnit
8
 */
9
public interface ScriptingText extends ScriptingUnit {
10

  
11
    /**
12
     * Returns the text associated to this unit.
13
     *
14
     * @return a String of this unit.
15
     */
16
    public String getText();
17

  
18
    /**
19
     * Sets a the text associated to this unit.
20
     *
21
     * @param text String to assign to this unit.
22
     */
23
    public void setText(String text);
24

  
25
    /**
26
     * Persists the current status of this unit.
27
     */
28
    public void save();
29

  
30
    public String getMimeType();
31
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingNotification.java
1
package org.gvsig.scripting;
2

  
3
/**
4
 * Interface to support the notifications in the application 
5
 *
6
 */
7
public interface ScriptingNotification {
8

  
9
	/**
10
	 * Gets the type of ScriptingNotification
11
	 * 
12
	 * @return An integer with the type.
13
	 */
14
	public int getType();
15
	
16
	/**
17
	 * Gets the ScriptingNotification's id
18
	 * 
19
	 * @return a String with the id
20
	 */
21
	public String getId();
22
	
23
	/**
24
	 * Get the {@link ScriptingUnit} which send the notification
25
	 * 
26
	 * @return {@link ScriptingUnit
27
	 */
28
	public ScriptingUnit getUnit();
29
	
30
	/**
31
	 * Gets the cause of the ScriptingNotification
32
	 * 
33
	 * @return Exception
34
	 */
35
	public Exception getException();
36
	
37

  
38
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/package.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 description.</p>
11
	
12
	<p>See the <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#packagecomment">Javadoc Tool documentation about the package file</a></p>
13

  
14
</body>
15
</html>
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/CompileErrorException.java
1
package org.gvsig.scripting;
2

  
3
import java.io.File;
4

  
5
public class CompileErrorException extends ScriptingErrorException {
6

  
7
	/**
8
	 * 
9
	 */
10
	private static final long serialVersionUID = -7829204331513125285L;
11

  
12
	public CompileErrorException(String msg, File name, int line, int column) {
13
		super(msg, name, line, column);
14
	}
15
	
16
	public CompileErrorException(String msg, File name, int line, int column, Throwable cause) {
17
		this(msg, name, line, column);
18
		this.initCause(cause);
19
	}
20
	
21
	public CompileErrorException(String msg, File name, Throwable cause) {
22
		this(msg, name, -1, -1);
23
		this.initCause(cause);
24
	}
25
}
0 26

  
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingDialog.java
1
package org.gvsig.scripting;
2

  
3
import java.io.File;
4

  
5
/**
6
 * <p> Interface that represents a single script with window dialog.</p>
7
 * 
8
 * @see ScriptingUnit
9
 * @see ScriptingBaseScript
10
 */
11
public interface ScriptingDialog extends ScriptingScript{
12

  
13
	public static final int MODE_DIALOG=1;
14
	public static final int MODE_WINDOW=2;
15
	public static final int MODE_TOOL=3;
16
	
17
	/**
18
	 * Returns the file where is the window dialog's gui.  
19
	 * 
20
	 * @return a File with the code of the window dialog.
21
	 */
22
	public File getDialogFile();
23

  
24
	/**
25
	 * Returns the type of the window dialog associated with the ScriptingDialog.  
26
	 * 
27
	 * @return an int with the window mode.
28
	 */
29
	public int getShowMode();
30
	
31
	/**
32
	 * Sets the window mode associated with a ScriptingDialog.
33
	 *
34
	 * @param mode
35
	 *            int that contains the window mode.
36
	 */
37
	public void setShowMode(int mode);
38
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingRunningException.java
1
package org.gvsig.scripting;
2

  
3
public class ScriptingRunningException extends Exception {
4

  
5
	/**
6
	 * 
7
	 */
8
	private static final long serialVersionUID = 4327337186862453971L;
9

  
10
	private String message;
11
	private String fileName;
12
	private int lineNunber;
13
	private int columnNumber;
14

  
15
	public ScriptingRunningException(String message, String fileName,
16
			int lineNumber, int columnNumber) {
17
		this.message = message;
18
		this.fileName = fileName;
19
		this.lineNunber = lineNumber;
20
		this.columnNumber = columnNumber;
21
	}
22

  
23
	public ScriptingRunningException(String message, String fileName) {
24
		this(message, fileName, -1, -1);
25
	}
26

  
27
	public int getLineNumber() {
28
		return this.lineNunber;
29
	}
30

  
31
	public int getColumnNumber() {
32
		return this.columnNumber;
33
	}
34

  
35
	public String getFileName() {
36
		return this.fileName;
37
	}
38

  
39
	public String getMessage() {
40
		return this.message;
41
	}
42
}
0 43

  
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingBaseScript.java
1
package org.gvsig.scripting;
2

  
3
import java.io.File;
4
import java.io.Writer;
5

  
6
import org.gvsig.tools.observer.WeakReferencingObservable;
7

  
8
/**
9
 * <p>
10
 * Interface that represents Scripting elements.</p>
11
 *
12
 * @see ScriptingUnit
13
 *
14
 * @see ScriptingScript
15
 * @see ScriptingDialog
16
 * @see ScriptingProject
17
 */
18
public interface ScriptingBaseScript extends ScriptingUnit, WeakReferencingObservable {
19

  
20
    public static final int ISOLATION_LOW = 0;
21
    public static final int ISOLATION_HIGH = 10;
22
    
23
    /**
24
     * Check if the script execution is enabled.
25
     *
26
     * @return if the script is enabled.
27
     */
28
    public boolean isEnabled();
29

  
30
    /**
31
     * Enable or disable the sript execution.
32
     *
33
     * @param enabled
34
     */
35
    public void setEnabled(boolean enabled);
36

  
37
    /**
38
     * Executes the code of a ScriptBaseScript.
39
     *
40
     * @return
41
     */
42
    public Object run();
43

  
44
    /**
45
     * Executes the code of a ScriptBaseScript.
46
     *
47
     * @param args Contains the input parameters to run the ScriptBaseScript.
48
     * @return
49
     */
50
    public Object run(Object args[]);
51

  
52
    /**
53
     * Executes the code of a ScriptBaseScript in a separated thread
54
     *
55
     * @param args Contains the input parameters to run the ScriptBaseScript.
56
     */
57
    public void runAsTask(Object args[]);
58

  
59
    public void compile() throws ScriptingRunningException;
60

  
61
    public void put(String name, Object value);
62

  
63
    /**
64
     * Return a resource File that is beside this script.
65
     *
66
     * @param filename
67
     * @return the file which is beside this script
68
     */
69
    public File getResource(String filename);
70

  
71
    public File getScriptFile();
72
  
73
    public String getLibrarySuffix();
74

  
75
    public void setLibrarySuffix(String librarySuffix);    
76
    
77
    public void addStdoutWriter(Writer out);
78
    
79
    public void addStderrWriter(Writer err);
80
    
81
    public void removeStdoutWriter(Writer out);
82
    
83
    public void removeStderrWriter(Writer err);
84
    
85
    public void setIsolationGroup(String group);
86
    
87
    public String getIsolationGroup();
88
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingLocator.java
1
package org.gvsig.scripting;
2

  
3
import org.gvsig.tools.locator.BaseLocator;
4
import org.gvsig.tools.locator.Locator;
5
import org.gvsig.tools.locator.LocatorException;
6

  
7
public class ScriptingLocator extends BaseLocator {
8

  
9
	private static final String LOCATOR_NAME = "ScriptingLocator";
10

  
11
	public static final String MANAGER_NAME = "scriptinglocator.manager";
12

  
13
	public static final String MANAGER_DESCRIPTION = "Scripting Manager";
14

  
15
	/**
16
	 * Unique instance.
17
	 */
18
	private static final ScriptingLocator instance = new ScriptingLocator();
19

  
20
	/**
21
	 * Return the singleton instance.
22
	 *
23
	 * @return the singleton instance
24
	 */
25
	public static ScriptingLocator getInstance() {
26
		return instance;
27
	}
28

  
29
	/**
30
	 * Return the Locator's name
31
	 *
32
	 * @return a String with the Locator's name
33
	 */
34
	@Override
35
    public String getLocatorName() {
36
		return LOCATOR_NAME;
37
	}
38

  
39
    /**
40
     * Return a reference to ScriptManager.
41
     * 
42
     * @return a reference to ScriptManager
43
     * @throws LocatorException
44
     *             if there is no access to the class or the class cannot be
45
     *             instantiated
46
     * @see Locator#get(String)
47
     */
48
	public static ScriptingManager getManager() throws LocatorException {
49
		return (ScriptingManager) getInstance().get(MANAGER_NAME);
50
	}
51

  
52
    /**
53
     * Registers the Class implementing the ScriptManager interface.
54
     * 
55
     * @param clazz
56
     *            implementing the ScriptManager interface
57
     */
58
    public static void registerManager(Class<? extends ScriptingManager> clazz) {
59
		getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
60
	}
61
	
62
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingLibrary.java
1
package org.gvsig.scripting;
2

  
3
import org.gvsig.tools.library.AbstractLibrary;
4
import org.gvsig.tools.library.LibraryException;
5
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
6

  
7
public class ScriptingLibrary extends AbstractLibrary {
8

  
9
    @Override
10
    public void doRegistration() {
11
        registerAsAPI(ScriptingLibrary.class);
12
    }
13

  
14
    @Override
15
    protected void doInitialize() throws LibraryException {
16
        // Nothing to do
17
    }
18

  
19
    @Override
20
    protected void doPostInitialize() throws LibraryException {
21
        // Validate there is any implementation registered.
22
        ScriptingManager manager = ScriptingLocator.getManager();
23

  
24
        if (manager == null) {
25
            throw new ReferenceNotRegisteredException(
26
                ScriptingLocator.MANAGER_NAME, ScriptingLocator.getInstance());
27
        }
28
    }
29

  
30
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingScript.java
1
package org.gvsig.scripting;
2

  
3
import org.gvsig.tools.script.Script;
4

  
5

  
6
/**
7
 * <p> Interface that represents a single script without window dialog.</p>
8
 * 
9
 * @see ScriptingUnit
10
 * @see ScriptingBaseScript
11
 */
12
public interface ScriptingScript 
13
        extends ScriptingText, ScriptingBaseScript, Script 
14
    {
15

  
16
	/**
17
	 * Returns the languange in which the ScriptingScript is written.
18
	 * 
19
	 * @return a String containing the name of the language
20
	 */
21
	public String getLangName();
22

  
23
	/**
24
	 * Returns the ScriptingScript's code.
25
	 * 
26
	 * @return a String with the code of the script.
27
	 */
28
        @Override
29
	public String getCode();
30

  
31
	/**
32
	 * Sets a the code associated with a ScriptingScript.
33
	 *
34
	 * @param code String that contains the new code.
35
	 */
36
        @Override
37
	public void setCode(String code);
38

  
39
	/**
40
	 * Returns the name of the main function in the ScriptingScript's code
41
	 * 
42
	 * @return a String with main function (default main name is 'main').
43
	 */
44
	public String getMainName();
45

  
46
	/**
47
	 * Stablishes a new main main function in the ScriptingScript's code.
48
	 *
49
	 * @param mainName
50
	 *            String that contains the new main function name.
51
	 */
52
	public void setMainName(String mainName);
53

  
54
	/**
55
	 * Persists the current status of a ScriptingScript with the content associated.
56
	 */
57
        @Override
58
	public void save();
59
	
60
	/**
61
	 * Executes a method from the Script's code
62
	 * 
63
	 * @param obj this Object represents the script's code
64
	 * @param name method's name to execute
65
	 * @param args input parameters of the method 
66
	 * 
67
	 * @return An Object that represents the execution
68
	 * 
69
	 * @throws NoSuchMethodException If there isn't a main function to begin the execution
70
	 */
71
	public Object invokeMethod(Object obj, String name, Object[] args) throws NoSuchMethodException;
72
	
73
	/**
74
	 * Executes a function from the Script's code
75
	 * 
76
	 * @param name method's name to execute
77
	 * @param args input parameters of the method 
78
	 * 
79
	 * @return An Object that represents the execution
80
	 * 
81
	 * @throws NoSuchMethodException If there isn't a main function to begin the execution
82
	 */
83
        @Override
84
	public Object invokeFunction(String name, Object[] args) throws NoSuchMethodException;
85
	
86
        @Override
87
        public String getMimeType();
88
        
89
        public void registerDataFolder(String id);
90
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ExecuteErrorException.java
1
package org.gvsig.scripting;
2

  
3
import java.io.File;
4

  
5
public class ExecuteErrorException extends ScriptingErrorException {
6

  
7
	/**
8
	 * 
9
	 */
10
	private static final long serialVersionUID = 3733567933742742587L;
11

  
12
	public ExecuteErrorException(String msg, File name, int line, int column) {
13
		super(msg, name, line, column);
14
	}
15
	
16
	public ExecuteErrorException(String msg, File name, int line, int column, Throwable cause) {
17
		this(msg, name, line, column);
18
		this.initCause(cause);
19
	}
20
	
21
	public ExecuteErrorException(String msg, File name, Throwable cause) {
22
		this(msg, name, -1, -1);
23
		this.initCause(cause);
24
	}
25
	
26
}
0 27

  
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingErrorException.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.scripting;
7

  
8
import java.io.File;
9
import org.apache.commons.io.FilenameUtils;
10

  
11
/**
12
 *
13
 * @author jjdelcerro
14
 */
15
public class ScriptingErrorException extends RuntimeException {
16
    private static final long serialVersionUID = -3489829775437358107L;
17
    private final File name;
18
    private final int line;
19
    private final int column;
20

  
21
    public ScriptingErrorException(String msg, File name, int line, int column) {
22
        super(msg);
23
        this.name = name;
24
        this.line = line;
25
        this.column = column;
26
    }
27

  
28
    public int getLineNumber() {
29
        return this.line;
30
    }
31

  
32
    public int getColumnNumber() {
33
        return this.column;
34
    }
35

  
36
    public String getScriptName() {
37
        return FilenameUtils.getBaseName(this.name.getName());
38
    }
39
   
40
    public File getScriptFile() {
41
        return this.name;
42
    }
43
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingManager.java
1
package org.gvsig.scripting;
2

  
3
import java.io.File;
4
import java.util.List;
5
import java.util.Map;
6
import java.util.Set;
7
import org.gvsig.tools.packageutils.Version;
8
import org.gvsig.tools.service.spi.ProviderFactory;
9
import org.gvsig.tools.script.ScriptManager;
10
import org.gvsig.tools.util.FolderSet;
11

  
12
/**
13
 * There are two top level management roles within ScriptingFramework: logical
14
 * and User's Interface (UI) management.
15
 *
16
 * This class is responsible of the logical role. It provides all the services
17
 * to manage the information used in ScriptingFramework.
18
 */
19
public interface ScriptingManager extends ScriptManager {
20

  
21
    public static final String INSTALLER_PROVIDER_NAME = "Script";
22
    public static final String INSTALLER_PROVIDER_DESCRIPTION = "Provider to install scripts";
23

  
24
    public static final String PYTHON_LANGUAGE_NAME = "python";
25
//    public static final String SCALA_LANGUAGE_NAME = "scala";
26
    public static final String DEFAULT_ISOLATION_GROUP = "default";
27
    
28
    public static final String UNIT_SCRIPT = "Script";
29
    public static final String UNIT_DIALOG = "Dialog";
30
    public static final String UNIT_FOLDER = "Folder";
31
    public static final String UNIT_EXTERNALFILE = "ExternalFile";
32

  
33
    public void setHomeFolder(File home);
34

  
35
    public File getHomeFolder();
36

  
37
    public File getDataFolder(String id);
38
    
39
    public void registerDataFolder(ScriptingFolder folderScript, String id);
40
    
41
    public List<DataFolderFound> searchOldVersions(Version currentVersion, FolderSet folder);
42
    
43
    /**
44
     * Returns the System's Folder
45
     *
46
     * @return a {@link ScriptingFolder} with the System's Folder.
47
     */
48
    public ScriptingFolder getSystemFolder();
49

  
50
    /**
51
     * Returns the User's Folder
52
     *
53
     * @return a {@link ScriptingFolder} with the User's Folder.
54
     */
55
    public ScriptingFolder getUserFolder();
56

  
57
    public List<ScriptingFolder> getAlternativeUserFolders();
58

  
59
    public void addAlternativeUserFolder(File f, String name, String description);
60

  
61
    public ScriptingUnit createUnit(String unitType, ScriptingFolder folder, String id);
62

  
63
    public ScriptingUnit createUnit(String unitType, ScriptingFolder folder, String id, String language);
64
    
65
    public List<String> getUnitTypes();
66

  
67
    /**
68
     * Returns the {@link ScriptingBaseScript} associated with the file
69
     * specified
70
     *
71
     * @param file File where is contained the {@link ScriptingBaseScript}'s
72
     * information
73
     *
74
     * @return {@link ScriptingBaseScript}
75
     */
76
    public ScriptingBaseScript getScript(File file);
77

  
78
    public ScriptingBaseScript getScript(String name);
79

  
80
    /**
81
     * Returns the {@link ScriptingFolder} associated with the file specified
82
     *
83
     * @param file File where is contained the {@link ScriptingFolder}'s
84
     * information
85
     *
86
     * @return {@link ScriptingFolder}
87
     */
88
    public ScriptingFolder getFolder(File file);
89
    
90
    /**
91
     * Return the {@link ScriptingUnit} associated with the path specified.
92
     * 
93
     * the path should start with "User" or "System".
94
     * 
95
     * @param pathName
96
     * 
97
     * @return the required {@link ScriptingUnit}
98
     */
99
    public ScriptingUnit getUnit(String pathName);
100

  
101

  
102
    /**
103
     * Returns the path of the User's Folder
104
     *
105
     * @return a String with the path of the User's Folder
106
     */
107
//    public String getRootUserFolder();
108
    /**
109
     * Registers a File System with {@link ScriptingUnit}s in the SystemFolder
110
     *
111
     * @param name String with the identificator name of the File System
112
     * registered
113
     * @param folder File with the root of the File System to register
114
     */
115
    public void registerSystemFolder(String name, File folder);
116

  
117
    public List<String> getSupportedLanguages();
118

  
119
    public String getExtensionOfLanguage(String language);
120

  
121
    public String getEngineNameByLanguage(String langName);
122
    
123
    public Set<String> getEnginesIsolationGroups();
124

  
125
    /**
126
     * Checks if an id is unique in a determinate folder
127
     *
128
     * @param folder {
129
     * @ScriptingFolder} with the directory to verify the id
130
     * @param id String with the id to validate
131
     *
132
     * @return true if there isn't another {@link ScriptingUnit} with the same
133
     * id, and false in the other case
134
     */
135
    public boolean validateUnitId(ScriptingFolder folder, String id);
136

  
137
    /**
138
     * Sets a key/value pair in the state of the ScriptingManager that may
139
     * either create a Java Language Binding to be used in the execution of
140
     * scripts
141
     *
142
     * @param key The name of named value to add
143
     * @param value The value of named value to add.
144
     */
145
    public void put(String key, Object value);
146

  
147
    /**
148
     * Retrieves a value set in the state of this ScriptingManager
149
     *
150
     * @param key The key whose value is to be returned
151
     *
152
     * @return an Object with the value corresponding to the key
153
     */
154
    public Object get(String key);
155

  
156
    public void addLibFolder(File lib);
157

  
158
    public File getRootUserFolder();
159
    
160
    public ProviderFactory getInstallerFactory();
161
    
162
    /**
163
     * Devuelbe la carpeta en la que se encuentran los paquetes
164
     * de la aplicacion.
165
     * 
166
     * @return 
167
     */
168
    public File getPackagesFolder();
169
    
170
    /**
171
     * Establece la carpeta en la que se encuentran los paquetes
172
     * de la aplicacion.
173
     * @param folder 
174
     */
175
    public void setPackagesFolder(File folder);
176
    
177
    /**
178
     * Search the available engines and initialize the manager.
179
     */
180
    public void loadEngines();
181
    
182
    public List<File> getLibFolders();
183
    
184
    /**
185
     * Return a map with the label and suffix of the library versions.
186
     * 
187
     * For each value of map, the value is the name of the version (a label) and
188
     * the key is the suffix for that version.
189
     * 
190
     * @return a map with suffix and labels of library versions. 
191
     */
192
    public Map<String,String> getLibFoldersVersions();
193
    
194
    /**
195
     * <p>
196
     * Returns a reference to an object (property) associated to this layer.</p>
197
     *
198
     * <p>
199
     * For example, you can attach a network definition to key "network" and
200
     * check
201
     * if a layer has a network loaded using
202
     * <i>getAssociatedObject("network")</i> and
203
     * that it's not null.</p>
204
     *
205
     * @param key the key associated to the property
206
     *
207
     * @return <code>null</code> if key is not found
208
     *
209
     * @see #getExtendedProperties()
210
     * @see #setProperty(Object, Object)
211
     */
212
    public Object getProperty(Object key);
213

  
214
    /**
215
     * Inserts an object as a property to this layer.
216
     *
217
     * @param key the key associated to the property
218
     * @param obj the property
219
     *
220
     * @see #getProperty(Object)
221
     * @see #getExtendedProperties()
222
     */
223
    public void setProperty(Object key, Object obj);
224

  
225
    /**
226
     * Returns a hash map with all new properties associated to this layer.
227
     *
228
     * @return hash table with the added properties
229
     *
230
     * @see #getProperty(Object)
231
     * @see #setProperty(Object, Object)
232
     */
233
    public Map getExtendedProperties();   
234
    
235
    public ScriptingFolder createLink(String name, File link, String targetPathName);
236

  
237
    public ScriptingFolder createLink(String name, ScriptingFolder link, String targetPathName);
238
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingFolder.java
1
package org.gvsig.scripting;
2

  
3
import java.io.File;
4
import java.io.IOException;
5
import java.util.List;
6
import java.util.function.Predicate;
7
import org.gvsig.tools.exception.BaseException;
8
import org.gvsig.tools.visitor.Visitable;
9
import org.gvsig.tools.visitor.Visitor;
10

  
11
/**
12
 * <p>
13
 * Interface that represents a directory in the ScriptingFramework.</p>
14
 *
15
 * @see ScriptingUnit
16
 */
17
public interface ScriptingFolder extends ScriptingUnit, Visitable {
18

  
19
    /**
20
     * Adds a {@link ScriptingUnit} to the ScriptingFolder.
21
     *
22
     * @param unit {@link ScriptingUnit} to include.
23
     */
24
    public void add(ScriptingUnit unit);
25

  
26
    /**
27
     * Removes a {@link ScriptingUnit} from the ScriptingFolder.
28
     *
29
     * @param unit {@link ScriptingUnit} to delete.
30
     */
31
    public void remove(ScriptingUnit unit);
32

  
33
    /**
34
     * Returns the {@link ScriptingUnit} associated with a File.
35
     *
36
     * @param file File of the data origin.
37
     *
38
     * @return a {@link ScriptingUnit} with the content extracted from the file.
39
     */
40
    public ScriptingUnit getUnit(File file);
41
    
42
    public ScriptingUnit getUnit(String path);
43

  
44
    /**
45
     * Gets all the {@link ScriptingUnit}s contained in a ScriptingFolder.
46
     *
47
     * @return a List with the {@link ScriptingUnit}s.
48
     *
49
     */
50
    public List<ScriptingUnit> getUnits();
51

  
52
    public List<ScriptingFolder> getUnitFolders();
53

  
54
    public boolean isLink();
55

  
56
    public void accept(Visitor visitor, Predicate<ScriptingUnit> includeFilter) throws BaseException;
57

  
58
    public void save();
59

  
60
    public String getRawInf();
61

  
62
    public void setRawInf(String rawInf);
63

  
64
    public String getProperty(String group, String name);
65

  
66
    public void setProperty(String group, String name, String value);
67
    
68
    public void setIconNames(String iconName, String iconNameOpen);
69
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/DataFolderFound.java
1
package org.gvsig.scripting;
2

  
3
import java.io.File;
4
import org.gvsig.tools.packageutils.Version;
5

  
6
/**
7
 *
8
 * @author jjdelcerro
9
 */
10
public interface DataFolderFound {
11

  
12
    ScriptingFolder getApplicationFolder();
13

  
14
    String getApplicationName();
15

  
16
    String getDataFolderId();
17

  
18
    File getNewDataFolder();
19

  
20
    File getOldDataFolder();
21

  
22
    Version getOldDataFolderVersion();
23

  
24
    void leave();
25

  
26
    void restore();
27

  
28
}
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.148/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingUnit.java
1
package org.gvsig.scripting;
2

  
3
import java.beans.PropertyChangeListener;
4
import java.io.File;
5
import java.util.List;
6
import java.util.Map;
7

  
8
/**
9
 * <p> Interface that represents the elements used in the ScriptingFramework.</p>
10
 * 
11
 * @see ScriptingBaseScript
12
 * @see ScriptingFolder
13
 */
14
public interface ScriptingUnit {
15
	
16
	/**
17
	 * Returns the ScriptingUnit's ID
18
	 * 
19
	 * @return a String containing the ScriptingUnit's ID
20
	 */
21
	public String getId();
22
	
23
	/**
24
	 * Returns the ScriptingUnit's name
25
	 * 
26
	 * @return a String containing the ScriptingUnit's name
27
	 */
28
	public String getName();
29
	
30
	/**
31
	 * Returns the ScriptingUnit's description
32
	 * 
33
	 * @return a String containing the ScriptingUnit's description
34
	 */
35
	public String getDescription();
36
	
37
	/**
38
	 * Returns information about the ScriptingUnit's creator
39
	 * 
40
	 * @return a String containing the ScriptingUnit's creator
41
	 */
42
	public String getCreatedBy();
43
	
44
	/**
45
	 * Returns the ScriptingUnit's version
46
	 * 
47
	 * @return a String containing the ScriptingUnit's version
48
	 */
49
	public String getVersion();
50
	
51
	/**
52
	 * Returns the ScriptingUnit's parent
53
	 * 
54
	 * @return a {@link ScriptingFolder} where is contained the ScriptingUnit
55
	 */
56
	public ScriptingFolder getParent();
57
	
58
    public String getUserPath();
59
	/**
60
	 * Sets a new name to the ScriptingUnit.
61
	 *
62
	 * @param name
63
	 *            String that contains the new name.
64
	 */
65
	public void setName(String name);
66
	
67
	/**
68
	 * Sets a new description to the ScriptingUnit.
69
	 *
70
	 * @param description
71
	 *            String that contains the new description.
72
	 */
73
	public void setDescription(String description);
74
	
75
	/**
76
	 * Sets a new information about the ScriptingUnit's creator.
77
	 *
78
	 * @param createdBy
79
	 *            String that contains the new creator's information.
80
	 */
81
	public void setCreatedBy(String createdBy);
82
	
83
	/**
84
	 * Sets a new version value to the ScriptingUnit.
85
	 *
86
	 * @param version
87
	 *            String that contains the new version.
88
	 */
89
	public void setVersion(String version);
90
        
91
    public void reload();
92
    
93
	/**
94
	 * Changes the ID of a ScriptingUnit and the name of the files and/or directories associated
95
	 *
96
	 * @param newId
97
	 *            String that contains the new Id.
98
	 *            
99
	 * @return true if it's succesful, false if not.
100
	 */
101
	public boolean rename(String newId);
102
	
103
	public boolean remove();
104
	
105
	/**
106
	 * Moves a ScriptingUnitfrom the current directory to the new location.
107
	 *
108
	 * @param target
109
	 *            {@link ScriptingFolder} that represents the destination..
110
	 *            
111
	 * @return true if it's succesful, false if not.
112
	 */
113
	public boolean move(ScriptingFolder target);
114
	
115
	/**
116
	 * Gets the name of the icons associated to the ScriptingUnit type.
117
	 *            
118
	 * @return a String array with the identificators of the icons associated.
119
	 */
120
	public String[] getIconNames();
121
	
122
	public String getTypeName();
123
	
124
	/**
125
	 * Gets a File with the ScriptUnit path name.
126
	 *
127
	 * @return a string with the path name of the ScriptUnit (inf/folder).
128
	 */
129
	public File getFile();
130
        
131
        /**
132
         * Return a list of the files that use this unit with out the inf file.
133
         * @return list of files of the unit.
134
         */
135
        public List<File> getFiles();
136
        
137
        public void addPropertyChangeListener(PropertyChangeListener listener);
138

  
139
        /**
140
         * Sets the unit current status with the saved version.
141
         *
142
         * @param saved Indicate if the unit is up-to-date or not.
143
         */
144
        public void setSaved(boolean saved);
145
        
146
        /**
147
         * Indicates if the ScriptBaseScript is modified from last saved version.
148
         *
149
         * @return true if current version is up-to-date, false if not.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff