Search in sources :

Example 1 with IContainer

use of org.jowidgets.api.widgets.IContainer in project jo-client-platform by jo-source.

the class BeanLinkPanelImpl method createForms.

private void createForms(final IContainer container, final IBeanFormBluePrint<LINK_BEAN_TYPE> linkFormBp, final IBeanFormBluePrint<LINKABLE_BEAN_TYPE> linkableFormBp) {
    if (linkFormBp != null && linkableFormBp != null) {
        final boolean scrolledContent = linkFormBp.getScrollbarsAllowed() && linkableFormBp.getScrollbarsAllowed();
        final IContainer content;
        if (scrolledContent) {
            container.setLayout(MigLayoutFactory.growingInnerCellLayout());
            content = container.add(BPF.scrollComposite(), MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
        } else {
            content = container;
        }
        content.setLayout(new MigLayoutDescriptor("0[grow, 0::]0", "0[]0[]0[]0"));
        final IBeanFormBluePrint<LINK_BEAN_TYPE> modifiedLinkFormBp = createModifiedFormBp(linkFormBp);
        if (scrolledContent) {
            modifiedLinkFormBp.setScrollbarsAllowed(false);
        }
        this.linkForm = content.add(modifiedLinkFormBp, "growx, w 0::, wrap");
        content.add(BPF.separator(), "growx, w 0::, wrap");
        final IBeanFormBluePrint<LINKABLE_BEAN_TYPE> modifiedLinkableFormBp = createModifiedFormBp(linkableFormBp);
        if (scrolledContent) {
            modifiedLinkableFormBp.setScrollbarsAllowed(false);
        }
        this.linkableForm = content.add(modifiedLinkableFormBp, "growx, w 0::");
    } else {
        container.setLayout(new MigLayoutDescriptor("0[grow, 0::]0", "0[grow, 0::]0"));
        if (linkFormBp != null) {
            this.linkForm = container.add(createModifiedFormBp(linkFormBp), "growx, w 0::, growy, h 0::");
        }
        if (linkableFormBp != null) {
            this.linkableForm = container.add(createModifiedFormBp(linkableFormBp), "growx, w 0::, growy, h 0::");
        }
    }
}
Also used : IContainer(org.jowidgets.api.widgets.IContainer) MigLayoutDescriptor(org.jowidgets.common.widgets.layout.MigLayoutDescriptor)

Example 2 with IContainer

use of org.jowidgets.api.widgets.IContainer in project jo-client-platform by jo-source.

the class BeanFormContentLayouter method layout.

@Override
public void layout(final IContainer container, final IBeanFormControlFactory controlFactory) {
    final Collection<ICustomWidgetCreator<? extends IControl>> buttons = controlFactory.createButtons();
    if (!buttons.isEmpty()) {
        container.setLayout(new MigLayoutDescriptor("0[grow, 0::]0", "0[0::]15[]0"));
        // add the form
        final IContainer formContainer = container.add(BPF.composite(), "growx, w 0::, wrap");
        layoutForm(formContainer, controlFactory);
        // add the button bar
        final IComposite buttonBar = container.add(BPF.composite(), "alignx r");
        buttonBar.setLayout(getButtonBarLayout(buttons));
        for (final ICustomWidgetCreator<? extends IControl> button : buttons) {
            buttonBar.add(button, "sg bg");
        }
    } else {
        layoutForm(container, controlFactory);
    }
}
Also used : IControl(org.jowidgets.api.widgets.IControl) ICustomWidgetCreator(org.jowidgets.common.widgets.factory.ICustomWidgetCreator) IComposite(org.jowidgets.api.widgets.IComposite) IContainer(org.jowidgets.api.widgets.IContainer) MigLayoutDescriptor(org.jowidgets.common.widgets.layout.MigLayoutDescriptor)

Example 3 with IContainer

use of org.jowidgets.api.widgets.IContainer in project jo-client-platform by jo-source.

the class BeanFormContentLayouter method layoutForm.

private void layoutForm(final IContainer formContainer, final IBeanFormControlFactory controlFactory) {
    formContainer.setLayout(Toolkit.getLayoutFactoryProvider().cachedFillLayout());
    final IComposite content = formContainer.add(BPF.composite());
    content.setLayout(new MigLayoutDescriptor(getColumnsConstraints(layout), ""));
    final List<boolean[]> globalGrid = new ArrayList<boolean[]>();
    int row = 0;
    final boolean showSeparators = layout.getGroups().size() > 1;
    for (final IBeanFormGroup group : layout.getGroups()) {
        final String label = group.getLabel();
        final BeanFormGroupRendering rendering = group.getRendering();
        row = getNextFreeRow(globalGrid);
        final List<boolean[]> grid;
        final IContainer container;
        if (BeanFormGroupRendering.NONE.equals(rendering)) {
            grid = globalGrid;
            container = content;
        } else if (BeanFormGroupRendering.SEPARATOR.equals(rendering)) {
            final String baseConstraints = "growx, cell 0 " + row + " " + (3 * layout.getColumnCount()) + " 1";
            setUsed(globalGrid, row, 0, 1, layout.getColumnCount());
            if (label != null && !"".equals(label)) {
                final String gapTop = (row > 0) ? "gaptop 27" : "";
                final String gapBottom = "gapbottom 7";
                final String cell = constraints(baseConstraints, gapTop, gapBottom);
                content.add(Toolkit.getBluePrintFactory().textSeparator(label), cell);
            } else if (row > 0 && showSeparators) {
                final String cell = constraints(baseConstraints, "gaptop 17, gapbottom 17");
                content.add(Toolkit.getBluePrintFactory().separator(), cell);
            }
            grid = globalGrid;
            container = content;
        } else if (BeanFormGroupRendering.BORDER.equals(rendering)) {
            final String cell = "growx, cell 0 " + row + " " + (3 * layout.getColumnCount()) + " 1";
            setUsed(globalGrid, row, 0, 1, layout.getColumnCount());
            if (label != null && !"".equals(label)) {
                container = content.add(Toolkit.getBluePrintFactory().composite(label), cell);
            } else {
                container = content.add(Toolkit.getBluePrintFactory().compositeWithBorder(), cell);
            }
            container.setLayout(new MigLayoutDescriptor(getColumnsConstraints(layout), ""));
            grid = new ArrayList<boolean[]>();
        } else {
            throw new IllegalStateException("Unkown BeanFormGroupRendering '" + rendering + "'.");
        }
        // reset column index
        int logicalColumn = 0;
        row = getNextFreeRow(grid);
        int currentRowHeight = 1;
        for (final IBeanFormProperty property : group.getProperties()) {
            final String propertyName = property.getPropertyName();
            final ICustomWidgetCreator<? extends IControl> controlCreator = controlFactory.createControl(propertyName);
            // only add to the layout if there is a control for this property
            if (controlCreator == null) {
                continue;
            }
            final int propertyColumnCount = property.getColumnCount();
            final int propertyColumnSpan = property.getColumnSpan();
            final int propertyRowCount = property.getRowCount();
            final int propertyRowSpan = property.getRowSpan();
            final Position nextGridPosition = getNextGridPosition(grid, row, logicalColumn, propertyColumnCount);
            logicalColumn = nextGridPosition.getX();
            row = nextGridPosition.getY();
            setUsed(grid, row, logicalColumn, propertyRowCount, propertyColumnCount);
            currentRowHeight = Math.max(currentRowHeight, propertyRowCount);
            final String sizeGroupLabel = "sg lbl" + logicalColumn;
            final String sizeGroupControl = "sgy r" + row + "ctrlspn" + propertyRowSpan;
            final ICustomWidgetCreator<? extends IControl> validationLabelCreator = controlFactory.createPropertyValidationLabel(propertyName);
            final int firstPropertyColumn = (3 * logicalColumn);
            // add label
            // CHECKSTYLE:OFF
            // FinalLocalVariable check seems to be broken in some cases
            String cell;
            // CHECKSTYLE:ON
            if (property.showLabel()) {
                final AlignmentVertical labelAlignmentVertical = property.getLabelAlignmentVertical();
                if (AlignmentVertical.TOP.equals(labelAlignmentVertical)) {
                    cell = "aligny top, cell " + firstPropertyColumn + " " + row;
                } else if (AlignmentVertical.CENTER.equals(labelAlignmentVertical)) {
                    cell = "aligny center, cell " + firstPropertyColumn + " " + row + " 1 " + propertyRowSpan;
                } else if (AlignmentVertical.BOTTOM.equals(labelAlignmentVertical)) {
                    cell = "aligny bottom, cell " + firstPropertyColumn + " " + (row + propertyRowSpan - 1);
                } else {
                    throw new IllegalStateException("Unknown vertical alignment '" + labelAlignmentVertical + "'.");
                }
                final ICustomWidgetCreator<? extends IControl> labelCreator;
                labelCreator = controlFactory.createLabel(propertyName, property.getLabelAlignmentHorizontal());
                container.add(labelCreator, constraints(cell, sizeGroupLabel));
                cell = "cell " + (firstPropertyColumn + 1) + " " + row + " " + (3 * propertyColumnSpan - 2) + " " + propertyRowSpan;
            } else {
                cell = "cell " + firstPropertyColumn + " " + row + " " + (3 * propertyColumnSpan - 1) + " " + propertyRowSpan;
            }
            container.add(controlCreator, constraints(cell, sizeGroupControl, getControlWidthConstraints(layout, logicalColumn), getHeightConstraints(property.getHeight()), "growx", "growy"));
            // add validation label
            if (validationLabelCreator != null) {
                final int validationLabelMinWidth = property.getValidationLabelMinWidth();
                container.add(validationLabelCreator, "w " + validationLabelMinWidth);
                validationLabelGap = Math.max(validationLabelGap, validationLabelMinWidth);
            }
            logicalColumn = logicalColumn + propertyColumnCount;
        }
    }
}
Also used : AlignmentVertical(org.jowidgets.common.types.AlignmentVertical) Position(org.jowidgets.common.types.Position) ArrayList(java.util.ArrayList) IComposite(org.jowidgets.api.widgets.IComposite) BeanFormGroupRendering(org.jowidgets.cap.ui.api.form.BeanFormGroupRendering) MigLayoutDescriptor(org.jowidgets.common.widgets.layout.MigLayoutDescriptor) IBeanFormGroup(org.jowidgets.cap.ui.api.form.IBeanFormGroup) IContainer(org.jowidgets.api.widgets.IContainer) IBeanFormProperty(org.jowidgets.cap.ui.api.form.IBeanFormProperty)

Example 4 with IContainer

use of org.jowidgets.api.widgets.IContainer in project jo-client-platform by jo-source.

the class BeanFormLayouterImpl method layout.

@Override
public void layout(final IContainer parent, final IBeanFormControlFactory controlFactory) {
    final IBeanFormInfo beanFormInfo = controlFactory.getBeanFormInfo();
    final IContainer container;
    if (controlFactory.getScrollbarsAllowed() && beanFormInfo != null) {
        parent.setLayout(MigLayoutFactory.growingInnerCellLayout());
        container = parent.add(BPF.scrollComposite(), MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
    } else {
        container = parent;
    }
    final String colConstraints = insets.getLeft() + "[grow, 0::]" + insets.getRight();
    final String rowConstraints;
    if (beanFormInfo != null) {
        rowConstraints = insets.getTop() + "[][grow, 0::]" + insets.getBottom();
    } else {
        rowConstraints = insets.getTop() + "[grow, 0::]" + insets.getBottom();
    }
    container.setLayout(new MigLayoutDescriptor(colConstraints, rowConstraints));
    if (beanFormInfo != null) {
        final IExpandCompositeBluePrint expandCompositeBp = expandCompositeBp();
        expandCompositeBp.setExpanded(beanFormInfo.isExpanded());
        expandCompositeBp.setText(beanFormInfo.getHeader().get());
        expandCompositeBp.setIcon(beanFormInfo.getHeaderIcon());
        final IExpandComposite expandComposite = container.add(expandCompositeBp, "growx, w 0::, wrap");
        final String cc = contentInsets.getLeft() + "[grow, 0::]" + contentInsets.getRight();
        final String rc = contentInsets.getTop() + "[]" + contentInsets.getBottom();
        expandComposite.setLayout(new MigLayoutDescriptor(cc, rc));
        final ITextLabelBluePrint labelBp = BPF.textLabel(beanFormInfo.getText().get());
        labelBp.setForegroundColor(contentTextColor).setMarkup(contentTextMarkup);
        expandComposite.add(labelBp, "growx, w 0::");
        expandComposite.addExpandListener(new IExpandListener() {

            @Override
            public void expandedChanged(final boolean expanded) {
                getRootContainer(parent).layout();
            }
        });
    }
    final boolean contentScrollbar = beanFormInfo == null && controlFactory.getScrollbarsAllowed();
    final IContainer contentContainer = createAndAddContentContainer(container, controlFactory, contentScrollbar);
    contentLayouter.layout(contentContainer, controlFactory);
}
Also used : IExpandListener(org.jowidgets.api.controller.IExpandListener) IExpandComposite(org.jowidgets.api.widgets.IExpandComposite) ITextLabelBluePrint(org.jowidgets.api.widgets.blueprint.ITextLabelBluePrint) IBeanFormInfo(org.jowidgets.cap.ui.api.form.IBeanFormInfo) IContainer(org.jowidgets.api.widgets.IContainer) MigLayoutDescriptor(org.jowidgets.common.widgets.layout.MigLayoutDescriptor) IExpandCompositeBluePrint(org.jowidgets.api.widgets.blueprint.IExpandCompositeBluePrint)

Example 5 with IContainer

use of org.jowidgets.api.widgets.IContainer in project jo-client-platform by jo-source.

the class BeanFormLayouterImpl method createAndAddContentContainer.

private IContainer createAndAddContentContainer(final IContainer parent, final IBeanFormControlFactory controlFactory, final boolean scrollComposite) {
    final ICustomWidgetCreator<? extends IControl> mainValidationLabel = controlFactory.createMainValidationLabel();
    final IContainer outerContainer;
    if (mainValidationLabel != null) {
        final IExpandCompositeBluePrint expandCompositeBp = expandCompositeBp();
        expandCompositeBp.setExpanded(true);
        expandCompositeBp.setCustomHeader(mainValidationLabel);
        final IExpandComposite expandComposite = parent.add(expandCompositeBp, MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
        expandComposite.setLayout(MigLayoutFactory.growingInnerCellLayout());
        expandComposite.setEnabled(false);
        outerContainer = expandComposite;
    } else {
        outerContainer = parent;
    }
    final IContainer innerContainer;
    if (scrollComposite) {
        outerContainer.setLayout(MigLayoutFactory.growingInnerCellLayout());
        innerContainer = outerContainer.add(BPF.scrollComposite(), MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
    } else {
        innerContainer = outerContainer.add(BPF.composite(), MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
    }
    final String cc = contentInsets.getLeft() + "[grow, 0::]" + contentInsets.getRight();
    final String rc = contentInsets.getTop() + "[]" + contentInsets.getBottom();
    innerContainer.setLayout(new MigLayoutDescriptor(cc, rc));
    final String widthCC = getMainWidthConstraints(controlFactory);
    return innerContainer.add(BPF.composite(), "growx, " + widthCC + ", h 0::, aligny top");
}
Also used : IExpandComposite(org.jowidgets.api.widgets.IExpandComposite) IContainer(org.jowidgets.api.widgets.IContainer) MigLayoutDescriptor(org.jowidgets.common.widgets.layout.MigLayoutDescriptor) IExpandCompositeBluePrint(org.jowidgets.api.widgets.blueprint.IExpandCompositeBluePrint)

Aggregations

IContainer (org.jowidgets.api.widgets.IContainer)7 MigLayoutDescriptor (org.jowidgets.common.widgets.layout.MigLayoutDescriptor)5 IComposite (org.jowidgets.api.widgets.IComposite)2 IExpandComposite (org.jowidgets.api.widgets.IExpandComposite)2 IExpandCompositeBluePrint (org.jowidgets.api.widgets.blueprint.IExpandCompositeBluePrint)2 IPluginProperties (org.jowidgets.plugin.api.IPluginProperties)2 IPluginPropertiesBuilder (org.jowidgets.plugin.api.IPluginPropertiesBuilder)2 ArrayList (java.util.ArrayList)1 IExpandListener (org.jowidgets.api.controller.IExpandListener)1 IControl (org.jowidgets.api.widgets.IControl)1 ITextLabelBluePrint (org.jowidgets.api.widgets.blueprint.ITextLabelBluePrint)1 BeanFormGroupRendering (org.jowidgets.cap.ui.api.form.BeanFormGroupRendering)1 IBeanFormGroup (org.jowidgets.cap.ui.api.form.IBeanFormGroup)1 IBeanFormInfo (org.jowidgets.cap.ui.api.form.IBeanFormInfo)1 IBeanFormProperty (org.jowidgets.cap.ui.api.form.IBeanFormProperty)1 IEntityComponentRelationTreeDetailViewPlugin (org.jowidgets.cap.ui.api.plugin.IEntityComponentRelationTreeDetailViewPlugin)1 IEntityComponentRelationTreeViewPlugin (org.jowidgets.cap.ui.api.plugin.IEntityComponentRelationTreeViewPlugin)1 ICapApiBluePrintFactory (org.jowidgets.cap.ui.api.widgets.ICapApiBluePrintFactory)1 AlignmentVertical (org.jowidgets.common.types.AlignmentVertical)1 Position (org.jowidgets.common.types.Position)1