Search in sources :

Example 41 with IFormField

use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.

the class AbstractComposerValueBox method setSelectionContext.

public void setSelectionContext(IDataModelAttribute attribute, IDataModelAttributeOp op, List<?> values) {
    if (op == null) {
        return;
    }
    if (values == null && getSelectedField() != null) {
        values = getSelectedField().getValues();
    }
    m_attribute = attribute;
    // 
    int dataType = op.getType();
    if (dataType == IDataModelAttribute.TYPE_INHERITED) {
        dataType = attribute.getType();
    }
    Map<Integer, IComposerValueField> typeToFieldMap = m_operatorTypeToFieldMap.get(op.getOperator());
    if (typeToFieldMap == null) {
        // default
        typeToFieldMap = m_operatorTypeToFieldMap.get(0);
    }
    IComposerValueField valueField = typeToFieldMap.get(dataType);
    // clear old
    if (m_selectedField != null) {
        m_selectedField.removeValueChangeListenerFromTarget(m_valueChangedListener);
        m_selectedField.clearSelectionContext();
    }
    // set new
    m_selectedField = valueField;
    if (m_selectedField != null) {
        m_selectedField.addValueChangeListenerToTarget(m_valueChangedListener);
        m_selectedField.setSelectionContext(m_attribute, dataType, op, values);
    }
    for (IFormField f : getFields()) {
        f.setVisible(f == m_selectedField);
    }
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField)

Example 42 with IFormField

use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.

the class AbstractGroupBox method categorizeFields.

private void categorizeFields() {
    // categorize items
    List<IFormField> controlList = new ArrayList<IFormField>();
    List<IGroupBox> groupList = new ArrayList<IGroupBox>();
    List<IButton> customButtonList = new ArrayList<IButton>();
    List<IButton> systemButtonList = new ArrayList<IButton>();
    for (IFormField field : getFields()) {
        if (field instanceof IGroupBox) {
            groupList.add((IGroupBox) field);
            controlList.add(field);
        } else if (field instanceof IButton) {
            IButton b = (IButton) field;
            if (b.isProcessButton()) {
                if (b.getSystemType() != IButton.SYSTEM_TYPE_NONE) {
                    systemButtonList.add((IButton) field);
                } else {
                    customButtonList.add((IButton) field);
                }
            } else {
                controlList.add(field);
            }
        } else {
            controlList.add(field);
        }
    }
    m_controlFields = controlList;
    m_groupBoxes = groupList;
    m_customButtons = customButtonList;
    m_systemButtons = systemButtonList;
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) IButton(org.eclipse.scout.rt.client.ui.form.fields.button.IButton) ArrayList(java.util.ArrayList)

Example 43 with IFormField

use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.

the class AbstractGroupBoxBodyGrid method validate.

@Override
public void validate(IGroupBox groupBox) {
    // reset old state
    setGridRows(0);
    // STEP 0: column count
    setGridColumns(computGridColumnCount(groupBox));
    int containingGridXYCount = 0;
    int notContainingGridXYCount = 0;
    // build
    List<IFormField> fieldsExceptProcessButtons = new ArrayList<IFormField>();
    for (IFormField formField : groupBox.getFields()) {
        if (formField.isVisible()) {
            if (!isProcessButton(formField)) {
                fieldsExceptProcessButtons.add(formField);
                GridData hints = formField.getGridDataHints();
                if (hints.x >= 0 && hints.y >= 0) {
                    containingGridXYCount++;
                } else {
                    notContainingGridXYCount++;
                }
            }
        } else {
            GridData data = GridDataBuilder.createFromHints(formField, 1);
            formField.setGridDataInternal(data);
        }
    }
    boolean isContainingXAndY = (containingGridXYCount > 0 && notContainingGridXYCount == 0);
    if (isContainingXAndY) {
        layoutAllStatic(fieldsExceptProcessButtons);
    } else {
        layoutAllDynamic(fieldsExceptProcessButtons);
    }
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) ArrayList(java.util.ArrayList) GridData(org.eclipse.scout.rt.client.ui.form.fields.GridData)

Example 44 with IFormField

use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.

the class VerticalSmartGroupBoxBodyGrid method layoutAllDynamic.

@Override
protected void layoutAllDynamic(List<IFormField> fields) {
    // calculate the used cells
    int cellCount = 0;
    for (IFormField f : fields) {
        GridData hints = getGridDataFromHints(f, getGridColumnCount());
        cellCount += hints.w * hints.h;
    }
    int rowCount = (cellCount + getGridColumnCount() - 1) / getGridColumnCount();
    VerticalGridMatrix matrix = new VerticalGridMatrix(getGridColumnCount(), rowCount);
    while (!matrix.computeGridData(fields)) {
        matrix.resetAll(getGridColumnCount(), ++rowCount);
    }
    // setGridData
    for (IFormField f : fields) {
        GridData data = matrix.getGridData(f);
        f.setGridDataInternal(data);
    }
    setGridRows(matrix.getRowCount());
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) VerticalGridMatrix(org.eclipse.scout.rt.client.ui.form.fields.groupbox.internal.matrix.VerticalGridMatrix) GridData(org.eclipse.scout.rt.client.ui.form.fields.GridData)

Example 45 with IFormField

use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.

the class HorizontalGridMatrix method computeGridData.

@Override
public boolean computeGridData(List<IFormField> fields) {
    for (IFormField f : fields) {
        GridData hints = GridDataBuilder.createFromHints(f, m_columnCount);
        GridData gridData = new GridData(hints);
        gridData.w = Math.min(hints.w, m_columnCount);
        add(f, hints, gridData);
        f.setGridDataInternal(gridData);
    }
    return true;
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) GridData(org.eclipse.scout.rt.client.ui.form.fields.GridData)

Aggregations

IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)60 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)13 GridData (org.eclipse.scout.rt.client.ui.form.fields.GridData)12 IButton (org.eclipse.scout.rt.client.ui.form.fields.button.IButton)5 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)5 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeListener (java.beans.PropertyChangeListener)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)4 IGroupBox (org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox)4 IExtensibleObject (org.eclipse.scout.rt.shared.extension.IExtensibleObject)4 Map (java.util.Map)3 PlatformExceptionTranslator (org.eclipse.scout.rt.platform.exception.PlatformExceptionTranslator)3 LinkedList (java.util.LinkedList)2 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 ICompositeField (org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)2 IValueField (org.eclipse.scout.rt.client.ui.form.fields.IValueField)2 FindFieldByFormDataIdVisitor (org.eclipse.scout.rt.client.ui.form.internal.FindFieldByFormDataIdVisitor)2