author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 17 Mar 2015 09:07:34 +0000 | |
changeset 3 | 4fa654e15e0d |
parent 2 | 0f7b0c88f894 |
permissions | -rw-r--r-- |
1 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
"{ Package: 'jv:statascripteditor' }" |
4 |
||
5 |
"{ NameSpace: Smalltalk }" |
|
6 |
||
7 |
MultiViewToolApplication subclass:#StataScriptEditor |
|
8 |
instanceVariableNames:'' |
|
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
11 |
category:'Stata Script Editor' |
|
12 |
! |
|
13 |
||
14 |
||
15 |
!StataScriptEditor class methodsFor:'menu specs'! |
|
16 |
||
17 |
mainMenu |
|
18 |
"This resource specification was automatically generated |
|
19 |
by the MenuEditor of ST/X." |
|
20 |
||
21 |
"Do not manually edit this!! If it is corrupted, |
|
22 |
the MenuEditor may not be able to read the specification." |
|
23 |
||
24 |
||
25 |
" |
|
26 |
MenuEditor new openOnClass:StataScriptEditor andSelector:#mainMenu |
|
27 |
(Menu new fromLiteralArrayEncoding:(StataScriptEditor mainMenu)) startUp |
|
28 |
" |
|
29 |
||
30 |
<resource: #menu> |
|
31 |
||
32 |
^ |
|
33 |
#(Menu |
|
34 |
( |
|
35 |
(MenuItem |
|
36 |
label: 'File' |
|
37 |
submenu: |
|
38 |
(Menu |
|
39 |
( |
|
40 |
(MenuItem |
|
41 |
label: 'New' |
|
42 |
itemValue: newWorkspace |
|
1 | 43 |
shortcutKey: Ctrlt |
0 | 44 |
) |
45 |
(MenuItem |
|
46 |
label: 'New Window' |
|
47 |
itemValue: newWindow |
|
1 | 48 |
shortcutKey: Ctrln |
0 | 49 |
) |
50 |
(MenuItem |
|
51 |
label: '-' |
|
52 |
) |
|
53 |
(MenuItem |
|
54 |
label: 'Open...' |
|
55 |
itemValue: menuLoad |
|
56 |
shortcutKey: Ctrlo |
|
57 |
) |
|
58 |
(MenuItem |
|
59 |
label: '-' |
|
60 |
) |
|
61 |
(MenuItem |
|
62 |
label: 'Save' |
|
63 |
itemValue: menuSave |
|
64 |
shortcutKey: Ctrls |
|
65 |
) |
|
66 |
(MenuItem |
|
67 |
label: 'Save As...' |
|
68 |
itemValue: menuSaveAs |
|
69 |
) |
|
70 |
(MenuItem |
|
71 |
label: '-' |
|
72 |
) |
|
73 |
(MenuItem |
|
74 |
label: 'Exit' |
|
75 |
itemValue: closeRequest |
|
76 |
) |
|
77 |
) |
|
78 |
nil |
|
79 |
nil |
|
80 |
) |
|
81 |
) |
|
82 |
(MenuItem |
|
83 |
label: 'Buffers' |
|
84 |
nameKey: Buffer |
|
85 |
submenu: |
|
86 |
(Menu |
|
87 |
( |
|
88 |
(MenuItem |
|
89 |
label: 'Add Buffer' |
|
90 |
itemValue: addWorkspace |
|
91 |
) |
|
92 |
(MenuItem |
|
93 |
label: '-' |
|
94 |
) |
|
95 |
(MenuItem |
|
96 |
label: 'Rename...' |
|
97 |
itemValue: renameWorkspace |
|
98 |
) |
|
99 |
(MenuItem |
|
100 |
label: '-' |
|
101 |
) |
|
102 |
(MenuItem |
|
103 |
enabled: canRemoveWorkspace |
|
104 |
label: 'Remove Buffer' |
|
105 |
itemValue: removeWorkspace |
|
106 |
) |
|
107 |
) |
|
108 |
nil |
|
109 |
nil |
|
110 |
) |
|
111 |
) |
|
112 |
(MenuItem |
|
113 |
label: 'Edit' |
|
114 |
submenu: |
|
115 |
(Menu |
|
116 |
( |
|
117 |
(MenuItem |
|
118 |
enabled: hasSelectionInActiveWorkspace |
|
119 |
label: 'Cut' |
|
120 |
itemValue: cutSelection |
|
121 |
) |
|
122 |
(MenuItem |
|
123 |
enabled: hasSelectionInActiveWorkspace |
|
124 |
label: 'Copy' |
|
125 |
itemValue: copySelection |
|
126 |
) |
|
127 |
(MenuItem |
|
128 |
label: 'Paste' |
|
129 |
itemValue: paste |
|
130 |
) |
|
131 |
(MenuItem |
|
132 |
label: '-' |
|
133 |
) |
|
134 |
(MenuItem |
|
135 |
label: 'Select All' |
|
136 |
itemValue: selectAll |
|
137 |
) |
|
138 |
) |
|
139 |
nil |
|
140 |
nil |
|
141 |
) |
|
142 |
) |
|
143 |
(MenuItem |
|
144 |
label: 'View' |
|
145 |
submenuChannel: viewMenu |
|
146 |
keepLinkedMenu: true |
|
147 |
) |
|
148 |
(MenuItem |
|
149 |
label: 'MENU_Help' |
|
150 |
startGroup: conditionalRight |
|
151 |
submenu: |
|
152 |
(Menu |
|
153 |
( |
|
154 |
(MenuItem |
|
1 | 155 |
label: 'Documenation' |
156 |
itemValue: openDocumentation |
|
157 |
) |
|
158 |
(MenuItem |
|
159 |
label: 'Report Problem' |
|
160 |
itemValue: openBug |
|
161 |
) |
|
162 |
(MenuItem |
|
163 |
label: '-' |
|
164 |
) |
|
165 |
(MenuItem |
|
0 | 166 |
label: 'About this Application...' |
167 |
itemValue: openAboutThisApplication |
|
168 |
) |
|
169 |
) |
|
170 |
nil |
|
171 |
nil |
|
172 |
) |
|
173 |
) |
|
174 |
) |
|
175 |
nil |
|
176 |
nil |
|
177 |
) |
|
1 | 178 |
! ! |
0 | 179 |
|
1 | 180 |
!StataScriptEditor methodsFor:'change & update'! |
181 |
||
182 |
windowLabelPrefix |
|
183 |
^ 'STATA Script Editor' |
|
184 |
||
185 |
"Created: / 17-03-2015 / 04:30:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
0 | 186 |
! ! |
187 |
||
188 |
!StataScriptEditor methodsFor:'defaults'! |
|
189 |
||
190 |
defaultFileNameForLoad |
|
191 |
^ LastOpenedFile |
|
192 |
||
193 |
"Created: / 25-10-2006 / 14:56:19 / cg" |
|
194 |
"Modified: / 10-02-2015 / 22:31:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
195 |
! |
|
196 |
||
197 |
defaultPatternLoad |
|
198 |
^ '*.do; *.smcl' |
|
199 |
||
200 |
"Created: / 25-10-2006 / 14:57:18 / cg" |
|
201 |
"Modified: / 10-02-2015 / 22:33:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
202 |
! ! |
|
203 |
||
1 | 204 |
!StataScriptEditor methodsFor:'help'! |
205 |
||
206 |
aboutThisApplicationText |
|
207 |
"text for an about box for this application. |
|
208 |
Extracts some common info (i.e. class revision, author etc.) from |
|
209 |
the classes documentation." |
|
210 |
||
211 |
^ resources |
|
212 |
stringWithCRs: 'STATA Script Editor (rev %1)\\https://bitbucket.org/janvrany/jv-statascripteditor/wiki/Home\\(C) 2015 Jan Vrany' |
|
213 |
with: (self class revision ? '0.1') |
|
214 |
||
215 |
"Created: / 17-03-2015 / 04:14:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
216 |
! ! |
|
217 |
||
218 |
!StataScriptEditor methodsFor:'hooks'! |
|
219 |
||
220 |
postBuildWith:aBuilder |
|
221 |
super postBuildWith:aBuilder. |
|
222 |
self window label:self windowLabelPrefix |
|
223 |
||
224 |
"Created: / 17-03-2015 / 04:22:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
225 |
! ! |
|
226 |
||
0 | 227 |
!StataScriptEditor methodsFor:'menu actions'! |
228 |
||
229 |
menuSave |
|
230 |
"automatically generated by UIEditor ..." |
|
231 |
||
232 |
"*** the code below performs no action" |
|
233 |
"*** (except for some feedback on the Transcript)" |
|
234 |
"*** Please change as required and accept in the browser." |
|
235 |
"*** (and replace this comment by something more useful ;-)" |
|
236 |
||
237 |
"action to be added ..." |
|
238 |
||
239 |
Transcript showCR:self class name, ': action for #menuSave ...'. |
|
1 | 240 |
! |
241 |
||
3
4fa654e15e0d
Implemented "New Window" menu function
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
242 |
newWindow |
4fa654e15e0d
Implemented "New Window" menu function
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
243 |
self class open |
4fa654e15e0d
Implemented "New Window" menu function
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
244 |
|
4fa654e15e0d
Implemented "New Window" menu function
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
245 |
"Modified: / 17-03-2015 / 09:03:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4fa654e15e0d
Implemented "New Window" menu function
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
246 |
! |
4fa654e15e0d
Implemented "New Window" menu function
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
247 |
|
1 | 248 |
openBug |
249 |
OperatingSystem |
|
250 |
openApplicationForDocument: 'https://bitbucket.org/janvrany/jv-statascripteditor/issues/new' |
|
251 |
operation: #open |
|
252 |
||
253 |
"Modified: / 17-03-2015 / 04:19:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
254 |
! |
|
255 |
||
256 |
openDocumentation |
|
257 |
OperatingSystem |
|
258 |
openApplicationForDocument: 'https://bitbucket.org/janvrany/jv-statascripteditor/wiki/Home' |
|
259 |
operation: #open |
|
260 |
||
261 |
"Modified: / 17-03-2015 / 04:17:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
0 | 262 |
! ! |
263 |
||
264 |
!StataScriptEditor methodsFor:'menu-actions'! |
|
265 |
||
266 |
loadFile:aFileName encoding:encodingSymbolOrNil label:label |
|
267 |
|file ws| |
|
268 |
||
269 |
file := aFileName asFilename. |
|
270 |
[ |
|
271 |
| contents | |
|
272 |
||
273 |
file suffix = 'smcl' ifTrue:[ |
|
274 |
contents := StataScriptLogImporter new import: file |
|
275 |
] ifFalse:[ |
|
276 |
contents := file contents. |
|
277 |
]. |
|
278 |
||
1 | 279 |
ws := self selectedWorkspacesTextView. |
280 |
ws contents asString indexOfNonSeparator ~~ 0 ifTrue:[ |
|
281 |
self addWindow: self createWorkspace named: label. |
|
282 |
ws := self selectedWorkspacesTextView. |
|
283 |
]. |
|
284 |
||
285 |
||
0 | 286 |
encodingSymbolOrNil notNil ifTrue:[ |
287 |
contents := contents encodeFrom:encodingSymbolOrNil into:#'unicode'. |
|
288 |
ws externalEncoding:encodingSymbolOrNil. |
|
289 |
]. |
|
290 |
ws contents:contents. |
|
291 |
ws defaultFileNameForFileDialog:file pathName. |
|
292 |
] on:StreamError do:[:ex| |
|
293 |
Dialog warn:(resources stringWithCRs:'Cannot open "%1":\\%2' with:file asString with:ex description). |
|
294 |
^ self |
|
295 |
]. |
|
296 |
ws modified:false. |
|
297 |
self setLabel:label. |
|
298 |
||
299 |
"Created: / 11-02-2015 / 00:32:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1 | 300 |
"Modified: / 17-03-2015 / 04:28:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 301 |
! |
302 |
||
303 |
menuLoad |
|
304 |
| file | |
|
305 |
||
306 |
file := Dialog |
|
307 |
requestFileName:(resources string:'Open file') |
|
308 |
default:(self defaultFileNameForLoad) |
|
309 |
pattern:(self defaultPatternLoad). |
|
310 |
file size ~~ 0 ifTrue:[ |
|
311 |
self loadFile:file |
|
312 |
] |
|
313 |
||
314 |
"Created: / 10-02-2015 / 22:30:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
315 |
! ! |
|
316 |
||
317 |
!StataScriptEditor methodsFor:'private'! |
|
318 |
||
319 |
createWorkspace |
|
320 |
|ws| |
|
321 |
||
322 |
ws := (HVScrollableView for:Tools::CodeView2). |
|
323 |
^ ws |
|
324 |
||
325 |
"Modified: / 09-12-2010 / 10:55:25 / cg" |
|
326 |
"Modified: / 05-02-2015 / 06:28:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
327 |
! |
|
328 |
||
329 |
isModifiedWorkspace:aView |
|
330 |
^ aView isModified |
|
331 |
||
332 |
"Created: / 05-02-2015 / 06:22:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
333 |
! ! |
|
334 |
||
2
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
335 |
!StataScriptEditor methodsFor:'startup & release'! |
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
336 |
|
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
337 |
closeDownViews |
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
338 |
super closeDownViews. |
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
339 |
Smalltalk isStandAloneApp ifTrue:[ |
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
340 |
WindowGroup scheduledWindowGroups isEmpty ifTrue:[ |
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
341 |
Smalltalk exit: 0 |
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
342 |
]. |
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
343 |
]. |
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
344 |
|
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
345 |
"Created: / 17-03-2015 / 04:36:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
346 |
! ! |
0f7b0c88f894
Terminate application when last window is closed down.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
347 |
|
0 | 348 |
!StataScriptEditor class methodsFor:'documentation'! |
349 |
||
350 |
version_HG |
|
351 |
||
352 |
^ '$Changeset: <not expanded> $' |
|
353 |
! ! |
|
354 |