Search in sources :

Example 11 with CC

use of net.miginfocom.layout.CC in project cuba by cuba-platform.

the class DesktopAbstractTable method setWidth.

@Override
public void setWidth(String width) {
    super.setWidth(width);
    CC cc = new CC().grow();
    MigLayoutHelper.applyWidth(cc, (int) widthSize.value, widthSize.unit, false);
    layout.setComponentConstraints(scrollPane, cc);
}
Also used : CC(net.miginfocom.layout.CC)

Example 12 with CC

use of net.miginfocom.layout.CC in project cuba by cuba-platform.

the class DesktopFieldGroup method reattachColumnFields.

protected void reattachColumnFields(int colIndex) {
    fields.values().stream().filter(FieldConfig::isBound).map(fieldConfig -> ((FieldConfigImpl) fieldConfig)).filter(fci -> fci.getColumn() == colIndex).forEach(fci -> {
        impl.remove(fci.getCompositionNN().getComposition());
        if (fci.getLabel() != null) {
            impl.remove(fci.getLabel());
        }
        if (fci.getToolTipButton() != null) {
            impl.remove(fci.getToolTipButton());
        }
    });
    List<FieldConfig> columnFCs = columnFieldMapping.get(colIndex);
    int insertRowIndex = 0;
    for (FieldConfig fc : columnFCs) {
        if (fc.isBound()) {
            FieldConfigImpl fci = (FieldConfigImpl) fc;
            Component fieldComponent = fci.getComponentNN();
            JComponent composition = fieldComponent.unwrapComposition(JComponent.class);
            JLabel label = fci.getLabel();
            if (label != null) {
                int preferredCaptionWidth = getPreferredCaptionWidth(colIndex);
                if (preferredCaptionWidth > 0) {
                    label.setPreferredSize(new Dimension(preferredCaptionWidth, 25));
                    label.setMaximumSize(new Dimension(preferredCaptionWidth, 25));
                    label.setMinimumSize(new Dimension(preferredCaptionWidth, 25));
                } else {
                    label.setPreferredSize(new Dimension(label.getPreferredSize().width, 25));
                }
                label.setVisible(fieldComponent.isVisible());
                CC labelCc = new CC();
                MigLayoutHelper.applyAlignment(labelCc, Alignment.TOP_LEFT);
                impl.add(label, labelCc.cell(colIndex * 3, insertRowIndex, 1, 1));
            }
            ToolTipButton toolTipButton = fci.getToolTipButton();
            if (fci.getToolTipButton() != null) {
                updateTooltipButton(fci, fieldComponent);
                DesktopToolTipManager.getInstance().registerTooltip(toolTipButton);
                impl.add(toolTipButton, new CC().cell(colIndex * 3 + 2, insertRowIndex, 1, 1).alignY("top"));
            }
            CC cell = new CC().cell(colIndex * 3 + 1, insertRowIndex, 1, 1);
            MigLayoutHelper.applyWidth(cell, (int) fieldComponent.getWidth(), fieldComponent.getWidthUnits(), false);
            MigLayoutHelper.applyHeight(cell, (int) fieldComponent.getHeight(), fieldComponent.getHeightUnits(), false);
            MigLayoutHelper.applyAlignment(cell, fieldComponent.getAlignment());
            composition.putClientProperty(getSwingPropertyId(), fci.getId());
            impl.add(composition, cell);
            insertRowIndex++;
        }
    }
    impl.validate();
    impl.repaint();
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) Datasource(com.haulmont.cuba.gui.data.Datasource) ActionListener(java.awt.event.ActionListener) UiPermissionValue(com.haulmont.cuba.gui.app.security.role.edit.UiPermissionValue) LoggerFactory(org.slf4j.LoggerFactory) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) AppBeans(com.haulmont.cuba.core.global.AppBeans) ToolTipButton(com.haulmont.cuba.desktop.sys.vcl.ToolTipButton) BooleanUtils(org.apache.commons.lang.BooleanUtils) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) CC(net.miginfocom.layout.CC) Preconditions.checkNotNullArgument(com.haulmont.bali.util.Preconditions.checkNotNullArgument) Component(com.haulmont.cuba.gui.components.Component) UiPermissionDescriptor(com.haulmont.cuba.gui.app.security.role.edit.UiPermissionDescriptor) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) Nullable(javax.annotation.Nullable) App(com.haulmont.cuba.desktop.App) DesktopToolTipManager(com.haulmont.cuba.desktop.sys.DesktopToolTipManager) Logger(org.slf4j.Logger) Formatter(com.haulmont.cuba.gui.components.Formatter) MigLayout(net.miginfocom.swing.MigLayout) Collectors(java.util.stream.Collectors) Preconditions.checkState(com.google.common.base.Preconditions.checkState) java.awt(java.awt) Consumer(java.util.function.Consumer) CollapsiblePanel(com.haulmont.cuba.desktop.sys.vcl.CollapsiblePanel) List(java.util.List) LC(net.miginfocom.layout.LC) ComponentsHelper(com.haulmont.cuba.gui.ComponentsHelper) Element(org.dom4j.Element) MigLayoutHelper(com.haulmont.cuba.desktop.sys.layout.MigLayoutHelper) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) LayoutAdapter(com.haulmont.cuba.desktop.sys.layout.LayoutAdapter) javax.swing(javax.swing) CC(net.miginfocom.layout.CC) Component(com.haulmont.cuba.gui.components.Component) ToolTipButton(com.haulmont.cuba.desktop.sys.vcl.ToolTipButton)

Example 13 with CC

use of net.miginfocom.layout.CC 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 14 with CC

use of net.miginfocom.layout.CC in project cuba by cuba-platform.

the class MigGridLayoutAdapter method getConstraints.

@Override
public CC getConstraints(com.haulmont.cuba.gui.components.Component component) {
    CC defaultContraints = MigLayoutHelper.getConstraints(component);
    Component composition = DesktopComponentsHelper.getComposition(component);
    Component layoutChild = composition;
    Container parent = composition.getParent();
    if (parent instanceof LayoutSlot) {
        parent = parent.getParent();
        layoutChild = composition.getParent();
    }
    if (parent == container) {
        // fill up span x span y
        if (layout.getComponentConstraints(layoutChild) instanceof CC) {
            CC componentConstraints = (CC) layout.getComponentConstraints(layoutChild);
            defaultContraints.setCellX(componentConstraints.getCellX());
            defaultContraints.setCellY(componentConstraints.getCellY());
            defaultContraints.setSpanX(componentConstraints.getSpanX());
            defaultContraints.setSpanY(componentConstraints.getSpanY());
        }
    }
    return defaultContraints;
}
Also used : CC(net.miginfocom.layout.CC) LayoutSlot(com.haulmont.cuba.desktop.gui.components.LayoutSlot)

Example 15 with CC

use of net.miginfocom.layout.CC in project cuba by cuba-platform.

the class MigGridLayoutAdapter method getConstraints.

@Override
public CC getConstraints(com.haulmont.cuba.gui.components.Component component, int col, int row, int col2, int row2) {
    int spanX = col2 - col + 1;
    int spanY = row2 - row + 1;
    CC constraints = MigLayoutHelper.getConstraints(component);
    constraints.cell(col, row, spanX, spanY);
    return constraints;
}
Also used : CC(net.miginfocom.layout.CC)

Aggregations

CC (net.miginfocom.layout.CC)18 BoxLayoutAdapter (com.haulmont.cuba.desktop.sys.layout.BoxLayoutAdapter)6 Component (com.haulmont.cuba.gui.components.Component)3 MigLayout (net.miginfocom.swing.MigLayout)3 LC (net.miginfocom.layout.LC)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Preconditions.checkNotNullArgument (com.haulmont.bali.util.Preconditions.checkNotNullArgument)1 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 AppBeans (com.haulmont.cuba.core.global.AppBeans)1 App (com.haulmont.cuba.desktop.App)1 AutoExpanding (com.haulmont.cuba.desktop.gui.components.AutoExpanding)1 LayoutSlot (com.haulmont.cuba.desktop.gui.components.LayoutSlot)1 DesktopToolTipManager (com.haulmont.cuba.desktop.sys.DesktopToolTipManager)1 LayoutAdapter (com.haulmont.cuba.desktop.sys.layout.LayoutAdapter)1 MigLayoutHelper (com.haulmont.cuba.desktop.sys.layout.MigLayoutHelper)1 CollapsiblePanel (com.haulmont.cuba.desktop.sys.vcl.CollapsiblePanel)1 ToolTipButton (com.haulmont.cuba.desktop.sys.vcl.ToolTipButton)1 ComponentsHelper (com.haulmont.cuba.gui.ComponentsHelper)1 UiPermissionDescriptor (com.haulmont.cuba.gui.app.security.role.edit.UiPermissionDescriptor)1