X Tutup
Skip to content

Commit f371e68

Browse files
author
sebastigurin
committed
initial project import
1 parent c0157ca commit f371e68

24 files changed

+839
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry exported="true" kind="lib" path="lib/velocity-1.6.4-dep.jar"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
5+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6+
<classpathentry kind="src" path="src"/>
7+
<classpathentry kind="output" path="bin"/>
8+
</classpath>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>net.sf.j2s.ui.template.velocity</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.pde.PluginNature</nature>
26+
<nature>org.eclipse.jdt.core.javanature</nature>
27+
</natures>
28+
</projectDescription>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Sun Aug 22 18:10:54 UYT 2010
2+
eclipse.preferences.version=1
3+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5+
org.eclipse.jdt.core.compiler.compliance=1.6
6+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8+
org.eclipse.jdt.core.compiler.source=1.6
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Manifest-Version: 1.0
2+
Bundle-ManifestVersion: 2
3+
Bundle-Name: J2sAppLauncherTemplate
4+
Bundle-SymbolicName: net.sf.j2s.ui.template.velocity;singleton:=true
5+
Bundle-Version: 1.0.0.qualifier
6+
Bundle-Activator: net.sf.j2s.ui.launching.template.velocity.Activator
7+
Require-Bundle: org.eclipse.ui,
8+
org.eclipse.core.runtime,
9+
org.eclipse.core.resources;bundle-version="3.6.0",
10+
org.eclipse.debug.core;bundle-version="3.6.0",
11+
org.eclipse.jdt.core;bundle-version="3.6.0",
12+
org.eclipse.jdt.launching;bundle-version="3.5.100",
13+
net.sf.j2s.ui;bundle-version="2.0.0",
14+
org.eclipse.debug.ui;bundle-version="3.6.0"
15+
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
16+
Bundle-ClassPath: lib/velocity-1.6.4-dep.jar,
17+
.
18+
Bundle-ActivationPolicy: lazy
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source.. = src/
2+
output.. = bin/
3+
bin.includes = META-INF/,\
4+
.,\
5+
plugin.xml,\
6+
lib/velocity-1.6.4-dep.jar
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Options +Indexes
46.7 KB
Loading
79.9 KB
Loading
Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
<!--
2+
@author: sugurin
3+
TODO: if this cmdline utility is included as j2s part, this document should be a section of j2s-user-guide
4+
5+
-->
6+
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
7+
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
8+
9+
<?xml-stylesheet type="text/xsl" href="../docbook-xsl/xhtml/docbook.xsl"?>
10+
11+
<article>
12+
<title>Java2Script application renderization based on templates</title>
13+
14+
<abstract> <para>This document describes <ulink url="http://j2s.sourceforge.net/">Java2Script</ulink>
15+
templates support for rendering an application</para>
16+
</abstract>
17+
18+
19+
<articleinfo>
20+
<title>Java2Script Command line API plugin </title>
21+
<author><surname>Gurin</surname><firstname>Sebastian</firstname></author>
22+
23+
24+
<revhistory>
25+
<revision>
26+
<revnumber>0.01</revnumber>
27+
<date>20 July 2010</date>
28+
<authorinitials>sebastiGurin</authorinitials>
29+
<revremark>Initial revision and release</revremark>
30+
</revision>
31+
32+
</revhistory>
33+
34+
</articleinfo>
35+
36+
<author><surname>Gurin</surname><firstname>Sebastian</firstname></author>
37+
38+
<section>
39+
<title>About this document</title>
40+
41+
<para>This document is available in the following formats:</para>
42+
43+
<orderedlist>
44+
45+
<listitem><formalpara><title>pdf</title><para>
46+
<ulink url="j2s-template.pdf">Java2Script application renderization based on templates</ulink></para></formalpara></listitem>
47+
48+
<listitem><formalpara><title>html fragmented</title><para>
49+
<ulink url="j2s-template-htmls">Java2Script application renderization based on templates</ulink></para></formalpara></listitem>
50+
51+
<listitem><formalpara><title>docbook</title><para>
52+
<ulink url="j2s-template.xml">Java2Script application renderization based on templates</ulink></para></formalpara></listitem>
53+
54+
<listitem><formalpara><title>download htmls</title><para>
55+
<ulink url="j2s-template-htmls.tgz">Java2Script application renderization based on templates</ulink></para></formalpara></listitem>
56+
57+
</orderedlist>
58+
59+
60+
</section>
61+
62+
63+
<section>
64+
<title>Background</title>
65+
66+
<para>Working with Java2Script eclipse plugin for writing your web applications in java can be divided in two
67+
main "tasks": 1) translate all .java code into .javascript code and 2) render the generated javascript
68+
application in some document, for example, in an html document.</para>
69+
70+
<para>The first task, code translation, is performed transparently by Java2Script plugin without the user
71+
to even worry about the java to javascript code translation. Nevertheless, current sollution for the second task, rendering the
72+
generated javascript application, is kind of "inflexible" in Java2Script. Today, J2S supports application launching in a fixed
73+
html document. The html code is clean enought to reusing its javascript code in other documents, but I think
74+
it can be more practical for the user to be able to define how it whish to "render" its application. For example,
75+
the user may want to :</para>
76+
77+
<itemizedlist>
78+
<listitem><para>create an html fragment not an entire html document.</para></listitem>
79+
<listitem><para>create a jsp/asp/php server web page or fragment that launch the j2s app</para></listitem>
80+
<listitem><para>create a javascript script that easily launch the application to be used in 3rd party html.</para></listitem>
81+
<listitem><para>create a java tagfile that easily launch the j2s application.</para></listitem>
82+
<listitem><para>create a "javascript:" link that load j2slib.js and the j2s application.</para></listitem>
83+
<listitem><para>customize output html markup and style.</para></listitem>
84+
<listitem><para>customize the output file name and path.</para></listitem>
85+
</itemizedlist>
86+
87+
<para>All of these, are examples, of different renderizations of the same Java2Script application.</para>
88+
<para>We thought that, giving the responsability of how a j2s app is "rendered" to templates will boost J2S plugin
89+
supporting these and other user cases with automation and freedom for the user and so we have created support for
90+
Java2Script application renderization through templates and that is what this document try to describe.</para>
91+
92+
</section>
93+
94+
95+
<section>
96+
<title>Introduction
97+
</title>
98+
<para>Java2Script now supports application renderization throught templates. The J2S project <code>net.sf.j2s.ui</code>
99+
now defines the extension point <code>j2sAppLauncherTemplateSupport</code> for J2S Application launching driven by templates.
100+
This project, <code>net.sf.j2s.ui.templates.velocity</code> is the first contribution to that extension point and provides a
101+
simple template renderization engine and simple template collection for rendering a Java2Script application, based on the
102+
template engine and language <ulink url="http://velocity.apache.org/">apache velocity</ulink>. Users interested in other
103+
template engines and language, can implement their own plugin contributors, basing them on <code>net.sf.j2s.ui.templates.velocity</code></para>
104+
105+
<para>In this document we will describe the new template J2s app renderization mechanism based on the velocity contribution.</para>
106+
107+
</section>
108+
109+
110+
<section>
111+
<title>Usage
112+
</title>
113+
<para>
114+
Before template support, when launching a J2S application, J2S can only generate an html document and the user can only add some html code
115+
at &lt;body> and &lt;head> elements in the HTML tab of the J2S application launching dialog:
116+
</para>
117+
118+
<figure>
119+
<title>Customizing HTML output code in old HTML application launching tab</title>
120+
<mediaobject>
121+
<imageobject>
122+
<imagedata fileref="images/html-tab.png"></imagedata>
123+
</imageobject>
124+
</mediaobject>
125+
</figure>
126+
127+
<para>
128+
If a template contribution is found, like <code>net.sf.j2s.ui.templates.velocity</code>, the HTML tab is replaced by the template tab. The template tab
129+
shows all contributor's built-in templates and even let the user create, save and load new templates:</para>
130+
131+
132+
<figure>
133+
<title>Defining a templtae for Java2Script application renderization</title>
134+
<mediaobject>
135+
<imageobject>
136+
<imagedata fileref="images/template-tab.png"></imagedata>
137+
</imageobject>
138+
</mediaobject>
139+
</figure>
140+
141+
142+
</section>
143+
144+
<section><title>Template variables</title>
145+
<para>In this section we list and describe the variables exposed by Java2Script to
146+
the template engine. </para>
147+
148+
<programlisting>
149+
# J2SClasspathIgnoredClasses ->
150+
# workingDir -> /home/sebastian/desarrollo/runtime-EclipseApplication/j2sBug
151+
# j2slibUrl -> j2slib
152+
# binUrl -> bin/
153+
# j2sClassPath -> ../../../../net.sf.j2s.lib/j2slib/java.runtime.j2x,../../java2script/svn/trunk/sources/net.sf.j2s.lib/j2slib/java.runtime.j2x,bin/foo/bar/equals.js,bin/foo/bar2/Runme.js,bin/foo/NullBug.js
154+
# mainType -> foo.NullBug
155+
# outputFileAbsolutePath -> /home/sebastian/desarrollo/runtime-EclipseApplication/j2sBug/help))=J2STemplateContextDump.html
156+
# outputFileName -> help))=J2STemplateContextDump.html
157+
# mozillaAddonCompatible -> false
158+
# arguments ->
159+
# htmlHeadOfBody ->
160+
# J2SClasspathJ2X ->
161+
# J2SClasspathExistingClasses -> ClazzLoader.packageClasspath (["foo.bar", "foo", "foo.bar2"], "bin/");
162+
# J2sMainClassLoadCode -> ClazzLoader.loadClass ("foo.NullBug", function () { foo.NullBug.main([]); });
163+
# projectName -> j2sBug
164+
# outputFileCode -> help))=J2STemplateContextDump.html
165+
# J2SSetPrimaryFolder -> ClazzLoader.setPrimaryFolder ("bin/");
166+
</programlisting>
167+
<table>
168+
<title>Template variables</title>
169+
<tgroup cols="3">
170+
<thead><row><entry>Variable name</entry><entry>Description</entry><entry>Example value</entry></row></thead>
171+
<tbody>
172+
<row><entry>J2SClasspathIgnoredClasses</entry><entry>array of ignored classes setted in "Class Path" tab</entry><entry>TODO</entry></row>
173+
<row><entry>workingDir</entry><entry>TODO</entry><entry>TODO</entry></row>
174+
<row><entry>j2slibUrl</entry><entry>TODO</entry><entry>TODO</entry></row>
175+
<row><entry>binUrl</entry><entry>TODO</entry><entry>TODO</entry></row>
176+
<row><entry>j2sClassPath</entry><entry>TODO</entry><entry>TODO</entry></row>
177+
<row><entry>mainType</entry><entry>TODO</entry><entry>TODO</entry></row>
178+
<row><entry>outputFileAbsolutePath</entry><entry>TODO</entry><entry>TODO</entry></row>
179+
<row><entry>outputFileName</entry><entry>TODO</entry><entry>TODO</entry></row>
180+
<row><entry>mozillaAddonCompatible</entry><entry>TODO</entry><entry>TODO</entry></row>
181+
<row><entry>arguments</entry><entry>TODO</entry><entry>TODO</entry></row>
182+
<row><entry>J2SClasspathJ2X</entry><entry>TODO</entry><entry>TODO</entry></row>
183+
<row><entry>J2SClasspathExistingClasses</entry><entry></entry><entry>ClazzLoader.packageClasspath (["foo.bar", "foo", "foo.bar2"], "bin/");</entry></row>
184+
<row><entry>J2sMainClassLoadCode</entry><entry>Javascript code that calls loadClass()</entry><entry>ClazzLoader.loadClass ("foo.NullBug", function () { foo.NullBug.main([]); });</entry></row>
185+
<row><entry>projectName</entry><entry>Name of the Java2Script project in which the main type resides</entry><entry>j2sTestProject1</entry></row>
186+
<row><entry>outputFileCode</entry><entry>template code for output file name. This code is evaluated by the template engine to get the actual output file name, that is stored in variables outputFileName and outputFileAbsolutePath </entry><entry>${mainType}.html</entry></row>
187+
<row><entry>J2SSetPrimaryFolder</entry><entry>javascript code that call setPrimaryFolder</entry><entry>ClazzLoader.setPrimaryFolder ("bin/"); </entry></row>
188+
</tbody>
189+
</tgroup>
190+
</table>
191+
</section>
192+
193+
194+
<section><title>Velocity based contribution</title>
195+
196+
<para>In this section we describe a contribution implementation based on velocity, the <code>net.sf.j2s.ui.templates.velocity</code> eclipse plugin project. </para>
197+
198+
<para>This is not a velocity user manual. Please go to <ulink url="http://velocity.apache.org/engine/devel/user-guide.html">apache velocity user's guide</ulink> for velocity syntax tutorial.</para>
199+
200+
<para>In a velocity template, each template variable mentioned previously is exposed. so for
201+
example you can access the j2slib folder url selected by the user with the velocity statement <code>${j2slibUrl}</code>.
202+
and so, the html script element for including the j2slib.js file is
203+
<code>&lt;script type="text/javascript" src="${j2slibUrl}j2slib.z.js">&lt;/script></code>. </para>
204+
205+
<para>Also, there is a variable named <code>ctx</code> that is a Map with velocity variable names and values. For example, for printing all velocity variables names and values in an html
206+
use the following template:</para>
207+
208+
<programlisting>
209+
&lt;ul>
210+
#foreach( $varName in $ctx.keySet() )
211+
&lt;li>&lt;b>$varName&lt;/b> -> $ctx.get($varName)&lt;/li>
212+
#end
213+
&lt;/ul>
214+
</programlisting>
215+
216+
217+
218+
219+
<section><title>Built-in templates</title>
220+
<para></para>
221+
222+
223+
<section>
224+
<title>Simple html document</title>
225+
<para>generates an html document that renders the java2script
226+
application</para>
227+
228+
</section>
229+
230+
<section>
231+
<title>Javascript Launcher (js)</title>
232+
<para>generates a .js file that includes all the code necesary for
233+
launching the j2s application with a single function call</para>
234+
235+
</section>
236+
237+
238+
<section>
239+
<title>Javascript Launcher (html)</title>
240+
<para>Using the same javascript code generated by Javascript Launcher
241+
(js), it creates a simple html document that launch the j2s
242+
application using the javascript. (shows and test how to use the
243+
javascript launcher in an html doc.)</para>
244+
245+
</section>
246+
</section>
247+
</section>
248+
249+
250+
251+
252+
253+
254+
255+
256+
257+
258+
259+
260+
261+
262+
263+
<section><title>Rendering J2S applications with templates from command line</title>
264+
<para><code>net.sf.j2s.ui.cmdline</code>plugin let the user do some high level Java2Script related actions with the command line. For example,
265+
the user can issue a list of commands like import and build existing java2script projects, or render a j2s application with a template, all in a single command line string.</para>
266+
267+
<para>The following are 3 differents command lines. The three shows how to do the same thing: import and build a J2S project and the render a java main
268+
type with a certain template file:</para>
269+
270+
<programlisting>
271+
# 1) command - 1) render (autoatically do import and build)
272+
eclipse -clean -nosplash -data "/home/sebastian/desarrollo/workspaceTest2" -application net.sf.j2s.ui.cmdlineApi \
273+
-cmd build -path "/home/sebastian/desarrollo/sgurin_workspace/j2stest" -projectName j2stest \
274+
-cmd render -projectName j2stest -mainType org.s.d.M1 -outputName "\${mainType}.html" -j2slibUrl "../yui3/j2slib" \
275+
-template "/home/sebastian/desarrollo/j2s_3.6_workspace/net.sf.j2s.ui.template.velocity/src/net/sf/j2s/ui/launching/template/velocity/templates/simpleHtmlDocument.vm"
276+
277+
# 2 commands: 1) import and build 2)render
278+
eclipse -clean -nosplash -data "/home/sebastian/desarrollo/workspaceTest2" -application net.sf.j2s.ui.cmdlineApi \
279+
-cmd build -path "/home/sebastian/desarrollo/sgurin_workspace/j2stest" -projectName j2stest \
280+
-cmd render -mainType org.s.d.M1 -projectName j2stest -outputName "\${mainType}.html" -j2slibUrl "../yui3/j2slib" -template "/home/sebastian/desarrollo/j2s_3.6_workspace/net.sf.j2s.ui.template.velocity/src/net/sf/j2s/ui/launching/template/velocity/templates/simpleHtmlDocument.vm"
281+
282+
# 3 commands 1) import, 2) build, 3) render
283+
eclipse -clean -nosplash -data "/home/sebastian/desarrollo/workspaceTest2" -application net.sf.j2s.ui.cmdlineApi \
284+
-cmd import -path "/home/sebastian/desarrollo/sgurin_workspace/j2stest" -projectName j2stest \
285+
-cmd build -projectName j2stest \
286+
-cmd render -mainType org.s.d.M1 -projectName j2stest -outputName "\${mainType}.html" -j2slibUrl "../yui3/j2slib" -template "/home/sebastian/desarrollo/j2s_3.6_workspace/net.sf.j2s.ui.template.velocity/src/net/sf/j2s/ui/launching/template/velocity/templates/simpleHtmlDocument.vm"
287+
288+
</programlisting>
289+
</section>
290+
291+
</article>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#generation of htmls and pdf from docbook.
2+
#author: sgurin
3+
4+
#clean
5+
rm j2s-template.pdf
6+
rm -r j2s-template-htmls
7+
rm j2s-template.tgz
8+
9+
#pdf
10+
dblatex j2s-template.xml
11+
12+
#multiple htmls
13+
db2html j2s-template.xml
14+
cp -r images j2s-template/images
15+
mv j2s-template j2s-template-htmls
16+
cp j2s-template-htmls/t2.html j2s-template-htmls/index.html
17+
18+
#multiple htmls compressed:
19+
chmod -R a+x j2s-template-htmls
20+
tar cvfz j2s-template-htmls.tgz j2s-template-htmls
21+
22+
#single html
23+
db2html --nochunks j2s-template.xml > j2s-template.html

0 commit comments

Comments
 (0)
X Tutup