use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class DesktopFieldGroup method bindDeclarativeFieldConfigs.
protected void bindDeclarativeFieldConfigs() {
List<Integer> reattachColumns = new ArrayList<>();
for (FieldConfig fc : getColumnOrderedFields()) {
if (!fc.isCustom() && !fc.isBound()) {
FieldConfigImpl fci = (FieldConfigImpl) fc;
Datasource targetDs = fc.getTargetDatasource();
if (targetDs == null) {
throw new IllegalStateException(String.format("Unable to get datasource for field '%s'", id));
}
FieldGroupFieldFactory.GeneratedField generatedField = fieldFactory.createField(fc);
Component fieldComponent = generatedField.getComponent();
fci.assignComponent(fieldComponent);
fci.setAttachMode(generatedField.getAttachMode());
setupFieldComponent(fci);
DesktopAbstractComponent fieldImpl = (DesktopAbstractComponent) fieldComponent;
fci.setComposition(fieldImpl);
assignTypicalAttributes(fieldComponent);
if (generatedField.getAttachMode() == FieldAttachMode.APPLY_DEFAULTS) {
applyFieldDefaults(fci);
}
int columnIndex = fci.getColumn();
if (!reattachColumns.contains(columnIndex)) {
reattachColumns.add(columnIndex);
}
}
}
if (!reattachColumns.isEmpty()) {
this.rows = detectRowsCount();
for (Integer reattachColumnIndex : reattachColumns) {
reattachColumnFields(reattachColumnIndex);
}
}
impl.revalidate();
impl.repaint();
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class DesktopGridLayout method updateEnabled.
@Override
public void updateEnabled() {
super.updateEnabled();
boolean resultEnabled = isEnabledWithParent();
for (Component component : ownComponents) {
if (component instanceof DesktopAbstractComponent) {
((DesktopAbstractComponent) component).setParentEnabled(resultEnabled);
}
}
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class DesktopAbstractBox method add.
@Override
public void add(Component component, int index) {
if (component.getParent() != null && component.getParent() != this) {
throw new IllegalStateException("Component already has parent");
}
if (ownComponents.contains(component)) {
int existingIndex = new ArrayList<>(ownComponents).indexOf(component);
if (index > existingIndex) {
index--;
}
remove(component);
}
JComponent composition = DesktopComponentsHelper.getComposition(component);
boolean hasExternalCaption = DesktopContainerHelper.hasExternalCaption(component);
if (hasExternalCaption || DesktopContainerHelper.hasExternalContextHelp(component)) {
ComponentCaption caption = new ComponentCaption(component);
captions.put(component, caption);
JPanel wrapper = new LayoutSlot();
BoxLayoutAdapter adapter = BoxLayoutAdapter.create(wrapper);
adapter.setExpandLayout(true);
adapter.setSpacing(false);
adapter.setMargin(false);
wrapper.add(composition);
if (hasExternalCaption) {
adapter.setFlowDirection(BoxLayoutAdapter.FlowDirection.Y);
wrapper.add(caption, 0);
} else {
wrapper.add(caption, new CC().alignY("top"));
}
impl.add(wrapper, layoutAdapter.getConstraints(component), index);
wrappers.put(component, new Pair<>(wrapper, adapter));
} else {
impl.add(composition, layoutAdapter.getConstraints(component), index);
}
if (component.getId() != null) {
componentByIds.put(component.getId(), component);
}
if (frame != null) {
if (component instanceof BelongToFrame && ((BelongToFrame) component).getFrame() == null) {
((BelongToFrame) component).setFrame(frame);
} else {
attachToFrame(component);
}
}
if (index == ownComponents.size()) {
ownComponents.add(component);
} else {
List<Component> componentsTempList = new ArrayList<>(ownComponents);
componentsTempList.add(index, component);
ownComponents.clear();
ownComponents.addAll(componentsTempList);
}
DesktopContainerHelper.assignContainer(component, this);
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
((DesktopAbstractComponent) component).setParentEnabled(false);
}
component.setParent(this);
requestContainerUpdate();
requestRepaint();
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class WebWindow method validateAll.
@Override
public boolean validateAll() {
ValidationErrors errors = new ValidationErrors();
Collection<Component> components = ComponentsHelper.getComponents(this);
for (Component component : components) {
if (component instanceof Validatable) {
Validatable validatable = (Validatable) component;
if (validatable.isValidateOnCommit()) {
try {
validatable.validate();
} catch (ValidationException e) {
if (log.isTraceEnabled())
log.trace("Validation failed", e);
else if (log.isDebugEnabled())
log.debug("Validation failed: " + e);
ComponentsHelper.fillErrorMessages(validatable, e, errors);
}
}
}
}
validateAdditionalRules(errors);
return handleValidationErrors(errors);
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class WebAbstractBox method removeAll.
@Override
public void removeAll() {
component.removeAllComponents();
Component[] components = ownComponents.toArray(new Component[ownComponents.size()]);
ownComponents.clear();
for (Component childComponent : components) {
childComponent.setParent(null);
}
}
Aggregations