home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 September / pcp155a.iso / linux / ldp / Folder.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-05-02  |  2.7 KB  |  115 lines

  1. import java.awt.Image;
  2. import java.net.URL;
  3. import java.util.Vector;
  4.  
  5. public class Folder {
  6.    private Vector subFolders;
  7.    private Image iconOpen;
  8.    private Image iconClosed;
  9.    private Folder parent;
  10.    public int level;
  11.    private String text;
  12.    private URL hRef;
  13.    private String target;
  14.    private String warning;
  15.    private boolean open;
  16.  
  17.    public Folder() {
  18.       this((Folder)null);
  19.    }
  20.  
  21.    public Folder(Folder parent) {
  22.       this.subFolders = new Vector();
  23.       this.iconOpen = null;
  24.       this.iconClosed = null;
  25.       this.text = "";
  26.       this.hRef = null;
  27.       this.target = "";
  28.       this.warning = null;
  29.       this.parent = parent;
  30.       if (parent != null) {
  31.          parent.addSubFolder(this);
  32.          this.level = parent.level + 1;
  33.       } else {
  34.          this.level = 0;
  35.       }
  36.  
  37.    }
  38.  
  39.    public void setText(String text) {
  40.       this.text = text;
  41.    }
  42.  
  43.    public String getText() {
  44.       return this.text;
  45.    }
  46.  
  47.    public void setHRef(URL hRef) {
  48.       this.hRef = hRef;
  49.    }
  50.  
  51.    public URL getHRef() {
  52.       return this.hRef;
  53.    }
  54.  
  55.    public void setTarget(String target) {
  56.       this.target = target;
  57.    }
  58.  
  59.    public String getTarget() {
  60.       return this.target;
  61.    }
  62.  
  63.    public void setWarning(String warning) {
  64.       this.warning = warning;
  65.    }
  66.  
  67.    public String getWarning() {
  68.       return this.warning;
  69.    }
  70.  
  71.    public void setOpen(boolean open) {
  72.       this.open = open;
  73.    }
  74.  
  75.    public boolean isOpen() {
  76.       return this.open;
  77.    }
  78.  
  79.    public void toggleOpen() {
  80.       this.open = !this.open;
  81.    }
  82.  
  83.    public void setIconOpen(Image iconOpen) {
  84.       this.iconOpen = iconOpen;
  85.    }
  86.  
  87.    public Image getIconOpen() {
  88.       return this.iconOpen;
  89.    }
  90.  
  91.    public Image getIcon() {
  92.       return this.isOpen() && this.hasChildren() ? this.getIconOpen() : this.getIconClosed();
  93.    }
  94.  
  95.    public void setIconClosed(Image iconClosed) {
  96.       this.iconClosed = iconClosed;
  97.    }
  98.  
  99.    public Image getIconClosed() {
  100.       return this.iconClosed;
  101.    }
  102.  
  103.    public boolean hasChildren() {
  104.       return !this.subFolders.isEmpty();
  105.    }
  106.  
  107.    public void addSubFolder(Folder f1) {
  108.       this.subFolders.addElement(f1);
  109.    }
  110.  
  111.    public Vector getSubFolders() {
  112.       return this.subFolders;
  113.    }
  114. }
  115.