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