List of usage examples for com.vaadin.ui AbstractSplitPanel setSplitPosition
public void setSplitPosition(float pos)
From source file:org.semanticsoft.vaaclipse.presentation.renderers.SashRenderer.java
License:Open Source License
void setWeights(MPartSashContainer sash) { @SuppressWarnings("unchecked") List<MPartSashContainerElement> renderableAndVisible = (List<MPartSashContainerElement>) filterRenderableAndVisibleElements( sash);//from w ww . j a v a2 s.co m if (renderableAndVisible.size() < 2) return; Map<MPartSashContainerElement, Double> weights = new HashMap<MPartSashContainerElement, Double>(); Map<Component, MPartSashContainerElement> map = new HashMap<Component, MPartSashContainerElement>(); double total_weight = 0; for (MPartSashContainerElement children : renderableAndVisible) { String data = children.getContainerData(); double weight = parseContainerData(data); map.put((Component) children.getWidget(), children); weights.put(children, weight); total_weight += weight; } if (total_weight == 0.0) //all child elements has zero weight total_weight = 1.0; AbstractSplitPanel topSashWidget = (AbstractSplitPanel) ((VerticalLayout) sash.getWidget()).getComponent(0); AbstractSplitPanel currentSashWidget = topSashWidget; while (true) { MPartSashContainerElement e1 = map.get(currentSashWidget.getFirstComponent()); //the first - is always element double w = weights.get(e1); double pos = (w / total_weight) * 100; currentSashWidget.setSplitPosition((float) pos); if (map.containsKey(currentSashWidget.getSecondComponent())) break; currentSashWidget = (AbstractSplitPanel) currentSashWidget.getSecondComponent(); total_weight = total_weight - w; } }