/** * returns the constraint for the given component position * * @param i position * @return constraint for component at given position */ public Object getConstraintAt(int i) { return getConstraintList().get(i); }
/** * Removes the given component from the container. * * @param c the component to remove * @see #remove(org.wings.SComponent) */ public void remove(SComponent c) { if (c == null) return; if (layout != null) layout.removeComponent(c); int index = getComponentList().indexOf(c); if (getComponentList().remove(c)) { getConstraintList().remove(index); c.removeNotify(); fireContainerEvent(SContainerEvent.COMPONENT_REMOVED, c); c.setParent(null); reload(); } }
/** * CAVEAT this did not work yet... We need to clone the layout manager as * well, so SLayoutManager must be Cloneable */ @Override public Object clone() { try { SContainer erg = (SContainer) super.clone(); // uiuiui, layout manager must be cloned as well,... // componentList and constraintList contain references to the // original components / constraints erg.getComponentList().clear(); erg.getConstraintList().clear(); for (int i = 0; i < getComponentCount(); i++) { erg.addComponent((SComponent) getComponent(i).clone()); } return erg; } catch (Exception e) { log.error("Unable to clone container", e); return null; } }
private static void rebuildPanel(SContainer oldPanel, SContainer newPanel) { SLayoutManager layoutManager = oldPanel.getLayout(); SComponent[] components = oldPanel.getComponents(); ArrayList constraints = oldPanel.getConstraintList(); oldPanel.removeAll(); oldPanel.setLayout(null); newPanel.setLayout(layoutManager); for (int i = 0; i < components.length; i++) { SComponent component = components[i]; Object constraint = constraints.get(i); newPanel.add(component, constraint); } }
getConstraintList().add(index, constraint); c.setParent(this);