Beispiel #1
0
  /**
   * Read the description of this RootFolder into a Folder and create the GUI components of the
   * Folder.
   *
   * @param node the element tree containing the Folder description
   * @return a node that is the root node in an expandable JTree
   */
  private DefaultMutableTreeNode readDescription(Element node) {
    Element e;

    // create a new Folder that contains the contents of this RootFolder
    Folder f = new Folder(null);

    // get some basic attributes
    name = XMLutils.getElementString("name", node); // $NON-NLS-1$
    title = XMLutils.getElementString("title", node); // $NON-NLS-1$
    description = XMLutils.getElementString("description", node); // $NON-NLS-1$
    tooltip = XMLutils.getElementString("tooltip", node); // $NON-NLS-1$

    // read any global parameters
    if ((e = node.getChild("parameters")) != null) { // $NON-NLS-1$
      globalParams = ParameterSet.readParameters(e);
      ParameterSet.globalParameterSet = globalParams;
    }

    // read a button panel
    if ((e = node.getChild("buttons")) != null) { // $NON-NLS-1$
      buttonPanel = new ButtonPanel(this);
      buttonPanel.readButtons(e);
    }

    // is the root node visible
    Boolean bval = XMLutils.getElementBoolean("visible", node); // $NON-NLS-1$
    if (bval != null) {
      rootIsVisible = bval.booleanValue();
    }

    // are the tree handles visible
    bval = XMLutils.getElementBoolean("showHandles", node); // $NON-NLS-1$
    if (bval != null) {
      showHandles = bval.booleanValue();
    }

    // create a new JTree node with the Folder as the data object
    DefaultMutableTreeNode newnode = new DefaultMutableTreeNode(f);

    // read the Folder from the element tree
    f.readFolder(newnode, node);

    return newnode;
  }
Beispiel #2
0
  /**
   * Read the definition of this Folder from the XML element tree.
   *
   * @param treenode the JTree node that represents this Folder
   * @param node the XML element tree
   */
  public void readFolder(DefaultMutableTreeNode treenode, Element node) {
    Element e;
    String source = null;

    // base class reads common values
    super.readDescription(node);

    // get the heading
    heading = XMLutils.getElementString("heading", node); // $NON-NLS-1$

    // if a background colour has been specified then set it also for the tabbed pane
    if (bgcolour != null) {
      tabbedPane.setBackground(bgcolour);
    }

    source = XMLutils.getElementString("source", node); // $NON-NLS-1$
    // if a source has been specified then read the description from the source
    // test the value of url, if it has been set then this could be the 2nd
    // time we are in this method, a source tag in a sourced description would
    // otherwise cause an infinite loop
    if (source != null && url == null) {
      url = source;
      readFolderFromURL(source, treenode);
      return;
    }

    // read the list of tabs in this folder
    if ((e = node.getChild("tabList")) != null) { // $NON-NLS-1$
      if (LOG.isDebugEnabled()) {
        LOG.debug(name + Messages.getString(BUNDLE_NAME, "Folder.4")); // $NON-NLS-1$
      }
      // iterate through the list
      List<Element> children = e.getChildren();
      Iterator<Element> iterator = children.iterator();
      while (iterator.hasNext()) {
        Element tabnode = (Element) iterator.next();

        // create a new Tab and read the definition
        Tab t = new Tab(this);
        t.readDescription(tabnode);

        // add the tab to this folder
        addDataItem(t);
      }
    }

    Element tds;
    // get any tabbed data sets
    // Tabbed data sets are siblings of other tabs in the tabbed pane and are
    // themselves a tabbed pane with a set of sub tabs
    if ((tds = node.getChild("tabbedDataSet")) != null) { // $NON-NLS-1$
      if (LOG.isDebugEnabled()) {
        LOG.debug(name + Messages.getString(BUNDLE_NAME, "Folder.6")); // $NON-NLS-1$
      }
      // create a new tabbed data set
      TabbedDataSet tabset = new TabbedDataSet(this);

      // read the description and add it to the tabbed pane
      tabset.bgcolour = bgcolour;
      tabset.readDescription(tds);

      addDataItem(tabset);
    }

    // read any sub folders recursively
    if ((e = node.getChild("folderList")) != null) { // $NON-NLS-1$
      if (LOG.isDebugEnabled()) {
        LOG.debug(name + Messages.getString(BUNDLE_NAME, "Folder.8")); // $NON-NLS-1$
      }
      // iterate through the list of folders
      List<Element> children = e.getChildren();
      Iterator<Element> iterator = children.iterator();
      while (iterator.hasNext()) {
        Element folder = (Element) iterator.next();

        // create a new Folder
        Folder f = new Folder(this);

        DefaultMutableTreeNode newnode = new DefaultMutableTreeNode(f);

        // read the description of the folder and add it to the JTree
        // as a child of the tree node that this Folder represents
        f.readFolder(newnode, folder);

        treenode.add(newnode);
      }
    }

    layoutComponents();

    // get any specified icon
    try {
      String logo = XMLutils.getElementString("icon", node); // $NON-NLS-1$
      if (logo != null) {
        URL u = new URL(logo);
        this.icon = new ImageIcon(u); // createAppletImageIcon(logo,title);
      }
    } catch (Exception ex) {
      LOG.error(name, ex);
    }
  }