use of com.haulmont.cuba.gui.components.FilterImplementation in project cuba by cuba-platform.
the class FilterLoader method loadComponent.
@Override
public void loadComponent() {
assignXmlDescriptor(resultComponent, element);
assignFrame(resultComponent);
loadAlign(resultComponent, element);
loadVisible(resultComponent, element);
loadEnable(resultComponent, element);
loadStyleName(resultComponent, element);
loadMargin(resultComponent, element);
loadIcon(resultComponent, element);
loadCaption(resultComponent, element);
loadDescription(resultComponent, element);
loadWidth(resultComponent, element, "100%");
loadCollapsible(resultComponent, element, true);
loadSettingsEnabled(resultComponent, element);
loadBorderVisible(resultComponent, element);
String useMaxResults = element.attributeValue("useMaxResults");
resultComponent.setUseMaxResults(useMaxResults == null || Boolean.parseBoolean(useMaxResults));
String textMaxResults = element.attributeValue("textMaxResults");
resultComponent.setTextMaxResults(Boolean.parseBoolean(textMaxResults));
final String manualApplyRequired = element.attributeValue("manualApplyRequired");
resultComponent.setManualApplyRequired(BooleanUtils.toBooleanObject(manualApplyRequired));
String editable = element.attributeValue("editable");
resultComponent.setEditable(editable == null || Boolean.parseBoolean(editable));
String columnsCount = element.attributeValue("columnsCount");
if (!Strings.isNullOrEmpty(columnsCount)) {
resultComponent.setColumnsCount(Integer.parseInt(columnsCount));
}
String folderActionsEnabled = element.attributeValue("folderActionsEnabled");
if (folderActionsEnabled != null) {
resultComponent.setFolderActionsEnabled(Boolean.parseBoolean(folderActionsEnabled));
}
String datasource = element.attributeValue("datasource");
if (!StringUtils.isBlank(datasource)) {
CollectionDatasource ds = (CollectionDatasource) context.getDsContext().get(datasource);
if (ds == null) {
throw new GuiDevelopmentException("Can't find datasource by name: " + datasource, context.getCurrentFrameId());
}
resultComponent.setDatasource(ds);
}
Frame frame = context.getFrame();
String applyTo = element.attributeValue("applyTo");
if (!StringUtils.isEmpty(applyTo)) {
context.addPostInitTask((context1, window) -> {
Component c = frame.getComponent(applyTo);
if (c == null) {
throw new GuiDevelopmentException("Can't apply component to component with ID: " + applyTo, context1.getFullFrameId());
}
resultComponent.setApplyTo(c);
});
}
String modeSwitchVisible = element.attributeValue("modeSwitchVisible");
resultComponent.setModeSwitchVisible(modeSwitchVisible == null || Boolean.parseBoolean(modeSwitchVisible));
context.addPostInitTask((context1, window) -> {
((FilterImplementation) resultComponent).loadFiltersAndApplyDefault();
String defaultMode = element.attributeValue("defaultMode");
if (defaultMode != null && "fts".equals(defaultMode)) {
resultComponent.switchFilterMode(FilterDelegate.FilterMode.FTS_MODE);
}
});
}
Aggregations