Search in sources :

Example 16 with CC

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

the class VclTestApp method createAlignTab.

private Component createAlignTab() {
    JPanel box = new JPanel();
    box.setFocusable(false);
    MigLayout boxLayout = new MigLayout("debug 1000, fill");
    box.setLayout(boxLayout);
    JPanel panel = new JPanel();
    MigLayout layout = new MigLayout("debug 1000, fill");
    panel.setLayout(layout);
    JLabel label = new JLabel("Label");
    CC cc = new CC();
    cc.alignX("right").alignY("50%");
    panel.add(label);
    layout.setComponentConstraints(label, cc);
    LC lc = new LC();
    // The size of an invisible component will be set to 0, 0 and the gaps will also be set to 0 around it.
    lc.hideMode(2);
    lc.debug(1000);
    AC rowConstr = new AC();
    AC colConstr = new AC();
    lc.fillX();
    lc.flowY();
    lc.gridGapY("0");
    layout.setLayoutConstraints(lc);
    layout.setRowConstraints(rowConstr);
    layout.setColumnConstraints(colConstr);
    box.add(panel, "height 100px, width 100px");
    layout.setComponentConstraints(label, cc);
    return box;
}
Also used : CC(net.miginfocom.layout.CC) AC(net.miginfocom.layout.AC) MigLayout(net.miginfocom.swing.MigLayout) LC(net.miginfocom.layout.LC)

Example 17 with CC

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

the class VclTestApp method createTableTab.

private Component createTableTab() {
    final JPanel box = new JPanel();
    box.setFocusable(false);
    MigLayout boxLayout = new MigLayout("fill");
    box.setLayout(boxLayout);
    final JScrollPane outerScrollPane = new JScrollPane();
    outerScrollPane.setViewportView(box);
    outerScrollPane.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            final Dimension minimumSize = box.getMinimumSize();
            final int width = Math.max(minimumSize.width, outerScrollPane.getViewport().getWidth());
            box.setPreferredSize(new Dimension(width, minimumSize.height));
        }
    });
    JPanel tablePanel = new JPanel();
    MigLayout tablePanellayout = new MigLayout("flowy, fill, insets 0", "", "[min!][fill]");
    tablePanel.setLayout(tablePanellayout);
    JPanel topPanel = new JPanel(new FlowLayout());
    topPanel.setVisible(true);
    tablePanel.add(topPanel);
    topPanel.add(new JButton("Button1"));
    topPanel.add(new JButton("Button2"));
    topPanel.add(new JButton("Button3"));
    topPanel.add(new JButton("Button4"));
    topPanel.add(new JButton("Button5"));
    JXTableExt table = new JXTableExt();
    JScrollPane tableScrollPane = new JScrollPane(table);
    // table.setFillsViewportHeight(true);
    tablePanel.add(tableScrollPane, "grow");
    table.setShowGrid(true);
    table.setGridColor(Color.lightGray);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setColumnControlVisible(true);
    table.setModel(new AbstractTableModel() {

        @Override
        public int getRowCount() {
            return 20;
        }

        @Override
        public int getColumnCount() {
            return 20;
        }

        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            return rowIndex + "-" + columnIndex;
        }
    });
    CC cc = new CC();
    // cc.growX(0);
    // cc.width("300!");
    cc.width("100%");
    // cc.growY(0.0f);
    cc.height("200!");
    // cc.height("100%");
    box.add(tablePanel);
    boxLayout.setComponentConstraints(tablePanel, cc);
    return outerScrollPane;
}
Also used : CC(net.miginfocom.layout.CC) MigLayout(net.miginfocom.swing.MigLayout) AbstractTableModel(javax.swing.table.AbstractTableModel) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 18 with CC

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

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