Esempio n. 1
0
  public void loadData(ArrayList<NameValuePair> params, String action) {

    if (loaded) {
      return;
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug(name + Messages.getString(BUNDLE_NAME, "Folder.26")); // $NON-NLS-1$
    }
    // tell the tabs in this folder to load their data
    for (int i = 0; i < dataItems.size(); i++) {
      DataItem item = (DataItem) dataItems.elementAt(i);

      if (item == null) {
        LOG.error(name + Messages.getString(BUNDLE_NAME, "Folder.27") + getTitle()); // $NON-NLS-1$
        continue;
      }
      if (LOG.isDebugEnabled()) {
        LOG.debug(
            name + Messages.getString(BUNDLE_NAME, "Folder.28") + item.getTitle()); // $NON-NLS-1$
      }
      item.loadData(params, action);
    }

    loaded = true;
  }
Esempio n. 2
0
  /** Layout the GUI components of this Folder. */
  private void layoutComponents() {

    // clear the box
    box.removeAll();

    // add the heading if one has been specified
    if (heading != null) {
      if (LOG.isDebugEnabled()) {
        LOG.debug(Messages.getString(BUNDLE_NAME, "Folder.0")); // $NON-NLS-1$
      }
      JLabel p1 = new JLabel(heading);
      box.add(p1);
    }

    // add the tabbed pane if there is more than 1 tab
    if (dataItems.size() > 1) {
      box.add(tabbedPane);

    } else if (dataItems.size() == 1) {
      // otherwise add the single tab as the main component
      DataItem item = (DataItem) dataItems.elementAt(0);
      box.add(item);
    }

    validate();

    repaint();
  }
Esempio n. 3
0
  /* (non-Javadoc)
   * @see org.ribax.swing.ui.TabContainer#loadData(java.util.ArrayList, java.lang.String)
   */
  public void loadData(ArrayList<NameValuePair> params, String action) {

    // if we already have our data then do nothing
    if (loaded) {
      return;
    }

    try {
      setCursor(new Cursor(Cursor.WAIT_CURSOR));

      // if we have deferred reading the Tab description until the Tab was displayed
      // then read the description now
      if (deferredSource != null) {
        readDescriptionFromURL(deferredSource, deferredParams, deferredAction);
        deferredSource = null;
        deferredParams = null;
        deferredAction = null;
      }
      if (LOG.isDebugEnabled()) {
        LOG.debug(name + Messages.getString(BUNDLE_NAME, "Tab.23")); // $NON-NLS-1$
      }
      // load the data for all the DataItems on this Tab
      loadItemData(params, action);
    } finally {
      // whatever happens we must set the cursor back to the default
      setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }

    // indicate we have loaded our data
    loaded = true;
  }
Esempio n. 4
0
  /* (non-Javadoc)
   * @see org.ribax.swing.ui.TabContainer#loadItemData(java.util.ArrayList, java.lang.String)
   */
  protected void loadItemData(ArrayList<NameValuePair> params, String action) {

    if (params == null) {
      params = new ArrayList<NameValuePair>();
    }

    // if there are parameters on this Tab then add them to the parameters for
    // submission to any web service
    if (paramSet != null) {
      ArrayList<NameValuePair> tlist = paramSet.getNameValuePairs();

      if (tlist != null) {
        params.addAll(tlist);
      }
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug(name + Messages.getString(BUNDLE_NAME, "Tab.19")); // $NON-NLS-1$
    }
    // tell each data Item to load its data using the parameters and action string
    for (int i = 0; i < dataItems.size(); i++) {
      DataItem item = (DataItem) dataItems.elementAt(i);

      if (item == null) {
        LOG.error(name + Messages.getString(BUNDLE_NAME, "Tab.20") + getTitle()); // $NON-NLS-1$
        continue;
      }
      item.loadData(params, action);
    }
  }
Esempio n. 5
0
  /* (non-Javadoc)
   * @see org.ribax.swing.ui.TabContainer#refresh(java.util.ArrayList, java.lang.String)
   */
  public void refresh(ArrayList<NameValuePair> params, String action) {

    if (LOG.isDebugEnabled()) {
      LOG.debug(name + Messages.getString(BUNDLE_NAME, "Tab.17")); // $NON-NLS-1$
    }
    // invalidate all the DataItems on this Tab
    invalidateDataItems();

    if (source != null) {
      // replace the contents of the tab with the data from the source
      readDescriptionFromURL(url, params, action);

      loaded = false;

      // now tell each new data item to load its data
      loadData(params, action);

    } else {

      // tell each DataItem in our internal list to refresh
      for (int i = 0; i < dataItems.size(); i++) {
        DataItem item = (DataItem) dataItems.elementAt(i);

        if (item == null) {
          LOG.error(name + Messages.getString(BUNDLE_NAME, "Tab.18") + getTitle()); // $NON-NLS-1$
          continue;
        }
        item.refresh(params, action);
      }
    }
  }
Esempio n. 6
0
 /* (non-Javadoc)
  * @see org.ribax.swing.ui.DataItem#updateData(java.util.ArrayList, java.lang.String)
  */
 public void updateData(ArrayList<NameValuePair> params, String action) {
   if (LOG.isDebugEnabled()) {
     LOG.debug(name + Messages.getString(BUNDLE_NAME, "Folder.25")); // $NON-NLS-1$
   }
   // update all the Tabs in this folder
   for (int i = 0; i < dataItems.size(); i++) {
     DataItem item = (DataItem) dataItems.elementAt(i);
     item.updateData(params, action);
   }
 }
Esempio n. 7
0
  /* (non-Javadoc)
   * @see org.ribax.swing.ui.TabContainer#readDescription(org.jdom.Element)
   */
  public void readDescription(Element tab) {
    Element e;

    super.readDescription(tab);

    box.removeAll();

    if (LOG.isDebugEnabled()) {
      LOG.debug(name + Messages.getString(BUNDLE_NAME, "Tab.2")); // $NON-NLS-1$
    }
    // get the set of DataItems on this Tab
    if ((e = tab.getChild("dataItems")) != null) { // $NON-NLS-1$
      if (LOG.isDebugEnabled()) {
        LOG.debug(name + Messages.getString(BUNDLE_NAME, "Tab.7")); // $NON-NLS-1$
      }
      // iterate through the DataItems
      List<Element> dilist = e.getChildren();
      Iterator<Element> it = dilist.iterator();
      while (it.hasNext()) {
        Element di = it.next();

        // use DataItemFactory.readComponent to create a new DataItem
        // from the Element tree
        DataItem component = DataItemFactory.readComponent(di, this);

        if (component == null) {
          continue;
        }

        // if the DataItem is hidden then only add it to our internal list
        if (component instanceof HiddenDataItem) {
          dataItems.add(component);
        } else // otherwise add it to our internal list and the display panel
        {
          addDataItem(component);
        }
      }
    }

    // layout the GUI components
    layoutComponents();
  }
Esempio n. 8
0
  /* (non-Javadoc)
   * @see org.ribax.swing.ui.DataItem#refresh(java.util.ArrayList, java.lang.String)
   */
  public void refresh(ArrayList<NameValuePair> params, String action) {
    if (LOG.isDebugEnabled()) {
      LOG.debug(name + " refresh");
    }

    // refresh each Tab in the tabbed pane
    for (int i = 0; i < dataItems.size(); i++) {
      DataItem item = (DataItem) dataItems.elementAt(i);
      item.refresh(params, action);
    }
  }
Esempio n. 9
0
  /* (non-Javadoc)
   * @see org.ribax.swing.ui.DataItem#invalidateData()
   */
  public void invalidateData() {
    if (LOG.isDebugEnabled()) {
      LOG.debug(name + Messages.getString(BUNDLE_NAME, "Folder.24")); // $NON-NLS-1$
    }
    loaded = false;

    // invalidate all the Tabs in this folder
    for (int i = 0; i < dataItems.size(); i++) {
      DataItem item = (DataItem) dataItems.elementAt(i);
      item.invalidateData();
    }
  }
Esempio n. 10
0
 /**
  * Add a component to the tabbed pane.
  *
  * @param item the component to add.
  */
 protected void addDataItem(DataItem item) {
   if (LOG.isDebugEnabled()) {
     LOG.debug(
         name
             + Messages.getString(BUNDLE_NAME, "Folder.20")
             + item.getDataItemName()
             + Messages.getString(BUNDLE_NAME, "Folder.21")); // $NON-NLS-1$ //$NON-NLS-2$
   }
   item.setBorder(new EmptyBorder(5, 5, 5, 5));
   dataItems.add(item);
   String title = item.getTitle();
   if (title == null || title.length() == 0) {
     title = item.toString();
   }
   tabbedPane.addTab(title, item);
 }
Esempio n. 11
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);
    }
  }
Esempio n. 12
0
  /**
   * Load the given Folder into the main panel.
   *
   * @param node the user object from the JTree node that should be a Folder/DataItem
   * @see org.ribax.swing.ui.Folder
   * @see org.ribax.swing.ui.DataItem
   */
  private void loadNodeObject(Object node) {

    if (node == null) {
      return;
    }

    try {
      setCursor(new Cursor(Cursor.WAIT_CURSOR));

      this.nodeInfo = node;

      if (LOG.isDebugEnabled()) {
        LOG.debug(
            name
                + Messages.getString(BUNDLE_NAME, "RootFolder.13")
                + nodeInfo.toString()); // $NON-NLS-1$
      }
      // the node object must be a DataItem
      if (nodeInfo instanceof DataItem) {

        // get the name or title of the Folder/DataItem
        String nodeName = ((DataItem) nodeInfo).getDataItemName();
        if (nodeName == null) {
          nodeName = ((DataItem) nodeInfo).getTitle();
        }

        applet.reportStatus(
            name
                + Messages.getString(BUNDLE_NAME, "RootFolder.14")
                + nodeName
                + Messages.getString(BUNDLE_NAME, "RootFolder.15")); // $NON-NLS-1$ //$NON-NLS-2$

        // tell the Folder to load it's data if it hasn't already done so
        if (globalParams == null) {
          ((DataItem) nodeInfo)
              .loadData(null, Messages.getString(BUNDLE_NAME, "RootFolder.16")); // $NON-NLS-1$
        } else {
          ((DataItem) nodeInfo)
              .loadData(globalParams.getNameValuePairs(), "LoadData"); // $NON-NLS-1$
        }
        applet.reportStatus(
            name + Messages.getString(BUNDLE_NAME, "RootFolder.18") + nodeName); // $NON-NLS-1$
      } else {
        LOG.info(
            name
                + Messages.getString(BUNDLE_NAME, "RootFolder.19")
                + nodeInfo.getClass().getName()); // $NON-NLS-1$
      }

      if (LOG.isDebugEnabled()) {
        LOG.debug(
            name
                + Messages.getString(BUNDLE_NAME, "RootFolder.20")
                + nodeInfo.toString()); // $NON-NLS-1$
      }
    } finally {
      setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }

    // update the UI so the selected Folder appears in the main panel
    mainPanel.removeAll();
    mainPanel.add((JComponent) nodeInfo, BorderLayout.CENTER);

    mainPanel.validate();
    mainPanel.repaint();
  }