Search in sources :

Example 6 with IComposite

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

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

the class AttributeFilterControlFactory method create.

@Override
public IAttributeFilterControl create(final Object parentUiReference, final IAttributeFilterControlBluePrint bluePrint) {
    final IBluePrintFactory bpf = Toolkit.getBluePrintFactory();
    final IComposite composite = Toolkit.getWidgetFactory().create(parentUiReference, bpf.composite());
    return new AttributeFilterControlImpl(composite, bluePrint);
}
Also used : IBluePrintFactory(org.jowidgets.api.widgets.blueprint.factory.IBluePrintFactory) IComposite(org.jowidgets.api.widgets.IComposite)

Example 8 with IComposite

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

the class AttributeFilterControlImpl method setAttributeImpl.

private void setAttributeImpl(final IAttribute<?> attribute, final IFilterType filterType, final boolean setDefaultOperator) {
    Assert.paramNotNull(attribute, "attribute");
    Assert.paramNotNull(filterType, "filterType");
    final IFilterPanelProvider<IOperator> filterPanelProvider = getFilterPanelProvider(attribute, filterType);
    final ICustomWidgetCreator<IFilterControl<IOperator, Object, IUiConfigurableFilter<Object>>> creator;
    creator = createPanelCreator(filterPanelProvider);
    final IComposite composite = getWidget();
    if (filterControl != null) {
        filterControl.removeInputListener(inputListener);
        composite.remove(filterControl);
    }
    filterControl = composite.add(creator, "growx, w 0::");
    filterControl.setEditable(editable);
    filterControl.addInputListener(inputListener);
    filterControl.addValidationConditionListener(validationConditionListener);
    this.operatorProvider = filterPanelProvider.getOperatorProvider();
    cmbOperator.removeInputListener(operatorListener);
    cmbOperator.setElements(operatorProvider.getOperators());
    final IOperator defaultOperator = operatorProvider.getDefaultOperator();
    if (defaultOperator != null) {
        if (setDefaultOperator) {
            cmbOperator.setValue(defaultOperator);
            filterControl.setOperator(defaultOperator);
        }
        setCmbNotEnabledByOperator(defaultOperator);
    }
    cmbOperator.addInputListener(operatorListener);
}
Also used : IOperator(org.jowidgets.cap.common.api.filter.IOperator) IComposite(org.jowidgets.api.widgets.IComposite) IFilterControl(org.jowidgets.cap.ui.api.filter.IFilterControl)

Example 9 with IComposite

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

the class BeanRelationTreeDetailFactory method create.

@Override
public IBeanRelationTreeDetail<Object> create(final Object parentUiReference, final IBeanRelationTreeDetailBluePrint<Object> bluePrint) {
    final ICompositeBluePrint bp = BPF.composite();
    bp.setSetup(bluePrint);
    final IComposite composite = Toolkit.getWidgetFactory().create(parentUiReference, bp);
    return new BeanRelationTreeDetailImpl<Object>(composite, bluePrint);
}
Also used : ICompositeBluePrint(org.jowidgets.api.widgets.blueprint.ICompositeBluePrint) IComposite(org.jowidgets.api.widgets.IComposite)

Example 10 with IComposite

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

the class SingleBeanFormFactory method create.

@Override
public ISingleBeanForm<Object> create(final Object parentUiReference, final ISingleBeanFormBluePrint<Object> bluePrint) {
    final IBluePrintFactory bpf = Toolkit.getBluePrintFactory();
    final IComposite composite = Toolkit.getWidgetFactory().create(parentUiReference, bpf.composite());
    return new SingleBeanFormImpl<Object>(composite, bluePrint);
}
Also used : IBluePrintFactory(org.jowidgets.api.widgets.blueprint.factory.IBluePrintFactory) IComposite(org.jowidgets.api.widgets.IComposite)

Aggregations

IComposite (org.jowidgets.api.widgets.IComposite)10 IBluePrintFactory (org.jowidgets.api.widgets.blueprint.factory.IBluePrintFactory)3 MigLayoutDescriptor (org.jowidgets.common.widgets.layout.MigLayoutDescriptor)3 IContainer (org.jowidgets.api.widgets.IContainer)2 ICompositeBluePrint (org.jowidgets.api.widgets.blueprint.ICompositeBluePrint)2 ArrayList (java.util.ArrayList)1 IControl (org.jowidgets.api.widgets.IControl)1 IScrollComposite (org.jowidgets.api.widgets.IScrollComposite)1 ITabItem (org.jowidgets.api.widgets.ITabItem)1 IScrollCompositeBluePrint (org.jowidgets.api.widgets.blueprint.IScrollCompositeBluePrint)1 IOperator (org.jowidgets.cap.common.api.filter.IOperator)1 IFilterControl (org.jowidgets.cap.ui.api.filter.IFilterControl)1 BeanFormGroupRendering (org.jowidgets.cap.ui.api.form.BeanFormGroupRendering)1 IBeanFormGroup (org.jowidgets.cap.ui.api.form.IBeanFormGroup)1 IBeanFormProperty (org.jowidgets.cap.ui.api.form.IBeanFormProperty)1 AlignmentVertical (org.jowidgets.common.types.AlignmentVertical)1 Position (org.jowidgets.common.types.Position)1 ICustomWidgetCreator (org.jowidgets.common.widgets.factory.ICustomWidgetCreator)1