Search in sources :

Example 36 with Component

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

the class FilterSelectWindow method init.

@SuppressWarnings("unchecked")
@Override
public void init(Map<String, Object> params) {
    ThemeConstants theme = themeConstantsManager.getConstants();
    getDialogOptions().setHeight(theme.get("cuba.gui.filterSelect.dialog.height")).setWidth(theme.get("cuba.gui.filterSelect.dialog.width")).setResizable(true);
    filterEntitiesTable.addGeneratedColumn("name", entity -> {
        Label<String> label = componentsFactory.createComponent(Label.class);
        String caption;
        if (Strings.isNullOrEmpty(entity.getCode())) {
            caption = AppBeans.get(MetadataTools.class).getInstanceName(entity);
        } else {
            caption = messages.getMessage(entity.getCode());
        }
        label.setValue(caption);
        captionsMap.put(entity, caption);
        return label;
    });
    filterEntities = (List<FilterEntity>) params.get("filterEntities");
    fillDatasource(null);
    filterEntitiesTable.setItemClickAction(new AbstractAction("selectByDblClk") {

        @Override
        public void actionPerform(Component component) {
            select();
        }

        @Override
        public String getCaption() {
            return messages.getMessage("filter.filterSelect.select");
        }
    });
    FilterHelper filterHelper = AppBeans.get(FilterHelper.class);
    filterHelper.addTextChangeListener(nameFilterField, new FilterHelper.TextChangeListener() {

        @Override
        public void textChanged(String text) {
            fillDatasource(text);
        }
    });
}
Also used : ThemeConstants(io.jmix.ui.theme.ThemeConstants) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) Component(io.jmix.ui.component.Component) FilterHelper(com.haulmont.cuba.gui.components.filter.FilterHelper) AbstractAction(io.jmix.ui.action.AbstractAction)

Example 37 with Component

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

the class ExecutionHistoryAction method actionPerform.

@Override
public void actionPerform(Component component) {
    if (target != null && target.getFrame() != null) {
        MetaClass metaClass = null;
        DataUnit items = target.getItems();
        if (items instanceof EntityDataUnit) {
            metaClass = ((EntityDataUnit) items).getEntityMetaClass();
        }
        openLookup(target.getFrame().getFrameOwner(), metaClass);
    } else if (component instanceof Component.BelongToFrame) {
        FrameOwner screen = ComponentsHelper.getWindowNN((Component.BelongToFrame) component).getFrameOwner();
        openLookup(screen, null);
    } else {
        throw new IllegalStateException("No target screen or component found for 'ExecutionHistoryAction'");
    }
}
Also used : DataUnit(io.jmix.ui.component.data.DataUnit) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) MetaClass(io.jmix.core.metamodel.model.MetaClass) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) Component(io.jmix.ui.component.Component)

Example 38 with Component

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

the class ListPrintFormAction method actionPerform.

@Override
public void actionPerform(Component component) {
    DialogAction cancelAction = new DialogAction(DialogAction.Type.CANCEL);
    ScreenContext screenContext = ComponentsHelper.getScreenContext(target);
    Preconditions.checkState(screenContext != null, "Component is not attached to window");
    Dialogs dialogs = screenContext.getDialogs();
    Set selected = target.getSelected();
    if (CollectionUtils.isNotEmpty(selected)) {
        if (selected.size() > 1) {
            Action printSelectedAction = new AbstractAction("actions.printSelected", Status.PRIMARY) {

                @Override
                public void actionPerform(Component component) {
                    printSelected(selected);
                }
            };
            printSelectedAction.setIcon(JmixIcon.BARS.source());
            printSelectedAction.setCaption(messages.getMessage(getClass(), "actions.printSelected"));
            Action printAllAction = new AbstractAction("actions.printAll") {

                @Override
                public void actionPerform(Component component) {
                    printAll();
                }
            };
            printAllAction.setIcon(JmixIcon.TABLE.source());
            printAllAction.setCaption(messages.getMessage(getClass(), "actions.printAll"));
            dialogs.createOptionDialog().withCaption(messages.getMessage(getClass(), "notifications.confirmPrintSelectedHeader")).withMessage(messages.getMessage(getClass(), "notifications.confirmPrintSelected")).withActions(printAllAction, printSelectedAction, cancelAction).show();
        } else {
            printSelected(selected);
        }
    } else {
        if (isDataAvailable()) {
            Action yesAction = new DialogAction(DialogAction.Type.OK) {

                @Override
                public void actionPerform(Component component) {
                    printAll();
                }
            };
            cancelAction.setPrimary(true);
            dialogs.createOptionDialog().withCaption(messages.getMessage(getClass(), "notifications.confirmPrintAllheader")).withMessage(messages.getMessage(getClass(), "notifications.confirmPrintAll")).withActions(yesAction, cancelAction).show();
        } else {
            Notifications notifications = screenContext.getNotifications();
            notifications.create().withCaption(messages.getMessage(getClass(), "notifications.noSelectedEntity")).withType(Notifications.NotificationType.HUMANIZED).show();
        }
    }
}
Also used : Action(io.jmix.ui.action.Action) DialogAction(io.jmix.ui.action.DialogAction) AbstractPrintFormAction(io.jmix.reportsui.action.AbstractPrintFormAction) AbstractAction(io.jmix.ui.action.AbstractAction) StudioAction(io.jmix.ui.meta.StudioAction) ScreenContext(io.jmix.ui.screen.ScreenContext) HashSet(java.util.HashSet) Set(java.util.Set) Dialogs(io.jmix.ui.Dialogs) DialogAction(io.jmix.ui.action.DialogAction) ListComponent(io.jmix.ui.component.ListComponent) Component(io.jmix.ui.component.Component) AbstractAction(io.jmix.ui.action.AbstractAction) Notifications(io.jmix.ui.Notifications)

Example 39 with Component

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

the class SideMenuImpl method setSidePanelToggleButton.

@Override
public void setSidePanelToggleButton(@Nullable Button toggleButton) {
    if (this.toggleButton != null) {
        this.toggleButton.setAction(null);
    }
    if (toggleButton != null) {
        AbstractAction toggleAction = new AbstractAction("toggleSideMenu") {

            @Override
            public void actionPerform(Component component) {
                toggleSidePanel();
            }
        };
        toggleAction.setCaption(toggleButton.getCaption());
        toggleAction.setIcon(toggleButton.getIcon());
        toggleAction.setDescription(toggleButton.getDescription());
        toggleAction.setEnabled(toggleButton.isEnabled());
        toggleAction.setVisible(toggleButton.isVisible());
        toggleButton.setAction(toggleAction);
    }
    this.toggleButton = toggleButton;
}
Also used : AbstractComponent(io.jmix.ui.component.impl.AbstractComponent) Component(io.jmix.ui.component.Component) AbstractAction(io.jmix.ui.action.AbstractAction)

Example 40 with Component

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

the class InputDialogAction method actionPerform.

@Override
public void actionPerform(Component component) {
    if (eventHub != null) {
        InputDialog inputDialog = null;
        if (component instanceof Component.BelongToFrame) {
            Window window = ComponentsHelper.getWindow((Component.BelongToFrame) component);
            if (window != null) {
                inputDialog = (InputDialog) window.getFrameOwner();
            }
        }
        if (!validationRequired || (inputDialog != null && inputDialog.isValid())) {
            InputDialogActionPerformed event = new InputDialogActionPerformed(this, component, inputDialog);
            eventHub.publish(InputDialogActionPerformed.class, event);
        }
    }
}
Also used : Window(io.jmix.ui.component.Window) InputDialog(io.jmix.ui.app.inputdialog.InputDialog) Component(io.jmix.ui.component.Component)

Aggregations

Component (io.jmix.ui.component.Component)81 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)16 Datasource (com.haulmont.cuba.gui.data.Datasource)12 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)11 Test (org.junit.jupiter.api.Test)11 Element (org.dom4j.Element)10 Consumer (java.util.function.Consumer)9 ListComponent (com.haulmont.cuba.gui.components.ListComponent)8 MetaClass (io.jmix.core.metamodel.model.MetaClass)7 Action (io.jmix.ui.action.Action)7 HasValue (io.jmix.ui.component.HasValue)7 FrameOwner (io.jmix.ui.screen.FrameOwner)7 ArrayList (java.util.ArrayList)7 DatasourceImpl (com.haulmont.cuba.gui.data.impl.DatasourceImpl)6 FetchPlan (io.jmix.core.FetchPlan)6 UUID (java.util.UUID)6 Nullable (javax.annotation.Nullable)6 User (com.haulmont.cuba.core.model.common.User)5 DsBuilder (com.haulmont.cuba.gui.data.DsBuilder)5 Entity (io.jmix.core.Entity)5