use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.
the class ResetPasswordAction method execute.
/**
* Executes the action.
*/
@Override
public void execute() {
if (target == null) {
throw new IllegalStateException("Target is not set");
}
if (target.getFrame() == null) {
throw new IllegalStateException("Target frame is not set");
}
if (!(target.getItems() instanceof EntityDataUnit)) {
throw new IllegalStateException("Target dataSource is null or does not implement EntityDataUnit");
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
throw new IllegalStateException("Target is not bound to entity");
}
Object editedEntity = target.getSingleSelected();
if (editedEntity == null) {
throw new IllegalStateException("There is not selected item in ResetPassword target");
}
if (!(editedEntity instanceof UserDetails)) {
throw new IllegalStateException("Target does not implement a UserDetails");
}
buildAndShowResetPasswordDialog();
}
use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.
the class ResetRememberMeTokenAction method isPermitted.
@Override
protected boolean isPermitted() {
if (target == null || !(target.getItems() instanceof EntityDataUnit)) {
return false;
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
return true;
}
UiEntityContext entityContext = new UiEntityContext(metaClass);
accessManager.applyRegisteredConstraints(entityContext);
if (!entityContext.isEditPermitted()) {
return false;
}
return super.isPermitted();
}
use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.
the class ResetRememberMeTokenAction method execute.
@Override
public void execute() {
if (target == null) {
throw new IllegalStateException("Target is not set");
}
if (!(target.getItems() instanceof EntityDataUnit)) {
throw new IllegalStateException("Target dataSource is null or does not implement EntityDataUnit");
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
throw new IllegalStateException("Target is not bound to entity");
}
if (!(UserDetails.class.isAssignableFrom(metaClass.getJavaClass()))) {
throw new IllegalStateException("Target does not implement a UserDetails");
}
buildAndShowChangePasswordDialog();
}
use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.
the class ShowUserSubstitutionsAction method isPermitted.
@Override
protected boolean isPermitted() {
if (target == null || !(target.getItems() instanceof EntityDataUnit)) {
return false;
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
return true;
}
UiEntityContext entityContext = new UiEntityContext(metaClass);
accessManager.applyRegisteredConstraints(entityContext);
if (!entityContext.isViewPermitted()) {
return false;
}
UiEntityContext userSubstitutionContext = new UiEntityContext(metadata.getClass(UserSubstitutionEntity.class));
accessManager.applyRegisteredConstraints(userSubstitutionContext);
if (!userSubstitutionContext.isViewPermitted()) {
return false;
}
return super.isPermitted();
}
use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.
the class ScreenBuilders method lookup.
/**
* Creates a screen builder using list component.
* <p>
* Example of building a lookup screen for adding row to table / tree component:
* <pre>{@code
* SomeCustomerListScreen screen = screenBuilders.lookup(customersTable)
* .withScreen(SomeCustomerListScreen.class)
* .build();
* }</pre>
*
* @param listComponent {@link Table}, {@link DataGrid} or another component containing the list of entities
* @param <E> type of entity
* @see #lookup(Class, FrameOwner)
*/
public <E> LookupBuilder<E> lookup(ListComponent<E> listComponent) {
checkNotNullArgument(listComponent);
checkNotNullArgument(listComponent.getFrame());
FrameOwner frameOwner = listComponent.getFrame().getFrameOwner();
Class<E> entityClass;
DataUnit items = listComponent.getItems();
if (items instanceof EntityDataUnit) {
entityClass = ((EntityDataUnit) items).getEntityMetaClass().getJavaClass();
} else {
throw new IllegalStateException(String.format("Component %s is not bound to data", listComponent));
}
LookupBuilder<E> builder = new LookupBuilder<>(frameOwner, entityClass, lookupBuilderProcessor::buildLookup);
builder.withListComponent(listComponent);
return builder;
}
Aggregations