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[]
}
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;
}
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[]
}
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;
}
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);
}
}
Aggregations