use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.
the class AbstractSequenceBox method initConfig.
@Override
protected void initConfig() {
m_labelCompositionLock = new OptimisticLock();
m_grid = new SequenceBoxGrid();
super.initConfig();
setAutoCheckFromTo(getConfiguredAutoCheckFromTo());
setEqualColumnWidths(getConfiguredEqualColumnWidths());
// when range box has visible label, suppress first field's label and append
// to own label
propertySupport.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
if (e.getPropertyName().equals(IFormField.PROP_LABEL_VISIBLE) || e.getPropertyName().equals(IFormField.PROP_LABEL) || e.getPropertyName().equals(IFormField.PROP_VISIBLE)) {
updateLabelComposition();
}
}
});
// If inner fields change their visibility dynamically, the label of the SequenceBox might change.
for (IFormField field : getFields()) {
field.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
if (e.getPropertyName().equals(IFormField.PROP_LABEL_VISIBLE) || e.getPropertyName().equals(IFormField.PROP_LABEL) || e.getPropertyName().equals(IFormField.PROP_VISIBLE)) {
updateLabelComposition();
}
}
});
}
updateLabelComposition();
hideFieldStatusOfChildren();
// attach change triggers
attachCheckFromToListeners();
}
use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.
the class AbstractSequenceBox method getComparableValueFields.
/**
* @return Comparable {@link IValueField}s with the same holder type than the first one
*/
private ArrayList<IValueField> getComparableValueFields() {
ArrayList<IValueField> valueFieldList = new ArrayList<IValueField>();
Class<?> sharedType = null;
for (IFormField f : getFields()) {
if (f instanceof IValueField) {
IValueField v = (IValueField) f;
Class<?> valueType = v.getHolderType();
if (Comparable.class.isAssignableFrom(valueType) && (sharedType == null || valueType == sharedType)) {
sharedType = valueType;
valueFieldList.add(v);
}
}
}
return valueFieldList;
}
use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.
the class AbstractGroupBoxBodyGrid method layoutAllStatic.
/**
* Make layout based on grid-x, grid-y, grid-w and grid-h No auto-layout
*/
private void layoutAllStatic(List<IFormField> fields) {
int totalGridW = 1;
int totalGridH = 0;
for (IFormField f : fields) {
GridData hints = GridDataBuilder.createFromHints(f, 1);
totalGridW = Math.max(totalGridW, hints.x + hints.w);
totalGridH = Math.max(totalGridH, hints.y + hints.h);
}
for (IFormField f : fields) {
GridData hints = GridDataBuilder.createFromHints(f, totalGridW);
f.setGridDataInternal(hints);
}
setGridColumns(totalGridW);
setGridRows(totalGridH);
}
use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.
the class VerticalGridMatrix method reorganizeGridAbove.
private void reorganizeGridAbove(int x, int y, int w) {
Set<IFormField> fieldsToReorganize = new HashSet<IFormField>();
Map<MatrixIndex, Cell> occupiedCells = new HashMap<MatrixIndex, Cell>();
Bounds reorgBounds = new Bounds(x, 0, w, y + 1);
int minY = y;
int usedCells = 0;
boolean continueLoop = true;
for (int yi = y; yi >= 0 && continueLoop; yi--) {
for (int xi = x; xi < x + w && continueLoop; xi++) {
MatrixIndex matrixIndex = new MatrixIndex(xi, yi);
Cell cell = m_cells.get(matrixIndex);
if (cell != null && !cell.isEmpty()) {
GridData gd = cell.fieldGridData;
if (horizontalMatchesOrOverlaps(reorgBounds, gd)) {
continueLoop = false;
} else if (horizontalOverlapsOnSide(reorgBounds, gd)) {
// freeze the cells for reorganization
occupiedCells.put(matrixIndex, cell);
usedCells++;
minY = Math.min(matrixIndex.y, minY);
} else // includes
{
// add field to reorganization
m_cells.remove(matrixIndex);
fieldsToReorganize.add(cell.field);
usedCells++;
minY = Math.min(matrixIndex.y, minY);
}
}
}
}
if (fieldsToReorganize.isEmpty()) {
return;
}
// sort fields
List<IFormField> sortedFieldsToReorganize = new ArrayList<IFormField>(fieldsToReorganize);
Collections.sort(sortedFieldsToReorganize, new Comparator<IFormField>() {
@Override
public int compare(IFormField o1, IFormField o2) {
Integer i1 = m_formFieldIndexes.get(o1);
Integer i2 = m_formFieldIndexes.get(o2);
return i1.compareTo(i2);
}
});
reorgBounds.y = minY;
VerticalGridMatrix reorgMatrix = new VerticalGridMatrix(reorgBounds.x, reorgBounds.y, reorgBounds.w, (usedCells + reorgBounds.w - 1) / reorgBounds.w);
reorgMatrix.addCells(occupiedCells);
while (!reorgMatrix.computeGridData(sortedFieldsToReorganize)) {
reorgMatrix.resetAll(reorgMatrix.getColumnCount(), reorgMatrix.getRowCount() + 1);
}
m_cursor.reset();
m_cells.putAll(reorgMatrix.getCells());
m_fieldGridDatas.putAll(reorgMatrix.getFieldGridDatas());
}
use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.
the class ScoutClientAssert method assertView.
private static void assertView(final ViewKind viewKind, final boolean strict, IForm form, IFormField... fields) {
Assert.assertNotNull(form);
Assert.assertNotNull(fields);
final HashSet<IFormField> expectedFields = new HashSet<IFormField>(Arrays.asList(fields));
final ArrayList<IFormField> unexpectedFields = new ArrayList<IFormField>();
form.visitFields(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
if (viewKind.testField(field)) {
boolean expected = expectedFields.remove(field);
if (strict && !expected) {
unexpectedFields.add(field);
}
}
return true;
}
});
if (!expectedFields.isEmpty() || !unexpectedFields.isEmpty()) {
StringBuilder builder = new StringBuilder();
builder.append(viewKind.getName());
builder.append(" fields:");
if (!expectedFields.isEmpty()) {
builder.append("\n\texpected ").append(viewKind.getPositive()).append(" but ").append(viewKind.getNegative()).append(": ");
builder.append(formatFieldNames(expectedFields));
}
if (!unexpectedFields.isEmpty()) {
builder.append("\n\texpected ").append(viewKind.getNegative()).append(" but ").append(viewKind.getPositive()).append(": ");
builder.append(formatFieldNames(unexpectedFields));
}
Assert.fail(builder.toString());
}
}
Aggregations