Example usage for com.vaadin.ui AbstractSplitPanel getSecondComponent

List of usage examples for com.vaadin.ui AbstractSplitPanel getSecondComponent

Introduction

In this page you can find the example usage for com.vaadin.ui AbstractSplitPanel getSecondComponent.

Prototype

public Component getSecondComponent() 

Source Link

Document

Gets the second component of this split panel.

Usage

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);/* ww w  .jav a2 s. c om*/
    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;
    }
}

From source file:org.semanticsoft.vaaclipse.widgets.WorkbenchWindow.java

License:Open Source License

private void updateBounds(ComponentContainer container, Bounds currentBounds) {
    if (container instanceof BoundsinfoVerticalLayout) {
        BoundsinfoVerticalLayout bvl = (BoundsinfoVerticalLayout) container;
        bvl.setBounds(currentBounds);/* w  w  w.  j a  v a 2 s .  c  o  m*/
    } else if (container instanceof StackWidget) {
        StackWidget bvl = (StackWidget) container;
        bvl.setBounds(currentBounds);
    }

    if (container instanceof SashWidget) {
        AbstractSplitPanel splitPanel = (AbstractSplitPanel) container;
        float splitPos = splitPanel.getSplitPosition() / 100;
        if (splitPanel instanceof HorizontalSplitPanel) {
            int firstBoundsWidth = (int) (splitPos * currentBounds.w);
            if (splitPanel.getFirstComponent() instanceof ComponentContainer) {
                Bounds leftBounds = new Bounds(currentBounds.x, currentBounds.y, firstBoundsWidth,
                        currentBounds.h);
                updateBounds((ComponentContainer) splitPanel.getFirstComponent(), leftBounds);
            }

            if (splitPanel.getSecondComponent() instanceof ComponentContainer) {
                Bounds rightBounds = new Bounds(currentBounds.x + firstBoundsWidth, currentBounds.y,
                        (int) (currentBounds.w - firstBoundsWidth), currentBounds.h);
                updateBounds((ComponentContainer) splitPanel.getSecondComponent(), rightBounds);
            }
        } else if (splitPanel instanceof VerticalSplitPanel) {
            int firstBoundsHeight = (int) (splitPos * currentBounds.h);
            if (splitPanel.getFirstComponent() instanceof ComponentContainer) {
                Bounds leftBounds = new Bounds(currentBounds.x, currentBounds.y, currentBounds.w,
                        firstBoundsHeight);
                updateBounds((ComponentContainer) splitPanel.getFirstComponent(), leftBounds);
            }

            if (splitPanel.getSecondComponent() instanceof ComponentContainer) {
                Bounds rightBounds = new Bounds(currentBounds.x, currentBounds.y + firstBoundsHeight,
                        (int) (currentBounds.w), currentBounds.h - firstBoundsHeight);
                updateBounds((ComponentContainer) splitPanel.getSecondComponent(), rightBounds);
            }
        }
    } else if (container instanceof ComponentContainer) {
        Iterator<Component> it = container.getComponentIterator();
        while (it.hasNext()) {
            Component c = it.next();
            if (c instanceof ComponentContainer) {
                updateBounds((ComponentContainer) c, currentBounds);
            }
        }
    }
}