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