use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class AbstractEditor method initCommitActions.
protected void initCommitActions(@SuppressWarnings("unused") InitEvent event) {
Component commitAndCloseButton = ComponentsHelper.findComponent(getFrame(), WINDOW_COMMIT_AND_CLOSE);
UiScreenProperties screenProperties = getApplicationContext().getBean(UiScreenProperties.class);
boolean commitAndCloseButtonExists = false;
String commitShortcut = screenProperties.getCommitShortcut();
if (commitAndCloseButton != null) {
commitAndCloseButtonExists = true;
getFrame().addAction(new BaseAction(WINDOW_COMMIT_AND_CLOSE).withCaption(messages.getMessage("actions.SaveClose")).withPrimary(true).withShortcut(commitShortcut).withHandler(e -> commitAndClose()));
}
boolean finalCommitAndCloseButtonExists = commitAndCloseButtonExists;
Action commitAction = new BaseAction(WINDOW_COMMIT).withCaption(messages.getMessage(commitAndCloseButtonExists ? "actions.Save" : "actions.Ok")).withPrimary(!commitAndCloseButtonExists).withShortcut(commitAndCloseButtonExists ? null : commitShortcut).withHandler(e -> {
if (!finalCommitAndCloseButtonExists) {
commitAndClose();
} else {
if (commit()) {
commitActionPerformed = true;
}
}
});
getFrame().addAction(commitAction);
Action closeAction = new BaseAction(WINDOW_CLOSE).withCaption(messages.getMessage("actions.Cancel")).withHandler(e -> close(commitActionPerformed ? Window.COMMIT_ACTION_ID : getId()));
getFrame().addAction(closeAction);
Action enableEditingAction = new BaseAction(ENABLE_EDITING).withCaption(messages.getMessage("actions.EnableEditing")).withHandler(e -> setReadOnly(false));
enableEditingAction.setVisible(false);
getFrame().addAction(enableEditingAction);
}
use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class AttributeComponentProvider method addRow.
protected void addRow(Object value, ComponentContainer parent, boolean isReadOnly) {
BoxLayout row = uiComponents.create(HBoxLayout.class);
row.setSpacing(true);
row.setWidthFull();
TextField valueField = uiComponents.create(TextField.class);
valueField.setValue(value);
valueField.setEditable(!isReadOnly);
row.add(valueField);
row.expand(valueField);
Button btnRemove = uiComponents.create(Button.class);
btnRemove.setIconFromSet(JmixIcon.TIMES);
btnRemove.setDescription(messages.getMessage(getClass(), "editAttribute.array.btnRemove"));
Action removeRowAction = new BaseAction("removeRow").withCaption("").withHandler(actionPerformedEvent -> parent.remove(row));
removeRowAction.setEnabled(!isReadOnly);
btnRemove.setAction(removeRowAction);
row.add(btnRemove);
parent.add(row);
}
use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class SelectValueDialog method createEntityPicker.
protected Field createEntityPicker(MetaClass metaClass) {
EntityPicker<Object> entityPicker = uiComponents.create(EntityPicker.NAME);
entityPicker.setMetaClass(metaClass);
Actions actions = getApplicationContext().getBean(Actions.class);
BaseAction lookupAction = (BaseAction) actions.create(EntityLookupAction.ID);
lookupAction.addActionPerformedListener(this::lookupActionPerformed);
entityPicker.addAction(lookupAction);
return entityPicker;
}
use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class ScreensImpl method checkModificationsAndCloseAll.
/**
* Check modifications and close all screens in all main windows excluding root screens.
*
* @return operation result
*/
public OperationResult checkModificationsAndCloseAll() {
if (hasUnsavedChanges()) {
UnknownOperationResult result = new UnknownOperationResult();
ui.getDialogs().createOptionDialog().withCaption(messages.getMessage("closeUnsaved.caption")).withMessage(messages.getMessage("discardChangesOnClose")).withActions(new BaseAction("closeApplication").withCaption(messages.getMessage("closeApplication")).withIcon(icons.get(JmixIcon.DIALOG_OK)).withHandler(event -> {
ui.getApp().closeWindowsInternal(true);
result.success();
}), new DialogAction(DialogAction.Type.CANCEL, Action.Status.PRIMARY).withHandler(event -> result.fail())).show();
return result;
} else {
ui.getApp().closeWindowsInternal(true);
return OperationResult.success();
}
}
use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class SearchFieldImpl method initActions.
protected void initActions() {
removeAllActions();
BaseAction searchAction = new BaseAction("search").withHandler(actionPerformedEvent -> performSearch()).withIcon(JmixIcon.SEARCH.source()).withShortcut("ENTER");
addAction(searchAction);
}
Aggregations