Revision 9331
branches/v10/extensions/extScripting/build.xml | ||
---|---|---|
1 |
<project name="extScripting" default="install-extension" basedir=".">
|
|
1 |
<project name="extScripting" default="batch-build" basedir=".">
|
|
2 | 2 |
<description> |
3 | 3 |
Instala el plugin de Centrar la Vista sobre un punto en Andami. |
4 | 4 |
</description> |
... | ... | |
11 | 11 |
<property name="dist" location="dist"/> |
12 | 12 |
<property name="lib" location="lib"/> |
13 | 13 |
<property name="extensionDir" location="../_fwAndami/gvSIG/extensiones"/> |
14 |
<property name="mainplugin" value="com.iver.cit.gvsig"/>
|
|
14 |
<property name="mainplugin" value="com.iver.cit.gvsig"/>
|
|
15 | 15 |
<property name="without_src" location="without_src"/> |
16 | 16 |
<property name="plugin" value="org.gvsig.scripting"/> |
17 |
<property name="jarName" value="${plugin}.jar"/> |
|
18 |
<property name="andami" location="../_fwAndami"/> |
|
19 |
<property name="andamiLibs" location="${andami}/lib"/> |
|
20 |
<property name="installBaseDir" location="${andami}"/> |
|
21 |
<property name="installDir" location="${installBaseDir}/gvSIG/extensiones/${plugin}"/> |
|
22 |
<property name="installLibDir" location="${installBaseDir}/gvSIG/extensiones/${mainplugin}/lib"/> |
|
23 |
<property name="compile-classpath" value="${andami}/andami.jar:${lib}/bsf-2.3.0rc1.jar:${lib}/bsh-2.0b1.jar:${lib}/groovy-all-1.0-beta-7.jar:${andamiLibs}/iver-utiles.jar:${lib}/jython-2.1.jar:${lib}/scriptablethinlet-0.9.jar:${lib}/thinlet.jar"/> |
|
17 |
<property name="jarName" value="${plugin}.jar"/> |
|
18 |
<property name="andami" location="../_fwAndami"/> |
|
19 |
<property name="andamiLibs" location="${andami}/lib"/> |
|
20 |
<property name="fmap" location="../libFMap"/> |
|
21 |
<property name="fmapLibs" location="${fmap}/lib"/> |
|
22 |
<property name="installBaseDir" location="${andami}"/> |
|
23 |
<property name="installDir" location="${installBaseDir}/gvSIG/extensiones/${plugin}"/> |
|
24 |
<property name="installLibDir" location="${installBaseDir}/gvSIG/extensiones/${mainplugin}/lib"/> |
|
25 |
<property name="compile-classpath" value="${andami}/andami.jar:${lib}/bsf-2.3.0rc1.jar:${lib}/bsh-2.0b1.jar:${lib}/groovy-all-1.0-beta-7.jar:${andamiLibs}/iver-utiles.jar:${lib}/jython-2.1.jar:${lib}/scriptablethinlet-0.9.jar:${lib}/thinlet.jar:${fmapLibs}/fmap.jar"/> |
|
24 | 26 |
|
25 | 27 |
<target name="init"> |
26 | 28 |
<!-- Create the time stamp --> |
... | ... | |
71 | 73 |
<fileset dir="config" includes="text*.properties"/> |
72 | 74 |
</copy> |
73 | 75 |
<jar jarfile="${dist}/bin/org/gvsig/scripting/${plugin}.jar" basedir="${build}"/> |
74 |
<copy file="config/config.xml" todir="${dist}/bin/org/gvsig/scripting"/>
|
|
76 |
<copy file="config/config.xml" todir="${dist}/bin/org/gvsig/scripting"/>
|
|
75 | 77 |
<copy todir="${dist}/bin/org/gvsig/scripting/images"> |
76 | 78 |
<fileset dir="images"/> |
77 | 79 |
</copy> |
... | ... | |
99 | 101 |
</target> |
100 | 102 |
|
101 | 103 |
<target name="generate-without-source" depends="init" description="generate the distribution without the source file" > |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
102 | 108 |
<!-- Create the distribution directory --> |
103 | 109 |
<delete dir="${without_src}"/> |
104 | 110 |
<mkdir dir="${without_src}"/> |
111 |
<mkdir dir="${without_src}/${mainplugin}/lib"/> |
|
105 | 112 |
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --> |
106 |
<jar jarfile="${without_src}/${plugin}.jar" basedir="${build}"/> |
|
113 |
<jar jarfile="${without_src}/${mainplugin}/lib/${plugin}.jar" basedir="${build}"/>
|
|
107 | 114 |
<copy file="config/config.xml" todir="${without_src}"/> |
108 | 115 |
<copy todir="${without_src}"> |
109 | 116 |
<fileset dir="config" includes="text*.properties"/> |
110 | 117 |
</copy> |
111 |
<mkdir dir="${without_src}/${mainplugin}/lib"/>
|
|
118 |
<!--copy todir="${without_src}/${mainplugin}/lib"-->
|
|
112 | 119 |
<copy todir="${without_src}/${mainplugin}/lib"> |
113 | 120 |
<fileset dir="${lib}" includes="*.jar,*.zip"/> |
114 | 121 |
</copy> |
... | ... | |
186 | 193 |
</target> |
187 | 194 |
|
188 | 195 |
<target name="copy-scripts"> |
189 |
<copy file="config/config.xml" todir="${dist}"/> |
|
190 |
<copy todir="${dist}"> |
|
191 |
<fileset dir="config" includes="text*.properties"/> |
|
192 |
</copy> |
|
193 | 196 |
<copy todir="${dist}/scripts"> |
194 | 197 |
<fileset dir="${scripts}" includes="**/**"/> |
195 | 198 |
</copy> |
196 | 199 |
</target> |
197 | 200 |
|
198 | 201 |
<target name="move-to-installDir"> |
202 |
<move todir="${installLibDir}"> |
|
203 |
<fileset dir="${dist}" includes="${jarName}"/> |
|
204 |
</move> |
|
199 | 205 |
<move todir="${installDir}"> |
200 | 206 |
<fileset dir="${dist}" includes="**/**"/> |
201 | 207 |
</move> |
202 |
<copy todir="${installDir}"> |
|
208 |
<copy todir="${installLibDir}">
|
|
203 | 209 |
<fileset dir="${lib}" includes="**/**"/> |
204 | 210 |
</copy> |
205 | 211 |
</target> |
branches/v10/extensions/extScripting/.classpath | ||
---|---|---|
11 | 11 |
<classpathentry sourcepath="/xthinlet/thinlet" kind="lib" path="lib/thinlet.jar"/> |
12 | 12 |
<classpathentry kind="lib" path="lib/js-1.5r3.jar"/> |
13 | 13 |
<classpathentry sourcepath="/Utiles/src" kind="lib" path="/_fwAndami/lib/iver-utiles.jar"/> |
14 |
<classpathentry kind="lib" path="/libFMap/lib/fmap.jar"/> |
|
15 |
<classpathentry kind="src" path="/appgvSIG"/> |
|
14 | 16 |
<classpathentry kind="output" path="bin"/> |
15 | 17 |
</classpath> |
branches/v10/extensions/extScripting/scripts/jython/startup.py | ||
---|---|---|
9 | 9 |
sys.gvSIG = gvSIG |
10 | 10 |
|
11 | 11 |
# Add current path to path |
12 |
sys.path.append(File(params.get("fileName")).getParent()) |
|
12 |
try: |
|
13 |
sys.path.append(File(params.get("fileName")).getParent()) |
|
14 |
except: |
|
15 |
pass |
|
13 | 16 |
|
14 | 17 |
# Add Scripts/jython/Libs to path |
15 | 18 |
sys.path.append(gvSIG.getScriptsDirectory()+File.separatorChar+"jython"+File.separatorChar+"Lib") |
branches/v10/extensions/extScripting/src/org/gvsig/scripting/ScriptingExtension.java | ||
---|---|---|
1 | 1 |
package org.gvsig.scripting; |
2 | 2 |
|
3 |
import java.io.File; |
|
4 |
import java.io.FileReader; |
|
3 | 5 |
import java.io.IOException; |
4 | 6 |
import java.net.URLDecoder; |
5 | 7 |
import java.util.Hashtable; |
... | ... | |
8 | 10 |
import org.apache.bsf.BSFEngine; |
9 | 11 |
import org.apache.bsf.BSFException; |
10 | 12 |
import org.apache.bsf.BSFManager; |
13 |
import org.gvsig.scripting.xul.XULInfoToolSupport; |
|
14 |
import org.gvsig.scripting.xul.XULScriptablePanel; |
|
11 | 15 |
|
12 | 16 |
import thinlet.script.ScriptableThinlet; |
13 | 17 |
|
14 | 18 |
import com.iver.andami.PluginServices; |
15 | 19 |
import com.iver.andami.plugins.Extension; |
16 | 20 |
import com.iver.andami.ui.mdiManager.IWindow; |
21 |
import com.iver.cit.gvsig.project.documents.view.info.gui.InfoToolViewer; |
|
17 | 22 |
|
18 | 23 |
public class ScriptingExtension extends Extension { |
19 | 24 |
private static BSFManager bsfManager; |
... | ... | |
77 | 82 |
// TODO Auto-generated catch block |
78 | 83 |
e.printStackTrace(); |
79 | 84 |
} |
80 |
|
|
85 |
|
|
81 | 86 |
return bsfManager; |
82 | 87 |
} |
83 | 88 |
|
84 | 89 |
public void initialize() { |
85 |
// TODO Recivirlo como paramentro |
|
86 |
//this.scriptFileName = "./centerToPoint.xml"; |
|
87 |
|
|
88 |
|
|
90 |
XULScriptablePanel.setBSFManager( getBSFManager() ); |
|
91 |
InfoToolViewer.XULPanelClass = XULInfoToolSupport.class; |
|
89 | 92 |
} |
90 | 93 |
|
91 | 94 |
public void execute(String actionCommand) { |
... | ... | |
122 | 125 |
} |
123 | 126 |
} |
124 | 127 |
|
128 |
private void runStartupScripJython() { |
|
129 |
BSFEngine bsfEngine; |
|
130 |
try { |
|
131 |
bsfEngine = getBSFManager().loadScriptingEngine(JYTHON); |
|
132 |
String startUpFileName = ScriptingExtension.getScriptingAppAccesor().getScriptsDirectory(); |
|
133 |
startUpFileName = startUpFileName + File.separatorChar+ "jython"+ File.separatorChar+"startup.py"; |
|
134 |
File startupFile = new File(startUpFileName); |
|
135 |
|
|
136 |
if (!startupFile.exists()) { |
|
137 |
//throw new IOException("Startup File "+startUpFileName+" not found"); |
|
138 |
return; |
|
139 |
} |
|
140 |
String startupCode = readFile(startupFile); |
|
141 |
bsfEngine.exec(startUpFileName, -1, -1, startupCode); |
|
142 |
} catch (BSFException e) { |
|
143 |
// TODO Auto-generated catch block |
|
144 |
e.printStackTrace(); |
|
145 |
} catch (IOException e) { |
|
146 |
// TODO Auto-generated catch block |
|
147 |
e.printStackTrace(); |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
private String readFile(File aFile) throws IOException { |
|
152 |
StringBuffer fileContents = new StringBuffer(); |
|
153 |
FileReader fileReader = new FileReader(aFile); |
|
154 |
int c; |
|
155 |
while ((c = fileReader.read()) > -1) { |
|
156 |
fileContents.append((char)c); |
|
157 |
} |
|
158 |
fileReader.close(); |
|
159 |
return fileContents.toString(); |
|
160 |
} |
|
161 |
|
|
125 | 162 |
public static Object show(Map params) { |
126 | 163 |
DefaultThinlet.setBSFManager(getBSFManager()); |
127 | 164 |
ScriptPanel panel; |
Also available in: Unified diff