package NET.worlds.scape; import NET.worlds.core.Std; import java.util.Enumeration; import java.util.Vector; abstract class ObjectSelectorDialog extends ListAdderDialog { private Property property; private Vector objectVector = null; SuperRoot root = null; Class clas = null; ObjectSelectorDialog(EditTile parent, String title, Property property, SuperRoot r, Class clas) { super(parent, title); this.property = property; this.root = r; this.clas = clas; this.ready(); } private void quicksort(String[] objectList, int l, int r) { if (r > l) { String v = objectList[r]; int i = l - 1; int j = r; String tstr; Object tobj; do { while (objectList[++i].compareTo(v) < 0) { } do { j--; } while (j > l && objectList[j].compareTo(v) > 0); tstr = objectList[i]; objectList[i] = objectList[j]; objectList[j] = tstr; tobj = this.objectVector.elementAt(i); this.objectVector.setElementAt(this.objectVector.elementAt(j), i); this.objectVector.setElementAt(tobj, j); } while (j > i); objectList[j] = objectList[i]; objectList[i] = objectList[r]; objectList[r] = tstr; this.objectVector.setElementAt(this.objectVector.elementAt(i), j); this.objectVector.setElementAt(this.objectVector.elementAt(r), i); this.objectVector.setElementAt(tobj, r); this.quicksort(objectList, l, i - 1); this.quicksort(objectList, i + 1, r); } } @Override protected void build() { this.objectVector = new Vector(); if (this.root != null) { Enumeration e = this.root.getDeepOwned(); while (e.hasMoreElements()) { Object obj = e.nextElement(); if (Std.instanceOf(obj, this.clas)) { this.objectVector.addElement(obj); } } String[] objectList = new String[this.objectVector.size()]; for (int i = 0; i < objectList.length; i++) { objectList[i] = this.objectVector.elementAt(i).toString(); } this.quicksort(objectList, 0, objectList.length - 1); this.setListContents(objectList); } super.build(); } protected abstract void addIt(Property var1, Object var2); @Override protected void add(int option) { Object obj = this.objectVector.elementAt(option); if (obj != null) { this.addIt(this.property, obj); } } }