Search in sources :

Example 1 with EditorScreen

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();
}
Also used : Entity(io.jmix.core.Entity) Table(io.jmix.ui.component.Table) Messages(io.jmix.core.Messages) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) Metadata(io.jmix.core.Metadata) OpenMode(io.jmix.ui.screen.OpenMode) ScreenContext(io.jmix.ui.screen.ScreenContext) MetaClass(io.jmix.core.metamodel.model.MetaClass) EditorScreen(io.jmix.ui.screen.EditorScreen) ScreenBuilders(io.jmix.ui.ScreenBuilders)

Example 2 with EditorScreen

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();
        }
    }
}
Also used : EditorScreen(io.jmix.ui.screen.EditorScreen) FilterCondition(io.jmix.ui.entity.FilterCondition) PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition)

Example 3 with EditorScreen

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);
}
Also used : EditorScreen(io.jmix.ui.screen.EditorScreen) LookupScreen(io.jmix.ui.screen.LookupScreen) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) ScreenEditorWrapper(com.haulmont.cuba.gui.screen.compatibility.ScreenEditorWrapper)

Example 4 with EditorScreen

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();
}
Also used : EntityInfoWindow(io.jmix.datatoolsui.screen.entityinfo.EntityInfoWindow) EditorScreen(io.jmix.ui.screen.EditorScreen) Screens(io.jmix.ui.Screens)

Example 5 with EditorScreen

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;
}
Also used : EditorScreen(io.jmix.ui.screen.EditorScreen) LookupScreen(io.jmix.ui.screen.LookupScreen) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions)

Aggregations

EditorScreen (io.jmix.ui.screen.EditorScreen)10 Screen (io.jmix.ui.screen.Screen)8 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)5 LookupScreen (io.jmix.ui.screen.LookupScreen)4 ScreenEditorWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenEditorWrapper)3 AbstractEditor (com.haulmont.cuba.gui.components.AbstractEditor)2 EntityLoadInfo (com.haulmont.cuba.core.global.EntityLoadInfo)1 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)1 Entity (io.jmix.core.Entity)1 Messages (io.jmix.core.Messages)1 Metadata (io.jmix.core.Metadata)1 Preconditions.checkNotEmptyString (io.jmix.core.common.util.Preconditions.checkNotEmptyString)1 MetaClass (io.jmix.core.metamodel.model.MetaClass)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 EntityInfoWindow (io.jmix.datatoolsui.screen.entityinfo.EntityInfoWindow)1 ScreenBuilders (io.jmix.ui.ScreenBuilders)1 Screens (io.jmix.ui.Screens)1 Table (io.jmix.ui.component.Table)1 Window (io.jmix.ui.component.Window)1 FilterCondition (io.jmix.ui.entity.FilterCondition)1