Revision 759
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28/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.28</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.148</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.28</connection> |
|
20 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-scripting/org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28</developerConnection> |
|
21 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-scripting/repository/show/org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28</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.28</version> |
|
90 |
</dependency> |
|
91 |
<dependency> |
|
92 |
<groupId>org.gvsig</groupId> |
|
93 |
<artifactId>org.gvsig.scripting.swing.api</artifactId> |
|
94 |
<version>2.3.28</version> |
|
95 |
</dependency> |
|
96 |
<dependency> |
|
97 |
<groupId>org.gvsig</groupId> |
|
98 |
<artifactId>org.gvsig.scripting.lib.impl</artifactId> |
|
99 |
<version>2.3.28</version> |
|
100 |
</dependency> |
|
101 |
<dependency> |
|
102 |
<groupId>org.gvsig</groupId> |
|
103 |
<artifactId>org.gvsig.scripting.swing.impl</artifactId> |
|
104 |
<version>2.3.28</version> |
|
105 |
</dependency> |
|
106 |
|
|
107 |
<dependency> |
|
108 |
<groupId>org.gvsig</groupId> |
|
109 |
<artifactId>org.gvsig.scripting.main</artifactId> |
|
110 |
<version>2.3.28</version> |
|
111 |
</dependency> |
|
112 |
|
|
113 |
<dependency> |
|
114 |
<groupId>org.gvsig</groupId> |
|
115 |
<artifactId>org.gvsig.scripting.thing</artifactId> |
|
116 |
<version>2.3.28</version> |
|
117 |
</dependency> |
|
118 |
|
|
119 |
<dependency> |
|
120 |
<groupId>org.gvsig</groupId> |
|
121 |
<artifactId>org.gvsig.scripting.app.mainplugin</artifactId> |
|
122 |
<version>2.3.28</version> |
|
123 |
</dependency> |
|
124 |
|
|
125 |
<dependency> |
|
126 |
<groupId>org.renjin</groupId> |
|
127 |
<artifactId>renjin-script-engine</artifactId> |
|
128 |
<version>0.8.1592</version> |
|
129 |
<classifier>jar-with-dependencies</classifier> |
|
130 |
</dependency> |
|
131 |
|
|
132 |
<dependency> |
|
133 |
<groupId>org.scala-lang</groupId> |
|
134 |
<artifactId>scala-dist</artifactId> |
|
135 |
<version>2.12.0-M2</version> |
|
136 |
<scope>runtime</scope> |
|
137 |
<exclusions> |
|
138 |
<exclusion> |
|
139 |
<groupId>org.scala-lang</groupId> |
|
140 |
<artifactId>scala-library-all</artifactId> |
|
141 |
</exclusion> |
|
142 |
</exclusions> |
|
143 |
</dependency> |
|
144 |
<dependency> |
|
145 |
<groupId>org.scala-lang</groupId> |
|
146 |
<artifactId>scala-compiler</artifactId> |
|
147 |
<version>2.12.0-M2</version> |
|
148 |
</dependency> |
|
149 |
<dependency> |
|
150 |
<groupId>org.scala-lang</groupId> |
|
151 |
<artifactId>scala-library</artifactId> |
|
152 |
<version>2.12.0-M2</version> |
|
153 |
</dependency> |
|
154 |
<dependency> |
|
155 |
<groupId>org.scala-lang</groupId> |
|
156 |
<artifactId>scala-reflect</artifactId> |
|
157 |
<version>2.12.0-M2</version> |
|
158 |
</dependency> |
|
159 |
<dependency> |
|
160 |
<groupId>org.scala-lang</groupId> |
|
161 |
<artifactId>scalap</artifactId> |
|
162 |
<version>2.12.0-M2</version> |
|
163 |
</dependency> |
|
164 |
<dependency> |
|
165 |
<groupId>jline</groupId> |
|
166 |
<artifactId>jline</artifactId> |
|
167 |
<version>2.12.1</version> |
|
168 |
</dependency> |
|
169 |
|
|
170 |
<dependency> |
|
171 |
<groupId>com.jeta</groupId> |
|
172 |
<artifactId>abeille</artifactId> |
|
173 |
<version>2.1.0.M3</version> |
|
174 |
<type>tar.gz</type> |
|
175 |
</dependency> |
|
176 |
|
|
177 |
<dependency> |
|
178 |
<groupId>org.apache.tika</groupId> |
|
179 |
<artifactId>tika-core</artifactId> |
|
180 |
<version>1.12</version> |
|
181 |
</dependency> |
|
182 |
<!-- Eliminar para org.gvsig.desktop > 2.0.115 --> |
|
183 |
<dependency> |
|
184 |
<groupId>org.jopendocument</groupId> |
|
185 |
<artifactId>jOpenDocument</artifactId> |
|
186 |
<version>1.3</version> |
|
187 |
</dependency> |
|
188 |
|
|
189 |
<dependency> |
|
190 |
<groupId>net.sf.cssbox</groupId> |
|
191 |
<artifactId>swingbox</artifactId> |
|
192 |
<version>1.1</version> |
|
193 |
</dependency> |
|
194 |
<dependency> |
|
195 |
<groupId>net.sf.cssbox</groupId> |
|
196 |
<artifactId>cssbox</artifactId> |
|
197 |
<version>4.7</version> |
|
198 |
</dependency> |
|
199 |
<dependency> |
|
200 |
<groupId>net.sourceforge.nekohtml</groupId> |
|
201 |
<artifactId>nekohtml</artifactId> |
|
202 |
<version>1.9.21</version> |
|
203 |
</dependency> |
|
204 |
<dependency> |
|
205 |
<groupId>net.sf.cssbox</groupId> |
|
206 |
<artifactId>jstyleparser</artifactId> |
|
207 |
<version>1.18</version> |
|
208 |
</dependency> |
|
209 |
|
|
210 |
</dependencies> |
|
211 |
</dependencyManagement> |
|
212 |
|
|
213 |
<modules> |
|
214 |
<module>org.gvsig.scripting.thing</module> |
|
215 |
<module>org.gvsig.scripting.lib</module> |
|
216 |
<module>org.gvsig.scripting.swing</module> |
|
217 |
<module>org.gvsig.scripting.main</module> |
|
218 |
<module>org.gvsig.scripting.app</module> |
|
219 |
</modules> |
|
220 |
</project> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28/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.28</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.28/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/test/java/org/gvsig/scripting/TestManager.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
import java.util.Set; |
|
8 |
|
|
9 |
import junit.framework.Assert; |
|
10 |
|
|
11 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
12 |
|
|
13 |
public abstract class TestManager extends AbstractLibraryAutoInitTestCase { |
|
14 |
|
|
15 |
protected ScriptingManager manager; |
|
16 |
|
|
17 |
@Override |
|
18 |
protected void doSetUp() throws Exception { |
|
19 |
manager = ScriptingLocator.getManager(); |
|
20 |
} |
|
21 |
|
|
22 |
public void setWorkingFolder(){ |
|
23 |
File file =new File(this.getClass().getClassLoader().getResource("org/gvsig/scripting/home").getFile()); |
|
24 |
// FIXME: hay que sustituirlo por manager.setHomeFolder(home) |
|
25 |
// manager.setRootUserFolder(file.getAbsolutePath()); |
|
26 |
} |
|
27 |
|
|
28 |
public void deleteFolderContent(ScriptingFolder folder){ |
|
29 |
List<ScriptingUnit> units = folder.getUnits(); |
|
30 |
Iterator<ScriptingUnit> it = units.iterator(); |
|
31 |
while(it.hasNext()){ |
|
32 |
ScriptingUnit unit = it.next(); |
|
33 |
if(unit instanceof ScriptingFolder){ |
|
34 |
deleteFolderContent((ScriptingFolder)unit); |
|
35 |
folder.remove(unit); |
|
36 |
}else{ |
|
37 |
folder.remove(unit); |
|
38 |
} |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
public void deleteWorkingFolderContent(){ |
|
43 |
setWorkingFolder(); |
|
44 |
ScriptingFolder folder = manager.getUserFolder(); |
|
45 |
deleteFolderContent(folder); |
|
46 |
} |
|
47 |
|
|
48 |
public void testUserFolderPath(){ |
|
49 |
setWorkingFolder(); |
|
50 |
Assert.assertEquals(manager.getRootUserFolder().getAbsolutePath(), manager.getUserFolder().getFile().getAbsolutePath()); |
|
51 |
} |
|
52 |
|
|
53 |
public void testExistsScriptId(){ |
|
54 |
setWorkingFolder(); |
|
55 |
manager.createUnit(ScriptingManager.UNIT_SCRIPT,manager.getUserFolder(),"test_script.py"); |
|
56 |
|
|
57 |
Assert.assertEquals(false, manager.validateUnitId(manager.getUserFolder(),"test_script")); |
|
58 |
Assert.assertEquals(true, manager.validateUnitId(manager.getUserFolder(),"test_script2")); |
|
59 |
deleteWorkingFolderContent(); |
|
60 |
} |
|
61 |
|
|
62 |
|
|
63 |
public void checkUnitValues(ScriptingUnit unit1, ScriptingUnit unit2){ |
|
64 |
Assert.assertEquals(unit1.getId(),unit2.getId()); |
|
65 |
Assert.assertEquals(unit1.getName(),unit2.getName()); |
|
66 |
} |
|
67 |
|
|
68 |
public void testRegisteringSystemFolders(){ |
|
69 |
ScriptingFolder folder_parent = (ScriptingFolder) manager.createUnit(ScriptingManager.UNIT_FOLDER,manager.getUserFolder(), "test"); |
|
70 |
ScriptingFolder folder = (ScriptingFolder) manager.createUnit(ScriptingManager.UNIT_FOLDER,folder_parent, "test"); |
|
71 |
ScriptingScript script = (ScriptingScript)manager.createUnit(ScriptingManager.UNIT_SCRIPT,folder, "test_script.py"); |
|
72 |
|
|
73 |
manager.registerSystemFolder("test", folder.getFile()); |
|
74 |
|
|
75 |
List<ScriptingUnit> units = manager.getSystemFolder().getUnits(); |
|
76 |
|
|
77 |
Iterator<ScriptingUnit> it = units.iterator(); |
|
78 |
ScriptingUnit unit = null; |
|
79 |
while(it.hasNext()){ |
|
80 |
unit = it.next(); |
|
81 |
checkUnitValues(unit, folder); |
|
82 |
} |
|
83 |
Assert.assertNotNull(unit); |
|
84 |
|
|
85 |
ScriptingScript script2 = (ScriptingScript) manager.getScript(new File(((ScriptingFolder)unit).getFile(),script.getId()+".py")); |
|
86 |
checkUnitValues(script,script2); |
|
87 |
deleteWorkingFolderContent(); |
|
88 |
} |
|
89 |
|
|
90 |
|
|
91 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/test/java/org/gvsig/scripting/TestFolder.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import junit.framework.Assert; |
|
8 |
|
|
9 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
10 |
|
|
11 |
public abstract class TestFolder extends AbstractLibraryAutoInitTestCase { |
|
12 |
|
|
13 |
protected ScriptingManager manager; |
|
14 |
|
|
15 |
@Override |
|
16 |
protected void doSetUp() throws Exception { |
|
17 |
manager = ScriptingLocator.getManager(); |
|
18 |
} |
|
19 |
|
|
20 |
public void setWorkingFolder(){ |
|
21 |
File file =new File(this.getClass().getClassLoader().getResource("org/gvsig/scripting/home").getFile()); |
|
22 |
if(file.exists()){ |
|
23 |
file.mkdir(); |
|
24 |
} |
|
25 |
// FIXME: hay que sustituirlo por manager.setHomeFolder(home) |
|
26 |
// manager.setRootUserFolder(file.getAbsolutePath()); |
|
27 |
} |
|
28 |
|
|
29 |
public void deleteFolderContent(ScriptingFolder folder){ |
|
30 |
List<ScriptingUnit> units = folder.getUnits(); |
|
31 |
Iterator<ScriptingUnit> it = units.iterator(); |
|
32 |
while(it.hasNext()){ |
|
33 |
ScriptingUnit unit = it.next(); |
|
34 |
if(unit instanceof ScriptingFolder){ |
|
35 |
deleteFolderContent((ScriptingFolder)unit); |
|
36 |
folder.remove(unit); |
|
37 |
}else{ |
|
38 |
folder.remove(unit); |
|
39 |
} |
|
40 |
} |
|
41 |
} |
|
42 |
|
|
43 |
public void deleteWorkingFolderContent(){ |
|
44 |
setWorkingFolder(); |
|
45 |
ScriptingFolder folder = manager.getUserFolder(); |
|
46 |
deleteFolderContent(folder); |
|
47 |
} |
|
48 |
|
|
49 |
public File getFile(ScriptingFolder folder, String name){ |
|
50 |
return new File(folder.getFile(),name); |
|
51 |
} |
|
52 |
|
|
53 |
public void checkFolder(ScriptingFolder folder, String fName){ |
|
54 |
File ffolder = getFile(folder, fName); |
|
55 |
Assert.assertTrue(ffolder.exists()); |
|
56 |
Assert.assertTrue(ffolder.isDirectory()); |
|
57 |
} |
|
58 |
|
|
59 |
public void checkScriptDefaultValues(ScriptingScript script){ |
|
60 |
Assert.assertEquals("test_script", script.getId()); |
|
61 |
Assert.assertEquals("test_script", script.getName()); |
|
62 |
Assert.assertEquals("python", script.getLangName()); |
|
63 |
Assert.assertEquals("main", script.getMainName()); |
|
64 |
} |
|
65 |
|
|
66 |
public void testCreation(){ |
|
67 |
deleteWorkingFolderContent(); |
|
68 |
ScriptingFolder folder = (ScriptingFolder) manager.createUnit(ScriptingManager.UNIT_FOLDER,manager.getUserFolder(),"test_folder"); |
|
69 |
|
|
70 |
checkFolder(manager.getUserFolder(),folder.getId()); |
|
71 |
} |
|
72 |
|
|
73 |
public void testList(){ |
|
74 |
testCreation(); |
|
75 |
ScriptingFolder folder = manager.getFolder(getFile(manager.getUserFolder(),"test_folder")); |
|
76 |
|
|
77 |
ScriptingScript script = (ScriptingScript) manager.createUnit(ScriptingManager.UNIT_SCRIPT,folder, "test_script.py"); |
|
78 |
|
|
79 |
List<ScriptingUnit> units = folder.getUnits(); |
|
80 |
Iterator<ScriptingUnit> it = units.iterator(); |
|
81 |
while(it.hasNext()){ |
|
82 |
ScriptingUnit unit = it.next(); |
|
83 |
checkScriptDefaultValues((ScriptingScript) unit); |
|
84 |
} |
|
85 |
|
|
86 |
folder.remove(script); |
|
87 |
Assert.assertTrue(folder.getUnits().isEmpty()); |
|
88 |
} |
|
89 |
|
|
90 |
public void testRename(){ |
|
91 |
testCreation(); |
|
92 |
ScriptingFolder folder = manager.getFolder(getFile(manager.getUserFolder(),"test_folder")); |
|
93 |
|
|
94 |
Assert.assertFalse(folder.rename("test_folder")); |
|
95 |
Assert.assertTrue(folder.rename("test_folder2")); |
|
96 |
|
|
97 |
Assert.assertEquals("test_folder2", folder.getName()); |
|
98 |
deleteWorkingFolderContent(); |
|
99 |
} |
|
100 |
|
|
101 |
public void testMove(){ |
|
102 |
testCreation(); |
|
103 |
ScriptingScript script = (ScriptingScript) manager.createUnit(ScriptingManager.UNIT_SCRIPT,manager.getUserFolder(), "test_script.py"); |
|
104 |
ScriptingFolder folder = manager.getFolder(getFile(manager.getUserFolder(),"test_folder")); |
|
105 |
Assert.assertEquals(script.getParent().getFile().getAbsolutePath(),manager.getUserFolder().getFile().getAbsolutePath()); |
|
106 |
|
|
107 |
folder.add(script); |
|
108 |
Assert.assertEquals(script.getParent(),folder); |
|
109 |
deleteWorkingFolderContent(); |
|
110 |
} |
|
111 |
|
|
112 |
|
|
113 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/test/java/org/gvsig/scripting/TestDialog.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
import java.io.BufferedWriter; |
|
4 |
import java.io.File; |
|
5 |
import java.io.FileWriter; |
|
6 |
import java.io.IOException; |
|
7 |
import java.util.Iterator; |
|
8 |
import java.util.List; |
|
9 |
|
|
10 |
import junit.framework.Assert; |
|
11 |
|
|
12 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
13 |
|
|
14 |
public abstract class TestDialog extends AbstractLibraryAutoInitTestCase { |
|
15 |
|
|
16 |
protected ScriptingManager manager; |
|
17 |
|
|
18 |
@Override |
|
19 |
protected void doSetUp() throws Exception { |
|
20 |
manager = ScriptingLocator.getManager(); |
|
21 |
} |
|
22 |
|
|
23 |
public void setWorkingFolder(){ |
|
24 |
File file =new File(this.getClass().getClassLoader().getResource("org/gvsig/scripting/home").getFile()); |
|
25 |
|
|
26 |
// FIXME: hay que sustituirlo por manager.setHomeFolder(home) |
|
27 |
// manager.setRootUserFolder(file.getAbsolutePath()); |
|
28 |
} |
|
29 |
|
|
30 |
public File getFile(String name){ |
|
31 |
return new File(manager.getRootUserFolder()+File.separator+name); |
|
32 |
} |
|
33 |
|
|
34 |
public void deleteFolderContent(ScriptingFolder folder){ |
|
35 |
List<ScriptingUnit> units = folder.getUnits(); |
|
36 |
Iterator<ScriptingUnit> it = units.iterator(); |
|
37 |
while(it.hasNext()){ |
|
38 |
ScriptingUnit unit = it.next(); |
|
39 |
if(unit instanceof ScriptingFolder){ |
|
40 |
deleteFolderContent((ScriptingFolder)unit); |
|
41 |
folder.remove(unit); |
|
42 |
}else{ |
|
43 |
folder.remove(unit); |
|
44 |
} |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
public void deleteWorkingFolderContent(){ |
|
49 |
setWorkingFolder(); |
|
50 |
ScriptingFolder folder = manager.getUserFolder(); |
|
51 |
deleteFolderContent(folder); |
|
52 |
} |
|
53 |
|
|
54 |
public void checkFile(String fName){ |
|
55 |
File fscript = getFile(fName); |
|
56 |
Assert.assertTrue(fscript.exists()); |
|
57 |
} |
|
58 |
|
|
59 |
public void checkScriptDefaultValues(ScriptingDialog script){ |
|
60 |
Assert.assertEquals("test_dialog", script.getId()); |
|
61 |
Assert.assertEquals("test_dialog", script.getName()); |
|
62 |
Assert.assertEquals("python", script.getLangName()); |
|
63 |
Assert.assertEquals("main", script.getMainName()); |
|
64 |
} |
|
65 |
|
|
66 |
public void checkScriptNewValues(ScriptingDialog script){ |
|
67 |
Assert.assertEquals("test_dialog", script.getId()); |
|
68 |
Assert.assertEquals("TestDialog", script.getName()); |
|
69 |
Assert.assertEquals("Tests sobre dialogs", script.getDescription()); |
|
70 |
Assert.assertEquals("python", script.getLangName()); |
|
71 |
Assert.assertEquals("main", script.getMainName()); |
|
72 |
Assert.assertEquals("creator", script.getCreatedBy()); |
|
73 |
Assert.assertEquals("v1.0", script.getVersion()); |
|
74 |
Assert.assertEquals("def hola():\n return 'hola mundo'\n",script.getCode()); |
|
75 |
} |
|
76 |
|
|
77 |
public void testCreation(){ |
|
78 |
deleteWorkingFolderContent(); |
|
79 |
setWorkingFolder(); |
|
80 |
ScriptingDialog script = (ScriptingDialog) manager.createUnit(ScriptingManager.UNIT_DIALOG,manager.getUserFolder(),"test_dialog.py"); |
|
81 |
|
|
82 |
script.save(); |
|
83 |
checkFile("test_dialog.py"); |
|
84 |
checkFile("test_dialog.dlg"); |
|
85 |
checkFile("test_dialog.inf"); |
|
86 |
|
|
87 |
checkScriptDefaultValues(script); |
|
88 |
} |
|
89 |
|
|
90 |
public void testOpen(){ |
|
91 |
testCreation(); |
|
92 |
ScriptingDialog script = (ScriptingDialog) manager.getScript(getFile("test_dialog.py")); |
|
93 |
|
|
94 |
checkScriptDefaultValues(script); |
|
95 |
deleteWorkingFolderContent(); |
|
96 |
} |
|
97 |
|
|
98 |
public void testSave(){ |
|
99 |
testCreation(); |
|
100 |
ScriptingDialog script = (ScriptingDialog) manager.getScript(getFile("test_dialog.py")); |
|
101 |
|
|
102 |
script.setName("TestDialog"); |
|
103 |
script.setDescription("Tests sobre dialogs"); |
|
104 |
script.setCode("def hola():\n return 'hola mundo'\n"); |
|
105 |
script.setCreatedBy("creator"); |
|
106 |
script.setVersion("v1.0"); |
|
107 |
script.save(); |
|
108 |
|
|
109 |
File f = script.getDialogFile(); |
|
110 |
try { |
|
111 |
BufferedWriter bw = new BufferedWriter(new FileWriter(f)); |
|
112 |
bw.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" + |
|
113 |
"<panel columns=\"1\">\n" + |
|
114 |
"\t<button action=\"hola\" text=\"press\"/>\n" + |
|
115 |
"</panel>"); |
|
116 |
} catch (IOException e) { |
|
117 |
// TODO Auto-generated catch block |
|
118 |
e.printStackTrace(); |
|
119 |
} |
|
120 |
|
|
121 |
script = (ScriptingDialog) manager.getScript(getFile("test_dialog.py")); |
|
122 |
checkScriptNewValues(script); |
|
123 |
|
|
124 |
} |
|
125 |
|
|
126 |
public void testRename(){ |
|
127 |
deleteWorkingFolderContent(); |
|
128 |
testCreation(); |
|
129 |
ScriptingDialog script = (ScriptingDialog) manager.getScript(getFile("test_dialog.py")); |
|
130 |
|
|
131 |
Assert.assertFalse(script.rename("test_dialog")); |
|
132 |
Assert.assertTrue(script.rename("test_dialog2")); |
|
133 |
|
|
134 |
script = (ScriptingDialog) manager.getScript(getFile("test_dialog2.py")); |
|
135 |
Assert.assertEquals("test_dialog2", script.getId()); |
|
136 |
|
|
137 |
File f = getFile("test_dialog.py"); |
|
138 |
Assert.assertFalse(f.exists()); |
|
139 |
f = getFile("test_dialog2.py"); |
|
140 |
Assert.assertTrue(f.exists()); |
|
141 |
|
|
142 |
deleteWorkingFolderContent(); |
|
143 |
} |
|
144 |
|
|
145 |
public void testMove(){ |
|
146 |
testCreation(); |
|
147 |
ScriptingFolder folderDestination = (ScriptingFolder) manager.createUnit(ScriptingManager.UNIT_FOLDER,manager.getUserFolder(), "other folder"); |
|
148 |
checkFile("other folder"); |
|
149 |
ScriptingDialog script = (ScriptingDialog) manager.getScript(getFile("test_dialog.py")); |
|
150 |
|
|
151 |
script.move(folderDestination); |
|
152 |
Assert.assertEquals(script.getParent().getFile().getAbsolutePath(),folderDestination.getFile().getAbsolutePath()); |
|
153 |
deleteWorkingFolderContent(); |
|
154 |
} |
|
155 |
|
|
156 |
public void testRun(){ |
|
157 |
/* testSave(); |
|
158 |
ScriptingDialog script = (ScriptingDialog) manager.getScript(getFile("test_dialog.py")); |
|
159 |
|
|
160 |
Assert.assertEquals("hola mundo", script.run()); |
|
161 |
|
|
162 |
//setMainName |
|
163 |
|
|
164 |
//invokeMethod |
|
165 |
|
|
166 |
//invokeFunction |
|
167 |
deleteWorkingFolderContent();*/ |
|
168 |
} |
|
169 |
|
|
170 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/test/java/org/gvsig/scripting/TestScript.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import junit.framework.Assert; |
|
8 |
|
|
9 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
10 |
|
|
11 |
public abstract class TestScript extends AbstractLibraryAutoInitTestCase { |
|
12 |
|
|
13 |
protected ScriptingManager manager; |
|
14 |
|
|
15 |
@Override |
|
16 |
protected void doSetUp() throws Exception { |
|
17 |
ScriptingLocator locator = new ScriptingLocator(); |
|
18 |
Assert.assertNotNull(locator); |
|
19 |
manager = ScriptingLocator.getManager(); |
|
20 |
Assert.assertNotNull(manager); |
|
21 |
} |
|
22 |
|
|
23 |
public void setWorkingFolder(){ |
|
24 |
File file =new File(this.getClass().getClassLoader().getResource("org/gvsig/scripting/home").getFile()); |
|
25 |
if(file.exists()){ |
|
26 |
file.mkdir(); |
|
27 |
} |
|
28 |
// FIXME: hay que sustituirlo por manager.setHomeFolder(home) |
|
29 |
// manager.setRootUserFolder(file.getAbsolutePath()); |
|
30 |
} |
|
31 |
|
|
32 |
public void deleteFolderContent(ScriptingFolder folder){ |
|
33 |
List<ScriptingUnit> units = folder.getUnits(); |
|
34 |
Iterator<ScriptingUnit> it = units.iterator(); |
|
35 |
while(it.hasNext()){ |
|
36 |
ScriptingUnit unit = it.next(); |
|
37 |
if(unit instanceof ScriptingFolder){ |
|
38 |
deleteFolderContent((ScriptingFolder)unit); |
|
39 |
folder.remove(unit); |
|
40 |
}else{ |
|
41 |
folder.remove(unit); |
|
42 |
} |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
public void deleteWorkingFolderContent(){ |
|
47 |
setWorkingFolder(); |
|
48 |
ScriptingFolder folder = manager.getUserFolder(); |
|
49 |
deleteFolderContent(folder); |
|
50 |
} |
|
51 |
|
|
52 |
public File getFile(ScriptingFolder folder, String name){ |
|
53 |
return new File(folder.getFile(),name); |
|
54 |
} |
|
55 |
|
|
56 |
public void checkFile(ScriptingFolder folder, String fName){ |
|
57 |
File fscript = getFile(folder, fName); |
|
58 |
Assert.assertTrue(fscript.exists()); |
|
59 |
} |
|
60 |
|
|
61 |
public void checkScriptDefaultValues(ScriptingScript script){ |
|
62 |
Assert.assertEquals(manager.getUserFolder().getFile().getAbsolutePath(), script.getParent().getFile().getAbsolutePath()); |
|
63 |
|
|
64 |
Assert.assertEquals("test_script", script.getId()); |
|
65 |
Assert.assertEquals("test_script", script.getName()); |
|
66 |
Assert.assertEquals("python", script.getLangName()); |
|
67 |
Assert.assertEquals("main", script.getMainName()); |
|
68 |
} |
|
69 |
|
|
70 |
public void checkScriptNewValues(ScriptingScript script){ |
|
71 |
Assert.assertEquals("test_script", script.getId()); |
|
72 |
Assert.assertEquals("TestScript", script.getName()); |
|
73 |
Assert.assertEquals("Tests sobre scripts", script.getDescription()); |
|
74 |
Assert.assertEquals("python", script.getLangName()); |
|
75 |
Assert.assertEquals("main", script.getMainName()); |
|
76 |
Assert.assertEquals("creator", script.getCreatedBy()); |
|
77 |
Assert.assertEquals("v1.0", script.getVersion()); |
|
78 |
Assert.assertEquals("def main():\n return 'hola mundo'\n",script.getCode()); |
|
79 |
} |
|
80 |
|
|
81 |
public void testCreation(){ |
|
82 |
setWorkingFolder(); |
|
83 |
ScriptingScript previous = (ScriptingScript) manager.getScript(new File(manager.getRootUserFolder()+File.separator+"test_script.py")); |
|
84 |
if (previous!=null){ |
|
85 |
manager.getUserFolder().remove(previous); |
|
86 |
} |
|
87 |
ScriptingScript script = (ScriptingScript) manager.createUnit(ScriptingManager.UNIT_SCRIPT,manager.getUserFolder(),"test_script.py"); |
|
88 |
|
|
89 |
script.save(); |
|
90 |
|
|
91 |
checkFile(manager.getUserFolder(),"test_script.py"); |
|
92 |
checkFile(manager.getUserFolder(),"test_script.inf"); |
|
93 |
|
|
94 |
checkScriptDefaultValues(script); |
|
95 |
} |
|
96 |
|
|
97 |
public void testOpen(){ |
|
98 |
testCreation(); |
|
99 |
ScriptingScript script = (ScriptingScript) manager.getScript(getFile(manager.getUserFolder(),"test_script.py")); |
|
100 |
|
|
101 |
checkScriptDefaultValues(script); |
|
102 |
deleteWorkingFolderContent(); |
|
103 |
} |
|
104 |
|
|
105 |
public void testSave(){ |
|
106 |
testCreation(); |
|
107 |
ScriptingScript script = (ScriptingScript) manager.getScript(getFile(manager.getUserFolder(),"test_script.py")); |
|
108 |
|
|
109 |
script.setName("TestScript"); |
|
110 |
script.setDescription("Tests sobre scripts"); |
|
111 |
script.setCode("def main():\n return 'hola mundo'\n"); |
|
112 |
script.setCreatedBy("creator"); |
|
113 |
script.setVersion("v1.0"); |
|
114 |
script.save(); |
|
115 |
|
|
116 |
script = (ScriptingScript) manager.getScript(getFile(manager.getUserFolder(),"test_script.py")); |
|
117 |
checkScriptNewValues(script); |
|
118 |
} |
|
119 |
|
|
120 |
public void testRename(){ |
|
121 |
testSave(); |
|
122 |
ScriptingScript script = (ScriptingScript) manager.getScript(getFile(manager.getUserFolder(),"test_script.py")); |
|
123 |
|
|
124 |
Assert.assertFalse(script.rename("test_script")); |
|
125 |
Assert.assertTrue(script.rename("test_script2")); |
|
126 |
|
|
127 |
script = (ScriptingScript) manager.getScript(getFile(manager.getUserFolder(),"test_script2.py")); |
|
128 |
|
|
129 |
Assert.assertEquals("test_script2", script.getId()); |
|
130 |
deleteWorkingFolderContent(); |
|
131 |
} |
|
132 |
|
|
133 |
public void testMove(){ |
|
134 |
setWorkingFolder(); |
|
135 |
ScriptingFolder folderDestination = (ScriptingFolder) manager.createUnit(ScriptingManager.UNIT_FOLDER,manager.getUserFolder(), "other folder"); |
|
136 |
checkFile(manager.getUserFolder(),"other folder"); |
|
137 |
|
|
138 |
ScriptingScript previous = (ScriptingScript) manager.getScript(new File(folderDestination.getFile(),"test_script.py")); |
|
139 |
if (previous!=null){ |
|
140 |
folderDestination.remove(previous); |
|
141 |
} |
|
142 |
|
|
143 |
testSave(); |
|
144 |
ScriptingScript script = (ScriptingScript) manager.getScript(getFile(manager.getUserFolder(),"test_script.py")); |
|
145 |
|
|
146 |
script.move(folderDestination); |
|
147 |
System.out.println(script.getParent() + " " + folderDestination); |
|
148 |
Assert.assertEquals(script.getParent(),folderDestination); |
|
149 |
deleteWorkingFolderContent(); |
|
150 |
} |
|
151 |
|
|
152 |
public void testRun() throws NoSuchMethodException{ |
|
153 |
testSave(); |
|
154 |
ScriptingScript script = (ScriptingScript) manager.getScript(getFile(manager.getUserFolder(),"test_script.py")); |
|
155 |
Assert.assertEquals("hola mundo", script.run()); |
|
156 |
|
|
157 |
script.setCode("def hola():\n return 'hola mundo'\n"); |
|
158 |
//setMainName |
|
159 |
script.setMainName("hola"); |
|
160 |
Assert.assertEquals("hola mundo", script.run()); |
|
161 |
|
|
162 |
//invokeMethod |
|
163 |
|
|
164 |
//invokeFunction |
|
165 |
Assert.assertEquals("hola mundo", script.invokeFunction("hola", null)); |
|
166 |
deleteWorkingFolderContent(); |
|
167 |
|
|
168 |
} |
|
169 |
|
|
170 |
|
|
171 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/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.28/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/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.28/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/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.28/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 |
|
|
7 |
/** |
|
8 |
* <p> Interface that represents the elements used in the ScriptingFramework.</p> |
|
9 |
* |
|
10 |
* @see ScriptingBaseScript |
|
11 |
* @see ScriptingFolder |
|
12 |
*/ |
|
13 |
public interface ScriptingUnit { |
|
14 |
|
|
15 |
/** |
|
16 |
* Returns the ScriptingUnit's ID |
|
17 |
* |
|
18 |
* @return a String containing the ScriptingUnit's ID |
|
19 |
*/ |
|
20 |
public String getId(); |
|
21 |
|
|
22 |
/** |
|
23 |
* Returns the ScriptingUnit's name |
|
24 |
* |
|
25 |
* @return a String containing the ScriptingUnit's name |
|
26 |
*/ |
|
27 |
public String getName(); |
|
28 |
|
|
29 |
/** |
|
30 |
* Returns the ScriptingUnit's description |
|
31 |
* |
|
32 |
* @return a String containing the ScriptingUnit's description |
|
33 |
*/ |
|
34 |
public String getDescription(); |
|
35 |
|
|
36 |
/** |
|
37 |
* Returns information about the ScriptingUnit's creator |
|
38 |
* |
|
39 |
* @return a String containing the ScriptingUnit's creator |
|
40 |
*/ |
|
41 |
public String getCreatedBy(); |
|
42 |
|
|
43 |
/** |
|
44 |
* Returns the ScriptingUnit's version |
|
45 |
* |
|
46 |
* @return a String containing the ScriptingUnit's version |
|
47 |
*/ |
|
48 |
public String getVersion(); |
|
49 |
|
|
50 |
/** |
|
51 |
* Returns the ScriptingUnit's parent |
|
52 |
* |
|
53 |
* @return a {@link ScriptingFolder} where is contained the ScriptingUnit |
|
54 |
*/ |
|
55 |
public ScriptingFolder getParent(); |
|
56 |
|
|
57 |
/** |
|
58 |
* Sets a new name to the ScriptingUnit. |
|
59 |
* |
|
60 |
* @param name |
|
61 |
* String that contains the new name. |
|
62 |
*/ |
|
63 |
public void setName(String name); |
|
64 |
|
|
65 |
/** |
|
66 |
* Sets a new description to the ScriptingUnit. |
|
67 |
* |
|
68 |
* @param description |
|
69 |
* String that contains the new description. |
|
70 |
*/ |
|
71 |
public void setDescription(String description); |
|
72 |
|
|
73 |
/** |
|
74 |
* Sets a new information about the ScriptingUnit's creator. |
|
75 |
* |
|
76 |
* @param createdBy |
|
77 |
* String that contains the new creator's information. |
|
78 |
*/ |
|
79 |
public void setCreatedBy(String createdBy); |
|
80 |
|
|
81 |
/** |
|
82 |
* Sets a new version value to the ScriptingUnit. |
|
83 |
* |
|
84 |
* @param version |
|
85 |
* String that contains the new version. |
|
86 |
*/ |
|
87 |
public void setVersion(String version); |
|
88 |
|
|
89 |
/** |
|
90 |
* Changes the ID of a ScriptingUnit and the name of the files and/or directories associated |
|
91 |
* |
|
92 |
* @param newId |
|
93 |
* String that contains the new Id. |
|
94 |
* |
|
95 |
* @return true if it's succesful, false if not. |
|
96 |
*/ |
|
97 |
public boolean rename(String newId); |
|
98 |
|
|
99 |
public boolean remove(); |
|
100 |
|
|
101 |
/** |
|
102 |
* Moves a ScriptingUnitfrom the current directory to the new location. |
|
103 |
* |
|
104 |
* @param target |
|
105 |
* {@link ScriptingFolder} that represents the destination.. |
|
106 |
* |
|
107 |
* @return true if it's succesful, false if not. |
|
108 |
*/ |
|
109 |
public boolean move(ScriptingFolder target); |
|
110 |
|
|
111 |
/** |
|
112 |
* Gets the name of the icons associated to the ScriptingUnit type. |
|
113 |
* |
|
114 |
* @return a String array with the identificators of the icons associated. |
|
115 |
*/ |
|
116 |
public String[] getIconNames(); |
|
117 |
|
|
118 |
public String getTypeName(); |
|
119 |
|
|
120 |
/** |
|
121 |
* Gets a File with the ScriptUnit path name. |
|
122 |
* |
|
123 |
* @return a string with the path name of the ScriptUnit (inf/folder). |
|
124 |
*/ |
|
125 |
public File getFile(); |
|
126 |
|
|
127 |
/** |
|
128 |
* Return a list of the files that use this unit with out the inf file. |
|
129 |
* @return list of files of the unit. |
|
130 |
*/ |
|
131 |
public List<File> getFiles(); |
|
132 |
|
|
133 |
public void addPropertyChangeListener(PropertyChangeListener listener); |
|
134 |
|
|
135 |
/** |
|
136 |
* Sets the unit current status with the saved version. |
|
137 |
* |
|
138 |
* @param saved Indicate if the unit is up-to-date or not. |
|
139 |
*/ |
|
140 |
public void setSaved(boolean saved); |
|
141 |
|
|
142 |
/** |
|
143 |
* Indicates if the ScriptBaseScript is modified from last saved version. |
|
144 |
* |
|
145 |
* @return true if current version is up-to-date, false if not. |
|
146 |
*/ |
|
147 |
public boolean isSaved(); |
|
148 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28/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.28/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingHelpManager.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
import java.util.Iterator; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
import javax.help.HelpSet; |
|
10 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
11 |
|
|
12 |
/** |
|
13 |
* This class is responsable of the management of the Help services provided to |
|
14 |
* the application. |
|
15 |
* It shows all the methods applied to the JavaDocs imported on the |
|
16 |
* ScriptingFramework |
|
17 |
* |
|
18 |
* @see ScriptingManager |
|
19 |
*/ |
|
20 |
public interface ScriptingHelpManager { |
|
21 |
|
|
22 |
public URL makeURL(File helpsetfolder, URL sourceurl); |
|
23 |
|
|
24 |
// /** |
|
25 |
// * Interface that represents each JavaDoc imported to the application |
|
26 |
// * |
|
27 |
// */ |
|
28 |
// public interface ScriptingHelpAPI { |
|
29 |
// |
|
30 |
// /** |
|
31 |
// * Gets the JavaDoc's identificator |
|
32 |
// * |
|
33 |
// * @return a String with the name of the JavaDoc imported identificator |
|
34 |
// */ |
|
35 |
// public String getName(); |
|
36 |
// } |
|
37 |
|
|
38 |
/** |
|
39 |
* Interface that represents a class contained on the JavaDocs |
|
40 |
* |
|
41 |
*/ |
|
42 |
public interface ScriptingHelpClass extends Comparable { |
|
43 |
|
|
44 |
/** |
|
45 |
* Gets the name of the class |
|
46 |
* |
|
47 |
* @return a String with the Class' name |
|
48 |
*/ |
|
49 |
public String getName(); |
|
50 |
|
|
51 |
/** |
|
52 |
* Gets the URL of the resource that contains the JavaDoc of this class |
|
53 |
* |
|
54 |
* @return a String with the URL. |
|
55 |
*/ |
|
56 |
public String getUrl(); |
|
57 |
|
|
58 |
public void addMethod(String name); |
|
59 |
|
|
60 |
public List<String> getMethods(); |
|
61 |
|
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Interface that represents a method implemented by a class of the JavaDoc |
|
66 |
* |
|
67 |
*/ |
|
68 |
public interface ScriptingHelpMethod extends Iterable<ScriptingHelpClass> { |
|
69 |
|
|
70 |
/** |
|
71 |
* Gets the method's name |
|
72 |
* |
|
73 |
* @return a String with the method's name |
|
74 |
*/ |
|
75 |
public String getName(); |
|
76 |
|
|
77 |
/** |
|
78 |
* Gets an Iterator of the {@link ScriptingHelpClass}es which implements |
|
79 |
* that method |
|
80 |
* |
|
81 |
*/ |
|
82 |
@Override |
|
83 |
public Iterator<ScriptingHelpClass> iterator(); |
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
// /** |
|
88 |
// * Returns the folder list of the Help's content |
|
89 |
// * |
|
90 |
// * @return list of folders |
|
91 |
// */ |
|
92 |
// public List<File> getHelpRoots(); |
|
93 |
// |
|
94 |
|
|
95 |
/** |
|
96 |
* Gets a List of all the {@link ScriptingHelpMethod}s contained on the |
|
97 |
* JavaDocs |
|
98 |
* |
|
99 |
* @return a List of the {@link ScriptingHelpMethod}s on all the |
|
100 |
* {@link ScriptingHelpAPI}s imported |
|
101 |
*/ |
|
102 |
public List<ScriptingHelpMethod> getMethods(); |
|
103 |
|
|
104 |
public void addMethods(URL methodsfile); |
|
105 |
|
|
106 |
/** |
|
107 |
* Gets the methods of all the classes includes on the JavaDocs which |
|
108 |
* matches with the text provided |
|
109 |
* |
|
110 |
* |
|
111 |
* @param text |
|
112 |
* @return a HashMap with the references founded |
|
113 |
* |
|
114 |
*/ |
|
115 |
public Map<String, ScriptingHelpMethod> findMethods(String text); |
|
116 |
|
|
117 |
/** |
|
118 |
* Returns the HelpSet with the Help information of the JavaDocs registered |
|
119 |
* |
|
120 |
* @return a HelpSet with the Help content |
|
121 |
*/ |
|
122 |
public HelpSet getHelpSet(); |
|
123 |
|
|
124 |
/** |
|
125 |
* Reloads the Help information of the JavaDocs |
|
126 |
* |
|
127 |
*/ |
|
128 |
public void reloadHelp(); |
|
129 |
|
|
130 |
/** |
|
131 |
* Removes a help module from the application's helpset |
|
132 |
* |
|
133 |
* @param name |
|
134 |
* String with the identificator of the module help to remove |
|
135 |
* @return |
|
136 |
* |
|
137 |
*/ |
|
138 |
public boolean removeHelp(String name); |
|
139 |
|
|
140 |
/** |
|
141 |
* Checks if exists a help module from the application's helpset with the |
|
142 |
* same identificator |
|
143 |
* |
|
144 |
* @param name |
|
145 |
* String with the identificator of the module help to check |
|
146 |
* |
|
147 |
* @return true if exists, false if not |
|
148 |
* |
|
149 |
*/ |
|
150 |
public boolean existsHelp(String name); |
|
151 |
|
|
152 |
/** |
|
153 |
* Adds a new help module to the application's helpset with the |
|
154 |
* identificator specified |
|
155 |
* |
|
156 |
* @param name |
|
157 |
* String with the identificator of the module help to add |
|
158 |
* @param javadocFolder |
|
159 |
* @param status |
|
160 |
* @return |
|
161 |
* |
|
162 |
*/ |
|
163 |
public boolean importJavadoc(String name, File javadocFolder, SimpleTaskStatus status); |
|
164 |
|
|
165 |
public ScriptingHelpClass getHelpClass(String name); |
|
166 |
|
|
167 |
public List<ScriptingHelpClass> getHelpClasses(); |
|
168 |
|
|
169 |
public List<File> getHelpRoots(); |
|
170 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28/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.28/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.28/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/HelpConfig.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.scripting; |
|
3 |
|
|
4 |
import java.io.File; |
|
5 |
import java.io.Writer; |
|
6 |
import java.net.URL; |
|
7 |
import javax.help.HelpSet; |
|
8 |
|
|
9 |
|
|
10 |
public interface HelpConfig { |
|
11 |
String FILENAME_DOCS = "docs"; |
|
12 |
String FILENAME_HELPINDEX = "help-index.xml"; |
|
13 |
String FILENAME_HELPMAPPING = "help.jhm"; |
|
14 |
String FILENAME_HELPSET = "help.hs"; |
|
15 |
String FILENAME_HELPTOC = "help-toc.xml"; |
|
16 |
String FILENAME_HELP_CONFIG = "help.cfg"; |
|
17 |
String FILENAME_INDEXER_CONFIG = "help-indexer.cfg"; |
|
18 |
String FILENAME_SEARCHDB = "searchdb"; |
|
19 |
|
|
20 |
boolean create(File folder, String name); |
|
21 |
|
|
22 |
boolean create(File folder, String name, File docsFolder); |
|
23 |
|
|
24 |
boolean create(File folder, File docsFolder); |
|
25 |
|
|
26 |
HelpSet createHelpSet(); |
|
27 |
|
|
28 |
boolean exists(File folder); |
|
29 |
|
|
30 |
File getDocsFolder(); |
|
31 |
|
|
32 |
URL getDocsUrl(); |
|
33 |
|
|
34 |
File getFolder(); |
|
35 |
|
|
36 |
File getHelpConfig(); |
|
37 |
|
|
38 |
File getHelpIndex(); |
|
39 |
|
|
40 |
Writer getHelpIndexWriter(); |
|
41 |
|
|
42 |
File getHelpMapping(); |
|
43 |
|
|
44 |
Writer getHelpMappingWriter(); |
|
45 |
|
|
46 |
File getHelpSet(); |
|
47 |
|
|
48 |
Writer getHelpSetWriter(); |
|
49 |
|
|
50 |
File getIndexerConfig(); |
|
51 |
|
|
52 |
ClassLoader getLoader(); |
|
53 |
|
|
54 |
String getName(); |
|
55 |
|
|
56 |
File getSearchdb(); |
|
57 |
|
|
58 |
File getTOC(); |
|
59 |
|
|
60 |
Writer getTOCWriter(); |
|
61 |
|
|
62 |
boolean load(File folder); |
|
63 |
|
|
64 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.28/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.28/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[]); |
Also available in: Unified diff