Search in sources :

Example 1 with IExpandListener

use of org.jowidgets.api.controller.IExpandListener 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)

Aggregations

IExpandListener (org.jowidgets.api.controller.IExpandListener)1 IContainer (org.jowidgets.api.widgets.IContainer)1 IExpandComposite (org.jowidgets.api.widgets.IExpandComposite)1 IExpandCompositeBluePrint (org.jowidgets.api.widgets.blueprint.IExpandCompositeBluePrint)1 ITextLabelBluePrint (org.jowidgets.api.widgets.blueprint.ITextLabelBluePrint)1 IBeanFormInfo (org.jowidgets.cap.ui.api.form.IBeanFormInfo)1 MigLayoutDescriptor (org.jowidgets.common.widgets.layout.MigLayoutDescriptor)1