Exemplo n.º 1
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);
      }
    }
  }
Exemplo n.º 2
0
  // copy layout delegate from another container
  public void copyLayoutDelegateFrom(
      LayoutSupportManager sourceLayoutSupport, RADVisualComponent<?>[] newRadComps) {
    LayoutSupportDelegate sourceDelegate = sourceLayoutSupport.getLayoutDelegate();

    int componentCount = sourceDelegate.getComponentCount();

    Container cont = getPrimaryContainer();
    Container contDel = getPrimaryContainerDelegate();

    if (layoutDelegate != null) {
      removeLayoutDelegate(false);
    }

    Component[] primaryComps = new Component[componentCount];

    for (int i = 0; i < componentCount; i++) {
      RADVisualComponent<?> radComp = newRadComps[i];
      primaryComps[i] = (Component) radComp.getBeanInstance();
    }

    LayoutSupportDelegate newDelegate = sourceDelegate.cloneLayoutSupport(this, newRadComps);

    newDelegate.setLayoutToContainer(cont, contDel);
    newDelegate.addComponentsToContainer(cont, contDel, primaryComps, 0);

    layoutDelegate = newDelegate;

    // Ensure correct propagation of copied properties (issue 50011, 72351)
    try {
      layoutDelegate.acceptContainerLayoutChange(null);
    } catch (PropertyVetoException pvex) {
      // should not happen
    }
  }
Exemplo n.º 3
0
 // components adding/removing
 public void injectComponents(
     RADVisualComponent<?>[] components, LayoutConstraints<?>[] aConstraints, int index) {
   if (index <= -1) {
     index = layoutDelegate.getComponentCount();
   }
   layoutDelegate.addComponents(components, aConstraints, index);
   for (RADVisualComponent<?> component : components) {
     component.resetConstraintsProperties();
   }
 }
Exemplo n.º 4
0
 public static LayoutConstraints<?> storeConstraints(RADVisualComponent<?> radComp) {
   LayoutSupportManager layoutSupport = radComp.getParentLayoutSupport();
   if (layoutSupport != null) {
     LayoutConstraints<?> constr = layoutSupport.getConstraints(radComp);
     if (constr != null) {
       radComp.setLayoutConstraints(layoutSupport.getLayoutDelegate().getClass(), constr);
     }
     return constr;
   } else {
     return null;
   }
 }
Exemplo n.º 5
0
 public LayoutConstraints<?> getConstraints(RADVisualComponent<?> radComp) {
   if (layoutDelegate != null) {
     int index = radComp.getComponentIndex(); // radContainer.getIndexOf(radComp);
     return index >= 0 && index < layoutDelegate.getComponentCount()
         ? layoutDelegate.getConstraints(index)
         : null;
   } else {
     return null;
   }
 }
Exemplo n.º 6
0
  @Override
  public void componentLayoutChanged(int index, PropertyChangeEvent ev)
      throws PropertyVetoException {
    RADVisualComponent<?> radComp = radContainer.getSubComponent(index);

    if (ev != null && ev.getPropertyName() != null) {
      layoutDelegate.acceptComponentLayoutChange(index, ev);

      FormModel formModel = radContainer.getFormModel();
      formModel.fireComponentLayoutChanged(
          radComp, ev.getPropertyName(), ev.getOldValue(), ev.getNewValue());

      if (radComp.getNodeReference() != null) // propagate the change to node
      {
        radComp
            .getNodeReference()
            .firePropertyChangeHelper(ev.getPropertyName(), ev.getOldValue(), ev.getNewValue());
      }
    } else {
      if (radComp.getNodeReference() != null) // propagate the change to node
      {
        radComp.getNodeReference().fireComponentPropertySetsChange();
      }
      radComp.resetConstraintsProperties();
    }
  }
Exemplo n.º 7
0
 public LayoutConstraints<?> getStoredConstraints(RADVisualComponent<?> radComp) {
   return radComp.getLayoutConstraints(layoutDelegate.getClass());
 }