author | Claus Gittinger <cg@exept.de> |
Sat, 07 Dec 2013 11:44:47 +0100 | |
changeset 3261 | 6edd75bca965 |
parent 2928 | 37224b335551 |
child 3443 | d2d6f852797e |
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 |
||
2928 | 243 |
^ displayObject notNil |
244 |
ifTrue:[ displayObject ] |
|
245 |
ifFalse:[ self class displayObject ] |
|
860 | 246 |
|
2928 | 247 |
"Modified: / 18-07-2011 / 09:39:12 / cg" |
860 | 248 |
! |
249 |
||
250 |
displayObject:anObject |
|
251 |
"set my graphical representation" |
|
252 |
||
253 |
displayObject := anObject |
|
254 |
||
255 |
! |
|
256 |
||
395 | 257 |
theObject |
546 | 258 |
"return the real object represented by the receiver" |
395 | 259 |
|
546 | 260 |
^ theObject |
261 |
||
262 |
"Modified: 19.4.1997 / 12:53:01 / cg" |
|
263 |
! |
|
395 | 264 |
|
265 |
theObject:something |
|
546 | 266 |
"set the real object represented by the receiver" |
395 | 267 |
|
546 | 268 |
theObject := something. |
269 |
||
270 |
"Modified: 19.4.1997 / 12:53:10 / cg" |
|
271 |
! ! |
|
395 | 272 |
|
273 |
!DropObject methodsFor:'testing'! |
|
274 |
||
1482 | 275 |
isClassObject |
276 |
"return true, if the dropObject represents some class" |
|
277 |
||
278 |
^ false |
|
279 |
! |
|
280 |
||
395 | 281 |
isColorObject |
546 | 282 |
"return true, if the dropObject represents a color" |
283 |
||
395 | 284 |
^ false |
546 | 285 |
|
286 |
"Modified: 19.4.1997 / 12:52:36 / cg" |
|
395 | 287 |
! |
288 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
289 |
isFileInArchive |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
290 |
^ false |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
291 |
! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
292 |
|
395 | 293 |
isFileObject |
546 | 294 |
"return true, if the dropObject represents some file or directory" |
295 |
||
395 | 296 |
^ false |
546 | 297 |
|
298 |
"Modified: 19.4.1997 / 12:52:29 / cg" |
|
395 | 299 |
! |
300 |
||
301 |
isImageObject |
|
546 | 302 |
"return true, if the dropObject represents some image" |
303 |
||
395 | 304 |
^ false |
546 | 305 |
|
306 |
"Modified: 19.4.1997 / 12:52:22 / cg" |
|
395 | 307 |
! |
308 |
||
1482 | 309 |
isMethodObject |
310 |
"return true, if the dropObject represents some method" |
|
311 |
||
312 |
^ false |
|
313 |
! |
|
314 |
||
395 | 315 |
isTextObject |
546 | 316 |
"return true, if the dropObject represents some text" |
317 |
||
395 | 318 |
^ false |
546 | 319 |
|
320 |
"Modified: 19.4.1997 / 12:52:17 / cg" |
|
321 |
! ! |
|
322 |
||
2749 | 323 |
!DropObject::Class class methodsFor:'documentation'! |
324 |
||
325 |
documentation |
|
326 |
" |
|
327 |
I represent a class being dragged (from a browser's classList) |
|
328 |
" |
|
329 |
! ! |
|
330 |
||
1482 | 331 |
!DropObject::Class methodsFor:'testing'! |
332 |
||
333 |
isClassObject |
|
334 |
"return true, if the dropObject represents a class" |
|
335 |
||
336 |
^ true |
|
337 |
! ! |
|
338 |
||
339 |
!DropObject::Color class methodsFor:'defaults'! |
|
340 |
||
341 |
displayObjectName |
|
342 |
"return the name of a bitmap image file, which is used |
|
343 |
during a drag." |
|
344 |
||
345 |
^ 'bitmaps/xpmBitmaps/misc_tools/color_wheel.xpm' |
|
346 |
||
347 |
"Modified: 19.4.1997 / 15:38:12 / cg" |
|
348 |
! ! |
|
349 |
||
2749 | 350 |
!DropObject::Color class methodsFor:'documentation'! |
351 |
||
352 |
documentation |
|
353 |
" |
|
354 |
I represent a color being dragged (from an image editor) |
|
355 |
" |
|
356 |
! ! |
|
357 |
||
1482 | 358 |
!DropObject::Color methodsFor:'testing'! |
359 |
||
360 |
isColorObject |
|
361 |
"return true, if the dropObject represents a color" |
|
362 |
||
363 |
^ true |
|
364 |
||
365 |
"Modified: 19.4.1997 / 12:51:57 / cg" |
|
366 |
! ! |
|
367 |
||
403 | 368 |
!DropObject::File class methodsFor:'defaults'! |
369 |
||
370 |
displayObjectName |
|
546 | 371 |
"return the name of a bitmap image file, which is used |
372 |
during a drag." |
|
403 | 373 |
|
546 | 374 |
^ 'bitmaps/xpmBitmaps/document_images/xfm_file.xpm' |
403 | 375 |
|
546 | 376 |
"Modified: 19.4.1997 / 15:38:07 / cg" |
403 | 377 |
! ! |
378 |
||
2749 | 379 |
!DropObject::File class methodsFor:'documentation'! |
380 |
||
381 |
documentation |
|
382 |
" |
|
383 |
I represent a file being dragged (from a file browser) |
|
384 |
" |
|
385 |
! ! |
|
386 |
||
403 | 387 |
!DropObject::File methodsFor:'accessing'! |
388 |
||
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
389 |
fetchFileInfo |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
390 |
info isNil ifTrue:[ |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
391 |
info := theObject 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 |
^ info |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
394 |
! |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
395 |
|
403 | 396 |
theObject:aPathname |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
397 |
|f| |
403 | 398 |
|
546 | 399 |
f := aPathname asFilename. |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
400 |
"/ info := f info. |
403 | 401 |
|
546 | 402 |
super theObject:f |
403 |
||
404 |
"Modified: 19.4.1997 / 12:49:17 / cg" |
|
403 | 405 |
! ! |
406 |
||
407 |
!DropObject::File methodsFor:'queries'! |
|
408 |
||
2253 | 409 |
asFilename |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
410 |
theObject isFilename ifTrue:[^ theObject]. |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
411 |
|
2253 | 412 |
^ theObject asString asFilename |
413 |
||
414 |
"Created: / 13-10-2006 / 17:22:24 / cg" |
|
415 |
! |
|
416 |
||
403 | 417 |
exists |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
418 |
"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
|
419 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
420 |
info isNil ifTrue:[ self fetchFileInfo ]. |
403 | 421 |
^ info notNil |
546 | 422 |
|
423 |
"Modified: 19.4.1997 / 12:49:30 / cg" |
|
403 | 424 |
! |
425 |
||
426 |
isDirectory |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
427 |
"checks whether file is a directory" |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
428 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
429 |
^ self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
430 |
and:[ self fetchFileInfo type == #directory ] |
403 | 431 |
! |
432 |
||
433 |
isHtmlFile |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
434 |
"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
|
435 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
436 |
|mimeType| |
403 | 437 |
|
438 |
isHtmlFile isNil ifTrue:[ |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
439 |
isHtmlFile := self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
440 |
and:[ self isDirectory not |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
441 |
and:[ (mimeType := MIMETypes mimeTypeForFilename:(self asFilename)) notNil |
3261 | 442 |
and:[ mimeType isHtmlType ]]]. |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
443 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
444 |
"/ isHtmlFile := self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
445 |
"/ and:[ self isDirectory not |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
446 |
"/ and:[ #( '.html' '.htm' '.HTML' '.HTM' ) includes: theObject suffix ]]. |
403 | 447 |
]. |
448 |
^ isHtmlFile |
|
449 |
! |
|
450 |
||
451 |
isImageFile |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
452 |
"returns true if file is an image file" |
403 | 453 |
|
454 |
isImageFile isNil ifTrue:[ |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
455 |
isImageFile := self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
456 |
and:[self isDirectory not |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
457 |
and:[ Image isImageFileSuffix:(self asFilename suffix) ]]. |
403 | 458 |
]. |
459 |
^ isImageFile |
|
460 |
||
546 | 461 |
"Modified: 19.4.1997 / 12:50:58 / cg" |
403 | 462 |
! |
463 |
||
464 |
isPrintable |
|
2614 | 465 |
"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
|
466 |
|
2614 | 467 |
|nChars stream buff size| |
468 |
||
469 |
nChars := 300. |
|
403 | 470 |
|
471 |
isPrintable isNil ifTrue:[ |
|
472 |
isPrintable := false. |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
473 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
474 |
(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
|
475 |
stream := self asFilename readStreamOrNil. |
1709
fc33be8aaa9c
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
1623
diff
changeset
|
476 |
stream notNil ifTrue:[ |
2614 | 477 |
buff := String new:nChars. |
478 |
size := stream nextBytes:nChars into:buff. |
|
403 | 479 |
stream close. |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
480 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
481 |
(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
|
482 |
^ false |
1952
5009754ae556
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1784
diff
changeset
|
483 |
]. |
403 | 484 |
]. |
485 |
isPrintable := true |
|
486 |
] |
|
487 |
]. |
|
488 |
^ isPrintable |
|
489 |
! ! |
|
490 |
||
491 |
!DropObject::File methodsFor:'testing'! |
|
492 |
||
493 |
isFileObject |
|
546 | 494 |
"return true, if the dropObject represents a file- or directory" |
396 | 495 |
|
496 |
^ true |
|
497 |
||
546 | 498 |
"Modified: 19.4.1997 / 12:51:49 / cg" |
395 | 499 |
! ! |
500 |
||
2749 | 501 |
!DropObject::FileInArchive class methodsFor:'documentation'! |
502 |
||
503 |
documentation |
|
504 |
" |
|
505 |
I represent a file being dragged from inside an archive (tar, zip,...) (from a file browser) |
|
506 |
" |
|
507 |
! ! |
|
508 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
509 |
!DropObject::FileInArchive methodsFor:'testing'! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
510 |
|
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
511 |
isFileInArchive |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
512 |
^ true |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
513 |
! ! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
514 |
|
1292 | 515 |
!DropObject::Image class methodsFor:'defaults'! |
516 |
||
517 |
displayObjectName |
|
518 |
"return the name of a bitmap image file, which is used |
|
519 |
during a drag." |
|
520 |
||
521 |
^ 'bitmaps/xpmBitmaps/misc_tools/picture.xpm' |
|
522 |
||
523 |
"Modified: 19.4.1997 / 15:38:02 / cg" |
|
524 |
! ! |
|
525 |
||
2749 | 526 |
!DropObject::Image class methodsFor:'documentation'! |
527 |
||
528 |
documentation |
|
529 |
" |
|
530 |
I represent a bitmap image being dragged |
|
531 |
" |
|
532 |
! ! |
|
533 |
||
1292 | 534 |
!DropObject::Image methodsFor:'testing'! |
535 |
||
536 |
isImageObject |
|
537 |
"return true, if the dropObject represents an image" |
|
538 |
||
539 |
^ true |
|
540 |
||
541 |
"Modified: 19.4.1997 / 12:51:28 / cg" |
|
542 |
! ! |
|
543 |
||
2749 | 544 |
!DropObject::Method class methodsFor:'documentation'! |
545 |
||
546 |
documentation |
|
547 |
" |
|
548 |
I represent a method image being dragged (from a browser's methodlist) |
|
549 |
" |
|
550 |
! ! |
|
551 |
||
1482 | 552 |
!DropObject::Method methodsFor:'testing'! |
553 |
||
554 |
isMethodObject |
|
555 |
"return true, if the dropObject represents a method" |
|
556 |
||
557 |
^ true |
|
558 |
! ! |
|
559 |
||
560 |
!DropObject::Text class methodsFor:'defaults'! |
|
561 |
||
562 |
displayObjectName |
|
563 |
^ 'bitmaps/xpmBitmaps/document_images/yellow_file_text_grab.xpm' |
|
564 |
||
565 |
"Modified: 19.4.1997 / 15:40:33 / cg" |
|
566 |
! ! |
|
567 |
||
2749 | 568 |
!DropObject::Text class methodsFor:'documentation'! |
569 |
||
570 |
documentation |
|
571 |
" |
|
572 |
I represent text being dragged (via CTRL-drag from a textView) |
|
573 |
" |
|
574 |
! ! |
|
575 |
||
1482 | 576 |
!DropObject::Text methodsFor:'testing'! |
577 |
||
578 |
isTextObject |
|
579 |
"return true, if the dropObject represents some text" |
|
580 |
||
581 |
^ true |
|
582 |
||
583 |
"Modified: 19.4.1997 / 12:52:08 / cg" |
|
584 |
! ! |
|
585 |
||
395 | 586 |
!DropObject class methodsFor:'documentation'! |
587 |
||
588 |
version |
|
3261 | 589 |
^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.23 2013-12-07 10:44:47 cg Exp $' |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
590 |
! |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
591 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
592 |
version_CVS |
3261 | 593 |
^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.23 2013-12-07 10:44:47 cg Exp $' |
395 | 594 |
! ! |
3261 | 595 |