author | Claus Gittinger <cg@exept.de> |
Mon, 08 Feb 2010 13:03:53 +0100 | |
changeset 2823 | bd8a57d5aa47 |
parent 2819 | 691218db6b3c |
child 2928 | 37224b335551 |
permissions | -rw-r--r-- |
546 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1482 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
395 | 14 |
Object subclass:#DropObject |
860 | 15 |
instanceVariableNames:'theObject displayObject' |
395 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
875 | 18 |
category:'Interface-DragAndDrop' |
395 | 19 |
! |
20 |
||
403 | 21 |
DropObject class instanceVariableNames:'DisplayObject' |
22 |
||
23 |
" |
|
1482 | 24 |
No other class instance variables are inherited by this class. |
403 | 25 |
" |
26 |
! |
|
27 |
||
1482 | 28 |
DropObject subclass:#Class |
395 | 29 |
instanceVariableNames:'' |
30 |
classVariableNames:'' |
|
31 |
poolDictionaries:'' |
|
32 |
privateIn:DropObject |
|
33 |
! |
|
34 |
||
1277
ad8a630c9acd
try bitmaps in package directory
Claus Gittinger <cg@exept.de>
parents:
1112
diff
changeset
|
35 |
DropObject subclass:#Color |
ad8a630c9acd
try bitmaps in package directory
Claus Gittinger <cg@exept.de>
parents:
1112
diff
changeset
|
36 |
instanceVariableNames:'' |
860 | 37 |
classVariableNames:'' |
38 |
poolDictionaries:'' |
|
39 |
privateIn:DropObject |
|
40 |
! |
|
41 |
||
1482 | 42 |
DropObject subclass:#File |
43 |
instanceVariableNames:'info isHtmlFile isImageFile isPrintable' |
|
44 |
classVariableNames:'' |
|
45 |
poolDictionaries:'' |
|
46 |
privateIn:DropObject |
|
47 |
! |
|
48 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
49 |
DropObject::File subclass:#FileInArchive |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
50 |
instanceVariableNames:'' |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
51 |
classVariableNames:'' |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
52 |
poolDictionaries:'' |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
53 |
privateIn:DropObject |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
54 |
! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
55 |
|
395 | 56 |
DropObject subclass:#Image |
57 |
instanceVariableNames:'' |
|
58 |
classVariableNames:'' |
|
59 |
poolDictionaries:'' |
|
60 |
privateIn:DropObject |
|
61 |
! |
|
62 |
||
1482 | 63 |
DropObject subclass:#Method |
64 |
instanceVariableNames:'' |
|
65 |
classVariableNames:'' |
|
66 |
poolDictionaries:'' |
|
67 |
privateIn:DropObject |
|
68 |
! |
|
69 |
||
70 |
DropObject subclass:#Text |
|
71 |
instanceVariableNames:'' |
|
72 |
classVariableNames:'' |
|
73 |
poolDictionaries:'' |
|
74 |
privateIn:DropObject |
|
75 |
! |
|
76 |
||
546 | 77 |
!DropObject class methodsFor:'documentation'! |
78 |
||
79 |
copyright |
|
80 |
" |
|
81 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
82 |
All Rights Reserved |
|
83 |
||
84 |
This software is furnished under a license and may be used |
|
85 |
only in accordance with the terms of that license and with the |
|
86 |
inclusion of the above copyright notice. This software may not |
|
87 |
be provided or otherwise made available to, or used by, any |
|
88 |
other person. No title to or ownership of the software is |
|
89 |
hereby transferred. |
|
90 |
" |
|
91 |
||
92 |
||
93 |
! |
|
94 |
||
95 |
documentation |
|
96 |
" |
|
97 |
instances of myself and subclasses wrap objects which are being |
|
98 |
dragged (and dropped). |
|
99 |
Any object can be dragged, but for some often encountered types, |
|
100 |
specialized subclasses are provided, which react to certain queries. |
|
101 |
||
102 |
[see also:] |
|
103 |
DragAndDropManager |
|
104 |
||
105 |
[author:] |
|
106 |
Claus Atzkern |
|
107 |
" |
|
108 |
! ! |
|
395 | 109 |
|
110 |
!DropObject class methodsFor:'instance creation'! |
|
111 |
||
1112 | 112 |
dropObjectClassFor:someThing |
113 |
"given something to drag&drop, return an appropriate |
|
114 |
dropObject class for it." |
|
2590 | 115 |
|
116 |
"/ no, no visitor pattern here - I though about it and I think it sucks here. |
|
117 |
"/ reason: its al local and known here, which DropObjects I am willing to support. |
|
118 |
"/ addint double dispatch (acceptDropSourceVisitor:) adds a dependency to 6 other classes, |
|
119 |
"/ and worse: if I ever change my mind to allow for another one, I would have to change |
|
120 |
"/ that class as well (to add its (accept...) implementaion. |
|
121 |
"/ So, the typeSwitch below is OK. |
|
1112 | 122 |
|
2589 | 123 |
someThing isColor ifTrue:[^ DropObject::Color]. |
124 |
someThing isImageOrForm ifTrue:[^ DropObject::Image]. |
|
125 |
someThing isFilename ifTrue:[^ DropObject::File]. |
|
126 |
someThing isString ifTrue:[^ DropObject::Text]. |
|
127 |
someThing isBehavior ifTrue:[^ DropObject::Class]. |
|
128 |
someThing isMethod ifTrue:[^ DropObject::Method]. |
|
1112 | 129 |
^ self |
130 |
! |
|
131 |
||
395 | 132 |
new:someThing |
547 | 133 |
"create an instance on something |
395 | 134 |
" |
135 |
|cls| |
|
136 |
||
1112 | 137 |
cls := self dropObjectClassFor:someThing. |
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
138 |
^ self newInstanceOf:cls for:someThing |
547 | 139 |
|
140 |
"Modified: 19.4.1997 / 17:19:55 / cg" |
|
395 | 141 |
! |
142 |
||
1482 | 143 |
newClass:aClass |
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
144 |
"create an instance for a class (dragging a class from a browser)" |
1482 | 145 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
146 |
^ self newInstanceOf:DropObject::Class for:aClass |
1482 | 147 |
! |
148 |
||
395 | 149 |
newColor:aColor |
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
150 |
"create an instance for a color (dragging a color from a bitmap editor)" |
547 | 151 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
152 |
^ self newInstanceOf:DropObject::Color for:aColor |
547 | 153 |
|
154 |
"Modified: 19.4.1997 / 17:20:17 / cg" |
|
395 | 155 |
! |
156 |
||
157 |
newFile:aFilename |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
158 |
"create an instance for a file or directory (dragging a file in a fileBrowser)" |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
159 |
|
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
160 |
^ self newInstanceOf:DropObject::File for:aFilename |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
161 |
! |
547 | 162 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
163 |
newFileInArchive:aFilename |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
164 |
"create an instance for a file or directory contained inside an archive |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
165 |
(dragging a file from an archive shown in a fileBrowser)" |
547 | 166 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
167 |
^ self newInstanceOf:DropObject::FileInArchive for:aFilename |
395 | 168 |
! |
169 |
||
170 |
newImage:anImageOrForm |
|
547 | 171 |
"create an instance for an image" |
172 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
173 |
^ self newInstanceOf:DropObject::Image for:anImageOrForm |
547 | 174 |
|
175 |
"Modified: 19.4.1997 / 17:20:37 / cg" |
|
395 | 176 |
! |
177 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
178 |
newInstanceOf:aClass for:someThing |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
179 |
"create an instance on something |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
180 |
" |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
181 |
^ aClass new theObject:someThing |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
182 |
|
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
183 |
"Modified: 19.4.1997 / 17:19:55 / cg" |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
184 |
! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
185 |
|
1482 | 186 |
newMethod:aMethod |
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
187 |
"create an instance for a method (dragging a method in a browser)" |
1482 | 188 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
189 |
^ self newInstanceOf:DropObject::Method for:aMethod |
1482 | 190 |
! |
191 |
||
395 | 192 |
newText:aTextOrString |
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
193 |
"create an instance for some text (dragging some text from an editor)" |
547 | 194 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
195 |
^ self newInstanceOf:DropObject::Text for:aTextOrString |
547 | 196 |
|
197 |
"Modified: 19.4.1997 / 17:20:46 / cg" |
|
395 | 198 |
! ! |
199 |
||
403 | 200 |
!DropObject class methodsFor:'defaults'! |
201 |
||
202 |
displayObject |
|
546 | 203 |
"return some object which is shown while dragging; |
204 |
here an image based upon my displayObjectName is returned. |
|
205 |
Either this method or #displayObjectName is usually redefined |
|
206 |
in subclasses" |
|
403 | 207 |
|
208 |
DisplayObject notNil ifTrue:[ |
|
209 |
^ DisplayObject |
|
210 |
]. |
|
1292 | 211 |
DisplayObject := Smalltalk imageFromFileNamed:(self displayObjectName) forClass:self. |
403 | 212 |
^ DisplayObject |
546 | 213 |
|
214 |
"Modified: 19.4.1997 / 13:04:05 / cg" |
|
215 |
! |
|
216 |
||
217 |
displayObject:aDisplayObject |
|
218 |
"set the object which is shown while dragging; |
|
219 |
this object must understand #displayOn:x:y: (i.e. the displayObject |
|
220 |
protocol). The object is kept per class for ALL future drag operations. |
|
221 |
Useful to change the default images in subclasses." |
|
222 |
||
223 |
DisplayObject := aDisplayObject |
|
224 |
||
225 |
"Modified: 19.4.1997 / 15:42:10 / cg" |
|
403 | 226 |
! |
227 |
||
228 |
displayObjectName |
|
546 | 229 |
"return the name of a bitmap image file, which is used |
230 |
during a drag. |
|
231 |
Here, a dummy file is returned." |
|
232 |
||
403 | 233 |
^ 'bitmaps/xpmBitmaps/plain_pixmaps/balloon3.xpm' |
234 |
||
546 | 235 |
"Modified: 19.4.1997 / 13:54:13 / cg" |
403 | 236 |
! ! |
237 |
||
395 | 238 |
!DropObject methodsFor:'accessing'! |
239 |
||
860 | 240 |
displayObject |
241 |
"return my graphical representation - here a default is returned" |
|
242 |
||
243 |
^ displayObject ? (self class displayObject) |
|
244 |
||
245 |
||
246 |
! |
|
247 |
||
248 |
displayObject:anObject |
|
249 |
"set my graphical representation" |
|
250 |
||
251 |
displayObject := anObject |
|
252 |
||
253 |
! |
|
254 |
||
395 | 255 |
theObject |
546 | 256 |
"return the real object represented by the receiver" |
395 | 257 |
|
546 | 258 |
^ theObject |
259 |
||
260 |
"Modified: 19.4.1997 / 12:53:01 / cg" |
|
261 |
! |
|
395 | 262 |
|
263 |
theObject:something |
|
546 | 264 |
"set the real object represented by the receiver" |
395 | 265 |
|
546 | 266 |
theObject := something. |
267 |
||
268 |
"Modified: 19.4.1997 / 12:53:10 / cg" |
|
269 |
! ! |
|
395 | 270 |
|
271 |
!DropObject methodsFor:'testing'! |
|
272 |
||
1482 | 273 |
isClassObject |
274 |
"return true, if the dropObject represents some class" |
|
275 |
||
276 |
^ false |
|
277 |
! |
|
278 |
||
395 | 279 |
isColorObject |
546 | 280 |
"return true, if the dropObject represents a color" |
281 |
||
395 | 282 |
^ false |
546 | 283 |
|
284 |
"Modified: 19.4.1997 / 12:52:36 / cg" |
|
395 | 285 |
! |
286 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
287 |
isFileInArchive |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
288 |
^ false |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
289 |
! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
290 |
|
395 | 291 |
isFileObject |
546 | 292 |
"return true, if the dropObject represents some file or directory" |
293 |
||
395 | 294 |
^ false |
546 | 295 |
|
296 |
"Modified: 19.4.1997 / 12:52:29 / cg" |
|
395 | 297 |
! |
298 |
||
299 |
isImageObject |
|
546 | 300 |
"return true, if the dropObject represents some image" |
301 |
||
395 | 302 |
^ false |
546 | 303 |
|
304 |
"Modified: 19.4.1997 / 12:52:22 / cg" |
|
395 | 305 |
! |
306 |
||
1482 | 307 |
isMethodObject |
308 |
"return true, if the dropObject represents some method" |
|
309 |
||
310 |
^ false |
|
311 |
! |
|
312 |
||
395 | 313 |
isTextObject |
546 | 314 |
"return true, if the dropObject represents some text" |
315 |
||
395 | 316 |
^ false |
546 | 317 |
|
318 |
"Modified: 19.4.1997 / 12:52:17 / cg" |
|
319 |
! ! |
|
320 |
||
2749 | 321 |
!DropObject::Class class methodsFor:'documentation'! |
322 |
||
323 |
documentation |
|
324 |
" |
|
325 |
I represent a class being dragged (from a browser's classList) |
|
326 |
" |
|
327 |
! ! |
|
328 |
||
1482 | 329 |
!DropObject::Class methodsFor:'testing'! |
330 |
||
331 |
isClassObject |
|
332 |
"return true, if the dropObject represents a class" |
|
333 |
||
334 |
^ true |
|
335 |
! ! |
|
336 |
||
337 |
!DropObject::Color class methodsFor:'defaults'! |
|
338 |
||
339 |
displayObjectName |
|
340 |
"return the name of a bitmap image file, which is used |
|
341 |
during a drag." |
|
342 |
||
343 |
^ 'bitmaps/xpmBitmaps/misc_tools/color_wheel.xpm' |
|
344 |
||
345 |
"Modified: 19.4.1997 / 15:38:12 / cg" |
|
346 |
! ! |
|
347 |
||
2749 | 348 |
!DropObject::Color class methodsFor:'documentation'! |
349 |
||
350 |
documentation |
|
351 |
" |
|
352 |
I represent a color being dragged (from an image editor) |
|
353 |
" |
|
354 |
! ! |
|
355 |
||
1482 | 356 |
!DropObject::Color methodsFor:'testing'! |
357 |
||
358 |
isColorObject |
|
359 |
"return true, if the dropObject represents a color" |
|
360 |
||
361 |
^ true |
|
362 |
||
363 |
"Modified: 19.4.1997 / 12:51:57 / cg" |
|
364 |
! ! |
|
365 |
||
403 | 366 |
!DropObject::File class methodsFor:'defaults'! |
367 |
||
368 |
displayObjectName |
|
546 | 369 |
"return the name of a bitmap image file, which is used |
370 |
during a drag." |
|
403 | 371 |
|
546 | 372 |
^ 'bitmaps/xpmBitmaps/document_images/xfm_file.xpm' |
403 | 373 |
|
546 | 374 |
"Modified: 19.4.1997 / 15:38:07 / cg" |
403 | 375 |
! ! |
376 |
||
2749 | 377 |
!DropObject::File class methodsFor:'documentation'! |
378 |
||
379 |
documentation |
|
380 |
" |
|
381 |
I represent a file being dragged (from a file browser) |
|
382 |
" |
|
383 |
! ! |
|
384 |
||
403 | 385 |
!DropObject::File methodsFor:'accessing'! |
386 |
||
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
387 |
fetchFileInfo |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
388 |
info isNil ifTrue:[ |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
389 |
info := theObject info |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
390 |
]. |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
391 |
^ info |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
392 |
! |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
393 |
|
403 | 394 |
theObject:aPathname |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
395 |
|f| |
403 | 396 |
|
546 | 397 |
f := aPathname asFilename. |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
398 |
"/ info := f info. |
403 | 399 |
|
546 | 400 |
super theObject:f |
401 |
||
402 |
"Modified: 19.4.1997 / 12:49:17 / cg" |
|
403 | 403 |
! ! |
404 |
||
405 |
!DropObject::File methodsFor:'queries'! |
|
406 |
||
2253 | 407 |
asFilename |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
408 |
theObject isFilename ifTrue:[^ theObject]. |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
409 |
|
2253 | 410 |
^ theObject asString asFilename |
411 |
||
412 |
"Created: / 13-10-2006 / 17:22:24 / cg" |
|
413 |
! |
|
414 |
||
403 | 415 |
exists |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
416 |
"returns true if the file or directory exists" |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
417 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
418 |
info isNil ifTrue:[ self fetchFileInfo ]. |
403 | 419 |
^ info notNil |
546 | 420 |
|
421 |
"Modified: 19.4.1997 / 12:49:30 / cg" |
|
403 | 422 |
! |
423 |
||
424 |
isDirectory |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
425 |
"checks whether file is a directory" |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
426 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
427 |
^ self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
428 |
and:[ self fetchFileInfo type == #directory ] |
403 | 429 |
! |
430 |
||
431 |
isHtmlFile |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
432 |
"checks whether file is an html file" |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
433 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
434 |
|mimeType| |
403 | 435 |
|
436 |
isHtmlFile isNil ifTrue:[ |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
437 |
isHtmlFile := self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
438 |
and:[ self isDirectory not |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
439 |
and:[ (mimeType := MIMETypes mimeTypeForFilename:(self asFilename)) notNil |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
440 |
and:[ mimeType isHtml ]]]. |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
441 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
442 |
"/ isHtmlFile := self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
443 |
"/ and:[ self isDirectory not |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
444 |
"/ and:[ #( '.html' '.htm' '.HTML' '.HTM' ) includes: theObject suffix ]]. |
403 | 445 |
]. |
446 |
^ isHtmlFile |
|
447 |
! |
|
448 |
||
449 |
isImageFile |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
450 |
"returns true if file is an image file" |
403 | 451 |
|
452 |
isImageFile isNil ifTrue:[ |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
453 |
isImageFile := self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
454 |
and:[self isDirectory not |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
455 |
and:[ Image isImageFileSuffix:(self asFilename suffix) ]]. |
403 | 456 |
]. |
457 |
^ isImageFile |
|
458 |
||
546 | 459 |
"Modified: 19.4.1997 / 12:50:58 / cg" |
403 | 460 |
! |
461 |
||
462 |
isPrintable |
|
2614 | 463 |
"return true if file contains only printable characters (in the first 300 bytes)" |
1952
5009754ae556
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1784
diff
changeset
|
464 |
|
2614 | 465 |
|nChars stream buff size| |
466 |
||
467 |
nChars := 300. |
|
403 | 468 |
|
469 |
isPrintable isNil ifTrue:[ |
|
470 |
isPrintable := false. |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
471 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
472 |
(self exists and:[ self isDirectory not ]) ifTrue:[ |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
473 |
stream := self asFilename readStreamOrNil. |
1709
fc33be8aaa9c
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
1623
diff
changeset
|
474 |
stream notNil ifTrue:[ |
2614 | 475 |
buff := String new:nChars. |
476 |
size := stream nextBytes:nChars into:buff. |
|
403 | 477 |
stream close. |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
478 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
479 |
(buff contains:[:char | char isPrintable not]) ifTrue:[ |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
480 |
^ false |
1952
5009754ae556
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1784
diff
changeset
|
481 |
]. |
403 | 482 |
]. |
483 |
isPrintable := true |
|
484 |
] |
|
485 |
]. |
|
486 |
^ isPrintable |
|
487 |
! ! |
|
488 |
||
489 |
!DropObject::File methodsFor:'testing'! |
|
490 |
||
491 |
isFileObject |
|
546 | 492 |
"return true, if the dropObject represents a file- or directory" |
396 | 493 |
|
494 |
^ true |
|
495 |
||
546 | 496 |
"Modified: 19.4.1997 / 12:51:49 / cg" |
395 | 497 |
! ! |
498 |
||
2749 | 499 |
!DropObject::FileInArchive class methodsFor:'documentation'! |
500 |
||
501 |
documentation |
|
502 |
" |
|
503 |
I represent a file being dragged from inside an archive (tar, zip,...) (from a file browser) |
|
504 |
" |
|
505 |
! ! |
|
506 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
507 |
!DropObject::FileInArchive methodsFor:'testing'! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
508 |
|
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
509 |
isFileInArchive |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
510 |
^ true |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
511 |
! ! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
512 |
|
1292 | 513 |
!DropObject::Image class methodsFor:'defaults'! |
514 |
||
515 |
displayObjectName |
|
516 |
"return the name of a bitmap image file, which is used |
|
517 |
during a drag." |
|
518 |
||
519 |
^ 'bitmaps/xpmBitmaps/misc_tools/picture.xpm' |
|
520 |
||
521 |
"Modified: 19.4.1997 / 15:38:02 / cg" |
|
522 |
! ! |
|
523 |
||
2749 | 524 |
!DropObject::Image class methodsFor:'documentation'! |
525 |
||
526 |
documentation |
|
527 |
" |
|
528 |
I represent a bitmap image being dragged |
|
529 |
" |
|
530 |
! ! |
|
531 |
||
1292 | 532 |
!DropObject::Image methodsFor:'testing'! |
533 |
||
534 |
isImageObject |
|
535 |
"return true, if the dropObject represents an image" |
|
536 |
||
537 |
^ true |
|
538 |
||
539 |
"Modified: 19.4.1997 / 12:51:28 / cg" |
|
540 |
! ! |
|
541 |
||
2749 | 542 |
!DropObject::Method class methodsFor:'documentation'! |
543 |
||
544 |
documentation |
|
545 |
" |
|
546 |
I represent a method image being dragged (from a browser's methodlist) |
|
547 |
" |
|
548 |
! ! |
|
549 |
||
1482 | 550 |
!DropObject::Method methodsFor:'testing'! |
551 |
||
552 |
isMethodObject |
|
553 |
"return true, if the dropObject represents a method" |
|
554 |
||
555 |
^ true |
|
556 |
! ! |
|
557 |
||
558 |
!DropObject::Text class methodsFor:'defaults'! |
|
559 |
||
560 |
displayObjectName |
|
561 |
^ 'bitmaps/xpmBitmaps/document_images/yellow_file_text_grab.xpm' |
|
562 |
||
563 |
"Modified: 19.4.1997 / 15:40:33 / cg" |
|
564 |
! ! |
|
565 |
||
2749 | 566 |
!DropObject::Text class methodsFor:'documentation'! |
567 |
||
568 |
documentation |
|
569 |
" |
|
570 |
I represent text being dragged (via CTRL-drag from a textView) |
|
571 |
" |
|
572 |
! ! |
|
573 |
||
1482 | 574 |
!DropObject::Text methodsFor:'testing'! |
575 |
||
576 |
isTextObject |
|
577 |
"return true, if the dropObject represents some text" |
|
578 |
||
579 |
^ true |
|
580 |
||
581 |
"Modified: 19.4.1997 / 12:52:08 / cg" |
|
582 |
! ! |
|
583 |
||
395 | 584 |
!DropObject class methodsFor:'documentation'! |
585 |
||
586 |
version |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
587 |
^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.21 2010-02-02 14:18:09 cg Exp $' |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
588 |
! |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
589 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
590 |
version_CVS |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
591 |
^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.21 2010-02-02 14:18:09 cg Exp $' |
395 | 592 |
! ! |