use of org.jowidgets.api.widgets.IContainer in project jo-client-platform by jo-source.
the class BeanLinkPanelImpl method createForms.
private void createForms(final IContainer container, final IBeanFormBluePrint<LINK_BEAN_TYPE> linkFormBp, final IBeanFormBluePrint<LINKABLE_BEAN_TYPE> linkableFormBp) {
if (linkFormBp != null && linkableFormBp != null) {
final boolean scrolledContent = linkFormBp.getScrollbarsAllowed() && linkableFormBp.getScrollbarsAllowed();
final IContainer content;
if (scrolledContent) {
container.setLayout(MigLayoutFactory.growingInnerCellLayout());
content = container.add(BPF.scrollComposite(), MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
} else {
content = container;
}
content.setLayout(new MigLayoutDescriptor("0[grow, 0::]0", "0[]0[]0[]0"));
final IBeanFormBluePrint<LINK_BEAN_TYPE> modifiedLinkFormBp = createModifiedFormBp(linkFormBp);
if (scrolledContent) {
modifiedLinkFormBp.setScrollbarsAllowed(false);
}
this.linkForm = content.add(modifiedLinkFormBp, "growx, w 0::, wrap");
content.add(BPF.separator(), "growx, w 0::, wrap");
final IBeanFormBluePrint<LINKABLE_BEAN_TYPE> modifiedLinkableFormBp = createModifiedFormBp(linkableFormBp);
if (scrolledContent) {
modifiedLinkableFormBp.setScrollbarsAllowed(false);
}
this.linkableForm = content.add(modifiedLinkableFormBp, "growx, w 0::");
} else {
container.setLayout(new MigLayoutDescriptor("0[grow, 0::]0", "0[grow, 0::]0"));
if (linkFormBp != null) {
this.linkForm = container.add(createModifiedFormBp(linkFormBp), "growx, w 0::, growy, h 0::");
}
if (linkableFormBp != null) {
this.linkableForm = container.add(createModifiedFormBp(linkableFormBp), "growx, w 0::, growy, h 0::");
}
}
}
use of org.jowidgets.api.widgets.IContainer in project jo-client-platform by jo-source.
the class BeanFormContentLayouter method layout.
@Override
public void layout(final IContainer container, final IBeanFormControlFactory controlFactory) {
final Collection<ICustomWidgetCreator<? extends IControl>> buttons = controlFactory.createButtons();
if (!buttons.isEmpty()) {
container.setLayout(new MigLayoutDescriptor("0[grow, 0::]0", "0[0::]15[]0"));
// add the form
final IContainer formContainer = container.add(BPF.composite(), "growx, w 0::, wrap");
layoutForm(formContainer, controlFactory);
// add the button bar
final IComposite buttonBar = container.add(BPF.composite(), "alignx r");
buttonBar.setLayout(getButtonBarLayout(buttons));
for (final ICustomWidgetCreator<? extends IControl> button : buttons) {
buttonBar.add(button, "sg bg");
}
} else {
layoutForm(container, controlFactory);
}
}
use of org.jowidgets.api.widgets.IContainer 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;
}
}
}
use of org.jowidgets.api.widgets.IContainer in project jo-client-platform by jo-source.
the class BeanFormLayouterImpl method layout.
@Override
public void layout(final IContainer parent, final IBeanFormControlFactory controlFactory) {
final IBeanFormInfo beanFormInfo = controlFactory.getBeanFormInfo();
final IContainer container;
if (controlFactory.getScrollbarsAllowed() && beanFormInfo != null) {
parent.setLayout(MigLayoutFactory.growingInnerCellLayout());
container = parent.add(BPF.scrollComposite(), MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
} else {
container = parent;
}
final String colConstraints = insets.getLeft() + "[grow, 0::]" + insets.getRight();
final String rowConstraints;
if (beanFormInfo != null) {
rowConstraints = insets.getTop() + "[][grow, 0::]" + insets.getBottom();
} else {
rowConstraints = insets.getTop() + "[grow, 0::]" + insets.getBottom();
}
container.setLayout(new MigLayoutDescriptor(colConstraints, rowConstraints));
if (beanFormInfo != null) {
final IExpandCompositeBluePrint expandCompositeBp = expandCompositeBp();
expandCompositeBp.setExpanded(beanFormInfo.isExpanded());
expandCompositeBp.setText(beanFormInfo.getHeader().get());
expandCompositeBp.setIcon(beanFormInfo.getHeaderIcon());
final IExpandComposite expandComposite = container.add(expandCompositeBp, "growx, w 0::, wrap");
final String cc = contentInsets.getLeft() + "[grow, 0::]" + contentInsets.getRight();
final String rc = contentInsets.getTop() + "[]" + contentInsets.getBottom();
expandComposite.setLayout(new MigLayoutDescriptor(cc, rc));
final ITextLabelBluePrint labelBp = BPF.textLabel(beanFormInfo.getText().get());
labelBp.setForegroundColor(contentTextColor).setMarkup(contentTextMarkup);
expandComposite.add(labelBp, "growx, w 0::");
expandComposite.addExpandListener(new IExpandListener() {
@Override
public void expandedChanged(final boolean expanded) {
getRootContainer(parent).layout();
}
});
}
final boolean contentScrollbar = beanFormInfo == null && controlFactory.getScrollbarsAllowed();
final IContainer contentContainer = createAndAddContentContainer(container, controlFactory, contentScrollbar);
contentLayouter.layout(contentContainer, controlFactory);
}
use of org.jowidgets.api.widgets.IContainer in project jo-client-platform by jo-source.
the class BeanFormLayouterImpl method createAndAddContentContainer.
private IContainer createAndAddContentContainer(final IContainer parent, final IBeanFormControlFactory controlFactory, final boolean scrollComposite) {
final ICustomWidgetCreator<? extends IControl> mainValidationLabel = controlFactory.createMainValidationLabel();
final IContainer outerContainer;
if (mainValidationLabel != null) {
final IExpandCompositeBluePrint expandCompositeBp = expandCompositeBp();
expandCompositeBp.setExpanded(true);
expandCompositeBp.setCustomHeader(mainValidationLabel);
final IExpandComposite expandComposite = parent.add(expandCompositeBp, MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
expandComposite.setLayout(MigLayoutFactory.growingInnerCellLayout());
expandComposite.setEnabled(false);
outerContainer = expandComposite;
} else {
outerContainer = parent;
}
final IContainer innerContainer;
if (scrollComposite) {
outerContainer.setLayout(MigLayoutFactory.growingInnerCellLayout());
innerContainer = outerContainer.add(BPF.scrollComposite(), MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
} else {
innerContainer = outerContainer.add(BPF.composite(), MigLayoutFactory.GROWING_CELL_CONSTRAINTS);
}
final String cc = contentInsets.getLeft() + "[grow, 0::]" + contentInsets.getRight();
final String rc = contentInsets.getTop() + "[]" + contentInsets.getBottom();
innerContainer.setLayout(new MigLayoutDescriptor(cc, rc));
final String widthCC = getMainWidthConstraints(controlFactory);
return innerContainer.add(BPF.composite(), "growx, " + widthCC + ", h 0::, aligny top");
}
Aggregations