Revision 164

View differences:

trunk/org.gvsig.scripting/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.
trunk/org.gvsig.scripting/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>
trunk/org.gvsig.scripting/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.
trunk/org.gvsig.scripting/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>
trunk/org.gvsig.scripting/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
trunk/org.gvsig.scripting/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
trunk/org.gvsig.scripting/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
trunk/org.gvsig.scripting/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>
trunk/org.gvsig.scripting/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.
trunk/org.gvsig.scripting/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.Map;
5

  
6
/**
7
 * There are two top level management roles within ScriptingFramework: logical and User's Interface (UI) management.
8
 *
9
 * This class is responsible of the logical role. It provides all the services to manage the information used in ScriptingFramework. 
10
 *
11
 * @see ScriptingUIManager
12
 *
13
 */
14
public interface ScriptingManager {
15
	
16
	/**
17
	 * Returns the System's Folder
18
	 * 
19
	 * @return a {@link ScriptingFolder} with the System's Folder.
20
	 */
21
	public ScriptingFolder getSystemFolder();
22
	
23
	/**
24
	 * Returns the User's Folder
25
	 * 
26
	 * @return a {@link ScriptingFolder} with the User's Folder.
27
	 */
28
	public ScriptingFolder getUserFolder();
29
	
30
	/**
31
	 * Creates a new instance of {@link ScriptingScript} named as the id and in the directory specified
32
	 * 
33
	 * @param folder {@link ScriptingFolder} with the destiny directory information
34
	 * @param id String with the identificator of the {@link ScriptingScript} created
35
	 * 
36
	 * @return the new {@link ScriptingScript}
37
	 */
38
	public ScriptingScript createScript(ScriptingFolder folder, String id);
39
	
40
	/**
41
	 * Creates a new instance of {@link ScriptingProject} named as the id and in the directory specified
42
	 * 
43
	 * @param folder {@link ScriptingFolder} with the destiny directory information
44
	 * @param id String with the identificator of the {@link ScriptingProject} created
45
	 * 
46
	 * @return the new {@link ScriptingProject}
47
	 */
48
	public ScriptingProject createProject(ScriptingFolder folder, String id);
49
	
50
	/**
51
	 * Creates a new instance of {@link ScriptingDialog} named as the id and in the directory specified
52
	 * 
53
	 * @param folder {@link ScriptingFolder} with the destiny directory information
54
	 * @param id String with the identificator of the {@link ScriptingDialog} created
55
	 * 
56
	 * @return the new {@link ScriptingDialog}
57
	 */
58
	public ScriptingDialog createDialog(ScriptingFolder folder, String id);
59
	
60
	/**
61
	 * Creates a new instance of {@link ScriptingFolder} named as the id and in the directory specified
62
	 * 
63
	 * @param folder {@link ScriptingFolder} with the destiny directory information
64
	 * @param id String with the identificator of the {@link ScriptingFolder} created
65
	 * 
66
	 * @return the new {@link ScriptingFolder}
67
	 */
68
	public ScriptingFolder createFolder(ScriptingFolder folder, String id);
69
	
70
	/**
71
	 * Returns the {@link ScriptingBaseScript} associated with the file specified
72
	 * 
73
	 * @param file File where is contained the {@link ScriptingBaseScript}'s information
74
	 * 
75
	 * @return {@link ScriptingBaseScript}
76
	 */
77
    public ScriptingBaseScript getScript(File file);
78
    
79
	/**
80
	 * Returns the {@link ScriptingFolder} associated with the file specified
81
	 * 
82
	 * @param file File where is contained the {@link ScriptingFolder}'s information
83
	 * 
84
	 * @return {@link ScriptingFolder}
85
	 */
86
    public ScriptingFolder getFolder(File file);
87
    
88
	/**
89
	 * Returns the path of the User's Folder
90
	 * 
91
	 * @return a String with the path of the User's Folder 
92
	 */
93
    public String getRootUserFolder();
94
    
95
	/**
96
	 * Registers a File System with {@link ScriptingUnit}s in the SystemFolder
97
	 * 
98
	 * @param name String with the identificator name of the File System registered
99
	 * @param folder File with the root of the File System to register
100
	 */
101
    public void registerSystemFolder(String name, File folder);
102
    
103
	/**
104
	 * Gets all the supported Language by their extensions associated with each one.
105
	 * 
106
	 * @return a Map with the pairs <key,value> where the key is a String with the extension and the value is the Languange associated
107
	 */
108
    public Map getSupportedLanguagesByExtension();
109
    
110
	/**
111
	 * Gets all the supported Language and the extensions associated with each one.
112
	 * 
113
	 * @return a Map with the pairs <key,value> where the key is a String with the Languange and the value is the extension associated
114
	 */
115
	public Map getExtensionsByLanguages();
116
	
117
	/**
118
	 * Checks if an id is unique in a determinate folder
119
	 * 
120
	 * @param folder {@ScriptingFolder} with the directory to verify the id
121
	 * @param id String with the id to validate
122
	 * 
123
	 * @return true if there isn't another {@link ScriptingUnit} with the same id, and false in the other case
124
	 */
125
	public boolean validateUnitId(ScriptingFolder folder, String id);
126
	
127

  
128
	/**
129
	 * Sets a key/value pair in the state of the ScriptingManager that may
130
	 *  either create a Java Language Binding to be used in the 
131
	 *  execution of scripts
132
	 * 
133
	 * @param key The name of named value to add
134
	 * @param value The value of named value to add. 
135
	 */
136
	public void put(String key, Object value);
137
	
138
	/**
139
	 * Retrieves a value set in the state of this ScriptingManager
140
	 * 
141
	 * @param key The key whose value is to be returned 
142
	 * @return
143
	 */
144
	public Object get(String key);
145
	
146
	public ScriptingHelpManager getHelpManager();
147

  
148
	
149
}
trunk/org.gvsig.scripting/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.util.List;
5

  
6
/**
7
 * <p> Interface that represents a directory in the ScriptingFramework.</p>
8
 * 
9
 * @see ScriptingUnit
10
 */
11
public interface ScriptingFolder  extends ScriptingUnit{
12

  
13
	/**
14
	 * Adds a {@link ScriptingUnit} to the ScriptingFolder.
15
	 *
16
	 * @param unit
17
	 *            {@link ScriptingUnit} to include.
18
	 */
19
	public void add(ScriptingUnit unit);
20
	
21
	/**
22
	 * Removes a {@link ScriptingUnit} from the ScriptingFolder.
23
	 *
24
	 * @param unit
25
	 *            {@link ScriptingUnit} to delete.
26
	 */
27
	public void remove(ScriptingUnit unit);
28
	
29
	/**
30
	 * Returns the {@link ScriptingUnit} associated with a File.
31
	 *
32
	 * @param file
33
	 *            File of the data origin.
34
	 *            
35
	 * @return a {@link ScriptingUnit} with the content extracted from the file.
36
	 */
37
	public ScriptingUnit getUnit(File file);
38
	
39
	/**
40
	 * Gets all the {@link ScriptingUnit}s contained in a ScriptingFolder.
41
	 *            
42
	 * @return a List with the {@link ScriptingUnit}s.
43
	 *
44
	 */
45
	public List getUnits();
46
	
47
	/**
48
	 * Gets the path of the ScriptingFolder.
49
	 *            
50
	 * @return a String with the ScriptingFolder's path.
51
	 *
52
	 */
53
	public String getPath();
54
	
55
}
trunk/org.gvsig.scripting/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>
trunk/org.gvsig.scripting/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 org.gvsig.tools.observer.WeakReferencingObservable;
4

  
5
/**
6
 * <p> Interface that represents Scripting elements.</p>
7
 * 
8
 * @see ScriptingUnit
9
 *
10
 * @see ScriptingScript
11
 * @see ScriptingDialog
12
 * @see ScriptingProject
13
 */
14
public interface ScriptingBaseScript extends ScriptingUnit, WeakReferencingObservable{
15
	
16
	/**
17
	 * Gets a String with the ScriptBaseScript's file path.
18
	 *
19
	 * @return a string with the path of the ScriptBaseScript main file path.
20
	 */
21
	public String getPath();
22
	
23
	/**
24
	 * Executes the code of a ScriptBaseScript.
25
	 * 
26
	 */
27
	public void run();
28
	
29
	/**
30
	 * Executes the code of a ScriptBaseScript.
31
	 * 
32
	 * @param args
33
	 * 			Contains the input parameters to run the ScriptBaseScript.   
34
	 */
35
	public void run(Object args[]);
36
	
37
	/**
38
	 * Sets the ScriptBaseScript's current status with the saved version.
39
	 *
40
	 * @param saved 
41
	 * 			Indicate if the ScriptBaseScript is up-to-date or not.
42
	 */
43
	public void setSaved(boolean saved);
44
	
45
	/**
46
	 * Indicates if the ScriptBaseScript is modified from last saved version.
47
	 * 
48
	 * @return true if current version is up-to-date, false if not.
49
	 */
50
	public boolean isSaved();
51

  
52
}
trunk/org.gvsig.scripting/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 ScriptingBaseScript{
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
}
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingUnit.java
1
package org.gvsig.scripting;
2

  
3
/**
4
 * <p> Interface that represents the elements used in the ScriptingFramework.</p>
5
 * 
6
 * @see ScriptingBaseScript
7
 * @see ScriptingFolder
8
 */
9
public interface ScriptingUnit {
10
	
11
	/**
12
	 * Returns the ScriptingUnit's ID
13
	 * 
14
	 * @return a String containing the ScriptingUnit's ID
15
	 */
16
	public String getId();
17
	
18
	/**
19
	 * Returns the ScriptingUnit's name
20
	 * 
21
	 * @return a String containing the ScriptingUnit's name
22
	 */
23
	public String getName();
24
	
25
	/**
26
	 * Returns the ScriptingUnit's description
27
	 * 
28
	 * @return a String containing the ScriptingUnit's description
29
	 */
30
	public String getDescription();
31
	
32
	/**
33
	 * Returns information about the ScriptingUnit's creator
34
	 * 
35
	 * @return a String containing the ScriptingUnit's creator
36
	 */
37
	public String getCreatedBy();
38
	
39
	/**
40
	 * Returns the ScriptingUnit's version
41
	 * 
42
	 * @return a String containing the ScriptingUnit's version
43
	 */
44
	public String getVersion();
45
	
46
	/**
47
	 * Returns the ScriptingUnit's parent
48
	 * 
49
	 * @return a {@link ScriptingFolder} where is contained the ScriptingUnit
50
	 */
51
	public ScriptingFolder getParent();
52
	
53
	/**
54
	 * Sets a new name to the ScriptingUnit.
55
	 *
56
	 * @param name
57
	 *            String that contains the new name.
58
	 */
59
	public void setName(String name);
60
	
61
	/**
62
	 * Sets a new description to the ScriptingUnit.
63
	 *
64
	 * @param description
65
	 *            String that contains the new description.
66
	 */
67
	public void setDescription(String description);
68
	
69
	/**
70
	 * Sets a new information about the ScriptingUnit's creator.
71
	 *
72
	 * @param createdBy
73
	 *            String that contains the new creator's information.
74
	 */
75
	public void setCreatedBy(String createdBy);
76
	
77
	/**
78
	 * Sets a new version value to the ScriptingUnit.
79
	 *
80
	 * @param version
81
	 *            String that contains the new version.
82
	 */
83
	public void setVersion(String version);
84
	
85
	/**
86
	 * Changes the ID of a ScriptingUnit and the name of the files and/or directories associated
87
	 *
88
	 * @param newId
89
	 *            String that contains the new Id.
90
	 *            
91
	 * @return true if it's succesful, false if not.
92
	 */
93
	public boolean rename(String newId);
94
	
95
	/**
96
	 * Moves a ScriptingUnitfrom the current directory to the new location.
97
	 *
98
	 * @param target
99
	 *            {@link ScriptingFolder} that represents the destination..
100
	 *            
101
	 * @return true if it's succesful, false if not.
102
	 */
103
	public boolean move(ScriptingFolder target);
104
	
105
	/**
106
	 * Gets the name of the icons associated to the ScriptingUnit type.
107
	 *            
108
	 * @return a String array with the identificators of the icons associated.
109
	 */
110
	public String[] getIconNames();
111
}
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/WindowManager.java
1
package org.gvsig.scripting;
2

  
3
import javax.swing.JPanel;
4

  
5
/**
6
 * Interface to manage the windows properties of the application
7
 *
8
 * @see ScriptingUIManager
9
 */
10
public interface WindowManager {
11
	
12
	public static final int MODE_DIALOG = 1;
13
	public static final int MODE_WINDOW = 2;
14
	public static final int MODE_TOOL = 3;
15
	
16
	/**
17
	 * Inserts a Panel in a window with a characteristic properties
18
	 * 
19
	 * @param panel JPanel with the content of the window
20
	 * @param title String with the title of the window
21
	 * @param mode int that defines the type of window
22
	 */
23
	public void showWindow(JPanel panel, String title, int mode);
24

  
25
}
trunk/org.gvsig.scripting/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

  
11
public interface ScriptingHelpManager {
12
	
13
	public interface ScriptingHelpAPI{
14
		public String getName();
15
	}
16

  
17
	public interface ScriptingHelpClass{
18
		public String getName();
19
		
20
		public String getUrl();
21
	}
22
	
23
	public interface ScriptingHelpMethod extends Iterable{
24
		public String getName();
25
		
26
		public Iterator<ScriptingHelpClass> iterator();
27

  
28
	}
29
	
30
	/**
31
	 * Returns the directory of the Help's content
32
	 * 
33
	 * @return a File with the Help's Folder 
34
	 */
35
	public File getFolder();
36
	
37
	public List<ScriptingHelpAPI> getAPI();
38
	
39
	public List<ScriptingHelpMethod> getMethods();
40
	
41
	/**
42
	 * Gets the methods of all the classes includes on the JavaDocs which matches with a text
43
	 * 
44
	 * @parama text String with the text to get the methods that contains it
45
	 * 
46
	 * @return a HashMap with the references founded
47
	 * 
48
	 */
49
	public Map<String,ScriptingHelpMethod> findMethods(String text);
50
	
51
	/**
52
	 * Returns the HelpSet with the Help information of the JavaDocs registered
53
	 * 
54
	 * @return a HelpSet with the Help content
55
	 */
56
	public HelpSet getHelpSet();
57
	
58
	/**
59
	 * Reloads the Help information of the JavaDocs
60
	 * 
61
	 */
62
	public void reloadHelp();
63

  
64
	/**
65
	 * Removes a help module from the application's helpset
66
	 * 
67
	 * @param name String with the identificator of the module help to remove
68
	 * 
69
	 */
70
	public void removeHelp(String name);
71
	
72
	/**
73
	 * Checks if exists a help module from the application's helpset with the same identificator
74
	 * 
75
	 * @param name String with the identificator of the module help to check
76
	 * 
77
	 * @return true if exists, false if not
78
	 * 
79
	 */
80
	public boolean existsHelp(String name);
81
	
82
	/**
83
	 * Adds a new help module to the application's helpset with the identificator specified
84
	 * 
85
	 * @param name String with the identificator of the module help to add
86
	 * @param url URL with the root directory of the help to import 
87
	 * 
88
	 * @return true if exists, false if not
89
	 * 
90
	 */
91
	public void importHelp(String name, URL url);
92
		
93
}
trunk/org.gvsig.scripting/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
	public String getLocatorName() {
35
		return LOCATOR_NAME;
36
	}
37

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

  
51
	/**
52
	 * Registers the Class implementing the PersistenceManager interface.
53
	 *
54
	 * @param clazz
55
	 *            implementing the PersistenceManager interface
56
	 */
57
	public static void registerManager(Class clazz) {
58
		getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
59
	}
60
	
61
}
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingLibrary.java
1
package org.gvsig.scripting;
2

  
3

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

  
7
public class ScriptingLibrary extends AbstractLibrary{
8
	
9
	@Override
10
	protected void doInitialize() throws LibraryException {
11
		//ScriptingLocator.registerManager(DefaultScriptingManager.class);
12
		
13
	}
14

  
15
	@Override
16
	protected void doPostInitialize() throws LibraryException {
17
		// TODO Auto-generated method stub
18
		
19
	}
20
	
21

  
22
}
trunk/org.gvsig.scripting/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 java.awt.event.ActionListener;
4

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

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

  
20
	/**
21
	 * Returns the ScriptingScript's code.
22
	 * 
23
	 * @return a String with the code of the script.
24
	 */
25
	public String getCode();
26

  
27
	/**
28
	 * Sets a the code associated with a ScriptingScript.
29
	 *
30
	 * @param code
31
	 *            String that contains the new code.
32
	 */
33
	public void setCode(String code);
34

  
35
	/**
36
	 * Returns the name of the main function in the ScriptingScript's code
37
	 * 
38
	 * @return a String with main function (default main name is 'main').
39
	 */
40
	public String getMainName();
41

  
42
	/**
43
	 * Establishes a new main main function in the ScriptingScript's code.
44
	 *
45
	 * @param mainName
46
	 *            String that contains the new main function name.
47
	 */
48
	public void setMainName(String mainName);
49

  
50
	/**
51
	 * Persists the current status of a ScriptingScript with the content associated.
52
	 */
53
	public void save();
54
	
55
	
56
	public Object invokeMethod(Object obj, String name, Object[] args) throws NoSuchMethodException;
57
	
58
	public Object invokeFunction(String name, Object[] args) throws NoSuchMethodException;
59
	
60
}
trunk/org.gvsig.scripting/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
}
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/src/main/java/org/gvsig/scripting/ScriptingProject.java
1
package org.gvsig.scripting;
2

  
3
/**
4
 * <p> Interface that represents a set of {@link ScriptingBaseScript}.</p>
5
 * 
6
 * @see ScriptingUnit
7
 * @see ScriptingBaseScript
8
 */
9
public interface ScriptingProject  extends ScriptingBaseScript {
10

  
11
}
trunk/org.gvsig.scripting/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"
3
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4
		 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5

  
6
	<modelVersion>4.0.0</modelVersion>
7
	<groupId>org.gvsig</groupId>
8
	<artifactId>org.gvsig.scripting.lib.api</artifactId>
9
	<packaging>jar</packaging>
10
	<version>1.0-SNAPSHOT</version>
11
	<name>org.gvsig.scripting.lib.api</name>
12
	<description>[PUT LIBRARY DESCRIPTION HERE]</description>
13
	<url>http://www.gvsig.org</url>
14
	<parent>
15
		<groupId>org.gvsig</groupId>
16
		<artifactId>org.gvsig.scripting.lib</artifactId>
17
		<version>1.0-SNAPSHOT</version>
18
	</parent>
19
	<scm>
20
		<connection>scm:svn:http://subversion.gvsig.org/gvSIG/branches/v2_0_0_prep/libraries/org.gvsig.scripting</connection>
21
		<developerConnection>scm:svn:https://gvsig.org/svn/gvSIG/branches/v2_0_0_prep/libraries/org.gvsig.scripting</developerConnection>
22
		<url>http://subversion.gvsig.org/viewvc/?root=gvSIG</url>
23
		<tag>HEAD</tag>
24
	</scm>
25
	<properties>
26
		<build-dir>${basedir}/../../../build</build-dir>
27
	</properties>
28
	<developers>
29
		<developer>
30
			<id>developer1</id>
31
			<name>Name Surname</name>
32
			<email>name@domain</email>
33
			<roles>
34
				<role>Architect</role>
35
				<role>Developer</role>
36
			</roles>
37
		</developer>
38
		<developer>
39
			<id>developer2</id>
40
			<name>Name2 Surname</name>
41
			<email>name2@domain</email>
42
			<roles>
43
				<role>Developer</role>
44
			</roles>
45
		</developer>
46
	</developers>
47
	<dependencies>
48
		<dependency>
49
			<groupId>org.gvsig</groupId>
50
			<artifactId>org.gvsig.scripting.thing</artifactId>
51
			<version>1.0-SNAPSHOT</version>
52
		</dependency>
53
		<dependency>
54
			<groupId>org.gvsig</groupId>
55
			<artifactId>org.gvsig.about.api</artifactId>
56
			<version>1.0-SNAPSHOT</version>
57
		</dependency>
58
		<dependency>
59
 			 <groupId>org.gvsig.legacy</groupId>
60
 			 <artifactId>jhall</artifactId>
61
		</dependency>
62
		<dependency>
63
		  <groupId>org.apache.bsf</groupId>
64
		  <artifactId>bsf-all</artifactId>
65
		</dependency>
66
		<dependency>
67
		  <groupId>org.ini4j</groupId>
68
		  <artifactId>ini4j</artifactId>
69
		</dependency>
70
	</dependencies>
71
	<reporting>
72
		<plugins>
73
			<plugin>
74
				<groupId>org.apache.maven.plugins</groupId>
75
				<artifactId>maven-javadoc-plugin</artifactId>
76
				<configuration>
77
					<doctitle>${project.name} ${project.version}</doctitle>
78
				</configuration>
79
				<reportSets>
80
					<reportSet>
81
						<id>api</id>
82
						<configuration>
83
							<name>Javadoc: API</name>
84
							<destDir>apidoc</destDir>
85
							<windowtitle>API Documentation</windowtitle>
86
							<links>
87
								<link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
88
								<link>http://www.slf4j.org/api/</link>
89
								<link>${site-repository}/org.gvsig.tools/2.0.0/apidocs/</link>
90
								<link>${site-repository}/org.gvsig.i18n/2.0.0/apidocs/</link>
91
								<link>${site-repository}/org.gvsig.metadata/2.0.0/apidocs/</link>
92
								<link>${site-repository}/org.gvsig.compat/2.0.0/apidocs/</link>
93
								<link>${site-repository}/org.gvsig.projection/2.0.0/apidocs/</link>
94
								<link>${site-repository}/org.gvsig.utils/2.0.0/apidocs/</link>
95
								<link>${site-repository}/org.gvsig.fmap.dal/2.0.0/apidocs/</link>
96
							</links>
97
						</configuration>
98
						<reports>
99
							<report>javadoc</report>
100
						</reports>
101
					</reportSet>
102
					
103
				</reportSets>
104
			</plugin>
105
		</plugins>
106
	</reporting>
107
	</project>
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.api/README.txt
1
The project structure of this project is the following:
2

  
3
Project
4
|-pom.xml:   		Maven 2 configuration file.
5
`-src
6
  |-main:    		Project source code, resources and configuration
7
  | |-java:  		Java source code
8
  | |-resources:	Resources needed by the code (resource bundles, images, etc.)   
9
  |`-javadoc:		Javadoc common resources	
10
  `-test:    		Unit tests source code, resources and configuration
11
    |-java:  		Unit tests java source code
12
    `-resources:	Resources needed by the test code (resource bundles, images, etc.)   
13

  
14
Look at the main folders for a README.txt file with more information on the 
15
contents of each folder.
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/LEEME.txt
1
Pasos para la descarga y ejecución del 
2
Script Framework desde un nuevo proyecto.
3
--------------------------------------------
4

  
5
1- Iniciar un nuevo workspace de Eclipse
6

  
7
2- Abrir la vista de SVN y añadir la dirección:
8
		
9
		 https://svn.forge.osor.eu/svn/gvsig-scripting
10

  
11
3- Desplegar la dirección del repositorio y el directorio 'trunk'
12

  
13
4- Seleccionar con el botón derecho del ratón el directorio 'build' 
14
	 e indicar la opción 'checkout'
15

  
16
		 4.1 Del cuadro de diálogo que se abre, seleccionar la opción 
17
		 		'Check out as a project in the workspace' y darle a 'Finish'
18
		 		
19
		 (Nota: falta actualizar el directorio 'build' con todo su contenido,
20
		 de momento está la versión que dejamos incompleta, así que habrá que
21
		 copiar lo que quede desde otro 'build')
22
		 
23
5- Repetimos el paso 4 con el directiorio el SVN 'org.gvsig.scripting'
24

  
25
6- Ejecutar la orden de maven 'maven configure eclipse workspace' desde el 
26
	 botón 'run external tools' o desde la opción del menú 'run'->'external Tools'
27
	 
28
	 	(Nota: si se ha seguido el procedimiento manual de copia descrito en la nota 
29
	 	anterior, deberá refrescar la carpeta 'build' seleccionándola y presionando
30
	 	sobre el botón F5)
31
	 
32
	 	6.1 Indicar la ubicación del workspace a configurar (si no se marca nada 
33
	 			escoje la actual)
34
	 			
35
	 	6.2 Reiniciar Eclipse para que asigne correctamente la variable 'M2_REPO' 
36
	 			(se	comprueba viendo que ha sido añadida a través del menú situado en 
37
	 			Window->Preferences...->Java->Build Path-> Classpath Variables)
38
	 			
39
7- Seleccionar la carpeta 'org.gvsig.scripting' y ejecutar la orden de maven 
40
	 'maven eclipse'
41
	 		
42
8- Seleccionar la carpeta 'org.gvsig.scripting' y ejecutar la orden de maven 
43
	 'maven install (no tests)'
44
	 			
45
9- Ir al navegador de archivos, y eliminar manualmente el fichero '.project'
46
	 del directorio 'org.gvsig.scripting'.
47
	 
48
	 	9.1 En el Eclipse, seleccionar 'Import' con el botón derecho sobre el panel 
49
	 	'Package Explorer'
50
	 	
51
	 	9.2 Elegir la opción 'Existing Projects into Workspace'.
52
	 	
53
	 	9.3 Seleccionar el directorio 'org.gvsig.scripting'.
54
	 	
55
10- Refrescar manualmente los directorios importados
56

  
57
		 		
58

  
59
	
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4
		 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5

  
6
	<modelVersion>4.0.0</modelVersion>
7
	<groupId>org.gvsig</groupId>
8
	<artifactId>org.gvsig.scripting.lib</artifactId>
9
	<packaging>pom</packaging>
10
	<version>1.0-SNAPSHOT</version>
11
	<name>org.gvsig.scripting.lib</name>
12
	<description>[PUT LIBRARY DESCRIPTION HERE]</description>
13
	<url>http://www.gvsig.org</url>
14
	<parent>
15
		<groupId>org.gvsig</groupId>
16
		<artifactId>org.gvsig.scripting</artifactId>
17
		<version>1.0-SNAPSHOT</version>
18
	</parent>
19
	<scm>
20
		<connection>scm:svn:http://subversion.gvsig.org/gvSIG/branches/v2_0_0_prep/libraries/org.gvsig.scripting</connection>
21
		<developerConnection>scm:svn:https://gvsig.org/svn/gvSIG/branches/v2_0_0_prep/libraries/org.gvsig.scripting</developerConnection>
22
		<url>http://subversion.gvsig.org/viewvc/?root=gvSIG</url>
23
		<tag>HEAD</tag>
24
	</scm>
25
	<properties>
26
		<build-dir>${basedir}/../../build</build-dir>
27
	</properties>
28
	<developers>
29
		<developer>
30
			<id>developer1</id>
31
			<name>Name Surname</name>
32
			<email>name@domain</email>
33
			<roles>
34
				<role>Architect</role>
35
				<role>Developer</role>
36
			</roles>
37
		</developer>
38
		<developer>
39
			<id>developer2</id>
40
			<name>Name2 Surname</name>
41
			<email>name2@domain</email>
42
			<roles>
43
				<role>Developer</role>
44
			</roles>
45
		</developer>
46
	</developers>
47
	<dependencyManagement>
48
		<dependencies>
49
			<dependency>
50
				<groupId>org.gvsig</groupId>
51
				<artifactId>org.gvsig.scripting.thing</artifactId>
52
				<version>1.0-SNAPSHOT</version>
53
			</dependency>
54
			<dependency>
55
				<groupId>org.gvsig</groupId>
56
				<artifactId>org.gvsig.about.api</artifactId>
57
				<version>1.0-SNAPSHOT</version>
58
			</dependency>
59
			<dependency>
60
				<groupId>org.gvsig</groupId>
61
				<artifactId>org.gvsig.tools</artifactId>
62
				<version>2.0-SNAPSHOT</version>
63
			</dependency>		
64
			<dependency>
65
	 			 <groupId>org.gvsig.legacy</groupId>
66
	 			 <artifactId>jhall</artifactId>
67
	  			<version>2.0.05</version>
68
			</dependency>
69
			<dependency>
70
				<groupId>org.gvsig</groupId>
71
				<artifactId>org.gvsig.i18n</artifactId>
72
				<version>2.0-SNAPSHOT</version>
73
			</dependency>	
74
			<dependency>
75
			  <groupId>com.jgoodies</groupId>
76
			  <artifactId>looks</artifactId>
77
			  <version>2.2.2</version>
78
			</dependency>
79
			<dependency>
80
			  <groupId>bsh</groupId>
81
			  <artifactId>bsh</artifactId>
82
			  <version>2.0b1</version>
83
			</dependency>
84
			<dependency>
85
			  <groupId>groovy</groupId>
86
			  <artifactId>groovy-all</artifactId>
87
			  <version>1.1-rc-1</version>
88
			</dependency>
89
			<dependency>
90
			  <groupId>org.apache.bsf</groupId>
91
			  <artifactId>bsf-all</artifactId>
92
			  <version>3.0-beta3</version>
93
			</dependency>
94
			<dependency>
95
			  <groupId>org.ini4j</groupId>
96
			  <artifactId>ini4j</artifactId>
97
			  <version>0.5.1</version>
98
			</dependency>
99
			<dependency>
100
			  <groupId>commons-logging</groupId>
101
			  <artifactId>commons-logging</artifactId>
102
			  <version>1.1.1</version>
103
			</dependency>
104
			<dependency>
105
			  <groupId>commons-logging</groupId>
106
			  <artifactId>commons-logging</artifactId>
107
			  <version>1.1.1</version>
108
			  <classifier>api</classifier>
109
			</dependency>
110
			<dependency>
111
			  <groupId>thinlet</groupId>
112
	 		  <artifactId>thinlet</artifactId>
113
	 		  <version>20050328</version>
114
			</dependency>
115
			<dependency>
116
			  <groupId>org.python</groupId>
117
			  <artifactId>jython</artifactId>
118
			  <version>2.2.1</version>
119
			</dependency>
120
		</dependencies>
121
	</dependencyManagement>
122
  <modules>
123
    <module>org.gvsig.scripting.lib.api</module>
124
    <module>org.gvsig.scripting.lib.impl</module>
125
  </modules>
126

  
127
	</project>
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/resources/org/gvsig/scripting/impl/scripts/hola2.py
1

  
2

  
3
def click():
4
  print 'click'
5

  
6
def main():
7
  print 'hola'
8
 
9
def hola(name):
10
  return 'hola %s' % name
11
  
12
def adios():
13
  print 'adios'
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/resources/org/gvsig/scripting/impl/scripts/hola.py
1

  
2

  
3
def main():
4
  print 'hola'
5
 
6
def hola(name):
7
  return 'hola %s' % name
8
  
9
def adios():
10
  print 'adios'
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/resources/org/gvsig/scripting/impl/scripts/hola2.dlg
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- generated by ThinG, the Thinlet GUI editor -->
3
<panel>
4
    <button text="hola" action="click"/>
5
</panel>
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/resources/README.txt
1
#set( $symbol_pound = '#' )
2
#set( $symbol_dollar = '$' )
3
#set( $symbol_escape = '\' )
4
Put into this folder the resources needed by your test classes.
5

  
6
This folder is added to the Tests classpath, so you can load any resources 
7
through the ClassLoader.
8

  
9
By default, in this folder you can find an example of log4j configuration,
10
prepared to log messages through the console, so logging works when you
11
run your tests classes.
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	DefaultExampleManager class.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.scripting.impl.DefaultExampleManager">
23
		<priority value="DEBUG" />
24
	</category>
25

  
26
	<!-- 
27
	By default, show only logging messages of INFO level or higher, 
28
	through the previously configured CONSOLE appender. 
29
	-->
30
	<root>
31
		<priority value="INFO" />
32
		<appender-ref ref="CONSOLE" />
33
	</root>
34
</log4j:configuration>
trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/test/java/org/gvsig/scripting/impl/TestScript.java
1
package org.gvsig.scripting.impl;
2

  
3
import java.io.File;
4
import java.io.IOException;
5
import java.net.URL;
6

  
7
import junit.framework.TestCase;
8

  
9
import org.gvsig.scripting.ScriptingFolder;
10
import org.gvsig.scripting.ScriptingLocator;
11
import org.gvsig.scripting.ScriptingManager;
12
import org.ini4j.Ini;
13
import org.ini4j.InvalidFileFormatException;
14

  
15
public class TestScript extends TestCase {
16
	
17
	ScriptingDefaultImplLibrary lib;
18
	ScriptingManager manager;
19
	
20
	public void setUp(){
21
		// Inicializamos las librerías
22
		lib = new ScriptingDefaultImplLibrary();
23
		lib.initialize();
24

  
25
		//  Asignamos el locator e iniciamos la instancia
26
		manager = ScriptingLocator.getManager();	
27
	}
28
	
29
	
30
	public void testSimpleDialog(){
31
		URL folderUrl = TestScript.class.getClassLoader().getResource("org/gvsig/scripting/impl/scripts");
32
		
33
		DefaultScriptingFolder folder = new DefaultScriptingFolder(manager, folderUrl);
34
		assertNotNull("No se ha podido obtener \"impl\"",folder);	
35
		
36
		DefaultScriptingScript script = new DefaultScriptingDialog(manager);
37
		script.load(folder,"hola2.py");
38
		this.checkScript(script, "hola2", "hola2", "scripting_dialog", null, null, folder, "main", "python");
39
		script.run(null);
40
	}	
41
	
42
	public void testSimplePythonScript() throws NoSuchMethodException{
43
		URL folderUrl = TestScript.class.getClassLoader().getResource("org/gvsig/scripting/impl/scripts");
44
		
45
		DefaultScriptingFolder folder = new DefaultScriptingFolder(manager, folderUrl);
46
		assertNotNull("No se ha podido obtener \"impl\"",folder);	
47
		
48
		DefaultScriptingScript script = new DefaultScriptingScript(manager);
49
		assertNotNull("No se ha podido obtener \"hola.py\"",script);	
50
		
51
		script.load(folder,"hola.py");
52
		this.checkScript(script, "hola", "hola", "scripting_python", null, null, folder, "main", "python");
53
		script.run(null);
54
		assertEquals("Resultado incorrecto","hola pepe",script.invokeFunction("hola", new Object[]{"pepe"}));
55
		script.setMainName("adios");
56
		script.run(null);
57
	}
58
	
59
	public void testSimpleSavePythonScript(){
60
		URL folderUrl = TestScript.class.getClassLoader().getResource("org/gvsig/scripting/impl/scripts");
61
		
62
		DefaultScriptingFolder folder = new DefaultScriptingFolder(manager, folderUrl);
63
		assertNotNull("No se ha podido obtener \"impl\"",folder);	
64
		
65
		DefaultScriptingScript script = new DefaultScriptingScript(manager);
66
		assertNotNull("No se ha podido obtener \"hola.py\"",script);	
67
		
68
		script.load(folder,"hola.py");
69
		this.checkScript(script, "hola", "hola", "scripting_python", null, null, folder, "main", "python");
70
		script.save();
71
	}
72
	
73
	public void testFolderScript(){
74
		URL folderUrl = TestScript.class.getClassLoader().getResource("org/gvsig/scripting/impl/scripts");
75
		DefaultScriptingFolder folder = new DefaultScriptingFolder(manager, folderUrl);
76
		this.checkFolder(folder, "scripts", "scripts", "scripting_folder", "scripting_folder_open", null, null);
77
	}
78

  
79
	public void testUserFolderScript(){
80
		ScriptingFolder folder = this.manager.getUserFolder();
81
		this.checkFolder((DefaultScriptingFolder) folder, "Scripts del usuario", "UserFolder", "scripting_userFolder", null, null, null);
82
	}
83
	
84
	private void checkScript(DefaultScriptingScript script, String name, String id, String icon01, String icon02, String description, DefaultScriptingFolder parent, String main, String lang){
85
		assertEquals("El nombre del script no es correcto",name,script.getName());
86
		assertEquals("El id del script no es correcto",id,script.getId());
87
		assertEquals("La descripción del script no es correcta",description,script.getDescription());
88
		assertEquals("Se esperaban 2 iconos",2, script.getIconNames().length);
89
		assertEquals("Icono incorrecto",icon01, script.getIconNames()[0]);
90
		assertEquals("Icono incorrecto",icon02, script.getIconNames()[1]);
91
		assertEquals("Nombre de Main incorrecto", main, script.getMainName());
92
		assertEquals("Nombre del Lenguaje incorrecto", lang, script.getLangName());
93
		if (parent != null){
94
			assertEquals("Parent incorrecto",parent, script.getParent());
95
		}
96
	}
97

  
98
	private void checkFolder(DefaultScriptingFolder folder, String name, String id, String icon01, String icon02, String description, DefaultScriptingFolder parent){
99
		assertNotNull("No se ha podido obtener folder",folder);		
100
		assertEquals("El nombre de la carpeta no es correcto",name,folder.getName());
101
		assertEquals("El id de la carpeta no es correcto",id,folder.getId());
102
		assertEquals("La descripción de la carpeta no es correcta",description,folder.getDescription());
103
		assertEquals("Se esperaban 2 iconos",2, folder.getIconNames().length);
104
		assertEquals("Icono incorrecto",icon01, folder.getIconNames()[0]);
105
		assertEquals("Icono incorrecto",icon02, folder.getIconNames()[1]);
106
		if (parent != null){
107
			assertEquals("Parent incorrecto",parent, folder.getParent());
108
		}
109
	}
110
	
111
	public static void main( String args[] ) {	  
112
		TestScript test = new TestScript();
113
		test.setUp();
114
		URL u = TestScript.class.getClassLoader().getResource("org/gvsig/scripting/impl/scripts/hola.inf");
115
		File f = new File(u.getPath());
116
		System.out.println(f.getAbsolutePath());
117
		try {
118
			f.createNewFile();
119
		} catch (IOException e1) {
120
			e1.printStackTrace();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff