-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchivist_utility_app.rbbas
172 lines (136 loc) · 3.71 KB
/
archivist_utility_app.rbbas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#tag Class
Protected Class archivist_utility_app
Inherits Application
#tag Event
Sub Open()
#if TargetMacOS
prefs_file = SpecialFolder.Preferences.Child("Archivist Utility.plist")
#else
prefs_file = SpecialFolder.Preferences.Child("Archivist Utility.xml")
#endif
LoadPrefs
End Sub
#tag EndEvent
#tag MenuHandler
Function About() As Boolean Handles About.Action
Msgbox app.versionstring + chr(10) + chr(10) + "Copyright ©2009 University of Alabama" + chr(10) + "Written by Tonio Loewald <[email protected]>"
Return True
End Function
#tag EndMenuHandler
#tag MenuHandler
Function FileNewSpreadsheetXSLXMLWindow() As Boolean Handles FileNewSpreadsheetXSLXMLWindow.Action
NewXMLGenerator
Return True
End Function
#tag EndMenuHandler
#tag MenuHandler
Function FileNewXMLXSLHTMLWindow() As Boolean Handles FileNewXMLXSLHTMLWindow.Action
NewXSLEditor
Return True
End Function
#tag EndMenuHandler
#tag MenuHandler
Function FileQuit() As Boolean Handles FileQuit.Action
SavePrefs
Return False
End Function
#tag EndMenuHandler
#tag Method, Flags = &h0
Sub LoadPrefs()
dim prefs as XmlDocument
dim t as string
dim input as TextInputStream
dim window_list as XmlNodeList
dim window_spec as XmlNode
dim w as window
dim i as integer
if not prefs_file.exists then
Raise New RuntimeException
end if
input = prefs_file.OpenAsTextFile
t = input.readAll
input.close
prefs = new XmlDocument
prefs.loadXml( t )
window_list = prefs.Child(0).Xql(".//windows/window")
for i = 0 to window_list.Length - 1
window_spec = window_list.item(i)
select case window_spec.GetAttribute("class")
case "XSL_Editor"
w = new XSL_Editor
case "XML_Generator"
w = new XML_Generator
end select
w.left = val( window_spec.GetAttribute("x") )
w.top = val( window_spec.GetAttribute("y") )
w.width = val( window_spec.GetAttribute("w") )
w.height = val( window_spec.GetAttribute("h") )
next
Exception
NewXSLEditor
NewXMLGenerator
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub NewXMLGenerator()
dim w as window
w = new XML_Generator
w.show
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub NewXSLEditor()
dim w as window
w = new XSL_Editor
w.show
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub SavePrefs()
dim output as TextOutputStream
dim i as integer
dim w as window
dim t as string
t = "<?xml version=""1.0"" encoding=""UTF-8""?>"
t = t + "<prefs>"
t = t + "<windows>"
for i = windowcount - 1 downTo 0
w = window(i)
t = t + "<window class=""" + w.className + """"
t = t + " x=""" + str(w.left) + """"
t = t + " y=""" + str(w.top) + """"
t = t + " w=""" + str(w.width) + """"
t = t + " h=""" + str(w.height) + """/>"
next
t = t + "</windows>"
t = t + "</prefs>"
t = PrettierXML( t )
output = prefs_file.CreateTextFile
output.write t
output.close
#if DebugBuild
prefs_file.parent.launch
#endif
End Sub
#tag EndMethod
#tag Property, Flags = &h0
prefs_file As folderItem
#tag EndProperty
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
return "Archivist Utility v" + app.ShortVersion + ", (built: " + app.BuildDate.shortDate + ")"
End Get
#tag EndGetter
versionstring As string
#tag EndComputedProperty
#tag ViewBehavior
#tag ViewProperty
Name="versionstring"
Group="Behavior"
Type="string"
EditorType="MultiLineEditor"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass