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);
}
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();
}
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();
}
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;
}
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;
}
Aggregations