net.miginfocom.layout.CC Java Examples

The following examples show how to use net.miginfocom.layout.CC. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PredefinedVariablesDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
@Override
public void preShow() {
    setTitle(Localizer.get("title.AvailableVariables"));
    panel.setLayout(new MigLayout(new LC().gridGap("8pt", "4pt")));

    JLabel jlName = new JLabel(Localizer.get("label.Name"));
    JLabel jlExample = new JLabel(Localizer.get("label.Example"));
    panel.add(jlName, new CC().pushX().growX());
    panel.add(jlExample, new CC().pushX().growX().wrap());
    panel.add(new SeparatorComponent(10), new CC().pushX().growX().wrap().spanX());

    for (Map.Entry<String, String> entry : ptWrapper.getFakeProperties().entrySet()) {
        JTextField  key = new JTextField (entry.getKey());
        JTextField  value = new JTextField (entry.getValue());
        key.setEditable(false);
        value.setEditable(false);

        panel.add(key, new CC().pushX().growX());
        panel.add(value, new CC().pushX().growX().wrap());
    }

    pack();
}
 
Example #2
Source File: WriteRulesDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
@Override
public void preShow() {
    panel.setLayout(new MigLayout(new LC().gridGap("0", "8pt")));

    //Type
    ArrayList<WriteRules> actionTypes = new ArrayList<>();
    if(hasParent){
        actionTypes.add(WriteRules.FROM_PARENT);
    }
    actionTypes.add(WriteRules.USE_EXISTING);
    actionTypes.add(WriteRules.ASK_ME);
    actionTypes.add(WriteRules.OVERWRITE);

    comboBoxRules = new ComboBox(actionTypes.toArray());
    comboBoxRules.setRenderer(new WriteRulesCellRenderer());
    comboBoxRules.setSelectedItem(writeRules);

    panel.add(comboBoxRules, new CC().pushX().growX().spanX().gapY("10","10"));
}
 
Example #3
Source File: ReportDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
private void addFailed(final BaseReport report) {
    //Icon
    JBLabel iconLabel = new JBLabel(PluginIcons.REPORT_FAIL);
    iconLabel.setToolTipText(Localizer.get("tooltip.ReportFailed"));

    //Label
    JBLabel label = new JBLabel(report.getAction().toString(), report.toIcon(), SwingConstants.LEFT);

    // Button details
    JButton btnDetails = new JButton(Localizer.get("action.ShowDetails"), AllIcons.General.InspectionsEye);
    btnDetails.repaint();
    btnDetails.addMouseListener(new ClickListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            Messages.showMessageDialog(
                    report.getMessage(),
                    Localizer.get("title.ErrorDetails"),
                    Messages.getInformationIcon()
            );
        }
    });

    panel.add(iconLabel, new CC().spanX().split(3));
    panel.add(label, new CC());
    panel.add(btnDetails, new CC().wrap().pad(0, 0, 0, 0));
}
 
Example #4
Source File: LibraryDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
private void initBinaryFilesTab() {
    pTabBinaryFiles = new JPanel(new MigLayout(new LC()));

    // List
    createBinaryFileList();

    //Content (right panel)
    JPanel panelBinaryFilesContent = new JPanel(new MigLayout());
    btnBinaryFilePath = new TextFieldWithBrowseButton();
    btnBinaryFilePath.setText("");
    btnBinaryFilePath.addBrowseFolderListener(Localizer.get("library.ChooseBinaryFile"), "", project, FileReaderUtil.getBinaryFileDescriptor());

    tfBinaryFileAlias = new EditorTextField("ExampleAlias");

    panelBinaryFilesContent.add(tfBinaryFileAlias, new CC().wrap());
    panelBinaryFilesContent.add(btnBinaryFilePath, new CC().wrap().gapY("8pt", "0"));

    //Splitter
    JBSplitter splitter = new JBSplitter(0.3f);
    splitter.setFirstComponent(listBinaryFiles);
    splitter.setSecondComponent(panelBinaryFilesContent);

    pTabBinaryFiles.add(splitter, new CC().push().grow());
    tabbedPane.addTab("Tab1", pTabBinaryFiles);
}
 
Example #5
Source File: MigGridLayoutAdapter.java    From cuba with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #6
Source File: SelectPackageTemplateDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
private void buildFavouritesUI() {
    resetFavourites();
    createFavouriteRadioButtons();

    if (!listButtons.isEmpty()) {
        cbCompactNames = new JCheckBox(Localizer.get("label.CompactNames"), isCompactNames);
        cbCompactNames.addItemListener(e -> {
            isCompactNames = e.getStateChange() == ItemEvent.SELECTED;
            buildFavouritesUI();
        });

        favouritesPanel.add(new SeparatorComponent(), new CC().growX().spanX().wrap());
        favouritesPanel.add(new JBLabel(Localizer.get("label.Favourites")), new CC().growX().spanX().pushX().wrap().alignX("center"));
        favouritesPanel.add(cbCompactNames, new CC().spanX().wrap().gapY("0", "10pt"));

        for (JBRadioButton radioButton : listButtons) {
            favouritesPanel.add(radioButton, new CC().growX().spanX().wrap());
        }

        listButtons.get(0).doClick();
    } else {
        rbFromPath.doClick();
    }
}
 
Example #7
Source File: SelectPackageTemplateDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
private void makePathButton() {
        btnPath = new TextFieldWithBrowseButton();
        btnPath.setText(PackageTemplateHelper.getRootDirPath());
        btnPath.addBrowseFolderListener(Localizer.get("SelectPackageTemplate"), "", project, FileReaderUtil.getPackageTemplatesDescriptor());

//        panel.add(new SeparatorComponent(), new CC().growX().spanX().wrap());
        panel.add(btnPath, new CC().pushX().growX().spanX());
        addPathButtons();

        rbFromPath = new JBRadioButton(Localizer.get("label.FromPath"));
        rbFromPath.addItemListener(e -> {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                toggleSourcePath(
                        TemplateSourceType.PATH,
                        null,
                        btnPath
                );
            }
        });

        panel.add(rbFromPath, new CC().growX().spanX().wrap());
    }
 
Example #8
Source File: SelectPackageTemplateDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
private void makeToolBar() {
    actionGroup = new DefaultActionGroup();

    initToolbarActions();

    actionGroup.add(actionAdd);
    actionGroup.add(actionEdit);
    actionGroup.add(actionAddToFavourites);
    actionGroup.add(actionSettings);
    actionGroup.add(actionExport);
    actionGroup.add(actionImport);
    actionGroup.add(actionAutoImport);

    jpToolbar = new JPanel(new MigLayout());
    panel.add(jpToolbar, new CC().spanX());

    ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true);
    jpToolbar.add(toolbar.getComponent(), new CC().spanX());
}
 
Example #9
Source File: CustomPathDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
@Override
public void preShow() {
    panel.setLayout(new MigLayout(new LC().gridGap("0", "8pt")));

    actionsPanel = new JPanel(new MigLayout(new LC().fillX().insetsAll("0").gridGap("0", "0")));
    wrappers = new ArrayList<>();

    for (SearchAction searchAction : customPath.getListSearchAction()) {
        createSearchAction(searchAction);
    }

    btnAdd = getAddButton();
    btnRegexpHelper = getRegexpButton();

    panel.add(actionsPanel, new CC().pushX().grow().spanX().wrap());
    panel.add(btnAdd, new CC().spanX().split(2));
    panel.add(btnRegexpHelper, new CC().wrap());
}
 
Example #10
Source File: FileWrapper.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
private void createUsageUI(JPanel container, Project project) {
    if (getPackageTemplateWrapper().getMode() != PackageTemplateWrapper.ViewMode.USAGE) {
        return;
    }
    FileTemplate fileTemplate = FileTemplateHelper.getTemplate(
            getFile().getTemplateName(),
            project,
            getPackageTemplateWrapper().getPackageTemplate().getFileTemplateSource()
    );

    if (fileTemplate == null) {
        return;
    }

    panelVariables = new CreateFromTemplatePanel(
            AttributesHelper.getUnsetAttributes(fileTemplate, getPackageTemplateWrapper()),
            false,
            null
    );

    container.add(panelVariables.getComponent(), new CC().spanX().pad(0, UIHelper.PADDING, 0, 0).wrap());
}
 
Example #11
Source File: FileWrapper.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
@Override
public void buildView(Project project, JPanel container) {
    jlName = new JLabel(UIHelper.getIconByFileExtension(getFile().getExtension()), SwingConstants.LEFT);
    jlName.setDisabledIcon(jlName.getIcon());
    jlName.setText(getFile().getTemplateName());

    etfDescription = UIHelper.getEditorTextField(getFile().getName(), project);

    container.add(getOptionsPanel(), new CC().spanX().split(3));
    container.add(jlName, new CC().pad(0, 0, 0, UIHelper.PADDING_LABEL));
    container.add(etfDescription, new CC().wrap().pushX().growX());
    updateComponentsState();

    addMouseListener();

    createUsageUI(container, project);
}
 
Example #12
Source File: MigLayoutHelper.java    From cuba with Apache License 2.0 6 votes vote down vote up
public static void applyWidth(CC constraints, int width, SizeUnit widthUnits, boolean expand) {
    if (width == -1) { // own size
        constraints.growX(0);
    } else if (widthUnits == SizeUnit.PERCENTAGE) {
        constraints.width(width + "%");
    } else if (width != 0 && widthUnits == SizeUnit.PIXELS) {
        constraints.growX(0);
        constraints.width(width + "!");  // min, pref, max size as specified
    } else {
        if (expand) {
            constraints.growX();
            constraints.growPrioX(99); // lower grow priority
            constraints.width("100%"); // preferred size to full container
        } else {
            constraints.growX(0);
        }
    }
}
 
Example #13
Source File: MigLayoutHelper.java    From cuba with Apache License 2.0 6 votes vote down vote up
public static void applyHeight(CC constraints, int height, SizeUnit heightUnits, boolean expand) {
    if (height == -1) { // own size
        constraints.growY(0.0f);
    } else if (heightUnits == SizeUnit.PERCENTAGE) {
        constraints.height(height + "%");
    } else if (height != 0 && heightUnits == SizeUnit.PIXELS) {
        constraints.growY(0.0f);
        constraints.height(height + "!"); // min, pref, max size as specified
    } else {
        if (expand) {
            constraints.growY();
            constraints.growPrioY(99); // lower grow priority
            constraints.height("100%"); // preferred size to full container
        } else {
            constraints.growY(0.0f);
        }
    }
}
 
Example #14
Source File: MigBoxLayoutAdapter.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void expand(Component component, String height, String width) {
    super.expand(component, height, width);

    Object cc = layout.getComponentConstraints(component);
    if (cc instanceof CC) {
        if (direction == null || direction == BoxLayoutAdapter.FlowDirection.X
                && (StringUtils.isEmpty(height) || "-1px".equals(height) || height.endsWith("%"))) {
            MigLayoutHelper.applyWidth((CC) cc, 100, SizeUnit.PERCENTAGE, true);
        }
        if (direction == null || direction == BoxLayoutAdapter.FlowDirection.Y
                && (StringUtils.isEmpty(width) || "-1px".equals(width) || width.endsWith("%"))) {
            MigLayoutHelper.applyHeight((CC) cc, 100, SizeUnit.PERCENTAGE, true);
        }

    } else
        cc = MigLayoutHelper.getExpandConstraints(width, height, direction);
    layout.setComponentConstraints(component, cc);
}
 
Example #15
Source File: DesktopWindow.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void updateContainerConstraints() {
    CC cc = new CC();

    if (widthSize != null) {
        MigLayoutHelper.applyWidth(cc, (int) widthSize.value, widthSize.sizeUnit, true);
    } else {
        MigLayoutHelper.applyWidth(cc, 100, SizeUnit.PERCENTAGE, true);
    }

    if (heightSize != null) {
        MigLayoutHelper.applyHeight(cc, (int) heightSize.value, heightSize.sizeUnit, true);
    } else {
        MigLayoutHelper.applyHeight(cc, 100, SizeUnit.PERCENTAGE, true);
    }

    MigLayout migLayout = (MigLayout) panel.getLayout();
    migLayout.setComponentConstraints(container, cc);
}
 
Example #16
Source File: GlobalVariableWrapper.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
@NotNull
private JPanel createOptionsBlock() {
    JPanel optionsPanel = new JPanel(new MigLayout(new LC()));

    // Script
    jlScript = new IconLabel(
            Localizer.get("tooltip.ColoredWhenItemHasScript"),
            PluginIcons.SCRIPT,
            PluginIcons.SCRIPT_DISABLED
    );

    updateComponentsState();

    optionsPanel.add(jlScript, new CC().pad(0, 0, 0, 6));
    optionsPanel.add(jlVariable, new CC());
    return optionsPanel;
}
 
Example #17
Source File: VclTestApp.java    From cuba with Apache License 2.0 5 votes vote down vote up
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();
    lc.hideMode(2); // The size of an invisible component will be set to 0, 0 and the gaps will also be set to 0 around it.
    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;
}
 
Example #18
Source File: RegexpHelperDialog.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
@Override
public void preShow() {
    setTitle(Localizer.get("title.RegexpHelper"));
    panel.setLayout(new MigLayout(new LC().gridGap("0", "8pt")));

    JLabel jlPattern = new JLabel(Localizer.get("label.RegexpPattern"));

    tfPattern = new EditorTextField(".*My[\\w]+\\.html.*", project, RegExpFileType.INSTANCE);
    tfPattern.setOneLineMode(false);

    JLabel jlText = new JLabel(Localizer.get("label.Text"));
    tfText = new EditorTextField("Bla bla bla\nMyUniqueTextFragment.html\nBla bla bla");
    tfText.setOneLineMode(false);

    JPanel secondPanel = new JPanel(new MigLayout(new LC().insets("0").gridGap("0", "4pt")));
    secondPanel.add(jlText, new CC().wrap());
    secondPanel.add(tfText, new CC().wrap().push().grow());

    JBSplitter splitter = new JBSplitter(true, 0.35f);
    splitter.setFirstComponent(tfPattern);
    splitter.setSecondComponent(secondPanel);
    splitter.setShowDividerControls(true);
    splitter.setHonorComponentsMinimumSize(true);

    btnTry = new JButton(Localizer.get("TryIt"));
    btnTry.addMouseListener(new ClickListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            doMatch();
        }
    });
    jlResult = new JLabel(Localizer.get("ResultWillBeHere"));

    panel.add(jlPattern, new CC().wrap().spanX());
    panel.add(splitter, new CC().wrap().push().grow().spanX());
    panel.add(btnTry, new CC().spanX().split(2));
    panel.add(jlResult, new CC().wrap().pushX().growX());
}
 
Example #19
Source File: LibraryDialog.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
public void buildView() {
    setTitle(Localizer.get("title.LibraryDialog"));
    panel.setBackground(JBColor.BLUE);

    tabbedPane = new JBTabbedPane();
    panel.add(tabbedPane, new CC().push().grow());

    initBinaryFilesTab();
    initSecondTab();
}
 
Example #20
Source File: SpoilerPane.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
public void init() {
        setLayout(new MigLayout());
        this.setBackground(content.getBackground());

//        add(jbToggle, bag.nextLine().next().fillCellVertically());
        add(jbToggle, new CC().alignX("left"));
//        add(jlTitle, bag.next().fillCellVertically().anchor(GridBagConstraints.NORTHWEST));
        add(jlTitle, new CC().wrap().alignX("left"));
        setCollapsed(true);

        this.jbToggle.addActionListener(e -> setCollapsed(!isCollapsed));
    }
 
Example #21
Source File: DesktopGridLayout.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void reAddChild(Component child) {
    CC childCC = (CC) layoutAdapter.getConstraints(child);
    int col1 = childCC.getCellX();
    int row1 = childCC.getCellY();
    int spanX = childCC.getSpanX();
    int spanY = childCC.getSpanY();

    // readd component
    int col2 = spanX - 1 + col1;
    int row2 = spanY - 1 + row1;

    remove(child);
    add(child, col1, row1, col2, row2);
}
 
Example #22
Source File: MigGridLayoutAdapter.java    From cuba with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #23
Source File: DesktopFieldGroup.java    From cuba with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #24
Source File: MigGridLayoutAdapter.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Object getCaptionConstraints(com.haulmont.cuba.gui.components.Component component,
                                    int col, int row, int col2, int row2) {
    CC constraints = new CC();
    constraints.cell(col, row);
    constraints.split(2);
    constraints.flowY();
    constraints.width("min!");
    constraints.height("min!");
    MigLayoutHelper.applyAlignment(constraints, component.getAlignment());
    return constraints;
}
 
Example #25
Source File: DesktopAbstractTable.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void setWidth(String width) {
    super.setWidth(width);
    CC cc = new CC().grow();
    MigLayoutHelper.applyWidth(cc, (int) widthSize.value, widthSize.sizeUnit, false);
    layout.setComponentConstraints(scrollPane, cc);
}
 
Example #26
Source File: MigLayoutHelper.java    From cuba with Apache License 2.0 5 votes vote down vote up
public static CC getExpandConstraints(String width, String height, BoxLayoutAdapter.FlowDirection direction) {
    CC cc = new CC();

    if (direction == null || direction == BoxLayoutAdapter.FlowDirection.X
            && (StringUtils.isEmpty(height) || "-1px".equals(height) || height.endsWith("%"))) {
        applyWidth(cc, 100, SizeUnit.PERCENTAGE, true);
    }
    if (direction == null || direction == BoxLayoutAdapter.FlowDirection.Y
            && (StringUtils.isEmpty(width) || "-1px".equals(width) || width.endsWith("%"))) {
        applyHeight(cc, 100, SizeUnit.PERCENTAGE, true);
    }

    return cc;
}
 
Example #27
Source File: MigLayoutHelper.java    From cuba with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #28
Source File: MigLayoutHelper.java    From cuba with Apache License 2.0 5 votes vote down vote up
public static void applyAlignment(CC cc, Component.Alignment align) {
    if (align == null) {
        align = Component.Alignment.TOP_LEFT; // same as for web
    }

    switch (align) {
        case TOP_RIGHT:
            cc.alignX("right").alignY("top");
            break;
        case TOP_LEFT:
            cc.alignX("left").alignY("top");
            break;
        case TOP_CENTER:
            cc.alignX("50%").alignY("top");
            break;
        case MIDDLE_RIGHT:
            cc.alignX("right").alignY("50%");
            break;
        case MIDDLE_LEFT:
            cc.alignX("left").alignY("50%");
            break;
        case MIDDLE_CENTER:
            cc.alignX("50%").alignY("50%");
            break;
        case BOTTOM_RIGHT:
            cc.alignX("right").alignY("bottom");
            break;
        case BOTTOM_LEFT:
            cc.alignX("left").alignY("bottom");
            break;
        case BOTTOM_CENTER:
            cc.alignX("50%").alignY("bottom");
            break;
    }
}
 
Example #29
Source File: MigBoxLayoutAdapter.java    From cuba with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #30
Source File: DirectoryWrapper.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
@Override
public void buildView(Project project, JPanel container) {
    if (panel == null) {
        panel = new JPanel(new MigLayout(new LC().insets("0").gridGapY("2pt").fillX()));
    } else {
        panel.removeAll();
    }

    jlName = new JLabel(AllIcons.Nodes.Package, SwingConstants.LEFT);
    jlName.setDisabledIcon(jlName.getIcon());
    jlName.setText(Localizer.get("Directory"));

    etfDescription = UIHelper.getEditorTextField(getDirectory().getName(), project);
    addMouseListener();

    container.add(getOptionsPanel(), new CC().spanX().split(3));
    container.add(jlName, new CC().pad(0, 0, 0, UIHelper.PADDING_LABEL));
    container.add(etfDescription, new CC().growX().pushX().wrap());

    updateComponentsState();

    //Children
    if (!getListElementWrapper().isEmpty()) {
        for (ElementWrapper elementWrapper : getListElementWrapper()) {
            elementWrapper.buildView(project, panel);
        }

        UIHelper.setLeftPadding(panel, UIHelper.PADDING + UIHelper.DEFAULT_PADDING);
        container.add(panel, new CC().spanX().growX().pushX().wrap());
    }
}