Merge remote-tracking branch 'origin/master' into fix_migration_to_new_spring_boot_version_merge_master
Signed-off-by: Ammar Bikic <ammar.bikic@bosch.io>
This commit is contained in:
@@ -20,10 +20,9 @@
|
||||
<name>hawkBit :: Repository :: JPA Implementation</name>
|
||||
|
||||
<properties>
|
||||
<javassist.version>3.20.0-GA</javassist.version>
|
||||
<jaxb.api.version>2.3.0</jaxb.api.version>
|
||||
<javax.annotation.version>1.3.1</javax.annotation.version>
|
||||
<apt.source.dir>${project.build.directory}/generated-sources/apt/</apt.source.dir>
|
||||
<classgraph.version>4.8.90</classgraph.version>
|
||||
<eclipselink.maven.plugin.version>2.7.5.1</eclipselink.maven.plugin.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -97,7 +96,7 @@
|
||||
<plugin>
|
||||
<groupId>com.ethlo.persistence.tools</groupId>
|
||||
<artifactId>eclipselink-maven-plugin</artifactId>
|
||||
<version>2.7.1.1</version>
|
||||
<version>${eclipselink.maven.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>modelgen</id>
|
||||
@@ -118,25 +117,24 @@
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>${jaxb.api.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!--
|
||||
Required for Java 11 since plugin version is build on
|
||||
EclipseLink 2.7.5 (which doesn't have latest fixes for Java 11)
|
||||
-->
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
<artifactId>org.eclipse.persistence.jpa</artifactId>
|
||||
<version>${eclipselink.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>${javassist.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>${javax.annotation.version}</version>
|
||||
</dependency>
|
||||
<!--
|
||||
Required for Java 11 since plugin uses older version (4.8.21)
|
||||
which suffer from NPE while weaving. We require at least 4.8.48
|
||||
see: https://github.com/ethlo/eclipselink-maven-plugin/issues/31
|
||||
-->
|
||||
<groupId>io.github.classgraph</groupId>
|
||||
<artifactId>classgraph</artifactId>
|
||||
<version>${classgraph.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -161,7 +160,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
||||
@MapKeyColumn(name = "attribute_key", nullable = false, length = Target.CONTROLLER_ATTRIBUTE_KEY_SIZE)
|
||||
@CollectionTable(name = "sp_target_attributes", joinColumns = {
|
||||
@JoinColumn(name = "target_id", nullable = false, updatable = false) }, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target"))
|
||||
private final Map<String, String> controllerAttributes = Collections.synchronizedMap(new HashMap<String, String>());
|
||||
private Map<String, String> controllerAttributes;
|
||||
|
||||
// set default request controller attributes to true, because we want to
|
||||
// request them the first
|
||||
|
||||
@@ -153,7 +153,6 @@ public final class RSQLUtility {
|
||||
try {
|
||||
LOGGER.debug("parsing rsql string {}", rsql);
|
||||
final Set<ComparisonOperator> operators = RSQLOperators.defaultOperators();
|
||||
operators.add(new ComparisonOperator("=li=", false));
|
||||
return new RSQLParser(operators).parse(rsql);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
throw new RSQLParameterSyntaxException("rsql filter must not be null", e);
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsGridLayout;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleGridLayout;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtype.filter.SMTypeFilterLayout;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventViewAware;
|
||||
@@ -77,14 +78,17 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
|
||||
this.permChecker = permChecker;
|
||||
this.artifactUploadState = artifactUploadState;
|
||||
|
||||
final CommonUiDependencies uiDependencies = new CommonUiDependencies(i18n, entityFactory, eventBus, uiNotification,
|
||||
permChecker);
|
||||
|
||||
if (permChecker.hasReadRepositoryPermission()) {
|
||||
this.smTypeFilterLayout = new SMTypeFilterLayout(i18n, permChecker, eventBus, entityFactory, uiNotification,
|
||||
softwareModuleTypeManagement, artifactUploadState.getSmTypeFilterLayoutUiState());
|
||||
this.smGridLayout = new SoftwareModuleGridLayout(i18n, permChecker, uiNotification, eventBus,
|
||||
softwareModuleManagement, softwareModuleTypeManagement, entityFactory,
|
||||
artifactUploadState.getSmTypeFilterLayoutUiState(), artifactUploadState.getSmGridLayoutUiState());
|
||||
this.artifactDetailsGridLayout = new ArtifactDetailsGridLayout(i18n, eventBus, permChecker, uiNotification,
|
||||
artifactUploadState, artifactUploadState.getArtifactDetailsGridLayoutUiState(), artifactManagement,
|
||||
this.smTypeFilterLayout = new SMTypeFilterLayout(uiDependencies, softwareModuleTypeManagement,
|
||||
artifactUploadState.getSmTypeFilterLayoutUiState(), EventView.UPLOAD);
|
||||
this.smGridLayout = new SoftwareModuleGridLayout(uiDependencies, softwareModuleManagement,
|
||||
softwareModuleTypeManagement, artifactUploadState.getSmTypeFilterLayoutUiState(),
|
||||
artifactUploadState.getSmGridLayoutUiState());
|
||||
this.artifactDetailsGridLayout = new ArtifactDetailsGridLayout(uiDependencies, artifactUploadState,
|
||||
artifactUploadState.getArtifactDetailsGridLayoutUiState(), artifactManagement,
|
||||
softwareModuleManagement, multipartConfigElement);
|
||||
|
||||
final Map<EventLayout, VisibilityHandler> layoutVisibilityHandlers = new EnumMap<>(EventLayout.class);
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
|
||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.ArtifactToProxyArtifactMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.ArtifactDataProvider;
|
||||
@@ -33,8 +33,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.icons.VaadinIcons;
|
||||
import com.vaadin.server.FileDownloader;
|
||||
@@ -65,23 +63,15 @@ public class ArtifactDetailsGrid extends AbstractGrid<ProxyArtifact, Long> {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permissionChecker
|
||||
* SpPermissionChecker
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param artifactManagement
|
||||
* ArtifactManagement
|
||||
*/
|
||||
public ArtifactDetailsGrid(final UIEventBus eventBus, final VaadinMessageSource i18n,
|
||||
final SpPermissionChecker permissionChecker, final UINotification notification,
|
||||
final ArtifactManagement artifactManagement) {
|
||||
super(i18n, eventBus, permissionChecker);
|
||||
public ArtifactDetailsGrid(final CommonUiDependencies uiDependencies, final ArtifactManagement artifactManagement) {
|
||||
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
|
||||
|
||||
this.notification = notification;
|
||||
this.notification = uiDependencies.getUiNotification();
|
||||
this.artifactManagement = artifactManagement;
|
||||
|
||||
this.artifactDeleteSupport = new DeleteSupport<>(this, i18n, notification, "artifact.details.header",
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.details;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.event.CommandTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
@@ -19,8 +20,6 @@ import org.eclipse.hawkbit.ui.common.grid.header.support.ResizeHeaderSupport;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Header for ArtifactDetails with maximize-support.
|
||||
@@ -35,16 +34,14 @@ public class ArtifactDetailsGridHeader extends AbstractMasterAwareGridHeader<Pro
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param artifactDetailsGridLayoutUiState
|
||||
* ArtifactDetailsGridLayoutUiState
|
||||
* ArtifactDetailsGridLayoutUiState
|
||||
*/
|
||||
public ArtifactDetailsGridHeader(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
public ArtifactDetailsGridHeader(final CommonUiDependencies uiDependencies,
|
||||
final ArtifactDetailsGridLayoutUiState artifactDetailsGridLayoutUiState) {
|
||||
super(i18n, null, eventBus);
|
||||
super(uiDependencies.getI18n(), uiDependencies.getPermChecker(), uiDependencies.getEventBus());
|
||||
|
||||
this.artifactDetailsGridLayoutUiState = artifactDetailsGridLayoutUiState;
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ import javax.servlet.MultipartConfigElement;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.artifacts.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.artifacts.upload.FileUploadProgress;
|
||||
import org.eclipse.hawkbit.ui.artifacts.upload.UploadDropAreaLayout;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayoutViewAware;
|
||||
@@ -28,9 +28,6 @@ import org.eclipse.hawkbit.ui.common.layout.AbstractGridComponentLayout;
|
||||
import org.eclipse.hawkbit.ui.common.layout.MasterEntityAwareComponent;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.GenericEventListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.SelectionChangedListener;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Display the details of the artifacts for a selected software module.
|
||||
@@ -48,38 +45,29 @@ public class ArtifactDetailsGridLayout extends AbstractGridComponentLayout {
|
||||
/**
|
||||
* Constructor for ArtifactDetailsLayout
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param artifactUploadState
|
||||
* ArtifactUploadState
|
||||
* ArtifactUploadState
|
||||
* @param artifactDetailsGridLayoutUiState
|
||||
* ArtifactDetailsGridLayoutUiState
|
||||
* ArtifactDetailsGridLayoutUiState
|
||||
* @param artifactManagement
|
||||
* ArtifactManagement
|
||||
* ArtifactManagement
|
||||
* @param softwareManagement
|
||||
* SoftwareModuleManagement
|
||||
* SoftwareModuleManagement
|
||||
* @param multipartConfigElement
|
||||
* MultipartConfigElement
|
||||
* MultipartConfigElement
|
||||
*/
|
||||
public ArtifactDetailsGridLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final SpPermissionChecker permChecker, final UINotification notification,
|
||||
final ArtifactUploadState artifactUploadState,
|
||||
public ArtifactDetailsGridLayout(final CommonUiDependencies uiDependencies, final ArtifactUploadState artifactUploadState,
|
||||
final ArtifactDetailsGridLayoutUiState artifactDetailsGridLayoutUiState,
|
||||
final ArtifactManagement artifactManagement, final SoftwareModuleManagement softwareManagement,
|
||||
final MultipartConfigElement multipartConfigElement) {
|
||||
this.artifactDetailsHeader = new ArtifactDetailsGridHeader(i18n, eventBus, artifactDetailsGridLayoutUiState);
|
||||
this.artifactDetailsGrid = new ArtifactDetailsGrid(eventBus, i18n, permChecker, notification,
|
||||
artifactManagement);
|
||||
this.artifactDetailsHeader = new ArtifactDetailsGridHeader(uiDependencies, artifactDetailsGridLayoutUiState);
|
||||
this.artifactDetailsGrid = new ArtifactDetailsGrid(uiDependencies, artifactManagement);
|
||||
|
||||
if (permChecker.hasCreateRepositoryPermission()) {
|
||||
this.uploadDropAreaLayout = new UploadDropAreaLayout(i18n, eventBus, notification, artifactUploadState,
|
||||
multipartConfigElement, softwareManagement, artifactManagement);
|
||||
if (uiDependencies.getPermChecker().hasCreateRepositoryPermission()) {
|
||||
this.uploadDropAreaLayout = new UploadDropAreaLayout(uiDependencies, artifactUploadState, multipartConfigElement,
|
||||
softwareManagement, artifactManagement);
|
||||
|
||||
buildLayout(artifactDetailsHeader, artifactDetailsGrid, uploadDropAreaLayout);
|
||||
} else {
|
||||
@@ -89,10 +77,10 @@ public class ArtifactDetailsGridLayout extends AbstractGridComponentLayout {
|
||||
}
|
||||
|
||||
final EventLayoutViewAware masterLayoutView = new EventLayoutViewAware(EventLayout.SM_LIST, EventView.UPLOAD);
|
||||
this.selectionChangedListener = new SelectionChangedListener<>(eventBus, masterLayoutView,
|
||||
this.selectionChangedListener = new SelectionChangedListener<>(uiDependencies.getEventBus(), masterLayoutView,
|
||||
getMasterEntityAwareComponents());
|
||||
this.fileUploadChangedListener = new GenericEventListener<>(eventBus, EventTopics.FILE_UPLOAD_CHANGED,
|
||||
this::onUploadChanged);
|
||||
this.fileUploadChangedListener = new GenericEventListener<>(uiDependencies.getEventBus(),
|
||||
EventTopics.FILE_UPLOAD_CHANGED, this::onUploadChanged);
|
||||
}
|
||||
|
||||
private List<MasterEntityAwareComponent<ProxySoftwareModule>> getMasterEntityAwareComponents() {
|
||||
@@ -103,7 +91,7 @@ public class ArtifactDetailsGridLayout extends AbstractGridComponentLayout {
|
||||
* Checks progress on file upload
|
||||
*
|
||||
* @param fileUploadProgress
|
||||
* FileUploadProgress
|
||||
* FileUploadProgress
|
||||
*/
|
||||
public void onUploadChanged(final FileUploadProgress fileUploadProgress) {
|
||||
if (uploadDropAreaLayout != null) {
|
||||
|
||||
@@ -8,59 +8,38 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleCreate;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractAddNamedEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.SoftwareModuleToProxyMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.event.CommandTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.SelectionChangedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.SelectionChangedEventPayload.SelectionChangedEventType;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Controller for populating and saving data in Add Software Module Window.
|
||||
*/
|
||||
public class AddSmWindowController extends AbstractEntityWindowController<ProxySoftwareModule, ProxySoftwareModule> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AddSmWindowController.class);
|
||||
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
public class AddSmWindowController
|
||||
extends AbstractAddNamedEntityWindowController<ProxySoftwareModule, ProxySoftwareModule, SoftwareModule> {
|
||||
|
||||
private final SoftwareModuleManagement smManagement;
|
||||
|
||||
private final SmWindowLayout layout;
|
||||
|
||||
private final EventView view;
|
||||
private final ProxySmValidator validator;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smManagement
|
||||
* SoftwareModuleManagement
|
||||
* @param layout
|
||||
@@ -68,26 +47,18 @@ public class AddSmWindowController extends AbstractEntityWindowController<ProxyS
|
||||
* @param view
|
||||
* EventView
|
||||
*/
|
||||
public AddSmWindowController(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification, final SoftwareModuleManagement smManagement,
|
||||
public AddSmWindowController(final CommonUiDependencies uiDependencies, final SoftwareModuleManagement smManagement,
|
||||
final SmWindowLayout layout, final EventView view) {
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.smManagement = smManagement;
|
||||
|
||||
this.layout = layout;
|
||||
|
||||
this.view = view;
|
||||
this.validator = new ProxySmValidator(uiDependencies);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return software module layout
|
||||
*/
|
||||
@Override
|
||||
public AbstractEntityWindowLayout<ProxySoftwareModule> getLayout() {
|
||||
public EntityWindowLayout<ProxySoftwareModule> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -99,48 +70,42 @@ public class AddSmWindowController extends AbstractEntityWindowController<ProxyS
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxySoftwareModule entity) {
|
||||
final SoftwareModuleCreate smCreate = entityFactory.softwareModule().create()
|
||||
protected SoftwareModule persistEntityInRepository(final ProxySoftwareModule entity) {
|
||||
final SoftwareModuleCreate smCreate = getEntityFactory().softwareModule().create()
|
||||
.type(entity.getTypeInfo().getKey()).name(entity.getName()).version(entity.getVersion())
|
||||
.vendor(entity.getVendor()).description(entity.getDescription());
|
||||
|
||||
final SoftwareModule newSoftwareModule;
|
||||
try {
|
||||
newSoftwareModule = smManagement.create(smCreate);
|
||||
} catch (final ConstraintViolationException ex) {
|
||||
LOG.trace("Create of software module failed in UI: {}", ex.getMessage());
|
||||
uiNotification.displayValidationError(
|
||||
i18n.getMessage("message.save.fail", entity.getName() + ":" + entity.getVersion()));
|
||||
return;
|
||||
}
|
||||
return smManagement.create(smCreate);
|
||||
}
|
||||
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.save.success",
|
||||
newSoftwareModule.getName() + ":" + newSoftwareModule.getVersion()));
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_ADDED, ProxySoftwareModule.class, newSoftwareModule.getId()));
|
||||
@Override
|
||||
protected String getDisplayableName(final SoftwareModule entity) {
|
||||
return HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
|
||||
}
|
||||
|
||||
final ProxySoftwareModule addedItem = new SoftwareModuleToProxyMapper().map(newSoftwareModule);
|
||||
eventBus.publish(CommandTopics.SELECT_GRID_ENTITY, this, new SelectionChangedEventPayload<>(
|
||||
SelectionChangedEventType.ENTITY_SELECTED, addedItem, EventLayout.SM_LIST, view));
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final ProxySoftwareModule entity) {
|
||||
return HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxySoftwareModule.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void selectPersistedEntity(final SoftwareModule entity) {
|
||||
final ProxySoftwareModule addedItem = new SoftwareModuleToProxyMapper().map(entity);
|
||||
publishSelectionEvent(new SelectionChangedEventPayload<>(SelectionChangedEventType.ENTITY_SELECTED, addedItem,
|
||||
EventLayout.SM_LIST, view));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxySoftwareModule entity) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getVersion())
|
||||
|| entity.getTypeInfo() == null) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.error.missing.nameorversionortype"));
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
final String trimmedVersion = StringUtils.trimWhitespace(entity.getVersion());
|
||||
final Long typeId = entity.getTypeInfo().getId();
|
||||
if (smManagement.getByNameAndVersionAndType(trimmedName, trimmedVersion, typeId).isPresent()) {
|
||||
uiNotification.displayValidationError(
|
||||
i18n.getMessage("message.duplicate.softwaremodule", trimmedName, trimmedVersion));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return validator.isEntityValid(entity,
|
||||
() -> smManagement.getByNameAndVersionAndType(trimmedName, trimmedVersion, typeId).isPresent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.EntityValidator;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Validator used in SoftwareModule window controllers to validate
|
||||
* {@link ProxySoftwareModule}.
|
||||
*/
|
||||
public class ProxySmValidator extends EntityValidator {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public ProxySmValidator(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
boolean isEntityValid(final ProxySoftwareModule entity, final BooleanSupplier duplicateCheck) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getVersion())
|
||||
|| entity.getTypeInfo() == null) {
|
||||
displayValidationError("message.error.missing.nameorversionortype");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
final String trimmedVersion = StringUtils.trimWhitespace(entity.getVersion());
|
||||
if (duplicateCheck.getAsBoolean()) {
|
||||
displayValidationError("message.duplicate.softwaremodule", trimmedName, trimmedVersion);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,10 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractMetaDataWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -23,38 +19,19 @@ import com.vaadin.ui.Window;
|
||||
* Builder for Software module meta data windows
|
||||
*/
|
||||
public class SmMetaDataWindowBuilder extends AbstractMetaDataWindowBuilder<Long> {
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
private final SpPermissionChecker permChecker;
|
||||
|
||||
private final SoftwareModuleManagement smManagement;
|
||||
|
||||
/**
|
||||
* Constructor for SmMetaDataWindowBuilder
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smManagement
|
||||
* SoftwareModuleManagement
|
||||
*/
|
||||
public SmMetaDataWindowBuilder(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification, final SpPermissionChecker permChecker,
|
||||
final SoftwareModuleManagement smManagement) {
|
||||
super(i18n);
|
||||
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
this.permChecker = permChecker;
|
||||
public SmMetaDataWindowBuilder(final CommonUiDependencies uiDependencies, final SoftwareModuleManagement smManagement) {
|
||||
super(uiDependencies);
|
||||
|
||||
this.smManagement = smManagement;
|
||||
}
|
||||
@@ -86,8 +63,6 @@ public class SmMetaDataWindowBuilder extends AbstractMetaDataWindowBuilder<Long>
|
||||
* @return software module window
|
||||
*/
|
||||
public Window getWindowForShowSmMetaData(final Long smId, final String name, final ProxyMetaData proxyMetaData) {
|
||||
return getWindowForShowMetaData(
|
||||
new SmMetaDataWindowLayout(i18n, eventBus, permChecker, uiNotification, entityFactory, smManagement),
|
||||
smId, name, proxyMetaData);
|
||||
return getWindowForShowMetaData(new SmMetaDataWindowLayout(uiDependencies, smManagement), smId, name, proxyMetaData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,9 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.model.MetaData;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.SmMetaDataDataProvider;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
@@ -23,9 +22,6 @@ import org.eclipse.hawkbit.ui.common.detailslayout.UpdateMetaDataWindowControlle
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Class for metadata add/update window layout.
|
||||
@@ -34,7 +30,6 @@ public class SmMetaDataWindowLayout extends AbstractMetaDataWindowLayout<Long> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final transient SoftwareModuleManagement smManagement;
|
||||
private final transient EntityFactory entityFactory;
|
||||
|
||||
private final MetaDataWindowGrid<Long> smMetaDataWindowGrid;
|
||||
|
||||
@@ -44,37 +39,26 @@ public class SmMetaDataWindowLayout extends AbstractMetaDataWindowLayout<Long> {
|
||||
|
||||
/**
|
||||
* Constructor for AbstractTagWindowLayout
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smManagement
|
||||
* SoftwareModuleManagement
|
||||
*/
|
||||
public SmMetaDataWindowLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final SpPermissionChecker permChecker, final UINotification uiNotification,
|
||||
final EntityFactory entityFactory, final SoftwareModuleManagement smManagement) {
|
||||
super(i18n, eventBus, uiNotification, permChecker);
|
||||
public SmMetaDataWindowLayout(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleManagement smManagement) {
|
||||
super(uiDependencies);
|
||||
|
||||
this.smManagement = smManagement;
|
||||
this.entityFactory = entityFactory;
|
||||
|
||||
this.smMetaDataWindowGrid = new MetaDataWindowGrid<>(i18n, eventBus, permChecker, uiNotification,
|
||||
new SmMetaDataDataProvider(smManagement), this::hasMetadataChangePermission, this::deleteMetaData);
|
||||
this.smMetaDataWindowGrid = new MetaDataWindowGrid<>(uiDependencies, new SmMetaDataDataProvider(smManagement),
|
||||
this::hasMetadataChangePermission, this::deleteMetaData);
|
||||
|
||||
this.smMetaDataAddUpdateWindowLayout = new SmMetaDataAddUpdateWindowLayout(i18n,
|
||||
this::hasMetadataChangePermission);
|
||||
this.addSmMetaDataWindowController = new AddMetaDataWindowController(i18n, uiNotification,
|
||||
this.smMetaDataAddUpdateWindowLayout = new SmMetaDataAddUpdateWindowLayout(i18n,this::hasMetadataChangePermission);
|
||||
this.addSmMetaDataWindowController = new AddMetaDataWindowController(uiDependencies,
|
||||
smMetaDataAddUpdateWindowLayout, this::createMetaData, this::isDuplicate);
|
||||
this.updateSmMetaDataWindowController = new UpdateMetaDataWindowController(i18n, uiNotification,
|
||||
smMetaDataAddUpdateWindowLayout, this::updateMetaData);
|
||||
this.updateSmMetaDataWindowController = new UpdateMetaDataWindowController(uiDependencies,
|
||||
smMetaDataAddUpdateWindowLayout, this::updateMetaData, this::isDuplicate);
|
||||
|
||||
buildLayout();
|
||||
addGridSelectionListener();
|
||||
@@ -87,14 +71,15 @@ public class SmMetaDataWindowLayout extends AbstractMetaDataWindowLayout<Long> {
|
||||
|
||||
@Override
|
||||
protected MetaData doCreateMetaData(final ProxyMetaData entity) {
|
||||
return smManagement.createMetaData(entityFactory.softwareModuleMetadata().create(masterEntityFilter)
|
||||
.key(entity.getKey()).value(entity.getValue()).targetVisible(entity.isVisibleForTargets()));
|
||||
return smManagement
|
||||
.createMetaData(uiDependencies.getEntityFactory().softwareModuleMetadata().create(masterEntityFilter)
|
||||
.key(entity.getKey()).value(entity.getValue()).targetVisible(entity.isVisibleForTargets()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MetaData doUpdateMetaData(final ProxyMetaData entity) {
|
||||
return smManagement
|
||||
.updateMetaData(entityFactory.softwareModuleMetadata().update(masterEntityFilter, entity.getKey())
|
||||
return smManagement.updateMetaData(
|
||||
uiDependencies.getEntityFactory().softwareModuleMetadata().update(masterEntityFilter, entity.getKey())
|
||||
.value(entity.getValue()).targetVisible(entity.isVisibleForTargets()));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,16 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -25,9 +22,6 @@ import com.vaadin.ui.Window;
|
||||
* Builder for Software module windows
|
||||
*/
|
||||
public class SmWindowBuilder extends AbstractEntityWindowBuilder<ProxySoftwareModule> {
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
|
||||
private final SoftwareModuleManagement smManagement;
|
||||
private final SoftwareModuleTypeManagement smTypeManagement;
|
||||
@@ -37,29 +31,18 @@ public class SmWindowBuilder extends AbstractEntityWindowBuilder<ProxySoftwareMo
|
||||
/**
|
||||
* Constructor for SmWindowBuilder
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smManagement
|
||||
* SoftwareModuleManagement
|
||||
* SoftwareModuleManagement
|
||||
* @param smTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param view
|
||||
* EventView
|
||||
* EventView
|
||||
*/
|
||||
public SmWindowBuilder(final VaadinMessageSource i18n, final EntityFactory entityFactory, final UIEventBus eventBus,
|
||||
final UINotification uiNotification, final SoftwareModuleManagement smManagement,
|
||||
public SmWindowBuilder(final CommonUiDependencies uiDependencies, final SoftwareModuleManagement smManagement,
|
||||
final SoftwareModuleTypeManagement smTypeManagement, final EventView view) {
|
||||
super(i18n);
|
||||
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.smManagement = smManagement;
|
||||
this.smTypeManagement = smTypeManagement;
|
||||
@@ -77,20 +60,20 @@ public class SmWindowBuilder extends AbstractEntityWindowBuilder<ProxySoftwareMo
|
||||
*/
|
||||
@Override
|
||||
public Window getWindowForAdd() {
|
||||
return getWindowForNewEntity(new AddSmWindowController(i18n, entityFactory, eventBus, uiNotification,
|
||||
smManagement, new SmWindowLayout(i18n, smTypeManagement), view));
|
||||
return getWindowForNewEntity(
|
||||
new AddSmWindowController(uiDependencies, smManagement, new SmWindowLayout(getI18n(), smTypeManagement), view));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param proxySm
|
||||
* ProxySoftwareModule
|
||||
* ProxySoftwareModule
|
||||
*
|
||||
* @return update window for software module
|
||||
*/
|
||||
@Override
|
||||
public Window getWindowForUpdate(final ProxySoftwareModule proxySm) {
|
||||
return getWindowForEntity(proxySm, new UpdateSmWindowController(i18n, entityFactory, eventBus, uiNotification,
|
||||
smManagement, new SmWindowLayout(i18n, smTypeManagement)));
|
||||
return getWindowForEntity(proxySm,
|
||||
new UpdateSmWindowController(uiDependencies, smManagement, new SmWindowLayout(getI18n(), smTypeManagement)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.artifacts.upload.FileUploadProgress;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.data.filters.SwFilterParams;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.AssignedSoftwareModuleToProxyMapper;
|
||||
@@ -42,8 +42,6 @@ import org.eclipse.hawkbit.ui.common.state.GridLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Button;
|
||||
|
||||
@@ -75,14 +73,8 @@ public class SoftwareModuleGrid extends AbstractGrid<ProxySoftwareModule, SwFilt
|
||||
/**
|
||||
* Constructor for SoftwareModuleGrid
|
||||
*
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permissionChecker
|
||||
* SpPermissionChecker
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smTypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
* @param smGridLayoutUiState
|
||||
@@ -92,15 +84,14 @@ public class SoftwareModuleGrid extends AbstractGrid<ProxySoftwareModule, SwFilt
|
||||
* @param view
|
||||
* EventView
|
||||
*/
|
||||
public SoftwareModuleGrid(final UIEventBus eventBus, final VaadinMessageSource i18n,
|
||||
final SpPermissionChecker permissionChecker, final UINotification notification,
|
||||
final TypeFilterLayoutUiState smTypeFilterLayoutUiState, final GridLayoutUiState smGridLayoutUiState,
|
||||
final SoftwareModuleManagement softwareModuleManagement, final EventView view) {
|
||||
super(i18n, eventBus, permissionChecker);
|
||||
public SoftwareModuleGrid(final CommonUiDependencies uiDependencies, final TypeFilterLayoutUiState smTypeFilterLayoutUiState,
|
||||
final GridLayoutUiState smGridLayoutUiState, final SoftwareModuleManagement softwareModuleManagement,
|
||||
final EventView view) {
|
||||
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
|
||||
|
||||
this.smTypeFilterLayoutUiState = smTypeFilterLayoutUiState;
|
||||
this.smGridLayoutUiState = smGridLayoutUiState;
|
||||
this.notification = notification;
|
||||
this.notification = uiDependencies.getUiNotification();
|
||||
this.softwareModuleManagement = softwareModuleManagement;
|
||||
this.softwareModuleToProxyMapper = new SoftwareModuleToProxyMapper();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
@@ -17,8 +17,6 @@ import org.eclipse.hawkbit.ui.common.grid.header.AbstractEntityGridHeader;
|
||||
import org.eclipse.hawkbit.ui.common.state.GridLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.common.state.HidableLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Header of Software module table.
|
||||
@@ -32,26 +30,21 @@ public class SoftwareModuleGridHeader extends AbstractEntityGridHeader {
|
||||
/**
|
||||
* Constructor for SoftwareModuleGridHeader
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smTypeFilterLayoutUiState
|
||||
* HidableLayoutUiState
|
||||
* HidableLayoutUiState
|
||||
* @param smGridLayoutUiState
|
||||
* GridLayoutUiState
|
||||
* GridLayoutUiState
|
||||
* @param smWindowBuilder
|
||||
* SmWindowBuilder
|
||||
* SmWindowBuilder
|
||||
* @param view
|
||||
* EventView
|
||||
* EventView
|
||||
*/
|
||||
public SoftwareModuleGridHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UIEventBus eventBus, final HidableLayoutUiState smTypeFilterLayoutUiState,
|
||||
final GridLayoutUiState smGridLayoutUiState, final SmWindowBuilder smWindowBuilder, final EventView view) {
|
||||
super(i18n, permChecker, eventBus, smTypeFilterLayoutUiState, smGridLayoutUiState, EventLayout.SM_TYPE_FILTER,
|
||||
view);
|
||||
public SoftwareModuleGridHeader(final CommonUiDependencies uiDependencies,
|
||||
final HidableLayoutUiState smTypeFilterLayoutUiState, final GridLayoutUiState smGridLayoutUiState,
|
||||
final SmWindowBuilder smWindowBuilder, final EventView view) {
|
||||
super(uiDependencies, smTypeFilterLayoutUiState, smGridLayoutUiState, EventLayout.SM_TYPE_FILTER, view);
|
||||
|
||||
addAddHeaderSupport(smWindowBuilder);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,10 @@ package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.artifacts.upload.FileUploadProgress;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetails;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsHeader;
|
||||
@@ -24,7 +23,6 @@ import org.eclipse.hawkbit.ui.common.event.EventLayoutViewAware;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventViewAware;
|
||||
import org.eclipse.hawkbit.ui.common.layout.AbstractGridComponentLayout;
|
||||
import org.eclipse.hawkbit.ui.common.layout.MasterEntityAwareComponent;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.EntityModifiedListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.EntityModifiedListener.EntityModifiedAwareSupport;
|
||||
@@ -34,16 +32,14 @@ import org.eclipse.hawkbit.ui.common.layout.listener.SelectGridEntityListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.SelectionChangedListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedGridRefreshAwareSupport;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedSelectionAwareSupport;
|
||||
import org.eclipse.hawkbit.ui.common.softwaremodule.AbstractSoftwareModuleGridLayout;
|
||||
import org.eclipse.hawkbit.ui.common.state.GridLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Software module table layout. (Upload Management)
|
||||
*/
|
||||
public class SoftwareModuleGridLayout extends AbstractGridComponentLayout {
|
||||
public class SoftwareModuleGridLayout extends AbstractSoftwareModuleGridLayout {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final SoftwareModuleGridHeader softwareModuleGridHeader;
|
||||
@@ -51,71 +47,51 @@ public class SoftwareModuleGridLayout extends AbstractGridComponentLayout {
|
||||
private final SoftwareModuleDetailsHeader softwareModuleDetailsHeader;
|
||||
private final SoftwareModuleDetails softwareModuleDetails;
|
||||
|
||||
private final transient FilterChangedListener<ProxySoftwareModule> smFilterListener;
|
||||
private final transient SelectionChangedListener<ProxySoftwareModule> masterSmChangedListener;
|
||||
private final transient SelectGridEntityListener<ProxySoftwareModule> selectSmListener;
|
||||
private final transient EntityModifiedListener<ProxySoftwareModule> smModifiedListener;
|
||||
private final transient GenericEventListener<FileUploadProgress> fileUploadChangedListener;
|
||||
|
||||
/**
|
||||
* Constructor for SoftwareModuleGridLayout
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param softwareModuleManagement
|
||||
* SoftwareModuleManagement
|
||||
* @param softwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param smTypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
* @param smGridLayoutUiState
|
||||
* GridLayoutUiState
|
||||
*/
|
||||
public SoftwareModuleGridLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UINotification uiNotification, final UIEventBus eventBus,
|
||||
public SoftwareModuleGridLayout(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleManagement softwareModuleManagement,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement, final EntityFactory entityFactory,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement,
|
||||
final TypeFilterLayoutUiState smTypeFilterLayoutUiState, final GridLayoutUiState smGridLayoutUiState) {
|
||||
super();
|
||||
super(uiDependencies, softwareModuleManagement, softwareModuleTypeManagement, EventView.UPLOAD);
|
||||
|
||||
final SmWindowBuilder smWindowBuilder = new SmWindowBuilder(i18n, entityFactory, eventBus, uiNotification,
|
||||
softwareModuleManagement, softwareModuleTypeManagement, EventView.UPLOAD);
|
||||
final SmMetaDataWindowBuilder smMetaDataWindowBuilder = new SmMetaDataWindowBuilder(i18n, entityFactory,
|
||||
eventBus, uiNotification, permChecker, softwareModuleManagement);
|
||||
|
||||
this.softwareModuleGridHeader = new SoftwareModuleGridHeader(i18n, permChecker, eventBus,
|
||||
smTypeFilterLayoutUiState, smGridLayoutUiState, smWindowBuilder, EventView.UPLOAD);
|
||||
this.softwareModuleGridHeader = new SoftwareModuleGridHeader(uiDependencies, smTypeFilterLayoutUiState,
|
||||
smGridLayoutUiState, getSmWindowBuilder(), getEventView());
|
||||
this.softwareModuleGridHeader.buildHeader();
|
||||
this.softwareModuleGrid = new SoftwareModuleGrid(eventBus, i18n, permChecker, uiNotification,
|
||||
smTypeFilterLayoutUiState, smGridLayoutUiState, softwareModuleManagement, EventView.UPLOAD);
|
||||
this.softwareModuleGrid = new SoftwareModuleGrid(uiDependencies, smTypeFilterLayoutUiState, smGridLayoutUiState,
|
||||
softwareModuleManagement, getEventView());
|
||||
this.softwareModuleGrid.init();
|
||||
|
||||
this.softwareModuleDetailsHeader = new SoftwareModuleDetailsHeader(i18n, permChecker, eventBus, uiNotification,
|
||||
smWindowBuilder, smMetaDataWindowBuilder);
|
||||
this.softwareModuleDetailsHeader = new SoftwareModuleDetailsHeader(uiDependencies, getSmWindowBuilder(),
|
||||
getSmMetaDataWindowBuilder());
|
||||
this.softwareModuleDetailsHeader.buildHeader();
|
||||
this.softwareModuleDetails = new SoftwareModuleDetails(i18n, eventBus, softwareModuleManagement,
|
||||
softwareModuleTypeManagement, smMetaDataWindowBuilder);
|
||||
this.softwareModuleDetails = new SoftwareModuleDetails(uiDependencies, softwareModuleManagement,
|
||||
softwareModuleTypeManagement, getSmMetaDataWindowBuilder());
|
||||
this.softwareModuleDetails.buildDetails();
|
||||
|
||||
this.smFilterListener = new FilterChangedListener<>(eventBus, ProxySoftwareModule.class,
|
||||
new EventViewAware(EventView.UPLOAD), softwareModuleGrid.getFilterSupport());
|
||||
this.masterSmChangedListener = new SelectionChangedListener<>(eventBus,
|
||||
new EventLayoutViewAware(EventLayout.SM_LIST, EventView.UPLOAD), getMasterSmAwareComponents());
|
||||
this.selectSmListener = new SelectGridEntityListener<>(eventBus,
|
||||
new EventLayoutViewAware(EventLayout.SM_LIST, EventView.UPLOAD),
|
||||
softwareModuleGrid.getSelectionSupport());
|
||||
this.smModifiedListener = new EntityModifiedListener.Builder<>(eventBus, ProxySoftwareModule.class)
|
||||
.entityModifiedAwareSupports(getSmModifiedAwareSupports()).build();
|
||||
this.fileUploadChangedListener = new GenericEventListener<>(eventBus, EventTopics.FILE_UPLOAD_CHANGED,
|
||||
this::onUploadChanged);
|
||||
addEventListener(new FilterChangedListener<>(uiDependencies.getEventBus(), ProxySoftwareModule.class,
|
||||
new EventViewAware(getEventView()), softwareModuleGrid.getFilterSupport()));
|
||||
addEventListener(new SelectionChangedListener<>(uiDependencies.getEventBus(),
|
||||
new EventLayoutViewAware(EventLayout.SM_LIST, getEventView()), getMasterSmAwareComponents()));
|
||||
addEventListener(new SelectGridEntityListener<>(uiDependencies.getEventBus(),
|
||||
new EventLayoutViewAware(EventLayout.SM_LIST, getEventView()),
|
||||
softwareModuleGrid.getSelectionSupport()));
|
||||
addEventListener(new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(), ProxySoftwareModule.class)
|
||||
.entityModifiedAwareSupports(getSmModifiedAwareSupports()).build());
|
||||
addEventListener(new GenericEventListener<>(uiDependencies.getEventBus(), EventTopics.FILE_UPLOAD_CHANGED,
|
||||
this::onUploadChanged));
|
||||
|
||||
buildLayout(softwareModuleGridHeader, softwareModuleGrid, softwareModuleDetailsHeader, softwareModuleDetails);
|
||||
}
|
||||
@@ -134,58 +110,20 @@ public class SoftwareModuleGridLayout extends AbstractGridComponentLayout {
|
||||
* Verifies when file upload is in progress
|
||||
*
|
||||
* @param fileUploadProgress
|
||||
* FileUploadProgress
|
||||
* FileUploadProgress
|
||||
*/
|
||||
public void onUploadChanged(final FileUploadProgress fileUploadProgress) {
|
||||
softwareModuleGrid.onUploadChanged(fileUploadProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show software module grid header
|
||||
*/
|
||||
public void showSmTypeHeaderIcon() {
|
||||
softwareModuleGridHeader.showFilterIcon();
|
||||
@Override
|
||||
protected SoftwareModuleGridHeader getSoftwareModuleGridHeader() {
|
||||
return softwareModuleGridHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide software module grid header
|
||||
*/
|
||||
public void hideSmTypeHeaderIcon() {
|
||||
softwareModuleGridHeader.hideFilterIcon();
|
||||
@Override
|
||||
protected SoftwareModuleGrid getSoftwareModuleGrid() {
|
||||
return softwareModuleGrid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximize the software module grid
|
||||
*/
|
||||
public void maximize() {
|
||||
softwareModuleGrid.createMaximizedContent();
|
||||
hideDetailsLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimize the software module grid
|
||||
*/
|
||||
public void minimize() {
|
||||
softwareModuleGrid.createMinimizedContent();
|
||||
showDetailsLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called when view is shown to the user
|
||||
*/
|
||||
public void restoreState() {
|
||||
softwareModuleGridHeader.restoreState();
|
||||
softwareModuleGrid.restoreState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe all the events listeners
|
||||
*/
|
||||
public void unsubscribeListener() {
|
||||
smFilterListener.unsubscribe();
|
||||
masterSmChangedListener.unsubscribe();
|
||||
selectSmListener.unsubscribe();
|
||||
smModifiedListener.unsubscribe();
|
||||
fileUploadChangedListener.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,75 +8,47 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractUpdateNamedEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Controller for update software module window
|
||||
*/
|
||||
public class UpdateSmWindowController extends AbstractEntityWindowController<ProxySoftwareModule, ProxySoftwareModule> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UpdateSmWindowController.class);
|
||||
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
public class UpdateSmWindowController
|
||||
extends AbstractUpdateNamedEntityWindowController<ProxySoftwareModule, ProxySoftwareModule, SoftwareModule> {
|
||||
|
||||
private final SoftwareModuleManagement smManagement;
|
||||
|
||||
private final SmWindowLayout layout;
|
||||
private final ProxySmValidator validator;
|
||||
|
||||
private String nameBeforeEdit;
|
||||
private String versionBeforeEdit;
|
||||
|
||||
/**
|
||||
* Constructor for UpdateSmWindowController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smManagement
|
||||
* SoftwareModuleManagement
|
||||
* @param layout
|
||||
* SmWindowLayout
|
||||
*/
|
||||
public UpdateSmWindowController(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification, final SoftwareModuleManagement smManagement,
|
||||
final SmWindowLayout layout) {
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
public UpdateSmWindowController(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleManagement smManagement, final SmWindowLayout layout) {
|
||||
super(uiDependencies);
|
||||
|
||||
this.smManagement = smManagement;
|
||||
|
||||
this.layout = layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Software module layout
|
||||
*/
|
||||
@Override
|
||||
public AbstractEntityWindowLayout<ProxySoftwareModule> getLayout() {
|
||||
return layout;
|
||||
this.validator = new ProxySmValidator(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,9 +62,17 @@ public class UpdateSmWindowController extends AbstractEntityWindowController<Pro
|
||||
sm.setVendor(proxyEntity.getVendor());
|
||||
sm.setDescription(proxyEntity.getDescription());
|
||||
|
||||
nameBeforeEdit = proxyEntity.getName();
|
||||
versionBeforeEdit = proxyEntity.getVersion();
|
||||
|
||||
return sm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityWindowLayout<ProxySoftwareModule> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptLayout(final ProxySoftwareModule proxyEntity) {
|
||||
layout.disableSmTypeSelect();
|
||||
@@ -101,33 +81,37 @@ public class UpdateSmWindowController extends AbstractEntityWindowController<Pro
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxySoftwareModule entity) {
|
||||
final SoftwareModuleUpdate smUpdate = entityFactory.softwareModule().update(entity.getId())
|
||||
protected SoftwareModule persistEntityInRepository(final ProxySoftwareModule entity) {
|
||||
final SoftwareModuleUpdate smUpdate = getEntityFactory().softwareModule().update(entity.getId())
|
||||
.vendor(entity.getVendor()).description(entity.getDescription());
|
||||
return smManagement.update(smUpdate);
|
||||
}
|
||||
|
||||
try {
|
||||
final SoftwareModule updatedSm = smManagement.update(smUpdate);
|
||||
@Override
|
||||
protected String getDisplayableName(final SoftwareModule entity) {
|
||||
return HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
|
||||
}
|
||||
|
||||
uiNotification.displaySuccess(
|
||||
i18n.getMessage("message.update.success", updatedSm.getName() + ":" + updatedSm.getVersion()));
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_UPDATED, ProxySoftwareModule.class, updatedSm.getId()));
|
||||
} catch (final EntityNotFoundException | EntityReadOnlyException e) {
|
||||
LOG.trace("Update of software module failed in UI: {}", e.getMessage());
|
||||
final String entityType = i18n.getMessage("caption.software.module");
|
||||
uiNotification
|
||||
.displayWarning(i18n.getMessage("message.deleted.or.notAllowed", entityType, entity.getName()));
|
||||
}
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final ProxySoftwareModule entity) {
|
||||
return HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxySoftwareModule.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxySoftwareModule entity) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getVersion())
|
||||
|| entity.getTypeInfo() == null) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.error.missing.nameorversionortype"));
|
||||
return false;
|
||||
}
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
final String trimmedVersion = StringUtils.trimWhitespace(entity.getVersion());
|
||||
final Long typeId = entity.getTypeInfo().getId();
|
||||
return validator.isEntityValid(entity, () -> hasNameOrVersionChanged(trimmedName, trimmedVersion)
|
||||
&& smManagement.getByNameAndVersionAndType(trimmedName, trimmedVersion, typeId).isPresent());
|
||||
}
|
||||
|
||||
return true;
|
||||
private boolean hasNameOrVersionChanged(final String trimmedName, final String trimmedVersion) {
|
||||
return !nameBeforeEdit.equals(trimmedName) || !versionBeforeEdit.equals(trimmedVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,71 +8,49 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtype;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractAddNamedEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType.SmTypeAssign;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.eclipse.hawkbit.ui.common.type.ProxyTypeValidator;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Controller for Add software module type window
|
||||
*/
|
||||
public class AddSmTypeWindowController extends AbstractEntityWindowController<ProxyType, ProxyType> {
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
public class AddSmTypeWindowController
|
||||
extends AbstractAddNamedEntityWindowController<ProxyType, ProxyType, SoftwareModuleType> {
|
||||
|
||||
private final SoftwareModuleTypeManagement smTypeManagement;
|
||||
|
||||
private final SmTypeWindowLayout layout;
|
||||
private final ProxyTypeValidator validator;
|
||||
|
||||
/**
|
||||
* Constructor for AddSmTypeWindowController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param layout
|
||||
* SmTypeWindowLayout
|
||||
*/
|
||||
public AddSmTypeWindowController(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification,
|
||||
public AddSmTypeWindowController(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleTypeManagement smTypeManagement, final SmTypeWindowLayout layout) {
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.smTypeManagement = smTypeManagement;
|
||||
|
||||
this.layout = layout;
|
||||
this.validator = new ProxyTypeValidator(uiDependencies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for Software module type Window Layout
|
||||
*
|
||||
* @return AbstractEntityWindowLayout
|
||||
*/
|
||||
@Override
|
||||
public AbstractEntityWindowLayout<ProxyType> getLayout() {
|
||||
public EntityWindowLayout<ProxyType> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -84,38 +62,29 @@ public class AddSmTypeWindowController extends AbstractEntityWindowController<Pr
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyType entity) {
|
||||
protected SoftwareModuleType persistEntityInRepository(final ProxyType entity) {
|
||||
final int assignNumber = entity.getSmTypeAssign() == SmTypeAssign.SINGLE ? 1 : Integer.MAX_VALUE;
|
||||
|
||||
final SoftwareModuleType newSmType = smTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key(entity.getKey()).name(entity.getName())
|
||||
return smTypeManagement
|
||||
.create(getEntityFactory().softwareModuleType().create().key(entity.getKey()).name(entity.getName())
|
||||
.description(entity.getDescription()).colour(entity.getColour()).maxAssignments(assignNumber));
|
||||
}
|
||||
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.save.success", newSmType.getName()));
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_ADDED, ProxySoftwareModule.class, ProxyType.class, newSmType.getId()));
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyType.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getParentEntityClass() {
|
||||
return ProxySoftwareModule.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyType entity) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getKey())
|
||||
|| entity.getSmTypeAssign() == null) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.error.missing.typenameorkeyorsmtype"));
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
final String trimmedKey = StringUtils.trimWhitespace(entity.getKey());
|
||||
if (smTypeManagement.getByName(trimmedName).isPresent()) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.type.duplicate.check", trimmedName));
|
||||
return false;
|
||||
}
|
||||
if (smTypeManagement.getByKey(trimmedKey).isPresent()) {
|
||||
uiNotification
|
||||
.displayValidationError(i18n.getMessage("message.type.key.swmodule.duplicate.check", trimmedKey));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return validator.isSmTypeValid(entity, () -> smTypeManagement.getByKey(trimmedKey).isPresent(),
|
||||
() -> smTypeManagement.getByName(trimmedName).isPresent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,11 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtype;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -23,35 +20,19 @@ import com.vaadin.ui.Window;
|
||||
* Builder for software module type window
|
||||
*/
|
||||
public class SmTypeWindowBuilder extends AbstractEntityWindowBuilder<ProxyType> {
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
|
||||
private final SoftwareModuleTypeManagement smTypeManagement;
|
||||
|
||||
/**
|
||||
* Constructor for SmTypeWindowBuilder
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
*/
|
||||
public SmTypeWindowBuilder(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification,
|
||||
final SoftwareModuleTypeManagement smTypeManagement) {
|
||||
super(i18n);
|
||||
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
|
||||
public SmTypeWindowBuilder(final CommonUiDependencies uiDependencies, final SoftwareModuleTypeManagement smTypeManagement) {
|
||||
super(uiDependencies);
|
||||
this.smTypeManagement = smTypeManagement;
|
||||
}
|
||||
|
||||
@@ -67,8 +48,8 @@ public class SmTypeWindowBuilder extends AbstractEntityWindowBuilder<ProxyType>
|
||||
*/
|
||||
@Override
|
||||
public Window getWindowForAdd() {
|
||||
return getWindowForNewEntity(new AddSmTypeWindowController(i18n, entityFactory, eventBus, uiNotification,
|
||||
smTypeManagement, new SmTypeWindowLayout(i18n, uiNotification)));
|
||||
return getWindowForNewEntity(
|
||||
new AddSmTypeWindowController(uiDependencies, smTypeManagement, new SmTypeWindowLayout(uiDependencies)));
|
||||
|
||||
}
|
||||
|
||||
@@ -76,13 +57,13 @@ public class SmTypeWindowBuilder extends AbstractEntityWindowBuilder<ProxyType>
|
||||
* Update window for software module type
|
||||
*
|
||||
* @param proxyType
|
||||
* ProxyType
|
||||
* ProxyType
|
||||
*
|
||||
* @return Window of Software module type
|
||||
*/
|
||||
@Override
|
||||
public Window getWindowForUpdate(final ProxyType proxyType) {
|
||||
return getWindowForEntity(proxyType, new UpdateSmTypeWindowController(i18n, entityFactory, eventBus,
|
||||
uiNotification, smTypeManagement, new SmTypeWindowLayout(i18n, uiNotification)));
|
||||
return getWindowForEntity(proxyType,
|
||||
new UpdateSmTypeWindowController(uiDependencies, smTypeManagement, new SmTypeWindowLayout(uiDependencies)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,11 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtype;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.builder.FormComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType.SmTypeAssign;
|
||||
import org.eclipse.hawkbit.ui.management.tag.TagWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
|
||||
import com.vaadin.ui.FormLayout;
|
||||
import com.vaadin.ui.RadioButtonGroup;
|
||||
@@ -31,13 +30,11 @@ public class SmTypeWindowLayout extends TagWindowLayout<ProxyType> {
|
||||
/**
|
||||
* Constructor for SmTypeWindowLayout
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public SmTypeWindowLayout(final VaadinMessageSource i18n, final UINotification uiNotification) {
|
||||
super(i18n, uiNotification);
|
||||
public SmTypeWindowLayout(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
|
||||
this.smTypeComponentBuilder = new SmTypeWindowLayoutComponentBuilder(i18n);
|
||||
|
||||
|
||||
@@ -8,41 +8,28 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtype;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractUpdateNamedEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType.SmTypeAssign;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.eclipse.hawkbit.ui.common.type.ProxyTypeValidator;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Controller for update software module type window
|
||||
*/
|
||||
public class UpdateSmTypeWindowController extends AbstractEntityWindowController<ProxyType, ProxyType> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UpdateSmTypeWindowController.class);
|
||||
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
public class UpdateSmTypeWindowController
|
||||
extends AbstractUpdateNamedEntityWindowController<ProxyType, ProxyType, SoftwareModuleType> {
|
||||
|
||||
private final SoftwareModuleTypeManagement smTypeManagement;
|
||||
|
||||
private final SmTypeWindowLayout layout;
|
||||
private final ProxyTypeValidator validator;
|
||||
|
||||
private String nameBeforeEdit;
|
||||
private String keyBeforeEdit;
|
||||
@@ -50,40 +37,20 @@ public class UpdateSmTypeWindowController extends AbstractEntityWindowController
|
||||
/**
|
||||
* Constructor for UpdateSmTypeWindowController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param layout
|
||||
* SmTypeWindowLayout
|
||||
*/
|
||||
public UpdateSmTypeWindowController(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification,
|
||||
public UpdateSmTypeWindowController(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleTypeManagement smTypeManagement, final SmTypeWindowLayout layout) {
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.smTypeManagement = smTypeManagement;
|
||||
|
||||
this.layout = layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for Software module type Window Layout
|
||||
*
|
||||
* @return AbstractEntityWindowLayout
|
||||
*/
|
||||
@Override
|
||||
public AbstractEntityWindowLayout<ProxyType> getLayout() {
|
||||
return layout;
|
||||
this.validator = new ProxyTypeValidator(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,6 +76,11 @@ public class UpdateSmTypeWindowController extends AbstractEntityWindowController
|
||||
.orElse(SmTypeAssign.SINGLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityWindowLayout<ProxyType> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptLayout(final ProxyType proxyEntity) {
|
||||
layout.disableTagName();
|
||||
@@ -117,46 +89,36 @@ public class UpdateSmTypeWindowController extends AbstractEntityWindowController
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyType entity) {
|
||||
final SoftwareModuleTypeUpdate smTypeUpdate = entityFactory.softwareModuleType().update(entity.getId())
|
||||
protected SoftwareModuleType persistEntityInRepository(final ProxyType entity) {
|
||||
final SoftwareModuleTypeUpdate smTypeUpdate = getEntityFactory().softwareModuleType().update(entity.getId())
|
||||
.description(entity.getDescription()).colour(entity.getColour());
|
||||
return smTypeManagement.update(smTypeUpdate);
|
||||
}
|
||||
|
||||
try {
|
||||
final SoftwareModuleType updatedSmType = smTypeManagement.update(smTypeUpdate);
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyType.class;
|
||||
}
|
||||
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.update.success", updatedSmType.getName()));
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this,
|
||||
new EntityModifiedEventPayload(EntityModifiedEventType.ENTITY_UPDATED, ProxySoftwareModule.class,
|
||||
ProxyType.class, updatedSmType.getId()));
|
||||
} catch (final EntityNotFoundException | EntityReadOnlyException e) {
|
||||
LOG.trace("Update of software module type failed in UI: {}", e.getMessage());
|
||||
|
||||
final String entityType = i18n.getMessage("caption.entity.software.module.type");
|
||||
uiNotification
|
||||
.displayWarning(i18n.getMessage("message.deleted.or.notAllowed", entityType, entity.getName()));
|
||||
}
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getParentEntityClass() {
|
||||
return ProxySoftwareModule.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyType entity) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getKey())
|
||||
|| entity.getSmTypeAssign() == null) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.error.missing.typenameorkeyorsmtype"));
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
final String trimmedKey = StringUtils.trimWhitespace(entity.getKey());
|
||||
if (!nameBeforeEdit.equals(trimmedName) && smTypeManagement.getByName(trimmedName).isPresent()) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.type.duplicate.check", trimmedName));
|
||||
return false;
|
||||
}
|
||||
if (!keyBeforeEdit.equals(trimmedKey) && smTypeManagement.getByKey(trimmedKey).isPresent()) {
|
||||
uiNotification
|
||||
.displayValidationError(i18n.getMessage("message.type.key.swmodule.duplicate.check", trimmedKey));
|
||||
return false;
|
||||
}
|
||||
return validator.isSmTypeValid(entity,
|
||||
() -> hasKeyChanged(trimmedKey) && smTypeManagement.getByKey(trimmedKey).isPresent(),
|
||||
() -> hasNameChanged(trimmedName) && smTypeManagement.getByName(trimmedName).isPresent());
|
||||
}
|
||||
|
||||
return true;
|
||||
private boolean hasNameChanged(final String trimmedName) {
|
||||
return !nameBeforeEdit.equals(trimmedName);
|
||||
}
|
||||
|
||||
private boolean hasKeyChanged(final String trimmedKey) {
|
||||
return !keyBeforeEdit.equals(trimmedKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtype.filter;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtype.SmTypeWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.TypeToProxyTypeMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.SoftwareModuleTypeDataProvider;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
@@ -20,9 +20,6 @@ import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractTypeFilterButtons;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -40,17 +37,11 @@ public class SMTypeFilterButtons extends AbstractTypeFilterButtons {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param softwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param smTypeWindowBuilder
|
||||
* SmTypeWindowBuilder
|
||||
* @param typeFilterLayoutUiState
|
||||
@@ -58,12 +49,11 @@ public class SMTypeFilterButtons extends AbstractTypeFilterButtons {
|
||||
* @param view
|
||||
* EventView
|
||||
*/
|
||||
public SMTypeFilterButtons(final UIEventBus eventBus, final VaadinMessageSource i18n,
|
||||
final UINotification uiNotification, final SpPermissionChecker permChecker,
|
||||
public SMTypeFilterButtons(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement,
|
||||
final SmTypeWindowBuilder smTypeWindowBuilder, final TypeFilterLayoutUiState typeFilterLayoutUiState,
|
||||
final EventView view) {
|
||||
super(eventBus, i18n, uiNotification, permChecker, typeFilterLayoutUiState);
|
||||
super(uiDependencies, typeFilterLayoutUiState);
|
||||
|
||||
this.softwareModuleTypeManagement = softwareModuleTypeManagement;
|
||||
this.smTypeWindowBuilder = smTypeWindowBuilder;
|
||||
|
||||
@@ -8,16 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtype.filter;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtype.SmTypeWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.grid.header.AbstractFilterHeader;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -36,23 +34,18 @@ public class SMTypeFilterHeader extends AbstractFilterHeader {
|
||||
/**
|
||||
* Constructor for SMTypeFilterHeader
|
||||
*
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smTypeWindowBuilder
|
||||
* SmTypeWindowBuilder
|
||||
* SmTypeWindowBuilder
|
||||
* @param smTypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
* @param view
|
||||
* EventView
|
||||
* EventView
|
||||
*/
|
||||
public SMTypeFilterHeader(final UIEventBus eventBus, final VaadinMessageSource i18n,
|
||||
final SpPermissionChecker permChecker, final SmTypeWindowBuilder smTypeWindowBuilder,
|
||||
public SMTypeFilterHeader(final CommonUiDependencies uiDependencies, final SmTypeWindowBuilder smTypeWindowBuilder,
|
||||
final TypeFilterLayoutUiState smTypeFilterLayoutUiState, final EventView view) {
|
||||
super(i18n, permChecker, eventBus);
|
||||
super(uiDependencies.getI18n(), uiDependencies.getPermChecker(), uiDependencies.getEventBus());
|
||||
|
||||
this.smTypeFilterLayoutUiState = smTypeFilterLayoutUiState;
|
||||
this.smTypeWindowBuilder = smTypeWindowBuilder;
|
||||
|
||||
@@ -11,10 +11,9 @@ package org.eclipse.hawkbit.ui.artifacts.smtype.filter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtype.SmTypeWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
@@ -27,9 +26,6 @@ import org.eclipse.hawkbit.ui.common.layout.listener.GridActionsVisibilityListen
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedGenericSupport;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedGridRefreshAwareSupport;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.ComponentContainer;
|
||||
|
||||
@@ -37,6 +33,7 @@ import com.vaadin.ui.ComponentContainer;
|
||||
* Software module type filter buttons layout.
|
||||
*/
|
||||
public class SMTypeFilterLayout extends AbstractFilterLayout {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final SMTypeFilterHeader smTypeFilterHeader;
|
||||
@@ -47,50 +44,46 @@ public class SMTypeFilterLayout extends AbstractFilterLayout {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param softwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param smTypeFilterLayoutUiState
|
||||
* SMTypeFilterLayoutUiState
|
||||
* @param eventView
|
||||
* {@link EventView}
|
||||
*/
|
||||
public SMTypeFilterLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UIEventBus eventBus, final EntityFactory entityFactory, final UINotification uiNotification,
|
||||
public SMTypeFilterLayout(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement,
|
||||
final TypeFilterLayoutUiState smTypeFilterLayoutUiState) {
|
||||
final SmTypeWindowBuilder smTypeWindowBuilder = new SmTypeWindowBuilder(i18n, entityFactory, eventBus,
|
||||
uiNotification, softwareModuleTypeManagement);
|
||||
final TypeFilterLayoutUiState smTypeFilterLayoutUiState, final EventView eventView) {
|
||||
final SmTypeWindowBuilder smTypeWindowBuilder = new SmTypeWindowBuilder(uiDependencies,
|
||||
softwareModuleTypeManagement);
|
||||
|
||||
this.smTypeFilterHeader = new SMTypeFilterHeader(eventBus, i18n, permChecker, smTypeWindowBuilder,
|
||||
smTypeFilterLayoutUiState, EventView.UPLOAD);
|
||||
this.smTypeFilterButtons = new SMTypeFilterButtons(eventBus, i18n, uiNotification, permChecker,
|
||||
softwareModuleTypeManagement, smTypeWindowBuilder, smTypeFilterLayoutUiState, EventView.UPLOAD);
|
||||
this.smTypeFilterHeader = new SMTypeFilterHeader(uiDependencies, smTypeWindowBuilder, smTypeFilterLayoutUiState,
|
||||
eventView);
|
||||
this.smTypeFilterButtons = new SMTypeFilterButtons(uiDependencies, softwareModuleTypeManagement,
|
||||
smTypeWindowBuilder, smTypeFilterLayoutUiState, eventView);
|
||||
|
||||
this.gridActionsVisibilityListener = new GridActionsVisibilityListener(eventBus,
|
||||
new EventLayoutViewAware(EventLayout.SM_TYPE_FILTER, EventView.UPLOAD),
|
||||
smTypeFilterButtons::hideActionColumns, smTypeFilterButtons::showEditColumn,
|
||||
smTypeFilterButtons::showDeleteColumn);
|
||||
this.entityModifiedListener = new EntityModifiedListener.Builder<>(eventBus, ProxyType.class)
|
||||
.entityModifiedAwareSupports(getEntityModifiedAwareSupports())
|
||||
.parentEntityType(ProxySoftwareModule.class).build();
|
||||
this.gridActionsVisibilityListener = new GridActionsVisibilityListener(uiDependencies.getEventBus(),
|
||||
new EventLayoutViewAware(EventLayout.SM_TYPE_FILTER, eventView), smTypeFilterButtons::hideActionColumns,
|
||||
smTypeFilterButtons::showEditColumn, smTypeFilterButtons::showDeleteColumn);
|
||||
this.entityModifiedListener = new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(),
|
||||
ProxyType.class).entityModifiedAwareSupports(getEntityModifiedAwareSupports())
|
||||
.parentEntityType(ProxySoftwareModule.class).build();
|
||||
|
||||
buildLayout();
|
||||
}
|
||||
|
||||
private List<EntityModifiedAwareSupport> getEntityModifiedAwareSupports() {
|
||||
return Arrays.asList(EntityModifiedGridRefreshAwareSupport.of(smTypeFilterButtons::refreshAll),
|
||||
return Arrays.asList(EntityModifiedGridRefreshAwareSupport.of(this::refreshFilterButtons),
|
||||
EntityModifiedGenericSupport.of(null, null, smTypeFilterButtons::resetFilterOnTypesDeleted));
|
||||
}
|
||||
|
||||
protected void refreshFilterButtons() {
|
||||
smTypeFilterButtons.refreshAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SMTypeFilterHeader getFilterHeader() {
|
||||
return smTypeFilterHeader;
|
||||
|
||||
@@ -18,14 +18,13 @@ import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.artifacts.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.layout.MasterEntityAwareComponent;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.icons.VaadinIcons;
|
||||
import com.vaadin.shared.ui.ContentMode;
|
||||
@@ -59,13 +58,9 @@ public class UploadDropAreaLayout extends CustomComponent implements MasterEntit
|
||||
|
||||
/**
|
||||
* Creates a new {@link UploadDropAreaLayout} instance.
|
||||
*
|
||||
* @param i18n
|
||||
* the {@link VaadinMessageSource}
|
||||
* @param eventBus
|
||||
* the {@link EventBus} used to send/retrieve events
|
||||
* @param uiNotification
|
||||
* {@link UINotification} for showing notifications
|
||||
*
|
||||
* @param uiDependencies
|
||||
* the {@link CommonUiDependencies}
|
||||
* @param artifactUploadState
|
||||
* the {@link ArtifactUploadState} for state information
|
||||
* @param multipartConfigElement
|
||||
@@ -77,18 +72,17 @@ public class UploadDropAreaLayout extends CustomComponent implements MasterEntit
|
||||
* the {@link ArtifactManagement} for storing the uploaded
|
||||
* artifacts
|
||||
*/
|
||||
public UploadDropAreaLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final UINotification uiNotification, final ArtifactUploadState artifactUploadState,
|
||||
public UploadDropAreaLayout(final CommonUiDependencies uiDependencies, final ArtifactUploadState artifactUploadState,
|
||||
final MultipartConfigElement multipartConfigElement, final SoftwareModuleManagement softwareManagement,
|
||||
final ArtifactManagement artifactManagement) {
|
||||
this.i18n = i18n;
|
||||
this.uiNotification = uiNotification;
|
||||
this.i18n = uiDependencies.getI18n();
|
||||
this.uiNotification = uiDependencies.getUiNotification();
|
||||
this.artifactUploadState = artifactUploadState;
|
||||
this.multipartConfigElement = multipartConfigElement;
|
||||
this.softwareManagement = softwareManagement;
|
||||
this.artifactManagement = artifactManagement;
|
||||
|
||||
this.uploadButtonLayout = new UploadProgressButtonLayout(i18n, eventBus, artifactUploadState,
|
||||
this.uploadButtonLayout = new UploadProgressButtonLayout(i18n, uiDependencies.getEventBus(), artifactUploadState,
|
||||
multipartConfigElement, artifactManagement, softwareManagement, uploadLock);
|
||||
|
||||
buildLayout();
|
||||
@@ -125,7 +119,7 @@ public class UploadDropAreaLayout extends CustomComponent implements MasterEntit
|
||||
* Update the upload view on file drop
|
||||
*
|
||||
* @param masterEntity
|
||||
* ProxySoftwareModule
|
||||
* ProxySoftwareModule
|
||||
*/
|
||||
@Override
|
||||
public void masterEntityChanged(final ProxySoftwareModule masterEntity) {
|
||||
@@ -139,7 +133,7 @@ public class UploadDropAreaLayout extends CustomComponent implements MasterEntit
|
||||
* Checks progress on file upload
|
||||
*
|
||||
* @param fileUploadProgress
|
||||
* FileUploadProgress
|
||||
* FileUploadProgress
|
||||
*/
|
||||
public void onUploadChanged(final FileUploadProgress fileUploadProgress) {
|
||||
uploadButtonLayout.onUploadChanged(fileUploadProgress);
|
||||
@@ -178,7 +172,7 @@ public class UploadDropAreaLayout extends CustomComponent implements MasterEntit
|
||||
* Validates the file drop events and triggers the upload
|
||||
*
|
||||
* @param event
|
||||
* FileDropEvent
|
||||
* FileDropEvent
|
||||
*/
|
||||
@Override
|
||||
public void drop(final FileDropEvent<VerticalLayout> event) {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
|
||||
/**
|
||||
* Window controller for entity creations.
|
||||
*
|
||||
* @param <T>
|
||||
* Type of proxy entity
|
||||
* @param <E>
|
||||
* Second type of proxy entity
|
||||
* @param <R>
|
||||
* Type of repository entity
|
||||
*/
|
||||
public abstract class AbstractAddEntityWindowController<T, E, R> extends AbstractEntityWindowController<T, E, R> {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public AbstractAddEntityWindowController(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistSuccessMessageKey() {
|
||||
return "message.save.success";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistFailureMessageKey() {
|
||||
return "message.save.fail";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityModifiedEventPayload createModifiedEventPayload(final R entity) {
|
||||
return new EntityModifiedEventPayload(EntityModifiedEventType.ENTITY_ADDED, getParentEntityClass(),
|
||||
getEntityClass(), getId(entity));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyNamedEntity;
|
||||
|
||||
/**
|
||||
* Window controller for named entity creations.
|
||||
*
|
||||
* @param <T>
|
||||
* Type of proxy entity
|
||||
* @param <E>
|
||||
* Second type of proxy entity
|
||||
* @param <R>
|
||||
* Type of repository entity
|
||||
*/
|
||||
public abstract class AbstractAddNamedEntityWindowController<T, E extends ProxyNamedEntity, R extends NamedEntity>
|
||||
extends AbstractAddEntityWindowController<T, E, R> {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public AbstractAddNamedEntityWindowController(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableName(final R entity) {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final E entity) {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getId(final R entity) {
|
||||
return entity.getId();
|
||||
}
|
||||
}
|
||||
@@ -20,31 +20,31 @@ import com.vaadin.ui.Window;
|
||||
* Builder for abstract entity window
|
||||
*
|
||||
* @param <T>
|
||||
* Generic type entity
|
||||
* Generic type entity
|
||||
*/
|
||||
public abstract class AbstractEntityWindowBuilder<T> {
|
||||
protected final VaadinMessageSource i18n;
|
||||
protected final CommonUiDependencies uiDependencies;
|
||||
|
||||
protected AbstractEntityWindowBuilder(final VaadinMessageSource i18n) {
|
||||
this.i18n = i18n;
|
||||
protected AbstractEntityWindowBuilder(final CommonUiDependencies uiDependencies) {
|
||||
this.uiDependencies = uiDependencies;
|
||||
}
|
||||
|
||||
protected CommonDialogWindow getWindowForNewEntity(final AbstractEntityWindowController<T, ?> controller) {
|
||||
protected CommonDialogWindow getWindowForNewEntity(final AbstractEntityWindowController<T, ?, ?> controller) {
|
||||
return getWindowForEntity(null, controller);
|
||||
}
|
||||
|
||||
protected CommonDialogWindow getWindowForNewEntity(final AbstractEntityWindowController<T, ?> controller,
|
||||
protected CommonDialogWindow getWindowForNewEntity(final AbstractEntityWindowController<T, ?, ?> controller,
|
||||
final Component windowContent) {
|
||||
return getWindowForEntity(null, controller, windowContent);
|
||||
}
|
||||
|
||||
protected CommonDialogWindow getWindowForEntity(final T proxyEntity,
|
||||
final AbstractEntityWindowController<T, ?> controller) {
|
||||
final AbstractEntityWindowController<T, ?, ?> controller) {
|
||||
return getWindowForEntity(proxyEntity, controller, controller.getLayout().getRootComponent());
|
||||
}
|
||||
|
||||
protected CommonDialogWindow getWindowForEntity(final T proxyEntity,
|
||||
final AbstractEntityWindowController<T, ?> controller, final Component windowContent) {
|
||||
final AbstractEntityWindowController<T, ?, ?> controller, final Component windowContent) {
|
||||
controller.populateWithData(proxyEntity);
|
||||
|
||||
final CommonDialogWindow window = createWindow(windowContent, controller.getSaveDialogCloseListener());
|
||||
@@ -56,8 +56,9 @@ public abstract class AbstractEntityWindowBuilder<T> {
|
||||
|
||||
protected CommonDialogWindow createWindow(final Component content,
|
||||
final SaveDialogCloseListener saveDialogCloseListener) {
|
||||
return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).id(getWindowId()).content(content).i18n(i18n)
|
||||
.helpLink(getHelpLink()).saveDialogCloseListener(saveDialogCloseListener).buildCommonDialogWindow();
|
||||
return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).id(getWindowId()).content(content)
|
||||
.i18n(uiDependencies.getI18n()).helpLink(getHelpLink()).saveDialogCloseListener(saveDialogCloseListener)
|
||||
.buildCommonDialogWindow();
|
||||
}
|
||||
|
||||
protected abstract String getWindowId();
|
||||
@@ -73,7 +74,7 @@ public abstract class AbstractEntityWindowBuilder<T> {
|
||||
* Gets the update window
|
||||
*
|
||||
* @param entity
|
||||
* Generic type entity
|
||||
* Generic type entity
|
||||
*
|
||||
* @return window
|
||||
*/
|
||||
@@ -83,4 +84,8 @@ public abstract class AbstractEntityWindowBuilder<T> {
|
||||
// can be overriden to provide help link to documentation
|
||||
return null;
|
||||
}
|
||||
|
||||
protected VaadinMessageSource getI18n() {
|
||||
return uiDependencies.getI18n();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,23 +8,56 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.event.CommandTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.SelectionChangedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Controller for abstract entity window
|
||||
*
|
||||
* @param <T>
|
||||
* Generic type entity
|
||||
* Type of proxy entity
|
||||
* @param <E>
|
||||
* Generic type entity
|
||||
* Second type of proxy entity
|
||||
* @param <R>
|
||||
* Type of repository entity
|
||||
*/
|
||||
public abstract class AbstractEntityWindowController<T, E> {
|
||||
public abstract class AbstractEntityWindowController<T, E, R> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractEntityWindowController.class);
|
||||
|
||||
private final CommonUiDependencies uiDependencies;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param uiDependencies
|
||||
* the {@link CommonUiDependencies}
|
||||
*/
|
||||
protected AbstractEntityWindowController(final CommonUiDependencies uiDependencies) {
|
||||
this.uiDependencies = uiDependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate entity with data
|
||||
*
|
||||
* @param proxyEntity
|
||||
* Generic type entity
|
||||
* Generic type entity
|
||||
*/
|
||||
public void populateWithData(final T proxyEntity) {
|
||||
getLayout().setEntity(buildEntityFromProxy(proxyEntity));
|
||||
@@ -66,11 +99,107 @@ public abstract class AbstractEntityWindowController<T, E> {
|
||||
};
|
||||
}
|
||||
|
||||
protected abstract void persistEntity(final E entity);
|
||||
protected void persistEntity(final E entity) {
|
||||
try {
|
||||
|
||||
final R createdEntity = persistEntityInRepository(entity);
|
||||
|
||||
handleEntityPersistedSuccessfully(createdEntity);
|
||||
|
||||
selectPersistedEntity(createdEntity);
|
||||
|
||||
} catch (final ConstraintViolationException | EntityNotFoundException | EntityReadOnlyException ex) {
|
||||
|
||||
handleEntityPersistFailed(entity, ex);
|
||||
|
||||
} finally {
|
||||
|
||||
postPersist();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract R persistEntityInRepository(E entity);
|
||||
|
||||
protected void handleEntityPersistedSuccessfully(final R persistedEntity) {
|
||||
displaySuccess(getPersistSuccessMessageKey(), getDisplayableName(persistedEntity));
|
||||
publishModifiedEvent(createModifiedEventPayload(persistedEntity));
|
||||
}
|
||||
|
||||
protected void handleEntityPersistFailed(final E entity, final RuntimeException ex) {
|
||||
final String name = getDisplayableNameForFailedMessage(entity);
|
||||
final String id = Objects.toString(entity);
|
||||
final String type = getEntityClass().getSimpleName();
|
||||
LOG.warn("Persist of entity name:{}, id:{}, type:{} failed in UI with reason: {}", name, id, type,
|
||||
ex.getMessage());
|
||||
displayWarning(getPersistFailureMessageKey(), name);
|
||||
}
|
||||
|
||||
protected abstract EntityModifiedEventPayload createModifiedEventPayload(final R entity);
|
||||
|
||||
protected abstract Long getId(R entity);
|
||||
|
||||
protected abstract String getDisplayableNameForFailedMessage(E entity);
|
||||
|
||||
protected abstract String getDisplayableName(R entity);
|
||||
|
||||
protected abstract String getPersistSuccessMessageKey();
|
||||
|
||||
protected abstract String getPersistFailureMessageKey();
|
||||
|
||||
protected abstract Class<? extends ProxyIdentifiableEntity> getEntityClass();
|
||||
|
||||
protected Class<? extends ProxyIdentifiableEntity> getParentEntityClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void selectPersistedEntity(final R entity) {
|
||||
// entity is not selected by default
|
||||
}
|
||||
|
||||
protected void postPersist() {
|
||||
// empty default implementation
|
||||
}
|
||||
|
||||
protected abstract boolean isEntityValid(final E entity);
|
||||
|
||||
protected boolean closeWindowAfterSave() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected VaadinMessageSource getI18n() {
|
||||
return uiDependencies.getI18n();
|
||||
}
|
||||
|
||||
protected EntityFactory getEntityFactory() {
|
||||
return uiDependencies.getEntityFactory();
|
||||
}
|
||||
|
||||
protected UIEventBus getEventBus() {
|
||||
return uiDependencies.getEventBus();
|
||||
}
|
||||
|
||||
protected UINotification getUiNotification() {
|
||||
return uiDependencies.getUiNotification();
|
||||
}
|
||||
|
||||
protected void displaySuccess(final String messageKey, final Object... args) {
|
||||
getUiNotification().displaySuccess(getI18n().getMessage(messageKey, args));
|
||||
}
|
||||
|
||||
protected void displayValidationError(final String messageKey, final Object... args) {
|
||||
getUiNotification().displayValidationError(getI18n().getMessage(messageKey, args));
|
||||
}
|
||||
|
||||
protected void displayWarning(final String messageKey, final Object... args) {
|
||||
getUiNotification().displayWarning(getI18n().getMessage(messageKey, args));
|
||||
}
|
||||
|
||||
protected void publishModifiedEvent(final EntityModifiedEventPayload eventPayload) {
|
||||
getEventBus().publish(EventTopics.ENTITY_MODIFIED, this, eventPayload);
|
||||
}
|
||||
|
||||
protected void publishSelectionEvent(final SelectionChangedEventPayload<E> eventPayload) {
|
||||
getEventBus().publish(CommandTopics.SELECT_GRID_ENTITY, this, eventPayload);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
|
||||
/**
|
||||
* Window controller for entity updates.
|
||||
*
|
||||
* @param <T>
|
||||
* Type of proxy entity
|
||||
* @param <E>
|
||||
* Second type of proxy entity
|
||||
* @param <R>
|
||||
* Type of repository entity
|
||||
*/
|
||||
public abstract class AbstractUpdateEntityWindowController<T, E, R> extends AbstractEntityWindowController<T, E, R> {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public AbstractUpdateEntityWindowController(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistSuccessMessageKey() {
|
||||
return "message.update.success";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistFailureMessageKey() {
|
||||
return "message.deleted.or.notAllowed";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityModifiedEventPayload createModifiedEventPayload(final R entity) {
|
||||
return new EntityModifiedEventPayload(EntityModifiedEventType.ENTITY_UPDATED, getParentEntityClass(),
|
||||
getEntityClass(), getId(entity));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyNamedEntity;
|
||||
|
||||
/**
|
||||
* Window controller for entity updates.
|
||||
*
|
||||
* @param <T>
|
||||
* Type of proxy entity
|
||||
* @param <E>
|
||||
* Second type of proxy entity
|
||||
* @param <R>
|
||||
* Type of repository entity
|
||||
*/
|
||||
public abstract class AbstractUpdateNamedEntityWindowController<T, E extends ProxyNamedEntity, R extends NamedEntity>
|
||||
extends AbstractUpdateEntityWindowController<T, E, R> {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public AbstractUpdateNamedEntityWindowController(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableName(final R entity) {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final E entity) {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getId(final R entity) {
|
||||
return entity.getId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Container for commonly used dependencies in the UI.
|
||||
*/
|
||||
public class CommonUiDependencies {
|
||||
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
private final SpPermissionChecker permChecker;
|
||||
|
||||
/**
|
||||
* Public constructor.
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param permChecker
|
||||
* {@link SpPermissionChecker}
|
||||
*/
|
||||
public CommonUiDependencies(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification, final SpPermissionChecker permChecker) {
|
||||
super();
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
this.permChecker = permChecker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link VaadinMessageSource}
|
||||
*
|
||||
* @return the i18n
|
||||
*/
|
||||
public VaadinMessageSource getI18n() {
|
||||
return i18n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link EntityFactory}
|
||||
*
|
||||
* @return the entityFactory
|
||||
*/
|
||||
public EntityFactory getEntityFactory() {
|
||||
return entityFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link UIEventBus}
|
||||
*
|
||||
* @return the eventBus
|
||||
*/
|
||||
public UIEventBus getEventBus() {
|
||||
return eventBus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link UINotification}
|
||||
*
|
||||
* @return the uiNotification
|
||||
*/
|
||||
public UINotification getUiNotification() {
|
||||
return uiNotification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link SpPermissionChecker}
|
||||
*
|
||||
* @return the permChecker
|
||||
*/
|
||||
public SpPermissionChecker getPermChecker() {
|
||||
return permChecker;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
|
||||
/**
|
||||
* Base function for a validator used in window controllers.
|
||||
*/
|
||||
public class EntityValidator {
|
||||
|
||||
private final CommonUiDependencies uiDependencies;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
protected EntityValidator(final CommonUiDependencies uiDependencies) {
|
||||
this.uiDependencies = uiDependencies;
|
||||
|
||||
}
|
||||
|
||||
protected void displayValidationError(final String messageKey, final Object... args) {
|
||||
uiDependencies.getUiNotification()
|
||||
.displayValidationError(uiDependencies.getI18n().getMessage(messageKey, args));
|
||||
}
|
||||
|
||||
protected VaadinMessageSource getI18n() {
|
||||
return uiDependencies.getI18n();
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.data.filters;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetDistributionsStateDataProvider;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Filter params for {@link DistributionSetDistributionsStateDataProvider}.
|
||||
*/
|
||||
public class DsDistributionsFilterParams implements Serializable {
|
||||
public class DsDistributionsFilterParams extends DsFilterParams {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String searchText;
|
||||
private Long dsTypeId;
|
||||
|
||||
/**
|
||||
@@ -31,36 +27,17 @@ public class DsDistributionsFilterParams implements Serializable {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param searchText
|
||||
* String
|
||||
* String
|
||||
* @param dsTypeId
|
||||
* Long
|
||||
* Long
|
||||
*/
|
||||
public DsDistributionsFilterParams(final String searchText, final Long dsTypeId) {
|
||||
this.searchText = searchText;
|
||||
super(searchText);
|
||||
this.dsTypeId = dsTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the searchText
|
||||
*
|
||||
* @return SearchText
|
||||
*/
|
||||
public String getSearchText() {
|
||||
return searchText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SearchText
|
||||
*
|
||||
* @param searchText
|
||||
* String
|
||||
*/
|
||||
public void setSearchText(final String searchText) {
|
||||
this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DsTypeId
|
||||
*/
|
||||
@@ -72,7 +49,7 @@ public class DsDistributionsFilterParams implements Serializable {
|
||||
* Setter for DsTypeId
|
||||
*
|
||||
* @param dsTypeId
|
||||
* Long
|
||||
* Long
|
||||
*/
|
||||
public void setDsTypeId(final Long dsTypeId) {
|
||||
this.dsTypeId = dsTypeId;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.data.filters;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetManagementStateDataProvider;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Filter params for {@link DistributionSetManagementStateDataProvider}.
|
||||
*/
|
||||
public class DsFilterParams implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String searchText;
|
||||
|
||||
/**
|
||||
* Constructor for DsManagementFilterParams
|
||||
*/
|
||||
public DsFilterParams() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param searchText
|
||||
* String as search text
|
||||
*/
|
||||
public DsFilterParams(final String searchText) {
|
||||
this.searchText = searchText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SearchText
|
||||
*/
|
||||
public String getSearchText() {
|
||||
return searchText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for searchText
|
||||
*
|
||||
* @param searchText
|
||||
* String
|
||||
*/
|
||||
public void setSearchText(final String searchText) {
|
||||
this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,21 +8,18 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.data.filters;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetManagementStateDataProvider;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Filter params for {@link DistributionSetManagementStateDataProvider}.
|
||||
*/
|
||||
public class DsManagementFilterParams implements Serializable {
|
||||
public class DsManagementFilterParams extends DsFilterParams {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String searchText;
|
||||
private boolean noTagClicked;
|
||||
private Collection<String> distributionSetTags;
|
||||
private String pinnedTargetControllerId;
|
||||
@@ -36,7 +33,7 @@ public class DsManagementFilterParams implements Serializable {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param searchText
|
||||
* String as search text
|
||||
* @param noTagClicked
|
||||
@@ -48,29 +45,12 @@ public class DsManagementFilterParams implements Serializable {
|
||||
*/
|
||||
public DsManagementFilterParams(final String searchText, final boolean noTagClicked,
|
||||
final List<String> distributionSetTags, final String pinnedTargetControllerId) {
|
||||
this.searchText = searchText;
|
||||
super(searchText);
|
||||
this.noTagClicked = noTagClicked;
|
||||
this.distributionSetTags = distributionSetTags;
|
||||
this.pinnedTargetControllerId = pinnedTargetControllerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SearchText
|
||||
*/
|
||||
public String getSearchText() {
|
||||
return searchText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for searchText
|
||||
*
|
||||
* @param searchText
|
||||
* String
|
||||
*/
|
||||
public void setSearchText(final String searchText) {
|
||||
this.searchText = !StringUtils.isEmpty(searchText) ? String.format("%%%s%%", searchText) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DistributionSetTags
|
||||
*/
|
||||
|
||||
@@ -10,9 +10,9 @@ package org.eclipse.hawkbit.ui.common.detailslayout;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
|
||||
import com.vaadin.server.Sizeable.Unit;
|
||||
import com.vaadin.ui.Window;
|
||||
@@ -21,18 +21,18 @@ import com.vaadin.ui.Window;
|
||||
* Abstract builder for Meta data window
|
||||
*
|
||||
* @param <F>
|
||||
* Generic type
|
||||
* Generic type
|
||||
*/
|
||||
public abstract class AbstractMetaDataWindowBuilder<F> extends AbstractEntityWindowBuilder<ProxyMetaData> {
|
||||
|
||||
/**
|
||||
* Constructor for AbstractMetaDataWindowBuilder
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public AbstractMetaDataWindowBuilder(final VaadinMessageSource i18n) {
|
||||
super(i18n);
|
||||
public AbstractMetaDataWindowBuilder(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,7 +44,7 @@ public abstract class AbstractMetaDataWindowBuilder<F> extends AbstractEntityWin
|
||||
final F selectedEntityFilter, final String selectedEntityName, final ProxyMetaData proxyMetaData) {
|
||||
final CommonDialogWindow window = createWindow(metaDataWindowLayout, null);
|
||||
|
||||
window.setAssistivePrefix(i18n.getMessage("caption.metadata.popup") + " " + "<b>");
|
||||
window.setAssistivePrefix(getI18n().getMessage("caption.metadata.popup") + " " + "<b>");
|
||||
window.setCaptionAsHtml(false);
|
||||
window.setCaption(selectedEntityName);
|
||||
window.setAssistivePostfix("</b>");
|
||||
|
||||
@@ -12,9 +12,11 @@ import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.model.MetaData;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
import org.eclipse.hawkbit.ui.common.layout.AbstractGridComponentLayout;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
@@ -36,9 +38,11 @@ public abstract class AbstractMetaDataWindowLayout<F> extends HorizontalLayout {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected final VaadinMessageSource i18n;
|
||||
protected final transient UIEventBus eventBus;
|
||||
protected final UINotification uiNotification;
|
||||
protected final SpPermissionChecker permChecker;
|
||||
protected final transient UIEventBus eventBus;
|
||||
protected final transient EntityFactory entityFactory;
|
||||
protected final transient CommonUiDependencies uiDependencies;
|
||||
|
||||
private final MetadataWindowGridHeader metadataWindowGridHeader;
|
||||
|
||||
@@ -49,24 +53,19 @@ public abstract class AbstractMetaDataWindowLayout<F> extends HorizontalLayout {
|
||||
/**
|
||||
* Constructor for AbstractTagWindowLayout
|
||||
*
|
||||
* @param i18n
|
||||
* I18N
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public AbstractMetaDataWindowLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final UINotification uiNotification, final SpPermissionChecker permChecker) {
|
||||
this.i18n = i18n;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
this.permChecker = permChecker;
|
||||
public AbstractMetaDataWindowLayout(final CommonUiDependencies uiDependencies) {
|
||||
this.uiDependencies = uiDependencies;
|
||||
this.i18n = uiDependencies.getI18n();
|
||||
this.eventBus = uiDependencies.getEventBus();
|
||||
this.uiNotification = uiDependencies.getUiNotification();
|
||||
this.permChecker = uiDependencies.getPermChecker();
|
||||
this.entityFactory = uiDependencies.getEntityFactory();
|
||||
|
||||
this.metadataWindowGridHeader = new MetadataWindowGridHeader(i18n, permChecker, eventBus,
|
||||
this::hasMetadataChangePermission, this::showAddMetaDataLayout);
|
||||
this.metadataWindowGridHeader = new MetadataWindowGridHeader(uiDependencies, this::hasMetadataChangePermission,
|
||||
this::showAddMetaDataLayout);
|
||||
}
|
||||
|
||||
// can be overriden in child classes for entity-specific permission
|
||||
@@ -74,14 +73,6 @@ public abstract class AbstractMetaDataWindowLayout<F> extends HorizontalLayout {
|
||||
return permChecker.hasUpdateRepositoryPermission();
|
||||
}
|
||||
|
||||
private void showAddMetaDataLayout() {
|
||||
getMetaDataWindowGrid().deselectAll();
|
||||
getAddMetaDataWindowController().populateWithData(null);
|
||||
saveCallback.accept(getAddMetaDataWindowController().getSaveDialogCloseListener());
|
||||
|
||||
resetSaveButton();
|
||||
}
|
||||
|
||||
protected MetaData createMetaData(final ProxyMetaData entity) {
|
||||
final MetaData newMetaData = doCreateMetaData(entity);
|
||||
|
||||
@@ -144,6 +135,14 @@ public abstract class AbstractMetaDataWindowLayout<F> extends HorizontalLayout {
|
||||
|
||||
protected abstract void doDeleteMetaDataByKey(final String metaDataKey);
|
||||
|
||||
private void showAddMetaDataLayout() {
|
||||
getMetaDataWindowGrid().deselectAll();
|
||||
getAddMetaDataWindowController().populateWithData(null);
|
||||
saveCallback.accept(getAddMetaDataWindowController().getSaveDialogCloseListener());
|
||||
|
||||
resetSaveButton();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return add meta data window controller
|
||||
*/
|
||||
|
||||
@@ -12,31 +12,30 @@ import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.MetaData;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractAddEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Controller to add meta data window
|
||||
*/
|
||||
public class AddMetaDataWindowController extends AbstractEntityWindowController<ProxyMetaData, ProxyMetaData> {
|
||||
private final VaadinMessageSource i18n;
|
||||
private final UINotification uiNotification;
|
||||
|
||||
public class AddMetaDataWindowController
|
||||
extends AbstractAddEntityWindowController<ProxyMetaData, ProxyMetaData, MetaData> {
|
||||
private final MetaDataAddUpdateWindowLayout layout;
|
||||
|
||||
private final Function<ProxyMetaData, MetaData> createMetaDataCallback;
|
||||
private final Predicate<String> duplicateCheckCallback;
|
||||
private final ProxyMetadataValidator validator;
|
||||
|
||||
/**
|
||||
* Constructor for AddMetaDataWindowController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param layout
|
||||
* MetaDataAddUpdateWindowLayout
|
||||
* @param createMetaDataCallback
|
||||
@@ -44,21 +43,15 @@ public class AddMetaDataWindowController extends AbstractEntityWindowController<
|
||||
* @param duplicateCheckCallback
|
||||
* Duplicate check callback
|
||||
*/
|
||||
public AddMetaDataWindowController(final VaadinMessageSource i18n, final UINotification uiNotification,
|
||||
public AddMetaDataWindowController(final CommonUiDependencies uiDependencies,
|
||||
final MetaDataAddUpdateWindowLayout layout, final Function<ProxyMetaData, MetaData> createMetaDataCallback,
|
||||
final Predicate<String> duplicateCheckCallback) {
|
||||
this.i18n = i18n;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.layout = layout;
|
||||
|
||||
this.createMetaDataCallback = createMetaDataCallback;
|
||||
this.duplicateCheckCallback = duplicateCheckCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaDataAddUpdateWindowLayout getLayout() {
|
||||
return layout;
|
||||
this.validator = new ProxyMetadataValidator(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,36 +61,56 @@ public class AddMetaDataWindowController extends AbstractEntityWindowController<
|
||||
return new ProxyMetaData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityWindowLayout<ProxyMetaData> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptLayout(final ProxyMetaData proxyEntity) {
|
||||
layout.enableMetadataKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyMetaData entity) {
|
||||
final MetaData newMetaData = createMetaDataCallback.apply(entity);
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.metadata.saved", newMetaData.getKey()));
|
||||
protected String getPersistSuccessMessageKey() {
|
||||
return "message.metadata.saved";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MetaData persistEntityInRepository(final ProxyMetaData entity) {
|
||||
return createMetaDataCallback.apply(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableName(final MetaData entity) {
|
||||
return entity.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final ProxyMetaData entity) {
|
||||
return entity.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishModifiedEvent(final EntityModifiedEventPayload eventPayload) {
|
||||
// do not publish entity created because it is already managed by the
|
||||
// update callback that sends the event for parent entity of metadata
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getId(final MetaData entity) {
|
||||
return entity.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyMetaData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyMetaData entity) {
|
||||
if (!StringUtils.hasText(entity.getKey())) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.key.missing"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!StringUtils.hasText(entity.getValue())) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.value.missing"));
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedKey = StringUtils.trimWhitespace(entity.getKey());
|
||||
if (duplicateCheckCallback.test(trimmedKey)) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.metadata.duplicate.check", trimmedKey));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return validator.isEntityValid(entity, () -> duplicateCheckCallback.test(trimmedKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.Collection;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.AbstractMetaDataDataProvider;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
@@ -22,9 +22,6 @@ import org.eclipse.hawkbit.ui.common.grid.support.FilterSupport;
|
||||
import org.eclipse.hawkbit.ui.common.grid.support.SelectionSupport;
|
||||
import org.eclipse.hawkbit.ui.common.layout.MasterEntityAwareComponent;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Grid for MetaData pop up layout.
|
||||
@@ -45,14 +42,8 @@ public class MetaDataWindowGrid<F> extends AbstractGrid<ProxyMetaData, F> implem
|
||||
/**
|
||||
* Constructor for MetaDataWindowGrid
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param permissionChecker
|
||||
* SpPermissionChecker
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dataProvider
|
||||
* provides entity-specific metadata entities
|
||||
* @param hasMetadataChangePermission
|
||||
@@ -61,14 +52,12 @@ public class MetaDataWindowGrid<F> extends AbstractGrid<ProxyMetaData, F> implem
|
||||
* callback method to delete metadata entities
|
||||
*
|
||||
*/
|
||||
public MetaDataWindowGrid(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final SpPermissionChecker permissionChecker, final UINotification notification,
|
||||
final AbstractMetaDataDataProvider<?, F> dataProvider, final BooleanSupplier hasMetadataChangePermission,
|
||||
public MetaDataWindowGrid(final CommonUiDependencies uiDependencies, final AbstractMetaDataDataProvider<?, F> dataProvider,final BooleanSupplier hasMetadataChangePermission,
|
||||
final Predicate<Collection<ProxyMetaData>> itemsDeletionCallback) {
|
||||
super(i18n, eventBus, permissionChecker);
|
||||
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
|
||||
|
||||
this.hasMetadataChangePermission = hasMetadataChangePermission;
|
||||
this.metaDataDeleteSupport = new DeleteSupport<>(this, i18n, notification, "caption.metadata",
|
||||
this.metaDataDeleteSupport = new DeleteSupport<>(this, i18n, uiDependencies.getUiNotification(), "caption.metadata",
|
||||
"caption.metadata.plur", ProxyMetaData::getKey, itemsDeletionCallback,
|
||||
UIComponentIdProvider.METADATA_DELETE_CONFIRMATION_DIALOG);
|
||||
|
||||
|
||||
@@ -10,13 +10,11 @@ package org.eclipse.hawkbit.ui.common.detailslayout;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.grid.header.AbstractGridHeader;
|
||||
import org.eclipse.hawkbit.ui.common.grid.header.support.AddHeaderSupport;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Component;
|
||||
|
||||
@@ -31,21 +29,15 @@ public class MetadataWindowGridHeader extends AbstractGridHeader {
|
||||
/**
|
||||
* Constructor for MetadataWindowGridHeader
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param hasMetadataChangePermission
|
||||
* checks the permission allowing to change metadata entities
|
||||
* @param addNewItemCallback
|
||||
* callback method to add new metadata entities
|
||||
* Runnable
|
||||
*/
|
||||
public MetadataWindowGridHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UIEventBus eventBus, final BooleanSupplier hasMetadataChangePermission,
|
||||
final Runnable addNewItemCallback) {
|
||||
super(i18n, permChecker, eventBus);
|
||||
public MetadataWindowGridHeader(final CommonUiDependencies uiDependencies,final BooleanSupplier hasMetadataChangePermission, final Runnable addNewItemCallback) {
|
||||
super(uiDependencies.getI18n(), uiDependencies.getPermChecker(), uiDependencies.getEventBus());
|
||||
|
||||
if (hasMetadataChangePermission.getAsBoolean()) {
|
||||
this.addHeaderSupport = new AddHeaderSupport(i18n, UIComponentIdProvider.METADATA_ADD_ICON_ID,
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.detailslayout;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.EntityValidator;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Validator used in Metadata window controllers to validate
|
||||
* {@link ProxyMetaData}.
|
||||
*/
|
||||
public class ProxyMetadataValidator extends EntityValidator {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public ProxyMetadataValidator(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
boolean isEntityValid(final ProxyMetaData entity, final BooleanSupplier duplicateCheck) {
|
||||
if (!StringUtils.hasText(entity.getValue())) {
|
||||
displayValidationError("message.value.missing");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!StringUtils.hasText(entity.getKey())) {
|
||||
displayValidationError("message.key.missing");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedKey = StringUtils.trimWhitespace(entity.getKey());
|
||||
if (duplicateCheck.getAsBoolean()) {
|
||||
displayValidationError("message.metadata.duplicate.check", trimmedKey);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -18,13 +18,12 @@ import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SmMetaDataWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.SmMetaDataDataProvider;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyKeyValueDetails;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.Window;
|
||||
@@ -46,10 +45,8 @@ public class SoftwareModuleDetails extends AbstractGridDetailsLayout<ProxySoftwa
|
||||
/**
|
||||
* Constructor for SoftwareModuleDetails
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param softwareManagement
|
||||
* SoftwareModuleManagement
|
||||
* @param softwareModuleTypeManagement
|
||||
@@ -57,17 +54,17 @@ public class SoftwareModuleDetails extends AbstractGridDetailsLayout<ProxySoftwa
|
||||
* @param smMetaDataWindowBuilder
|
||||
* SmMetaDataWindowBuilder
|
||||
*/
|
||||
public SoftwareModuleDetails(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final SoftwareModuleManagement softwareManagement,
|
||||
public SoftwareModuleDetails(final CommonUiDependencies uiDependencies, final SoftwareModuleManagement softwareManagement,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement,
|
||||
final SmMetaDataWindowBuilder smMetaDataWindowBuilder) {
|
||||
super(i18n);
|
||||
super(uiDependencies.getI18n());
|
||||
|
||||
this.smMetaDataWindowBuilder = smMetaDataWindowBuilder;
|
||||
this.softwareModuleTypeManagement = softwareModuleTypeManagement;
|
||||
|
||||
this.smMetadataGrid = new MetadataDetailsGrid<>(i18n, eventBus, UIComponentIdProvider.SW_TYPE_PREFIX,
|
||||
this::showMetadataDetails, new SmMetaDataDataProvider(softwareManagement));
|
||||
this.smMetadataGrid = new MetadataDetailsGrid<>(i18n, uiDependencies.getEventBus(),
|
||||
UIComponentIdProvider.SW_TYPE_PREFIX, this::showMetadataDetails,
|
||||
new SmMetaDataDataProvider(softwareManagement));
|
||||
|
||||
addDetailsComponents(Arrays.asList(new SimpleEntry<>(i18n.getMessage("caption.tab.details"), entityDetails),
|
||||
new SimpleEntry<>(i18n.getMessage("caption.tab.description"), entityDescription),
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModuleDetails;
|
||||
@@ -51,7 +52,7 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
* Software module details table.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SoftwareModuleDetailsGrid extends Grid<ProxySoftwareModuleDetails>
|
||||
implements MasterEntityAwareComponent<ProxyDistributionSet> {
|
||||
@@ -77,15 +78,9 @@ public class SoftwareModuleDetailsGrid extends Grid<ProxySoftwareModuleDetails>
|
||||
|
||||
/**
|
||||
* Initialize software module table- to be displayed in details layout.
|
||||
*
|
||||
* @param i18n
|
||||
* I18N
|
||||
* @param eventBus
|
||||
* SessionEventBus
|
||||
* @param uiNotification
|
||||
* UINotification for displaying error and success notifications
|
||||
* @param permissionChecker
|
||||
* SpPermissionChecker
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param distributionSetManagement
|
||||
* DistributionSetManagement
|
||||
* @param smManagement
|
||||
@@ -93,14 +88,13 @@ public class SoftwareModuleDetailsGrid extends Grid<ProxySoftwareModuleDetails>
|
||||
* @param dsTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
*/
|
||||
public SoftwareModuleDetailsGrid(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final UINotification uiNotification, final SpPermissionChecker permissionChecker,
|
||||
public SoftwareModuleDetailsGrid(final CommonUiDependencies uiDependencies,
|
||||
final DistributionSetManagement distributionSetManagement, final SoftwareModuleManagement smManagement,
|
||||
final DistributionSetTypeManagement dsTypeManagement) {
|
||||
this.i18n = i18n;
|
||||
this.uiNotification = uiNotification;
|
||||
this.eventBus = eventBus;
|
||||
this.permissionChecker = permissionChecker;
|
||||
this.i18n = uiDependencies.getI18n();
|
||||
this.uiNotification = uiDependencies.getUiNotification();
|
||||
this.eventBus = uiDependencies.getEventBus();
|
||||
this.permissionChecker = uiDependencies.getPermChecker();
|
||||
|
||||
this.distributionSetManagement = distributionSetManagement;
|
||||
this.smManagement = smManagement;
|
||||
|
||||
@@ -9,18 +9,15 @@
|
||||
package org.eclipse.hawkbit.ui.common.detailslayout;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsGrid;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SmMetaDataWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SmWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.grid.header.AbstractDetailsHeader;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.shared.ui.window.WindowMode;
|
||||
import com.vaadin.ui.UI;
|
||||
@@ -34,6 +31,7 @@ public class SoftwareModuleDetailsHeader extends AbstractDetailsHeader<ProxySoft
|
||||
|
||||
private final transient SmWindowBuilder smWindowBuilder;
|
||||
private final transient SmMetaDataWindowBuilder smMetaDataWindowBuilder;
|
||||
private final transient CommonUiDependencies uiDependencies;
|
||||
|
||||
private transient ArtifactDetailsHeaderSupport artifactDetailsHeaderSupport;
|
||||
private transient ArtifactManagement artifactManagement;
|
||||
@@ -42,23 +40,17 @@ public class SoftwareModuleDetailsHeader extends AbstractDetailsHeader<ProxySoft
|
||||
/**
|
||||
* Constructor for SoftwareModuleDetailsHeader
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param smWindowBuilder
|
||||
* SmWindowBuilder
|
||||
* @param smMetaDataWindowBuilder
|
||||
* SmMetaDataWindowBuilder
|
||||
*/
|
||||
public SoftwareModuleDetailsHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UIEventBus eventBus, final UINotification uiNotification, final SmWindowBuilder smWindowBuilder,
|
||||
public SoftwareModuleDetailsHeader(final CommonUiDependencies uiDependencies, final SmWindowBuilder smWindowBuilder,
|
||||
final SmMetaDataWindowBuilder smMetaDataWindowBuilder) {
|
||||
super(i18n, permChecker, eventBus, uiNotification);
|
||||
super(uiDependencies.getI18n(), uiDependencies.getPermChecker(), uiDependencies.getEventBus(), uiDependencies.getUiNotification());
|
||||
this.uiDependencies = uiDependencies;
|
||||
|
||||
this.smWindowBuilder = smWindowBuilder;
|
||||
this.smMetaDataWindowBuilder = smMetaDataWindowBuilder;
|
||||
@@ -156,8 +148,7 @@ public class SoftwareModuleDetailsHeader extends AbstractDetailsHeader<ProxySoft
|
||||
}
|
||||
|
||||
if (artifactDetailsGrid == null) {
|
||||
artifactDetailsGrid = new ArtifactDetailsGrid(eventBus, i18n, permChecker, uiNotification,
|
||||
artifactManagement);
|
||||
artifactDetailsGrid = new ArtifactDetailsGrid(uiDependencies, artifactManagement);
|
||||
}
|
||||
setInitialArtifactDetailsGridSize(artifactDetailsGrid);
|
||||
artifactDetailsGrid.getMasterEntitySupport().masterEntityChanged(selectedEntity);
|
||||
|
||||
@@ -9,58 +9,51 @@
|
||||
package org.eclipse.hawkbit.ui.common.detailslayout;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.model.MetaData;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractUpdateEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Controller for update meta data window
|
||||
*/
|
||||
public class UpdateMetaDataWindowController extends AbstractEntityWindowController<ProxyMetaData, ProxyMetaData> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UpdateMetaDataWindowController.class);
|
||||
|
||||
private final VaadinMessageSource i18n;
|
||||
private final UINotification uiNotification;
|
||||
public class UpdateMetaDataWindowController
|
||||
extends AbstractUpdateEntityWindowController<ProxyMetaData, ProxyMetaData, MetaData> {
|
||||
|
||||
private final MetaDataAddUpdateWindowLayout layout;
|
||||
|
||||
private final Function<ProxyMetaData, MetaData> updateMetaDataCallback;
|
||||
private final Predicate<String> duplicateCheckCallback;
|
||||
private final ProxyMetadataValidator validator;
|
||||
|
||||
private String keyBeforeEdit;
|
||||
|
||||
/**
|
||||
* Constructor for UpdateMetaDataWindowController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param layout
|
||||
* MetaDataAddUpdateWindowLayout
|
||||
* @param updateMetaDataCallback
|
||||
* Update meta data call back function for event listener
|
||||
*
|
||||
* @param duplicateCheckCallback
|
||||
* call back to check if entity already exists in repository
|
||||
*/
|
||||
public UpdateMetaDataWindowController(final VaadinMessageSource i18n, final UINotification uiNotification,
|
||||
final MetaDataAddUpdateWindowLayout layout,
|
||||
final Function<ProxyMetaData, MetaData> updateMetaDataCallback) {
|
||||
this.i18n = i18n;
|
||||
this.uiNotification = uiNotification;
|
||||
public UpdateMetaDataWindowController(final CommonUiDependencies uiDependencies,
|
||||
final MetaDataAddUpdateWindowLayout layout, final Function<ProxyMetaData, MetaData> updateMetaDataCallback,
|
||||
final Predicate<String> duplicateCheckCallback) {
|
||||
super(uiDependencies);
|
||||
|
||||
this.layout = layout;
|
||||
|
||||
this.updateMetaDataCallback = updateMetaDataCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaDataAddUpdateWindowLayout getLayout() {
|
||||
return layout;
|
||||
this.duplicateCheckCallback = duplicateCheckCallback;
|
||||
this.validator = new ProxyMetadataValidator(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,44 +65,75 @@ public class UpdateMetaDataWindowController extends AbstractEntityWindowControll
|
||||
metaData.setEntityId(proxyEntity.getEntityId());
|
||||
metaData.setVisibleForTargets(proxyEntity.isVisibleForTargets());
|
||||
|
||||
keyBeforeEdit = proxyEntity.getKey();
|
||||
|
||||
return metaData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityWindowLayout<ProxyMetaData> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptLayout(final ProxyMetaData proxyEntity) {
|
||||
layout.disableMetadataKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyMetaData entity) {
|
||||
try {
|
||||
final MetaData updatedMetaData = updateMetaDataCallback.apply(entity);
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.metadata.updated", updatedMetaData.getKey()));
|
||||
} catch (final EntityNotFoundException | EntityReadOnlyException e) {
|
||||
LOG.trace("Update of meta data failed in UI: {}", e.getMessage());
|
||||
final String entityType = i18n.getMessage("caption.metadata");
|
||||
uiNotification
|
||||
.displayWarning(i18n.getMessage("message.key.deleted.or.notAllowed", entityType, entity.getKey()));
|
||||
}
|
||||
protected boolean closeWindowAfterSave() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MetaData persistEntityInRepository(final ProxyMetaData entity) {
|
||||
return updateMetaDataCallback.apply(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistSuccessMessageKey() {
|
||||
return "message.metadata.updated";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistFailureMessageKey() {
|
||||
return "message.key.deleted.or.notAllowed";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableName(final MetaData entity) {
|
||||
return entity.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final ProxyMetaData entity) {
|
||||
return entity.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getId(final MetaData entity) {
|
||||
return entity.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishModifiedEvent(final EntityModifiedEventPayload eventPayload) {
|
||||
// do not publish entity updated because it is already managed by the
|
||||
// update callback that sends the event for parent entity of metadata
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyMetaData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyMetaData entity) {
|
||||
if (!StringUtils.hasText(entity.getKey())) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.key.missing"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!StringUtils.hasText(entity.getValue())) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.value.missing"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
final String trimmedKey = StringUtils.trimWhitespace(entity.getKey());
|
||||
return validator.isEntityValid(entity,
|
||||
() -> hasKeyChanged(trimmedKey) && duplicateCheckCallback.test(trimmedKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean closeWindowAfterSave() {
|
||||
return false;
|
||||
private boolean hasKeyChanged(final String trimmedKey) {
|
||||
return !keyBeforeEdit.equals(trimmedKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.distributionset;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.filters.DsFilterParams;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.layout.AbstractGridComponentLayout;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.TopicEventListener;
|
||||
|
||||
/**
|
||||
* Abstract base class for distribution set grid layouts.
|
||||
*/
|
||||
public abstract class AbstractDistributionSetGridLayout extends AbstractGridComponentLayout {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final transient Set<TopicEventListener> listeners = new HashSet<>();
|
||||
private final transient DsWindowBuilder dsWindowBuilder;
|
||||
private final transient DsMetaDataWindowBuilder dsMetaDataWindowBuilder;
|
||||
private final EventView eventView;
|
||||
|
||||
/**
|
||||
* Constructor for AbstractDistributionSetGridLayout
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param systemManagement
|
||||
* SystemManagement
|
||||
* @param systemSecurityContext
|
||||
* SystemSecurityContext
|
||||
* @param configManagement
|
||||
* TenantConfigurationManagement
|
||||
* @param distributionSetManagement
|
||||
* DistributionSetManagement
|
||||
* @param distributionSetTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* @param eventView
|
||||
* EventView
|
||||
*/
|
||||
public AbstractDistributionSetGridLayout(final CommonUiDependencies uiDependencies,
|
||||
final SystemManagement systemManagement, final SystemSecurityContext systemSecurityContext,
|
||||
final TenantConfigurationManagement configManagement,
|
||||
final DistributionSetManagement distributionSetManagement,
|
||||
final DistributionSetTypeManagement distributionSetTypeManagement, final EventView eventView) {
|
||||
|
||||
this.eventView = eventView;
|
||||
|
||||
dsWindowBuilder = new DsWindowBuilder(uiDependencies, systemManagement, systemSecurityContext, configManagement,
|
||||
distributionSetManagement, distributionSetTypeManagement, eventView);
|
||||
dsMetaDataWindowBuilder = new DsMetaDataWindowBuilder(uiDependencies, distributionSetManagement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link DsMetaDataWindowBuilder}.
|
||||
*
|
||||
* @return the dsMetaDataWindowBuilder
|
||||
*/
|
||||
public DsMetaDataWindowBuilder getDsMetaDataWindowBuilder() {
|
||||
return dsMetaDataWindowBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link DsWindowBuilder}.
|
||||
*
|
||||
* @return the dsWindowBuilder
|
||||
*/
|
||||
public DsWindowBuilder getDsWindowBuilder() {
|
||||
return dsWindowBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link EventView}
|
||||
*
|
||||
* @return the eventView
|
||||
*/
|
||||
public EventView getEventView() {
|
||||
return eventView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link AbstractDsGrid}
|
||||
*
|
||||
* @return the distributionGrid
|
||||
*/
|
||||
public abstract <T extends DsFilterParams> AbstractDsGrid<T> getDistributionGrid();
|
||||
|
||||
/**
|
||||
* Returns the {@link DistributionSetGridHeader}
|
||||
*
|
||||
* @return the distributionGridHeader
|
||||
*/
|
||||
public abstract DistributionSetGridHeader getDistributionSetGridHeader();
|
||||
|
||||
/**
|
||||
* Show distribution set filter header icon
|
||||
*/
|
||||
public void showDsFilterHeaderIcon() {
|
||||
getDistributionSetGridHeader().showFilterIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide distribution set filter header icon
|
||||
*/
|
||||
public void hideDsFilterHeaderIcon() {
|
||||
getDistributionSetGridHeader().hideFilterIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximize the distribution grid
|
||||
*/
|
||||
public void maximize() {
|
||||
getDistributionGrid().createMaximizedContent();
|
||||
hideDetailsLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimize the distribution grid
|
||||
*/
|
||||
public void minimize() {
|
||||
getDistributionGrid().createMinimizedContent();
|
||||
showDetailsLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the distribution grid state
|
||||
*/
|
||||
public void restoreState() {
|
||||
getDistributionSetGridHeader().restoreState();
|
||||
getDistributionGrid().restoreState();
|
||||
}
|
||||
|
||||
protected void addEventListener(final TopicEventListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe the event listeners.
|
||||
*/
|
||||
public void unsubscribeListener() {
|
||||
listeners.forEach(TopicEventListener::unsubscribe);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
@@ -6,14 +6,14 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.grid;
|
||||
package org.eclipse.hawkbit.ui.common.distributionset;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.DistributionSetToProxyDistributionMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
@@ -23,13 +23,12 @@ import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModi
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
|
||||
import org.eclipse.hawkbit.ui.common.grid.support.DeleteSupport;
|
||||
import org.eclipse.hawkbit.ui.common.grid.support.SelectionSupport;
|
||||
import org.eclipse.hawkbit.ui.common.state.GridLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Button;
|
||||
|
||||
@@ -50,15 +49,14 @@ public abstract class AbstractDsGrid<F> extends AbstractGrid<ProxyDistributionSe
|
||||
protected final GridLayoutUiState distributionSetGridLayoutUiState;
|
||||
protected final transient DistributionSetManagement dsManagement;
|
||||
protected final transient DistributionSetToProxyDistributionMapper dsToProxyDistributionMapper;
|
||||
|
||||
protected final transient DeleteSupport<ProxyDistributionSet> distributionDeleteSupport;
|
||||
protected final transient UINotification notification;
|
||||
|
||||
protected AbstractDsGrid(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final SpPermissionChecker permissionChecker, final UINotification notification,
|
||||
final DistributionSetManagement dsManagement, final GridLayoutUiState distributionSetGridLayoutUiState,
|
||||
final EventView view) {
|
||||
super(i18n, eventBus, permissionChecker);
|
||||
protected AbstractDsGrid(final CommonUiDependencies uiDependencies, final DistributionSetManagement dsManagement,
|
||||
final GridLayoutUiState distributionSetGridLayoutUiState, final EventView view) {
|
||||
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
|
||||
|
||||
this.notification = uiDependencies.getUiNotification();
|
||||
this.distributionSetGridLayoutUiState = distributionSetGridLayoutUiState;
|
||||
this.dsManagement = dsManagement;
|
||||
this.dsToProxyDistributionMapper = new DistributionSetToProxyDistributionMapper();
|
||||
@@ -6,7 +6,7 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.detailslayout;
|
||||
package org.eclipse.hawkbit.ui.common.distributionset;
|
||||
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.Arrays;
|
||||
@@ -22,16 +22,17 @@ import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.DsMetaDataDataProvider;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyKeyValueDetails;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractGridDetailsLayout;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.MetadataDetailsGrid;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsGrid;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.TargetFilterQueryDetailsGrid;
|
||||
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.DsMetaDataWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.Window;
|
||||
@@ -59,14 +60,8 @@ public class DistributionSetDetails extends AbstractGridDetailsLayout<ProxyDistr
|
||||
/**
|
||||
* Constructor for DistributionSetDetails
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param permissionChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dsManagement
|
||||
* DistributionSetManagement
|
||||
* @param smManagement
|
||||
@@ -82,27 +77,25 @@ public class DistributionSetDetails extends AbstractGridDetailsLayout<ProxyDistr
|
||||
* @param dsMetaDataWindowBuilder
|
||||
* DsMetaDataWindowBuilder
|
||||
*/
|
||||
public DistributionSetDetails(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final SpPermissionChecker permissionChecker, final UINotification uiNotification,
|
||||
final DistributionSetManagement dsManagement, final SoftwareModuleManagement smManagement,
|
||||
final DistributionSetTypeManagement dsTypeManagement, final DistributionSetTagManagement dsTagManagement,
|
||||
public DistributionSetDetails(final CommonUiDependencies uiDependencies, final DistributionSetManagement dsManagement,
|
||||
final SoftwareModuleManagement smManagement, final DistributionSetTypeManagement dsTypeManagement,
|
||||
final DistributionSetTagManagement dsTagManagement,
|
||||
final TenantConfigurationManagement tenantConfigurationManagement,
|
||||
final SystemSecurityContext systemSecurityContext, final DsMetaDataWindowBuilder dsMetaDataWindowBuilder) {
|
||||
super(i18n);
|
||||
super(uiDependencies.getI18n());
|
||||
|
||||
this.tenantConfigurationManagement = tenantConfigurationManagement;
|
||||
this.systemSecurityContext = systemSecurityContext;
|
||||
this.permissionChecker = permissionChecker;
|
||||
this.permissionChecker = uiDependencies.getPermChecker();
|
||||
this.dsMetaDataWindowBuilder = dsMetaDataWindowBuilder;
|
||||
|
||||
this.smDetailsGrid = new SoftwareModuleDetailsGrid(i18n, eventBus, uiNotification, permissionChecker,
|
||||
dsManagement, smManagement, dsTypeManagement);
|
||||
this.smDetailsGrid = new SoftwareModuleDetailsGrid(uiDependencies, dsManagement, smManagement, dsTypeManagement);
|
||||
|
||||
this.distributionTagToken = new DistributionTagToken(permissionChecker, i18n, uiNotification, eventBus,
|
||||
dsTagManagement, dsManagement);
|
||||
this.distributionTagToken = new DistributionTagToken(uiDependencies, dsTagManagement, dsManagement);
|
||||
|
||||
this.dsMetadataGrid = new MetadataDetailsGrid<>(i18n, eventBus, UIComponentIdProvider.DS_TYPE_PREFIX,
|
||||
this::showMetadataDetails, new DsMetaDataDataProvider(dsManagement));
|
||||
this.dsMetadataGrid = new MetadataDetailsGrid<>(uiDependencies.getI18n(), uiDependencies.getEventBus(),
|
||||
UIComponentIdProvider.DS_TYPE_PREFIX, this::showMetadataDetails,
|
||||
new DsMetaDataDataProvider(dsManagement));
|
||||
|
||||
addDetailsComponents(Arrays.asList(new SimpleEntry<>(i18n.getMessage("caption.tab.details"), entityDetails),
|
||||
new SimpleEntry<>(i18n.getMessage("caption.tab.description"), entityDescription),
|
||||
@@ -6,17 +6,12 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.detailslayout;
|
||||
package org.eclipse.hawkbit.ui.common.distributionset;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.grid.header.AbstractDetailsHeader;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.DsMetaDataWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.DsWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.Window;
|
||||
@@ -33,23 +28,17 @@ public class DistributionSetDetailsHeader extends AbstractDetailsHeader<ProxyDis
|
||||
/**
|
||||
* Constructor for DistributionSetDetailsHeader
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dsWindowBuilder
|
||||
* DsWindowBuilder
|
||||
* @param dsMetaDataWindowBuilder
|
||||
* DsMetaDataWindowBuilder
|
||||
*/
|
||||
public DistributionSetDetailsHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UIEventBus eventBus, final UINotification uiNotification, final DsWindowBuilder dsWindowBuilder,
|
||||
final DsMetaDataWindowBuilder dsMetaDataWindowBuilder) {
|
||||
super(i18n, permChecker, eventBus, uiNotification);
|
||||
public DistributionSetDetailsHeader(final CommonUiDependencies uiDependencies,
|
||||
final DsWindowBuilder dsWindowBuilder, final DsMetaDataWindowBuilder dsMetaDataWindowBuilder) {
|
||||
super(uiDependencies.getI18n(), uiDependencies.getPermChecker(), uiDependencies.getEventBus(),
|
||||
uiDependencies.getUiNotification());
|
||||
|
||||
this.dsWindowBuilder = dsWindowBuilder;
|
||||
this.dsMetaDataWindowBuilder = dsMetaDataWindowBuilder;
|
||||
@@ -6,9 +6,9 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.distributions.dstable;
|
||||
package org.eclipse.hawkbit.ui.common.distributionset;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
@@ -17,8 +17,6 @@ import org.eclipse.hawkbit.ui.common.grid.header.AbstractEntityGridHeader;
|
||||
import org.eclipse.hawkbit.ui.common.state.GridLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.common.state.HidableLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Distribution table header.
|
||||
@@ -32,27 +30,22 @@ public class DistributionSetGridHeader extends AbstractEntityGridHeader {
|
||||
/**
|
||||
* Constructor for DistributionSetGridHeader
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dSTypeFilterLayoutUiState
|
||||
* HidableLayoutUiState
|
||||
* HidableLayoutUiState
|
||||
* @param distributionSetGridLayoutUiState
|
||||
* GridLayoutUiState
|
||||
* GridLayoutUiState
|
||||
* @param filterLayout
|
||||
* EventLayout
|
||||
* EventLayout
|
||||
* @param view
|
||||
* EventView
|
||||
* EventView
|
||||
*/
|
||||
public DistributionSetGridHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UIEventBus eventBus, final HidableLayoutUiState dSTypeFilterLayoutUiState,
|
||||
public DistributionSetGridHeader(final CommonUiDependencies uiDependencies,
|
||||
final HidableLayoutUiState dSTypeFilterLayoutUiState,
|
||||
final GridLayoutUiState distributionSetGridLayoutUiState, final EventLayout filterLayout,
|
||||
final EventView view) {
|
||||
super(i18n, permChecker, eventBus, dSTypeFilterLayoutUiState, distributionSetGridLayoutUiState, filterLayout,
|
||||
view);
|
||||
super(uiDependencies, dSTypeFilterLayoutUiState, distributionSetGridLayoutUiState, filterLayout, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -6,16 +6,13 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.distributions.dstable;
|
||||
package org.eclipse.hawkbit.ui.common.distributionset;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractMetaDataWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.DsMetaDataWindowLayout;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -23,38 +20,19 @@ import com.vaadin.ui.Window;
|
||||
* Builder for DistributionSet meta data window
|
||||
*/
|
||||
public class DsMetaDataWindowBuilder extends AbstractMetaDataWindowBuilder<Long> {
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
private final SpPermissionChecker permChecker;
|
||||
|
||||
private final DistributionSetManagement dsManagement;
|
||||
|
||||
/**
|
||||
* Constructor for DsMetaDataWindowBuilder
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dsManagement
|
||||
* DistributionSetManagement
|
||||
*/
|
||||
public DsMetaDataWindowBuilder(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification, final SpPermissionChecker permChecker,
|
||||
final DistributionSetManagement dsManagement) {
|
||||
super(i18n);
|
||||
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
this.permChecker = permChecker;
|
||||
public DsMetaDataWindowBuilder(final CommonUiDependencies uiDependencies, final DistributionSetManagement dsManagement) {
|
||||
super(uiDependencies);
|
||||
|
||||
this.dsManagement = dsManagement;
|
||||
}
|
||||
@@ -86,8 +64,6 @@ public class DsMetaDataWindowBuilder extends AbstractMetaDataWindowBuilder<Long>
|
||||
* @return Dialog window
|
||||
*/
|
||||
public Window getWindowForShowDsMetaData(final Long dsId, final String name, final ProxyMetaData proxyMetaData) {
|
||||
return getWindowForShowMetaData(
|
||||
new DsMetaDataWindowLayout(i18n, eventBus, permChecker, uiNotification, entityFactory, dsManagement),
|
||||
dsId, name, proxyMetaData);
|
||||
return getWindowForShowMetaData(new DsMetaDataWindowLayout(uiDependencies, dsManagement), dsId, name, proxyMetaData);
|
||||
}
|
||||
}
|
||||
@@ -6,21 +6,21 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.distributions.dstable;
|
||||
package org.eclipse.hawkbit.ui.common.distributionset;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.AddDsWindowController;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.DsWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.UpdateDsWindowController;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -28,9 +28,6 @@ import com.vaadin.ui.Window;
|
||||
* Builder for distribution set window
|
||||
*/
|
||||
public class DsWindowBuilder extends AbstractEntityWindowBuilder<ProxyDistributionSet> {
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
private final SystemManagement systemManagement;
|
||||
private final SystemSecurityContext systemSecurityContext;
|
||||
private final TenantConfigurationManagement tenantConfigurationManagement;
|
||||
@@ -43,38 +40,28 @@ public class DsWindowBuilder extends AbstractEntityWindowBuilder<ProxyDistributi
|
||||
/**
|
||||
* Constructor for DsWindowBuilder
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param systemManagement
|
||||
* SystemManagement
|
||||
* SystemManagement
|
||||
* @param systemSecurityContext
|
||||
* SystemSecurityContext
|
||||
* SystemSecurityContext
|
||||
* @param tenantConfigurationManagement
|
||||
* TenantConfigurationManagement
|
||||
* TenantConfigurationManagement
|
||||
* @param dsManagement
|
||||
* DistributionSetManagement
|
||||
* DistributionSetManagement
|
||||
* @param dsTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* @param view
|
||||
* EventView
|
||||
* EventView
|
||||
*/
|
||||
public DsWindowBuilder(final VaadinMessageSource i18n, final EntityFactory entityFactory, final UIEventBus eventBus,
|
||||
final UINotification uiNotification, final SystemManagement systemManagement,
|
||||
public DsWindowBuilder(final CommonUiDependencies uiDependencies, final SystemManagement systemManagement,
|
||||
final SystemSecurityContext systemSecurityContext,
|
||||
final TenantConfigurationManagement tenantConfigurationManagement,
|
||||
final DistributionSetManagement dsManagement, final DistributionSetTypeManagement dsTypeManagement,
|
||||
final EventView view) {
|
||||
super(i18n);
|
||||
super(uiDependencies);
|
||||
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
this.systemManagement = systemManagement;
|
||||
this.systemSecurityContext = systemSecurityContext;
|
||||
this.tenantConfigurationManagement = tenantConfigurationManagement;
|
||||
@@ -92,17 +79,16 @@ public class DsWindowBuilder extends AbstractEntityWindowBuilder<ProxyDistributi
|
||||
|
||||
@Override
|
||||
public Window getWindowForAdd() {
|
||||
return getWindowForNewEntity(new AddDsWindowController(i18n, entityFactory, eventBus, uiNotification,
|
||||
systemManagement, dsManagement,
|
||||
new DsWindowLayout(i18n, systemSecurityContext, tenantConfigurationManagement, dsTypeManagement),
|
||||
return getWindowForNewEntity(new AddDsWindowController(uiDependencies, systemManagement, dsManagement,
|
||||
new DsWindowLayout(uiDependencies.getI18n(), systemSecurityContext, tenantConfigurationManagement,
|
||||
dsTypeManagement),
|
||||
view));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window getWindowForUpdate(final ProxyDistributionSet proxyDs) {
|
||||
return getWindowForEntity(proxyDs, new UpdateDsWindowController(i18n, entityFactory, eventBus, uiNotification,
|
||||
dsManagement,
|
||||
new DsWindowLayout(i18n, systemSecurityContext, tenantConfigurationManagement, dsTypeManagement)));
|
||||
return getWindowForEntity(proxyDs, new UpdateDsWindowController(uiDependencies, dsManagement,
|
||||
new DsWindowLayout(getI18n(), systemSecurityContext, tenantConfigurationManagement, dsTypeManagement)));
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
@@ -30,9 +30,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.UI;
|
||||
@@ -46,31 +44,24 @@ public abstract class AbstractTagFilterButtons extends AbstractFilterButtons<Pro
|
||||
|
||||
private final TagFilterLayoutUiState tagFilterLayoutUiState;
|
||||
|
||||
private final UINotification uiNotification;
|
||||
protected final UINotification uiNotification;
|
||||
private final Button noTagButton;
|
||||
private final transient TagFilterButtonClick tagFilterButtonClick;
|
||||
|
||||
/**
|
||||
* Constructor for AbstractTagFilterButtons
|
||||
*
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param tagFilterLayoutUiState
|
||||
* TagFilterLayoutUiState
|
||||
*/
|
||||
public AbstractTagFilterButtons(final UIEventBus eventBus, final VaadinMessageSource i18n,
|
||||
final UINotification uiNotification, final SpPermissionChecker permChecker,
|
||||
public AbstractTagFilterButtons(final CommonUiDependencies uiDependencies,
|
||||
final TagFilterLayoutUiState tagFilterLayoutUiState) {
|
||||
super(eventBus, i18n, uiNotification, permChecker);
|
||||
super(uiDependencies.getEventBus(), uiDependencies.getI18n(), uiDependencies.getUiNotification(), uiDependencies.getPermChecker());
|
||||
|
||||
this.uiNotification = uiDependencies.getUiNotification();
|
||||
this.tagFilterLayoutUiState = tagFilterLayoutUiState;
|
||||
this.uiNotification = uiNotification;
|
||||
this.noTagButton = buildNoTagButton();
|
||||
this.tagFilterButtonClick = new TagFilterButtonClick(this::onFilterChangedEvent, this::onNoTagChangedEvent);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.common.filterlayout;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
@@ -22,8 +22,6 @@ import org.eclipse.hawkbit.ui.common.event.FilterType;
|
||||
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour.ClickBehaviourType;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.Window;
|
||||
@@ -42,23 +40,16 @@ public abstract class AbstractTypeFilterButtons extends AbstractFilterButtons<Pr
|
||||
/**
|
||||
* Constructor for AbstractTypeFilterButtons
|
||||
*
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param typeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
*/
|
||||
public AbstractTypeFilterButtons(final UIEventBus eventBus, final VaadinMessageSource i18n,
|
||||
final UINotification uiNotification, final SpPermissionChecker permChecker,
|
||||
public AbstractTypeFilterButtons(final CommonUiDependencies uiDependencies,
|
||||
final TypeFilterLayoutUiState typeFilterLayoutUiState) {
|
||||
super(eventBus, i18n, uiNotification, permChecker);
|
||||
super(uiDependencies.getEventBus(), uiDependencies.getI18n(), uiDependencies.getUiNotification(), uiDependencies.getPermChecker());
|
||||
|
||||
this.uiNotification = uiNotification;
|
||||
this.uiNotification = uiDependencies.getUiNotification();
|
||||
this.typeFilterLayoutUiState = typeFilterLayoutUiState;
|
||||
this.typeFilterButtonClick = new TypeFilterButtonClick(this::onFilterChanged);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ package org.eclipse.hawkbit.ui.common.grid.header;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.event.CommandTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
@@ -30,8 +30,6 @@ import org.eclipse.hawkbit.ui.common.grid.header.support.SearchHeaderSupport;
|
||||
import org.eclipse.hawkbit.ui.common.state.GridLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.common.state.HidableLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.UI;
|
||||
@@ -59,12 +57,8 @@ public abstract class AbstractEntityGridHeader extends AbstractGridHeader {
|
||||
/**
|
||||
* Constructor for AbstractEntityGridHeader
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param filterLayoutUiState
|
||||
* HidableLayoutUiState
|
||||
* @param gridLayoutUiState
|
||||
@@ -74,10 +68,9 @@ public abstract class AbstractEntityGridHeader extends AbstractGridHeader {
|
||||
* @param view
|
||||
* EventView
|
||||
*/
|
||||
public AbstractEntityGridHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UIEventBus eventBus, final HidableLayoutUiState filterLayoutUiState,
|
||||
public AbstractEntityGridHeader(final CommonUiDependencies uiDependencies, final HidableLayoutUiState filterLayoutUiState,
|
||||
final GridLayoutUiState gridLayoutUiState, final EventLayout filterLayout, final EventView view) {
|
||||
super(i18n, permChecker, eventBus);
|
||||
super(uiDependencies.getI18n(), uiDependencies.getPermChecker(), uiDependencies.getEventBus());
|
||||
|
||||
this.filterLayoutUiState = filterLayoutUiState;
|
||||
this.gridLayoutUiState = gridLayoutUiState;
|
||||
|
||||
@@ -18,20 +18,19 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.AbstractAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Support for assigning the {@link ProxyDistributionSet} items to
|
||||
* {@link ProxyTag}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DistributionSetsToTagAssignmentSupport
|
||||
extends ToTagAssignmentSupport<ProxyDistributionSet, DistributionSet> {
|
||||
@@ -42,25 +41,18 @@ public class DistributionSetsToTagAssignmentSupport
|
||||
/**
|
||||
* Constructor for DistributionSetsToTagAssignmentSupport
|
||||
*
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param distributionSetManagement
|
||||
* DistributionSetManagement
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
*/
|
||||
public DistributionSetsToTagAssignmentSupport(final UINotification notification, final VaadinMessageSource i18n,
|
||||
final DistributionSetManagement distributionSetManagement, final UIEventBus eventBus,
|
||||
final SpPermissionChecker permChecker) {
|
||||
super(notification, i18n);
|
||||
public DistributionSetsToTagAssignmentSupport(final CommonUiDependencies uiDependencies,
|
||||
final DistributionSetManagement distributionSetManagement) {
|
||||
super(uiDependencies.getUiNotification(), uiDependencies.getI18n());
|
||||
|
||||
this.distributionSetManagement = distributionSetManagement;
|
||||
this.eventBus = eventBus;
|
||||
this.permChecker = permChecker;
|
||||
this.eventBus = uiDependencies.getEventBus();
|
||||
this.permChecker = uiDependencies.getPermChecker();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,17 +17,16 @@ import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
|
||||
import org.eclipse.hawkbit.ui.management.miscs.DeploymentAssignmentWindowController;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
|
||||
/**
|
||||
* Support for assigning the distribution sets to target.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DistributionSetsToTargetAssignmentSupport
|
||||
extends DeploymentAssignmentSupport<ProxyDistributionSet, ProxyTarget> {
|
||||
@@ -40,10 +39,8 @@ public class DistributionSetsToTargetAssignmentSupport
|
||||
/**
|
||||
* Constructor for DistributionSetsToTargetAssignmentSupport
|
||||
*
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param systemSecurityContext
|
||||
* SystemSecurityContext
|
||||
* @param configManagement
|
||||
@@ -53,14 +50,14 @@ public class DistributionSetsToTargetAssignmentSupport
|
||||
* @param assignmentController
|
||||
* DeploymentAssignmentWindowController
|
||||
*/
|
||||
public DistributionSetsToTargetAssignmentSupport(final UINotification notification, final VaadinMessageSource i18n,
|
||||
public DistributionSetsToTargetAssignmentSupport(final CommonUiDependencies uiDependencies,
|
||||
final SystemSecurityContext systemSecurityContext, final TenantConfigurationManagement configManagement,
|
||||
final SpPermissionChecker permChecker, final DeploymentAssignmentWindowController assignmentController) {
|
||||
super(notification, i18n);
|
||||
final DeploymentAssignmentWindowController assignmentController) {
|
||||
super(uiDependencies.getUiNotification(), uiDependencies.getI18n());
|
||||
|
||||
this.systemSecurityContext = systemSecurityContext;
|
||||
this.configManagement = configManagement;
|
||||
this.permChecker = permChecker;
|
||||
this.permChecker = uiDependencies.getPermChecker();
|
||||
this.assignmentController = assignmentController;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,52 +15,40 @@ import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.AbstractAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Support for assigning the distribution set tags to distribution set.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DsTagsToDistributionSetAssignmentSupport
|
||||
extends TagsAssignmentSupport<ProxyDistributionSet, DistributionSet> {
|
||||
private final DistributionSetManagement distributionSetManagement;
|
||||
private final UIEventBus eventBus;
|
||||
private final SpPermissionChecker permChecker;
|
||||
private final CommonUiDependencies uiDependencies;
|
||||
|
||||
/**
|
||||
* Constructor for DsTagsToDistributionSetAssignmentSupport
|
||||
*
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param distributionSetManagement
|
||||
* DistributionSetManagement
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
*/
|
||||
public DsTagsToDistributionSetAssignmentSupport(final UINotification notification, final VaadinMessageSource i18n,
|
||||
final DistributionSetManagement distributionSetManagement, final UIEventBus eventBus,
|
||||
final SpPermissionChecker permChecker) {
|
||||
super(notification, i18n);
|
||||
public DsTagsToDistributionSetAssignmentSupport(final CommonUiDependencies uiDependencies,
|
||||
final DistributionSetManagement distributionSetManagement) {
|
||||
super(uiDependencies);
|
||||
this.uiDependencies = uiDependencies;
|
||||
|
||||
this.distributionSetManagement = distributionSetManagement;
|
||||
this.eventBus = eventBus;
|
||||
this.permChecker = permChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMissingPermissionsForDrop() {
|
||||
return permChecker.hasUpdateRepositoryPermission() ? Collections.emptyList()
|
||||
return uiDependencies.getPermChecker().hasUpdateRepositoryPermission() ? Collections.emptyList()
|
||||
: Collections.singletonList(SpPermission.UPDATE_REPOSITORY);
|
||||
}
|
||||
|
||||
@@ -77,7 +65,7 @@ public class DsTagsToDistributionSetAssignmentSupport
|
||||
|
||||
@Override
|
||||
protected void publishTagAssignmentEvent(final ProxyDistributionSet targetItem) {
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
uiDependencies.getEventBus().publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_UPDATED, ProxyDistributionSet.class, targetItem.getId()));
|
||||
|
||||
}
|
||||
|
||||
@@ -12,14 +12,13 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.AbstractAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
|
||||
/**
|
||||
* Support for assigning the {@link ProxyTag} items to target item (target or
|
||||
* distribution set).
|
||||
*
|
||||
*
|
||||
* @param <T>
|
||||
* The item-type of target item
|
||||
* @param <R>
|
||||
@@ -27,8 +26,8 @@ import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
*/
|
||||
public abstract class TagsAssignmentSupport<T, R extends NamedEntity> extends AssignmentSupport<ProxyTag, T> {
|
||||
|
||||
protected TagsAssignmentSupport(final UINotification notification, final VaadinMessageSource i18n) {
|
||||
super(notification, i18n);
|
||||
protected TagsAssignmentSupport(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies.getUiNotification(), uiDependencies.getI18n());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,16 +13,15 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
|
||||
/**
|
||||
* Support for assigning target tags to distribution set.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TargetTagsToDistributionSetAssignmentSupport extends AssignmentSupport<ProxyTag, ProxyDistributionSet> {
|
||||
private final TargetsToDistributionSetAssignmentSupport targetsToDistributionSetAssignmentSupport;
|
||||
@@ -31,19 +30,17 @@ public class TargetTagsToDistributionSetAssignmentSupport extends AssignmentSupp
|
||||
/**
|
||||
* Constructor for TargetTagsToDistributionSetAssignmentSupport
|
||||
*
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetManagement
|
||||
* TargetManagement
|
||||
* @param targetsToDistributionSetAssignmentSupport
|
||||
* TargetsToDistributionSetAssignmentSupport
|
||||
*/
|
||||
public TargetTagsToDistributionSetAssignmentSupport(final UINotification notification,
|
||||
final VaadinMessageSource i18n, final TargetManagement targetManagement,
|
||||
public TargetTagsToDistributionSetAssignmentSupport(final CommonUiDependencies uiDependencies,
|
||||
final TargetManagement targetManagement,
|
||||
final TargetsToDistributionSetAssignmentSupport targetsToDistributionSetAssignmentSupport) {
|
||||
super(notification, i18n);
|
||||
super(uiDependencies.getUiNotification(), uiDependencies.getI18n());
|
||||
|
||||
this.targetManagement = targetManagement;
|
||||
this.targetsToDistributionSetAssignmentSupport = targetsToDistributionSetAssignmentSupport;
|
||||
|
||||
@@ -15,50 +15,39 @@ import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.AbstractAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Support for assigning target tags to target.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TargetTagsToTargetAssignmentSupport extends TagsAssignmentSupport<ProxyTarget, Target> {
|
||||
private final TargetManagement targetManagement;
|
||||
private final UIEventBus eventBus;
|
||||
private final SpPermissionChecker permChecker;
|
||||
private final CommonUiDependencies uiDependencies;
|
||||
|
||||
/**
|
||||
* Constructor for TargetTagsToTargetAssignmentSupport
|
||||
*
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetManagement
|
||||
* TargetManagement
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
*/
|
||||
public TargetTagsToTargetAssignmentSupport(final UINotification notification, final VaadinMessageSource i18n,
|
||||
final TargetManagement targetManagement, final UIEventBus eventBus, final SpPermissionChecker permChecker) {
|
||||
super(notification, i18n);
|
||||
public TargetTagsToTargetAssignmentSupport(final CommonUiDependencies uiDependencies,
|
||||
final TargetManagement targetManagement) {
|
||||
super(uiDependencies);
|
||||
this.uiDependencies = uiDependencies;
|
||||
|
||||
this.targetManagement = targetManagement;
|
||||
this.eventBus = eventBus;
|
||||
this.permChecker = permChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMissingPermissionsForDrop() {
|
||||
return permChecker.hasUpdateTargetPermission() ? Collections.emptyList()
|
||||
return uiDependencies.getPermChecker().hasUpdateTargetPermission() ? Collections.emptyList()
|
||||
: Collections.singletonList(SpPermission.UPDATE_TARGET);
|
||||
}
|
||||
|
||||
@@ -74,7 +63,7 @@ public class TargetTagsToTargetAssignmentSupport extends TagsAssignmentSupport<P
|
||||
|
||||
@Override
|
||||
protected void publishTagAssignmentEvent(final ProxyTarget targetItem) {
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
uiDependencies.getEventBus().publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_UPDATED, ProxyTarget.class, targetItem.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,16 +15,15 @@ import java.util.stream.Collectors;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
|
||||
import org.eclipse.hawkbit.ui.management.miscs.DeploymentAssignmentWindowController;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
|
||||
/**
|
||||
* Support for assigning targets to distribution set.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TargetsToDistributionSetAssignmentSupport
|
||||
extends DeploymentAssignmentSupport<ProxyTarget, ProxyDistributionSet> {
|
||||
@@ -35,20 +34,16 @@ public class TargetsToDistributionSetAssignmentSupport
|
||||
/**
|
||||
* Constructor for TargetsToDistributionSetAssignmentSupport
|
||||
*
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param assignmentController
|
||||
* DeploymentAssignmentWindowController
|
||||
*/
|
||||
public TargetsToDistributionSetAssignmentSupport(final UINotification notification, final VaadinMessageSource i18n,
|
||||
final SpPermissionChecker permChecker, final DeploymentAssignmentWindowController assignmentController) {
|
||||
super(notification, i18n);
|
||||
public TargetsToDistributionSetAssignmentSupport(final CommonUiDependencies uiDependencies,
|
||||
final DeploymentAssignmentWindowController assignmentController) {
|
||||
super(uiDependencies.getUiNotification(), uiDependencies.getI18n());
|
||||
|
||||
this.permChecker = permChecker;
|
||||
this.permChecker = uiDependencies.getPermChecker();
|
||||
this.assignmentController = assignmentController;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,19 +18,18 @@ import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.AbstractAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Support for assigning the {@link ProxyTarget} items to {@link ProxyTag}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TargetsToTagAssignmentSupport extends ToTagAssignmentSupport<ProxyTarget, Target> {
|
||||
private final TargetManagement targetManagement;
|
||||
@@ -40,23 +39,16 @@ public class TargetsToTagAssignmentSupport extends ToTagAssignmentSupport<ProxyT
|
||||
/**
|
||||
* Constructor for TargetsToTagAssignmentSupport
|
||||
*
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetManagement
|
||||
* TargetManagement
|
||||
*/
|
||||
public TargetsToTagAssignmentSupport(final UINotification notification, final VaadinMessageSource i18n,
|
||||
final UIEventBus eventBus, final SpPermissionChecker permChecker, final TargetManagement targetManagement) {
|
||||
super(notification, i18n);
|
||||
public TargetsToTagAssignmentSupport(final CommonUiDependencies uiDependencies, final TargetManagement targetManagement) {
|
||||
super(uiDependencies.getUiNotification(), uiDependencies.getI18n());
|
||||
|
||||
this.eventBus = eventBus;
|
||||
this.permChecker = permChecker;
|
||||
this.eventBus = uiDependencies.getEventBus();
|
||||
this.permChecker = uiDependencies.getPermChecker();
|
||||
this.targetManagement = targetManagement;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.softwaremodule;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SmMetaDataWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SmWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleGrid;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleGridHeader;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.layout.AbstractGridComponentLayout;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.TopicEventListener;
|
||||
|
||||
/**
|
||||
* Abstract base class for software modules in grid layouts.
|
||||
*/
|
||||
public abstract class AbstractSoftwareModuleGridLayout extends AbstractGridComponentLayout {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final transient Set<TopicEventListener> listeners = new HashSet<>();
|
||||
private final transient SmWindowBuilder smWindowBuilder;
|
||||
private final transient SmMetaDataWindowBuilder smMetaDataWindowBuilder;
|
||||
private final EventView eventView;
|
||||
|
||||
/**
|
||||
* Constructor for AbstractSoftwareModuleGridLayout.
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param softwareModuleManagement
|
||||
* SoftwareModuleManagement
|
||||
* @param softwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param eventView
|
||||
* EventView
|
||||
*/
|
||||
public AbstractSoftwareModuleGridLayout(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleManagement softwareModuleManagement,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement, final EventView eventView) {
|
||||
|
||||
this.eventView = eventView;
|
||||
smWindowBuilder = new SmWindowBuilder(uiDependencies, softwareModuleManagement, softwareModuleTypeManagement,
|
||||
eventView);
|
||||
smMetaDataWindowBuilder = new SmMetaDataWindowBuilder(uiDependencies, softwareModuleManagement);
|
||||
|
||||
}
|
||||
|
||||
protected abstract SoftwareModuleGridHeader getSoftwareModuleGridHeader();
|
||||
|
||||
protected abstract SoftwareModuleGrid getSoftwareModuleGrid();
|
||||
|
||||
/**
|
||||
* Return SmMetaDataWindowBuilder
|
||||
*
|
||||
* @return the smMetaDataWindowBuilder
|
||||
*/
|
||||
public SmMetaDataWindowBuilder getSmMetaDataWindowBuilder() {
|
||||
return smMetaDataWindowBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return SmWindowBuilder.
|
||||
*
|
||||
* @return the smWindowBuilder
|
||||
*/
|
||||
public SmWindowBuilder getSmWindowBuilder() {
|
||||
return smWindowBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return EventView.
|
||||
*
|
||||
* @return the eventView
|
||||
*/
|
||||
public EventView getEventView() {
|
||||
return eventView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show software module grid header
|
||||
*/
|
||||
public void showSmTypeHeaderIcon() {
|
||||
getSoftwareModuleGridHeader().showFilterIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide software module grid header
|
||||
*/
|
||||
public void hideSmTypeHeaderIcon() {
|
||||
getSoftwareModuleGridHeader().hideFilterIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximize the software module grid
|
||||
*/
|
||||
public void maximize() {
|
||||
getSoftwareModuleGrid().createMaximizedContent();
|
||||
hideDetailsLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimize the software module grid
|
||||
*/
|
||||
public void minimize() {
|
||||
getSoftwareModuleGrid().createMinimizedContent();
|
||||
showDetailsLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called when view is shown to the user
|
||||
*/
|
||||
public void restoreState() {
|
||||
getSoftwareModuleGridHeader().restoreState();
|
||||
getSoftwareModuleGrid().restoreState();
|
||||
}
|
||||
|
||||
protected void addEventListener(final TopicEventListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe the event listeners.
|
||||
*/
|
||||
public void unsubscribeListener() {
|
||||
listeners.forEach(TopicEventListener::unsubscribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.tag;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.EntityValidator;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Validator used in *Tag window controllers to validate {@link ProxyTag}.
|
||||
*/
|
||||
public class ProxyTagValidator extends EntityValidator {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public ProxyTagValidator(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entity is valid
|
||||
*
|
||||
* @param entity
|
||||
* {@link ProxyTag}
|
||||
* @param duplicateCheck
|
||||
* <code>true</code> if the entity already exists in the
|
||||
* repository
|
||||
* @return <code>true</code> if the entity is valid
|
||||
*/
|
||||
public boolean isEntityValid(final ProxyTag entity, final BooleanSupplier duplicateCheck) {
|
||||
if (!StringUtils.hasText(entity.getName())) {
|
||||
displayValidationError("message.error.missing.tagname");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (duplicateCheck.getAsBoolean()) {
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
displayValidationError("message.tag.duplicate.check", trimmedName);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.Identifiable;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyNamedEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
import org.eclipse.hawkbit.ui.common.layout.MasterEntityAwareComponent;
|
||||
@@ -42,12 +43,11 @@ public abstract class AbstractTagToken<T extends ProxyNamedEntity>
|
||||
|
||||
private T masterEntity;
|
||||
|
||||
protected AbstractTagToken(final SpPermissionChecker checker, final VaadinMessageSource i18n,
|
||||
final UINotification uiNotification, final UIEventBus eventBus) {
|
||||
this.checker = checker;
|
||||
this.i18n = i18n;
|
||||
this.uiNotification = uiNotification;
|
||||
this.eventBus = eventBus;
|
||||
protected AbstractTagToken(final CommonUiDependencies uiDependencies) {
|
||||
this.checker = uiDependencies.getPermChecker();
|
||||
this.i18n = uiDependencies.getI18n();
|
||||
this.uiNotification = uiDependencies.getUiNotification();
|
||||
this.eventBus = uiDependencies.getEventBus();
|
||||
|
||||
buildTagPanel();
|
||||
tagPanelLayout.setVisible(false);
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.TagToProxyTagMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
@@ -25,9 +25,6 @@ import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Implementation of target/ds tag token layout.
|
||||
@@ -42,24 +39,17 @@ public class DistributionTagToken extends AbstractTagToken<ProxyDistributionSet>
|
||||
/**
|
||||
* Constructor for DistributionTagToken
|
||||
*
|
||||
* @param checker
|
||||
* SpPermissionChecker
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uinotification
|
||||
* UINotification
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param distributionSetTagManagement
|
||||
* DistributionSetTagManagement
|
||||
* @param distributionSetManagement
|
||||
* DistributionSetManagement
|
||||
*/
|
||||
public DistributionTagToken(final SpPermissionChecker checker, final VaadinMessageSource i18n,
|
||||
final UINotification uinotification, final UIEventBus eventBus,
|
||||
public DistributionTagToken(final CommonUiDependencies uiDependencies,
|
||||
final DistributionSetTagManagement distributionSetTagManagement,
|
||||
final DistributionSetManagement distributionSetManagement) {
|
||||
super(checker, i18n, uinotification, eventBus);
|
||||
super(uiDependencies);
|
||||
|
||||
this.distributionSetTagManagement = distributionSetTagManagement;
|
||||
this.distributionSetManagement = distributionSetManagement;
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.TagToProxyTagMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
|
||||
@@ -25,9 +25,6 @@ import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Implementation of Target tag token.
|
||||
@@ -43,23 +40,16 @@ public class TargetTagToken extends AbstractTagToken<ProxyTarget> {
|
||||
/**
|
||||
* Constructor for TargetTagToken
|
||||
*
|
||||
* @param checker
|
||||
* SpPermissionChecker
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uinotification
|
||||
* UINotification
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetTagManagement
|
||||
* TargetTagManagement
|
||||
* @param targetManagement
|
||||
* TargetManagement
|
||||
*/
|
||||
public TargetTagToken(final SpPermissionChecker checker, final VaadinMessageSource i18n,
|
||||
final UINotification uinotification, final UIEventBus eventBus,
|
||||
final TargetTagManagement targetTagManagement, final TargetManagement targetManagement) {
|
||||
super(checker, i18n, uinotification, eventBus);
|
||||
public TargetTagToken(final CommonUiDependencies uiDependencies, final TargetTagManagement targetTagManagement,
|
||||
final TargetManagement targetManagement) {
|
||||
super(uiDependencies);
|
||||
|
||||
this.targetTagManagement = targetTagManagement;
|
||||
this.targetManagement = targetManagement;
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.type;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.EntityValidator;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Validator used in *Type window controllers to validate {@link ProxyType}.
|
||||
*/
|
||||
public class ProxyTypeValidator extends EntityValidator {
|
||||
|
||||
private static final String KEY_MISSING_NAME_OR_KEY = "message.error.missing.typenameorkeyorsmtype";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public ProxyTypeValidator(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entity is valid
|
||||
*
|
||||
* @param entity
|
||||
* {@link ProxyTag}
|
||||
* @param keyDuplicateCheck
|
||||
* <code>true</code> if the entity key already exists in the
|
||||
* repository
|
||||
* @param nameDuplicateCheck
|
||||
* <code>true</code> if the entity name already exists in the
|
||||
* repository
|
||||
* @return <code>true</code> if the entity is valid
|
||||
*/
|
||||
public boolean isDsTypeValid(final ProxyType entity, final BooleanSupplier keyDuplicateCheck,
|
||||
final BooleanSupplier nameDuplicateCheck) {
|
||||
return mandatoryDsAttributesPresent(entity) && nameDoesNotExistInRepo(entity, nameDuplicateCheck)
|
||||
&& keyDoesNotExistInRepo(entity, keyDuplicateCheck, "message.type.key.ds.duplicate.check");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entity is valid
|
||||
*
|
||||
* @param entity
|
||||
* {@link ProxyTag}
|
||||
* @param keyDuplicateCheck
|
||||
* <code>true</code> if the entity key already exists in the
|
||||
* repository
|
||||
* @param nameDuplicateCheck
|
||||
* <code>true</code> if the entity name already exists in the
|
||||
* repository
|
||||
* @return <code>true</code> if the entity is valid
|
||||
*/
|
||||
public boolean isSmTypeValid(final ProxyType entity, final BooleanSupplier keyDuplicateCheck,
|
||||
final BooleanSupplier nameDuplicateCheck) {
|
||||
return mandatorySmAttributesPresent(entity) && nameDoesNotExistInRepo(entity, nameDuplicateCheck)
|
||||
&& keyDoesNotExistInRepo(entity, keyDuplicateCheck, "message.type.key.swmodule.duplicate.check");
|
||||
}
|
||||
|
||||
private boolean mandatorySmAttributesPresent(final ProxyType entity) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getKey())
|
||||
|| entity.getSmTypeAssign() == null) {
|
||||
displayValidationError(KEY_MISSING_NAME_OR_KEY);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean mandatoryDsAttributesPresent(final ProxyType entity) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getKey())
|
||||
|| CollectionUtils.isEmpty(entity.getSelectedSmTypes())) {
|
||||
displayValidationError(KEY_MISSING_NAME_OR_KEY);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean keyDoesNotExistInRepo(final ProxyType entity, final BooleanSupplier keyExistsInRepository,
|
||||
final String duplicateKeyMessageKey) {
|
||||
if (keyExistsInRepository.getAsBoolean()) {
|
||||
final String trimmedKey = StringUtils.trimWhitespace(entity.getKey());
|
||||
displayValidationError(duplicateKeyMessageKey, trimmedKey);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean nameDoesNotExistInRepo(final ProxyType entity, final BooleanSupplier nameExistsInRepository) {
|
||||
if (nameExistsInRepository.getAsBoolean()) {
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
displayValidationError("message.type.duplicate.check", trimmedName);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.ui.AbstractHawkbitUI;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventViewAware;
|
||||
@@ -93,21 +94,24 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
|
||||
this.permChecker = permChecker;
|
||||
this.manageDistUIState = manageDistUIState;
|
||||
|
||||
final CommonUiDependencies uiDependencies = new CommonUiDependencies(i18n, entityFactory, eventBus, uiNotification,
|
||||
permChecker);
|
||||
|
||||
if (permChecker.hasReadRepositoryPermission()) {
|
||||
this.dsTypeFilterLayout = new DSTypeFilterLayout(i18n, permChecker, eventBus, entityFactory, uiNotification,
|
||||
softwareModuleTypeManagement, distributionSetTypeManagement, distributionSetManagement,
|
||||
systemManagement, manageDistUIState.getDsTypeFilterLayoutUiState());
|
||||
this.distributionSetGridLayout = new DistributionSetGridLayout(i18n, eventBus, permChecker, uiNotification,
|
||||
entityFactory, targetManagement, targetFilterQueryManagement, distributionSetManagement,
|
||||
softwareModuleManagement, distributionSetTypeManagement, distributionSetTagManagement,
|
||||
softwareModuleTypeManagement, systemManagement, configManagement, systemSecurityContext,
|
||||
this.dsTypeFilterLayout = new DSTypeFilterLayout(uiDependencies, softwareModuleTypeManagement,
|
||||
distributionSetTypeManagement, distributionSetManagement, systemManagement,
|
||||
manageDistUIState.getDsTypeFilterLayoutUiState());
|
||||
this.distributionSetGridLayout = new DistributionSetGridLayout(uiDependencies, targetManagement,
|
||||
targetFilterQueryManagement, distributionSetManagement, softwareModuleManagement,
|
||||
distributionSetTypeManagement, distributionSetTagManagement, softwareModuleTypeManagement,
|
||||
systemManagement, configManagement, systemSecurityContext,
|
||||
manageDistUIState.getDsTypeFilterLayoutUiState(),
|
||||
manageDistUIState.getDistributionSetGridLayoutUiState());
|
||||
this.swModuleGridLayout = new SwModuleGridLayout(i18n, uiNotification, eventBus, softwareModuleManagement,
|
||||
softwareModuleTypeManagement, entityFactory, permChecker, artifactManagement,
|
||||
manageDistUIState.getSmTypeFilterLayoutUiState(), manageDistUIState.getSwModuleGridLayoutUiState());
|
||||
this.distSMTypeFilterLayout = new DistSMTypeFilterLayout(eventBus, i18n, permChecker, entityFactory,
|
||||
uiNotification, softwareModuleTypeManagement, manageDistUIState.getSmTypeFilterLayoutUiState());
|
||||
this.swModuleGridLayout = new SwModuleGridLayout(uiDependencies, softwareModuleManagement,
|
||||
softwareModuleTypeManagement, artifactManagement, manageDistUIState.getSmTypeFilterLayoutUiState(),
|
||||
manageDistUIState.getSwModuleGridLayoutUiState());
|
||||
this.distSMTypeFilterLayout = new DistSMTypeFilterLayout(uiDependencies, softwareModuleTypeManagement,
|
||||
manageDistUIState.getSmTypeFilterLayoutUiState());
|
||||
|
||||
final Map<EventLayout, VisibilityHandler> layoutVisibilityHandlers = new EnumMap<>(EventLayout.class);
|
||||
layoutVisibilityHandlers.put(EventLayout.DS_TYPE_FILTER,
|
||||
@@ -201,12 +205,12 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
|
||||
|
||||
private void showDsTypeLayout() {
|
||||
dsTypeFilterLayout.setVisible(true);
|
||||
distributionSetGridLayout.hideDsTypeHeaderIcon();
|
||||
distributionSetGridLayout.hideDsFilterHeaderIcon();
|
||||
}
|
||||
|
||||
private void hideDsTypeLayout() {
|
||||
dsTypeFilterLayout.setVisible(false);
|
||||
distributionSetGridLayout.showDsTypeHeaderIcon();
|
||||
distributionSetGridLayout.showDsFilterHeaderIcon();
|
||||
}
|
||||
|
||||
private void maximizeDsGridLayout() {
|
||||
|
||||
@@ -12,65 +12,47 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractAddNamedEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.eclipse.hawkbit.ui.common.type.ProxyTypeValidator;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Add distribution set type window controller
|
||||
*/
|
||||
public class AddDsTypeWindowController extends AbstractEntityWindowController<ProxyType, ProxyType> {
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
public class AddDsTypeWindowController
|
||||
extends AbstractAddNamedEntityWindowController<ProxyType, ProxyType, DistributionSetType> {
|
||||
|
||||
private final DistributionSetTypeManagement dsTypeManagement;
|
||||
|
||||
private final DsTypeWindowLayout layout;
|
||||
private final ProxyTypeValidator validator;
|
||||
|
||||
/**
|
||||
* Constructor for AddDsTypeWindowController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dsTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* @param layout
|
||||
* DsTypeWindowLayout
|
||||
*/
|
||||
public AddDsTypeWindowController(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification,
|
||||
public AddDsTypeWindowController(final CommonUiDependencies uiDependencies,
|
||||
final DistributionSetTypeManagement dsTypeManagement, final DsTypeWindowLayout layout) {
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.dsTypeManagement = dsTypeManagement;
|
||||
|
||||
this.layout = layout;
|
||||
this.validator = new ProxyTypeValidator(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractEntityWindowLayout<ProxyType> getLayout() {
|
||||
public EntityWindowLayout<ProxyType> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -82,7 +64,7 @@ public class AddDsTypeWindowController extends AbstractEntityWindowController<Pr
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyType entity) {
|
||||
protected DistributionSetType persistEntityInRepository(final ProxyType entity) {
|
||||
final List<Long> mandatorySmTypeIds = entity.getSelectedSmTypes().stream().filter(ProxyType::isMandatory)
|
||||
.map(ProxyType::getId).collect(Collectors.toList());
|
||||
|
||||
@@ -90,34 +72,26 @@ public class AddDsTypeWindowController extends AbstractEntityWindowController<Pr
|
||||
.filter(selectedSmType -> !selectedSmType.isMandatory()).map(ProxyType::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final DistributionSetType newDsType = dsTypeManagement.create(entityFactory.distributionSetType().create()
|
||||
.key(entity.getKey()).name(entity.getName()).description(entity.getDescription())
|
||||
.colour(entity.getColour()).mandatory(mandatorySmTypeIds).optional(optionalSmTypeIds));
|
||||
return dsTypeManagement.create(getEntityFactory().distributionSetType().create().key(entity.getKey())
|
||||
.name(entity.getName()).description(entity.getDescription()).colour(entity.getColour())
|
||||
.mandatory(mandatorySmTypeIds).optional(optionalSmTypeIds));
|
||||
}
|
||||
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.save.success", newDsType.getName()));
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_ADDED, ProxyDistributionSet.class, ProxyType.class, newDsType.getId()));
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyType.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getParentEntityClass() {
|
||||
return ProxyDistributionSet.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyType entity) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getKey())
|
||||
|| CollectionUtils.isEmpty(entity.getSelectedSmTypes())) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.error.missing.typenameorkeyorsmtype"));
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
final String trimmedKey = StringUtils.trimWhitespace(entity.getKey());
|
||||
if (dsTypeManagement.getByName(trimmedName).isPresent()) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.type.duplicate.check", trimmedName));
|
||||
return false;
|
||||
}
|
||||
if (dsTypeManagement.getByKey(trimmedKey).isPresent()) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.type.key.ds.duplicate.check", trimmedKey));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return validator.isDsTypeValid(entity, () -> dsTypeManagement.getByKey(trimmedKey).isPresent(),
|
||||
() -> dsTypeManagement.getByName(trimmedName).isPresent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,11 @@ package org.eclipse.hawkbit.ui.distributions.disttype;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -25,9 +22,6 @@ import com.vaadin.ui.Window;
|
||||
* Builder for distribution set type window
|
||||
*/
|
||||
public class DsTypeWindowBuilder extends AbstractEntityWindowBuilder<ProxyType> {
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
|
||||
private final DistributionSetTypeManagement dsTypeManagement;
|
||||
private final DistributionSetManagement dsManagement;
|
||||
@@ -36,30 +30,18 @@ public class DsTypeWindowBuilder extends AbstractEntityWindowBuilder<ProxyType>
|
||||
/**
|
||||
* Constructor for DsTypeWindowBuilder
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dsTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* @param dsManagement
|
||||
* DistributionSetManagement
|
||||
* DistributionSetManagement
|
||||
* @param smTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
*/
|
||||
public DsTypeWindowBuilder(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification,
|
||||
final DistributionSetTypeManagement dsTypeManagement, final DistributionSetManagement dsManagement,
|
||||
final SoftwareModuleTypeManagement smTypeManagement) {
|
||||
super(i18n);
|
||||
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
public DsTypeWindowBuilder(final CommonUiDependencies uiDependencies, final DistributionSetTypeManagement dsTypeManagement,
|
||||
final DistributionSetManagement dsManagement, final SoftwareModuleTypeManagement smTypeManagement) {
|
||||
super(uiDependencies);
|
||||
|
||||
this.dsTypeManagement = dsTypeManagement;
|
||||
this.dsManagement = dsManagement;
|
||||
@@ -73,15 +55,14 @@ public class DsTypeWindowBuilder extends AbstractEntityWindowBuilder<ProxyType>
|
||||
|
||||
@Override
|
||||
public Window getWindowForAdd() {
|
||||
return getWindowForNewEntity(new AddDsTypeWindowController(i18n, entityFactory, eventBus, uiNotification,
|
||||
dsTypeManagement, new DsTypeWindowLayout(i18n, uiNotification, smTypeManagement)));
|
||||
return getWindowForNewEntity(new AddDsTypeWindowController(uiDependencies, dsTypeManagement,
|
||||
new DsTypeWindowLayout(uiDependencies, smTypeManagement)));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window getWindowForUpdate(final ProxyType proxyType) {
|
||||
return getWindowForEntity(proxyType,
|
||||
new UpdateDsTypeWindowController(i18n, entityFactory, eventBus, uiNotification, dsTypeManagement,
|
||||
dsManagement, new DsTypeWindowLayout(i18n, uiNotification, smTypeManagement)));
|
||||
return getWindowForEntity(proxyType, new UpdateDsTypeWindowController(uiDependencies, dsTypeManagement, dsManagement,
|
||||
new DsTypeWindowLayout(uiDependencies, smTypeManagement)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,10 @@
|
||||
package org.eclipse.hawkbit.ui.distributions.disttype;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.builder.FormComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.management.tag.TagWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
|
||||
import com.vaadin.ui.ComponentContainer;
|
||||
import com.vaadin.ui.FormLayout;
|
||||
@@ -31,16 +30,14 @@ public class DsTypeWindowLayout extends TagWindowLayout<ProxyType> {
|
||||
/**
|
||||
* Constructor for DsTypeWindowLayout
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param softwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
*/
|
||||
public DsTypeWindowLayout(final VaadinMessageSource i18n, final UINotification uiNotification,
|
||||
public DsTypeWindowLayout(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
|
||||
super(i18n, uiNotification);
|
||||
super(uiDependencies);
|
||||
|
||||
this.dsTypeComponentBuilder = new DsTypeWindowLayoutComponentBuilder(i18n, softwareModuleTypeManagement);
|
||||
|
||||
|
||||
@@ -15,44 +15,30 @@ import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractUpdateNamedEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.TypeToProxyTypeMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.eclipse.hawkbit.ui.common.type.ProxyTypeValidator;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Controller for update distribution set type window
|
||||
*/
|
||||
public class UpdateDsTypeWindowController extends AbstractEntityWindowController<ProxyType, ProxyType> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UpdateDsTypeWindowController.class);
|
||||
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
public class UpdateDsTypeWindowController
|
||||
extends AbstractUpdateNamedEntityWindowController<ProxyType, ProxyType, DistributionSetType> {
|
||||
|
||||
private final DistributionSetTypeManagement dsTypeManagement;
|
||||
private final DistributionSetManagement dsManagement;
|
||||
private final TypeToProxyTypeMapper<SoftwareModuleType> smTypeToProxyTypeMapper;
|
||||
|
||||
private final DsTypeWindowLayout layout;
|
||||
private final ProxyTypeValidator validator;
|
||||
|
||||
private String nameBeforeEdit;
|
||||
private String keyBeforeEdit;
|
||||
@@ -61,14 +47,8 @@ public class UpdateDsTypeWindowController extends AbstractEntityWindowController
|
||||
/**
|
||||
* Constructor for UpdateDsTypeWindowController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dsTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* @param dsManagement
|
||||
@@ -76,21 +56,16 @@ public class UpdateDsTypeWindowController extends AbstractEntityWindowController
|
||||
* @param layout
|
||||
* DsTypeWindowLayout
|
||||
*/
|
||||
public UpdateDsTypeWindowController(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification,
|
||||
public UpdateDsTypeWindowController(final CommonUiDependencies uiDependencies,
|
||||
final DistributionSetTypeManagement dsTypeManagement, final DistributionSetManagement dsManagement,
|
||||
final DsTypeWindowLayout layout) {
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.dsTypeManagement = dsTypeManagement;
|
||||
this.dsManagement = dsManagement;
|
||||
|
||||
this.smTypeToProxyTypeMapper = new TypeToProxyTypeMapper<>();
|
||||
|
||||
this.layout = layout;
|
||||
this.validator = new ProxyTypeValidator(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,15 +119,15 @@ public class UpdateDsTypeWindowController extends AbstractEntityWindowController
|
||||
layout.disableTypeKey();
|
||||
|
||||
if (isDsTypeAssigned) {
|
||||
uiNotification.displayValidationError(
|
||||
nameBeforeEdit + " " + i18n.getMessage("message.error.dist.set.type.update"));
|
||||
getUiNotification().displayValidationError(
|
||||
nameBeforeEdit + " " + getI18n().getMessage("message.error.dist.set.type.update"));
|
||||
layout.disableDsTypeSmSelectLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyType entity) {
|
||||
final DistributionSetTypeUpdate dsTypeUpdate = entityFactory.distributionSetType().update(entity.getId())
|
||||
protected DistributionSetType persistEntityInRepository(final ProxyType entity) {
|
||||
final DistributionSetTypeUpdate dsTypeUpdate = getEntityFactory().distributionSetType().update(entity.getId())
|
||||
.description(entity.getDescription()).colour(entity.getColour());
|
||||
|
||||
final List<Long> mandatorySmTypeIds = entity.getSelectedSmTypes().stream().filter(ProxyType::isMandatory)
|
||||
@@ -164,40 +139,33 @@ public class UpdateDsTypeWindowController extends AbstractEntityWindowController
|
||||
|
||||
dsTypeUpdate.mandatory(mandatorySmTypeIds).optional(optionalSmTypeIds);
|
||||
|
||||
try {
|
||||
final DistributionSetType updatedDsType = dsTypeManagement.update(dsTypeUpdate);
|
||||
return dsTypeManagement.update(dsTypeUpdate);
|
||||
}
|
||||
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.update.success", updatedDsType.getName()));
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this,
|
||||
new EntityModifiedEventPayload(EntityModifiedEventType.ENTITY_UPDATED, ProxyDistributionSet.class,
|
||||
ProxyType.class, updatedDsType.getId()));
|
||||
} catch (final EntityNotFoundException | EntityReadOnlyException e) {
|
||||
LOG.trace("Update of DS type failed in UI: {}", e.getMessage());
|
||||
final String entityType = i18n.getMessage("caption.entity.distribution.type");
|
||||
uiNotification
|
||||
.displayWarning(i18n.getMessage("message.deleted.or.notAllowed", entityType, entity.getName()));
|
||||
}
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyType.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getParentEntityClass() {
|
||||
return ProxyDistributionSet.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyType entity) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getKey())
|
||||
|| CollectionUtils.isEmpty(entity.getSelectedSmTypes())) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.error.missing.typenameorkeyorsmtype"));
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
final String trimmedKey = StringUtils.trimWhitespace(entity.getKey());
|
||||
if (!nameBeforeEdit.equals(trimmedName) && dsTypeManagement.getByName(trimmedName).isPresent()) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.type.duplicate.check", trimmedName));
|
||||
return false;
|
||||
}
|
||||
if (!keyBeforeEdit.equals(trimmedKey) && dsTypeManagement.getByKey(trimmedKey).isPresent()) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.type.key.ds.duplicate.check", trimmedKey));
|
||||
return false;
|
||||
}
|
||||
return validator.isDsTypeValid(entity,
|
||||
() -> hasKeyChanged(trimmedKey) && dsTypeManagement.getByKey(trimmedKey).isPresent(),
|
||||
() -> hasNameChanged(trimmedName) && dsTypeManagement.getByName(trimmedName).isPresent());
|
||||
}
|
||||
|
||||
return true;
|
||||
private boolean hasNameChanged(final String trimmedName) {
|
||||
return !nameBeforeEdit.equals(trimmedName);
|
||||
}
|
||||
|
||||
private boolean hasKeyChanged(final String trimmedKey) {
|
||||
return !keyBeforeEdit.equals(trimmedKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.distributions.disttype.filter;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.TypeToProxyTypeMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetTypeDataProvider;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
@@ -22,9 +22,6 @@ import org.eclipse.hawkbit.ui.common.filterlayout.AbstractTypeFilterButtons;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.distributions.disttype.DsTypeWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -40,17 +37,11 @@ public class DSTypeFilterButtons extends AbstractTypeFilterButtons {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param distributionSetTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param systemManagement
|
||||
* SystemManagement
|
||||
* @param dsTypeWindowBuilder
|
||||
@@ -58,11 +49,10 @@ public class DSTypeFilterButtons extends AbstractTypeFilterButtons {
|
||||
* @param typeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
*/
|
||||
public DSTypeFilterButtons(final UIEventBus eventBus, final VaadinMessageSource i18n,
|
||||
final UINotification uiNotification, final SpPermissionChecker permChecker,
|
||||
public DSTypeFilterButtons(final CommonUiDependencies uiDependencies,
|
||||
final DistributionSetTypeManagement distributionSetTypeManagement, final SystemManagement systemManagement,
|
||||
final DsTypeWindowBuilder dsTypeWindowBuilder, final TypeFilterLayoutUiState typeFilterLayoutUiState) {
|
||||
super(eventBus, i18n, uiNotification, permChecker, typeFilterLayoutUiState);
|
||||
super(uiDependencies, typeFilterLayoutUiState);
|
||||
|
||||
this.distributionSetTypeManagement = distributionSetTypeManagement;
|
||||
this.dsTypeWindowBuilder = dsTypeWindowBuilder;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.distributions.disttype.filter;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.grid.header.AbstractFilterHeader;
|
||||
@@ -16,8 +16,6 @@ import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.distributions.disttype.DsTypeWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -36,20 +34,16 @@ public class DSTypeFilterHeader extends AbstractFilterHeader {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param eventBus
|
||||
* DsTypeWindowBuilder
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dsTypeWindowBuilder
|
||||
* DsTypeWindowBuilder
|
||||
* DsTypeWindowBuilder
|
||||
* @param dSTypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
*/
|
||||
DSTypeFilterHeader(final UIEventBus eventBus, final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final DsTypeWindowBuilder dsTypeWindowBuilder, final TypeFilterLayoutUiState dSTypeFilterLayoutUiState) {
|
||||
super(i18n, permChecker, eventBus);
|
||||
DSTypeFilterHeader(final CommonUiDependencies uiDependencies, final DsTypeWindowBuilder dsTypeWindowBuilder,
|
||||
final TypeFilterLayoutUiState dSTypeFilterLayoutUiState) {
|
||||
super(uiDependencies.getI18n(), uiDependencies.getPermChecker(), uiDependencies.getEventBus());
|
||||
|
||||
this.dSTypeFilterLayoutUiState = dSTypeFilterLayoutUiState;
|
||||
this.dsTypeWindowBuilder = dsTypeWindowBuilder;
|
||||
|
||||
@@ -13,10 +13,9 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
@@ -30,9 +29,6 @@ import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedGener
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedGridRefreshAwareSupport;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.distributions.disttype.DsTypeWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.ComponentContainer;
|
||||
|
||||
@@ -50,17 +46,9 @@ public class DSTypeFilterLayout extends AbstractFilterLayout {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param softwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param distributionSetTypeManagement
|
||||
@@ -72,25 +60,23 @@ public class DSTypeFilterLayout extends AbstractFilterLayout {
|
||||
* @param dSTypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
*/
|
||||
public DSTypeFilterLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UIEventBus eventBus, final EntityFactory entityFactory, final UINotification uiNotification,
|
||||
public DSTypeFilterLayout(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement,
|
||||
final DistributionSetTypeManagement distributionSetTypeManagement,
|
||||
final DistributionSetManagement distributionSetManagement, final SystemManagement systemManagement,
|
||||
final TypeFilterLayoutUiState dSTypeFilterLayoutUiState) {
|
||||
final DsTypeWindowBuilder dsTypeWindowBuilder = new DsTypeWindowBuilder(i18n, entityFactory, eventBus,
|
||||
uiNotification, distributionSetTypeManagement, distributionSetManagement, softwareModuleTypeManagement);
|
||||
final DsTypeWindowBuilder dsTypeWindowBuilder = new DsTypeWindowBuilder(uiDependencies, distributionSetTypeManagement,
|
||||
distributionSetManagement, softwareModuleTypeManagement);
|
||||
|
||||
this.dsTypeFilterHeader = new DSTypeFilterHeader(eventBus, i18n, permChecker, dsTypeWindowBuilder,
|
||||
dSTypeFilterLayoutUiState);
|
||||
this.dSTypeFilterButtons = new DSTypeFilterButtons(eventBus, i18n, uiNotification, permChecker,
|
||||
distributionSetTypeManagement, systemManagement, dsTypeWindowBuilder, dSTypeFilterLayoutUiState);
|
||||
this.dsTypeFilterHeader = new DSTypeFilterHeader(uiDependencies, dsTypeWindowBuilder, dSTypeFilterLayoutUiState);
|
||||
this.dSTypeFilterButtons = new DSTypeFilterButtons(uiDependencies, distributionSetTypeManagement, systemManagement,
|
||||
dsTypeWindowBuilder, dSTypeFilterLayoutUiState);
|
||||
|
||||
this.gridActionsVisibilityListener = new GridActionsVisibilityListener(eventBus,
|
||||
this.gridActionsVisibilityListener = new GridActionsVisibilityListener(uiDependencies.getEventBus(),
|
||||
new EventLayoutViewAware(EventLayout.DS_TYPE_FILTER, EventView.DISTRIBUTIONS),
|
||||
dSTypeFilterButtons::hideActionColumns, dSTypeFilterButtons::showEditColumn,
|
||||
dSTypeFilterButtons::showDeleteColumn);
|
||||
this.entityModifiedListener = new EntityModifiedListener.Builder<>(eventBus, ProxyType.class)
|
||||
this.entityModifiedListener = new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(), ProxyType.class)
|
||||
.entityModifiedAwareSupports(getEntityModifiedAwareSupports())
|
||||
.parentEntityType(ProxyDistributionSet.class).build();
|
||||
|
||||
|
||||
@@ -9,54 +9,39 @@
|
||||
package org.eclipse.hawkbit.ui.distributions.dstable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractAddNamedEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.DistributionSetToProxyDistributionMapper;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTypeInfo;
|
||||
import org.eclipse.hawkbit.ui.common.event.CommandTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.SelectionChangedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.SelectionChangedEventPayload.SelectionChangedEventType;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Controller for add distribution set window
|
||||
*/
|
||||
public class AddDsWindowController extends AbstractEntityWindowController<ProxyDistributionSet, ProxyDistributionSet> {
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
public class AddDsWindowController
|
||||
extends AbstractAddNamedEntityWindowController<ProxyDistributionSet, ProxyDistributionSet, DistributionSet> {
|
||||
|
||||
private final SystemManagement systemManagement;
|
||||
|
||||
private final DistributionSetManagement dsManagement;
|
||||
|
||||
private final DsWindowLayout layout;
|
||||
|
||||
private final EventView view;
|
||||
private final ProxyDsValidator validator;
|
||||
|
||||
/**
|
||||
* Constructor for AddDsWindowController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* VaadinMessageSource
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param systemManagement
|
||||
* SystemManagement
|
||||
* @param dsManagement
|
||||
@@ -66,24 +51,19 @@ public class AddDsWindowController extends AbstractEntityWindowController<ProxyD
|
||||
* @param view
|
||||
* EventView
|
||||
*/
|
||||
public AddDsWindowController(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification, final SystemManagement systemManagement,
|
||||
public AddDsWindowController(final CommonUiDependencies uiDependencies, final SystemManagement systemManagement,
|
||||
final DistributionSetManagement dsManagement, final DsWindowLayout layout, final EventView view) {
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.systemManagement = systemManagement;
|
||||
|
||||
this.dsManagement = dsManagement;
|
||||
|
||||
this.layout = layout;
|
||||
|
||||
this.view = view;
|
||||
this.validator = new ProxyDsValidator(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractEntityWindowLayout<ProxyDistributionSet> getLayout() {
|
||||
public EntityWindowLayout<ProxyDistributionSet> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -101,36 +81,39 @@ public class AddDsWindowController extends AbstractEntityWindowController<ProxyD
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyDistributionSet entity) {
|
||||
final DistributionSet newDs = dsManagement.create(entityFactory.distributionSet().create()
|
||||
.type(entity.getTypeInfo().getKey()).name(entity.getName()).version(entity.getVersion())
|
||||
.description(entity.getDescription()).requiredMigrationStep(entity.isRequiredMigrationStep()));
|
||||
protected DistributionSet persistEntityInRepository(final ProxyDistributionSet entity) {
|
||||
return dsManagement.create(getEntityFactory().distributionSet().create().type(entity.getTypeInfo().getKey())
|
||||
.name(entity.getName()).version(entity.getVersion()).description(entity.getDescription())
|
||||
.requiredMigrationStep(entity.isRequiredMigrationStep()));
|
||||
}
|
||||
|
||||
uiNotification
|
||||
.displaySuccess(i18n.getMessage("message.save.success", newDs.getName() + ":" + newDs.getVersion()));
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_ADDED, ProxyDistributionSet.class, newDs.getId()));
|
||||
@Override
|
||||
protected String getDisplayableName(final DistributionSet entity) {
|
||||
return HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
|
||||
}
|
||||
|
||||
final ProxyDistributionSet addedItem = new DistributionSetToProxyDistributionMapper().map(newDs);
|
||||
eventBus.publish(CommandTopics.SELECT_GRID_ENTITY, this, new SelectionChangedEventPayload<>(
|
||||
SelectionChangedEventType.ENTITY_SELECTED, addedItem, EventLayout.DS_LIST, view));
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final ProxyDistributionSet entity) {
|
||||
return HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyDistributionSet.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void selectPersistedEntity(final DistributionSet entity) {
|
||||
final ProxyDistributionSet addedItem = new DistributionSetToProxyDistributionMapper().map(entity);
|
||||
publishSelectionEvent(new SelectionChangedEventPayload<>(SelectionChangedEventType.ENTITY_SELECTED, addedItem,
|
||||
EventLayout.DS_LIST, view));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyDistributionSet entity) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getVersion())) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.error.missing.nameorversion"));
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
final String trimmedVersion = StringUtils.trimWhitespace(entity.getVersion());
|
||||
if (dsManagement.getByNameAndVersion(trimmedName, trimmedVersion).isPresent()) {
|
||||
uiNotification
|
||||
.displayValidationError(i18n.getMessage("message.duplicate.dist", trimmedName, trimmedVersion));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return validator.isEntityValid(entity,
|
||||
() -> dsManagement.getByNameAndVersion(trimmedName, trimmedVersion).isPresent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.filters.DsDistributionsFilterParams;
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetDistributionsStateDataProvider;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.distributionset.AbstractDsGrid;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.FilterType;
|
||||
import org.eclipse.hawkbit.ui.common.grid.AbstractDsGrid;
|
||||
import org.eclipse.hawkbit.ui.common.grid.support.DragAndDropSupport;
|
||||
import org.eclipse.hawkbit.ui.common.grid.support.FilterSupport;
|
||||
import org.eclipse.hawkbit.ui.common.grid.support.assignment.AssignmentSupport;
|
||||
@@ -31,9 +31,6 @@ import org.eclipse.hawkbit.ui.common.state.GridLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Distribution set grid which is shown on the Distributions View.
|
||||
@@ -46,38 +43,29 @@ public class DistributionSetGrid extends AbstractDsGrid<DsDistributionsFilterPar
|
||||
/**
|
||||
* Constructor for DistributionSetGrid
|
||||
*
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permissionChecker
|
||||
* SpPermissionChecker
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetManagement
|
||||
* TargetManagement
|
||||
* TargetManagement
|
||||
* @param dsManagement
|
||||
* DistributionSetManagement
|
||||
* DistributionSetManagement
|
||||
* @param smManagement
|
||||
* SoftwareModuleManagement
|
||||
* SoftwareModuleManagement
|
||||
* @param dsTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* @param smTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param dSTypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
* @param distributionSetGridLayoutUiState
|
||||
* GridLayoutUiState
|
||||
* GridLayoutUiState
|
||||
*/
|
||||
public DistributionSetGrid(final UIEventBus eventBus, final VaadinMessageSource i18n,
|
||||
final SpPermissionChecker permissionChecker, final UINotification notification,
|
||||
final TargetManagement targetManagement, final DistributionSetManagement dsManagement,
|
||||
final SoftwareModuleManagement smManagement, final DistributionSetTypeManagement dsTypeManagement,
|
||||
final SoftwareModuleTypeManagement smTypeManagement,
|
||||
public DistributionSetGrid(final CommonUiDependencies uiDependencies, final TargetManagement targetManagement,
|
||||
final DistributionSetManagement dsManagement, final SoftwareModuleManagement smManagement,
|
||||
final DistributionSetTypeManagement dsTypeManagement, final SoftwareModuleTypeManagement smTypeManagement,
|
||||
final TypeFilterLayoutUiState dSTypeFilterLayoutUiState,
|
||||
final GridLayoutUiState distributionSetGridLayoutUiState) {
|
||||
super(i18n, eventBus, permissionChecker, notification, dsManagement, distributionSetGridLayoutUiState,
|
||||
EventView.DISTRIBUTIONS);
|
||||
super(uiDependencies, dsManagement, distributionSetGridLayoutUiState, EventView.DISTRIBUTIONS);
|
||||
|
||||
this.dSTypeFilterLayoutUiState = dSTypeFilterLayoutUiState;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.util.List;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
@@ -23,16 +22,17 @@ import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.DistributionSetDetails;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.DistributionSetDetailsHeader;
|
||||
import org.eclipse.hawkbit.ui.common.distributionset.AbstractDistributionSetGridLayout;
|
||||
import org.eclipse.hawkbit.ui.common.distributionset.DistributionSetDetails;
|
||||
import org.eclipse.hawkbit.ui.common.distributionset.DistributionSetDetailsHeader;
|
||||
import org.eclipse.hawkbit.ui.common.distributionset.DistributionSetGridHeader;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayoutViewAware;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventViewAware;
|
||||
import org.eclipse.hawkbit.ui.common.layout.AbstractGridComponentLayout;
|
||||
import org.eclipse.hawkbit.ui.common.layout.MasterEntityAwareComponent;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.EntityModifiedListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.EntityModifiedListener.EntityModifiedAwareSupport;
|
||||
@@ -44,14 +44,11 @@ import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedSelec
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedTagTokenAwareSupport;
|
||||
import org.eclipse.hawkbit.ui.common.state.GridLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* DistributionSet table layout.
|
||||
* DistributionSet table layout in distributions view.
|
||||
*/
|
||||
public class DistributionSetGridLayout extends AbstractGridComponentLayout {
|
||||
public class DistributionSetGridLayout extends AbstractDistributionSetGridLayout {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final DistributionSetGridHeader distributionSetGridHeader;
|
||||
@@ -59,53 +56,37 @@ public class DistributionSetGridLayout extends AbstractGridComponentLayout {
|
||||
private final DistributionSetDetailsHeader distributionSetDetailsHeader;
|
||||
private final DistributionSetDetails distributionSetDetails;
|
||||
|
||||
private final transient FilterChangedListener<ProxyDistributionSet> dsFilterListener;
|
||||
private final transient SelectionChangedListener<ProxyDistributionSet> masterDsChangedListener;
|
||||
private final transient SelectGridEntityListener<ProxyDistributionSet> selectDsListener;
|
||||
private final transient EntityModifiedListener<ProxyDistributionSet> dsModifiedListener;
|
||||
private final transient EntityModifiedListener<ProxyTag> tagModifiedListener;
|
||||
|
||||
/**
|
||||
* Constructor for DistributionSetGridLayout
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param permissionChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetManagement
|
||||
* TargetManagement
|
||||
* TargetManagement
|
||||
* @param targetFilterQueryManagement
|
||||
* TargetFilterQueryManagement
|
||||
* TargetFilterQueryManagement
|
||||
* @param distributionSetManagement
|
||||
* DistributionSetManagement
|
||||
* DistributionSetManagement
|
||||
* @param smManagement
|
||||
* SoftwareModuleManagement
|
||||
* SoftwareModuleManagement
|
||||
* @param distributionSetTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* DistributionSetTypeManagement
|
||||
* @param distributionSetTagManagement
|
||||
* DistributionSetTagManagement
|
||||
* DistributionSetTagManagement
|
||||
* @param smTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param systemManagement
|
||||
* SystemManagement
|
||||
* SystemManagement
|
||||
* @param configManagement
|
||||
* TenantConfigurationManagement
|
||||
* TenantConfigurationManagement
|
||||
* @param systemSecurityContext
|
||||
* SystemSecurityContext
|
||||
* SystemSecurityContext
|
||||
* @param dSTypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
* @param distributionSetGridLayoutUiState
|
||||
* GridLayoutUiState
|
||||
* GridLayoutUiState
|
||||
*/
|
||||
public DistributionSetGridLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final SpPermissionChecker permissionChecker, final UINotification uiNotification,
|
||||
final EntityFactory entityFactory, final TargetManagement targetManagement,
|
||||
public DistributionSetGridLayout(final CommonUiDependencies uiDependencies, final TargetManagement targetManagement,
|
||||
final TargetFilterQueryManagement targetFilterQueryManagement,
|
||||
final DistributionSetManagement distributionSetManagement, final SoftwareModuleManagement smManagement,
|
||||
final DistributionSetTypeManagement distributionSetTypeManagement,
|
||||
@@ -114,42 +95,40 @@ public class DistributionSetGridLayout extends AbstractGridComponentLayout {
|
||||
final TenantConfigurationManagement configManagement, final SystemSecurityContext systemSecurityContext,
|
||||
final TypeFilterLayoutUiState dSTypeFilterLayoutUiState,
|
||||
final GridLayoutUiState distributionSetGridLayoutUiState) {
|
||||
final DsWindowBuilder dsWindowBuilder = new DsWindowBuilder(i18n, entityFactory, eventBus, uiNotification,
|
||||
systemManagement, systemSecurityContext, configManagement, distributionSetManagement,
|
||||
super(uiDependencies, systemManagement, systemSecurityContext, configManagement, distributionSetManagement,
|
||||
distributionSetTypeManagement, EventView.DISTRIBUTIONS);
|
||||
final DsMetaDataWindowBuilder dsMetaDataWindowBuilder = new DsMetaDataWindowBuilder(i18n, entityFactory,
|
||||
eventBus, uiNotification, permissionChecker, distributionSetManagement);
|
||||
|
||||
this.distributionSetGridHeader = new DistributionSetGridHeader(i18n, permissionChecker, eventBus,
|
||||
dSTypeFilterLayoutUiState, distributionSetGridLayoutUiState, EventLayout.DS_TYPE_FILTER,
|
||||
EventView.DISTRIBUTIONS);
|
||||
this.distributionSetGridHeader.addAddHeaderSupport(dsWindowBuilder);
|
||||
this.distributionSetGridHeader = new DistributionSetGridHeader(uiDependencies, dSTypeFilterLayoutUiState,
|
||||
distributionSetGridLayoutUiState, EventLayout.DS_TYPE_FILTER, getEventView());
|
||||
this.distributionSetGridHeader.addAddHeaderSupport(getDsWindowBuilder());
|
||||
this.distributionSetGridHeader.buildHeader();
|
||||
this.distributionSetGrid = new DistributionSetGrid(eventBus, i18n, permissionChecker, uiNotification,
|
||||
targetManagement, distributionSetManagement, smManagement, distributionSetTypeManagement,
|
||||
smTypeManagement, dSTypeFilterLayoutUiState, distributionSetGridLayoutUiState);
|
||||
|
||||
this.distributionSetDetailsHeader = new DistributionSetDetailsHeader(i18n, permissionChecker, eventBus,
|
||||
uiNotification, dsWindowBuilder, dsMetaDataWindowBuilder);
|
||||
this.distributionSetDetails = new DistributionSetDetails(i18n, eventBus, permissionChecker, uiNotification,
|
||||
distributionSetManagement, smManagement, distributionSetTypeManagement, distributionSetTagManagement,
|
||||
configManagement, systemSecurityContext, dsMetaDataWindowBuilder);
|
||||
this.distributionSetGrid = new DistributionSetGrid(uiDependencies, targetManagement, distributionSetManagement,
|
||||
smManagement, distributionSetTypeManagement, smTypeManagement, dSTypeFilterLayoutUiState,
|
||||
distributionSetGridLayoutUiState);
|
||||
|
||||
this.distributionSetDetailsHeader = new DistributionSetDetailsHeader(uiDependencies, getDsWindowBuilder(),
|
||||
getDsMetaDataWindowBuilder());
|
||||
|
||||
this.distributionSetDetails = new DistributionSetDetails(uiDependencies, distributionSetManagement, smManagement,
|
||||
distributionSetTypeManagement, distributionSetTagManagement, configManagement, systemSecurityContext,
|
||||
getDsMetaDataWindowBuilder());
|
||||
this.distributionSetDetails.setUnassignSmAllowed(true);
|
||||
this.distributionSetDetails.addTfqDetailsGrid(targetFilterQueryManagement);
|
||||
this.distributionSetDetails.buildDetails();
|
||||
|
||||
this.dsFilterListener = new FilterChangedListener<>(eventBus, ProxyDistributionSet.class,
|
||||
new EventViewAware(EventView.DISTRIBUTIONS), distributionSetGrid.getFilterSupport());
|
||||
this.masterDsChangedListener = new SelectionChangedListener<>(eventBus,
|
||||
new EventLayoutViewAware(EventLayout.DS_LIST, EventView.DISTRIBUTIONS), getDsEntityAwareComponents());
|
||||
this.selectDsListener = new SelectGridEntityListener<>(eventBus,
|
||||
new EventLayoutViewAware(EventLayout.DS_LIST, EventView.DISTRIBUTIONS),
|
||||
distributionSetGrid.getSelectionSupport());
|
||||
this.dsModifiedListener = new EntityModifiedListener.Builder<>(eventBus, ProxyDistributionSet.class)
|
||||
.entityModifiedAwareSupports(getDsModifiedAwareSupports()).build();
|
||||
this.tagModifiedListener = new EntityModifiedListener.Builder<>(eventBus, ProxyTag.class)
|
||||
addEventListener(new FilterChangedListener<>(uiDependencies.getEventBus(), ProxyDistributionSet.class,
|
||||
new EventViewAware(getEventView()), distributionSetGrid.getFilterSupport()));
|
||||
addEventListener(new SelectionChangedListener<>(uiDependencies.getEventBus(),
|
||||
new EventLayoutViewAware(EventLayout.DS_LIST, getEventView()), getDsEntityAwareComponents()));
|
||||
addEventListener(new SelectGridEntityListener<>(uiDependencies.getEventBus(),
|
||||
new EventLayoutViewAware(EventLayout.DS_LIST, getEventView()),
|
||||
distributionSetGrid.getSelectionSupport()));
|
||||
addEventListener(new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(), ProxyDistributionSet.class)
|
||||
.entityModifiedAwareSupports(getDsModifiedAwareSupports()).build());
|
||||
addEventListener(new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(), ProxyTag.class)
|
||||
.entityModifiedAwareSupports(getTagModifiedAwareSupports()).parentEntityType(ProxyDistributionSet.class)
|
||||
.build();
|
||||
.build());
|
||||
|
||||
buildLayout(distributionSetGridHeader, distributionSetGrid, distributionSetDetailsHeader,
|
||||
distributionSetDetails);
|
||||
@@ -170,52 +149,13 @@ public class DistributionSetGridLayout extends AbstractGridComponentLayout {
|
||||
.singletonList(EntityModifiedTagTokenAwareSupport.of(distributionSetDetails.getDistributionTagToken()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show distribution set type header icon
|
||||
*/
|
||||
public void showDsTypeHeaderIcon() {
|
||||
distributionSetGridHeader.showFilterIcon();
|
||||
@Override
|
||||
public DistributionSetGrid getDistributionGrid() {
|
||||
return distributionSetGrid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide distribution set type header icon
|
||||
*/
|
||||
public void hideDsTypeHeaderIcon() {
|
||||
distributionSetGridHeader.hideFilterIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximize the distribution set grid
|
||||
*/
|
||||
public void maximize() {
|
||||
distributionSetGrid.createMaximizedContent();
|
||||
hideDetailsLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimize the distribution set grid
|
||||
*/
|
||||
public void minimize() {
|
||||
distributionSetGrid.createMinimizedContent();
|
||||
showDetailsLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the distribution set header and grid
|
||||
*/
|
||||
public void restoreState() {
|
||||
distributionSetGridHeader.restoreState();
|
||||
distributionSetGrid.restoreState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe the eent listener
|
||||
*/
|
||||
public void unsubscribeListener() {
|
||||
dsFilterListener.unsubscribe();
|
||||
masterDsChangedListener.unsubscribe();
|
||||
selectDsListener.unsubscribe();
|
||||
dsModifiedListener.unsubscribe();
|
||||
tagModifiedListener.unsubscribe();
|
||||
@Override
|
||||
public DistributionSetGridHeader getDistributionSetGridHeader() {
|
||||
return distributionSetGridHeader;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,8 @@ package org.eclipse.hawkbit.ui.distributions.dstable;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.model.MetaData;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.providers.DsMetaDataDataProvider;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyMetaData;
|
||||
@@ -25,9 +24,6 @@ import org.eclipse.hawkbit.ui.common.detailslayout.UpdateMetaDataWindowControlle
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Class for metadata add/update window layout.
|
||||
@@ -36,7 +32,6 @@ public class DsMetaDataWindowLayout extends AbstractMetaDataWindowLayout<Long> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final transient DistributionSetManagement dsManagement;
|
||||
private final transient EntityFactory entityFactory;
|
||||
|
||||
private final MetaDataWindowGrid<Long> dsMetaDataWindowGrid;
|
||||
|
||||
@@ -46,36 +41,26 @@ public class DsMetaDataWindowLayout extends AbstractMetaDataWindowLayout<Long> {
|
||||
|
||||
/**
|
||||
* Constructor for AbstractTagWindowLayout
|
||||
*
|
||||
* @param i18n
|
||||
* I18N
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dsManagement
|
||||
* DistributionSetManagement
|
||||
*/
|
||||
public DsMetaDataWindowLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final SpPermissionChecker permChecker, final UINotification uiNotification,
|
||||
final EntityFactory entityFactory, final DistributionSetManagement dsManagement) {
|
||||
super(i18n, eventBus, uiNotification, permChecker);
|
||||
public DsMetaDataWindowLayout(final CommonUiDependencies uiDependencies,
|
||||
final DistributionSetManagement dsManagement) {
|
||||
super(uiDependencies);
|
||||
|
||||
this.dsManagement = dsManagement;
|
||||
this.entityFactory = entityFactory;
|
||||
|
||||
this.dsMetaDataWindowGrid = new MetaDataWindowGrid<>(i18n, eventBus, permChecker, uiNotification,
|
||||
new DsMetaDataDataProvider(dsManagement), this::hasMetadataChangePermission, this::deleteMetaData);
|
||||
this.dsMetaDataWindowGrid = new MetaDataWindowGrid<>(uiDependencies, new DsMetaDataDataProvider(dsManagement),
|
||||
this::hasMetadataChangePermission,this::deleteMetaData);
|
||||
|
||||
this.metaDataAddUpdateWindowLayout = new MetaDataAddUpdateWindowLayout(i18n, this::hasMetadataChangePermission);
|
||||
this.addDsMetaDataWindowController = new AddMetaDataWindowController(i18n, uiNotification,
|
||||
this.metaDataAddUpdateWindowLayout = new MetaDataAddUpdateWindowLayout(i18n,this::hasMetadataChangePermission);
|
||||
this.addDsMetaDataWindowController = new AddMetaDataWindowController(uiDependencies,
|
||||
metaDataAddUpdateWindowLayout, this::createMetaData, this::isDuplicate);
|
||||
this.updateDsMetaDataWindowController = new UpdateMetaDataWindowController(i18n, uiNotification,
|
||||
metaDataAddUpdateWindowLayout, this::updateMetaData);
|
||||
this.updateDsMetaDataWindowController = new UpdateMetaDataWindowController(uiDependencies,
|
||||
metaDataAddUpdateWindowLayout, this::updateMetaData, this::isDuplicate);
|
||||
|
||||
buildLayout();
|
||||
addGridSelectionListener();
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.distributions.dstable;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityValidator;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Validator used in target window controllers to validate {@link ProxyDistributionSet}.
|
||||
*/
|
||||
public class ProxyDsValidator extends EntityValidator {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public ProxyDsValidator(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
boolean isEntityValid(final ProxyDistributionSet entity, final BooleanSupplier duplicateCheck) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getVersion())) {
|
||||
displayValidationError("message.error.missing.nameorversion");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
final String trimmedVersion = StringUtils.trimWhitespace(entity.getVersion());
|
||||
if (duplicateCheck.getAsBoolean()) {
|
||||
displayValidationError("message.duplicate.dist", trimmedName, trimmedVersion);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -9,72 +9,46 @@
|
||||
package org.eclipse.hawkbit.ui.distributions.dstable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractUpdateNamedEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Controller for update distribution set window
|
||||
*/
|
||||
public class UpdateDsWindowController
|
||||
extends AbstractEntityWindowController<ProxyDistributionSet, ProxyDistributionSet> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UpdateDsWindowController.class);
|
||||
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
extends AbstractUpdateNamedEntityWindowController<ProxyDistributionSet, ProxyDistributionSet, DistributionSet> {
|
||||
|
||||
private final DistributionSetManagement dsManagement;
|
||||
|
||||
private final DsWindowLayout layout;
|
||||
private final ProxyDsValidator validator;
|
||||
|
||||
private String nameBeforeEdit;
|
||||
private String versionBeforeEdit;
|
||||
|
||||
/**
|
||||
* Constructor for UpdateDsWindowController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param dsManagement
|
||||
* DistributionSetManagement
|
||||
* @param layout
|
||||
* DsWindowLayout
|
||||
*/
|
||||
public UpdateDsWindowController(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification,
|
||||
public UpdateDsWindowController(final CommonUiDependencies uiDependencies,
|
||||
final DistributionSetManagement dsManagement, final DsWindowLayout layout) {
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.dsManagement = dsManagement;
|
||||
|
||||
this.layout = layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractEntityWindowLayout<ProxyDistributionSet> getLayout() {
|
||||
return layout;
|
||||
this.validator = new ProxyDsValidator(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,50 +62,54 @@ public class UpdateDsWindowController
|
||||
ds.setDescription(proxyEntity.getDescription());
|
||||
ds.setRequiredMigrationStep(proxyEntity.isRequiredMigrationStep());
|
||||
|
||||
nameBeforeEdit = proxyEntity.getName();
|
||||
versionBeforeEdit = proxyEntity.getVersion();
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityWindowLayout<ProxyDistributionSet> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptLayout(final ProxyDistributionSet proxyEntity) {
|
||||
layout.disableDsTypeSelect();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyDistributionSet entity) {
|
||||
final DistributionSetUpdate dsUpdate = entityFactory.distributionSet().update(entity.getId())
|
||||
protected DistributionSet persistEntityInRepository(final ProxyDistributionSet entity) {
|
||||
final DistributionSetUpdate dsUpdate = getEntityFactory().distributionSet().update(entity.getId())
|
||||
.name(entity.getName()).version(entity.getVersion()).description(entity.getDescription())
|
||||
.requiredMigrationStep(entity.isRequiredMigrationStep());
|
||||
return dsManagement.update(dsUpdate);
|
||||
}
|
||||
|
||||
try {
|
||||
final DistributionSet updatedDs = dsManagement.update(dsUpdate);
|
||||
@Override
|
||||
protected String getDisplayableName(final DistributionSet entity) {
|
||||
return HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
|
||||
}
|
||||
|
||||
uiNotification.displaySuccess(
|
||||
i18n.getMessage("message.update.success", updatedDs.getName() + ":" + updatedDs.getVersion()));
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_UPDATED, ProxyDistributionSet.class, updatedDs.getId()));
|
||||
} catch (final EntityNotFoundException | EntityReadOnlyException e) {
|
||||
LOG.trace("Update of distribution set failed in UI: {}", e.getMessage());
|
||||
final String entityType = i18n.getMessage("caption.distribution");
|
||||
uiNotification
|
||||
.displayWarning(i18n.getMessage("message.deleted.or.notAllowed", entityType, entity.getName()));
|
||||
}
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final ProxyDistributionSet entity) {
|
||||
return HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyDistributionSet.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyDistributionSet entity) {
|
||||
if (!StringUtils.hasText(entity.getName()) || !StringUtils.hasText(entity.getVersion())) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.error.missing.nameorversion"));
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
final String trimmedVersion = StringUtils.trimWhitespace(entity.getVersion());
|
||||
if (dsManagement.getByNameAndVersion(trimmedName, trimmedVersion).isPresent()) {
|
||||
uiNotification
|
||||
.displayValidationError(i18n.getMessage("message.duplicate.dist", trimmedName, trimmedVersion));
|
||||
return false;
|
||||
}
|
||||
return validator.isEntityValid(entity, () -> hasNameOrVersionChanged(trimmedName, trimmedVersion)
|
||||
&& dsManagement.getByNameAndVersion(trimmedName, trimmedVersion).isPresent());
|
||||
}
|
||||
|
||||
return true;
|
||||
private boolean hasNameOrVersionChanged(final String trimmedName, final String trimmedVersion) {
|
||||
return !nameBeforeEdit.equals(trimmedName) || !versionBeforeEdit.equals(trimmedVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,11 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SmMetaDataWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SmWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleGrid;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleGridHeader;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyDistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetails;
|
||||
@@ -29,7 +26,6 @@ import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayoutViewAware;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventViewAware;
|
||||
import org.eclipse.hawkbit.ui.common.layout.AbstractGridComponentLayout;
|
||||
import org.eclipse.hawkbit.ui.common.layout.MasterEntityAwareComponent;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.EntityModifiedListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.EntityModifiedListener.EntityModifiedAwareSupport;
|
||||
@@ -38,16 +34,14 @@ import org.eclipse.hawkbit.ui.common.layout.listener.SelectGridEntityListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.SelectionChangedListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedGridRefreshAwareSupport;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedSelectionAwareSupport;
|
||||
import org.eclipse.hawkbit.ui.common.softwaremodule.AbstractSoftwareModuleGridLayout;
|
||||
import org.eclipse.hawkbit.ui.common.state.GridLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Implementation of software module Layout on the Distribution View
|
||||
*/
|
||||
public class SwModuleGridLayout extends AbstractGridComponentLayout {
|
||||
public class SwModuleGridLayout extends AbstractSoftwareModuleGridLayout {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final SoftwareModuleGridHeader swModuleGridHeader;
|
||||
@@ -55,29 +49,15 @@ public class SwModuleGridLayout extends AbstractGridComponentLayout {
|
||||
private final SoftwareModuleDetailsHeader softwareModuleDetailsHeader;
|
||||
private final SoftwareModuleDetails swModuleDetails;
|
||||
|
||||
private final transient FilterChangedListener<ProxySoftwareModule> smFilterListener;
|
||||
private final transient SelectionChangedListener<ProxyDistributionSet> masterDsChangedListener;
|
||||
private final transient SelectionChangedListener<ProxySoftwareModule> masterSmChangedListener;
|
||||
private final transient SelectGridEntityListener<ProxySoftwareModule> selectSmListener;
|
||||
private final transient EntityModifiedListener<ProxySoftwareModule> smModifiedListener;
|
||||
|
||||
/**
|
||||
* Constructor for SwModuleGridLayout
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param softwareModuleManagement
|
||||
* SoftwareModuleManagement
|
||||
* @param softwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param artifactManagement
|
||||
* ArtifactManagement
|
||||
* @param smTypeFilterLayoutUiState
|
||||
@@ -85,48 +65,39 @@ public class SwModuleGridLayout extends AbstractGridComponentLayout {
|
||||
* @param swModuleGridLayoutUiState
|
||||
* GridLayoutUiState
|
||||
*/
|
||||
public SwModuleGridLayout(final VaadinMessageSource i18n, final UINotification uiNotification,
|
||||
final UIEventBus eventBus, final SoftwareModuleManagement softwareModuleManagement,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement, final EntityFactory entityFactory,
|
||||
final SpPermissionChecker permChecker, final ArtifactManagement artifactManagement,
|
||||
final TypeFilterLayoutUiState smTypeFilterLayoutUiState,
|
||||
public SwModuleGridLayout(final CommonUiDependencies uiDependencies, final SoftwareModuleManagement softwareModuleManagement,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement,
|
||||
final ArtifactManagement artifactManagement, final TypeFilterLayoutUiState smTypeFilterLayoutUiState,
|
||||
final GridLayoutUiState swModuleGridLayoutUiState) {
|
||||
super();
|
||||
super(uiDependencies, softwareModuleManagement, softwareModuleTypeManagement, EventView.DISTRIBUTIONS);
|
||||
|
||||
final SmWindowBuilder smWindowBuilder = new SmWindowBuilder(i18n, entityFactory, eventBus, uiNotification,
|
||||
softwareModuleManagement, softwareModuleTypeManagement, EventView.DISTRIBUTIONS);
|
||||
final SmMetaDataWindowBuilder smMetaDataWindowBuilder = new SmMetaDataWindowBuilder(i18n, entityFactory,
|
||||
eventBus, uiNotification, permChecker, softwareModuleManagement);
|
||||
|
||||
this.swModuleGridHeader = new SoftwareModuleGridHeader(i18n, permChecker, eventBus, smTypeFilterLayoutUiState,
|
||||
swModuleGridLayoutUiState, smWindowBuilder, EventView.DISTRIBUTIONS);
|
||||
this.swModuleGridHeader = new SoftwareModuleGridHeader(uiDependencies, smTypeFilterLayoutUiState,
|
||||
swModuleGridLayoutUiState, getSmWindowBuilder(), getEventView());
|
||||
this.swModuleGridHeader.buildHeader();
|
||||
this.swModuleGrid = new SoftwareModuleGrid(eventBus, i18n, permChecker, uiNotification,
|
||||
smTypeFilterLayoutUiState, swModuleGridLayoutUiState, softwareModuleManagement,
|
||||
EventView.DISTRIBUTIONS);
|
||||
this.swModuleGrid = new SoftwareModuleGrid(uiDependencies, smTypeFilterLayoutUiState, swModuleGridLayoutUiState,
|
||||
softwareModuleManagement, getEventView());
|
||||
this.swModuleGrid.addDragAndDropSupport();
|
||||
this.swModuleGrid.addMasterSupport();
|
||||
this.swModuleGrid.init();
|
||||
|
||||
this.softwareModuleDetailsHeader = new SoftwareModuleDetailsHeader(i18n, permChecker, eventBus, uiNotification,
|
||||
smWindowBuilder, smMetaDataWindowBuilder);
|
||||
this.softwareModuleDetailsHeader = new SoftwareModuleDetailsHeader(uiDependencies, getSmWindowBuilder(),
|
||||
getSmMetaDataWindowBuilder());
|
||||
this.softwareModuleDetailsHeader.addArtifactDetailsHeaderSupport(artifactManagement);
|
||||
this.softwareModuleDetailsHeader.buildHeader();
|
||||
this.swModuleDetails = new SoftwareModuleDetails(i18n, eventBus, softwareModuleManagement,
|
||||
softwareModuleTypeManagement, smMetaDataWindowBuilder);
|
||||
this.swModuleDetails = new SoftwareModuleDetails(uiDependencies, softwareModuleManagement,
|
||||
softwareModuleTypeManagement, getSmMetaDataWindowBuilder());
|
||||
this.swModuleDetails.buildDetails();
|
||||
|
||||
this.smFilterListener = new FilterChangedListener<>(eventBus, ProxySoftwareModule.class,
|
||||
new EventViewAware(EventView.DISTRIBUTIONS), swModuleGrid.getFilterSupport());
|
||||
this.masterDsChangedListener = new SelectionChangedListener<>(eventBus,
|
||||
new EventLayoutViewAware(EventLayout.DS_LIST, EventView.DISTRIBUTIONS), getMasterDsAwareComponents());
|
||||
this.masterSmChangedListener = new SelectionChangedListener<>(eventBus,
|
||||
new EventLayoutViewAware(EventLayout.SM_LIST, EventView.DISTRIBUTIONS), getMasterSmAwareComponents());
|
||||
this.selectSmListener = new SelectGridEntityListener<>(eventBus,
|
||||
new EventLayoutViewAware(EventLayout.SM_LIST, EventView.DISTRIBUTIONS),
|
||||
swModuleGrid.getSelectionSupport());
|
||||
this.smModifiedListener = new EntityModifiedListener.Builder<>(eventBus, ProxySoftwareModule.class)
|
||||
.entityModifiedAwareSupports(getSmModifiedAwareSupports()).build();
|
||||
addEventListener(new FilterChangedListener<>(uiDependencies.getEventBus(), ProxySoftwareModule.class,
|
||||
new EventViewAware(getEventView()), swModuleGrid.getFilterSupport()));
|
||||
addEventListener(new SelectionChangedListener<>(uiDependencies.getEventBus(),
|
||||
new EventLayoutViewAware(EventLayout.DS_LIST, getEventView()), getMasterDsAwareComponents()));
|
||||
addEventListener(new SelectionChangedListener<>(uiDependencies.getEventBus(),
|
||||
new EventLayoutViewAware(EventLayout.SM_LIST, getEventView()), getMasterSmAwareComponents()));
|
||||
addEventListener(new SelectGridEntityListener<>(uiDependencies.getEventBus(),
|
||||
new EventLayoutViewAware(EventLayout.SM_LIST, getEventView()), swModuleGrid.getSelectionSupport()));
|
||||
addEventListener(new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(), ProxySoftwareModule.class)
|
||||
.entityModifiedAwareSupports(getSmModifiedAwareSupports()).build());
|
||||
|
||||
buildLayout(swModuleGridHeader, swModuleGrid, softwareModuleDetailsHeader, swModuleDetails);
|
||||
}
|
||||
@@ -145,52 +116,13 @@ public class SwModuleGridLayout extends AbstractGridComponentLayout {
|
||||
swModuleGrid::mapIdToProxyEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show software type module header icon
|
||||
*/
|
||||
public void showSmTypeHeaderIcon() {
|
||||
swModuleGridHeader.showFilterIcon();
|
||||
@Override
|
||||
protected SoftwareModuleGridHeader getSoftwareModuleGridHeader() {
|
||||
return swModuleGridHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide software type module header icon
|
||||
*/
|
||||
public void hideSmTypeHeaderIcon() {
|
||||
swModuleGridHeader.hideFilterIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximize the software module grid
|
||||
*/
|
||||
public void maximize() {
|
||||
swModuleGrid.createMaximizedContent();
|
||||
hideDetailsLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimize the software module grid
|
||||
*/
|
||||
public void minimize() {
|
||||
swModuleGrid.createMinimizedContent();
|
||||
showDetailsLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the software module grid and header
|
||||
*/
|
||||
public void restoreState() {
|
||||
swModuleGridHeader.restoreState();
|
||||
swModuleGrid.restoreState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe the event listener
|
||||
*/
|
||||
public void unsubscribeListener() {
|
||||
smFilterListener.unsubscribe();
|
||||
masterDsChangedListener.unsubscribe();
|
||||
masterSmChangedListener.unsubscribe();
|
||||
selectSmListener.unsubscribe();
|
||||
smModifiedListener.unsubscribe();
|
||||
@Override
|
||||
protected SoftwareModuleGrid getSoftwareModuleGrid() {
|
||||
return swModuleGrid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,123 +8,45 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.distributions.smtype.filter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtype.SmTypeWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtype.filter.SMTypeFilterButtons;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtype.filter.SMTypeFilterHeader;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayoutViewAware;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtype.filter.SMTypeFilterLayout;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.EntityModifiedListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.EntityModifiedListener.EntityModifiedAwareSupport;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.GridActionsVisibilityListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedGenericSupport;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedGridRefreshAwareSupport;
|
||||
import org.eclipse.hawkbit.ui.common.state.TypeFilterLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.ComponentContainer;
|
||||
|
||||
/**
|
||||
* Software Module Type filter layout.
|
||||
*/
|
||||
public class DistSMTypeFilterLayout extends AbstractFilterLayout {
|
||||
public class DistSMTypeFilterLayout extends SMTypeFilterLayout {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final SMTypeFilterHeader smTypeFilterHeader;
|
||||
private final SMTypeFilterButtons smTypeFilterButtons;
|
||||
|
||||
private final transient GridActionsVisibilityListener gridActionsVisibilityListener;
|
||||
private final transient EntityModifiedListener<ProxyType> entityModifiedListener;
|
||||
|
||||
private final transient SmTypeCssStylesHandler smTypeCssStylesHandler;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param softwareModuleTypeManagement
|
||||
* SoftwareModuleTypeManagement
|
||||
* @param smTypeFilterLayoutUiState
|
||||
* TypeFilterLayoutUiState
|
||||
*/
|
||||
public DistSMTypeFilterLayout(final UIEventBus eventBus, final VaadinMessageSource i18n,
|
||||
final SpPermissionChecker permChecker, final EntityFactory entityFactory,
|
||||
final UINotification uiNotification, final SoftwareModuleTypeManagement softwareModuleTypeManagement,
|
||||
public DistSMTypeFilterLayout(final CommonUiDependencies uiDependencies,
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement,
|
||||
final TypeFilterLayoutUiState smTypeFilterLayoutUiState) {
|
||||
final SmTypeWindowBuilder smTypeWindowBuilder = new SmTypeWindowBuilder(i18n, entityFactory, eventBus,
|
||||
uiNotification, softwareModuleTypeManagement);
|
||||
|
||||
this.smTypeFilterHeader = new SMTypeFilterHeader(eventBus, i18n, permChecker, smTypeWindowBuilder,
|
||||
smTypeFilterLayoutUiState, EventView.DISTRIBUTIONS);
|
||||
this.smTypeFilterButtons = new SMTypeFilterButtons(eventBus, i18n, uiNotification, permChecker,
|
||||
softwareModuleTypeManagement, smTypeWindowBuilder, smTypeFilterLayoutUiState, EventView.DISTRIBUTIONS);
|
||||
|
||||
this.gridActionsVisibilityListener = new GridActionsVisibilityListener(eventBus,
|
||||
new EventLayoutViewAware(EventLayout.SM_TYPE_FILTER, EventView.DISTRIBUTIONS),
|
||||
smTypeFilterButtons::hideActionColumns, smTypeFilterButtons::showEditColumn,
|
||||
smTypeFilterButtons::showDeleteColumn);
|
||||
this.entityModifiedListener = new EntityModifiedListener.Builder<>(eventBus, ProxyType.class)
|
||||
.entityModifiedAwareSupports(getEntityModifiedAwareSupports())
|
||||
.parentEntityType(ProxySoftwareModule.class).build();
|
||||
super(uiDependencies, softwareModuleTypeManagement, smTypeFilterLayoutUiState, EventView.DISTRIBUTIONS);
|
||||
|
||||
this.smTypeCssStylesHandler = new SmTypeCssStylesHandler(softwareModuleTypeManagement);
|
||||
this.smTypeCssStylesHandler.updateSmTypeStyles();
|
||||
|
||||
buildLayout();
|
||||
}
|
||||
|
||||
private List<EntityModifiedAwareSupport> getEntityModifiedAwareSupports() {
|
||||
return Arrays.asList(EntityModifiedGridRefreshAwareSupport.of(this::refreshFilterButtons),
|
||||
EntityModifiedGenericSupport.of(null, null, smTypeFilterButtons::resetFilterOnTypesDeleted));
|
||||
}
|
||||
|
||||
private void refreshFilterButtons() {
|
||||
smTypeFilterButtons.refreshAll();
|
||||
smTypeCssStylesHandler.updateSmTypeStyles();
|
||||
// buildLayout(); was already called in super(...)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SMTypeFilterHeader getFilterHeader() {
|
||||
return smTypeFilterHeader;
|
||||
}
|
||||
protected void refreshFilterButtons() {
|
||||
super.refreshFilterButtons();
|
||||
|
||||
@Override
|
||||
protected ComponentContainer getFilterContent() {
|
||||
return wrapFilterContent(smTypeFilterButtons);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the software module type filter button
|
||||
*/
|
||||
public void restoreState() {
|
||||
smTypeFilterButtons.restoreState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe the event listener
|
||||
*/
|
||||
public void unsubscribeListener() {
|
||||
gridActionsVisibilityListener.unsubscribe();
|
||||
entityModifiedListener.unsubscribe();
|
||||
this.smTypeCssStylesHandler.updateSmTypeStyles();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,19 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractAddEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Controller for add target filter
|
||||
@@ -29,54 +24,38 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
*
|
||||
*/
|
||||
public class AddTargetFilterController
|
||||
extends AbstractEntityWindowController<ProxyTargetFilterQuery, ProxyTargetFilterQuery> {
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
extends AbstractAddEntityWindowController<ProxyTargetFilterQuery, ProxyTargetFilterQuery, TargetFilterQuery> {
|
||||
|
||||
private final TargetFilterQueryManagement targetFilterManagement;
|
||||
|
||||
private final TargetFilterAddUpdateLayout layout;
|
||||
|
||||
private final Runnable closeFormCallback;
|
||||
private final ProxyTargetFilterValidator validator;
|
||||
|
||||
/**
|
||||
* Constructor for AddTargetFilterController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetFilterManagement
|
||||
* TargetFilterQueryManagement
|
||||
* TargetFilterQueryManagement
|
||||
* @param layout
|
||||
* TargetFilterAddUpdateLayout
|
||||
* TargetFilterAddUpdateLayout
|
||||
* @param closeFormCallback
|
||||
* Runnable
|
||||
* Runnable
|
||||
*/
|
||||
public AddTargetFilterController(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification,
|
||||
public AddTargetFilterController(final CommonUiDependencies uiDependencies,
|
||||
final TargetFilterQueryManagement targetFilterManagement, final TargetFilterAddUpdateLayout layout,
|
||||
final Runnable closeFormCallback) {
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.targetFilterManagement = targetFilterManagement;
|
||||
|
||||
this.layout = layout;
|
||||
|
||||
this.closeFormCallback = closeFormCallback;
|
||||
this.validator = new ProxyTargetFilterValidator(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractEntityWindowLayout<ProxyTargetFilterQuery> getLayout() {
|
||||
public EntityWindowLayout<ProxyTargetFilterQuery> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -86,30 +65,39 @@ public class AddTargetFilterController
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyTargetFilterQuery entity) {
|
||||
final TargetFilterQuery newTargetFilter = targetFilterManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(entity.getName()).query(entity.getQuery()));
|
||||
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.save.success", newTargetFilter.getName()));
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_ADDED, ProxyTargetFilterQuery.class, newTargetFilter.getId()));
|
||||
protected TargetFilterQuery persistEntityInRepository(final ProxyTargetFilterQuery entity) {
|
||||
return targetFilterManagement.create(
|
||||
getEntityFactory().targetFilterQuery().create().name(entity.getName()).query(entity.getQuery()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postPersist() {
|
||||
closeFormCallback.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableName(final TargetFilterQuery entity) {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final ProxyTargetFilterQuery entity) {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getId(final TargetFilterQuery entity) {
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyTargetFilterQuery.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyTargetFilterQuery entity) {
|
||||
if (!StringUtils.hasText(entity.getName())) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.error.missing.filtername"));
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
if (targetFilterManagement.getByName(trimmedName).isPresent()) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.target.filter.duplicate", trimmedName));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return validator.isEntityValid(entity, () -> targetFilterManagement.getByName(trimmedName).isPresent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,15 +9,12 @@
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
@@ -25,9 +22,6 @@ import com.vaadin.ui.Window;
|
||||
* Builder for auto assignment window
|
||||
*/
|
||||
public class AutoAssignmentWindowBuilder extends AbstractEntityWindowBuilder<ProxyTargetFilterQuery> {
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
private final EntityFactory entityFactory;
|
||||
|
||||
private final TargetManagement targetManagement;
|
||||
private final TargetFilterQueryManagement targetFilterQueryManagement;
|
||||
@@ -36,30 +30,19 @@ public class AutoAssignmentWindowBuilder extends AbstractEntityWindowBuilder<Pro
|
||||
/**
|
||||
* Constructor for AutoAssignmentWindowBuilder
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetManagement
|
||||
* TargetManagement
|
||||
* TargetManagement
|
||||
* @param targetFilterQueryManagement
|
||||
* TargetFilterQueryManagement
|
||||
* TargetFilterQueryManagement
|
||||
* @param dsManagement
|
||||
* DistributionSetManagement
|
||||
* DistributionSetManagement
|
||||
*/
|
||||
public AutoAssignmentWindowBuilder(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final UINotification uiNotification, final EntityFactory entityFactory,
|
||||
final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterQueryManagement,
|
||||
public AutoAssignmentWindowBuilder(final CommonUiDependencies uiDependencies, final TargetManagement targetManagement,
|
||||
final TargetFilterQueryManagement targetFilterQueryManagement,
|
||||
final DistributionSetManagement dsManagement) {
|
||||
super(i18n);
|
||||
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
this.entityFactory = entityFactory;
|
||||
super(uiDependencies);
|
||||
|
||||
this.targetManagement = targetManagement;
|
||||
this.targetFilterQueryManagement = targetFilterQueryManagement;
|
||||
@@ -75,14 +58,13 @@ public class AutoAssignmentWindowBuilder extends AbstractEntityWindowBuilder<Pro
|
||||
* Gets the auto assigment window
|
||||
*
|
||||
* @param proxyTargetFilter
|
||||
* ProxyTargetFilterQuery
|
||||
* ProxyTargetFilterQuery
|
||||
*
|
||||
* @return Common dialog window
|
||||
* @return Common dialog window
|
||||
*/
|
||||
public Window getWindowForAutoAssignment(final ProxyTargetFilterQuery proxyTargetFilter) {
|
||||
return getWindowForEntity(proxyTargetFilter,
|
||||
new AutoAssignmentWindowController(i18n, eventBus, uiNotification, entityFactory, targetManagement,
|
||||
targetFilterQueryManagement, new AutoAssignmentWindowLayout(i18n, dsManagement)));
|
||||
return getWindowForEntity(proxyTargetFilter, new AutoAssignmentWindowController(uiDependencies, targetManagement,
|
||||
targetFilterQueryManagement, new AutoAssignmentWindowLayout(getI18n(), dsManagement)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,22 +8,18 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractUpdateEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.server.Sizeable;
|
||||
import com.vaadin.ui.UI;
|
||||
@@ -31,29 +27,18 @@ import com.vaadin.ui.UI;
|
||||
/**
|
||||
* Controller for auto assignment window
|
||||
*/
|
||||
public class AutoAssignmentWindowController
|
||||
extends AbstractEntityWindowController<ProxyTargetFilterQuery, ProxyTargetFilterQuery> {
|
||||
private final VaadinMessageSource i18n;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
private final EntityFactory entityFactory;
|
||||
public class AutoAssignmentWindowController extends
|
||||
AbstractUpdateEntityWindowController<ProxyTargetFilterQuery, ProxyTargetFilterQuery, TargetFilterQuery> {
|
||||
|
||||
private final TargetManagement targetManagement;
|
||||
private final TargetFilterQueryManagement targetFilterQueryManagement;
|
||||
|
||||
private final AutoAssignmentWindowLayout layout;
|
||||
|
||||
/**
|
||||
* Constructor for AutoAssignmentWindowController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetManagement
|
||||
* TargetManagement
|
||||
* @param targetFilterQueryManagement
|
||||
@@ -61,26 +46,16 @@ public class AutoAssignmentWindowController
|
||||
* @param layout
|
||||
* AutoAssignmentWindowLayout
|
||||
*/
|
||||
public AutoAssignmentWindowController(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final UINotification uiNotification, final EntityFactory entityFactory,
|
||||
public AutoAssignmentWindowController(final CommonUiDependencies uiDependencies,
|
||||
final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterQueryManagement,
|
||||
final AutoAssignmentWindowLayout layout) {
|
||||
this.i18n = i18n;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
this.entityFactory = entityFactory;
|
||||
super(uiDependencies);
|
||||
|
||||
this.targetManagement = targetManagement;
|
||||
this.targetFilterQueryManagement = targetFilterQueryManagement;
|
||||
|
||||
this.layout = layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractEntityWindowLayout<ProxyTargetFilterQuery> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProxyTargetFilterQuery buildEntityFromProxy(final ProxyTargetFilterQuery proxyEntity) {
|
||||
final ProxyTargetFilterQuery autoAssignmentFilter = new ProxyTargetFilterQuery();
|
||||
@@ -101,6 +76,11 @@ public class AutoAssignmentWindowController
|
||||
return autoAssignmentFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityWindowLayout<ProxyTargetFilterQuery> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptLayout(final ProxyTargetFilterQuery proxyEntity) {
|
||||
layout.switchAutoAssignmentInputsVisibility(layout.getEntity().isAutoAssignmentEnabled());
|
||||
@@ -108,36 +88,38 @@ public class AutoAssignmentWindowController
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyTargetFilterQuery entity) {
|
||||
// super.persistEntity couldn't be used because of the two cases
|
||||
// store/show dialog
|
||||
if (entity.isAutoAssignmentEnabled() && entity.getDistributionSetInfo() != null) {
|
||||
final Long autoAssignDsId = entity.getDistributionSetInfo().getId();
|
||||
final Long targetsForAutoAssignmentCount = targetManagement.countByRsqlAndNonDS(autoAssignDsId,
|
||||
entity.getQuery());
|
||||
|
||||
final String confirmationCaption = i18n
|
||||
final String confirmationCaption = getI18n()
|
||||
.getMessage(UIMessageIdProvider.CAPTION_CONFIRM_AUTO_ASSIGN_CONSEQUENCES);
|
||||
final String confirmationQuestion = targetsForAutoAssignmentCount == 0
|
||||
? i18n.getMessage(UIMessageIdProvider.MESSAGE_CONFIRM_AUTO_ASSIGN_CONSEQUENCES_NONE)
|
||||
: i18n.getMessage(UIMessageIdProvider.MESSAGE_CONFIRM_AUTO_ASSIGN_CONSEQUENCES_TEXT,
|
||||
? getI18n().getMessage(UIMessageIdProvider.MESSAGE_CONFIRM_AUTO_ASSIGN_CONSEQUENCES_NONE)
|
||||
: getI18n().getMessage(UIMessageIdProvider.MESSAGE_CONFIRM_AUTO_ASSIGN_CONSEQUENCES_TEXT,
|
||||
targetsForAutoAssignmentCount);
|
||||
|
||||
showConsequencesDialog(confirmationCaption, confirmationQuestion, entity.getId(), autoAssignDsId,
|
||||
entity.getAutoAssignActionType(), entity);
|
||||
entity.getAutoAssignActionType());
|
||||
} else {
|
||||
targetFilterQueryManagement
|
||||
.updateAutoAssignDS(entityFactory.targetFilterQuery().updateAutoAssign(entity.getId()).ds(null));
|
||||
publishModifiedEvent(entity.getId());
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.updateAutoAssignDS(
|
||||
getEntityFactory().targetFilterQuery().updateAutoAssign(entity.getId()).ds(null));
|
||||
publishModifiedEvent(createModifiedEventPayload(targetFilterQuery));
|
||||
}
|
||||
}
|
||||
|
||||
private void showConsequencesDialog(final String confirmationCaption, final String confirmationQuestion,
|
||||
final Long targetFilterId, final Long autoAssignDsId, final ActionType autoAssignActionType,
|
||||
final ProxyTargetFilterQuery entity) {
|
||||
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n, confirmationCaption, confirmationQuestion,
|
||||
ok -> {
|
||||
final Long targetFilterId, final Long autoAssignDsId, final ActionType autoAssignActionType) {
|
||||
final ConfirmationDialog confirmDialog = new ConfirmationDialog(getI18n(), confirmationCaption,
|
||||
confirmationQuestion, ok -> {
|
||||
if (ok) {
|
||||
targetFilterQueryManagement.updateAutoAssignDS(entityFactory.targetFilterQuery()
|
||||
.updateAutoAssign(targetFilterId).ds(autoAssignDsId).actionType(autoAssignActionType));
|
||||
publishModifiedEvent(entity.getId());
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.updateAutoAssignDS(
|
||||
getEntityFactory().targetFilterQuery().updateAutoAssign(targetFilterId)
|
||||
.ds(autoAssignDsId).actionType(autoAssignActionType));
|
||||
publishModifiedEvent(createModifiedEventPayload(targetFilterQuery));
|
||||
}
|
||||
}, UIComponentIdProvider.DIST_SET_SELECT_CONS_WINDOW_ID);
|
||||
|
||||
@@ -147,17 +129,52 @@ public class AutoAssignmentWindowController
|
||||
confirmDialog.getWindow().bringToFront();
|
||||
}
|
||||
|
||||
private void publishModifiedEvent(final Long entityId) {
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_UPDATED, ProxyTargetFilterQuery.class, entityId));
|
||||
@Override
|
||||
protected TargetFilterQuery persistEntityInRepository(final ProxyTargetFilterQuery entity) {
|
||||
// this subclass cares itself for persisting the entity because of
|
||||
// special requirements (multiple confirmation dialogs).
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableName(final TargetFilterQuery entity) {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final ProxyTargetFilterQuery entity) {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getId(final TargetFilterQuery entity) {
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistSuccessMessageKey() {
|
||||
// this subclass cares itself for persisting the entity because of
|
||||
// special requirements (multiple confirmation dialogs)
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistFailureMessageKey() {
|
||||
// this subclass cares itself for persisting the entity because of
|
||||
// special requirements (multiple confirmation dialogs)
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyTargetFilterQuery.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyTargetFilterQuery entity) {
|
||||
if (entity.isAutoAssignmentEnabled()
|
||||
&& (entity.getAutoAssignActionType() == null || entity.getDistributionSetInfo() == null)) {
|
||||
uiNotification.displayValidationError(
|
||||
i18n.getMessage(UIMessageIdProvider.MESSAGE_AUTOASSIGN_CREATE_ERROR_MISSINGELEMENTS));
|
||||
displayValidationError(UIMessageIdProvider.MESSAGE_AUTOASSIGN_CREATE_ERROR_MISSINGELEMENTS);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.eclipse.hawkbit.repository.rsql.RsqlValidationOracle;
|
||||
import org.eclipse.hawkbit.ui.AbstractHawkbitUI;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventViewAware;
|
||||
@@ -65,13 +66,14 @@ public class FilterManagementView extends VerticalLayout implements View {
|
||||
final TargetManagement targetManagement, final DistributionSetManagement distributionSetManagement) {
|
||||
this.filterManagementUIState = filterManagementUIState;
|
||||
|
||||
this.targetFilterGridLayout = new TargetFilterGridLayout(i18n, eventBus, permissionChecker, notification,
|
||||
entityFactory, targetFilterQueryManagement, targetManagement, distributionSetManagement,
|
||||
filterManagementUIState);
|
||||
final CommonUiDependencies uiDependencies = new CommonUiDependencies(i18n, entityFactory, eventBus, notification,
|
||||
permissionChecker);
|
||||
|
||||
this.targetFilterDetailsLayout = new TargetFilterDetailsLayout(i18n, permissionChecker, eventBus, notification,
|
||||
uiProperties, entityFactory, rsqlValidationOracle, targetManagement, targetFilterQueryManagement,
|
||||
filterManagementUIState.getDetailsLayoutUiState());
|
||||
this.targetFilterGridLayout = new TargetFilterGridLayout(uiDependencies, targetFilterQueryManagement,
|
||||
targetManagement, distributionSetManagement, filterManagementUIState);
|
||||
|
||||
this.targetFilterDetailsLayout = new TargetFilterDetailsLayout(uiDependencies, uiProperties, rsqlValidationOracle,
|
||||
targetManagement, targetFilterQueryManagement, filterManagementUIState.getDetailsLayoutUiState());
|
||||
|
||||
final Map<EventLayout, VisibilityHandler> layoutVisibilityHandlers = new EnumMap<>(EventLayout.class);
|
||||
layoutVisibilityHandlers.put(EventLayout.TARGET_FILTER_QUERY_LIST,
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.EntityValidator;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Validator used in targetfilter window controllers to validate
|
||||
* {@link ProxyTargetFilterQuery}.
|
||||
*/
|
||||
public class ProxyTargetFilterValidator extends EntityValidator {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
*/
|
||||
public ProxyTargetFilterValidator(final CommonUiDependencies uiDependencies) {
|
||||
super(uiDependencies);
|
||||
}
|
||||
|
||||
boolean isEntityValid(final ProxyTargetFilterQuery entity, final BooleanSupplier duplicateCheck) {
|
||||
if (!StringUtils.hasText(entity.getName())) {
|
||||
displayValidationError("message.error.missing.filtername");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
if (duplicateCheck.getAsBoolean()) {
|
||||
displayValidationError("message.target.filter.duplicate", trimmedName);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,12 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.rsql.RsqlValidationOracle;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.event.CommandTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
@@ -26,9 +26,6 @@ import org.eclipse.hawkbit.ui.filtermanagement.state.TargetFilterDetailsLayoutUi
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.TargetFilterDetailsLayoutUiState.Mode;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Layout for Custom Filter view
|
||||
@@ -47,16 +44,8 @@ public class TargetFilterDetailsGridHeader extends AbstractBreadcrumbGridHeader
|
||||
/**
|
||||
* Constructor for TargetFilterDetailsGridHeader
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetFilterManagement
|
||||
* TargetFilterQueryManagement
|
||||
* @param uiProperties
|
||||
@@ -66,11 +55,10 @@ public class TargetFilterDetailsGridHeader extends AbstractBreadcrumbGridHeader
|
||||
* @param uiState
|
||||
* TargetFilterDetailsLayoutUiState
|
||||
*/
|
||||
public TargetFilterDetailsGridHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UIEventBus eventBus, final UINotification uiNotification, final EntityFactory entityFactory,
|
||||
public TargetFilterDetailsGridHeader(final CommonUiDependencies uiDependencies,
|
||||
final TargetFilterQueryManagement targetFilterManagement, final UiProperties uiProperties,
|
||||
final RsqlValidationOracle rsqlValidationOracle, final TargetFilterDetailsLayoutUiState uiState) {
|
||||
super(i18n, permChecker, eventBus);
|
||||
super(uiDependencies.getI18n(), uiDependencies.getPermChecker(), uiDependencies.getEventBus());
|
||||
|
||||
this.uiState = uiState;
|
||||
|
||||
@@ -84,10 +72,10 @@ public class TargetFilterDetailsGridHeader extends AbstractBreadcrumbGridHeader
|
||||
|
||||
this.targetFilterAddUpdateLayout = new TargetFilterAddUpdateLayout(i18n, permChecker, uiProperties, uiState,
|
||||
eventBus, rsqlValidationOracle);
|
||||
this.addTargetFilterController = new AddTargetFilterController(i18n, entityFactory, eventBus, uiNotification,
|
||||
targetFilterManagement, targetFilterAddUpdateLayout, this::closeDetails);
|
||||
this.updateTargetFilterController = new UpdateTargetFilterController(i18n, entityFactory, eventBus,
|
||||
uiNotification, targetFilterManagement, targetFilterAddUpdateLayout, this::closeDetails);
|
||||
this.addTargetFilterController = new AddTargetFilterController(uiDependencies, targetFilterManagement,
|
||||
targetFilterAddUpdateLayout, this::closeDetails);
|
||||
this.updateTargetFilterController = new UpdateTargetFilterController(uiDependencies, targetFilterManagement,
|
||||
targetFilterAddUpdateLayout, this::closeDetails);
|
||||
|
||||
buildHeader();
|
||||
}
|
||||
@@ -150,7 +138,7 @@ public class TargetFilterDetailsGridHeader extends AbstractBreadcrumbGridHeader
|
||||
}
|
||||
|
||||
private void showAddUpdateFilterLayout(final String captionMessage,
|
||||
final AbstractEntityWindowController<ProxyTargetFilterQuery, ProxyTargetFilterQuery> controller,
|
||||
final AbstractEntityWindowController<ProxyTargetFilterQuery, ProxyTargetFilterQuery, TargetFilterQuery> controller,
|
||||
final ProxyTargetFilterQuery proxyEntity) {
|
||||
headerCaptionDetails.setValue(captionMessage);
|
||||
controller.populateWithData(proxyEntity);
|
||||
@@ -187,7 +175,7 @@ public class TargetFilterDetailsGridHeader extends AbstractBreadcrumbGridHeader
|
||||
|
||||
/**
|
||||
* Check validity of target filter query.
|
||||
*
|
||||
*
|
||||
* @return {@code true}: if header form layout is active and the target
|
||||
* filter query is valid {@code false}: otherwise
|
||||
*/
|
||||
|
||||
@@ -8,12 +8,11 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.rsql.RsqlValidationOracle;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
@@ -24,9 +23,6 @@ import org.eclipse.hawkbit.ui.common.layout.AbstractGridComponentLayout;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.FilterChangedListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.ShowEntityFormLayoutListener;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.TargetFilterDetailsLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* DistributionSet table layout.
|
||||
@@ -43,19 +39,11 @@ public class TargetFilterDetailsLayout extends AbstractGridComponentLayout {
|
||||
|
||||
/**
|
||||
* TargetFilterDetailsLayout constructor
|
||||
*
|
||||
* @param i18n
|
||||
* MessageSource
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param eventBus
|
||||
* Bus to publish UI events
|
||||
* @param uiNotification
|
||||
* helper to display messages
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param uiProperties
|
||||
* properties
|
||||
* @param entityFactory
|
||||
* entity factory
|
||||
* @param rsqlValidationOracle
|
||||
* to get RSQL validation and suggestions
|
||||
* @param targetManagement
|
||||
@@ -65,24 +53,23 @@ public class TargetFilterDetailsLayout extends AbstractGridComponentLayout {
|
||||
* @param uiState
|
||||
* to persist the user interaction
|
||||
*/
|
||||
public TargetFilterDetailsLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
|
||||
final UIEventBus eventBus, final UINotification uiNotification, final UiProperties uiProperties,
|
||||
final EntityFactory entityFactory, final RsqlValidationOracle rsqlValidationOracle,
|
||||
final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterManagement,
|
||||
final TargetFilterDetailsLayoutUiState uiState) {
|
||||
public TargetFilterDetailsLayout(final CommonUiDependencies uiDependencies, final UiProperties uiProperties,
|
||||
final RsqlValidationOracle rsqlValidationOracle, final TargetManagement targetManagement,
|
||||
final TargetFilterQueryManagement targetFilterManagement, final TargetFilterDetailsLayoutUiState uiState) {
|
||||
|
||||
this.targetFilterDetailsGridHeader = new TargetFilterDetailsGridHeader(i18n, permChecker, eventBus,
|
||||
uiNotification, entityFactory, targetFilterManagement, uiProperties, rsqlValidationOracle, uiState);
|
||||
this.targetFilterTargetGrid = new TargetFilterTargetGrid(i18n, eventBus, targetManagement, uiState);
|
||||
this.targetFilterCountMessageLabel = new TargetFilterCountMessageLabel(i18n);
|
||||
this.targetFilterDetailsGridHeader = new TargetFilterDetailsGridHeader(uiDependencies, targetFilterManagement,
|
||||
uiProperties, rsqlValidationOracle, uiState);
|
||||
this.targetFilterTargetGrid = new TargetFilterTargetGrid(uiDependencies, targetManagement, uiState);
|
||||
this.targetFilterCountMessageLabel = new TargetFilterCountMessageLabel(uiDependencies.getI18n());
|
||||
|
||||
initGridDataUpdatedListener();
|
||||
|
||||
this.showFilterQueryFormListener = new ShowEntityFormLayoutListener<>(eventBus, ProxyTargetFilterQuery.class,
|
||||
this.showFilterQueryFormListener = new ShowEntityFormLayoutListener<>(uiDependencies.getEventBus(),
|
||||
ProxyTargetFilterQuery.class,
|
||||
new EventLayoutViewAware(EventLayout.TARGET_FILTER_QUERY_FORM, EventView.TARGET_FILTER),
|
||||
targetFilterDetailsGridHeader::showAddFilterLayout,
|
||||
targetFilterDetailsGridHeader::showEditFilterLayout);
|
||||
this.targetFilterListener = new FilterChangedListener<>(eventBus, ProxyTarget.class,
|
||||
this.targetFilterListener = new FilterChangedListener<>(uiDependencies.getEventBus(), ProxyTarget.class,
|
||||
new EventViewAware(EventView.TARGET_FILTER), targetFilterTargetGrid.getFilterSupport());
|
||||
|
||||
buildLayout(targetFilterDetailsGridHeader, targetFilterTargetGrid, targetFilterCountMessageLabel);
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.ActionTypeIconSupplier;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.TargetFilterQueryToProxyTargetFilterMapper;
|
||||
@@ -35,9 +35,7 @@ import org.eclipse.hawkbit.ui.filtermanagement.state.TargetFilterGridLayoutUiSta
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.data.ValueProvider;
|
||||
import com.vaadin.server.Sizeable;
|
||||
@@ -71,28 +69,21 @@ public class TargetFilterGrid extends AbstractGrid<ProxyTargetFilterQuery, Strin
|
||||
/**
|
||||
* Constructor for TargetFilterGrid
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param notification
|
||||
* UINotification
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param uiState
|
||||
* TargetFilterGridLayoutUiState
|
||||
* @param targetFilterQueryManagement
|
||||
* TargetFilterQueryManagement
|
||||
* @param permChecker
|
||||
* SpPermissionChecker
|
||||
* @param autoAssignmentWindowBuilder
|
||||
* AutoAssignmentWindowBuilder
|
||||
*/
|
||||
public TargetFilterGrid(final VaadinMessageSource i18n, final UINotification notification,
|
||||
final UIEventBus eventBus, final TargetFilterGridLayoutUiState uiState,
|
||||
final TargetFilterQueryManagement targetFilterQueryManagement, final SpPermissionChecker permChecker,
|
||||
public TargetFilterGrid(final CommonUiDependencies uiDependencies, final TargetFilterGridLayoutUiState uiState,
|
||||
final TargetFilterQueryManagement targetFilterQueryManagement,
|
||||
final AutoAssignmentWindowBuilder autoAssignmentWindowBuilder) {
|
||||
super(i18n, eventBus, permChecker);
|
||||
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
|
||||
|
||||
this.notification = notification;
|
||||
this.notification = uiDependencies.getUiNotification();
|
||||
this.uiState = uiState;
|
||||
this.targetFilterQueryManagement = targetFilterQueryManagement;
|
||||
this.autoAssignmentWindowBuilder = autoAssignmentWindowBuilder;
|
||||
|
||||
@@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.event.CommandTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
@@ -26,8 +26,6 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.TargetFilterGridLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.ui.Component;
|
||||
|
||||
@@ -44,19 +42,14 @@ public class TargetFilterGridHeader extends AbstractGridHeader {
|
||||
|
||||
/**
|
||||
* Constructor for TargetFilterHeader
|
||||
*
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param uiState
|
||||
* TargetFilterGridLayoutUiState
|
||||
* @param permissionChecker
|
||||
* SpPermissionChecker
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
*/
|
||||
public TargetFilterGridHeader(final UIEventBus eventBus, final TargetFilterGridLayoutUiState uiState,
|
||||
final SpPermissionChecker permissionChecker, final VaadinMessageSource i18n) {
|
||||
super(i18n, permissionChecker, eventBus);
|
||||
public TargetFilterGridHeader(final CommonUiDependencies uiDependencies, final TargetFilterGridLayoutUiState uiState) {
|
||||
super(uiDependencies.getI18n(), uiDependencies.getPermChecker(), uiDependencies.getEventBus());
|
||||
|
||||
this.uiState = uiState;
|
||||
|
||||
|
||||
@@ -12,10 +12,9 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventViewAware;
|
||||
@@ -25,9 +24,6 @@ import org.eclipse.hawkbit.ui.common.layout.listener.EntityModifiedListener.Enti
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.FilterChangedListener;
|
||||
import org.eclipse.hawkbit.ui.common.layout.listener.support.EntityModifiedGridRefreshAwareSupport;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* TargetFilter table layout.
|
||||
@@ -43,17 +39,9 @@ public class TargetFilterGridLayout extends AbstractGridComponentLayout {
|
||||
|
||||
/**
|
||||
* TargetFilterGridLayout constructor
|
||||
*
|
||||
* @param i18n
|
||||
* MessageSource
|
||||
* @param eventBus
|
||||
* Bus to publish UI events
|
||||
* @param permissionChecker
|
||||
* Checker for user permissions
|
||||
* @param notification
|
||||
* helper to display messages
|
||||
* @param entityFactory
|
||||
* entity factory
|
||||
*
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetFilterQueryManagement
|
||||
* management to CRUD target filters
|
||||
* @param targetManagement
|
||||
@@ -63,25 +51,25 @@ public class TargetFilterGridLayout extends AbstractGridComponentLayout {
|
||||
* @param filterManagementUIState
|
||||
* to persist the user interaction
|
||||
*/
|
||||
public TargetFilterGridLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final SpPermissionChecker permissionChecker, final UINotification notification,
|
||||
final EntityFactory entityFactory, final TargetFilterQueryManagement targetFilterQueryManagement,
|
||||
final TargetManagement targetManagement, final DistributionSetManagement distributionSetManagement,
|
||||
public TargetFilterGridLayout(final CommonUiDependencies uiDependencies,
|
||||
final TargetFilterQueryManagement targetFilterQueryManagement, final TargetManagement targetManagement,
|
||||
final DistributionSetManagement distributionSetManagement,
|
||||
final FilterManagementUIState filterManagementUIState) {
|
||||
this.targetFilterGridHeader = new TargetFilterGridHeader(eventBus,
|
||||
filterManagementUIState.getGridLayoutUiState(), permissionChecker, i18n);
|
||||
this.targetFilterGridHeader = new TargetFilterGridHeader(uiDependencies,
|
||||
filterManagementUIState.getGridLayoutUiState());
|
||||
|
||||
final AutoAssignmentWindowBuilder autoAssignmentWindowBuilder = new AutoAssignmentWindowBuilder(i18n, eventBus,
|
||||
notification, entityFactory, targetManagement, targetFilterQueryManagement, distributionSetManagement);
|
||||
final AutoAssignmentWindowBuilder autoAssignmentWindowBuilder = new AutoAssignmentWindowBuilder(uiDependencies,
|
||||
targetManagement, targetFilterQueryManagement, distributionSetManagement);
|
||||
|
||||
this.targetFilterGrid = new TargetFilterGrid(i18n, notification, eventBus,
|
||||
filterManagementUIState.getGridLayoutUiState(), targetFilterQueryManagement, permissionChecker,
|
||||
autoAssignmentWindowBuilder);
|
||||
this.targetFilterGrid = new TargetFilterGrid(uiDependencies, filterManagementUIState.getGridLayoutUiState(),
|
||||
targetFilterQueryManagement, autoAssignmentWindowBuilder);
|
||||
|
||||
this.targetQueryFilterListener = new FilterChangedListener<>(eventBus, ProxyTargetFilterQuery.class,
|
||||
new EventViewAware(EventView.TARGET_FILTER), targetFilterGrid.getFilterSupport());
|
||||
this.filterQueryModifiedListener = new EntityModifiedListener.Builder<>(eventBus, ProxyTargetFilterQuery.class)
|
||||
.entityModifiedAwareSupports(getFilterQueryModifiedAwareSupports()).build();
|
||||
this.targetQueryFilterListener = new FilterChangedListener<>(uiDependencies.getEventBus(),
|
||||
ProxyTargetFilterQuery.class, new EventViewAware(EventView.TARGET_FILTER),
|
||||
targetFilterGrid.getFilterSupport());
|
||||
this.filterQueryModifiedListener = new EntityModifiedListener.Builder<>(uiDependencies.getEventBus(),
|
||||
ProxyTargetFilterQuery.class).entityModifiedAwareSupports(getFilterQueryModifiedAwareSupports())
|
||||
.build();
|
||||
|
||||
buildLayout(targetFilterGridHeader, targetFilterGrid);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.TargetStatusIconSupplier;
|
||||
import org.eclipse.hawkbit.ui.common.data.mappers.TargetToProxyTargetMapper;
|
||||
@@ -19,8 +20,6 @@ import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
|
||||
import org.eclipse.hawkbit.ui.common.grid.support.FilterSupport;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.TargetFilterDetailsLayoutUiState;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Shows the targets as a result of the executed filter query.
|
||||
@@ -36,9 +35,9 @@ public class TargetFilterTargetGrid extends AbstractGrid<ProxyTarget, String> {
|
||||
|
||||
private final TargetFilterDetailsLayoutUiState uiState;
|
||||
|
||||
TargetFilterTargetGrid(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
final TargetManagement targetManagement, final TargetFilterDetailsLayoutUiState uiState) {
|
||||
super(i18n, eventBus);
|
||||
TargetFilterTargetGrid(final CommonUiDependencies uiDependencies, final TargetManagement targetManagement,
|
||||
final TargetFilterDetailsLayoutUiState uiState) {
|
||||
super(uiDependencies.getI18n(), uiDependencies.getEventBus());
|
||||
|
||||
this.uiState = uiState;
|
||||
|
||||
|
||||
@@ -8,82 +8,54 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetFilterQueryUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractEntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractUpdateEntityWindowController;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.EntityWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
|
||||
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventTopics;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Controller for update target filter
|
||||
*/
|
||||
public class UpdateTargetFilterController
|
||||
extends AbstractEntityWindowController<ProxyTargetFilterQuery, ProxyTargetFilterQuery> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UpdateTargetFilterController.class);
|
||||
|
||||
private final VaadinMessageSource i18n;
|
||||
private final EntityFactory entityFactory;
|
||||
private final UIEventBus eventBus;
|
||||
private final UINotification uiNotification;
|
||||
public class UpdateTargetFilterController extends
|
||||
AbstractUpdateEntityWindowController<ProxyTargetFilterQuery, ProxyTargetFilterQuery, TargetFilterQuery> {
|
||||
|
||||
private final TargetFilterQueryManagement targetFilterManagement;
|
||||
|
||||
private final TargetFilterAddUpdateLayout layout;
|
||||
|
||||
private final Runnable closeFormCallback;
|
||||
private final ProxyTargetFilterValidator validator;
|
||||
|
||||
private String nameBeforeEdit;
|
||||
|
||||
/**
|
||||
* Constructor for UpdateTargetFilterController
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param entityFactory
|
||||
* EntityFactory
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiNotification
|
||||
* UINotification
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param targetFilterManagement
|
||||
* TargetFilterQueryManagement
|
||||
* TargetFilterQueryManagement
|
||||
* @param layout
|
||||
* TargetFilterAddUpdateLayout
|
||||
* TargetFilterAddUpdateLayout
|
||||
* @param closeFormCallback
|
||||
* Runnable
|
||||
* Runnable
|
||||
*/
|
||||
public UpdateTargetFilterController(final VaadinMessageSource i18n, final EntityFactory entityFactory,
|
||||
final UIEventBus eventBus, final UINotification uiNotification,
|
||||
public UpdateTargetFilterController(final CommonUiDependencies uiDependencies,
|
||||
final TargetFilterQueryManagement targetFilterManagement, final TargetFilterAddUpdateLayout layout,
|
||||
final Runnable closeFormCallback) {
|
||||
this.i18n = i18n;
|
||||
this.entityFactory = entityFactory;
|
||||
this.eventBus = eventBus;
|
||||
this.uiNotification = uiNotification;
|
||||
super(uiDependencies);
|
||||
|
||||
this.targetFilterManagement = targetFilterManagement;
|
||||
|
||||
this.layout = layout;
|
||||
|
||||
this.closeFormCallback = closeFormCallback;
|
||||
this.validator = new ProxyTargetFilterValidator(uiDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractEntityWindowLayout<ProxyTargetFilterQuery> getLayout() {
|
||||
public EntityWindowLayout<ProxyTargetFilterQuery> getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -101,39 +73,45 @@ public class UpdateTargetFilterController
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void persistEntity(final ProxyTargetFilterQuery entity) {
|
||||
final TargetFilterQueryUpdate targetFilterUpdate = entityFactory.targetFilterQuery().update(entity.getId())
|
||||
protected TargetFilterQuery persistEntityInRepository(final ProxyTargetFilterQuery entity) {
|
||||
final TargetFilterQueryUpdate targetFilterUpdate = getEntityFactory().targetFilterQuery().update(entity.getId())
|
||||
.name(entity.getName()).query(entity.getQuery());
|
||||
return targetFilterManagement.update(targetFilterUpdate);
|
||||
}
|
||||
|
||||
try {
|
||||
final TargetFilterQuery updatedTargetFilter = targetFilterManagement.update(targetFilterUpdate);
|
||||
@Override
|
||||
protected void postPersist() {
|
||||
closeFormCallback.run();
|
||||
}
|
||||
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.update.success", updatedTargetFilter.getName()));
|
||||
eventBus.publish(EventTopics.ENTITY_MODIFIED, this, new EntityModifiedEventPayload(
|
||||
EntityModifiedEventType.ENTITY_UPDATED, ProxyTargetFilterQuery.class, updatedTargetFilter.getId()));
|
||||
} catch (final EntityNotFoundException | EntityReadOnlyException e) {
|
||||
LOG.trace("Update of target filter failed in UI: {}", e.getMessage());
|
||||
final String entityType = i18n.getMessage("caption.target.filter");
|
||||
uiNotification
|
||||
.displayWarning(i18n.getMessage("message.deleted.or.notAllowed", entityType, entity.getName()));
|
||||
} finally {
|
||||
closeFormCallback.run();
|
||||
}
|
||||
@Override
|
||||
protected String getDisplayableName(final TargetFilterQuery entity) {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayableNameForFailedMessage(final ProxyTargetFilterQuery entity) {
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getId(final TargetFilterQuery entity) {
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ProxyIdentifiableEntity> getEntityClass() {
|
||||
return ProxyTargetFilterQuery.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEntityValid(final ProxyTargetFilterQuery entity) {
|
||||
if (!StringUtils.hasText(entity.getName())) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.error.missing.filtername"));
|
||||
return false;
|
||||
}
|
||||
|
||||
final String trimmedName = StringUtils.trimWhitespace(entity.getName());
|
||||
if (!nameBeforeEdit.equals(trimmedName) && targetFilterManagement.getByName(trimmedName).isPresent()) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.target.filter.duplicate", trimmedName));
|
||||
return false;
|
||||
}
|
||||
return validator.isEntityValid(entity,
|
||||
() -> hasNamedChanged(trimmedName) && targetFilterManagement.getByName(trimmedName).isPresent());
|
||||
}
|
||||
|
||||
return true;
|
||||
private boolean hasNamedChanged(final String trimmedName) {
|
||||
return !nameBeforeEdit.equals(trimmedName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.ui.AbstractHawkbitUI;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventView;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventViewAware;
|
||||
@@ -99,21 +100,23 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
|
||||
this.permChecker = permChecker;
|
||||
this.managementUIState = managementUIState;
|
||||
|
||||
final CommonUiDependencies uiDependencies = new CommonUiDependencies(i18n, entityFactory, eventBus, uiNotification,
|
||||
permChecker);
|
||||
|
||||
if (permChecker.hasTargetReadPermission()) {
|
||||
this.targetTagFilterLayout = new TargetTagFilterLayout(i18n, managementUIState, permChecker, eventBus,
|
||||
uiNotification, entityFactory, targetFilterQueryManagement, targetTagManagement, targetManagement,
|
||||
this.targetTagFilterLayout = new TargetTagFilterLayout(uiDependencies, managementUIState,
|
||||
targetFilterQueryManagement, targetTagManagement, targetManagement,
|
||||
managementUIState.getTargetTagFilterLayoutUiState());
|
||||
|
||||
this.targetGridLayout = new TargetGridLayout(eventBus, targetManagement, entityFactory, i18n,
|
||||
uiNotification, deploymentManagement, uiProperties, permChecker, targetTagManagement,
|
||||
distributionSetManagement, uiExecutor, configManagement, systemSecurityContext,
|
||||
this.targetGridLayout = new TargetGridLayout(uiDependencies, targetManagement, deploymentManagement, uiProperties,
|
||||
targetTagManagement, distributionSetManagement, uiExecutor, configManagement, systemSecurityContext,
|
||||
managementUIState.getTargetTagFilterLayoutUiState(), managementUIState.getTargetGridLayoutUiState(),
|
||||
managementUIState.getTargetBulkUploadUiState(),
|
||||
managementUIState.getDistributionGridLayoutUiState());
|
||||
this.targetCountLayout = targetGridLayout.getCountMessageLabel().createFooterMessageComponent();
|
||||
|
||||
this.actionHistoryLayout = new ActionHistoryLayout(i18n, deploymentManagement, eventBus, uiNotification,
|
||||
permChecker, managementUIState.getActionHistoryGridLayoutUiState());
|
||||
this.actionHistoryLayout = new ActionHistoryLayout(uiDependencies, deploymentManagement,
|
||||
managementUIState.getActionHistoryGridLayoutUiState());
|
||||
} else {
|
||||
this.targetTagFilterLayout = null;
|
||||
this.targetGridLayout = null;
|
||||
@@ -122,14 +125,12 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
|
||||
}
|
||||
|
||||
if (permChecker.hasReadRepositoryPermission()) {
|
||||
this.distributionTagLayout = new DistributionTagLayout(eventBus, i18n, permChecker,
|
||||
distributionSetTagManagement, entityFactory, uiNotification, distributionSetManagement,
|
||||
managementUIState.getDistributionTagLayoutUiState());
|
||||
this.distributionGridLayout = new DistributionGridLayout(i18n, eventBus, permChecker, entityFactory,
|
||||
uiNotification, targetManagement, distributionSetManagement, smManagement,
|
||||
distributionSetTypeManagement, distributionSetTagManagement, systemManagement, deploymentManagement,
|
||||
configManagement, systemSecurityContext, uiProperties,
|
||||
managementUIState.getDistributionGridLayoutUiState(),
|
||||
this.distributionTagLayout = new DistributionTagLayout(uiDependencies, distributionSetTagManagement,
|
||||
distributionSetManagement, managementUIState.getDistributionTagLayoutUiState());
|
||||
this.distributionGridLayout = new DistributionGridLayout(uiDependencies, targetManagement,
|
||||
distributionSetManagement, smManagement, distributionSetTypeManagement,
|
||||
distributionSetTagManagement, systemManagement, deploymentManagement, configManagement,
|
||||
systemSecurityContext, uiProperties, managementUIState.getDistributionGridLayoutUiState(),
|
||||
managementUIState.getDistributionTagLayoutUiState(),
|
||||
managementUIState.getTargetGridLayoutUiState());
|
||||
} else {
|
||||
@@ -379,12 +380,12 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
|
||||
|
||||
private void showDsTagLayout() {
|
||||
distributionTagLayout.setVisible(true);
|
||||
distributionGridLayout.hideDsTagHeaderIcon();
|
||||
distributionGridLayout.hideDsFilterHeaderIcon();
|
||||
}
|
||||
|
||||
private void hideDsTagLayout() {
|
||||
distributionTagLayout.setVisible(false);
|
||||
distributionGridLayout.showDsTagHeaderIcon();
|
||||
distributionGridLayout.showDsFilterHeaderIcon();
|
||||
}
|
||||
|
||||
private void maximizeActionHistoryGridLayout() {
|
||||
|
||||
@@ -15,8 +15,8 @@ import java.util.Optional;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.ActionStatusIconSupplier;
|
||||
import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.ActionTypeIconSupplier;
|
||||
@@ -42,10 +42,8 @@ import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.data.ValueProvider;
|
||||
import com.vaadin.icons.VaadinIcons;
|
||||
@@ -86,12 +84,11 @@ public class ActionHistoryGrid extends AbstractGrid<ProxyAction, String> {
|
||||
|
||||
private final transient MasterEntitySupport<ProxyTarget> masterEntitySupport;
|
||||
|
||||
ActionHistoryGrid(final VaadinMessageSource i18n, final DeploymentManagement deploymentManagement,
|
||||
final UIEventBus eventBus, final UINotification notification, final SpPermissionChecker permissionChecker,
|
||||
ActionHistoryGrid(final CommonUiDependencies uiDependencies, final DeploymentManagement deploymentManagement,
|
||||
final ActionHistoryGridLayoutUiState actionHistoryGridLayoutUiState) {
|
||||
super(i18n, eventBus, permissionChecker);
|
||||
super(uiDependencies.getI18n(), uiDependencies.getEventBus(), uiDependencies.getPermChecker());
|
||||
|
||||
this.notification = notification;
|
||||
this.notification = uiDependencies.getUiNotification();
|
||||
this.deploymentManagement = deploymentManagement;
|
||||
this.actionToProxyActionMapper = new ActionToProxyActionMapper();
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.management.actionhistory;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
|
||||
import org.eclipse.hawkbit.ui.common.event.CommandTopics;
|
||||
import org.eclipse.hawkbit.ui.common.event.EventLayout;
|
||||
@@ -19,8 +20,6 @@ import org.eclipse.hawkbit.ui.common.grid.header.support.ResizeHeaderSupport;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
/**
|
||||
* Header for ActionHistory with maximize-support.
|
||||
@@ -35,16 +34,14 @@ public class ActionHistoryGridHeader extends AbstractMasterAwareGridHeader<Proxy
|
||||
/**
|
||||
* Constructor for ActionHistoryGridHeader
|
||||
*
|
||||
* @param i18n
|
||||
* VaadinMessageSource
|
||||
* @param eventBus
|
||||
* UIEventBus
|
||||
* @param uiDependencies
|
||||
* {@link CommonUiDependencies}
|
||||
* @param actionHistoryGridLayoutUiState
|
||||
* ActionHistoryGridLayoutUiState
|
||||
* ActionHistoryGridLayoutUiState
|
||||
*/
|
||||
public ActionHistoryGridHeader(final VaadinMessageSource i18n, final UIEventBus eventBus,
|
||||
public ActionHistoryGridHeader(final CommonUiDependencies uiDependencies,
|
||||
final ActionHistoryGridLayoutUiState actionHistoryGridLayoutUiState) {
|
||||
super(i18n, null, eventBus);
|
||||
super(uiDependencies.getI18n(), uiDependencies.getPermChecker(), uiDependencies.getEventBus());
|
||||
|
||||
this.actionHistoryGridLayoutUiState = actionHistoryGridLayoutUiState;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user