public void commitAndClose() { if (getDsContext().commit()) { saveFiles(); close(COMMIT_ACTION_ID); } }
public void onWindowCommit() { if (!validateAll()) { return; } getDsContext().commit(); procAttachmentsFrame.putFilesIntoStorage(); close(COMMIT_ACTION_ID); }
protected boolean commitInternal(boolean close) { if (!preCommit()) return false; boolean committed; DsContext context = getDsContext(); if (context != null) { committed = context.commit(); } else { DataSupplier supplier = getDataService(); supplier.commit(getItem()); committed = true; } return postCommit(committed, close); }
/** * Method that is invoked by clicking Ok button after editing an existing or creating a new record. */ @SuppressWarnings("unchecked") public void save() { if (!editing) return; FieldGroup fieldGroup = getFieldGroup(); List<Validatable> components = new ArrayList<>(); for (Component component: fieldGroup.getComponents()) { if (component instanceof Validatable) { components.add((Validatable)component); } } if (!validate(components)) { return; } getDsContext().commit(); ListComponent table = getTable(); CollectionDatasource browseDs = table.getDatasource(); Entity editedItem = fieldGroup.getDatasource().getItem(); if (creating) { browseDs.includeItem(editedItem); } else { browseDs.updateItem(editedItem); } table.setSelected(editedItem); releaseLock(); disableEditControls(); }
@Override public void actionPerform(Component component) { LoggedEntity selectedEntity = loggedEntityTable.getSelected().iterator().next(); Set<LoggedAttribute> enabledAttributes = selectedEntity.getAttributes(); for (Component c : attributesBoxScroll.getComponents()) { CheckBox currentCheckBox = (CheckBox) c; if (currentCheckBox.getId().equals(SELECT_ALL_CHECK_BOX)) continue; Boolean currentCheckBoxValue = currentCheckBox.getValue(); if (currentCheckBoxValue && !isEntityHaveAttribute(currentCheckBox.getId(), enabledAttributes)) { //add attribute if checked and not exist in table LoggedAttribute newLoggedAttribute = metadata.create(LoggedAttribute.class); newLoggedAttribute.setName(currentCheckBox.getId()); newLoggedAttribute.setEntity(selectedEntity); loggedAttrDs.addItem(newLoggedAttribute); } if (!currentCheckBoxValue && isEntityHaveAttribute(currentCheckBox.getId(), enabledAttributes)) { //remove attribute if unchecked and exist in table LoggedAttribute removeAtr = getLoggedAttribute(currentCheckBox.getId(), enabledAttributes); if (removeAtr != null) loggedAttrDs.removeItem(removeAtr); } } getDsContext().commit(); loggedEntityDs.refresh(); disableControls(); loggedEntityTable.setEnabled(true); loggedEntityTable.focus(); logService.invalidateCache(); } }