use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class ContainerLoader method loadSubComponentsAndExpand.
protected void loadSubComponentsAndExpand(ExpandingLayout layout, Element element) {
loadSubComponents();
String expand = element.attributeValue("expand");
if (!StringUtils.isEmpty(expand)) {
String[] parts = expand.split(";");
String targetId = parts[0];
Component componentToExpand = layout.getOwnComponent(targetId);
if (componentToExpand != null) {
String height = find(parts, "height");
String width = find(parts, "width");
layout.expand(componentToExpand, height, width);
} else {
throw new GuiDevelopmentException("Illegal expand target '" + targetId + "' for container", context.getFullFrameId(), "component", targetId);
}
}
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class WebGridLayout method addLayoutClickListener.
@Override
public void addLayoutClickListener(LayoutClickListener listener) {
getEventRouter().addListener(LayoutClickListener.class, listener);
if (layoutClickListener == null) {
layoutClickListener = event -> {
Component childComponent = findChildComponent(event.getChildComponent());
MouseEventDetails mouseEventDetails = WebWrapperUtils.toMouseEventDetails(event);
LayoutClickEvent layoutClickEvent = new LayoutClickEvent(this, childComponent, mouseEventDetails);
getEventRouter().fireEvent(LayoutClickListener.class, LayoutClickListener::layoutClick, layoutClickEvent);
};
component.addLayoutClickListener(layoutClickListener);
}
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class WebGroupBox method removeAll.
@Override
public void removeAll() {
getComponentContent().removeAllComponents();
Component[] components = ownComponents.toArray(new Component[ownComponents.size()]);
ownComponents.clear();
for (Component childComponent : components) {
childComponent.setParent(null);
}
}
use of com.haulmont.cuba.gui.components.Component 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);
}
});
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class RelatedEntitiesLoader method loadComponent.
@Override
public void loadComponent() {
assignFrame(resultComponent);
loadCaption(resultComponent, element);
loadIcon(resultComponent, element);
loadWidth(resultComponent, element);
loadStyleName(resultComponent, element);
loadEnable(resultComponent, element);
loadVisible(resultComponent, element);
loadAlign(resultComponent, element);
String openType = element.attributeValue("openType");
if (StringUtils.isNotEmpty(openType)) {
resultComponent.setOpenType(OpenType.valueOf(openType));
}
String exclude = element.attributeValue("exclude");
if (StringUtils.isNotBlank(exclude)) {
resultComponent.setExcludePropertiesRegex(exclude);
}
for (Object routeObject : element.elements("property")) {
Element routeElement = (Element) routeObject;
String property = routeElement.attributeValue("name");
if (StringUtils.isEmpty(property)) {
throw new GuiDevelopmentException("Name attribute for related entities property is not specified", context.getFullFrameId(), "componentId", resultComponent.getId());
}
String caption = loadResourceString(routeElement.attributeValue("caption"));
String filterCaption = loadResourceString(routeElement.attributeValue("filterCaption"));
String screen = routeElement.attributeValue("screen");
if (StringUtils.isNotEmpty(screen)) {
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
if (windowConfig.findWindowInfo(screen) == null) {
throw new GuiDevelopmentException("Screen for custom route in related entities not found", context.getFullFrameId(), "componentId", resultComponent.getId());
}
}
resultComponent.addPropertyOption(property, screen, caption, filterCaption);
}
String listComponent = element.attributeValue("for");
if (StringUtils.isEmpty(listComponent)) {
throw new GuiDevelopmentException("'for' attribute of related entities is not specified", context.getFullFrameId(), "componentId", resultComponent.getId());
}
context.addPostInitTask((context1, window) -> {
if (resultComponent.getListComponent() == null) {
Component bindComponent = resultComponent.getFrame().getComponent(listComponent);
if (!(bindComponent instanceof ListComponent)) {
throw new GuiDevelopmentException("Specify 'for' attribute: id of table or tree", context1.getFullFrameId(), "componentId", resultComponent.getId());
}
resultComponent.setListComponent((ListComponent) bindComponent);
}
});
loadFocusable(resultComponent, element);
loadTabIndex(resultComponent, element);
}
Aggregations