Search in sources :

Example 6 with BoxLayoutAdapter

use of com.haulmont.cuba.desktop.sys.layout.BoxLayoutAdapter in project cuba by cuba-platform.

the class DesktopGridLayout method updateComponent.

@Override
public void updateComponent(Component child) {
    boolean componentReAdded = false;
    if (DesktopContainerHelper.mayHaveExternalCaption(child) || DesktopContainerHelper.mayHaveExternalContextHelp(child)) {
        if (captions.containsKey(child) && !DesktopContainerHelper.hasExternalCaption(child) && !DesktopContainerHelper.hasExternalContextHelp(child)) {
            reAddChild(child);
            componentReAdded = true;
        } else if (!captions.containsKey(child) && (DesktopContainerHelper.hasExternalCaption(child) || DesktopContainerHelper.hasExternalContextHelp(child))) {
            reAddChild(child);
            componentReAdded = true;
        } else if (captions.containsKey(child)) {
            ComponentCaption caption = captions.get(child);
            caption.update();
            if (!wrappers.containsKey(child)) {
                CC c = (CC) layoutAdapter.getConstraints(child);
                layoutAdapter.updateConstraints(caption, layoutAdapter.getCaptionConstraints(child, c.getCellX(), c.getCellY(), c.getCellX(), c.getCellY()));
            }
        }
    }
    if (!componentReAdded) {
        JComponent composition;
        if (wrappers.containsKey(child)) {
            composition = wrappers.get(child).getFirst();
            CC constraints = MigLayoutHelper.getConstraints(child);
            if (child.getHeight() == -1.0) {
                MigLayoutHelper.applyHeight(constraints, -1, UNITS_PIXELS, false);
            } else {
                MigLayoutHelper.applyHeight(constraints, 100, UNITS_PERCENTAGE, false);
            }
            if (child.getWidth() == -1.0) {
                MigLayoutHelper.applyWidth(constraints, -1, UNITS_PIXELS, false);
            } else {
                MigLayoutHelper.applyWidth(constraints, 100, UNITS_PERCENTAGE, false);
            }
            BoxLayoutAdapter adapter = wrappers.get(child).getSecond();
            adapter.updateConstraints(DesktopComponentsHelper.getComposition(child), constraints);
        } else {
            composition = DesktopComponentsHelper.getComposition(child);
        }
        layoutAdapter.updateConstraints(composition, layoutAdapter.getConstraints(child));
    }
    requestRepaint();
    requestContainerUpdate();
}
Also used : CC(net.miginfocom.layout.CC) BoxLayoutAdapter(com.haulmont.cuba.desktop.sys.layout.BoxLayoutAdapter)

Example 7 with BoxLayoutAdapter

use of com.haulmont.cuba.desktop.sys.layout.BoxLayoutAdapter in project cuba by cuba-platform.

the class DesktopAbstractBox method updateComponentInternal.

protected void updateComponentInternal(Component child) {
    boolean componentReAdded = false;
    if (DesktopContainerHelper.mayHaveExternalCaption(child) || DesktopContainerHelper.mayHaveExternalContextHelp(child)) {
        if (captions.containsKey(child) && !DesktopContainerHelper.hasExternalCaption(child) && !DesktopContainerHelper.hasExternalContextHelp(child)) {
            reAddChild(child);
            componentReAdded = true;
        } else if (!captions.containsKey(child) && (DesktopContainerHelper.hasExternalCaption(child) || DesktopContainerHelper.hasExternalContextHelp(child))) {
            reAddChild(child);
            componentReAdded = true;
        } else if (captions.containsKey(child)) {
            ComponentCaption caption = captions.get(child);
            caption.update();
            BoxLayoutAdapter adapterForCaption = layoutAdapter;
            if (wrappers.containsKey(child)) {
                adapterForCaption = wrappers.get(child).getSecond();
            }
            adapterForCaption.updateConstraints(caption, adapterForCaption.getCaptionConstraints(child));
        }
    }
    if (!componentReAdded) {
        JComponent composition;
        if (wrappers.containsKey(child)) {
            composition = wrappers.get(child).getFirst();
            CC constraints = MigLayoutHelper.getConstraints(child);
            if (child.getHeight() == -1.0) {
                MigLayoutHelper.applyHeight(constraints, -1, UNITS_PIXELS, false);
            } else {
                MigLayoutHelper.applyHeight(constraints, 100, UNITS_PERCENTAGE, false);
            }
            if (child.getWidth() == -1.0) {
                MigLayoutHelper.applyWidth(constraints, -1, UNITS_PIXELS, false);
            } else {
                MigLayoutHelper.applyWidth(constraints, 100, UNITS_PERCENTAGE, false);
            }
            BoxLayoutAdapter adapter = wrappers.get(child).getSecond();
            adapter.updateConstraints(DesktopComponentsHelper.getComposition(child), constraints);
        } else {
            composition = DesktopComponentsHelper.getComposition(child);
        }
        layoutAdapter.updateConstraints(composition, layoutAdapter.getConstraints(child));
    }
}
Also used : CC(net.miginfocom.layout.CC) BoxLayoutAdapter(com.haulmont.cuba.desktop.sys.layout.BoxLayoutAdapter)

Aggregations

BoxLayoutAdapter (com.haulmont.cuba.desktop.sys.layout.BoxLayoutAdapter)7 CC (net.miginfocom.layout.CC)6 Component (com.haulmont.cuba.gui.components.Component)2 MigBoxLayoutAdapter (com.haulmont.cuba.desktop.sys.layout.MigBoxLayoutAdapter)1 JTextComponent (javax.swing.text.JTextComponent)1