Revision 754

View differences:

org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/javadoc/overview.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.scripting package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>TODO: Example library overview.</p>
11
	
12
	<p>See the <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#overviewcomment">Javadoc Tool documentation about the overview file</a></p>
13

  
14
</body>
15
</html>
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/resources/thing/componentchooser.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- jEdit settings: :tabSize=4:indentSize=4:noTabs=true:folding=explicit:collapseFolds=1: -->
3

  
4
<panel bottom="12" columns="1" left="12" right="12" top="12" weightx="1" weighty="1">
5
    <list colspan="2" name="list" line="false" weightx="1" weighty="1" action="selectionChanged(this, lSelected)" perform="close()"/>
6
    <panel gap="6" top="12" weightx="1">
7
        <label text="Selected:"/>
8
        <label name="lSelected" text="null"/>
9
        <panel weightx="1"/>
10
        <button name="bOk" text="Ok" icon="icons/ok.gif" mnemonic="0" type="default" action="ok()"/>
11
        <button name="bCancel" text="Cancel" icon="icons/cancel.gif" mnemonic="0" type="cancel" action="close()"/>
12
    </panel>
13
</panel>
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/resources/thing/thing.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- jEdit settings: :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: -->
3

  
4
<panel columns="1" gap="4">
5

  
6
	<menubar weightx="1">
7
		<menu text="File" mnemonic="0">
8
			<menuitem text="New" mnemonic="0" icon="icons/empty_menu.gif" accelerator="ctrl N" action="menu_file_new()"/>
9
			<menuitem text="Open..." mnemonic="0" icon="icons/empty_menu.gif" accelerator="ctrl O" action="menu_file_open()"/>
10
			<separator/>
11
			<menuitem text="Reload" mnemonic="0" icon="icons/empty_menu.gif" accelerator="ctrl R" action="menu_file_reload()"/>
12
			<separator/>
13
			<menuitem text="Save" mnemonic="0" icon="icons/empty_menu.gif" accelerator="ctrl S" action="menu_file_save()"/>
14
			<menuitem text="Save As..." mnemonic="5" icon="icons/empty_menu.gif" action="menu_file_save_as()"/>
15
			<separator/>
16
			<menuitem text="Exit" mnemonic="0" icon="icons/empty_menu.gif" accelerator="alt F4" action="menu_file_exit()"/>
17
		</menu>
18
		<menu text="Edit" mnemonic="0">
19
			<menuitem text="Cut" name="menu_edit_cut" mnemonic="0" accelerator="ctrl X" icon="icons/edit_cut.gif" action="menu_edit_cut()"/>
20
			<menuitem text="Copy" name="menu_edit_copy" mnemonic="1" accelerator="ctrl C" icon="icons/edit_copy.gif" action="menu_edit_copy()"/>
21
			<menuitem text="Paste" name="menu_edit_paste" mnemonic="0" accelerator="ctrl V" icon="icons/edit_paste.gif" action="menu_edit_paste()"/>
22
			<menuitem text="Paste from system clipboard" name="menu_edit_paste_systemcb" mnemonic="1" accelerator="ctrl shift V" icon="icons/empty_menu.gif" action="menu_edit_paste_systemcb()"/>
23
			<menuitem text="Delete" name="menu_edit_delete" mnemonic="0" icon="icons/edit_delete.gif" action="menu_edit_delete()"/>
24
			<separator/>
25
			<menuitem text="Settings..." mnemonic="0" icon="icons/empty_menu.gif" action="menu_edit_settings()"/>
26
		</menu>
27
		<menu text="Tools" mnemonic="0">
28
			<menuitem text="Generate Handler Stub Source..." name="menu_tools_generate" mnemonic="0" accelerator="ctrl G" icon="icons/empty_menu.gif" action="menu_tools_generate()"/>
29
		</menu>
30
		<menu text="Help" mnemonic="0">
31
			<menuitem text="About Thing..." mnemonic="0" icon="icons/thing_small.gif" action="menu_help_about()"/>
32
		</menu>
33
	</menubar>
34

  
35
	<panel name="toolbar" weightx="1" gap="-1">
36

  
37
		<!-- top level components -->
38
		<button name="tb_add_panel" property="classname=panel" icon="icons/panel.gif" tooltip="Create new panel" action="addComponent(this)"/>
39
		<button name="tb_add_dialog" property="classname=dialog" icon="icons/dialog.gif" tooltip="Create new dialog" action="addComponent(this)"/>
40
		<button name="tb_add_desktop" property="classname=desktop" icon="icons/desktop.gif" tooltip="Create new desktop" action="addComponent(this)"/>
41
		<button name="tb_add_splitpane" property="classname=splitpane" icon="icons/splitpane.gif" tooltip="Create new splitpane" action="addComponent(this)"/>
42
		<button name="tb_add_tabbedpane" property="classname=tabbedpane" icon="icons/tabbedpane.gif" tooltip="Create new tabbedpane" action="addComponent(this)"/>
43

  
44
		<!-- menu components -->
45
		<button name="tb_add_menubar" property="classname=menubar" icon="icons/menubar.gif" tooltip="Create new menubar" action="addComponent(this)"/>
46
		<button name="tb_add_menu" property="classname=menu" icon="icons/menu.gif" tooltip="Create new menu" action="addComponent(this)"/>
47
		<button name="tb_add_menuitem" property="classname=menuitem" icon="icons/menuitem.gif" tooltip="Create new menuitem" action="addComponent(this)"/>
48
		<button name="tb_add_checkboxmenuitem" property="classname=checkboxmenuitem" icon="icons/checkboxmenuitem.gif" tooltip="Create new checkboxmenuitem" action="addComponent(this)"/>
49

  
50
		<!-- components -->
51
		<button name="tb_add_label" property="classname=label" icon="icons/label.gif" tooltip="Create new label" action="addComponent(this)"/>
52
		<button name="tb_add_button" property="classname=button" icon="icons/button.gif" tooltip="Create new button" action="addComponent(this)"/>
53
		<button name="tb_add_togglebutton" property="classname=togglebutton" icon="icons/togglebutton.gif" tooltip="Create new togglebutton" action="addComponent(this)"/>
54
		<button name="tb_add_checkbox" property="classname=checkbox" icon="icons/checkbox.gif" tooltip="Create new checkbox" action="addComponent(this)"/>
55
		<button name="tb_add_textfield" property="classname=textfield" icon="icons/textfield.gif" tooltip="Create new textfield" action="addComponent(this)"/>
56
		<button name="tb_add_combobox" property="classname=combobox" icon="icons/combobox.gif" tooltip="Create new combobox" action="addComponent(this)"/>
57
		<button name="tb_add_passwordfield" property="classname=passwordfield" icon="icons/passwordfield.gif" tooltip="Create new passwordfield" action="addComponent(this)"/>
58
		<button name="tb_add_spinbox" property="classname=spinbox" icon="icons/spinbox.gif" tooltip="Create new spinbox" action="addComponent(this)"/>
59
		<button name="tb_add_progressbar" property="classname=progressbar" icon="icons/progressbar.gif" tooltip="Create new progressbar" action="addComponent(this)"/>
60
		<button name="tb_add_slider" property="classname=slider" icon="icons/slider.gif" tooltip="Create new slider" action="addComponent(this)"/>
61
		<button name="tb_add_separator" property="classname=separator" icon="icons/separator.gif" tooltip="Create new separator" action="addComponent(this)"/>
62
		<button name="tb_add_list" property="classname=list" icon="icons/list.gif" tooltip="Create new list" action="addComponent(this)"/>
63
		<button name="tb_add_table" property="classname=table" icon="icons/table.gif" tooltip="Create new table" action="addComponent(this)"/>
64
		<button name="tb_add_textarea" property="classname=textarea" icon="icons/textarea.gif" tooltip="Create new textarea" action="addComponent(this)"/>
65
		<button name="tb_add_tree" property="classname=tree" icon="icons/tree.gif" tooltip="Create new tree" action="addComponent(this)"/>
66

  
67
		<!-- list items -->
68
		<button name="tb_add_choice" property="classname=choice" icon="icons/choice.gif" tooltip="Create new choice" action="addComponent(this)"/>
69
		<button name="tb_add_item" property="classname=item" icon="icons/item.gif" tooltip="Create new item" action="addComponent(this)"/>
70
		<button name="tb_add_node" property="classname=node" icon="icons/node.gif" tooltip="Create new node" action="addComponent(this)"/>
71
		<button name="tb_add_tab" property="classname=tab" icon="icons/tab.gif" tooltip="Create new tab" action="addComponent(this)"/>
72

  
73
		<!-- table components -->
74
		<button name="tb_add_row" property="classname=row" icon="icons/row.gif" tooltip="Create new row" action="addComponent(this)"/>
75
		<button name="tb_add_cell" property="classname=cell" icon="icons/cell.gif" tooltip="Create new cell" action="addComponent(this)"/>
76
		<button name="tb_add_header" property="classname=header" icon="icons/header.gif" tooltip="Create new header" action="addComponent(this)"/>
77
		<button name="tb_add_column" property="classname=column" icon="icons/column.gif" tooltip="Create new column" action="addComponent(this)"/>
78

  
79
		<!-- other -->
80
		<button name="tb_add_popupmenu" property="classname=popupmenu" icon="icons/popupmenu.gif" tooltip="Create new popupmenu" action="addComponent(this)"/>
81

  
82
		<!-- later -->
83
		<!--
84
		<button name="tb_add_bean" property="classname=bean" icon="icons/bean.gif" tooltip="Create new bean" action="addComponent(this)" enabled="false"/>
85
		-->
86

  
87
		<!-- placeholder in case there are no buttons add all -->
88
		<separator height="30" width="1"/>
89
	</panel>
90

  
91
	<!-- main workarea -->
92
	<panel left="4" right="4" weightx="1" weighty="1">
93
		<splitpane orientation="horizontal" divider="200" weightx="1" weighty="1">
94

  
95
			<!-- left splitpane: component tree and properties table -->
96
			<splitpane orientation="vertical">
97
				<panel columns="1" weightx="1" weighty="1">
98
					<tree name="tree" angle="true" line="false" selection="single" weightx="1" weighty="1" action="treeSelectionChanged()"/>
99
					<panel top="3" bottom="3" gap="2" scrollable="true">
100
						<button name="tb_edit_copy" icon="icons/edit_copy.gif" tooltip="Copy selected component to internal ThinG clipboard and system clipboard" action="menu_edit_copy()"/>
101
						<button name="tb_edit_cut" icon="icons/edit_cut.gif" tooltip="Cut selected component to internal ThinG clipboard and system clipboard" action="menu_edit_cut()"/>
102
						<button name="tb_edit_paste" icon="icons/edit_paste.gif" tooltip="Paste component from internal ThinG clipboard below selected component" action="menu_edit_paste()"/>
103
						<button name="tb_edit_delete" icon="icons/edit_delete.gif" tooltip="Remove selected component" action="menu_edit_delete()"/>
104
						<separator/>
105
						<button name="tb_edit_moveup" icon="icons/edit_moveup.gif" tooltip="Move selected component up" action="moveComponentUp()"/>
106
						<button name="tb_edit_movedown" icon="icons/edit_movedown.gif" tooltip="Move selected component down" action="moveComponentDown()"/>
107
					</panel>
108
				</panel>
109
				<panel columns="1" gap="5">
110
					<table name="props" selection="single" weightx="1" weighty="1" action="tableSelectionChanged()">
111
						<header>
112
							<column name="props_key" text="Property" width="80" sort="ascent"/>
113
							<column name="props_value" text="Value"/>
114
						</header>
115
					</table>
116
					<panel name="propedit" columns="3" gap="5" weightx="1" border="true" top="5" left="5" bottom="5" right="5">
117
						<label name="propedit_name" text=""/>
118
						<panel name="propedit_panel" gap="5" weightx="1"/>
119
						<button name="propedit_reset" text="Reset" tooltip="Reset to default value" font="10" valign="center" enabled="false" action="propEditReset()"/>
120
					</panel>
121
				</panel>
122
			</splitpane>
123

  
124
			<!-- right splitpane: preview panel -->
125
			<tabbedpane name="tabs" placement="top" selected="1" action="tabSelected(this.selected)">
126
				<!-- Attention: because of an obscure bug in Thinlet.getNextFocusable(), -->
127
				<!-- the tab "XML" must be the first one! If it is not the first panel, Thinlet -->
128
				<!-- runs into an endless loop when the user navigates from the "Preview" tab -->
129
				<!-- to the "XML" tab, trying to set the next focusable component. -->
130
				<tab text="XML" mnemonic="0">
131
					<panel weightx="1" weighty="1">
132
						<textarea name="serialize" editable="false" weightx="1" weighty="1"/>
133
					</panel>
134
				</tab>
135
				<tab text="Preview" mnemonic="0">
136
					<panel name="preview" border="true" scrollable="true" weightx="1" weighty="1"/>
137
				</tab>
138
			</tabbedpane>
139

  
140
		</splitpane>
141
	</panel>
142

  
143
	<!-- status bar at bottom -->
144
	<textfield name="statusbar" editable="false" text="ThinG" weightx="1"/>
145

  
146
</panel>
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/resources/thing/generate.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- jEdit settings: :tabSize=4:indentSize=4:noTabs=true:folding=explicit:collapseFolds=1: -->
3

  
4
<panel columns="1"
5
    bottom="12" left="12" right="12" top="12" gap="12"
6
    init="init(cbGenerateInterface, cbGenerateHandler, cbGenerateAsThinlet, cbGenerateMain, tInterfaceName, tHandlerName, tPackageName, tOutputDir, tPreview, bOk)"
7
    weightx="1" weighty="1"
8
>
9
    <panel border="true" bottom="6" columns="3" font=" bold" gap="6" left="6" right="6" text="Generate" top="6" weightx="1">
10
        <checkbox action="checkboxChanged(this)" mnemonic="0" name="cbGenerateInterface" text="Interface for Handler class" weightx="1"/>
11
        <label for="tInterfaceName" mnemonic="1" text="Interface Name:"/>
12
        <textfield perform="textfieldChanged(this)" name="tInterfaceName" weightx="4"/>
13
        <checkbox action="checkboxChanged(this)" mnemonic="0" name="cbGenerateHandler" selected="true" text="Handler class" weightx="1"/>
14
        <label for="tHandlerName" mnemonic="1" text="Class Name:"/>
15
        <textfield perform="textfieldChanged(this)" name="tHandlerName" weightx="4"/>
16
        <panel/>
17
        <label for="tPackageName" mnemonic="0" text="Package Name:"/>
18
        <textfield perform="textfieldChanged(this)" name="tPackageName" weightx="4"/>
19
        <panel colspan="3" gap="6" weightx="1">
20
            <label for="tOutputDir" mnemonic="7" text="Output Directory:"/>
21
            <textfield name="tOutputDir" weightx="1"/>
22
            <button action="buttonOutputDirClicked()" text="..." tooltip="Select Output Directory"/>
23
        </panel>
24
    </panel>
25
    <panel border="true" bottom="6" columns="1" font=" bold" gap="6" left="6" right="6" text="Handler Options" top="6">
26
        <checkbox action="checkboxChanged(this)" mnemonic="13" name="cbGenerateAsThinlet" text="Handler is a Thinlet"/>
27
        <checkbox action="checkboxChanged(this)" mnemonic="9" name="cbGenerateMain" text="Generate main()"/>
28
    </panel>
29
    <panel border="true" bottom="6" font=" bold" gap="6" left="6" right="6" text="Preview" top="6" weightx="1" weighty="1">
30
        <textarea editable="false" font="Monospaced 11" name="tPreview" weightx="1" weighty="1"/>
31
    </panel>
32
    <panel gap="6" halign="right" weightx="1">
33
        <button action="ok()" icon="icons/ok.gif" mnemonic="0" name="bOk" text="Ok" valign="bottom" weighty="1"/>
34
        <button action="close()" icon="icons/cancel.gif" mnemonic="0" name="bCancel" text="Cancel" type="cancel" valign="bottom" weighty="1"/>
35
    </panel>
36
</panel>
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/resources/thing/icons/componentchooser.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- jEdit settings: :tabSize=4:indentSize=4:noTabs=true:folding=explicit:collapseFolds=1: -->
3

  
4
<panel bottom="12" columns="1" left="12" right="12" top="12" weightx="1" weighty="1">
5
    <list colspan="2" name="list" line="false" weightx="1" weighty="1" action="selectionChanged(this, lSelected)" perform="close()"/>
6
    <panel gap="6" top="12" weightx="1">
7
        <label text="Selected:"/>
8
        <label name="lSelected" text="null"/>
9
        <panel weightx="1"/>
10
        <button name="bOk" text="Ok" icon="icons/ok.gif" mnemonic="0" type="default" action="ok()"/>
11
        <button name="bCancel" text="Cancel" icon="icons/cancel.gif" mnemonic="0" type="cancel" action="close()"/>
12
    </panel>
13
</panel>
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/resources/thing/settings.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- jEdit settings: :tabSize=4:indentSize=4:noTabs=true:folding=explicit:collapseFolds=1: -->
3

  
4
<panel border="true" bottom="12" columns="2" gap="20" left="12" right="12" top="12" weightx="1" weighty="1">
5
    <label icon="icons/thing.gif" rowspan="3" valign="top"/>
6
    <panel border="true" bottom="6" font="bold" gap="6" left="6" right="6" text="Icons" top="6">
7
        <label for="tIconpath" mnemonic="0" text="Icon Path:"/>
8
        <textfield name="tIconpath" weightx="1"/>
9
        <button action="chooseDir(tIconpath, tIconpath.text)" name="bChoose" text="..." tooltip="Choose directory"/>
10
    </panel>
11
    <panel border="true" bottom="6" columns="3" font="bold" gap="6" left="6" right="6" text="XML Output" top="6" weightx="1" weighty="1">
12
        <label for="rbIndentSpace" mnemonic="1" text="Indent Char:"/>
13
        <checkbox group="indentChar" halign="left" name="rbIndentSpace" selected="true" text="Space"/>
14
        <checkbox group="indentChar" halign="left" name="rbIndentTab" text="Tab"/>
15
        <label for="spIndentSize" mnemonic="7" text="Indent Size:"/>
16
        <spinbox colspan="2" end="1" halign="left" maximum="100" minimum="1" name="spIndentSize" start="1" text="4"/>
17
        <label for="tCustomHeader" mnemonic="7" text="Custom Header:" valign="top"/>
18
        <textarea colspan="3" height="80" name="tCustomHeader" weightx="1" weighty="1" width="300"/>
19
    </panel>
20
    <panel gap="6" halign="right" weightx="1">
21
        <button action="ok(tIconpath.text, spIndentSize.text, rbIndentSpace.selected, rbIndentTab.selected, tCustomHeader.text)" icon="icons/ok.gif" mnemonic="0" name="bOk" text="Ok" valign="bottom" weighty="1"/>
22
        <button action="close()" icon="icons/cancel.gif" mnemonic="0" name="bCancel" text="Cancel" type="cancel" valign="bottom" weighty="1"/>
23
    </panel>
24
</panel>
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/resources/thing/version.properties
1
# ThinG version number
2
version=0.1
3

  
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/resources/thing/generator.properties
1
# jEdit settings:
2
# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1:
3
#
4
# Templates for the ThinG Generator.
5
#
6
# Important:
7
# When changing any of the templates, please keep in mind:
8
# - leading whitespace must be enclosed in quotes '...'
9
# - brackets '{' and '}' must be enclosed in quotes unless they denote a parameter
10
# - end-of-lines are always denoted with '\n'. The generator may change this
11
#   into the OS specific line separator such as '\r\n' on Windows or '\r' on Mac.
12

  
13

  
14
# 0: current date (java.util.Date instance)
15
file.header.firstline=\
16
	// Generated by ThinG on {0,date} {0,time}.\n\
17
	\n
18

  
19

  
20
# 0: "<package-spec>", e.g. "foo.bar.baz"
21
file.header.package=\
22
	package {0};\n\
23
	\n
24

  
25

  
26
# 0: additional import statement, e.g. "import thinlet.FrameLauncher;" or ""
27
# 1: JavaDoc comment
28
file.header=\
29
	import thinlet.Thinlet;\n\
30
	{0}\
31
	\n\
32
	\n\
33
	/**\n\
34
	' '* {1}\n\
35
	' '*/\n
36

  
37

  
38
file.footer=\
39
	'}'\n
40

  
41

  
42
# 0: "<classname>"
43
# 1: "[ extends Thinlet]"
44
# 2: "[ implements <interfacename>]"
45
handler.signature=\
46
	public class {0}{1}{2}\n\
47
	'{'\n
48

  
49

  
50
# 0: "<interfacename>"
51
interface.signature=\
52
	public interface {0}\n\
53
	'{'\n
54

  
55

  
56
# 0: "<classname>"
57
# 1: "<thinlet-filename>"
58
class.asThinlet.constructor=\
59
	\n\
60
	'    '/**\n\
61
	'     '* Create a new {0} instance.\n\
62
	'     '*/\n\
63
	'    'public {0}() throws java.io.IOException\n\
64
	'    {'\n\
65
	'        'add(parse("{1}"));\n\
66
	'    }'\n\
67
	\n
68

  
69

  
70
# 0: JavaDoc comment for the method.
71
method.javadoc.header=\
72
	\n\
73
	'    '/**\n\
74
	'     '* {0}\n
75

  
76

  
77
method.javadoc.param.intro=\
78
	'     '*\n
79

  
80

  
81
# 1: "<parameter-name>"
82
# 2: JavaDoc comment for the parameter
83
method.javadoc.param=\
84
	'     '* @param {0} {1}\n
85

  
86

  
87
method.javadoc.footer=\
88
	'     '*/\n
89

  
90

  
91
# 0: full method signature, e.g. "mymethod(String param1, int param2)"
92
method.body.interface=\
93
	'    'public void {0};\n\
94
	\n
95

  
96

  
97
# 0: full method signature, e.g. "mymethod(String param1, int param2)"
98
method.body.handler=\
99
	'    'public void {0}\n\
100
	'    {'\n\
101
	'    }'\n\
102
	\n
103

  
104

  
105
# 0: "<classname>"
106
main.asThinlet=\
107
	\n\
108
	'    '/**\n\
109
	'     '* Show a test frame with the Thinlet contents.\n\
110
	'     '*\n\
111
	'     '* @param args  ignored.\n\
112
	'     '*/\n\
113
	'    'public static void main(String[] args) throws java.io.IOException\n\
114
	'    {'\n\
115
	'        'new FrameLauncher("{0}", new {0}(), 400, 400);\n\
116
	'    }'\n\
117
	\n
118

  
119

  
120
# 0: "<classname>"
121
# 1: "<thinlet-filename>"
122
main.notAsThinlet=\
123
	\n\
124
	'    '/**\n\
125
	'     '* Show a test frame with the Thinlet contents.\n\
126
	'     '*\n\
127
	'     '* @param args  ignored.\n\
128
	'     '*/\n\
129
	'    'public static void main(String[] args) throws java.io.IOException\n\
130
	'    {'\n\
131
	'        'class MyThinlet extends Thinlet\n\
132
	'        {'\n\
133
	'            'public MyThinlet() throws java.io.IOException\n\
134
	'            {'\n\
135
	'                'add(parse("{1}", new {0}()));\n\
136
	'            }'\n\
137
	'        };'\n\
138
	'        'new FrameLauncher("{0}", new MyThinlet(), 400, 400);\n\
139
	'    }'\n\
140
	\n
141

  
142

  
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/resources/README.txt
1
Put into this folder the resources needed by your library classes.
2

  
3
This folder is added to the runtime classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, into this folder you can find some examples of resource bundle 
7
property files that may be used by your library classes.
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/java/thing/GenerateDialog.java
1
// jEdit settings:
2
// :tabSize=4:indentSize=4:noTabs=true:folding=explicit:collapseFolds=1:
3

  
4
package thing;
5

  
6

  
7
import java.awt.Dimension;
8
import java.awt.Frame;
9
import java.io.File;
10
import java.io.FileWriter;
11
import java.io.IOException;
12
import java.io.StringWriter;
13
import java.util.logging.Level;
14
import java.util.logging.Logger;
15

  
16
import thinlet.Thinlet;
17

  
18
import thinletcommons.AntiAliasedThinlet;
19
import thinletcommons.DirChooser;
20
import thinletcommons.MessageDialog;
21
import thinletcommons.ThinletDialog;
22

  
23

  
24
/**
25
 * Dialog "Generate".
26
 *
27
 * @author Dirk Moebius
28
 */
29
public class GenerateDialog
30
{
31

  
32
    //{{{ logging
33
    private static final Logger log = Logger.getLogger("thing");
34
    private static final boolean debug() { return log.isLoggable(Level.FINE); }
35
    //}}}
36

  
37

  
38
    private ThinletDialog dialog;
39
    private Thinlet thinlet;
40
    private Handler thingHandler;
41

  
42
    // components
43
    private Object cbGenerateInterface, cbGenerateHandler, cbGenerateAsThinlet,
44
        cbGenerateMain, tInterfaceName, tHandlerName, tPackageName, tOutputDir,
45
        tPreview, bOk;
46

  
47

  
48
    public GenerateDialog(Frame owner, Handler thingHandler)
49
    {
50
        this.dialog = new ThinletDialog(owner, "Generate Handler Stub Source");
51
        this.thinlet = new AntiAliasedThinlet();
52
        this.thingHandler = thingHandler;
53

  
54
        try
55
        {
56
            Object panel = thinlet.parse("/thing/generate.xml", this);
57
            thinlet.add(panel);
58
        }
59
        catch(Exception e)
60
        {
61
            log.log(Level.SEVERE, "Error parsing generate.xml", e);
62
        }
63

  
64
        dialog.setContent(thinlet);
65
    }
66

  
67

  
68
    public void show()
69
    {
70
        dialog.setSize(new Dimension(500, 460));
71
        dialog.setLocationRelativeTo(dialog.getOwner());
72
        dialog.setVisible(true);
73
    }
74

  
75

  
76
    //{{{ callbacks
77
    public void init(Object cbGenerateInterface, Object cbGenerateHandler,
78
        Object cbGenerateAsThinlet, Object cbGenerateMain, Object tInterfaceName,
79
        Object tHandlerName, Object tPackageName, Object tOutputDir,
80
        Object tPreview, Object bOk)
81
    {
82
        this.cbGenerateInterface = cbGenerateInterface;
83
        this.cbGenerateHandler = cbGenerateHandler;
84
        this.cbGenerateAsThinlet = cbGenerateAsThinlet;
85
        this.cbGenerateMain = cbGenerateMain;
86
        this.tInterfaceName = tInterfaceName;
87
        this.tHandlerName = tHandlerName;
88
        this.tPackageName = tPackageName;
89
        this.tOutputDir = tOutputDir;
90
        this.tPreview = tPreview;
91
        this.bOk = bOk;
92

  
93
        thinlet.setString(tHandlerName, "text", getHandlerClassname());
94
        thinlet.setString(tInterfaceName, "text", getInterfaceName());
95

  
96
        // output directory: directory of thinlet file, or last dir, or user dir
97
        String outputDir = null;
98
        if(thingHandler.getCurrentFile() != null)
99
            outputDir = thingHandler.getCurrentFile().getParentFile().getAbsolutePath();
100
        else
101
            outputDir = Settings.getLastDir();
102
        thinlet.setString(tOutputDir, "text", outputDir);
103

  
104
        updateGui();
105
    }
106

  
107

  
108
    public void checkboxChanged(Object checkbox)
109
    {
110
        updateGui();
111
    }
112

  
113

  
114
    public void textfieldChanged(Object textfield)
115
    {
116
        updatePreview();
117
    }
118

  
119

  
120
    public void buttonOutputDirClicked()
121
    {
122
        String outputDir = thinlet.getString(tOutputDir, "text");
123
        DirChooser chooser = new DirChooser(dialog, "Choose Directory...");
124
        chooser.setSelectedDirectory(new File(outputDir));
125
        chooser.show();
126
        File dir = chooser.getSelectedDirectory();
127
        if(dir != null)
128
            thinlet.setString(tOutputDir, "text", dir.getAbsolutePath());
129
    }
130

  
131

  
132
    public void ok()
133
    {
134
        if(generate())
135
            close();
136
    }
137

  
138

  
139
    public void close()
140
    {
141
        dialog.setVisible(false);
142
    }
143
    //}}}
144

  
145

  
146
    //{{{ private methods
147
    private String getHandlerClassname()
148
    {
149
        String handlerName = thinlet.getString(tHandlerName, "text");
150
        if(handlerName == null || handlerName.trim().length() == 0)
151
            if(thingHandler.getCurrentFile() != null)
152
                return capitalize(getBaseName(thingHandler.getCurrentFile().getName())) + "Handler";
153
            else
154
                return "UnnamedHandler";
155
        else
156
            return getBaseName(handlerName.trim());
157
    }
158

  
159

  
160
    private String getInterfaceName()
161
    {
162
        String interfaceName = thinlet.getString(tInterfaceName, "text");
163
        if(interfaceName == null || interfaceName.trim().length() == 0)
164
            return "I" + getHandlerClassname();
165
        else
166
            return getBaseName(interfaceName.trim());
167
    }
168

  
169

  
170
    private String getPackageName()
171
    {
172
        String packageName = thinlet.getString(tPackageName, "text");
173
        if(packageName == null || packageName.trim().length() == 0)
174
            return null;
175
        else
176
            return packageName.trim();
177
    }
178

  
179

  
180
    private File getOutputFile(File dir, String filename)
181
    {
182
        File f = new File(dir, filename);
183
        if(f.exists())
184
        {
185
            thingHandler.setStatusText("File " + f.getAbsolutePath() + " exists.");
186
            int answer = new MessageDialog(dialog, "File Exists", "File "
187
                + f.getAbsolutePath() + "\nexists. Overwrite?",
188
                MessageDialog.MODE_YES_NO).show();
189
            if(answer != MessageDialog.ACTION_YES)
190
                return null;
191
            if(!f.canWrite())
192
            {
193
                thingHandler.setStatusText("Cannot write to file " + f.getAbsolutePath() + ". (write protected?)");
194
                new MessageDialog(dialog, "Write Error", "Cannot write to file\n"
195
                    + f.getAbsolutePath() + "\n(write protected?)").show();
196
                return null;
197
            }
198
        }
199
        return f;
200
    }
201

  
202

  
203
    private boolean generate()
204
    {
205
        boolean generateHandler = thinlet.getBoolean(cbGenerateHandler, "selected");
206
        boolean generateInterface = thinlet.getBoolean(cbGenerateInterface, "selected");
207

  
208
        if(!generateHandler && !generateInterface)
209
            return true;
210

  
211
        File outputDir = new File(thinlet.getString(tOutputDir, "text"));
212
        if(!outputDir.exists())
213
        {
214
            new MessageDialog(dialog, "Generate Error", "The output directory\n"
215
                + outputDir.getAbsolutePath() + "\ndoes not exist.").show();
216
            return false;
217
        }
218

  
219
        Settings.setLastDir(outputDir.getAbsolutePath());
220

  
221
        try
222
        {
223
            Generator generator = new Generator();
224
            generator.setPackageName(getPackageName());
225
            generator.setGenerateFirstLine(true);
226
            if(generateHandler)
227
            {
228
                File handlerFile = getOutputFile(outputDir, getHandlerClassname() + ".java");
229
                if(handlerFile == null)
230
                    return false;
231
                generator.setWriterForHandler(new FileWriter(handlerFile));
232
                generator.setHandlerClassname(getHandlerClassname());
233
                generator.setGenerateAsThinlet(thinlet.getBoolean(cbGenerateAsThinlet, "selected"));
234
                generator.setGenerateMain(thinlet.getBoolean(cbGenerateMain, "selected"));
235
            }
236
            if(generateInterface)
237
            {
238
                File interfaceFile = getOutputFile(outputDir, getInterfaceName() + ".java");
239
                if(interfaceFile == null)
240
                    return false;
241
                generator.setWriterForInterface(new FileWriter(interfaceFile));
242
                generator.setInterfaceName(getInterfaceName());
243
            }
244

  
245
            String thinletFilename = (thingHandler.getCurrentFile() != null) ?
246
                thingHandler.getCurrentFile().getName() : "untitled.xml";
247

  
248
            generator.generate(thingHandler.getThinlet(), thingHandler.getTopComponent(),
249
                thingHandler.getPropertyManager(), thinletFilename);
250

  
251
            thingHandler.setStatusText("Code generated successfully to directory " + outputDir.getAbsolutePath());
252
            new MessageDialog(dialog, "Success", "Code generated successfully.").show();
253
            return true;
254
        }
255
        catch(IOException e)
256
        {
257
            log.log(Level.SEVERE, "Error generating java code to disk", e);
258
            thingHandler.setStatusText("I/O Error during generate.");
259
            new MessageDialog(dialog, "I/O Error", "An I/O error occurred during generate:\n\n"
260
                + e.toString() + "\n\nSee log for details.").show();
261
        }
262

  
263
        return false;
264
    }
265

  
266

  
267
    private void updateGui()
268
    {
269
        boolean generateHandler = thinlet.getBoolean(cbGenerateHandler, "selected");
270
        boolean generateInterface = thinlet.getBoolean(cbGenerateInterface, "selected");
271
        thinlet.setBoolean(tHandlerName, "enabled", generateHandler);
272
        thinlet.setBoolean(tInterfaceName, "enabled", generateInterface);
273
        thinlet.setBoolean(cbGenerateAsThinlet, "enabled", generateHandler);
274
        thinlet.setBoolean(cbGenerateMain, "enabled", generateHandler);
275
        thinlet.setBoolean(tPackageName, "enabled", generateHandler || generateInterface);
276
        thinlet.setBoolean(tPreview, "enabled", generateHandler || generateInterface);
277
        thinlet.setBoolean(bOk, "enabled", generateHandler || generateInterface);
278

  
279
        updatePreview();
280
    }
281

  
282

  
283
    private void updatePreview()
284
    {
285
        boolean generateHandler = thinlet.getBoolean(cbGenerateHandler, "selected");
286
        boolean generateInterface = thinlet.getBoolean(cbGenerateInterface, "selected");
287

  
288
        if(!generateHandler && !generateInterface)
289
            return;
290

  
291
        // a writer for the preview string
292
        StringWriter sw = new StringWriter();
293

  
294
        Generator generator = new Generator();
295
        generator.setPackageName(getPackageName());
296
        generator.setGenerateFirstLine(false);
297
        if(generateHandler)
298
        {
299
            generator.setHandlerClassname(getHandlerClassname());
300
            generator.setGenerateAsThinlet(thinlet.getBoolean(cbGenerateAsThinlet, "selected"));
301
            generator.setGenerateMain(thinlet.getBoolean(cbGenerateMain, "selected"));
302
            generator.setWriterForHandler(sw);
303
        }
304
        if(generateInterface)
305
        {
306
            generator.setInterfaceName(getInterfaceName());
307
            // if we're generating the handler too, then write the interface
308
            // code to nirvana, otherwise write it to the preview string
309
            generator.setWriterForInterface(generateHandler ? new StringWriter() : sw);
310
        }
311

  
312
        String thinletFilename = (thingHandler.getCurrentFile() != null) ?
313
            thingHandler.getCurrentFile().getName() : "untitled.xml";
314

  
315
        try
316
        {
317
            generator.generate(thingHandler.getThinlet(), thingHandler.getTopComponent(),
318
                thingHandler.getPropertyManager(), thinletFilename);
319
            thinlet.setString(tPreview, "text", sw.toString());
320
        }
321
        catch(IOException e)
322
        {
323
            // unlikely
324
            log.log(Level.SEVERE, "Error generating preview", e);
325
            thinlet.setString(tPreview, "text", e.toString());
326
        }
327
    }
328

  
329

  
330
    private static String capitalize(String s)
331
    {
332
        if(s == null) return null;
333
        if(s.length() == 0) return s;
334
        if(s.length() == 1) return s.toUpperCase();
335
        return s.substring(0, 1).toUpperCase() + s.substring(1);
336
    }
337

  
338

  
339
    /**
340
     * Return the base name of the given filename, without the extension.
341
     */
342
    private static String getBaseName(String filename)
343
    {
344
        int dotpos = filename.indexOf('.');
345
        return dotpos > 0 ? filename.substring(0, dotpos) : filename;
346
    }
347
    //}}} private methods
348

  
349
}
350

  
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/java/thing/ThinletReader.java
1
// jEdit settings:
2
// :tabSize=4:indentSize=4:noTabs=true:folding=explicit:collapseFolds=1:
3

  
4
package thing;
5

  
6

  
7
import java.io.InputStream;
8
import java.io.IOException;
9
import java.io.LineNumberReader;
10
import java.io.Reader;
11
import java.io.StringReader;
12
import java.text.ParseException;
13
import java.util.Hashtable;
14

  
15
import thinlet.Thinlet;
16

  
17
import utils.ReaderInputStream;
18

  
19

  
20
/**
21
 * A SAX parser for Thinlet XML.
22
 * It is actually a thin wrapper around the <code>parse()</code> methods of
23
 * the <code>Thinlet</code> class.
24
 *
25
 * @author Dirk Moebius
26
 */
27
public class ThinletReader
28
{
29

  
30
    /**
31
     * A callback handler for the {@link ThinletReader}.
32
     */
33
    public static interface SAXHandler
34
    {
35
        /**
36
         * Called when the {@link ThinletReader} visits a new element, before
37
         * visiting all of its children.
38
         *
39
         * @param name  the name of the element.
40
         * @param attributelist  the attributes of the element.
41
         */
42
        public void startElement(String name, Hashtable attributelist);
43

  
44
        /**
45
         * Called when the {@link ThinletReader} has finished visiting all
46
         * children of the current element. {@link ThinletReader} calls this
47
         * method in opposite order of the calls to
48
         * {@link #startElement(String,Hashtable)}. Implementors of this
49
         * interface must keep track of the element that has been finished
50
         * themselves, by using a stack for example.
51
         */
52
        public void endElement();
53
    }
54

  
55

  
56
    public ThinletReader()
57
    {
58
    }
59

  
60

  
61
    public void parse(String xml, SAXHandler handler) throws ParseException
62
    {
63
        parse(new StringReader(xml), handler);
64
    }
65

  
66

  
67
    public void parse(Reader reader, SAXHandler handler) throws ParseException
68
    {
69
        LineNumberReader lnr = new LineNumberReader(reader);
70
        try
71
        {
72
            ThinletParser parser = new ThinletParser(handler);
73
            parser.parse(new ReaderInputStream(lnr));
74
        }
75
        catch(Exception e)
76
        {
77
            String msg = e.getMessage();
78
            if(msg == null || msg.length() == 0)
79
                msg = e.getClass().getName();
80
            ParseException pe = new ParseException(msg, lnr.getLineNumber());
81
            pe.setStackTrace(e.getStackTrace());
82
            throw pe;
83
        }
84
    }
85

  
86

  
87
    private static class ThinletParser extends Thinlet
88
    {
89
        private SAXHandler saxhandler;
90

  
91
        public ThinletParser(SAXHandler saxhandler)
92
        {
93
            this.saxhandler = saxhandler;
94
        }
95

  
96
        /**
97
         * Overridden to use <code>Thinlet.parseXML(InputStream)</code>
98
         * (the Thinlet SAX parser) instead of parsing with full validation and
99
         * creation of elements.
100
         *
101
         * @param is  the input stream.
102
         * @param handler  ignored.
103
         * @return <code>null</code>; use {@link SAXHandler#startElement(String,Hashtable)}
104
         * and {@link SAXHandler#endElement()} to be notified of the parsed
105
         * elements.
106
         */
107
        public Object parse(InputStream is, Object handler) throws IOException
108
        {
109
            super.parseXML(is);
110
            return null;
111
        }
112

  
113
        protected void startElement(String name, Hashtable attributelist)
114
        {
115
            if(attributelist == null)
116
                attributelist = new Hashtable();
117
            this.saxhandler.startElement(name, attributelist);
118
        }
119

  
120
        protected void endElement()
121
        {
122
            this.saxhandler.endElement();
123
        }
124
    }
125

  
126
}
127

  
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.27/org.gvsig.scripting.thing/src/main/java/thing/Handler.java
1
// jEdit settings:
2
// :tabSize=4:indentSize=4:noTabs=true:folding=explicit:collapseFolds=1:
3

  
4
package thing;
5

  
6

  
7
import java.awt.Color;
8
import java.awt.Font;
9
import java.awt.Frame;
10
import java.awt.Image;
11
import java.awt.datatransfer.DataFlavor;
12
import java.awt.datatransfer.StringSelection;
13
import java.awt.datatransfer.Transferable;
14
import java.awt.datatransfer.UnsupportedFlavorException;
15
import java.io.BufferedWriter;
16
import java.io.File;
17
import java.io.FileReader;
18
import java.io.FileWriter;
19
import java.io.IOException;
20
import java.io.Reader;
21
import java.io.StringReader;
22
import java.text.ParseException;
23
import java.util.Enumeration;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff