Search in sources :

Example 71 with Component

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);
        }
    }
}
Also used : GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) Component(com.haulmont.cuba.gui.components.Component)

Example 72 with Component

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);
    }
}
Also used : Component(com.haulmont.cuba.gui.components.Component)

Example 73 with Component

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);
    }
}
Also used : Component(com.haulmont.cuba.gui.components.Component)

Example 74 with Component

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);
        }
    });
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) Component(com.haulmont.cuba.gui.components.Component) FilterImplementation(com.haulmont.cuba.gui.components.FilterImplementation)

Example 75 with Component

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);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) ListComponent(com.haulmont.cuba.gui.components.ListComponent) ListComponent(com.haulmont.cuba.gui.components.ListComponent) Component(com.haulmont.cuba.gui.components.Component)

Aggregations

Component (com.haulmont.cuba.gui.components.Component)78 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)10 Datasource (com.haulmont.cuba.gui.data.Datasource)10 User (com.haulmont.cuba.security.entity.User)9 List (java.util.List)9 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)8 ArrayList (java.util.ArrayList)8 UUID (java.util.UUID)8 LookupPickerField (com.haulmont.cuba.gui.components.LookupPickerField)7 Group (com.haulmont.cuba.security.entity.Group)7 Assert.assertEquals (org.junit.Assert.assertEquals)7 Assert.assertNotNull (org.junit.Assert.assertNotNull)7 Assert.assertTrue (org.junit.Assert.assertTrue)7 Ignore (org.junit.Ignore)7 Test (org.junit.Test)7 Element (org.dom4j.Element)6 ButtonTabComponent (com.haulmont.cuba.desktop.sys.ButtonTabComponent)5 AbstractAction (com.haulmont.cuba.gui.components.AbstractAction)5 Frame (com.haulmont.cuba.gui.components.Frame)4 AbstractComponent (com.vaadin.ui.AbstractComponent)4