// 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 } }
public void setLayoutDelegate(LayoutSupportDelegate newDelegate /*, boolean fromCode*/) throws Exception { LayoutConstraints<?>[] oldConstraints; LayoutSupportDelegate oldDelegate = layoutDelegate; if (layoutDelegate != null && (layoutDelegate != newDelegate /* || !fromCode*/)) { oldConstraints = removeLayoutDelegate(true); } else { oldConstraints = null; } layoutDelegate = newDelegate; propertySets = null; needInit = false; if (layoutDelegate != null) { try { layoutDelegate.initialize(this, null); fillLayout(oldConstraints); getPropertySets(); // force properties and listeners creation } catch (Exception ex) { removeLayoutDelegate(false); layoutDelegate = oldDelegate; if (layoutDelegate != null) { fillLayout(null); } throw ex; } } }