Search in sources :

Example 21 with DevelopmentException

use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.

the class ScreenFacetImpl method createScreen.

protected S createScreen(FrameOwner frameOwner) {
    S screen;
    Screens screens = UiControllerUtils.getScreenContext(frameOwner).getScreens();
    if (screenId != null) {
        screen = (S) screens.create(screenId, openMode, getScreenOptions());
    } else if (screenClass != null) {
        screen = screens.create(screenClass, openMode, getScreenOptions());
    } else {
        throw new DevelopmentException("Unable to open screen because no screen id or screen class are specified");
    }
    return screen;
}
Also used : Screens(io.jmix.ui.Screens) DevelopmentException(io.jmix.core.DevelopmentException)

Example 22 with DevelopmentException

use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.

the class DatasourceImpl method __setItem.

protected void __setItem(T item) {
    if (this.item != null) {
        detachListener(this.item);
    }
    if (item != null) {
        final MetaClass aClass = metadata.getClass(item);
        if (!aClass.equals(metaClass) && !metaClass.getDescendants().contains(aClass)) {
            throw new DevelopmentException(String.format("Invalid item metaClass '%s'", aClass), ParamsMap.of("datasource", getId(), "metaClass", aClass));
        }
        attachListener(item);
    }
    this.item = item;
    this.modified = false;
    clearCommitLists();
    if (item != null && PersistenceHelper.isNew(item)) {
        itemsToCreate.add(item);
        this.modified = true;
    }
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) DevelopmentException(io.jmix.core.DevelopmentException)

Example 23 with DevelopmentException

use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.

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(io.jmix.core.metamodel.model.MetaClass) DevelopmentException(io.jmix.core.DevelopmentException)

Example 24 with DevelopmentException

use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.

the class WebDataGrid method addGeneratedColumn.

@Override
public io.jmix.ui.component.DataGrid.Column<E> addGeneratedColumn(String columnId, GenericColumnGenerator<E, ?> generator) {
    io.jmix.ui.component.DataGrid.Column<E> column = getColumn(columnId);
    if (column == null) {
        throw new DevelopmentException("Unable to set ColumnGenerator for non-existing column: " + columnId);
    }
    Class<? extends Renderer> rendererType = null;
    Renderer renderer = column.getRenderer();
    if (renderer != null) {
        Class<?>[] rendererInterfaces = renderer.getClass().getInterfaces();
        rendererType = (Class<? extends Renderer>) Arrays.stream(rendererInterfaces).filter(Renderer.class::isAssignableFrom).findFirst().orElseThrow(() -> new DevelopmentException("Renderer should be specified explicitly for generated column: " + columnId));
    }
    io.jmix.ui.component.DataGrid.Column<E> generatedColumn = addGeneratedColumn(columnId, new ColumnGenerator<E, Object>() {

        @Override
        public Object getValue(ColumnGeneratorEvent<E> event) {
            return generator.getValue(event);
        }

        @Override
        public Class<Object> getType() {
            return ((DataGrid.Column) column).getGeneratedType();
        }
    });
    if (renderer != null) {
        generatedColumn.setRenderer(createRenderer(rendererType));
    }
    return column;
}
Also used : DataGrid(com.haulmont.cuba.gui.components.DataGrid) AbstractDataGrid(io.jmix.ui.component.impl.AbstractDataGrid) DevelopmentException(io.jmix.core.DevelopmentException)

Example 25 with DevelopmentException

use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.

the class DataManagerTest method testNonEntityResults.

@Test
public void testNonEntityResults() throws Exception {
    // fails on aggregates
    LoadContext context = LoadContext.create(Server.class).setQuery(LoadContext.createQuery("select count(s) from test$Server s"));
    try {
        dataManager.load(context);
        fail();
    } catch (Exception e) {
        assertTrue(e instanceof DevelopmentException);
    }
    // fails on single attributes
    context = LoadContext.create(Server.class).setQuery(LoadContext.createQuery("select s.name from test$Server s"));
    try {
        dataManager.load(context);
        fail();
    } catch (Exception e) {
        assertTrue(e instanceof DevelopmentException);
    }
}
Also used : Server(com.haulmont.cuba.core.model.common.Server) LoadContext(com.haulmont.cuba.core.global.LoadContext) DevelopmentException(io.jmix.core.DevelopmentException) DevelopmentException(io.jmix.core.DevelopmentException) CoreTest(com.haulmont.cuba.core.testsupport.CoreTest) Test(org.junit.jupiter.api.Test)

Aggregations

DevelopmentException (io.jmix.core.DevelopmentException)26 MetaClass (io.jmix.core.metamodel.model.MetaClass)10 MethodHandle (java.lang.invoke.MethodHandle)3 DataGrid (com.haulmont.cuba.gui.components.DataGrid)2 FetchPlanProperty (io.jmix.core.FetchPlanProperty)2 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)2 EditorBuilder (io.jmix.ui.builder.EditorBuilder)2 AbstractDataGrid (io.jmix.ui.component.impl.AbstractDataGrid)2 AnnotatedMethod (io.jmix.ui.sys.UiControllerReflectionInspector.AnnotatedMethod)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 Map (java.util.Map)2 NamePattern (com.haulmont.chile.core.annotations.NamePattern)1 LoadContext (com.haulmont.cuba.core.global.LoadContext)1 ViewBuilder (com.haulmont.cuba.core.global.ViewBuilder)1 Server (com.haulmont.cuba.core.model.common.Server)1 CoreTest (com.haulmont.cuba.core.testsupport.CoreTest)1 AbstractWindow (com.haulmont.cuba.gui.components.AbstractWindow)1 TreeDataGrid (com.haulmont.cuba.gui.components.TreeDataGrid)1 LegacyFragmentAdapter (com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter)1