@Override public Entity getItem() { return ((EditorScreen) screen).getEditedEntity(); }
editorScreen.setEntityToEdit(entity); CloseAction closeAction = event.getCloseAction(); if (isCommitCloseAction(closeAction)) { E editedEntity = editorScreen.getEditedEntity();
protected Screen createEditor(WindowInfo windowInfo, NavigationState requestedState) { Map<String, Object> screenOptions = createEditorScreenOptions(windowInfo, requestedState); if (screenOptions.isEmpty()) { return null; } Screen editor; OpenMode openMode = getScreenOpenMode(requestedState.getNestedRoute(), windowInfo); if (LegacyFrame.class.isAssignableFrom(windowInfo.getControllerClass())) { editor = getScreens().create(windowInfo.getId(), openMode, new MapScreenOptions(screenOptions)); } else { editor = getScreens().create(windowInfo.getId(), openMode); } Entity entity = (Entity) screenOptions.get(WindowParams.ITEM.name()); //noinspection unchecked ((EditorScreen<Entity>) editor).setEntityToEdit(entity); return editor; }
@SuppressWarnings({"unchecked", "deprecation", "IncorrectCreateGuiComponent"}) @Override public 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 Window.Editor ? (Window.Editor) screen : new ScreenEditorWrapper(screen); }
protected <E extends Entity> E getCommittedEntity(EditorScreen<E> editorScreen, @Nullable DataContext parentDataContext) { E editedEntity = editorScreen.getEditedEntity(); if (parentDataContext != null) { E trackedEntity = parentDataContext.find(editedEntity); if (trackedEntity != null) // makes sense for NoopDataContext return trackedEntity; } return editedEntity; }
@SuppressWarnings({"unchecked", "deprecation", "IncorrectCreateGuiComponent"}) @Override public Window.Editor openEditor(WindowInfo windowInfo, Entity item, OpenType openType, 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; editorScreen.setEntityToEdit(item); show(screen); return screen instanceof Window.Editor ? (Window.Editor) screen : new ScreenEditorWrapper(screen); }
protected Map<String, String> buildParams(Screen screen, Map<String, String> urlParams) { String route = getRoute(screen); if (StringUtils.isEmpty(route) && (isEditor(screen) || MapUtils.isNotEmpty(urlParams))) { log.debug("There's no route for screen \"{}\". URL params will be ignored", screen.getId()); return Collections.emptyMap(); } if (omitParams(screen)) { return Collections.emptyMap(); } Map<String, String> params = new LinkedHashMap<>(); if (isEditor(screen)) { Object entityId = ((EditorScreen) screen).getEditedEntity().getId(); if (entityId != null) { String serializedId = UrlIdSerializer.serializeId(entityId); if (!"".equals(serializedId)) { params.put("id", serializedId); } } } params.putAll(urlParams != null ? urlParams : Collections.emptyMap()); return params; }
@SuppressWarnings({"unchecked", "deprecation", "IncorrectCreateGuiComponent"}) @Override public Window.Editor openEditor(WindowInfo windowInfo, Entity item, OpenType openType, Datasource parentDs) { 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; if (editorScreen instanceof AbstractEditor) { ((AbstractEditor) editorScreen).setParentDs(parentDs); } editorScreen.setEntityToEdit(item); show(screen); return screen instanceof Window.Editor ? (Window.Editor) screen : new ScreenEditorWrapper(screen); }
entity = ((EditorScreen) frameOwner).getEditedEntity();
@SuppressWarnings({"unchecked", "deprecation", "IncorrectCreateGuiComponent"}) @Override public Window.Editor openEditor(WindowInfo windowInfo, Entity item, OpenType openType, Map<String, Object> params, Datasource parentDs) { 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; if (editorScreen instanceof AbstractEditor) { ((AbstractEditor) editorScreen).setParentDs(parentDs); } editorScreen.setEntityToEdit(item); show(screen); return screen instanceof Window.Editor ? (Window.Editor) screen : new ScreenEditorWrapper(screen); }
@Override public void actionPerform(Component component) { if (beforeActionPerformedHandler != null) { if (!beforeActionPerformedHandler.beforeActionPerformed()) return; } Entity entity = editor.getEditedEntity(); if (entity != null) { MetaClass metaClass = entity.getMetaClass(); openRunReportScreen((Screen) editor, entity, metaClass, reportOutputName); } else { Messages messages = AppBeans.get(Messages.NAME); Notifications notifications = UiControllerUtils.getScreenContext((FrameOwner) editor).getNotifications(); notifications.create() .withCaption(messages.getMessage(ReportGuiManager.class, "notifications.noSelectedEntity")) .show(); } } }
public void saveScreenHistory(Screen frameOwner) { WindowContext windowContext = frameOwner.getWindow().getContext(); if (security.isEntityOpPermitted(ScreenHistoryEntity.class, EntityOp.CREATE) && (frameOwner instanceof EditorScreen) && windowContext.getLaunchMode() != OpenMode.DIALOG && (screenIds.contains(frameOwner.getId()))) { String caption = frameOwner.getWindow().getCaption(); UUID entityId = null; Entity entity = ((EditorScreen) frameOwner).getEditedEntity(); if (entity != null) { if (PersistenceHelper.isNew(entity)) { return; } if (StringUtils.isBlank(caption)) { caption = messages.getTools().getEntityCaption(entity.getMetaClass()) + " " + metadata.getTools().getInstanceName(entity); } entityId = (UUID) entity.getId(); } ScreenHistoryEntity screenHistoryEntity = metadata.create(ScreenHistoryEntity.class); screenHistoryEntity.setCaption(StringUtils.abbreviate(caption, 255)); screenHistoryEntity.setUrl(makeLink(frameOwner)); screenHistoryEntity.setEntityId(entityId); addAdditionalFields(screenHistoryEntity, entity); CommitContext cc = new CommitContext(Collections.singleton(screenHistoryEntity)); dataManager.commit(cc); } }
screenSource = event.getSource(); if (screenSource instanceof EditorScreen) { item = ((EditorScreen) screenSource).getEditedEntity();