1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package NET.worlds.scape;
import NET.worlds.console.PolledDialog;
import NET.worlds.network.URL;
import java.util.Enumeration;
import java.util.Vector;
public class URLPropertyEditor extends PropEditor {
private FileList files;
private Enumeration additions;
private boolean acceptAnyExt = false;
private boolean acceptDrops;
private URLPropertyEditor(Property property, String extList, Enumeration additions, boolean acceptDrops) {
super(property);
this.acceptDrops = acceptDrops;
URL dir = URL.getContainingOrCurDir((SuperRoot)property.getOwner());
if (extList == null) {
this.acceptAnyExt = true;
} else {
if (extList.startsWith("*")) {
extList = extList.substring(1);
this.acceptAnyExt = true;
}
this.files = new FileList(dir.unalias(), extList);
}
this.additions = additions;
}
@Override
public PolledDialog edit(EditTile parent, String title) {
Vector v = this.files == null ? new Vector() : this.files.getList();
if (this.additions != null) {
while (this.additions.hasMoreElements()) {
v.addElement(this.additions.nextElement().toString());
}
}
return new URLEditorDialog(parent, title, this.property, v, this.acceptAnyExt ? null : this.files);
}
public static Property make(Property property, String extList) {
return make(property, extList, null, true);
}
public static Property make(Property property, String extList, boolean acceptDrops) {
return make(property, extList, null, acceptDrops);
}
public static Property make(Property property, String extList, Enumeration additions) {
return make(property, extList, additions, true);
}
public static Property make(Property property, String extList, Enumeration additions, boolean acceptDrops) {
property.setPropertyType(10);
return property.setEditor(new URLPropertyEditor(property, extList, additions, acceptDrops));
}
@Override
public boolean libraryDrop(EditTile target, Object obj, boolean isPaste, boolean doDrop) {
if (!isPaste && this.acceptDrops && obj instanceof URL && (this.acceptAnyExt || this.files.extMatches(((URL)obj).getExt()))) {
if (doDrop) {
target.addUndoableSet(this.property, obj);
}
return true;
} else {
return false;
}
}
}
|