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;
}
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);
}
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;
}
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;
}
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));
}
}
Aggregations