Search in sources :

Example 21 with GuiDevelopmentException

use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.

the class SideMenuLoader method loadSidePanel.

protected void loadSidePanel(SideMenu component, Element element) {
    String sidePanelId = element.attributeValue("sidePanel");
    if (StringUtils.isNotEmpty(sidePanelId)) {
        Component sidePanel = resultComponent.getFrame().getComponent(sidePanelId);
        if (sidePanel == null) {
            throw new GuiDevelopmentException("Unable to find sidePanel component for SideMenu", context.getFullFrameId(), "sidePanel", sidePanelId);
        }
        component.setSidePanel(sidePanel);
    }
}
Also used : GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) Component(com.haulmont.cuba.gui.components.Component)

Example 22 with GuiDevelopmentException

use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.

the class SideMenuLoader method loadSidePanelToggleButton.

protected void loadSidePanelToggleButton(SideMenu component, Element element) {
    String toggleButtonId = element.attributeValue("sidePanelToggleButton");
    if (StringUtils.isNotEmpty(toggleButtonId)) {
        Component toggleButton = resultComponent.getFrame().getComponent(toggleButtonId);
        if (!(toggleButton instanceof Button)) {
            throw new GuiDevelopmentException("Unable to find sidePanelToggleButton for SideMenu", context.getFullFrameId(), "sidePanelToggleButton", toggleButtonId);
        }
        component.setSidePanelToggleButton((Button) toggleButton);
    }
}
Also used : Button(com.haulmont.cuba.gui.components.Button) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) Component(com.haulmont.cuba.gui.components.Component)

Example 23 with GuiDevelopmentException

use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.

the class TokenListLoader method loadLookup.

protected void loadLookup(TokenList component, Element element) {
    Element lookupElement = element.element("lookup");
    if (lookupElement == null) {
        throw new GuiDevelopmentException("'tokenList' must contain 'lookup' element", context.getFullFrameId(), "TokenList ID", element.attributeValue("id"));
    }
    String optionsDatasource = lookupElement.attributeValue("optionsDatasource");
    if (!StringUtils.isEmpty(optionsDatasource)) {
        CollectionDatasource ds = (CollectionDatasource) context.getDsContext().get(optionsDatasource);
        component.setOptionsDatasource(ds);
    }
    String optionsCaptionProperty = lookupElement.attributeValue("captionProperty");
    if (!StringUtils.isEmpty(optionsCaptionProperty)) {
        component.setOptionsCaptionMode(CaptionMode.PROPERTY);
        component.setOptionsCaptionProperty(optionsCaptionProperty);
    }
    String lookup = lookupElement.attributeValue("lookup");
    if (StringUtils.isNotEmpty(lookup)) {
        component.setLookup(Boolean.parseBoolean(lookup));
        if (component.isLookup()) {
            String lookupScreen = lookupElement.attributeValue("lookupScreen");
            if (StringUtils.isNotEmpty(lookupScreen)) {
                component.setLookupScreen(lookupScreen);
            }
            String openType = lookupElement.attributeValue("openType");
            if (StringUtils.isNotEmpty(openType)) {
                component.setLookupOpenMode(OpenType.valueOf(openType));
            }
        }
    }
    String multiSelect = lookupElement.attributeValue("multiselect");
    if (StringUtils.isNotEmpty(multiSelect)) {
        component.setMultiSelect(Boolean.parseBoolean(multiSelect));
    }
    String inputPrompt = lookupElement.attributeValue("inputPrompt");
    if (StringUtils.isNotEmpty(inputPrompt)) {
        component.setLookupInputPrompt(loadResourceString(inputPrompt));
    }
    loadFilterMode(component, lookupElement);
}
Also used : CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Example 24 with GuiDevelopmentException

use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.

the class TokenListLoader method loadDatasource.

protected void loadDatasource(TokenList component, Element element) {
    final String datasource = element.attributeValue("datasource");
    if (!StringUtils.isEmpty(datasource)) {
        CollectionDatasource ds = (CollectionDatasource) context.getDsContext().get(datasource);
        if (ds == null) {
            throw new GuiDevelopmentException(String.format("Datasource '%s' is not defined", datasource), context.getFullFrameId());
        }
        component.setDatasource(ds);
    }
}
Also used : CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Example 25 with GuiDevelopmentException

use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.

the class WindowLoader method addInitTimerMethodTask.

protected void addInitTimerMethodTask(Timer timer, String timerMethodName) {
    context.addPostInitTask((windowContext, window) -> {
        Method timerMethod;
        try {
            timerMethod = window.getClass().getMethod(timerMethodName, Timer.class);
        } catch (NoSuchMethodException e) {
            throw new GuiDevelopmentException("Unable to find invoke method for timer", windowContext.getFullFrameId(), ParamsMap.of("Timer Id", timer.getId(), "Method name", timerMethodName));
        }
        timer.addActionListener(t -> {
            try {
                timerMethod.invoke(window, t);
            } catch (IllegalAccessException | InvocationTargetException e) {
                throw new RuntimeException("Unable to invoke onTimer", e);
            }
        });
    });
}
Also used : Timer(com.haulmont.cuba.gui.components.Timer) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)55 Element (org.dom4j.Element)23 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)8 Component (com.haulmont.cuba.gui.components.Component)7 Datasource (com.haulmont.cuba.gui.data.Datasource)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 MetaClass (com.haulmont.chile.core.model.MetaClass)5 ComponentLoader (com.haulmont.cuba.gui.xml.layout.ComponentLoader)4 MetaProperty (com.haulmont.chile.core.model.MetaProperty)3 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)3 CategoryAttribute (com.haulmont.cuba.core.entity.CategoryAttribute)3 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)3 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)3 LayoutLoader (com.haulmont.cuba.gui.xml.layout.LayoutLoader)3 FileDescriptor (com.haulmont.cuba.core.entity.FileDescriptor)2 WindowManager (com.haulmont.cuba.gui.WindowManager)2 Column (com.haulmont.cuba.gui.components.DataGrid.Column)2 ListComponent (com.haulmont.cuba.gui.components.ListComponent)2 DsContext (com.haulmont.cuba.gui.data.DsContext)2 ByteArrayDataProvider (com.haulmont.cuba.gui.export.ByteArrayDataProvider)2