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);
}
}
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;
}
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);
}
}
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());
}
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;
}
Aggregations