Search in sources :

Example 11 with DevelopmentException

use of com.haulmont.cuba.core.global.DevelopmentException in project cuba by cuba-platform.

the class AbstractEditPresentationAction method createEditor.

protected PresentationEditor createEditor(Presentation presentation) {
    Class<? extends PresentationEditor> windowClass = getPresentationEditorClass();
    PresentationEditor window;
    try {
        Constructor<? extends PresentationEditor> windowConstructor = windowClass.getConstructor(Presentation.class, Component.HasPresentations.class);
        window = windowConstructor.newInstance(presentation, table);
    } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
        throw new DevelopmentException("Invalid presentation's screen");
    }
    return window;
}
Also used : PresentationEditor(com.haulmont.cuba.web.gui.components.presentations.PresentationEditor) Component(com.haulmont.cuba.gui.components.Component) InvocationTargetException(java.lang.reflect.InvocationTargetException) DevelopmentException(com.haulmont.cuba.core.global.DevelopmentException)

Example 12 with DevelopmentException

use of com.haulmont.cuba.core.global.DevelopmentException in project cuba by cuba-platform.

the class WebWindowManager method createTopLevelWindow.

public void createTopLevelWindow(WindowInfo windowInfo) {
    ui.beforeTopLevelWindowInit();
    String template = windowInfo.getTemplate();
    Window.TopLevelWindow topLevelWindow;
    Map<String, Object> params = Collections.emptyMap();
    if (template != null) {
        // noinspection unchecked
        topLevelWindow = (Window.TopLevelWindow) createWindow(windowInfo, OpenType.NEW_TAB, params, LayoutLoaderConfig.getWindowLoaders(), true);
    } else {
        Class screenClass = windowInfo.getScreenClass();
        if (screenClass != null) {
            // noinspection unchecked
            topLevelWindow = (Window.TopLevelWindow) createWindowByScreenClass(windowInfo, params);
        } else {
            throw new DevelopmentException("Unable to load top level window");
        }
    }
    // detect work area
    Window windowImpl = ((Window.Wrapper) topLevelWindow).getWrappedWindow();
    if (topLevelWindow instanceof AbstractMainWindow) {
        AbstractMainWindow mainWindow = (AbstractMainWindow) topLevelWindow;
        // bind system UI components to AbstractMainWindow
        ComponentsHelper.walkComponents(windowImpl, component -> {
            if (component instanceof AppWorkArea) {
                mainWindow.setWorkArea((AppWorkArea) component);
            } else if (component instanceof UserIndicator) {
                mainWindow.setUserIndicator((UserIndicator) component);
            } else if (component instanceof FoldersPane) {
                mainWindow.setFoldersPane((FoldersPane) component);
            }
            return false;
        });
    }
    ui.setTopLevelWindow(topLevelWindow);
    // load menu
    ComponentsHelper.walkComponents(windowImpl, component -> {
        if (component instanceof TopLevelWindowAttachListener) {
            ((TopLevelWindowAttachListener) component).topLevelWindowAttached(topLevelWindow);
        }
        return false;
    });
    if (topLevelWindow instanceof Window.HasWorkArea) {
        AppWorkArea workArea = ((Window.HasWorkArea) topLevelWindow).getWorkArea();
        if (workArea != null) {
            workArea.addStateChangeListener(new AppWorkArea.StateChangeListener() {

                @Override
                public void stateChanged(AppWorkArea.State newState) {
                    if (newState == AppWorkArea.State.WINDOW_CONTAINER) {
                        initTabShortcuts();
                        // listener used only once
                        getConfiguredWorkArea(createWorkAreaContext(topLevelWindow)).removeStateChangeListener(this);
                    }
                }
            });
        }
    }
    afterShowWindow(topLevelWindow);
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) FoldersPane(com.haulmont.cuba.gui.components.mainwindow.FoldersPane) TopLevelWindowAttachListener(com.haulmont.cuba.gui.components.mainwindow.TopLevelWindowAttachListener) DevelopmentException(com.haulmont.cuba.core.global.DevelopmentException) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) AppWorkArea(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea) UserIndicator(com.haulmont.cuba.gui.components.mainwindow.UserIndicator)

Example 13 with DevelopmentException

use of com.haulmont.cuba.core.global.DevelopmentException in project cuba by cuba-platform.

the class DsContextLoader method loadCollectionDatasource.

protected CollectionDatasource loadCollectionDatasource(Element element) {
    MetaClass metaClass = loadMetaClass(element);
    if (metaClass == null)
        throw new DevelopmentException("'class' attribute is not set for the datasource");
    initCollectionDatasourceAttributes(element, metaClass);
    CollectionDatasource datasource = builder.setDsClass(getDatasourceClass(element)).buildCollectionDatasource();
    String maxResults = element.attributeValue("maxResults");
    if (!StringUtils.isEmpty(maxResults))
        datasource.setMaxResults(Integer.parseInt(maxResults));
    if (datasource instanceof CollectionDatasource.Suspendable)
        ((CollectionDatasource.Suspendable) datasource).setSuspended(true);
    loadQuery(element, datasource);
    loadDatasources(element, datasource);
    return datasource;
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) DevelopmentException(com.haulmont.cuba.core.global.DevelopmentException)

Example 14 with DevelopmentException

use of com.haulmont.cuba.core.global.DevelopmentException in project cuba by cuba-platform.

the class DsContextLoader method loadGroupDatasource.

protected Datasource loadGroupDatasource(Element element) {
    MetaClass metaClass = loadMetaClass(element);
    if (metaClass == null)
        throw new DevelopmentException("'class' attribute is not set for the datasource");
    initCollectionDatasourceAttributes(element, metaClass);
    GroupDatasource datasource = builder.setDsClass(getDatasourceClass(element)).buildGroupDatasource();
    if (datasource instanceof CollectionDatasource.Suspendable)
        ((CollectionDatasource.Suspendable) datasource).setSuspended(true);
    loadQuery(element, datasource);
    loadDatasources(element, datasource);
    return datasource;
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) DevelopmentException(com.haulmont.cuba.core.global.DevelopmentException)

Example 15 with DevelopmentException

use of com.haulmont.cuba.core.global.DevelopmentException in project cuba by cuba-platform.

the class WebPickerField method checkDatasourceProperty.

public void checkDatasourceProperty(Datasource datasource, String property) {
    Preconditions.checkNotNullArgument(datasource);
    Preconditions.checkNotNullArgument(property);
    MetaPropertyPath metaPropertyPath = getResolvedMetaPropertyPath(datasource.getMetaClass(), property);
    if (!metaPropertyPath.getRange().isClass()) {
        throw new DevelopmentException(String.format("property '%s.%s' should have Entity type", datasource.getMetaClass().getName(), property));
    }
}
Also used : MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) DevelopmentException(com.haulmont.cuba.core.global.DevelopmentException)

Aggregations

DevelopmentException (com.haulmont.cuba.core.global.DevelopmentException)16 MetaClass (com.haulmont.chile.core.model.MetaClass)4 Element (org.dom4j.Element)3 InputStream (java.io.InputStream)2 Datatype (com.haulmont.chile.core.datatypes.Datatype)1 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 View (com.haulmont.cuba.core.global.View)1 ViewProperty (com.haulmont.cuba.core.global.ViewProperty)1 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)1 Component (com.haulmont.cuba.gui.components.Component)1 Window (com.haulmont.cuba.gui.components.Window)1 AppWorkArea (com.haulmont.cuba.gui.components.mainwindow.AppWorkArea)1 FoldersPane (com.haulmont.cuba.gui.components.mainwindow.FoldersPane)1 TopLevelWindowAttachListener (com.haulmont.cuba.gui.components.mainwindow.TopLevelWindowAttachListener)1 UserIndicator (com.haulmont.cuba.gui.components.mainwindow.UserIndicator)1 WebWindow (com.haulmont.cuba.web.gui.WebWindow)1 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)1 PresentationEditor (com.haulmont.cuba.web.gui.components.presentations.PresentationEditor)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1