Search in sources :

Example 1 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix-docs by Haulmont.

the class ValuePickerScreen method onInit.

// end::inject-valuePickerClearAction[]
// tag::onInit-start[]
@Subscribe
protected void onInit(InitEvent event) {
    // end::onInit-start[]
    // tag::base-action-value-picker[]
    ValuePicker valueField = uiComponents.create(ValuePicker.NAME);
    valueField.addAction(new BaseAction("hello") {

        @Override
        public String getCaption() {
            return null;
        }

        @Override
        public String getDescription() {
            return messageBundle.getMessage("helloDescription");
        }

        @Override
        public String getIcon() {
            return JmixIcon.HANDSHAKE_O.source();
        }

        @Override
        public void actionPerform(Component component) {
            notifications.create().withCaption("Hello!").withType(Notifications.NotificationType.TRAY).show();
        }
    });
    valueField.addAction(new BaseAction("goodbye").withCaption(null).withDescription(messageBundle.getMessage("goodbyeDescription")).withIcon(JmixIcon.HAND_PAPER_O.source()).withHandler(e -> notifications.create().withCaption("Goodbye!").withType(Notifications.NotificationType.TRAY).show()));
    vBox.add(valueField);
    // end::base-action-value-picker[]
    loginValuePicker.addAction(new BaseAction("showValue").withHandler(actionPerformedEvent -> {
        String value = loginValuePicker.getValue();
        notifications.create().withCaption(value != null ? value : "No value").show();
    }).withDescription("Show Value").withIcon(JmixIcon.EYE.source()));
    // tag::add-clear-action1[]
    loginValuePicker.addAction(actions.create(ValueClearAction.ID));
// end::add-clear-action1[]
// tag::onInit-end[]
}
Also used : ValuePicker(io.jmix.ui.component.ValuePicker) Dialogs(io.jmix.ui.Dialogs) Autowired(org.springframework.beans.factory.annotation.Autowired) ValuePicker(io.jmix.ui.component.ValuePicker) Notifications(io.jmix.ui.Notifications) JmixIcon(io.jmix.ui.icon.JmixIcon) Strings(com.google.common.base.Strings) Component(io.jmix.ui.component.Component) UiComponents(io.jmix.ui.UiComponents) ValueClearAction(io.jmix.ui.action.valuepicker.ValueClearAction) io.jmix.ui.screen(io.jmix.ui.screen) VBoxLayout(io.jmix.ui.component.VBoxLayout) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) RandomStringUtils(org.apache.commons.lang3.RandomStringUtils) Named(javax.inject.Named) DialogAction(io.jmix.ui.action.DialogAction) Actions(io.jmix.ui.Actions) BaseAction(io.jmix.ui.action.BaseAction) Component(io.jmix.ui.component.Component)

Example 2 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix-docs by Haulmont.

the class DataGridScreen method createCloseButton.

// end::details-generator[]
// tag::create-close-button[]
protected Component createCloseButton(Customer entity) {
    Button closeButton = uiComponents.create(Button.class);
    closeButton.setIcon("font-icon:TIMES");
    BaseAction closeAction = new BaseAction("closeAction").withHandler(actionPerformedEvent -> detailsGrid.setDetailsVisible(entity, false)).withCaption("");
    closeButton.setAction(closeAction);
    return closeButton;
}
Also used : CollectionLoader(io.jmix.ui.model.CollectionLoader) ValueSource(io.jmix.ui.component.data.ValueSource) ThemeClassNames(io.jmix.ui.theme.ThemeClassNames) CollectionContainer(io.jmix.ui.model.CollectionContainer) Date(java.util.Date) Collection(java.util.Collection) Autowired(org.springframework.beans.factory.annotation.Autowired) ContainerDataGridItems(io.jmix.ui.component.data.datagrid.ContainerDataGridItems) ExcelExportAction(io.jmix.uiexport.action.ExcelExportAction) Notifications(io.jmix.ui.Notifications) JmixIcon(io.jmix.ui.icon.JmixIcon) DateUtils(org.apache.commons.lang3.time.DateUtils) UiComponents(io.jmix.ui.UiComponents) Icons(io.jmix.ui.icon.Icons) io.jmix.ui.screen(io.jmix.ui.screen) ui.ex1.entity(ui.ex1.entity) Map(java.util.Map) BaseAction(io.jmix.ui.action.BaseAction) Named(javax.inject.Named) io.jmix.ui.component(io.jmix.ui.component) BaseAction(io.jmix.ui.action.BaseAction)

Example 3 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix-docs by Haulmont.

the class ActionScreen method onInit.

// end::inject-sayHelloBtn[]
// tag::on-init-start[]
@Subscribe
public void onInit(InitEvent event) {
    // end::on-init-start[]
    // tag::create-action-set[]
    createAction.setOpenMode(OpenMode.DIALOG);
    createAction.setScreenClass(CustomerEdit.class);
    // end::create-action-set[]
    // tag::edit-action-set[]
    editAction.setOpenMode(OpenMode.DIALOG);
    editAction.setScreenClass(CustomerEdit.class);
    // end::edit-action-set[]
    // tag::bulk-action-set[]
    custTableBulk.setOpenMode(OpenMode.THIS_TAB);
    custTableBulk.setIncludeProperties(Arrays.asList("rewardPoints", "email"));
    custTableBulk.setColumnsMode(ColumnsMode.ONE_COLUMN);
    // end::bulk-action-set[]
    // tag::remove-action-set[]
    removeAction.setConfirmation(true);
    removeAction.setConfirmationTitle("Removing customer...");
    removeAction.setConfirmationMessage("Do you really want to remove the customer?");
    // end::remove-action-set[]
    // tag::view-action-set[]
    viewAction.setOpenMode(OpenMode.DIALOG);
    viewAction.setScreenClass(CustomerEdit.class);
    // end::view-action-set[]
    // tag::tagLookup-action-set[]
    tagLookupAction.setOpenMode(OpenMode.DIALOG);
    tagLookupAction.setScreenClass(CustomerBrowse.class);
    // end::tagLookup-action-set[]
    // tag::base-action-button[]
    sayHelloBtn.setAction(new BaseAction("hello") {

        @Override
        public boolean isPrimary() {
            return true;
        }

        @Override
        public void actionPerform(Component component) {
            notifications.create().withCaption("Hello!").withType(Notifications.NotificationType.TRAY).show();
        }
    });
    sayGoodbyeBtn.setAction(new BaseAction("goodbye").withPrimary(true).withHandler(e -> notifications.create().withCaption("Goodbye!").withType(Notifications.NotificationType.TRAY).show()));
// end::base-action-button[]
// tag::on-init-end[]
}
Also used : CollectionLoader(io.jmix.ui.model.CollectionLoader) java.util(java.util) Customer(ui.ex1.entity.Customer) BulkEditors(io.jmix.ui.bulk.BulkEditors) Dialogs(io.jmix.ui.Dialogs) io.jmix.ui.action.list(io.jmix.ui.action.list) TagLookupAction(io.jmix.ui.action.tagpicker.TagLookupAction) Autowired(org.springframework.beans.factory.annotation.Autowired) Metadata(io.jmix.core.Metadata) ParamsMap(io.jmix.core.common.util.ParamsMap) CustomerEdit(ui.ex1.screen.entity.customer.CustomerEdit) ColumnsMode(io.jmix.ui.app.bulk.ColumnsMode) Notifications(io.jmix.ui.Notifications) io.jmix.ui.screen(io.jmix.ui.screen) ScreenBuilders(io.jmix.ui.ScreenBuilders) CustomerBrowse(ui.ex1.screen.entity.customer.CustomerBrowse) RemoveOperation(io.jmix.ui.RemoveOperation) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Named(javax.inject.Named) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) DialogAction(io.jmix.ui.action.DialogAction) io.jmix.ui.component(io.jmix.ui.component) BaseAction(io.jmix.ui.action.BaseAction)

Example 4 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class AbstractComponentLoader method loadDeclarativeActionDefault.

protected Action loadDeclarativeActionDefault(ActionsHolder actionsHolder, Element element) {
    String id = loadActionId(element);
    String trackSelection = element.attributeValue("trackSelection");
    boolean shouldTrackSelection = Boolean.parseBoolean(trackSelection);
    Action targetAction;
    if (shouldTrackSelection) {
        Actions actions = getActions();
        targetAction = actions.create(ItemTrackingAction.ID, id);
        loadActionConstraint(targetAction, element);
    } else {
        targetAction = new BaseAction(id);
    }
    initAction(element, targetAction);
    return targetAction;
}
Also used : Action(io.jmix.ui.action.Action) ItemTrackingAction(io.jmix.ui.action.ItemTrackingAction) BaseAction(io.jmix.ui.action.BaseAction) Actions(io.jmix.ui.Actions) BaseAction(io.jmix.ui.action.BaseAction)

Example 5 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class AbstractWindow method initEnableEditingActionStub.

protected void initEnableEditingActionStub() {
    String enableEditingActionId = "enableEditing";
    Action enableEditingAction = getAction(enableEditingActionId);
    if (enableEditingAction == null) {
        enableEditingAction = new BaseAction(enableEditingActionId).withCaption(messages.getMessage("actions.EnableEditing")).withHandler(actionPerformedEvent -> {
            // 'enableEditing' action stub, in order to prevent breaking changes.
            throw new IllegalStateException("Only io.jmix.ui.screen.ReadOnlyAwareScreen " + "inheritors must support the 'enableEditing' action");
        });
        enableEditingAction.setVisible(false);
        addAction(enableEditingAction);
    }
}
Also used : WindowManager(com.haulmont.cuba.gui.WindowManager) Autowired(org.springframework.beans.factory.annotation.Autowired) Frame(io.jmix.ui.component.Frame) HashMap(java.util.HashMap) ScreenSettings(com.haulmont.cuba.gui.screen.ScreenSettings) Component(io.jmix.ui.component.Component) Icons(io.jmix.ui.icon.Icons) Map(java.util.Map) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) DialogOptions(com.haulmont.cuba.gui.DialogOptions) DsContext(com.haulmont.cuba.gui.data.DsContext) Window(io.jmix.ui.component.Window) Nullable(javax.annotation.Nullable) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) Internal(io.jmix.core.annotation.Internal) Order(org.springframework.core.annotation.Order) Subscription(io.jmix.core.common.event.Subscription) Collection(java.util.Collection) JmixOrder(io.jmix.core.JmixOrder) Messages(com.haulmont.cuba.core.global.Messages) UnknownOperationResult(io.jmix.ui.util.UnknownOperationResult) Consumer(java.util.function.Consumer) Settings(com.haulmont.cuba.settings.Settings) List(java.util.List) io.jmix.ui.screen(io.jmix.ui.screen) Stream(java.util.stream.Stream) WindowInfo(io.jmix.ui.WindowInfo) CubaLegacySettings(com.haulmont.cuba.settings.CubaLegacySettings) Element(org.dom4j.Element) MessageTools(io.jmix.core.MessageTools) OperationResult(io.jmix.ui.util.OperationResult) UiScreenProperties(io.jmix.ui.UiScreenProperties) io.jmix.ui.component(io.jmix.ui.component) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) BaseAction(io.jmix.ui.action.BaseAction)

Aggregations

BaseAction (io.jmix.ui.action.BaseAction)49 Action (io.jmix.ui.action.Action)30 Autowired (org.springframework.beans.factory.annotation.Autowired)12 Icons (io.jmix.ui.icon.Icons)11 io.jmix.ui.screen (io.jmix.ui.screen)9 DialogAction (io.jmix.ui.action.DialogAction)8 Window (io.jmix.ui.component.Window)8 UiScreenProperties (io.jmix.ui.UiScreenProperties)7 io.jmix.ui.component (io.jmix.ui.component)7 JmixIcon (io.jmix.ui.icon.JmixIcon)7 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)6 Notifications (io.jmix.ui.Notifications)6 Component (io.jmix.ui.component.Component)6 Collection (java.util.Collection)6 Messages (io.jmix.core.Messages)5 UiComponents (io.jmix.ui.UiComponents)5 Nullable (javax.annotation.Nullable)5 Strings (com.google.common.base.Strings)4 Dialogs (io.jmix.ui.Dialogs)4 ItemTrackingAction (io.jmix.ui.action.ItemTrackingAction)4