author | HG Automerge |
Thu, 22 Dec 2016 23:11:31 +0000 | |
branch | jv |
changeset 3815 | 021778442c82 |
parent 3443 | d2d6f852797e |
child 4187 | 6e1d90c18dc9 |
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 |
|
2589 | 132 |
someThing isColor ifTrue:[^ DropObject::Color]. |
133 |
someThing isImageOrForm ifTrue:[^ DropObject::Image]. |
|
134 |
someThing isFilename ifTrue:[^ DropObject::File]. |
|
135 |
someThing isString ifTrue:[^ DropObject::Text]. |
|
136 |
someThing isBehavior ifTrue:[^ DropObject::Class]. |
|
137 |
someThing isMethod ifTrue:[^ DropObject::Method]. |
|
1112 | 138 |
^ self |
139 |
! |
|
140 |
||
395 | 141 |
new:someThing |
547 | 142 |
"create an instance on something |
395 | 143 |
" |
144 |
|cls| |
|
145 |
||
1112 | 146 |
cls := self dropObjectClassFor:someThing. |
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
147 |
^ self newInstanceOf:cls for:someThing |
547 | 148 |
|
149 |
"Modified: 19.4.1997 / 17:19:55 / cg" |
|
395 | 150 |
! |
151 |
||
1482 | 152 |
newClass:aClass |
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
153 |
"create an instance for a class (dragging a class from a browser)" |
1482 | 154 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
155 |
^ self newInstanceOf:DropObject::Class for:aClass |
1482 | 156 |
! |
157 |
||
395 | 158 |
newColor:aColor |
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
159 |
"create an instance for a color (dragging a color from a bitmap editor)" |
547 | 160 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
161 |
^ self newInstanceOf:DropObject::Color for:aColor |
547 | 162 |
|
163 |
"Modified: 19.4.1997 / 17:20:17 / cg" |
|
395 | 164 |
! |
165 |
||
166 |
newFile:aFilename |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
167 |
"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
|
168 |
|
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
169 |
^ self newInstanceOf:DropObject::File for:aFilename |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
170 |
! |
547 | 171 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
172 |
newFileInArchive:aFilename |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
173 |
"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
|
174 |
(dragging a file from an archive shown in a fileBrowser)" |
547 | 175 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
176 |
^ self newInstanceOf:DropObject::FileInArchive for:aFilename |
395 | 177 |
! |
178 |
||
179 |
newImage:anImageOrForm |
|
547 | 180 |
"create an instance for an image" |
181 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
182 |
^ self newInstanceOf:DropObject::Image for:anImageOrForm |
547 | 183 |
|
184 |
"Modified: 19.4.1997 / 17:20:37 / cg" |
|
395 | 185 |
! |
186 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
187 |
newInstanceOf:aClass for:someThing |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
188 |
"create an instance on something |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
189 |
" |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
190 |
^ aClass new theObject:someThing |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
191 |
|
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
192 |
"Modified: 19.4.1997 / 17:19:55 / cg" |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
193 |
! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
194 |
|
1482 | 195 |
newMethod:aMethod |
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
196 |
"create an instance for a method (dragging a method in a browser)" |
1482 | 197 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
198 |
^ self newInstanceOf:DropObject::Method for:aMethod |
1482 | 199 |
! |
200 |
||
3443 | 201 |
newProject:aPackageSymbol |
202 |
"create an instance for a package (dragging a package from a browser)" |
|
203 |
||
204 |
^ self newInstanceOf:DropObject::Project for:aPackageSymbol |
|
205 |
! |
|
206 |
||
395 | 207 |
newText:aTextOrString |
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
208 |
"create an instance for some text (dragging some text from an editor)" |
547 | 209 |
|
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
210 |
^ self newInstanceOf:DropObject::Text for:aTextOrString |
547 | 211 |
|
212 |
"Modified: 19.4.1997 / 17:20:46 / cg" |
|
395 | 213 |
! ! |
214 |
||
403 | 215 |
!DropObject class methodsFor:'defaults'! |
216 |
||
217 |
displayObject |
|
546 | 218 |
"return some object which is shown while dragging; |
219 |
here an image based upon my displayObjectName is returned. |
|
220 |
Either this method or #displayObjectName is usually redefined |
|
221 |
in subclasses" |
|
403 | 222 |
|
223 |
DisplayObject notNil ifTrue:[ |
|
224 |
^ DisplayObject |
|
225 |
]. |
|
1292 | 226 |
DisplayObject := Smalltalk imageFromFileNamed:(self displayObjectName) forClass:self. |
403 | 227 |
^ DisplayObject |
546 | 228 |
|
229 |
"Modified: 19.4.1997 / 13:04:05 / cg" |
|
230 |
! |
|
231 |
||
232 |
displayObject:aDisplayObject |
|
233 |
"set the object which is shown while dragging; |
|
234 |
this object must understand #displayOn:x:y: (i.e. the displayObject |
|
235 |
protocol). The object is kept per class for ALL future drag operations. |
|
236 |
Useful to change the default images in subclasses." |
|
237 |
||
238 |
DisplayObject := aDisplayObject |
|
239 |
||
240 |
"Modified: 19.4.1997 / 15:42:10 / cg" |
|
403 | 241 |
! |
242 |
||
243 |
displayObjectName |
|
546 | 244 |
"return the name of a bitmap image file, which is used |
245 |
during a drag. |
|
246 |
Here, a dummy file is returned." |
|
247 |
||
403 | 248 |
^ 'bitmaps/xpmBitmaps/plain_pixmaps/balloon3.xpm' |
249 |
||
546 | 250 |
"Modified: 19.4.1997 / 13:54:13 / cg" |
403 | 251 |
! ! |
252 |
||
395 | 253 |
!DropObject methodsFor:'accessing'! |
254 |
||
860 | 255 |
displayObject |
256 |
"return my graphical representation - here a default is returned" |
|
257 |
||
2928 | 258 |
^ displayObject notNil |
259 |
ifTrue:[ displayObject ] |
|
260 |
ifFalse:[ self class displayObject ] |
|
860 | 261 |
|
2928 | 262 |
"Modified: / 18-07-2011 / 09:39:12 / cg" |
860 | 263 |
! |
264 |
||
265 |
displayObject:anObject |
|
266 |
"set my graphical representation" |
|
267 |
||
268 |
displayObject := anObject |
|
269 |
||
270 |
! |
|
271 |
||
395 | 272 |
theObject |
546 | 273 |
"return the real object represented by the receiver" |
395 | 274 |
|
546 | 275 |
^ theObject |
276 |
||
277 |
"Modified: 19.4.1997 / 12:53:01 / cg" |
|
278 |
! |
|
395 | 279 |
|
280 |
theObject:something |
|
546 | 281 |
"set the real object represented by the receiver" |
395 | 282 |
|
546 | 283 |
theObject := something. |
284 |
||
285 |
"Modified: 19.4.1997 / 12:53:10 / cg" |
|
286 |
! ! |
|
395 | 287 |
|
288 |
!DropObject methodsFor:'testing'! |
|
289 |
||
1482 | 290 |
isClassObject |
291 |
"return true, if the dropObject represents some class" |
|
292 |
||
293 |
^ false |
|
294 |
! |
|
295 |
||
395 | 296 |
isColorObject |
546 | 297 |
"return true, if the dropObject represents a color" |
298 |
||
395 | 299 |
^ false |
546 | 300 |
|
301 |
"Modified: 19.4.1997 / 12:52:36 / cg" |
|
395 | 302 |
! |
303 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
304 |
isFileInArchive |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
305 |
^ false |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
306 |
! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
307 |
|
395 | 308 |
isFileObject |
546 | 309 |
"return true, if the dropObject represents some file or directory" |
310 |
||
395 | 311 |
^ false |
546 | 312 |
|
313 |
"Modified: 19.4.1997 / 12:52:29 / cg" |
|
395 | 314 |
! |
315 |
||
316 |
isImageObject |
|
546 | 317 |
"return true, if the dropObject represents some image" |
318 |
||
395 | 319 |
^ false |
546 | 320 |
|
321 |
"Modified: 19.4.1997 / 12:52:22 / cg" |
|
395 | 322 |
! |
323 |
||
1482 | 324 |
isMethodObject |
325 |
"return true, if the dropObject represents some method" |
|
326 |
||
327 |
^ false |
|
328 |
! |
|
329 |
||
3443 | 330 |
isProjectObject |
331 |
"return true, if the dropObject represents some project" |
|
332 |
||
333 |
^ false |
|
334 |
! |
|
335 |
||
395 | 336 |
isTextObject |
546 | 337 |
"return true, if the dropObject represents some text" |
338 |
||
395 | 339 |
^ false |
546 | 340 |
|
341 |
"Modified: 19.4.1997 / 12:52:17 / cg" |
|
342 |
! ! |
|
343 |
||
2749 | 344 |
!DropObject::Class class methodsFor:'documentation'! |
345 |
||
346 |
documentation |
|
347 |
" |
|
348 |
I represent a class being dragged (from a browser's classList) |
|
349 |
" |
|
350 |
! ! |
|
351 |
||
1482 | 352 |
!DropObject::Class methodsFor:'testing'! |
353 |
||
354 |
isClassObject |
|
355 |
"return true, if the dropObject represents a class" |
|
356 |
||
357 |
^ true |
|
358 |
! ! |
|
359 |
||
360 |
!DropObject::Color class methodsFor:'defaults'! |
|
361 |
||
362 |
displayObjectName |
|
363 |
"return the name of a bitmap image file, which is used |
|
364 |
during a drag." |
|
365 |
||
366 |
^ 'bitmaps/xpmBitmaps/misc_tools/color_wheel.xpm' |
|
367 |
||
368 |
"Modified: 19.4.1997 / 15:38:12 / cg" |
|
369 |
! ! |
|
370 |
||
2749 | 371 |
!DropObject::Color class methodsFor:'documentation'! |
372 |
||
373 |
documentation |
|
374 |
" |
|
375 |
I represent a color being dragged (from an image editor) |
|
376 |
" |
|
377 |
! ! |
|
378 |
||
1482 | 379 |
!DropObject::Color methodsFor:'testing'! |
380 |
||
381 |
isColorObject |
|
382 |
"return true, if the dropObject represents a color" |
|
383 |
||
384 |
^ true |
|
385 |
||
386 |
"Modified: 19.4.1997 / 12:51:57 / cg" |
|
387 |
! ! |
|
388 |
||
403 | 389 |
!DropObject::File class methodsFor:'defaults'! |
390 |
||
391 |
displayObjectName |
|
546 | 392 |
"return the name of a bitmap image file, which is used |
393 |
during a drag." |
|
403 | 394 |
|
546 | 395 |
^ 'bitmaps/xpmBitmaps/document_images/xfm_file.xpm' |
403 | 396 |
|
546 | 397 |
"Modified: 19.4.1997 / 15:38:07 / cg" |
403 | 398 |
! ! |
399 |
||
2749 | 400 |
!DropObject::File class methodsFor:'documentation'! |
401 |
||
402 |
documentation |
|
403 |
" |
|
404 |
I represent a file being dragged (from a file browser) |
|
405 |
" |
|
406 |
! ! |
|
407 |
||
403 | 408 |
!DropObject::File methodsFor:'accessing'! |
409 |
||
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
410 |
fetchFileInfo |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
411 |
info isNil ifTrue:[ |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
412 |
info := theObject info |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
413 |
]. |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
414 |
^ info |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
415 |
! |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
416 |
|
403 | 417 |
theObject:aPathname |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
418 |
|f| |
403 | 419 |
|
546 | 420 |
f := aPathname asFilename. |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
421 |
"/ info := f info. |
403 | 422 |
|
546 | 423 |
super theObject:f |
424 |
||
425 |
"Modified: 19.4.1997 / 12:49:17 / cg" |
|
403 | 426 |
! ! |
427 |
||
428 |
!DropObject::File methodsFor:'queries'! |
|
429 |
||
2253 | 430 |
asFilename |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
431 |
theObject isFilename ifTrue:[^ theObject]. |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
432 |
|
2253 | 433 |
^ theObject asString asFilename |
434 |
||
435 |
"Created: / 13-10-2006 / 17:22:24 / cg" |
|
436 |
! |
|
437 |
||
403 | 438 |
exists |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
439 |
"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
|
440 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
441 |
info isNil ifTrue:[ self fetchFileInfo ]. |
403 | 442 |
^ info notNil |
546 | 443 |
|
444 |
"Modified: 19.4.1997 / 12:49:30 / cg" |
|
403 | 445 |
! |
446 |
||
447 |
isDirectory |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
448 |
"checks whether file is a directory" |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
449 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
450 |
^ self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
451 |
and:[ self fetchFileInfo type == #directory ] |
403 | 452 |
! |
453 |
||
454 |
isHtmlFile |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
455 |
"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
|
456 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
457 |
|mimeType| |
403 | 458 |
|
459 |
isHtmlFile isNil ifTrue:[ |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
460 |
isHtmlFile := self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
461 |
and:[ self isDirectory not |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
462 |
and:[ (mimeType := MIMETypes mimeTypeForFilename:(self asFilename)) notNil |
3261 | 463 |
and:[ mimeType isHtmlType ]]]. |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
464 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
465 |
"/ isHtmlFile := self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
466 |
"/ and:[ self isDirectory not |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
467 |
"/ and:[ #( '.html' '.htm' '.HTML' '.HTM' ) includes: theObject suffix ]]. |
403 | 468 |
]. |
469 |
^ isHtmlFile |
|
470 |
! |
|
471 |
||
472 |
isImageFile |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
473 |
"returns true if file is an image file" |
403 | 474 |
|
475 |
isImageFile isNil ifTrue:[ |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
476 |
isImageFile := self exists |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
477 |
and:[self isDirectory not |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
478 |
and:[ Image isImageFileSuffix:(self asFilename suffix) ]]. |
403 | 479 |
]. |
480 |
^ isImageFile |
|
481 |
||
546 | 482 |
"Modified: 19.4.1997 / 12:50:58 / cg" |
403 | 483 |
! |
484 |
||
485 |
isPrintable |
|
2614 | 486 |
"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
|
487 |
|
2614 | 488 |
|nChars stream buff size| |
489 |
||
490 |
nChars := 300. |
|
403 | 491 |
|
492 |
isPrintable isNil ifTrue:[ |
|
493 |
isPrintable := false. |
|
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
494 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
495 |
(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
|
496 |
stream := self asFilename readStreamOrNil. |
1709
fc33be8aaa9c
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
1623
diff
changeset
|
497 |
stream notNil ifTrue:[ |
2614 | 498 |
buff := String new:nChars. |
499 |
size := stream nextBytes:nChars into:buff. |
|
403 | 500 |
stream close. |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
501 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
502 |
(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
|
503 |
^ false |
1952
5009754ae556
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1784
diff
changeset
|
504 |
]. |
403 | 505 |
]. |
506 |
isPrintable := true |
|
507 |
] |
|
508 |
]. |
|
509 |
^ isPrintable |
|
510 |
! ! |
|
511 |
||
512 |
!DropObject::File methodsFor:'testing'! |
|
513 |
||
514 |
isFileObject |
|
546 | 515 |
"return true, if the dropObject represents a file- or directory" |
396 | 516 |
|
517 |
^ true |
|
518 |
||
546 | 519 |
"Modified: 19.4.1997 / 12:51:49 / cg" |
395 | 520 |
! ! |
521 |
||
2749 | 522 |
!DropObject::FileInArchive class methodsFor:'documentation'! |
523 |
||
524 |
documentation |
|
525 |
" |
|
526 |
I represent a file being dragged from inside an archive (tar, zip,...) (from a file browser) |
|
527 |
" |
|
528 |
! ! |
|
529 |
||
1784
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
530 |
!DropObject::FileInArchive methodsFor:'testing'! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
531 |
|
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
532 |
isFileInArchive |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
533 |
^ true |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
534 |
! ! |
67f412dd5926
refactored inst-creation code;
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
535 |
|
1292 | 536 |
!DropObject::Image class methodsFor:'defaults'! |
537 |
||
538 |
displayObjectName |
|
539 |
"return the name of a bitmap image file, which is used |
|
540 |
during a drag." |
|
541 |
||
542 |
^ 'bitmaps/xpmBitmaps/misc_tools/picture.xpm' |
|
543 |
||
544 |
"Modified: 19.4.1997 / 15:38:02 / cg" |
|
545 |
! ! |
|
546 |
||
2749 | 547 |
!DropObject::Image class methodsFor:'documentation'! |
548 |
||
549 |
documentation |
|
550 |
" |
|
551 |
I represent a bitmap image being dragged |
|
552 |
" |
|
553 |
! ! |
|
554 |
||
1292 | 555 |
!DropObject::Image methodsFor:'testing'! |
556 |
||
557 |
isImageObject |
|
558 |
"return true, if the dropObject represents an image" |
|
559 |
||
560 |
^ true |
|
561 |
||
562 |
"Modified: 19.4.1997 / 12:51:28 / cg" |
|
563 |
! ! |
|
564 |
||
2749 | 565 |
!DropObject::Method class methodsFor:'documentation'! |
566 |
||
567 |
documentation |
|
568 |
" |
|
569 |
I represent a method image being dragged (from a browser's methodlist) |
|
570 |
" |
|
571 |
! ! |
|
572 |
||
1482 | 573 |
!DropObject::Method methodsFor:'testing'! |
574 |
||
575 |
isMethodObject |
|
576 |
"return true, if the dropObject represents a method" |
|
577 |
||
578 |
^ true |
|
579 |
! ! |
|
580 |
||
3443 | 581 |
!DropObject::Project class methodsFor:'documentation'! |
582 |
||
583 |
documentation |
|
584 |
" |
|
585 |
I represent a project being dragged (from a browser's projectList) |
|
586 |
" |
|
587 |
! ! |
|
588 |
||
589 |
!DropObject::Project methodsFor:'testing'! |
|
590 |
||
591 |
isProjectObject |
|
592 |
"return true, if the dropObject represents a project" |
|
593 |
||
594 |
^ true |
|
595 |
! ! |
|
596 |
||
1482 | 597 |
!DropObject::Text class methodsFor:'defaults'! |
598 |
||
599 |
displayObjectName |
|
600 |
^ 'bitmaps/xpmBitmaps/document_images/yellow_file_text_grab.xpm' |
|
601 |
||
602 |
"Modified: 19.4.1997 / 15:40:33 / cg" |
|
603 |
! ! |
|
604 |
||
2749 | 605 |
!DropObject::Text class methodsFor:'documentation'! |
606 |
||
607 |
documentation |
|
608 |
" |
|
609 |
I represent text being dragged (via CTRL-drag from a textView) |
|
610 |
" |
|
611 |
! ! |
|
612 |
||
1482 | 613 |
!DropObject::Text methodsFor:'testing'! |
614 |
||
615 |
isTextObject |
|
616 |
"return true, if the dropObject represents some text" |
|
617 |
||
618 |
^ true |
|
619 |
||
620 |
"Modified: 19.4.1997 / 12:52:08 / cg" |
|
621 |
! ! |
|
622 |
||
395 | 623 |
!DropObject class methodsFor:'documentation'! |
624 |
||
625 |
version |
|
3443 | 626 |
^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.24 2015-02-04 23:15:25 cg Exp $' |
2819
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
627 |
! |
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
628 |
|
691218db6b3c
code cleanup - DropObject::File was a big mess.
Claus Gittinger <cg@exept.de>
parents:
2749
diff
changeset
|
629 |
version_CVS |
3443 | 630 |
^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.24 2015-02-04 23:15:25 cg Exp $' |
395 | 631 |
! ! |
3261 | 632 |