summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/Library.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/Library.java
downloadworlds.jar-main.tar.xz
worlds.jar-main.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/scape/Library.java')
-rw-r--r--NET/worlds/scape/Library.java216
1 files changed, 216 insertions, 0 deletions
diff --git a/NET/worlds/scape/Library.java b/NET/worlds/scape/Library.java
new file mode 100644
index 0000000..4d35537
--- /dev/null
+++ b/NET/worlds/scape/Library.java
@@ -0,0 +1,216 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import NET.worlds.network.URL;
+/* */ import java.io.File;
+/* */ import java.io.IOException;
+/* */ import java.util.Vector;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class Library
+/* */ extends SuperRoot
+/* */ {
+/* */ private Object owningDialog;
+/* 39 */ private Vector<LibraryEntry> contents = new Vector();
+/* */ private LibEventHandler handler;
+/* */ protected String propertyName;
+/* */
+/* */ public static Library load(URL url)
+/* */ {
+/* 45 */ return (Library)SuperRoot.readFile(url);
+/* */ }
+/* */
+/* */ public Library(URL url, String name)
+/* */ {
+/* 50 */ setSourceURL(url);
+/* 51 */ setName(name);
+/* */ }
+/* */
+/* */
+/* */ public Library() {}
+/* */
+/* */ public void save()
+/* */ {
+/* */ try
+/* */ {
+/* 61 */ saveFile(getSourceURL());
+/* */ }
+/* */ catch (IOException localIOException) {}
+/* */ }
+/* */
+/* */ public void delete() {
+/* 67 */ new File(getSourceURL().unalias()).delete();
+/* */ }
+/* */
+/* */ public void add(LibraryEntry ent)
+/* */ {
+/* 72 */ assert (ent.getOwner() == null);
+/* 73 */ this.contents.addElement(ent);
+/* 74 */ super.add(ent);
+/* 75 */ changed();
+/* */ }
+/* */
+/* */ public void delete(LibraryEntry ent)
+/* */ {
+/* 80 */ boolean found = this.contents.removeElement(ent);
+/* 81 */ assert (found);
+/* 82 */ assert (ent.getOwner() == this);
+/* 83 */ ent.detach();
+/* 84 */ changed();
+/* */ }
+/* */
+/* */ public void move(LibraryEntry src, LibraryEntry dst)
+/* */ {
+/* 89 */ int oldPos = this.contents.indexOf(src);
+/* 90 */ assert (oldPos != -1);
+/* 91 */ int newPos = this.contents.indexOf(dst);
+/* 92 */ assert (newPos != -1);
+/* 93 */ this.contents.removeElement(src);
+/* 94 */ this.contents.insertElementAt(src, newPos);
+/* 95 */ changed();
+/* */ }
+/* */
+/* */ void entryChanged(LibraryEntry which)
+/* */ {
+/* 100 */ changed();
+/* */ }
+/* */
+/* */ private void changed()
+/* */ {
+/* 105 */ if (this.handler != null)
+/* 106 */ this.handler.libraryChanged(this);
+/* */ }
+/* */
+/* 109 */ public Object getOwningDialog() { return this.owningDialog; }
+/* */
+/* 111 */ public Vector<LibraryEntry> getContents() { return (Vector)this.contents.clone(); }
+/* 112 */ public String getPropertyName() { return this.propertyName; }
+/* */
+/* */ public LibraryEntry getEntry(int index)
+/* */ {
+/* 116 */ return (LibraryEntry)this.contents.elementAt(index);
+/* */ }
+/* */
+/* 119 */ public void setOwningDialog(Object o) { this.owningDialog = o; }
+/* 120 */ public void setName(String s) { super.setName(s);changed(); }
+/* 121 */ public void setPropertyName(String s) { this.propertyName = s;changed();
+/* */ }
+/* */
+/* */ public void setEventHandler(LibEventHandler handler) {
+/* 125 */ this.handler = handler;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public Object properties(int index, int offset, int mode, Object value)
+/* */ throws NoSuchPropertyException
+/* */ {
+/* 134 */ Object ret = null;
+/* 135 */ switch (index - offset) {
+/* */ case 0:
+/* 137 */ if (mode == 0) {
+/* 138 */ ret = PropAdder.make(
+/* 139 */ new VectorProperty(this, index, "Contents"));
+/* 140 */ } else if (mode == 1) {
+/* 141 */ ret = getContents();
+/* 142 */ } else if (mode == 4) {
+/* 143 */ delete((LibraryEntry)value);
+/* 144 */ } else if (mode == 3) {
+/* 145 */ add((LibraryEntry)value);
+/* 146 */ } else if ((mode == 5) && ((value instanceof LibraryEntry)))
+/* 147 */ ret = value;
+/* 148 */ break;
+/* */ case 1:
+/* 150 */ if (mode == 0) {
+/* 151 */ ret = StringPropertyEditor.make(
+/* 152 */ new Property(this, index, "Property Name")
+/* 153 */ .allowSetNull());
+/* 154 */ } else if (mode == 1) {
+/* 155 */ ret = getPropertyName();
+/* 156 */ } else if (mode == 2)
+/* 157 */ setPropertyName((String)value);
+/* 158 */ break;
+/* */ default:
+/* 160 */ ret = super.properties(index, offset + 2, mode, value);
+/* */ }
+/* 162 */ return ret;
+/* */ }
+/* */
+/* */ public Object propertyParent()
+/* */ {
+/* 167 */ return getOwningDialog();
+/* */ }
+/* */
+/* 170 */ private static Object classCookie = new Object();
+/* */
+/* */ public void saveState(Saver s) throws IOException
+/* */ {
+/* 174 */ s.saveVersion(2, classCookie);
+/* 175 */ super.saveState(s);
+/* 176 */ s.saveVector(this.contents);
+/* 177 */ s.saveString(this.propertyName);
+/* */ }
+/* */
+/* */ public void restoreState(Restorer r) throws IOException, TooNewException
+/* */ {
+/* 182 */ Vector<?> newContents = null;
+/* */
+/* 184 */ switch (r.restoreVersion(classCookie)) {
+/* */ case 0:
+/* 186 */ setName(r.restoreString());
+/* 187 */ r.restoreString();
+/* 188 */ r.restoreString();
+/* 189 */ newContents = r.restoreVector();
+/* 190 */ break;
+/* */ case 1:
+/* 192 */ super.restoreState(r);
+/* 193 */ r.restoreString();
+/* 194 */ r.restoreString();
+/* 195 */ newContents = r.restoreVector();
+/* 196 */ break;
+/* */ case 2:
+/* 198 */ super.restoreState(r);
+/* 199 */ newContents = r.restoreVector();
+/* 200 */ this.propertyName = r.restoreString();
+/* 201 */ break;
+/* */ default:
+/* 203 */ throw new TooNewException();
+/* */ }
+/* */
+/* 206 */ for (int i = 0; i < newContents.size(); i++) {
+/* 207 */ add((LibraryEntry)newContents.elementAt(i));
+/* */ }
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Library.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file