use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class NotificationFacetImpl method subscribeOnAction.
protected void subscribeOnAction(Frame owner) {
Action action = ComponentsHelper.findAction(owner, actionId);
if (!(action instanceof BaseAction)) {
throw new GuiDevelopmentException(String.format("Unable to find Notification target action with id '%s'", actionId), owner.getId());
}
((BaseAction) action).addActionPerformedListener(e -> show());
}
use of io.jmix.ui.action.BaseAction in project jmix-docs by Haulmont.
the class TableScreen method onInit.
// end::inject-tableClick[]
// tag::onInit-start[]
@Subscribe
public void onInit(InitEvent event) {
// end::onInit-start[]
customersTable.addGeneratedColumn("aaa", entity -> null);
// tag::add-base-action[]
customersTable.addAction(new AboutSingleAction());
// end::add-base-action[]
// tag::add-ItemTrackingAction[]
customersTable.addAction(new ItemTrackingAction("about") {
@Nullable
@Override
public String getCaption() {
return "About";
}
@Override
public void actionPerform(Component component) {
notifications.create().withCaption("Hello " + customersTable.getSelected().iterator().next()).withType(Notifications.NotificationType.TRAY).show();
}
});
// end::add-ItemTrackingAction[]
// tag::table-set-style-name[]
tableBorderless.setStyleName(ThemeClassNames.TABLE_BORDERLESS);
// end::table-set-style-name[]
// tag::column-value-provider[]
printableTableExcelExport.addColumnValueProvider("firstName", context -> {
// <1>
Customer customer = context.getEntity();
return "Name: " + customer.getFirstName();
});
// end::column-value-provider[]
printableTableExcelExport.addColumnValueProvider("fullName", context -> {
Customer customer = context.getEntity();
return customer.getFirstName() + " " + customer.getLastName();
});
// tag::table-add-printable[]
/*printableTable.addPrintable("firstName", new Table.Printable<Customer, String>() {
@Override
public String getValue(Customer item) {
return "Name: " + item.getFirstName();
}
});*/
// end::table-add-printable[]
// tag::printable-column-generator[]
/*printableTable.addGeneratedColumn("fullName", new Table.PrintableColumnGenerator<Customer, String>() {
@Override
public String getValue(Customer item) {
return item.getFirstName() + " " + item.getLastName();
}
@Override
public Component generateCell(Customer entity) {
Label label = uiComponents.create(Label.NAME);
label.setValue(entity.getFirstName() + " " + entity.getLastName());
return label;
}
});*/
// end::printable-column-generator[]
// tag::item-click-action[]
tableClick.setItemClickAction(new BaseAction("itemClickAction").withHandler(actionPerformedEvent -> {
Customer customer = tableClick.getSingleSelected();
if (customer != null) {
notifications.create().withCaption("Item clicked for: " + customer.getFirstName() + "" + customer.getLastName()).show();
}
}));
// end::item-click-action[]
// tag::enter-press-action[]
tableClick.setEnterPressAction(new BaseAction("enterPressAction").withHandler(actionPerformedEvent -> {
Customer customer = tableClick.getSingleSelected();
if (customer != null) {
notifications.create().withCaption("Enter pressed for: " + customer.getFirstName() + "" + customer.getLastName()).show();
}
}));
// end::enter-press-action[]
// tag::programmatic-binding[]
customersTable1.setItems(new ContainerTableItems<>(customersDc));
// end::programmatic-binding[]
// tag::onInit-end[]
}
use of io.jmix.ui.action.BaseAction in project jmix-docs by Haulmont.
the class PopupButtonScreen method onInit.
// end::event[]
@Subscribe
protected void onInit(InitEvent event) {
// end::listener[]
popupButton.addAction(new BaseAction("saveAsDocAction").withCaption("Save as .doc").withHandler(actionPerformedEvent -> saveAsDoc()));
popupButton.addAction(new BaseAction("saveAsPdfAction").withCaption("Save as .pdf").withHandler(actionPerformedEvent -> saveAsPdf()));
// tag::listener[]
popupButton.addPopupVisibilityListener(popupVisibilityEvent -> notifications.create().withCaption("Popup visibility changed").show());
}
use of io.jmix.ui.action.BaseAction in project jmix-docs by Haulmont.
the class EntityPickerScreen method onInit.
// tag::on-init-start[]
@Subscribe
public void onInit(InitEvent event) {
// end::on-init-start[]
// tag::addAction2[]
entityPicker.addAction(actions.create(EntityOpenAction.class));
// end::addAction2[]
// tag::set-entity-lookup-action[]
entityLookupAction.setOpenMode(OpenMode.DIALOG);
entityLookupAction.setScreenClass(CustomerBrowse.class);
// end::set-entity-lookup-action[]
// tag::set-entity-open-action[]
openAction.setOpenMode(OpenMode.DIALOG);
openAction.setScreenClass(CustomerEdit.class);
// end::set-entity-open-action[]
// tag::add-custom-action[]
customerEp.addAction(new BaseAction("showLevel").withCaption(null).withDescription(null).withIcon(JmixIcon.VIEW_ACTION.source()).withHandler(e -> {
Customer customer = customerEp.getValue();
if (customer != null) {
notifications.create().withCaption(customer.getFirstName() + " " + customer.getLastName() + "'s level is " + customer.getLevel()).show();
} else {
notifications.create().withCaption("Choose a customer").show();
}
}));
// end::add-custom-action[]
// tag::userPicker3[]
EntityPicker<User> userPicker = uiComponents.create(EntityPicker.of(User.class));
userPicker.setMetaClass(metadata.getClass(User.class));
userPicker.addAction(actions.create(EntityLookupAction.class));
userPicker.addAction(actions.create(EntityOpenAction.class));
userPicker.addAction(actions.create(EntityClearAction.class));
vbox.add(userPicker);
// tag::on-init-end[]
}
use of io.jmix.ui.action.BaseAction in project jmix-docs by Haulmont.
the class AttachmentBrowse method attachmentsTableFileColumnGenerator.
@Install(to = "attachmentsTable.fileName", subject = "columnGenerator")
private Component attachmentsTableFileColumnGenerator(Attachment attachment) {
if (attachment.getFile() != null) {
LinkButton linkButton = uiComponents.create(LinkButton.class);
linkButton.setAction(new BaseAction("download").withCaption(attachment.getFile().getFileName()).withHandler(actionPerformedEvent -> downloader.download(attachment.getFile())));
return linkButton;
} else {
return new Table.PlainTextCell("<empty>");
}
}
Aggregations