Beispiel #1
0
  /**
   * Removes all beans from containing component
   *
   * @param container a <code>JComponent</code> value
   */
  public static void removeAllBeansFromContainer(JComponent container, Integer... tab) {

    int index = 0;
    if (tab.length > 0) {
      index = tab[0].intValue();
    }

    Vector<Object> components = null;
    if (TABBED_COMPONENTS.size() > 0 && index < TABBED_COMPONENTS.size()) {
      components = TABBED_COMPONENTS.get(index);
    }

    if (container != null) {
      if (components != null) {
        for (int i = 0; i < components.size(); i++) {
          Object tempInstance = components.elementAt(i);
          Object tempBean = ((BeanInstance) tempInstance).getBean();
          if (Beans.isInstanceOf(tempBean, JComponent.class)) {
            container.remove((JComponent) tempBean);
          }
        }
      }
      container.revalidate();
    }
  }
Beispiel #2
0
  /**
   * Adds the supplied collection of beans at the supplied index in the list of collections. If the
   * index is not supplied then the primary collection is set (i.e. index 0). Also adds the beans to
   * the supplied JComponent container (if not null)
   *
   * @param beanInstances a <code>Vector</code> value
   * @param container a <code>JComponent</code> value
   */
  public static void setBeanInstances(
      Vector<Object> beanInstances, JComponent container, Integer... tab) {
    removeAllBeansFromContainer(container, tab);

    if (container != null) {
      for (int i = 0; i < beanInstances.size(); i++) {
        Object bean = ((BeanInstance) beanInstances.elementAt(i)).getBean();
        if (Beans.isInstanceOf(bean, JComponent.class)) {
          container.add((JComponent) bean);
        }
      }
      container.revalidate();
      container.repaint();
    }

    int index = 0;
    if (tab.length > 0) {
      index = tab[0].intValue();
    }

    if (index < TABBED_COMPONENTS.size()) {
      TABBED_COMPONENTS.set(index, beanInstances);
    }

    // COMPONENTS = beanInstances;
  }
Beispiel #3
0
  /**
   * Adds the supplied collection of beans to the end of the list of collections and to the
   * JComponent container (if not null)
   *
   * @param beanInstances the vector of bean instances to add
   * @param container
   */
  public static void addBeanInstances(Vector<Object> beanInstances, JComponent container) {
    // reset(container);

    if (container != null) {
      for (int i = 0; i < beanInstances.size(); i++) {
        Object bean = ((BeanInstance) beanInstances.elementAt(i)).getBean();
        if (Beans.isInstanceOf(bean, JComponent.class)) {
          container.add((JComponent) bean);
        }
      }
      container.revalidate();
      container.repaint();
    }

    TABBED_COMPONENTS.add(beanInstances);
  }
Beispiel #4
0
  /**
   * Adds this bean to the global list of beans and to the supplied container. The constructor calls
   * this method, so a client should not need to unless they have called removeBean and then wish to
   * have it added again.
   *
   * @param container the Component on which this BeanInstance will be displayed
   */
  public void addBean(JComponent container, Integer... tab) {

    int index = 0;
    if (tab.length > 0) {
      index = tab[0].intValue();
    }

    Vector<Object> components = null;
    if (TABBED_COMPONENTS.size() > 0 && index < TABBED_COMPONENTS.size()) {
      components = TABBED_COMPONENTS.get(index);
    }

    // do nothing if we are already in the list
    if (components.contains(this)) {
      return;
    }

    // Ignore invisible components
    if (!Beans.isInstanceOf(m_bean, JComponent.class)) {
      System.out.println("Component is invisible!");
      return;
    }

    components.addElement(this);

    // Position and layout the component
    JComponent c = (JComponent) m_bean;
    Dimension d = c.getPreferredSize();
    int dx = (int) (d.getWidth() / 2);
    int dy = (int) (d.getHeight() / 2);
    m_x -= dx;
    m_y -= dy;
    c.setLocation(m_x, m_y);
    // c.doLayout();
    c.validate();
    // bp.addBean(c);
    // c.repaint();
    if (container != null) {
      container.add(c);
      container.revalidate();
    }
  }
Beispiel #5
0
  public static void appendBeans(JComponent container, Vector<Object> beans, int tab) {
    if (TABBED_COMPONENTS.size() > 0 && tab < TABBED_COMPONENTS.size()) {
      Vector<Object> components = TABBED_COMPONENTS.get(tab);
      //

      for (int i = 0; i < beans.size(); i++) {
        components.add(beans.get(i));
        if (container != null) {
          Object bean = ((BeanInstance) beans.elementAt(i)).getBean();
          if (Beans.isInstanceOf(bean, JComponent.class)) {
            container.add((JComponent) bean);
          }
        }
      }

      if (container != null) {
        container.revalidate();
        container.repaint();
      }
    }
  }