Search in sources :

Example 16 with WindowConfig

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

the class FoldersBean method openFolder.

@Override
public void openFolder(AbstractSearchFolder folder) {
    if (StringUtils.isBlank(folder.getFilterComponentId())) {
        log.warn("Unable to open folder: componentId is blank");
        return;
    }
    String[] strings = ValuePathHelper.parse(folder.getFilterComponentId());
    String screenId = strings[0];
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(screenId);
    Map<String, Object> params = new HashMap<>();
    WindowParams.DISABLE_AUTO_REFRESH.set(params, true);
    WindowParams.DISABLE_RESUME_SUSPENDED.set(params, true);
    if (!StringUtils.isBlank(folder.getTabName())) {
        WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getTabName()));
    } else {
        WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getName()));
    }
    WindowParams.FOLDER_ID.set(params, folder.getId());
    com.haulmont.cuba.gui.components.Window window = App.getInstance().getWindowManager().openWindow(windowInfo, OpenType.NEW_TAB, params);
    Filter filterComponent = null;
    if (strings.length > 1) {
        String filterComponentId = StringUtils.join(Arrays.copyOfRange(strings, 1, strings.length), '.');
        filterComponent = (Filter) window.getComponentNN(filterComponentId);
        FilterEntity filterEntity = metadata.create(FilterEntity.class);
        filterEntity.setFolder(folder);
        filterEntity.setComponentId(folder.getFilterComponentId());
        filterEntity.setName(folder.getLocName());
        filterEntity.setXml(folder.getFilterXml());
        filterEntity.setApplyDefault(BooleanUtils.isNotFalse(folder.getApplyDefault()));
        if (folder instanceof SearchFolder) {
            filterEntity.setIsSet(((SearchFolder) folder).getIsSet());
        }
        filterComponent.setFilterEntity(filterEntity);
        filterComponent.switchFilterMode(FilterDelegate.FilterMode.GENERIC_MODE);
    }
    if (filterComponent != null && folder instanceof SearchFolder) {
        final SearchFolder searchFolder = (SearchFolder) folder;
        if (searchFolder.getPresentation() != null) {
            ((com.haulmont.cuba.gui.components.Component.HasPresentations) filterComponent.getApplyTo()).applyPresentation(searchFolder.getPresentation().getId());
        }
    }
    ((DsContextImplementation) window.getDsContext()).resumeSuspended();
}
Also used : DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) HashMap(java.util.HashMap) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) Filter(com.haulmont.cuba.gui.components.Filter)

Example 17 with WindowConfig

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

the class WebEntityLinkField method openEntityEditor.

protected void openEntityEditor() {
    Object value = getValue();
    Entity entity;
    if (value instanceof Entity) {
        entity = (Entity) value;
    } else {
        entity = datasource.getItem();
    }
    if (entity == null) {
        return;
    }
    WindowManager wm;
    Window window = ComponentsHelper.getWindow(this);
    if (window == null) {
        throw new IllegalStateException("Please specify Frame for EntityLinkField");
    } else {
        wm = window.getWindowManager();
    }
    if (screenOpenType.getOpenMode() == OpenMode.DIALOG && screenDialogParams != null) {
        wm.getDialogParams().copyFrom(screenDialogParams);
    }
    if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) {
        Messages messages = AppBeans.get(Messages.NAME);
        wm.showNotification(messages.getMainMessage("OpenAction.objectIsDeleted"), Frame.NotificationType.HUMANIZED);
        return;
    }
    DataSupplier dataSupplier = window.getDsContext().getDataSupplier();
    entity = dataSupplier.reload(entity, View.MINIMAL);
    String windowAlias = screen;
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    if (windowAlias == null) {
        windowAlias = windowConfig.getEditorScreenId(entity.getMetaClass());
    }
    final Window.Editor editor = wm.openEditor(windowConfig.getWindowInfo(windowAlias), entity, screenOpenType, screenParams != null ? screenParams : Collections.<String, Object>emptyMap());
    editor.addCloseListener(actionId -> {
        // move focus to component
        component.focus();
        if (Window.COMMIT_ACTION_ID.equals(actionId)) {
            Entity item = editor.getItem();
            afterCommitOpenedEntity(item);
        }
        if (screenCloseListener != null) {
            screenCloseListener.windowClosed(editor, actionId);
        }
    });
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) Entity(com.haulmont.cuba.core.entity.Entity) Messages(com.haulmont.cuba.core.global.Messages) SoftDelete(com.haulmont.cuba.core.entity.SoftDelete) DataSupplier(com.haulmont.cuba.gui.data.DataSupplier) WindowManager(com.haulmont.cuba.gui.WindowManager)

Example 18 with WindowConfig

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

the class WebFrame method openLookup.

@Override
public Window.Lookup openLookup(Class<? extends Entity> entityClass, Window.Lookup.Handler handler, WindowManager.OpenType openType, Map<String, Object> params) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo lookupScreen = windowConfig.getLookupScreen(entityClass);
    WebWindowManager wm = App.getInstance().getWindowManager();
    return wm.openLookup(lookupScreen, handler, openType, params);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindowManager(com.haulmont.cuba.web.WebWindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 19 with WindowConfig

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

the class WebFrame method openFrame.

@Override
public Frame openFrame(Component parent, String windowAlias, Map<String, Object> params) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    WebWindowManager wm = App.getInstance().getWindowManager();
    Frame wrappedFrame = ((Frame.Wrapper) wrapper).getWrappedFrame();
    return wm.openFrame(wrappedFrame, parent, windowInfo, params);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindowManager(com.haulmont.cuba.web.WebWindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 20 with WindowConfig

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

the class WebFrame method openEditor.

@Override
public Window.Editor openEditor(Entity item, WindowManager.OpenType openType) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo editorScreen = windowConfig.getEditorScreen(item);
    WebWindowManager wm = App.getInstance().getWindowManager();
    return wm.openEditor(editorScreen, item, openType);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindowManager(com.haulmont.cuba.web.WebWindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Aggregations

WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)27 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)20 WebWindowManager (com.haulmont.cuba.web.WebWindowManager)15 MetaClass (com.haulmont.chile.core.model.MetaClass)3 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)3 WindowManager (com.haulmont.cuba.gui.WindowManager)2 Window (com.haulmont.cuba.gui.components.Window)2 Element (org.dom4j.Element)2 ErrorInfo (org.jdesktop.swingx.error.ErrorInfo)2 ParamsMap (com.haulmont.bali.util.ParamsMap)1 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 Entity (com.haulmont.cuba.core.entity.Entity)1 SoftDelete (com.haulmont.cuba.core.entity.SoftDelete)1 Messages (com.haulmont.cuba.core.global.Messages)1 UiPermissionTarget (com.haulmont.cuba.gui.app.security.entity.UiPermissionTarget)1 Component (com.haulmont.cuba.gui.components.Component)1 Filter (com.haulmont.cuba.gui.components.Filter)1 ListComponent (com.haulmont.cuba.gui.components.ListComponent)1 RemoveAction (com.haulmont.cuba.gui.components.actions.RemoveAction)1 DataSupplier (com.haulmont.cuba.gui.data.DataSupplier)1