/** * Returns the table's data container. */ protected CollectionContainer<T> getBrowseContainer() { DataUnit items = getTable().getItems(); if (items instanceof ContainerDataUnit) return ((ContainerDataUnit<T>) items).getContainer(); else throw new UnsupportedOperationException("Unsupported items: " + items); }
/** * Disables edit controls. */ protected void disableEditControls() { this.editing = false; initEditComponents(false); ((Component.Focusable) getTable()).focus(); }
/** * Adds an EditAction that enables controls for editing. */ protected void initBrowseEditAction() { ListComponent<T> table = getTable(); EditAction editAction = (EditAction) table.getActionNN("edit"); editAction.withHandler(actionPerformedEvent -> { if (table.getSelected().size() == 1) { if (lockIfNeeded(table.getSingleSelected())) { refreshOptionsForLookupFields(); enableEditControls(false); } } }); editAction.addEnabledRule(() -> table.getSelected().size() == 1 && getBeanLocator().get(Security.class).isEntityOpPermitted(getEntityClass(), EntityOp.UPDATE)); }
/** * Method invoked when clicking on the Ok button after editing an existing or creating a new record. */ public void saveChanges() { if (!editing) return; ValidationErrors validationErrors = validateEditorForm(); if (!validationErrors.isEmpty()) { ScreenValidation screenValidation = getBeanLocator().get(ScreenValidation.class); screenValidation.showValidationErrors(this, validationErrors); return; } getScreenData().getDataContext().commit(); T editedItem = getEditContainer().getItem(); if (creating) { getBrowseContainer().getMutableItems().add(0, editedItem); } else { getBrowseContainer().replaceItem(editedItem); } getTable().setSelected(editedItem); releaseLock(); disableEditControls(); }
ListComponent<T> table = getTable(); CreateAction createAction = (CreateAction) table.getActionNN("create"); createAction.withHandler(actionPerformedEvent -> {