summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/URLPropertyEditor.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/URLPropertyEditor.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/URLPropertyEditor.java')
-rw-r--r--NET/worlds/scape/URLPropertyEditor.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/NET/worlds/scape/URLPropertyEditor.java b/NET/worlds/scape/URLPropertyEditor.java
new file mode 100644
index 0000000..2a346c1
--- /dev/null
+++ b/NET/worlds/scape/URLPropertyEditor.java
@@ -0,0 +1,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;
+ }
+ }
+}