Search in sources :

Example 21 with Window

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

the class ListPrintFormAction method printAll.

protected void printAll() {
    ContainerDataUnit unit = (ContainerDataUnit) target.getItems();
    CollectionContainer container = unit.getContainer();
    if (container instanceof CollectionPropertyContainer) {
        // as CollectionPropertyContainer does not have loader it always fetches all records,
        // so print these records as selected
        printSelected(new HashSet(container.getMutableItems()));
        return;
    }
    CollectionLoader loader = (CollectionLoader) ((HasLoader) unit.getContainer()).getLoader();
    MetaClass metaClass = container.getEntityMetaClass();
    LoadContext loadContext = loader.createLoadContext();
    ParameterPrototype parameterPrototype = new ParameterPrototype(metaClass.getName());
    parameterPrototype.setMetaClassName(metaClass.getName());
    LoadContext.Query query = loadContext.getQuery();
    parameterPrototype.setQueryString(query.getQueryString());
    parameterPrototype.setQueryParams(query.getParameters());
    parameterPrototype.setCondition(query.getCondition());
    parameterPrototype.setSort(query.getSort());
    if (!Strings.isNullOrEmpty(loadContext.getFetchPlan().getName())) {
        parameterPrototype.setFetchPlanName(loadContext.getFetchPlan().getName());
    } else {
        parameterPrototype.setFetchPlan(loadContext.getFetchPlan());
    }
    Window window = ComponentsHelper.getWindowNN(target);
    openRunReportScreen(window.getFrameOwner(), parameterPrototype, metaClass);
}
Also used : Window(io.jmix.ui.component.Window) ParameterPrototype(io.jmix.reports.app.ParameterPrototype) MetaClass(io.jmix.core.metamodel.model.MetaClass) LoadContext(io.jmix.core.LoadContext) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) HashSet(java.util.HashSet)

Example 22 with Window

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

the class MultipleResourcePolicyModelCreateScreen 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(COMMIT_ACTION_ID).withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(actionPerformedEvent -> {
        ValidationErrors validationErrors = validateScreen();
        if (!validationErrors.isEmpty()) {
            screenValidation.showValidationErrors(this, validationErrors);
        } else {
            close(new StandardCloseAction(COMMIT_ACTION_ID));
        }
    });
    window.addAction(commitAndCloseAction);
    Action closeAction = new BaseAction(CANCEL_ACTION_ID).withIcon(icons.get(JmixIcon.EDITOR_CANCEL)).withCaption(messages.getMessage("actions.Cancel")).withHandler(actionPerformedEvent -> close(new StandardCloseAction(CANCEL_ACTION_ID)));
    window.addAction(closeAction);
}
Also used : Window(io.jmix.ui.component.Window) StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Messages(io.jmix.core.Messages) UiScreenProperties(io.jmix.ui.UiScreenProperties) StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) ValidationErrors(io.jmix.ui.component.ValidationErrors) Icons(io.jmix.ui.icon.Icons) BaseAction(io.jmix.ui.action.BaseAction)

Example 23 with Window

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

the class ResetPasswordDialog method initScreenActions.

protected void initScreenActions() {
    Window window = getWindow();
    String commitShortcut = uiProperties.getCommitShortcut();
    Action commitAndCloseAction = new BaseAction(Window.COMMIT_ACTION_ID).withCaption(messages.getMessage("io.jmix.securityui.screen.resetpassword/ResetPasswordDialog.generateSave")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(actionPerformedEvent -> {
        Map<UserDetails, String> newPasswords = userManager.resetPasswords(users);
        StringBuilder builder = new StringBuilder();
        for (Map.Entry<UserDetails, String> entry : newPasswords.entrySet()) {
            builder.append(entry.getKey().getUsername()).append("\t").append(entry.getValue()).append("\n");
        }
        readyPassword.setValue(builder.toString());
        readyPassword.setVisible(true);
    });
    window.addAction(commitAndCloseAction);
    Action closeAction = new BaseAction(Window.CLOSE_ACTION_ID).withIcon(icons.get(JmixIcon.EDITOR_CANCEL)).withCaption(messages.getMessage("actions.Close")).withHandler(actionPerformedEvent -> close(new StandardCloseAction(Window.CLOSE_ACTION_ID)));
    window.addAction(closeAction);
}
Also used : Window(io.jmix.ui.component.Window) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) UserDetails(org.springframework.security.core.userdetails.UserDetails) BaseAction(io.jmix.ui.action.BaseAction) Map(java.util.Map)

Example 24 with Window

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

the class FilterUtils method generateFilterPath.

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

Example 25 with Window

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

the class EntityLinkFieldImpl method openEntityEditor.

protected void openEntityEditor() {
    V value = getValue();
    Object entity = null;
    if (value instanceof Entity) {
        entity = value;
    } else if (getValueSource() instanceof EntityValueSource) {
        entity = ((EntityValueSource) getValueSource()).getItem();
    }
    if (entity == null) {
        return;
    }
    Window window = ComponentsHelper.getWindow(this);
    if (window == null) {
        throw new IllegalStateException("Please specify Frame for EntityLinkField");
    }
    ScreenContext context = ComponentsHelper.getScreenContext(this);
    if (EntityValues.isSoftDeleted(entity)) {
        context.getNotifications().create(Notifications.NotificationType.HUMANIZED).withCaption(messages.getMessage("OpenAction.objectIsDeleted")).show();
        return;
    }
    DataManager dataManager = applicationContext.getBean(DataManager.class);
    entity = dataManager.load(Id.of(entity)).fetchPlan(applicationContext.getBean(FetchPlanRepository.class).getFetchPlan(entity.getClass(), FetchPlan.INSTANCE_NAME)).one();
    String windowAlias = screen;
    MetaClass metaClass = metadata.getClass(entity);
    if (windowAlias == null) {
        windowAlias = windowConfig.getEditorScreenId(metaClass);
    }
    Screen screenEditor = screenBuilders.editor(metaClass.getJavaClass(), window.getFrameOwner()).withScreenId(windowAlias).editEntity(entity).withOpenMode(screenOpenMode).withOptions(new MapScreenOptions(screenParams != null ? screenParams : new HashMap<>())).build();
    screenEditor.addAfterCloseListener(event -> {
        // move focus to component
        component.focus();
        String closeActionId = null;
        CloseAction closeAction = event.getCloseAction();
        if (closeAction instanceof StandardCloseAction) {
            closeActionId = ((StandardCloseAction) closeAction).getActionId();
        }
        Screen screenSource = null;
        if (StringUtils.isNotEmpty(closeActionId) && Window.COMMIT_ACTION_ID.equals(closeActionId)) {
            Object item = null;
            screenSource = event.getSource();
            if (screenSource instanceof EditorScreen) {
                item = ((EditorScreen) screenSource).getEditedEntity();
            }
            if (item != null) {
                afterCommitOpenedEntity(item);
            }
        }
        fireEditorCloseEvent(screenSource == null ? null : (EditorScreen) screenSource, closeActionId);
    });
    screenEditor.show();
}
Also used : Window(io.jmix.ui.component.Window) EntityValueSource(io.jmix.ui.component.data.meta.EntityValueSource) HashMap(java.util.HashMap) MetaClass(io.jmix.core.metamodel.model.MetaClass)

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