Пример #1
0
  private void fillLayout(LayoutConstraints<?>[] oldConstraints) {
    RADVisualComponent<?>[] radComps = radContainer.getSubComponents();
    int componentCount = radComps.length;
    Component[] primaryComps = new Component[componentCount];
    LayoutConstraints<?>[] newConstraints = new LayoutConstraints<?>[componentCount];

    for (int i = 0; i < componentCount; i++) {
      primaryComps[i] = radComps[i].getBeanInstance();
      newConstraints[i] = radComps[i].getLayoutConstraints(layoutDelegate.getClass());
    }

    layoutDelegate.convertConstraints(oldConstraints, newConstraints, primaryComps);

    if (componentCount > 0) {
      layoutDelegate.acceptNewComponents(radComps, newConstraints, 0);
      layoutDelegate.addComponents(radComps, newConstraints, 0);

      for (int i = 0; i < componentCount; i++) {
        radComps[i].resetConstraintsProperties();
      }
    }

    // setup primary container
    Container cont = getPrimaryContainer();
    Container contDel = getPrimaryContainerDelegate();
    layoutDelegate.setLayoutToContainer(cont, contDel);
    if (componentCount > 0) {
      layoutDelegate.addComponentsToContainer(cont, contDel, primaryComps, 0);
    }
  }
Пример #2
0
  public void removeComponent(RADVisualComponent<?> radComp, int index) {
    // first store constraints in the meta component
    LayoutConstraints<?> constr = layoutDelegate.getConstraints(index);
    if (constr != null) {
      radComp.setLayoutConstraints(layoutDelegate.getClass(), constr);
    }
    // remove the component from layout
    layoutDelegate.removeComponent(index);
    // remove the component instance from the primary container instance
    if (!layoutDelegate.removeComponentFromContainer(
        getPrimaryContainer(),
        getPrimaryContainerDelegate(),
        (Component)
            radComp
                .getBeanInstance())) { // layout delegate does not support removing individual
                                       // components,
      // so we clear the container and add the remaining components again
      layoutDelegate.clearContainer(getPrimaryContainer(), getPrimaryContainerDelegate());

      RADVisualComponent<?>[] radComps = radContainer.getSubComponents();
      if (radComps.length > 1) {
        // we rely on that radcomp was not removed from the model yet
        Component[] comps = new Component[radComps.length - 1];
        for (int i = 0; i < radComps.length; i++) {
          if (i != index) {
            Component comp = (Component) radComps[i].getBeanInstance();
            comps[i < index ? i : i - 1] = comp;
          }
        }
        layoutDelegate.addComponentsToContainer(
            getPrimaryContainer(), getPrimaryContainerDelegate(), comps, 0);
      }
    }
  }
Пример #3
0
  private LayoutConstraints<?>[] removeLayoutDelegate(boolean extractConstraints) {
    int componentCount = layoutDelegate.getComponentCount();
    LayoutConstraints<?>[] constraints = null;

    if (componentCount > 0) {
      RADVisualComponent<?>[] radComps = radContainer.getSubComponents();
      if (radComps.length
          == componentCount) { // robustness: might be called after failed layout initialization
        if (extractConstraints) {
          constraints = new LayoutConstraints<?>[componentCount];
        }

        for (int i = 0; i < componentCount; i++) {
          LayoutConstraints<?> constr = layoutDelegate.getConstraints(i);
          if (extractConstraints) {
            constraints[i] = constr;
          }
          if (constr != null) {
            radComps[i].setLayoutConstraints(layoutDelegate.getClass(), constr);
          }
        }
      }
    }
    layoutDelegate.removeAll();
    layoutDelegate.clearContainer(getPrimaryContainer(), getPrimaryContainerDelegate());
    layoutDelegate = null;
    return constraints;
  }
Пример #4
0
 public void removeAll() {
   // first store constraints in meta components
   RADVisualComponent<?>[] components = radContainer.getSubComponents();
   for (int i = 0; i < components.length; i++) {
     LayoutConstraints<?> constr = layoutDelegate.getConstraints(i);
     if (constr != null) {
       components[i].setLayoutConstraints(layoutDelegate.getClass(), constr);
     }
   }
   // remove components from layout
   layoutDelegate.removeAll();
   // clear the primary container instance
   layoutDelegate.clearContainer(getPrimaryContainer(), getPrimaryContainerDelegate());
 }
Пример #5
0
  @Override
  public void updatePrimaryContainer() {
    Container cont = getPrimaryContainer();
    Container contDel = getPrimaryContainerDelegate();

    layoutDelegate.clearContainer(cont, contDel);
    layoutDelegate.setLayoutToContainer(cont, contDel);

    RADVisualComponent<?>[] components = radContainer.getSubComponents();
    if (components.length > 0) {
      Component[] comps = new Component[components.length];
      for (int i = 0; i < components.length; i++) {
        comps[i] = (Component) components[i].getBeanInstance();
      }
      layoutDelegate.addComponentsToContainer(cont, contDel, comps, 0);
    }
  }