use of org.eclipse.scout.rt.client.ui.form.fields.GridData in project scout.rt by eclipse.
the class RadioButtonGroupGrid method validate.
@Override
public void validate(ICompositeField compositeField) {
// reset
m_group = compositeField;
m_gridColumns = 0;
m_gridRows = 0;
ArrayList<IFormField> list = new ArrayList<IFormField>();
// filter
for (IFormField f : m_group.getFields()) {
if (f.isVisible()) {
list.add(f);
} else {
GridData data = GridDataBuilder.createFromHints(f, 1);
f.setGridDataInternal(data);
}
}
m_fields = list.toArray(new IFormField[list.size()]);
applyGridData();
}
use of org.eclipse.scout.rt.client.ui.form.fields.GridData in project scout.rt by eclipse.
the class AbstractGroupBox method setScrollable.
@Override
public void setScrollable(TriState scrollable) {
if (scrollable == null) {
scrollable = TriState.UNDEFINED;
}
if (scrollable.equals(isScrollable())) {
return;
}
propertySupport.setProperty(PROP_SCROLLABLE, scrollable);
if (scrollable.isTrue()) {
// force weightY to be > 0
GridData gd = getGridDataHints();
if (gd.weightY <= 0) {
gd.weightY = 1;
setGridDataHints(gd);
}
}
}
use of org.eclipse.scout.rt.client.ui.form.fields.GridData 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.GridData in project scout.rt by eclipse.
the class GroupBoxProcessButtonGrid method layoutStatic.
private void layoutStatic() {
for (IButton button : m_buttons) {
// No need to calculate any layout, just make sure the properties from gridDataHints are copied to gridData (e.g. horizontal alignment)
GridData data = GridDataBuilder.createFromHints(button, 1);
button.setGridDataInternal(data);
}
}
use of org.eclipse.scout.rt.client.ui.form.fields.GridData 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());
}
Aggregations