|
1 "{ Package: 'stx:goodies/xmlsuite/xquery' }" |
|
2 |
|
3 "{ NameSpace: XQuery }" |
|
4 |
|
5 Smalltalk::Workspace subclass:#Workspace |
|
6 instanceVariableNames:'workspaceUI documentProvider parserClass interpreter' |
|
7 classVariableNames:'' |
|
8 poolDictionaries:'' |
|
9 category:'XQuery-UI' |
|
10 ! |
|
11 |
|
12 |
|
13 !Workspace methodsFor:'accessing'! |
|
14 |
|
15 documentProvider |
|
16 |
|
17 documentProvider ifNil:[documentProvider := XMLv2::XPathSimpleDocumentProvider default]. |
|
18 ^ documentProvider |
|
19 |
|
20 "Created: / 15-12-2006 / 07:45:45 / janfrog" |
|
21 "Modified: / 15-12-2006 / 08:52:45 / janfrog" |
|
22 ! |
|
23 |
|
24 documentProvider:anXPathDocumentProvider |
|
25 documentProvider := anXPathDocumentProvider. |
|
26 |
|
27 "Created: / 15-12-2006 / 07:45:45 / janfrog" |
|
28 ! |
|
29 |
|
30 evaluateQueryBlock |
|
31 |
|
32 ^self doItAction |
|
33 |
|
34 "Created: / 17-10-2007 / 13:29:17 / janfrog" |
|
35 ! |
|
36 |
|
37 evaluateQueryBlock: aBlock |
|
38 |
|
39 ^self doItAction: aBlock |
|
40 |
|
41 "Created: / 17-10-2007 / 13:29:23 / janfrog" |
|
42 ! |
|
43 |
|
44 indexClassToUse |
|
45 ^ CellStore::OPSQueryPointersWithParents |
|
46 |
|
47 "Created: / 14-11-2007 / 11:37:25 / janfrog" |
|
48 ! |
|
49 |
|
50 interpreter |
|
51 |
|
52 ^interpreter ifNil:[interpreter := self compilerClass new] |
|
53 |
|
54 "Created: / 29-08-2007 / 09:44:42 / janfrog" |
|
55 ! |
|
56 |
|
57 interpreter: anXQueryExecutor |
|
58 |
|
59 interpreter := anXQueryExecutor |
|
60 |
|
61 "Created: / 29-08-2007 / 09:45:12 / janfrog" |
|
62 ! |
|
63 |
|
64 workspaceUI |
|
65 ^ workspaceUI |
|
66 |
|
67 "Created: / 12-12-2006 / 13:36:33 / janfrog" |
|
68 ! |
|
69 |
|
70 workspaceUI:aWorkspaceUI |
|
71 workspaceUI := aWorkspaceUI. |
|
72 |
|
73 "Created: / 12-12-2006 / 13:36:33 / janfrog" |
|
74 ! ! |
|
75 |
|
76 !Workspace methodsFor:'accessing - selection'! |
|
77 |
|
78 selectionOrTextOfCursorLine:doSelect |
|
79 |sel| |
|
80 |
|
81 "/self accept. |
|
82 sel := self selectionAsString. |
|
83 sel notNil ifTrue:[^ sel]. |
|
84 ^self contents |
|
85 |
|
86 "Created: / 12-12-2006 / 12:32:18 / janfrog" |
|
87 "Modified: / 12-04-2007 / 13:05:54 / janfrog" |
|
88 ! ! |
|
89 |
|
90 !Workspace methodsFor:'compiler interface'! |
|
91 |
|
92 compilerClass |
|
93 ^ compilerClass ? XQueryExecutor |
|
94 |
|
95 "Created: / 12-12-2006 / 12:33:07 / janfrog" |
|
96 ! |
|
97 |
|
98 parserClass |
|
99 ^ parserClass ? XQueryParser |
|
100 |
|
101 "Created: / 12-04-2007 / 12:51:11 / janfrog" |
|
102 ! ! |
|
103 |
|
104 !Workspace methodsFor:'events'! |
|
105 |
|
106 keyPress:key x:x y:y |
|
107 <resource: #keyboard (#Ctrld #Ctrlp #Ctrli)> |
|
108 |
|
109 |
|
110 (key == #Ctrld) ifTrue:[^ self doIt]. |
|
111 (key == #Ctrli) ifTrue:[^ self inspectIt]. |
|
112 (key == #Ctrlp) ifTrue:[^ self printIt]. |
|
113 |
|
114 ^super keyPress:key x:x y:y. |
|
115 |
|
116 "Created: / 10-02-2007 / 10:34:35 / janfrog" |
|
117 "Modified: / 12-04-2007 / 13:27:40 / janfrog" |
|
118 ! ! |
|
119 |
|
120 !Workspace methodsFor:'initialization & release'! |
|
121 |
|
122 executeDoIt:aString |
|
123 |
|
124 ^self interpreter |
|
125 setDocumentProvider: self documentProvider; |
|
126 evaluate: aString |
|
127 |
|
128 "Created: / 12-12-2006 / 12:46:24 / janfrog" |
|
129 "Modified: / 29-08-2007 / 09:44:15 / janfrog" |
|
130 ! ! |
|
131 |
|
132 !Workspace methodsFor:'menu & menu actions'! |
|
133 |
|
134 doIt |
|
135 "user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
136 and finally restore cursor; return result of evaluation" |
|
137 |
|
138 |res| |
|
139 |
|
140 self indexClassToUse isNil ifFalse:[ |
|
141 |selectedText| |
|
142 |
|
143 selectedText := self selectionOrTextOfCursorLine. |
|
144 interpreter indexClassToUse:self indexClassToUse. |
|
145 self do:(selectedText) withValueDo:[:result | res := result. ]. |
|
146 |
|
147 workspaceUI |
|
148 ifNotNil:[workspaceUI addResult:res]. |
|
149 ]. |
|
150 interpreter indexClassToUse:nil. |
|
151 self do:(self selectionOrTextOfCursorLine) withValueDo:[:result | res := result. ]. |
|
152 |
|
153 workspaceUI ifNotNil:[workspaceUI addResult:res] |
|
154 |
|
155 "janfrogs ver" |
|
156 "^ self |
|
157 do:(self selectionOrTextOfCursorLine) |
|
158 withValueDo:[:result | workspaceUI ifNotNil:[workspaceUI addResult: result]]" |
|
159 |
|
160 "Created: / 12-12-2006 / 13:24:09 / janfrog" |
|
161 |
|
162 "Modified: / 14-11-2007 / 12:40:21 / janfrog" |
|
163 "Modified: / 20-11-2007 / 12:36:15 / beyboy" |
|
164 ! |
|
165 |
|
166 inspectIt |
|
167 "user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
168 and start an inspector on the result" |
|
169 |
|
170 |shifted| |
|
171 |
|
172 shifted := self sensor shiftDown. |
|
173 |
|
174 ^ self |
|
175 do:(self selectionOrTextOfCursorLine) |
|
176 withValueDo:[:result | shifted ifTrue:[result basicInspect] ifFalse:[result asDocumentFragment inspect] ] |
|
177 |
|
178 "Modified: / 16-05-1998 / 16:44:44 / cg" |
|
179 "Created: / 12-12-2006 / 12:42:23 / janfrog" |
|
180 ! |
|
181 |
|
182 inspectQuery |
|
183 "user selected 'inspect query' from menu; use doIt to evaluate the code |
|
184 and start an inspector on the result" |
|
185 |
|
186 |shifted ast | |
|
187 |
|
188 shifted := self sensor shiftDown. |
|
189 ast := self parserClass parse:(self selectionOrTextOfCursorLine). |
|
190 shifted |
|
191 ifTrue:[ast basicInspect] |
|
192 ifFalse:[ast inspect] |
|
193 "/(self selectionOrTextOfCursorLine) |
|
194 |
|
195 "Modified: / 16-05-1998 / 16:44:44 / cg" |
|
196 "Created: / 12-04-2007 / 12:50:28 / janfrog" |
|
197 "Modified: / 31-10-2007 / 12:28:36 / janfrog" |
|
198 ! |
|
199 |
|
200 printIt |
|
201 "user selected 'printIt' from menu; use doIt to evaluate the code |
|
202 and insert result of evaluation into my text. |
|
203 If the text is readOnly, do nothing." |
|
204 |
|
205 self isReadOnly ifTrue:[ |
|
206 self beep |
|
207 ] ifFalse:[ |
|
208 self |
|
209 do:(self selectionOrTextOfCursorLine) |
|
210 withValueDo:[:result | |
|
211 self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
|
212 self insertSelectedStringAtCursor:(result asDocumentFragment asColorXMLString "printString") |
|
213 ] |
|
214 ] |
|
215 |
|
216 "Modified: / 16-05-1998 / 16:44:44 / cg" |
|
217 "Created: / 12-12-2006 / 12:36:05 / janfrog" |
|
218 ! ! |
|
219 |
|
220 !Workspace methodsFor:'selection'! |
|
221 |
|
222 selectionAsString |
|
223 |
|
224 ^super selectionAsString |
|
225 |
|
226 "Created: / 14-02-2007 / 00:44:30 / janfrog" |
|
227 ! ! |
|
228 |
|
229 !Workspace class methodsFor:'documentation'! |
|
230 |
|
231 version |
|
232 ^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xquery/XQuery__Workspace.st,v 1.17 2007-12-05 21:11:34 vranyj1 Exp $' |
|
233 ! ! |