use of com.vaadin.v7.ui.AbstractLegacyComponent in project SORMAS-Project by hzi-braunschweig.
the class CommitDiscardWrapperComponent method setWrappedComponent.
protected void setWrappedComponent(C component, FieldGroup... fieldGroups) {
this.wrappedComponent = component;
this.fieldGroups = new ArrayList(Arrays.asList(fieldGroups));
if (contentPanel != null) {
contentPanel.setContent(wrappedComponent);
return;
}
setSpacing(false);
setMargin(true);
setSizeUndefined();
contentPanel = new Panel(component);
updateInternalWidth();
updateInternalHeight();
addComponent(contentPanel);
setExpandRatio(contentPanel, 1);
buttonsPanel = new HorizontalLayout();
buttonsPanel.setMargin(false);
buttonsPanel.setSpacing(true);
buttonsPanel.setWidth(100, Unit.PERCENTAGE);
Button discardButton = getDiscardButton();
buttonsPanel.addComponent(discardButton);
buttonsPanel.setComponentAlignment(discardButton, Alignment.BOTTOM_RIGHT);
buttonsPanel.setExpandRatio(discardButton, 1);
Button commitButton = getCommitButton();
buttonsPanel.addComponent(commitButton);
buttonsPanel.setComponentAlignment(commitButton, Alignment.BOTTOM_RIGHT);
buttonsPanel.setExpandRatio(commitButton, 0);
addComponent(buttonsPanel);
setComponentAlignment(buttonsPanel, Alignment.BOTTOM_RIGHT);
setShortcutsEnabled(shortcutsEnabled);
if (fieldGroups != null && fieldGroups.length > 0) {
// convention: set wrapper to read-only when all wrapped field groups are read-only
boolean allReadOnly = true;
for (FieldGroup fieldGroup : fieldGroups) {
if (!fieldGroup.isReadOnly()) {
allReadOnly = false;
break;
}
}
if (allReadOnly) {
setReadOnly(true);
}
} else if (wrappedComponent != null) {
if (wrappedComponent instanceof AbstractLegacyComponent && ((AbstractLegacyComponent) wrappedComponent).isReadOnly()) {
setReadOnly(true);
}
}
dirty = false;
addDirtyHandler(fieldGroups);
}
Aggregations