home *** CD-ROM | disk | FTP | other *** search
- package com.sfs.awt.treeview;
-
- import com.sfs.util.Insertionsort;
- import com.sfs.util.Sortable;
- import java.awt.FontMetrics;
- import java.util.Vector;
-
- public class RootFolder extends Folder implements Sortable {
- public Vector Rows;
- // $FF: renamed from: fm java.awt.FontMetrics
- public FontMetrics field_0;
- TreeView View;
- Vector Selection;
- Item caretItem;
- protected Insertionsort Sorter;
-
- public Item prevVisibleItem(int var1) {
- Item var2 = null;
-
- do {
- --var1;
- if (var1 <= -1) {
- break;
- }
-
- var2 = this.getItemAt(var1);
- } while(!var2.isVisible());
-
- return var1 == -1 ? null : var2;
- }
-
- public String toString() {
- String var1 = "RootFolder ->\n";
-
- for(int var2 = 0; var2 < this.Rows.size(); ++var2) {
- Item var3 = (Item)this.Rows.elementAt(var2);
- String var4 = var3.getName();
- int var5 = var3.getSpaces();
-
- for(var1 = var1 + Integer.toString(var2) + "\t:"; var5-- > 0; var1 = var1 + " ") {
- }
-
- var1 = var1 + var4 + "\n";
- }
-
- var1 = var1 + "_________________________________________________\n";
- return var1;
- }
-
- public Item visibleItemAt(int var1) {
- Item var2 = null;
-
- while(var1 < this.Rows.size()) {
- var2 = this.getItemAt(var1);
- ++var1;
- if (var2.isVisible()) {
- break;
- }
- }
-
- return var1 > this.Rows.size() ? null : var2;
- }
-
- public Item getItemAt(int var1) {
- try {
- return (Item)this.Rows.elementAt(var1);
- } catch (ArrayIndexOutOfBoundsException var2) {
- return null;
- }
- }
-
- public Item getLastSelectedItem() {
- return this.Selection.size() == 0 ? null : (Item)this.Selection.lastElement();
- }
-
- public void removeItem(Item var1) {
- this.removeItemAt(this.indexOf(var1));
- }
-
- public synchronized void setSorter(Sortable var1) {
- this.Sorter = new Insertionsort(var1);
- }
-
- public void clearSelection() {
- while(this.Selection.size() > 0) {
- ((Item)this.Selection.elementAt(0)).setSelected(false);
- }
-
- }
-
- public int indexOf(Item var1) {
- return this.Rows.indexOf(var1);
- }
-
- public void removeItemAt(int var1) {
- Item var2 = (Item)this.Rows.elementAt(var1);
- int var3 = var2.getSpaces();
-
- do {
- this.Rows.removeElementAt(var1);
- } while(this.Rows.size() > var1 && ((Item)this.Rows.elementAt(var1)).getSpaces() > var3);
-
- }
-
- protected void removeSelectedItem(Item var1) {
- this.Selection.removeElement(var1);
- }
-
- protected boolean isSelectedItem(Item var1) {
- return this.Selection.contains(var1);
- }
-
- public Item getCaretItem() {
- return this.caretItem;
- }
-
- protected void setCaretItem(Item var1) {
- this.caretItem = var1;
- }
-
- protected void AdjustScrollbars() {
- if (this.field_0 != null) {
- int var1 = 0;
- int var2 = 0;
- Item var3 = this.visibleItemAt(0);
- int var4 = this.indexOf(var3);
-
- while(true) {
- int var5 = var3.getSpaces() * 17 + 16 + this.field_0.stringWidth(var3.getName());
- if (var5 > var2) {
- var2 = var5;
- }
-
- ++var1;
- var3 = this.nextVisibleItem(var4);
- if (var3 == null) {
- if (this.View != null) {
- this.View.setScrollbars(var1, var2 / 17);
- }
-
- return;
- }
-
- var4 = this.indexOf(var3);
- }
- }
- }
-
- public int compare(Object var1, Object var2) {
- return 0;
- }
-
- public Vector getSelection() {
- return this.Selection;
- }
-
- public int getHeight() {
- int var1 = 0;
- int var2 = this.Rows.size();
-
- while(var2-- > 0) {
- if (this.getItemAt(var2).isVisible()) {
- ++var1;
- }
- }
-
- return var1;
- }
-
- public RootFolder(TreeView var1, String var2, Object var3) {
- this((TreeView)null, var2, var3, 0);
- this.View = var1;
- }
-
- RootFolder(TreeView var1, String var2, Object var3, int var4) {
- super((RootFolder)null, (Folder)null, var2, var3, var4);
- this.Rows = new Vector();
- super.Owner = this;
- this.Selection = new Vector();
- ((Folder)this).setOpen(true);
- this.insertItem(this);
- this.Sorter = new Insertionsort(this);
- }
-
- protected void addSelectedItem(Item var1) {
- this.Selection.addElement(var1);
- }
-
- public void insertItem(Item var1) {
- Folder var2 = var1.getParent();
- int var3 = 0;
- if (var2 != null) {
- if (var2.Root.size() == 1) {
- var3 = this.indexOf(var2) + 1;
- } else if (var2.Root.indexOf(var1) == var2.Root.size() - 1) {
- var3 = this.indexOf(var2) + var2.size();
- if (var2.size() > 0) {
- for(int var4 = ((Item)var2).getSpaces(); var3 < this.Rows.size() && (this.getItemAt(var3).getSpaces() > var4 || this.getItemAt(var3).getParent() == var2); ++var3) {
- }
- }
- } else {
- var3 = this.indexOf(var2.getItem(var2.Root.indexOf(var1) + 1));
- }
- }
-
- this.Rows.insertElementAt(var1, var3);
- this.AdjustScrollbars();
- }
-
- public Item nextVisibleItem(int var1) {
- Item var2 = null;
-
- do {
- ++var1;
- if (var1 >= this.Rows.size()) {
- break;
- }
-
- var2 = this.getItemAt(var1);
- } while(!var2.isVisible());
-
- return var1 == this.Rows.size() ? null : var2;
- }
- }
-