Search in sources :

Example 1 with Window

use of io.jmix.ui.component.Window in project jmix by jmix-framework.

the class FilteringLookupAction method getFilterComponentPath.

public static String getFilterComponentPath(Filter filter) {
    StringBuilder sb = new StringBuilder(filter.getId() != null ? filter.getId() : "filterWithoutId");
    Frame frame = filter.getFrame();
    while (frame != null) {
        sb.insert(0, ".");
        String s = frame.getId() != null ? frame.getId() : "frameWithoutId";
        if (s.contains(".")) {
            s = "[" + s + "]";
        }
        sb.insert(0, s);
        if (frame instanceof Window) {
            break;
        }
        frame = frame.getFrame();
    }
    return sb.toString();
}
Also used : AbstractWindow(com.haulmont.cuba.gui.components.AbstractWindow) Window(io.jmix.ui.component.Window) Frame(io.jmix.ui.component.Frame)

Example 2 with Window

use of io.jmix.ui.component.Window in project jmix by jmix-framework.

the class NotFoundScreen method onInit.

@Subscribe
protected void onInit(InitEvent event) {
    Window window = getWindow();
    Label<String> msgLabel = uiComponents.create(Label.TYPE_STRING);
    msgLabel.setAlignment(Component.Alignment.TOP_CENTER);
    msgLabel.addStyleName(ThemeClassNames.LABEL_H1);
    msgLabel.setValue(messages.formatMessage("", "notAssociatedRoute", requestedRoute));
    window.add(msgLabel);
    window.setCaption(messages.formatMessage("", "tabCaption", requestedRoute));
}
Also used : Window(io.jmix.ui.component.Window) Subscribe(io.jmix.ui.screen.Subscribe)

Example 3 with Window

use of io.jmix.ui.component.Window in project jmix by jmix-framework.

the class SideMenuBuilder method build.

protected void build(SideMenu menu, List<MenuItem> rootItems) {
    Window window = ComponentsHelper.getWindowImplementation(menu);
    if (window == null) {
        throw new IllegalStateException("SideMenu is not belong to Window");
    }
    for (MenuItem menuItem : rootItems) {
        // AppMenu does not support separators
        UiMenuContext menuItemContext = new UiMenuContext(menuItem);
        accessManager.applyRegisteredConstraints(menuItemContext);
        if (menuItemContext.isPermitted() && !menuItem.isSeparator()) {
            createMenuBarItem(window, menu, menuItem);
        }
    }
    removeExtraSeparators(menu);
}
Also used : Window(io.jmix.ui.component.Window) UiMenuContext(io.jmix.ui.accesscontext.UiMenuContext)

Example 4 with Window

use of io.jmix.ui.component.Window in project jmix by jmix-framework.

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];
    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());
    WindowManager wm = windowManagerProvider.get();
    Window window = wm.openWindow(windowInfo, WindowManager.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) {
        SearchFolder searchFolder = (SearchFolder) folder;
        if (searchFolder.getPresentationId() != null) {
            ((HasTablePresentations) filterComponent.getApplyTo()).applyPresentation(searchFolder.getPresentationId());
        }
    }
    if (window.getFrameOwner() instanceof LegacyFrame) {
        DsContext dsContext = ((LegacyFrame) window.getFrameOwner()).getDsContext();
        if (dsContext != null) {
            ((DsContextImplementation) dsContext).resumeSuspended();
        }
    }
}
Also used : Window(io.jmix.ui.component.Window) DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) DsContext(com.haulmont.cuba.gui.data.DsContext) 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) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) WindowInfo(io.jmix.ui.WindowInfo) WindowManager(com.haulmont.cuba.gui.WindowManager) Filter(com.haulmont.cuba.gui.components.Filter) HasTablePresentations(io.jmix.ui.component.HasTablePresentations)

Example 5 with Window

use of io.jmix.ui.component.Window in project jmix by jmix-framework.

the class RoleAssignmentScreen method initScreenActions.

protected void initScreenActions() {
    Window window = getWindow();
    Messages messages = getApplicationContext().getBean(Messages.class);
    Icons icons = getApplicationContext().getBean(Icons.class);
    String commitShortcut = getApplicationContext().getBean(UiScreenProperties.class).getCommitShortcut();
    Action commitAndCloseAction = new BaseAction(Window.COMMIT_ACTION_ID).withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(actionPerformedEvent -> {
        // noinspection ConstantConditions
        getScreenData().getDataContext().commit();
        close(new StandardCloseAction(Window.COMMIT_ACTION_ID));
    });
    window.addAction(commitAndCloseAction);
    Action closeAction = new BaseAction(Window.CLOSE_ACTION_ID).withIcon(icons.get(JmixIcon.EDITOR_CANCEL)).withCaption(messages.getMessage("actions.Cancel")).withHandler(actionPerformedEvent -> {
        if (dataContext.hasChanges()) {
            screenValidation.showUnsavedChangesDialog(this, WINDOW_CLOSE_ACTION).onDiscard(() -> close(WINDOW_CLOSE_ACTION));
        } else {
            close(WINDOW_CLOSE_ACTION);
        }
    });
    window.addAction(closeAction);
}
Also used : Window(io.jmix.ui.component.Window) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Messages(io.jmix.core.Messages) UiScreenProperties(io.jmix.ui.UiScreenProperties) Icons(io.jmix.ui.icon.Icons) BaseAction(io.jmix.ui.action.BaseAction)

Aggregations

Window (io.jmix.ui.component.Window)29 FilterSelectWindow (com.haulmont.cuba.gui.components.filter.filterselect.FilterSelectWindow)5 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)4 FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)4 MetaClass (io.jmix.core.metamodel.model.MetaClass)4 Filter (com.haulmont.cuba.gui.components.Filter)3 Action (io.jmix.ui.action.Action)3 Component (io.jmix.ui.component.Component)3 HashMap (java.util.HashMap)3 WindowManager (com.haulmont.cuba.gui.WindowManager)2 AbstractCondition (com.haulmont.cuba.gui.components.filter.condition.AbstractCondition)2 DsContext (com.haulmont.cuba.gui.data.DsContext)2 DsContextImplementation (com.haulmont.cuba.gui.data.impl.DsContextImplementation)2 Messages (io.jmix.core.Messages)2 UiScreenProperties (io.jmix.ui.UiScreenProperties)2 WindowInfo (io.jmix.ui.WindowInfo)2 BaseAction (io.jmix.ui.action.BaseAction)2 Frame (io.jmix.ui.component.Frame)2 Screen (io.jmix.ui.screen.Screen)2 CubaProperties (com.haulmont.cuba.CubaProperties)1