summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/PropTreeNode.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/PropTreeNode.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/PropTreeNode.java')
-rw-r--r--NET/worlds/scape/PropTreeNode.java142
1 files changed, 142 insertions, 0 deletions
diff --git a/NET/worlds/scape/PropTreeNode.java b/NET/worlds/scape/PropTreeNode.java
new file mode 100644
index 0000000..a064dec
--- /dev/null
+++ b/NET/worlds/scape/PropTreeNode.java
@@ -0,0 +1,142 @@
+package NET.worlds.scape;
+
+import NET.worlds.console.TreeNode;
+import java.util.Enumeration;
+import java.util.Vector;
+
+class PropTreeNode extends TreeNode {
+ private Object obj;
+ private boolean allowSorting = true;
+
+ public PropTreeNode(Object obj) {
+ super(null);
+ this.obj = obj;
+
+ assert obj != null;
+ }
+
+ public PropTreeNode(Object obj, TreeNode parent) {
+ super(parent);
+ this.obj = obj;
+
+ assert obj != null;
+ }
+
+ @Override
+ public boolean shouldSort() {
+ return this.allowSorting;
+ }
+
+ @Override
+ public Vector getChildren() {
+ Vector ret = null;
+ Object obj = this.obj;
+ if (obj instanceof VectorProperty) {
+ VectorProperty vp = (VectorProperty)obj;
+ this.allowSorting = vp.shouldSort();
+ ret = new Vector();
+ Vector v = (Vector)vp.get();
+ if (v != null) {
+ int count = v.size();
+
+ for (int i = 0; i < count; i++) {
+ Object child = v.elementAt(i);
+ if (child == null) {
+ System.out.println("Error: VectorProperty " + vp.getName() + " of " + vp.getOwner() + " was null.");
+ } else {
+ ret.addElement(new PropTreeNode(child, this));
+ }
+ }
+ }
+ } else {
+ if (obj instanceof Property) {
+ obj = ((Property)obj).get();
+ }
+
+ if (obj instanceof Properties) {
+ ret = new Vector();
+ Enumeration e = new EnumProperties(obj);
+
+ while (e.hasMoreElements()) {
+ Property p = (Property)e.nextElement();
+ if (p instanceof VectorProperty || p.getEditor() == null && p.get() instanceof Properties) {
+ ret.addElement(new PropTreeNode(p, this));
+ }
+ }
+ }
+ }
+
+ return ret;
+ }
+
+ @Override
+ public Object getObject() {
+ return this.obj;
+ }
+
+ @Override
+ public boolean displayAsTitle() {
+ return this.obj instanceof VectorProperty || this.obj instanceof Property;
+ }
+
+ public boolean canEdit() {
+ return false;
+ }
+
+ public VectorProperty getContainingVectorProperty() {
+ Object obj = this.obj;
+ TreeNode e = this.getParent();
+ return !(obj instanceof VectorProperty) && (e == null || !((obj = e.getObject()) instanceof VectorProperty)) ? null : (VectorProperty)obj;
+ }
+
+ public PropAdder getAdder() {
+ VectorProperty vec = this.getContainingVectorProperty();
+ return vec != null ? vec.getAdder() : null;
+ }
+
+ public String getContainerName() {
+ return this.getContainingVectorProperty().getName();
+ }
+
+ public boolean canAdd() {
+ PropAdder adder = this.getAdder();
+ return adder != null && adder.hasAddDialog();
+ }
+
+ public boolean canDelete() {
+ TreeNode e = this.getParent();
+ Object obj;
+ Object var3;
+ return e != null
+ && (
+ (obj = e.getObject()) instanceof VectorProperty && ((VectorProperty)obj).getAdder() != null
+ || (var3 = this.getObject()) instanceof Property && ((Property)var3).canSetNull() && ((Property)var3).get() != null
+ );
+ }
+
+ public Undoable delete(boolean isCut) {
+ assert this.canDelete();
+
+ Object o = this.getParent().getObject();
+ if (o instanceof VectorProperty) {
+ VectorProperty owner = (VectorProperty)o;
+ Vector v = (Vector)owner.get();
+ int i = v.indexOf(this.obj);
+
+ assert i != -1;
+
+ return (Undoable)(isCut ? new UndoablCut(owner, i) : new UndoablDelete(owner, i));
+ } else {
+ return new UndoablSet((Property)this.getObject(), null);
+ }
+ }
+
+ @Override
+ public String toString() {
+ if (this.obj instanceof SuperRoot) {
+ return ((SuperRoot)this.obj).getName();
+ } else {
+ return this.obj instanceof Property ? ((Property)this.obj).getName() : this.obj.toString();
+ }
+ }
+}