use of io.jmix.ui.component.Window in project jmix by jmix-framework.
the class ListPrintFormAction method printAll.
protected void printAll() {
ContainerDataUnit unit = (ContainerDataUnit) target.getItems();
CollectionContainer container = unit.getContainer();
if (container instanceof CollectionPropertyContainer) {
// as CollectionPropertyContainer does not have loader it always fetches all records,
// so print these records as selected
printSelected(new HashSet(container.getMutableItems()));
return;
}
CollectionLoader loader = (CollectionLoader) ((HasLoader) unit.getContainer()).getLoader();
MetaClass metaClass = container.getEntityMetaClass();
LoadContext loadContext = loader.createLoadContext();
ParameterPrototype parameterPrototype = new ParameterPrototype(metaClass.getName());
parameterPrototype.setMetaClassName(metaClass.getName());
LoadContext.Query query = loadContext.getQuery();
parameterPrototype.setQueryString(query.getQueryString());
parameterPrototype.setQueryParams(query.getParameters());
parameterPrototype.setCondition(query.getCondition());
parameterPrototype.setSort(query.getSort());
if (!Strings.isNullOrEmpty(loadContext.getFetchPlan().getName())) {
parameterPrototype.setFetchPlanName(loadContext.getFetchPlan().getName());
} else {
parameterPrototype.setFetchPlan(loadContext.getFetchPlan());
}
Window window = ComponentsHelper.getWindowNN(target);
openRunReportScreen(window.getFrameOwner(), parameterPrototype, metaClass);
}
use of io.jmix.ui.component.Window in project jmix by jmix-framework.
the class MultipleResourcePolicyModelCreateScreen method initScreenActions.
protected void initScreenActions() {
Window window = getWindow();
Messages messages = getApplicationContext().getBean(Messages.class);
Icons icons = getApplicationContext().getBean(Icons.class);
String commitShortcut = getApplicationContext().getBean(UiScreenProperties.class).getCommitShortcut();
Action commitAndCloseAction = new BaseAction(COMMIT_ACTION_ID).withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(actionPerformedEvent -> {
ValidationErrors validationErrors = validateScreen();
if (!validationErrors.isEmpty()) {
screenValidation.showValidationErrors(this, validationErrors);
} else {
close(new StandardCloseAction(COMMIT_ACTION_ID));
}
});
window.addAction(commitAndCloseAction);
Action closeAction = new BaseAction(CANCEL_ACTION_ID).withIcon(icons.get(JmixIcon.EDITOR_CANCEL)).withCaption(messages.getMessage("actions.Cancel")).withHandler(actionPerformedEvent -> close(new StandardCloseAction(CANCEL_ACTION_ID)));
window.addAction(closeAction);
}
use of io.jmix.ui.component.Window in project jmix by jmix-framework.
the class ResetPasswordDialog method initScreenActions.
protected void initScreenActions() {
Window window = getWindow();
String commitShortcut = uiProperties.getCommitShortcut();
Action commitAndCloseAction = new BaseAction(Window.COMMIT_ACTION_ID).withCaption(messages.getMessage("io.jmix.securityui.screen.resetpassword/ResetPasswordDialog.generateSave")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(actionPerformedEvent -> {
Map<UserDetails, String> newPasswords = userManager.resetPasswords(users);
StringBuilder builder = new StringBuilder();
for (Map.Entry<UserDetails, String> entry : newPasswords.entrySet()) {
builder.append(entry.getKey().getUsername()).append("\t").append(entry.getValue()).append("\n");
}
readyPassword.setValue(builder.toString());
readyPassword.setVisible(true);
});
window.addAction(commitAndCloseAction);
Action closeAction = new BaseAction(Window.CLOSE_ACTION_ID).withIcon(icons.get(JmixIcon.EDITOR_CANCEL)).withCaption(messages.getMessage("actions.Close")).withHandler(actionPerformedEvent -> close(new StandardCloseAction(Window.CLOSE_ACTION_ID)));
window.addAction(closeAction);
}
use of io.jmix.ui.component.Window in project jmix by jmix-framework.
the class FilterUtils method generateFilterPath.
public static String generateFilterPath(Filter filter) {
StringBuilder sb = new StringBuilder();
Frame frame = filter.getFrame();
while (frame != null) {
String s = frame.getId() != null ? frame.getId() : "frameWithoutId";
s = "[" + s + "]";
sb.insert(0, s);
if (frame instanceof Window) {
break;
}
frame = frame.getFrame();
}
sb.append(".").append(filter.getId() != null ? filter.getId() : "filterWithoutId");
return sb.toString();
}
use of io.jmix.ui.component.Window in project jmix by jmix-framework.
the class EntityLinkFieldImpl method openEntityEditor.
protected void openEntityEditor() {
V value = getValue();
Object entity = null;
if (value instanceof Entity) {
entity = value;
} else if (getValueSource() instanceof EntityValueSource) {
entity = ((EntityValueSource) getValueSource()).getItem();
}
if (entity == null) {
return;
}
Window window = ComponentsHelper.getWindow(this);
if (window == null) {
throw new IllegalStateException("Please specify Frame for EntityLinkField");
}
ScreenContext context = ComponentsHelper.getScreenContext(this);
if (EntityValues.isSoftDeleted(entity)) {
context.getNotifications().create(Notifications.NotificationType.HUMANIZED).withCaption(messages.getMessage("OpenAction.objectIsDeleted")).show();
return;
}
DataManager dataManager = applicationContext.getBean(DataManager.class);
entity = dataManager.load(Id.of(entity)).fetchPlan(applicationContext.getBean(FetchPlanRepository.class).getFetchPlan(entity.getClass(), FetchPlan.INSTANCE_NAME)).one();
String windowAlias = screen;
MetaClass metaClass = metadata.getClass(entity);
if (windowAlias == null) {
windowAlias = windowConfig.getEditorScreenId(metaClass);
}
Screen screenEditor = screenBuilders.editor(metaClass.getJavaClass(), window.getFrameOwner()).withScreenId(windowAlias).editEntity(entity).withOpenMode(screenOpenMode).withOptions(new MapScreenOptions(screenParams != null ? screenParams : new HashMap<>())).build();
screenEditor.addAfterCloseListener(event -> {
// move focus to component
component.focus();
String closeActionId = null;
CloseAction closeAction = event.getCloseAction();
if (closeAction instanceof StandardCloseAction) {
closeActionId = ((StandardCloseAction) closeAction).getActionId();
}
Screen screenSource = null;
if (StringUtils.isNotEmpty(closeActionId) && Window.COMMIT_ACTION_ID.equals(closeActionId)) {
Object item = null;
screenSource = event.getSource();
if (screenSource instanceof EditorScreen) {
item = ((EditorScreen) screenSource).getEditedEntity();
}
if (item != null) {
afterCommitOpenedEntity(item);
}
}
fireEditorCloseEvent(screenSource == null ? null : (EditorScreen) screenSource, closeActionId);
});
screenEditor.show();
}
Aggregations