Search in sources :

Example 1 with CC

use of net.miginfocom.layout.CC in project Terasology by MovingBlocks.

the class MigLayout method addWidget.

@Override
public void addWidget(UIWidget element, CCHint hint) {
    final ComponentWrapper cw = getWrapper(element);
    final String cStr = ConstraintParser.prepare(hint != null ? hint.cc : "");
    CC constraint = AccessController.doPrivileged((PrivilegedAction<CC>) () -> ConstraintParser.parseComponentConstraint(cStr));
    ccMap.put(cw, constraint);
    wrappers.put(element, cw);
    children.add(cw);
    dirty = true;
}
Also used : CC(net.miginfocom.layout.CC) ComponentWrapper(net.miginfocom.layout.ComponentWrapper)

Example 2 with CC

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

the class DesktopFieldGroup method getCellComponent.

public DesktopAbstractComponent getCellComponent(int colIndex, int rowIndex) {
    if (colIndex < 0 || colIndex >= getColumns()) {
        throw new IllegalArgumentException(String.format("Illegal column number %s, available amount of columns is %s", colIndex, getColumns()));
    }
    List<FieldConfig> colFields = columnFieldMapping.get(colIndex);
    if (rowIndex < 0 || rowIndex > colFields.size()) {
        throw new IllegalArgumentException(String.format("Illegal column number %s, available amount of columns is %s", colIndex, getColumns()));
    }
    for (FieldConfig fieldConfig : fields.values()) {
        DesktopAbstractComponent composition = ((FieldConfigImpl) fieldConfig).getComposition();
        if (composition != null) {
            JComponent jComponent = composition.getComposition();
            Object componentConstraints = layout.getComponentConstraints(jComponent);
            if (componentConstraints instanceof CC) {
                CC cc = (CC) componentConstraints;
                if (cc.getCellY() == rowIndex) {
                    int ccColIndex = (cc.getCellX() - 1) / 3;
                    if (colIndex == ccColIndex) {
                        return composition;
                    }
                }
            }
        }
    }
    return null;
}
Also used : CC(net.miginfocom.layout.CC)

Example 3 with CC

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

the class DesktopAbstractBox method add.

@Override
public void add(Component component, int index) {
    if (component.getParent() != null && component.getParent() != this) {
        throw new IllegalStateException("Component already has parent");
    }
    if (ownComponents.contains(component)) {
        int existingIndex = new ArrayList<>(ownComponents).indexOf(component);
        if (index > existingIndex) {
            index--;
        }
        remove(component);
    }
    JComponent composition = DesktopComponentsHelper.getComposition(component);
    boolean hasExternalCaption = DesktopContainerHelper.hasExternalCaption(component);
    if (hasExternalCaption || DesktopContainerHelper.hasExternalContextHelp(component)) {
        ComponentCaption caption = new ComponentCaption(component);
        captions.put(component, caption);
        JPanel wrapper = new LayoutSlot();
        BoxLayoutAdapter adapter = BoxLayoutAdapter.create(wrapper);
        adapter.setExpandLayout(true);
        adapter.setSpacing(false);
        adapter.setMargin(false);
        wrapper.add(composition);
        if (hasExternalCaption) {
            adapter.setFlowDirection(BoxLayoutAdapter.FlowDirection.Y);
            wrapper.add(caption, 0);
        } else {
            wrapper.add(caption, new CC().alignY("top"));
        }
        impl.add(wrapper, layoutAdapter.getConstraints(component), index);
        wrappers.put(component, new Pair<>(wrapper, adapter));
    } else {
        impl.add(composition, layoutAdapter.getConstraints(component), index);
    }
    if (component.getId() != null) {
        componentByIds.put(component.getId(), component);
    }
    if (frame != null) {
        if (component instanceof BelongToFrame && ((BelongToFrame) component).getFrame() == null) {
            ((BelongToFrame) component).setFrame(frame);
        } else {
            attachToFrame(component);
        }
    }
    if (index == ownComponents.size()) {
        ownComponents.add(component);
    } else {
        List<Component> componentsTempList = new ArrayList<>(ownComponents);
        componentsTempList.add(index, component);
        ownComponents.clear();
        ownComponents.addAll(componentsTempList);
    }
    DesktopContainerHelper.assignContainer(component, this);
    if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
        ((DesktopAbstractComponent) component).setParentEnabled(false);
    }
    component.setParent(this);
    requestContainerUpdate();
    requestRepaint();
}
Also used : CC(net.miginfocom.layout.CC) BoxLayoutAdapter(com.haulmont.cuba.desktop.sys.layout.BoxLayoutAdapter) Component(com.haulmont.cuba.gui.components.Component)

Example 4 with CC

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

the class MigBoxLayoutAdapter method getCaptionConstraints.

@Override
public Object getCaptionConstraints(com.haulmont.cuba.gui.components.Component component) {
    CC cc = new CC();
    cc.split(2);
    cc.width("min!");
    cc.height("min!");
    MigLayoutHelper.applyAlignment(cc, component.getAlignment());
    return cc;
}
Also used : CC(net.miginfocom.layout.CC)

Example 5 with CC

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

the class MigLayoutHelper method getConstraints.

public static CC getConstraints(Component component) {
    boolean expandX = false;
    boolean expandY = false;
    // for latter comparing with AutoExpanding
    if (component instanceof AbstractFrame) {
        component = (Component) ((AbstractFrame) component).getComponent();
    }
    if (component instanceof AutoExpanding) {
        expandX = ((AutoExpanding) component).expandsWidth();
        expandY = ((AutoExpanding) component).expandsHeight();
    }
    int width = (int) component.getWidth();
    SizeUnit widthUnits = component.getWidthSizeUnit();
    int height = (int) component.getHeight();
    SizeUnit heightUnits = component.getHeightSizeUnit();
    CC cc = new CC();
    applyWidth(cc, width, widthUnits, expandX);
    applyHeight(cc, height, heightUnits, expandY);
    applyAlignment(cc, component.getAlignment());
    return cc;
}
Also used : CC(net.miginfocom.layout.CC) AutoExpanding(com.haulmont.cuba.desktop.gui.components.AutoExpanding) SizeUnit(com.haulmont.cuba.gui.components.SizeUnit) AbstractFrame(com.haulmont.cuba.gui.components.AbstractFrame)

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