diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/URLEditorDialog.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/URLEditorDialog.java')
| -rw-r--r-- | NET/worlds/scape/URLEditorDialog.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/NET/worlds/scape/URLEditorDialog.java b/NET/worlds/scape/URLEditorDialog.java new file mode 100644 index 0000000..034ccdd --- /dev/null +++ b/NET/worlds/scape/URLEditorDialog.java @@ -0,0 +1,54 @@ +package NET.worlds.scape; + +import NET.worlds.console.Console; +import NET.worlds.network.URL; +import java.net.MalformedURLException; +import java.util.Vector; + +class URLEditorDialog extends FieldWithListEditorDialog { + Property property; + FileList extChecker; + + URLEditorDialog(EditTile parent, String title, Property property, Vector files, FileList extChecker) { + super(parent, title + " dir: " + URL.getBestContainer((SuperRoot)property.getOwner()), files); + this.property = property; + this.extChecker = extChecker; + this.ready(); + } + + @Override + protected String getValue() { + SuperRoot context = (SuperRoot)this.property.getOwner(); + if (context != null && this.property.getName().equals("Source URL")) { + context = context.getOwner(); + } + + String s = URL.getRelativeTo((URL)this.property.get(), context); + return s == null ? "" : s; + } + + @Override + protected boolean setValue(String text) { + URL url = null; + if (text.length() == 0) { + if (!this.property.canSetNull()) { + return false; + } + } else { + if (this.extChecker != null && !this.extChecker.extMatches(text)) { + Console.println(Console.message("extension-match") + this.extChecker.getExtList()); + return false; + } + + try { + url = new URL((SuperRoot)this.property.getOwner(), text); + } catch (MalformedURLException var4) { + Console.println(Console.message("Illegal-URL") + var4); + return false; + } + } + + this.parent.addUndoableSet(this.property, url); + return true; + } +} |