Search in sources :

Example 6 with MigLayoutDescriptor

use of org.jowidgets.common.widgets.layout.MigLayoutDescriptor in project jo-client-platform by jo-source.

the class DefaultArithmeticFilterControl method setOperator.

@Override
public void setOperator(final ArithmeticOperator operator) {
    if (this.operator != operator) {
        this.operator = operator;
        removeInputListener();
        getWidget().removeAll();
        control1 = null;
        control2 = null;
        collectionControl = null;
        if (ArithmeticOperator.BETWEEN == operator) {
            // $NON-NLS-1$ //$NON-NLS-2$
            getWidget().setLayout(new MigLayoutDescriptor("0[grow][][grow]0", "0[]0"));
            // $NON-NLS-1$
            control1 = getWidget().add(controlCreator, "growx");
            getWidget().add(Toolkit.getBluePrintFactory().textLabel(AND.get()));
            // $NON-NLS-1$
            control2 = getWidget().add(controlCreator, "growx");
        } else if (ArithmeticOperator.EMPTY != operator) {
            // $NON-NLS-1$ //$NON-NLS-2$
            getWidget().setLayout(new MigLayoutDescriptor("0[grow]0", "0[]0"));
            if (isCollectionOperator(operator)) {
                // $NON-NLS-1$
                collectionControl = getWidget().add(collectionControlCreator, "growx");
            } else {
                // $NON-NLS-1$
                control1 = getWidget().add(controlCreator, "growx");
            }
        } else {
            // $NON-NLS-1$ //$NON-NLS-2$
            getWidget().setLayout(new MigLayoutDescriptor("0[]0", "0[]0"));
            getWidget().add(Toolkit.getBluePrintFactory().textLabel());
        }
        addInputListener();
        addValidators();
        setValidationCacheDirty();
    }
}
Also used : MigLayoutDescriptor(org.jowidgets.common.widgets.layout.MigLayoutDescriptor)

Example 7 with MigLayoutDescriptor

use of org.jowidgets.common.widgets.layout.MigLayoutDescriptor in project jo-client-platform by jo-source.

the class DocumentBeanFormPluginImpl method addBrowserAttribute.

private void addBrowserAttribute(final IContainer container, final IAttribute<?> attribute, final IBeanFormControlFactory controlFactory) {
    container.setLayout(new MigLayoutDescriptor("wrap", "0[grow, 0::]0", "0[]0[grow, 0::]0"));
    final String propertyName = attribute.getPropertyName();
    @SuppressWarnings("unchecked") final IInputControl<IDocument> inputField = (IInputControl<IDocument>) container.add(controlFactory.createControl(propertyName), "growx, w 0::");
    final IBrowser browser = container.add(BrowserBPF.browser(), MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
    container.addShowingStateListener(new IShowingStateListener() {

        @Override
        public void showingStateChanged(final boolean isShowing) {
            if (isShowing) {
                setUrl(container, browser, inputField);
            }
        }
    });
    inputField.addInputListener(new IInputListener() {

        @Override
        public void inputChanged() {
            setUrl(container, browser, inputField);
        }
    });
}
Also used : IBrowser(org.jowidgets.addons.widgets.browser.api.IBrowser) IShowingStateListener(org.jowidgets.api.controller.IShowingStateListener) IInputControl(org.jowidgets.api.widgets.IInputControl) IInputListener(org.jowidgets.common.widgets.controller.IInputListener) MigLayoutDescriptor(org.jowidgets.common.widgets.layout.MigLayoutDescriptor) IDocument(org.jowidgets.cap.common.api.dto.IDocument)

Example 8 with MigLayoutDescriptor

use of org.jowidgets.common.widgets.layout.MigLayoutDescriptor in project jo-client-platform by jo-source.

the class BeanGraphAttributeListImpl method buildAttributeList.

public void buildAttributeList(final Map<String, Boolean> filterMap, final FilterType type) {
    final ITableLayoutBuilder builder = Toolkit.getLayoutFactoryProvider().tableLayoutBuilder();
    builder.columnCount(2);
    builder.gap(15);
    builder.verticalGap(4);
    builder.alignment(1, Alignment.CENTER);
    builder.fixedColumnWidth(0, 200);
    builder.fixedColumnWidth(1, 50);
    this.attributeLayoutManager = builder.build();
    attributeLayoutManager.beginLayout();
    this.setLayout(new MigLayoutDescriptor("hidemode 2", "[grow, 0::]", "[grow,0::]0[grow,0::]"));
    final IBluePrintFactory bpf = Toolkit.getBluePrintFactory();
    new AttributeHeaderComposite(add(bpf.composite(), "grow, wrap"));
    initializeGroups(this, filterMap, bpf, type);
    attributeLayoutManager.endLayout();
    attributeLayoutManager.validate();
    final Dimension prefSize = super.getPreferredSize();
    setPreferredSize(new Dimension(prefSize.getWidth(), prefSize.getHeight()));
}
Also used : ITableLayoutBuilder(org.jowidgets.api.layout.tablelayout.ITableLayoutBuilder) IBluePrintFactory(org.jowidgets.api.widgets.blueprint.factory.IBluePrintFactory) Dimension(org.jowidgets.common.types.Dimension) MigLayoutDescriptor(org.jowidgets.common.widgets.layout.MigLayoutDescriptor)

Example 9 with MigLayoutDescriptor

use of org.jowidgets.common.widgets.layout.MigLayoutDescriptor in project jo-client-platform by jo-source.

the class ArithmeticPropertyFilterControl method setOperator.

@Override
public void setOperator(final ArithmeticOperator operator) {
    // $NON-NLS-1$
    Assert.paramNotNull(operator, "operator");
    if (this.operator != operator) {
        this.operator = operator;
        removeInputListener();
        getWidget().removeAll();
        combo1 = null;
        combo2 = null;
        if (ArithmeticOperator.BETWEEN == operator) {
            // $NON-NLS-1$ //$NON-NLS-2$
            getWidget().setLayout(new MigLayoutDescriptor("0[grow][][grow]0", "0[]0"));
            // $NON-NLS-1$
            combo1 = getWidget().add(comboBoxBluePrint(attributes), "grow, w 0::");
            getWidget().add(Toolkit.getBluePrintFactory().textLabel(AND.get()));
            // $NON-NLS-1$
            combo2 = getWidget().add(comboBoxBluePrint(attributes), "grow, w 0::");
        } else if (ArithmeticOperator.EMPTY != operator) {
            // $NON-NLS-1$ //$NON-NLS-2$
            getWidget().setLayout(new MigLayoutDescriptor("0[grow]0", "0[]0"));
            final List<IAttribute<?>> currentAttributes;
            if (isCollectionOperator(operator)) {
                currentAttributes = collectionTypeAttributes;
            } else {
                currentAttributes = attributes;
            }
            // $NON-NLS-1$
            combo1 = getWidget().add(comboBoxBluePrint(currentAttributes), "grow, w 0::");
        }
        addInputListener();
        addValidators();
    }
}
Also used : LinkedList(java.util.LinkedList) List(java.util.List) MigLayoutDescriptor(org.jowidgets.common.widgets.layout.MigLayoutDescriptor)

Example 10 with MigLayoutDescriptor

use of org.jowidgets.common.widgets.layout.MigLayoutDescriptor 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)

Aggregations

MigLayoutDescriptor (org.jowidgets.common.widgets.layout.MigLayoutDescriptor)13 IContainer (org.jowidgets.api.widgets.IContainer)5 IComposite (org.jowidgets.api.widgets.IComposite)3 IExpandComposite (org.jowidgets.api.widgets.IExpandComposite)2 IExpandCompositeBluePrint (org.jowidgets.api.widgets.blueprint.IExpandCompositeBluePrint)2 ITextLabelBluePrint (org.jowidgets.api.widgets.blueprint.ITextLabelBluePrint)2 IBluePrintFactory (org.jowidgets.api.widgets.blueprint.factory.IBluePrintFactory)2 Dimension (org.jowidgets.common.types.Dimension)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 IBrowser (org.jowidgets.addons.widgets.browser.api.IBrowser)1 IExpandListener (org.jowidgets.api.controller.IExpandListener)1 IShowingStateListener (org.jowidgets.api.controller.IShowingStateListener)1 ITableLayoutBuilder (org.jowidgets.api.layout.tablelayout.ITableLayoutBuilder)1 IButton (org.jowidgets.api.widgets.IButton)1 IControl (org.jowidgets.api.widgets.IControl)1 IInputControl (org.jowidgets.api.widgets.IInputControl)1 IScrollCompositeBluePrint (org.jowidgets.api.widgets.blueprint.IScrollCompositeBluePrint)1 IInputContentContainer (org.jowidgets.api.widgets.content.IInputContentContainer)1