use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.
the class LinkCellClickListener method accept.
@Override
public void accept(Table.Column.ClickEvent clickEvent) {
if (!clickEvent.isText()) {
return;
}
Table.Column<?> column = clickEvent.getSource();
Table owner = column.getOwner();
if (owner == null || owner.getFrame() == null) {
return;
}
Object rowItem = clickEvent.getItem();
MetaPropertyPath mpp = column.getMetaPropertyPathNN();
Object item = EntityValues.getValueEx(rowItem, mpp);
Entity entity;
if (EntityValues.isEntity(item)) {
entity = (Entity) item;
} else {
entity = (Entity) rowItem;
}
if (EntityValues.isSoftDeleted(entity)) {
ScreenContext context = ComponentsHelper.getScreenContext(owner);
context.getNotifications().create(Notifications.NotificationType.HUMANIZED).withCaption(applicationContext.getBean(Messages.class).getMessage("OpenAction.objectIsDeleted")).show();
return;
}
entity = loadEntity(entity);
MetaClass metaClass = applicationContext.getBean(Metadata.class).getClass(entity);
String linkScreenId = loadLinkScreenId(column, metaClass);
OpenMode openMode = loadLinkScreenOpenMode(column);
Screen editor = applicationContext.getBean(ScreenBuilders.class).editor(metaClass.getJavaClass(), owner.getFrame().getFrameOwner()).withScreenId(linkScreenId).editEntity(entity).withOpenMode(openMode).build();
editor.addAfterCloseListener(afterCloseEvent -> {
// move focus to component
owner.focus();
if (afterCloseEvent.closedWith(StandardOutcome.COMMIT) && editor instanceof EditorScreen) {
onEditScreenAfterCommit(mpp, rowItem, (EditorScreen) editor, owner);
}
});
editor.show();
}
use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.
the class LogicalFilterConditionEdit method editActionAfterCloseHandler.
protected void editActionAfterCloseHandler(AfterCloseEvent afterCloseEvent) {
Screen screen = afterCloseEvent.getSource();
if (afterCloseEvent.closedWith(StandardOutcome.COMMIT) && screen instanceof EditorScreen && getListComponent() != null) {
FilterCondition singleSelected = logicalFilterSupport.findSelectedConditionFromRootFilterCondition(getEditedEntity(), getListComponent().getSingleSelected());
if (singleSelected != null && singleSelected.getParent() instanceof LogicalFilterCondition) {
LogicalFilterCondition parent = (LogicalFilterCondition) singleSelected.getParent();
int index = parent.getOwnFilterConditions().indexOf(singleSelected);
FilterCondition editedCondition = (FilterCondition) ((EditorScreen<?>) screen).getEditedEntity();
parent.getOwnFilterConditions().set(index, editedCondition);
editedCondition.setParent(parent);
refreshChildrenConditions();
expandItems();
}
}
}
use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.
the class CubaScreens method openEditor.
@Override
public com.haulmont.cuba.gui.components.Window.Editor openEditor(WindowInfo windowInfo, Entity item, OpenType openType) {
Map<String, Object> params = createParametersMap(windowInfo, Collections.singletonMap(WindowParams.ITEM.name(), item));
MapScreenOptions options = new MapScreenOptions(params);
Screen screen = createScreen(windowInfo, openType.getOpenMode(), options);
applyOpenTypeParameters(screen.getWindow(), openType);
EditorScreen editorScreen = (EditorScreen) screen;
editorScreen.setEntityToEdit(item);
show(screen);
return screen instanceof com.haulmont.cuba.gui.components.Window.Editor ? (com.haulmont.cuba.gui.components.Window.Editor) screen : new ScreenEditorWrapper(screen);
}
use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.
the class EditorScreenShowEntityInfoAction method execute.
@Override
public void execute(Screen screen) {
if (!(screen instanceof EditorScreen)) {
throw new IllegalArgumentException("Screen must be instance of EditorScreen");
}
Object entity = ((EditorScreen<?>) screen).getEditedEntity();
Screens screens = UiControllerUtils.getScreenContext(screen).getScreens();
EntityInfoWindow infoWindow = screens.create(EntityInfoWindow.class);
infoWindow.setEntity(entity);
infoWindow.show();
}
use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.
the class CubaScreens method createEditor.
@Override
public Screen createEditor(WindowInfo windowInfo, Entity item, OpenType openType, @Nullable Map<String, Object> params) {
params = createParametersMap(windowInfo, params);
params.put(WindowParams.ITEM.name(), item);
MapScreenOptions options = new MapScreenOptions(params);
Screen screen = createScreen(windowInfo, openType.getOpenMode(), options);
applyOpenTypeParameters(screen.getWindow(), openType);
EditorScreen editorScreen = (EditorScreen) screen;
// noinspection unchecked
editorScreen.setEntityToEdit(item);
return screen;
}
Aggregations