@Override public void accept(String caption) { datasource.getItem().setValue(fieldName, caption); } }
public void setStencil(T stencil) { stencilDs.setItem(stencil); } }
@Override public void setBeanLocator(BeanLocator beanLocator) { MetaClass metaClass = datasource.getMetaClass(); MetadataTools metadataTools = beanLocator.get(MetadataTools.NAME); MetaPropertyPath metaPropertyPath = metadataTools.resolveMetaPropertyPath(metaClass, property); checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass); this.metaPropertyPath = metaPropertyPath; this.datasource.addStateChangeListener(this::datasourceStateChanged); this.datasource.addItemChangeListener(this::datasourceItemChanged); this.datasource.addItemPropertyChangeListener(this::datasourceItemPropertyChanged); if (datasource.getState() == Datasource.State.VALID) { setState(BindingState.ACTIVE); } }
protected Map<DataSupplier, Collection<Datasource<Entity>>> collectCommitData() { Collection<Datasource> datasources = new ArrayList<>(); for (DsContext childDsContext : children) { datasources.addAll(childDsContext.getAll()); } datasources.addAll(datasourceMap.values()); Map<DataSupplier, Collection<Datasource<Entity>>> commitDatasources = new HashMap<>(); for (Datasource datasource : datasources) { if (Datasource.CommitMode.DATASTORE == datasource.getCommitMode() && datasource.isAllowCommit() && (datasource.isModified() || !((DatasourceImplementation) datasource).getItemsToCreate().isEmpty())) { DataSupplier dataservice = datasource.getDataSupplier(); Collection<Datasource<Entity>> collection = commitDatasources.get(dataservice); if (collection == null) { collection = new ArrayList<>(); commitDatasources.put(dataservice, collection); } collection.add(datasource); } } return commitDatasources; }
@SuppressWarnings("unchecked") protected void setItemInternal(Entity item) { Datasource ds = getDatasourceInternal(); DataSupplier dataservice = ds.getDataSupplier(); if (dynamicAttributesGuiTools.screenContainsDynamicAttributes(ds.getView(), getFrame().getId())) { ds.setLoadDynamicAttributes(true); && parentDs instanceof CollectionDatasource && ((CollectionDatasource) parentDs).containsItem(item.getId()) && !entityStates.isLoadedWithView(item, ds.getView())) { item = dataservice.reload(item, ds.getView(), ds.getMetaClass(), ds.getLoadDynamicAttributes()); if (parentDs instanceof CollectionPropertyDatasourceImpl) { ((CollectionPropertyDatasourceImpl) parentDs).replaceItem(item); handlePreviouslyDeletedCompositionItems(item, parentDs); } else if (!PersistenceHelper.isNew(item)) { item = dataservice.reload(item, ds.getView(), ds.getMetaClass(), ds.getLoadDynamicAttributes()); && !ds.getMetaClass().equals(item.getMetaClass())) { Entity newItem = ds.getDataSupplier().newInstance(ds.getMetaClass()); MetadataTools metadataTools = getBeanLocator().get(MetadataTools.NAME); metadataTools.copy(item, newItem); if (ds.getLoadDynamicAttributes() && item instanceof BaseGenericIdEntity) { if (PersistenceHelper.isNew(item)) { dynamicAttributesGuiTools.initDefaultAttributeValues((BaseGenericIdEntity) item, item.getMetaClass()); ds.setItem(item);
dependFrom.addItemChangeListener(e -> { if (datasource.getState() == Datasource.State.VALID) { datasource.refresh(); datasource.refresh(); dependFrom.addItemPropertyChangeListener(e -> { if (propertyName != null) { final Entity item = Datasource.State.VALID.equals(dependFrom.getState()) ? dependFrom.getItem() : null; if (Objects.equals(item, e.getItem())) { datasource.refresh();
protected void commitAndClose() { if (delegate.isModified()) { if (!validateAll()) return; try { userProfile.updateProfile(userDs.getItem()); } catch (ValidationException e) { showNotification(e.getLocalizedMessage(), NotificationType.ERROR); return; } User newUser = userProfile.getProfile(); userDs.setItem(newUser); UserSession userSession = userSessionSource.getUserSession(); userSession.setUser(newUser); pushUserSessionUpdate(userSession); showNotification(getMessage("profile.commitSuccess"), NotificationType.HUMANIZED); } close(COMMIT_ACTION_ID); }
/** * Adds a listener that reloads the selected record with the specified view and sets it to editDs. */ @SuppressWarnings("unchecked") protected void initBrowseItemChangeListener() { CollectionDatasource browseDs = getTable().getDatasource(); Datasource editDs = getFieldGroup().getDatasource(); browseDs.addItemChangeListener(e -> { if (e.getItem() != null) { Entity reloadedItem = getDsContext().getDataSupplier().reload( e.getDs().getItem(), editDs.getView(), null, e.getDs().getLoadDynamicAttributes()); editDs.setItem(reloadedItem); } }); }
); mainDs.setLoadDynamicAttributes(true); mainDs.addStateChangeListener(e -> { if (e.getState() == State.VALID) { if (e.getPrevState() != State.VALID) { initMetaClass(mainDs.getItem()); } else { valid(); mainDs.addItemPropertyChangeListener(e -> { if ("category".equals(e.getProperty())) { categoryChanged = true; try { initMetaClass(mainDs.getItem()); } finally { categoryChanged = false; mainDs.addItemChangeListener(e -> initMetaClass(e.getItem()) );
@Override protected boolean preCommit() { //remove ds contexts from widget frames dashboardDs.getDsContext().getChildren().removeIf(dsContext -> !((dsContext.get("parametersDs") != null && dsContext.get("parametersDs").getMetaClass() != null && "dashboard$Parameter".equals(dsContext.get("parametersDs").getMetaClass().getName())) || (dsContext.get("widgetTemplatesDs") != null && dsContext.get("widgetTemplatesDs").getMetaClass() != null) && "dashboard$WidgetTemplate".equals(dsContext.get("widgetTemplatesDs").getMetaClass().getName()))); FieldGroup.FieldConfig assistantBeanName = fieldGroup2.getField("assistantBeanName"); LookupField lookupField = (LookupField) assistantBeanName.getComponent(); String val = lookupField.getValue(); dashboardDs.getItem().setAssistantBeanName(val); PersistentDashboard persDash = getItem(); Dashboard dashboard = getDashboard(); String jsonModel = converter.dashboardToJson(dashboard); persDash.setDashboardModel(jsonModel); persDash.setName(dashboard.getTitle()); persDash.setCode(dashboard.getCode()); persDash.setIsAvailableForAllUsers(dashboard.getIsAvailableForAllUsers()); return true; }
@Override public MetaClass resolveCategorizedEntityClass() { if (categorizedEntityClass == null) { return mainDs.getMetaClass(); } else { return categorizedEntityClass; } }
protected void initValidationScriptGroupBoxCaption() { setValidationScriptGroupBoxCaption(reportDs.getItem().getValidationOn()); reportDs.addItemPropertyChangeListener(e -> { boolean validationOnChanged = e.getProperty().equalsIgnoreCase("validationOn"); if (validationOnChanged) { setValidationScriptGroupBoxCaption(e.getItem().getValidationOn()); } }); }
protected Collection<T> getCollection() { Security security = AppBeans.get(Security.NAME); MetaClass parentMetaClass = masterDs.getMetaClass(); MetaClass propertyMetaClass = metaProperty.getRange().asClass(); if (!security.isEntityOpPermitted(propertyMetaClass, EntityOp.READ) || !security.isEntityAttrPermitted(parentMetaClass, metaProperty.getName(), EntityAttrAccess.VIEW)) { return new ArrayList<>(); // Don't use Collections.emptyList() to avoid confusing UnsupportedOperationExceptions } else { final Instance master = masterDs.getItem(); //noinspection unchecked return master == null ? null : (Collection<T>) master.getValue(metaProperty.getName()); } }
protected void uploadJson() { try (InputStream fileContent = importJsonField.getFileContent()) { String json = IOUtils.toString(Objects.requireNonNull(fileContent), UTF_8); Dashboard newDashboard = metadata.create(Dashboard.class); BeanUtils.copyProperties(converter.dashboardFromJson(json), newDashboard); dashboardDs.setItem(newDashboard); initParametersFrame(); initPaletteFrame(); canvasFrame.updateLayout(newDashboard); dashboardDs.refresh(); } catch (Exception e) { throw new DashboardException("Cannot import data from a file", e); } }
datasource.setup(dsContext, dataSupplier, metaClass.getName() + "Ds", metaClass, view); ((DatasourceImpl) datasource).valid(); datasource.setItem(instance); datasource.setAllowCommit(false);
@Override @SuppressWarnings("IncorrectCreateEntity") public void init(Map<String, Object> params) { super.init(params); dataGenerator = new RandomPivotTableDataGenerator(); PivotTableDescription description = createDefaultPivotTableDescription(); pivotTableDs.setItem(description); initAggregationTable(); initPropertyTable(); pivotTableDs.addItemPropertyChangeListener(e -> showPreview()); }
@Override public void committed(Set<Entity> entities) { Entity parentItem = masterDs.getItem(); boolean isModified = masterDs.isModified();
procInstanceDs.setItem(procInstance); procInstanceDs.setAllowCommit(false); procActorsDs.setAllowCommit(false); procAttachmentsDs.setAllowCommit(false);
@Override public State getState() { return masterDs.getState(); }