|
1 "{ Package: 'stx:libtool' }" |
|
2 |
|
3 ToolApplicationModel subclass:#WorkspaceApplication |
|
4 instanceVariableNames:'' |
|
5 classVariableNames:'' |
|
6 poolDictionaries:'' |
|
7 category:'Interface-Smalltalk' |
|
8 ! |
|
9 |
|
10 |
|
11 !WorkspaceApplication class methodsFor:'interface specs'! |
|
12 |
|
13 windowSpec |
|
14 "This resource specification was automatically generated |
|
15 by the UIPainter of ST/X." |
|
16 |
|
17 "Do not manually edit this!! If it is corrupted, |
|
18 the UIPainter may not be able to read the specification." |
|
19 |
|
20 " |
|
21 UIPainter new openOnClass:WorkspaceApplication andSelector:#windowSpec |
|
22 WorkspaceApplication new openInterface:#windowSpec |
|
23 WorkspaceApplication open |
|
24 " |
|
25 |
|
26 <resource: #canvas> |
|
27 |
|
28 ^ |
|
29 #(#FullSpec |
|
30 #name: #windowSpec |
|
31 #window: |
|
32 #(#WindowSpec |
|
33 #label: 'Workspace' |
|
34 #name: 'Workspace' |
|
35 #min: #(#Point 10 10) |
|
36 #max: #(#Point 1024 768) |
|
37 #bounds: #(#Rectangle 170 332 602 573) |
|
38 #menu: #mainMenu |
|
39 ) |
|
40 #component: |
|
41 #(#SpecCollection |
|
42 #collection: #( |
|
43 #(#ArbitraryComponentSpec |
|
44 #name: 'WorkspaceView' |
|
45 #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
46 #hasHorizontalScrollBar: true |
|
47 #hasVerticalScrollBar: true |
|
48 #miniScrollerVertical: false |
|
49 #hasBorder: false |
|
50 #component: #Workspace |
|
51 ) |
|
52 ) |
|
53 |
|
54 ) |
|
55 ) |
|
56 ! ! |
|
57 |
|
58 !WorkspaceApplication class methodsFor:'menu specs'! |
|
59 |
|
60 mainMenu |
|
61 "This resource specification was automatically generated |
|
62 by the MenuEditor of ST/X." |
|
63 |
|
64 "Do not manually edit this!! If it is corrupted, |
|
65 the MenuEditor may not be able to read the specification." |
|
66 |
|
67 " |
|
68 MenuEditor new openOnClass:WorkspaceApplication andSelector:#mainMenu |
|
69 (Menu new fromLiteralArrayEncoding:(WorkspaceApplication mainMenu)) startUp |
|
70 " |
|
71 |
|
72 <resource: #menu> |
|
73 |
|
74 ^ |
|
75 #(#Menu |
|
76 #( |
|
77 #(#MenuItem |
|
78 #label: 'File' |
|
79 #translateLabel: true |
|
80 #submenu: |
|
81 #(#Menu |
|
82 #( |
|
83 #(#MenuItem |
|
84 #label: 'New' |
|
85 #translateLabel: true |
|
86 #value: #menuNew |
|
87 #isVisible: false |
|
88 ) |
|
89 #(#MenuItem |
|
90 #label: '-' |
|
91 #isVisible: false |
|
92 ) |
|
93 #(#MenuItem |
|
94 #label: 'Load File...' |
|
95 #translateLabel: true |
|
96 #value: #menuLoad |
|
97 ) |
|
98 #(#MenuItem |
|
99 #label: '-' |
|
100 ) |
|
101 #(#MenuItem |
|
102 #label: 'Save As...' |
|
103 #translateLabel: true |
|
104 #value: #menuSaveAs |
|
105 ) |
|
106 #(#MenuItem |
|
107 #label: '-' |
|
108 ) |
|
109 #(#MenuItem |
|
110 #label: 'Exit' |
|
111 #translateLabel: true |
|
112 #value: #closeRequest |
|
113 ) |
|
114 ) |
|
115 nil |
|
116 nil |
|
117 ) |
|
118 ) |
|
119 #(#MenuItem |
|
120 #label: 'Edit' |
|
121 #translateLabel: true |
|
122 #submenu: |
|
123 #(#Menu |
|
124 #( |
|
125 #(#MenuItem |
|
126 #label: 'Copy' |
|
127 #translateLabel: true |
|
128 #value: #copySelection |
|
129 ) |
|
130 #(#MenuItem |
|
131 #label: 'Cut' |
|
132 #translateLabel: true |
|
133 #value: #cutSelection |
|
134 ) |
|
135 #(#MenuItem |
|
136 #label: 'Paste' |
|
137 #translateLabel: true |
|
138 #value: #paste |
|
139 ) |
|
140 ) |
|
141 nil |
|
142 nil |
|
143 ) |
|
144 ) |
|
145 #(#MenuItem |
|
146 #label: 'Smalltalk' |
|
147 #translateLabel: true |
|
148 #submenu: |
|
149 #(#Menu |
|
150 #( |
|
151 #(#MenuItem |
|
152 #label: 'DoIt' |
|
153 #translateLabel: true |
|
154 #value: #doIt |
|
155 ) |
|
156 #(#MenuItem |
|
157 #label: 'PrintIt' |
|
158 #translateLabel: true |
|
159 #value: #printIt |
|
160 ) |
|
161 #(#MenuItem |
|
162 #label: 'InspectIt' |
|
163 #translateLabel: true |
|
164 #value: #inspectIt |
|
165 ) |
|
166 #(#MenuItem |
|
167 #label: '-' |
|
168 ) |
|
169 #(#MenuItem |
|
170 #label: 'Browse' |
|
171 #translateLabel: true |
|
172 #value: #browseIt |
|
173 ) |
|
174 ) |
|
175 nil |
|
176 nil |
|
177 ) |
|
178 ) |
|
179 #(#MenuItem |
|
180 #label: 'Help' |
|
181 #translateLabel: true |
|
182 #startGroup: #right |
|
183 #submenu: |
|
184 #(#Menu |
|
185 #( |
|
186 #(#MenuItem |
|
187 #label: 'Documentation' |
|
188 #translateLabel: true |
|
189 #value: #openDocumentation |
|
190 ) |
|
191 #(#MenuItem |
|
192 #label: '-' |
|
193 ) |
|
194 #(#MenuItem |
|
195 #label: 'About this Application' |
|
196 #translateLabel: true |
|
197 #value: #openAboutThisApplication |
|
198 ) |
|
199 ) |
|
200 nil |
|
201 nil |
|
202 ) |
|
203 ) |
|
204 ) |
|
205 nil |
|
206 nil |
|
207 ) |
|
208 ! ! |
|
209 |
|
210 !WorkspaceApplication methodsFor:'accessing'! |
|
211 |
|
212 workspaceView |
|
213 ^ (builder componentAt:#WorkspaceView) |
|
214 ! ! |
|
215 |
|
216 !WorkspaceApplication methodsFor:'initialization & release'! |
|
217 |
|
218 closeRequest |
|
219 (self askIfModified:'Close without saving ?' yesButton:'Close') ifFalse:[ |
|
220 ^ self |
|
221 ]. |
|
222 |
|
223 ^ super closeRequest |
|
224 ! |
|
225 |
|
226 postBuildWith:aBuilder |
|
227 "This is a hook method generated by the Browser. |
|
228 It will be invoked during the initialization of your app/dialog, |
|
229 after all of the visual components have been built, |
|
230 but BEFORE the top window is made visible. |
|
231 Add any app-specific actions here (reading files, setting up |
|
232 values etc.)" |
|
233 |
|
234 "/ add any code here ... |
|
235 |
|
236 ^ super postBuildWith:aBuilder |
|
237 ! ! |
|
238 |
|
239 !WorkspaceApplication methodsFor:'menu actions'! |
|
240 |
|
241 browseIt |
|
242 self workspaceView browseIt |
|
243 ! |
|
244 |
|
245 copySelection |
|
246 self workspaceView copySelection |
|
247 ! |
|
248 |
|
249 cutSelection |
|
250 self workspaceView cutSelection |
|
251 ! |
|
252 |
|
253 doIt |
|
254 self workspaceView doIt |
|
255 ! |
|
256 |
|
257 inspectIt |
|
258 self workspaceView inspectIt |
|
259 ! |
|
260 |
|
261 menuLoad |
|
262 |file| |
|
263 |
|
264 (self askIfModified:'Text was modified. Load anyway ?' yesButton:'Load'). |
|
265 file := Dialog requestFileName:'Load file:'. |
|
266 file size > 0 ifTrue:[ |
|
267 self workspaceView contents:file asFilename contentsOfEntireFile. |
|
268 ] |
|
269 ! |
|
270 |
|
271 menuSaveAs |
|
272 |file| |
|
273 |
|
274 (self askIfModified:'Text was modified. Save anyway ?' yesButton:'Load'). |
|
275 file := Dialog requestFileName:'Save file:'. |
|
276 file size > 0 ifTrue:[ |
|
277 self workspaceView saveAs:file. |
|
278 ] |
|
279 ! |
|
280 |
|
281 openDocumentation |
|
282 "opens the documentation file" |
|
283 |
|
284 self openHTMLDocument: 'tools/misc/TOP.html#WORKSPACE' |
|
285 ! |
|
286 |
|
287 paste |
|
288 self workspaceView paste |
|
289 ! |
|
290 |
|
291 printIt |
|
292 self workspaceView printIt |
|
293 ! ! |
|
294 |
|
295 !WorkspaceApplication methodsFor:'private'! |
|
296 |
|
297 askIfModified:question yesButton:yesButtonText |
|
298 "tell user, that code has been modified - let her confirm" |
|
299 |
|
300 |textView| |
|
301 |
|
302 textView := self workspaceView. |
|
303 (textView modified not or:[textView contentsWasSaved]) ifTrue:[ |
|
304 ^ true |
|
305 ]. |
|
306 (Dialog |
|
307 confirm:(resources string:question) withCRs |
|
308 yesLabel:(resources at:yesButtonText) |
|
309 noLabel:(resources at:'Cancel')) |
|
310 ifTrue:[ |
|
311 "/ reset modified flag so question is asked only once |
|
312 textView modified:false. |
|
313 ^ true |
|
314 ]. |
|
315 ^ false |
|
316 |
|
317 "Modified: 2.10.1997 / 14:23:47 / stefan" |
|
318 ! ! |
|
319 |
|
320 !WorkspaceApplication class methodsFor:'documentation'! |
|
321 |
|
322 version |
|
323 ^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.1 2001-09-12 07:24:25 cg Exp $' |
|
324 ! ! |