Search in sources :

Example 1 with IExpandComposite

use of org.jowidgets.api.widgets.IExpandComposite 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 2 with IExpandComposite

use of org.jowidgets.api.widgets.IExpandComposite 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)2 IExpandComposite (org.jowidgets.api.widgets.IExpandComposite)2 IExpandCompositeBluePrint (org.jowidgets.api.widgets.blueprint.IExpandCompositeBluePrint)2 MigLayoutDescriptor (org.jowidgets.common.widgets.layout.MigLayoutDescriptor)2 IExpandListener (org.jowidgets.api.controller.IExpandListener)1 ITextLabelBluePrint (org.jowidgets.api.widgets.blueprint.ITextLabelBluePrint)1 IBeanFormInfo (org.jowidgets.cap.ui.api.form.IBeanFormInfo)1