Merge pull request #367 from bsinno/fix_ui_performance

Fix UI login and view change performance
This commit is contained in:
Kai Zimmermann
2016-12-01 17:15:57 +01:00
committed by GitHub
185 changed files with 2818 additions and 3476 deletions

View File

@@ -10,10 +10,13 @@ package org.eclipse.hawkbit.app;
import org.eclipse.hawkbit.ui.login.HawkbitLoginUI; import org.eclipse.hawkbit.ui.login.HawkbitLoginUI;
import org.eclipse.hawkbit.ui.themes.HawkbitTheme; import org.eclipse.hawkbit.ui.themes.HawkbitTheme;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import com.vaadin.annotations.Theme; import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title; import com.vaadin.annotations.Title;
import com.vaadin.spring.annotation.SpringUI; import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.spring.navigator.SpringViewProvider;
/** /**
* Example hawkBit login UI implementation. * Example hawkBit login UI implementation.
@@ -31,4 +34,9 @@ public class MyLoginUI extends HawkbitLoginUI {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Autowired
protected MyLoginUI(final SpringViewProvider viewProvider, final ApplicationContext context) {
super(viewProvider, context);
}
} }

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.app;
import org.eclipse.hawkbit.ui.HawkbitUI; import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.push.EventPushStrategy; import org.eclipse.hawkbit.ui.push.EventPushStrategy;
import org.vaadin.spring.events.EventBus.SessionEventBus;
import com.vaadin.annotations.Push; import com.vaadin.annotations.Push;
import com.vaadin.annotations.Theme; import com.vaadin.annotations.Theme;
@@ -43,7 +42,7 @@ public class MyUI extends HawkbitUI {
* @param eventBus * @param eventBus
* the event bus * the event bus
*/ */
public MyUI(final EventPushStrategy pushStrategy, final SessionEventBus eventBus) { public MyUI(final EventPushStrategy pushStrategy) {
super(pushStrategy, eventBus); super(pushStrategy);
} }
} }

View File

@@ -10,8 +10,11 @@ package org.eclipse.hawkbit.app;
import org.eclipse.hawkbit.ui.login.HawkbitLoginUI; import org.eclipse.hawkbit.ui.login.HawkbitLoginUI;
import org.eclipse.hawkbit.ui.themes.HawkbitTheme; import org.eclipse.hawkbit.ui.themes.HawkbitTheme;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import com.vaadin.spring.annotation.SpringUI; import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.spring.navigator.SpringViewProvider;
/** /**
* Example hawkBit login UI implementation. * Example hawkBit login UI implementation.
@@ -27,6 +30,11 @@ import com.vaadin.spring.annotation.SpringUI;
@SuppressWarnings({ "squid:MaximumInheritanceDepth" }) @SuppressWarnings({ "squid:MaximumInheritanceDepth" })
public class MyLoginUI extends HawkbitLoginUI { public class MyLoginUI extends HawkbitLoginUI {
@Autowired
protected MyLoginUI(final SpringViewProvider viewProvider, final ApplicationContext context) {
super(viewProvider, context);
}
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.app;
import org.eclipse.hawkbit.ui.HawkbitUI; import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.push.EventPushStrategy; import org.eclipse.hawkbit.ui.push.EventPushStrategy;
import org.vaadin.spring.events.EventBus.SessionEventBus;
import com.vaadin.annotations.Push; import com.vaadin.annotations.Push;
import com.vaadin.shared.communication.PushMode; import com.vaadin.shared.communication.PushMode;
@@ -41,8 +40,8 @@ public class MyUI extends HawkbitUI {
* @param eventBus * @param eventBus
* the event bus * the event bus
*/ */
public MyUI(final EventPushStrategy pushStrategy, final SessionEventBus eventBus) { public MyUI(final EventPushStrategy pushStrategy) {
super(pushStrategy, eventBus); super(pushStrategy);
} }
} }

View File

@@ -69,9 +69,6 @@ public class ConfigurableScenario {
private final MgmtSoftwareModuleClientResource uploadSoftwareModule; private final MgmtSoftwareModuleClientResource uploadSoftwareModule;
// Exception - squid:S00107 - this is a simulator that leverages multiple
// resouces/feign beans.
@SuppressWarnings("squid:S00107")
public ConfigurableScenario(final MgmtDistributionSetClientResource distributionSetResource, public ConfigurableScenario(final MgmtDistributionSetClientResource distributionSetResource,
final MgmtSoftwareModuleClientResource softwareModuleResource, final MgmtSoftwareModuleClientResource softwareModuleResource,
final MgmtSoftwareModuleClientResource uploadSoftwareModule, final MgmtTargetClientResource targetResource, final MgmtSoftwareModuleClientResource uploadSoftwareModule, final MgmtTargetClientResource targetResource,

View File

@@ -8,6 +8,8 @@
*/ */
package org.eclipse.hawkbit.autoconfigure.ui; package org.eclipse.hawkbit.autoconfigure.ui;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.hawkbit.DistributedResourceBundleMessageSource; import org.eclipse.hawkbit.DistributedResourceBundleMessageSource;
import org.eclipse.hawkbit.ui.push.DelayedEventBusPushStrategy; import org.eclipse.hawkbit.ui.push.DelayedEventBusPushStrategy;
import org.eclipse.hawkbit.ui.push.EventPushStrategy; import org.eclipse.hawkbit.ui.push.EventPushStrategy;
@@ -18,6 +20,7 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.vaadin.spring.annotation.EnableVaadinExtensions; import org.vaadin.spring.annotation.EnableVaadinExtensions;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.annotation.EnableEventBus; import org.vaadin.spring.events.annotation.EnableEventBus;
import org.vaadin.spring.security.annotation.EnableVaadinSecurity; import org.vaadin.spring.security.annotation.EnableVaadinSecurity;
@@ -65,8 +68,11 @@ public class UIAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
@UIScope @UIScope
public EventPushStrategy eventPushStrategy(final ConfigurableApplicationContext applicationContext) { public EventPushStrategy eventPushStrategy(final ConfigurableApplicationContext applicationContext,
final DelayedEventBusPushStrategy delayedEventBusPushStrategy = new DelayedEventBusPushStrategy(); final ScheduledExecutorService executorService, final UIEventBus eventBus,
final UIEventProvider eventProvider) {
final DelayedEventBusPushStrategy delayedEventBusPushStrategy = new DelayedEventBusPushStrategy(executorService,
eventBus, eventProvider);
applicationContext.addApplicationListener(delayedEventBusPushStrategy); applicationContext.addApplicationListener(delayedEventBusPushStrategy);
return delayedEventBusPushStrategy; return delayedEventBusPushStrategy;
} }

View File

@@ -8,6 +8,8 @@
*/ */
package org.eclipse.hawkbit; package org.eclipse.hawkbit;
import java.io.Serializable;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.EnvironmentAware; import org.springframework.context.EnvironmentAware;
@@ -25,7 +27,8 @@ import org.springframework.stereotype.Component;
*/ */
@Component @Component
@ConfigurationProperties(prefix = "hawkbit.controller") @ConfigurationProperties(prefix = "hawkbit.controller")
public class ControllerPollProperties { public class ControllerPollProperties implements Serializable {
private static final long serialVersionUID = 1L;
/** /**
* Maximum polling time that can be configured by a tenant in HH:MM:SS * Maximum polling time that can be configured by a tenant in HH:MM:SS

View File

@@ -63,7 +63,8 @@ public interface TargetManagement {
* *
* @return number of found {@link Target}s. * @return number of found {@link Target}s.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countTargetByAssignedDistributionSet(@NotNull Long distId); Long countTargetByAssignedDistributionSet(@NotNull Long distId);
/** /**
@@ -104,7 +105,8 @@ public interface TargetManagement {
* to search for * to search for
* @return number of found {@link Target}s. * @return number of found {@link Target}s.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countTargetByInstalledDistributionSet(@NotNull Long distId); Long countTargetByInstalledDistributionSet(@NotNull Long distId);
/** /**

View File

@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.repository.model;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
/** /**
* A {@link DistributionSet} defines a meta package that combines a set of * A {@link DistributionSet} defines a meta package that combines a set of
* {@link SoftwareModule}s which have to be or are provisioned to a * {@link SoftwareModule}s which have to be or are provisioned to a
@@ -36,12 +34,6 @@ public interface DistributionSet extends NamedVersionedEntity {
*/ */
boolean isDeleted(); boolean isDeleted();
/**
* @return immutable {@link List} of {@link DistributionSetMetadata}
* elements. See {@link DistributionSetManagement} to alter.
*/
List<DistributionSetMetadata> getMetadata();
/** /**
* @return <code>true</code> if {@link DistributionSet} contains a mandatory * @return <code>true</code> if {@link DistributionSet} contains a mandatory
* migration step, i.e. unfinished {@link Action}s will kept active * migration step, i.e. unfinished {@link Action}s will kept active
@@ -49,21 +41,11 @@ public interface DistributionSet extends NamedVersionedEntity {
*/ */
boolean isRequiredMigrationStep(); boolean isRequiredMigrationStep();
/**
* @return the assignedTargets
*/
List<Target> getAssignedTargets();
/** /**
* @return the auto assign target filters * @return the auto assign target filters
*/ */
List<TargetFilterQuery> getAutoAssignFilters(); List<TargetFilterQuery> getAutoAssignFilters();
/**
* @return the installedTargets
*/
List<TargetInfo> getInstalledTargets();
/** /**
* *
* @return unmodifiableSet of {@link SoftwareModule}. * @return unmodifiableSet of {@link SoftwareModule}.

View File

@@ -231,7 +231,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
} }
private JpaDistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) { private JpaDistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
final JpaDistributionSet set = (JpaDistributionSet) findDistributionSetByIdWithDetails(setId); final JpaDistributionSet set = (JpaDistributionSet) findDistributionSetById(setId);
if (set == null) { if (set == null) {
throw new EntityNotFoundException("Distribution set cannot be updated as it does not exixt" + setId); throw new EntityNotFoundException("Distribution set cannot be updated as it does not exixt" + setId);

View File

@@ -34,7 +34,7 @@ public interface TargetTagRepository
*/ */
@Modifying @Modifying
@Transactional(isolation = Isolation.READ_UNCOMMITTED) @Transactional(isolation = Isolation.READ_UNCOMMITTED)
Long deleteByName(final String tagName); Long deleteByName(String tagName);
/** /**
* find {@link TargetTag} by its name. * find {@link TargetTag} by its name.
@@ -43,7 +43,7 @@ public interface TargetTagRepository
* to filter on * to filter on
* @return the {@link TargetTag} if found, otherwise null * @return the {@link TargetTag} if found, otherwise null
*/ */
JpaTargetTag findByNameEquals(final String tagName); JpaTargetTag findByNameEquals(String tagName);
/** /**
* Returns all instances of the type. * Returns all instances of the type.

View File

@@ -209,7 +209,6 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
return deleted; return deleted;
} }
@Override
public List<DistributionSetMetadata> getMetadata() { public List<DistributionSetMetadata> getMetadata() {
if (metadata == null) { if (metadata == null) {
return Collections.emptyList(); return Collections.emptyList();
@@ -241,29 +240,11 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
return this; return this;
} }
@Override
public List<Target> getAssignedTargets() {
if (assignedToTargets == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(assignedToTargets);
}
@Override @Override
public List<TargetFilterQuery> getAutoAssignFilters() { public List<TargetFilterQuery> getAutoAssignFilters() {
return autoAssignFilters; return autoAssignFilters;
} }
@Override
public List<TargetInfo> getInstalledTargets() {
if (installedAtTargets == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(installedAtTargets);
}
@Override @Override
public String toString() { public String toString() {
return "DistributionSet [getName()=" + getName() + ", getOptLockRevision()=" + getOptLockRevision() return "DistributionSet [getName()=" + getName() + ", getOptLockRevision()=" + getOptLockRevision()

View File

@@ -176,14 +176,6 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
this.type = type; this.type = type;
} }
public List<SoftwareModuleMetadata> getMetadata() {
if (metadata == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(metadata);
}
@Override @Override
public String toString() { public String toString() {
return "SoftwareModule [deleted=" + deleted + ", name=" + getName() + ", version=" + getVersion() return "SoftwareModule [deleted=" + deleted + ", name=" + getName() + ", version=" + getVersion()

View File

@@ -83,7 +83,6 @@ public final class DistributionSetSpecification {
targetRoot.fetch(JpaDistributionSet_.modules, JoinType.LEFT); targetRoot.fetch(JpaDistributionSet_.modules, JoinType.LEFT);
targetRoot.fetch(JpaDistributionSet_.tags, JoinType.LEFT); targetRoot.fetch(JpaDistributionSet_.tags, JoinType.LEFT);
targetRoot.fetch(JpaDistributionSet_.type, JoinType.LEFT); targetRoot.fetch(JpaDistributionSet_.type, JoinType.LEFT);
targetRoot.fetch(JpaDistributionSet_.metadata, JoinType.LEFT);
query.distinct(true); query.distinct(true);
return predicate; return predicate;
@@ -110,8 +109,8 @@ public final class DistributionSetSpecification {
} }
/** /**
* {@link Specification} for retrieving {@link DistributionSet}s by * {@link Specification} for retrieving {@link DistributionSet}s by "like
* "like name or like description or like version". * name or like description or like version".
* *
* @param subString * @param subString
* to be filtered on * to be filtered on
@@ -125,8 +124,8 @@ public final class DistributionSetSpecification {
} }
/** /**
* {@link Specification} for retrieving {@link DistributionSet}s by * {@link Specification} for retrieving {@link DistributionSet}s by "has at
* "has at least one of the given tag names". * least one of the given tag names".
* *
* @param tagNames * @param tagNames
* to be filtered on * to be filtered on

View File

@@ -14,23 +14,22 @@ import org.eclipse.hawkbit.im.authentication.PermissionService;
import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
/** /**
* Bean which contains all SP permissions. * Bean which contains all SP permissions.
* *
*
*
*
*/ */
@Validated
@Service @Service
public class SpPermissionChecker implements Serializable { public class SpPermissionChecker implements Serializable {
private static final long serialVersionUID = 2757865286212875704L; private static final long serialVersionUID = 2757865286212875704L;
@Autowired
private transient PermissionService permissionService; private transient PermissionService permissionService;
@Autowired
SpPermissionChecker(final PermissionService permissionService) {
this.permissionService = permissionService;
}
/** /**
* Gets the SP monitor View Permission. * Gets the SP monitor View Permission.
* *

View File

@@ -32,23 +32,22 @@ import com.vaadin.ui.VerticalLayout;
* *
* @see Navigator#setErrorView(Class) * @see Navigator#setErrorView(Class)
*/ */
@SuppressWarnings("serial")
@SpringComponent @SpringComponent
@UIScope @UIScope
class ErrorView extends VerticalLayout implements View { class ErrorView extends VerticalLayout implements View {
private static final long serialVersionUID = 1L;
private final Label message; private final Label message;
@Autowired private final I18N i18n;
private I18N i18n;
private final DashboardMenu dashboardMenu;
@Autowired @Autowired
private DashboardMenu dashboardMenu; ErrorView(final I18N i18n, final DashboardMenu dashboardMenu) {
this.i18n = i18n;
/** this.dashboardMenu = dashboardMenu;
* Constructor.
*/
public ErrorView() {
setMargin(true); setMargin(true);
message = new Label(); message = new Label();
addComponent(message); addComponent(message);

View File

@@ -61,7 +61,8 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
private transient EventPushStrategy pushStrategy; private transient EventPushStrategy pushStrategy;
protected transient EventBus.SessionEventBus eventBus; @Autowired
protected transient EventBus.UIEventBus eventBus;
@Autowired @Autowired
private SpringViewProvider viewProvider; private SpringViewProvider viewProvider;
@@ -80,23 +81,13 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
@Autowired @Autowired
private ErrorView errorview; private ErrorView errorview;
/**
* Default constructor.
*/
@Autowired
public HawkbitUI(final EventBus.SessionEventBus eventBus) {
this.eventBus = eventBus;
}
/** /**
* Constructor taking the push strategy. * Constructor taking the push strategy.
* *
* @param pushStrategy * @param pushStrategy
* the strategy to push events from the backend to the UI * the strategy to push events from the backend to the UI
*/ */
@Autowired public HawkbitUI(final EventPushStrategy pushStrategy) {
public HawkbitUI(final EventPushStrategy pushStrategy, final EventBus.SessionEventBus eventBus) {
this(eventBus);
this.pushStrategy = pushStrategy; this.pushStrategy = pushStrategy;
} }

View File

@@ -8,6 +8,8 @@
*/ */
package org.eclipse.hawkbit.ui; package org.eclipse.hawkbit.ui;
import java.io.Serializable;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -17,13 +19,15 @@ import org.springframework.stereotype.Component;
*/ */
@Component @Component
@ConfigurationProperties("hawkbit.server.ui") @ConfigurationProperties("hawkbit.server.ui")
public class UiProperties { public class UiProperties implements Serializable {
private static final long serialVersionUID = 1L;
/** /**
* Demo account login information. * Demo account login information.
* *
*/ */
public static class Demo { public static class Demo implements Serializable {
private static final long serialVersionUID = 1L;
/** /**
* Demo tenant. * Demo tenant.
@@ -72,12 +76,15 @@ public class UiProperties {
* documentation etc.). * documentation etc.).
* *
*/ */
public static class Links { public static class Links implements Serializable {
private static final long serialVersionUID = 1L;
/** /**
* Configuration of UI documentation links. * Configuration of UI documentation links.
* *
*/ */
public static class Documentation { public static class Documentation implements Serializable {
private static final long serialVersionUID = 1L;
/** /**
* Link to root of documentation and user guides. * Link to root of documentation and user guides.
*/ */
@@ -235,13 +242,15 @@ public class UiProperties {
* Configuration of login view. * Configuration of login view.
* *
*/ */
public static class Login { public static class Login implements Serializable {
private static final long serialVersionUID = 1L;
/** /**
* Cookie configuration for login credential cookie. * Cookie configuration for login credential cookie.
* *
*/ */
public static class Cookie { public static class Cookie implements Serializable {
private static final long serialVersionUID = 1L;
/** /**
* Secure cookie enabled. * Secure cookie enabled.
*/ */

View File

@@ -8,13 +8,19 @@
*/ */
package org.eclipse.hawkbit.ui.artifacts; package org.eclipse.hawkbit.ui.artifacts;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.HawkbitUI; import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout; import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout;
import org.eclipse.hawkbit.ui.artifacts.event.ArtifactDetailsEvent; import org.eclipse.hawkbit.ui.artifacts.event.ArtifactDetailsEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.footer.SMDeleteActionsLayout; import org.eclipse.hawkbit.ui.artifacts.footer.SMDeleteActionsLayout;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleTableLayout; import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleTableLayout;
import org.eclipse.hawkbit.ui.artifacts.smtype.SMTypeFilterLayout; import org.eclipse.hawkbit.ui.artifacts.smtype.SMTypeFilterLayout;
@@ -25,8 +31,10 @@ import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.util.SPInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -37,7 +45,7 @@ import com.vaadin.server.Page;
import com.vaadin.server.Page.BrowserWindowResizeEvent; import com.vaadin.server.Page.BrowserWindowResizeEvent;
import com.vaadin.server.Page.BrowserWindowResizeListener; import com.vaadin.server.Page.BrowserWindowResizeListener;
import com.vaadin.spring.annotation.SpringView; import com.vaadin.spring.annotation.SpringView;
import com.vaadin.spring.annotation.ViewScope; import com.vaadin.spring.annotation.UIScope;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.DragAndDropWrapper; import com.vaadin.ui.DragAndDropWrapper;
import com.vaadin.ui.GridLayout; import com.vaadin.ui.GridLayout;
@@ -47,45 +55,33 @@ import com.vaadin.ui.VerticalLayout;
/** /**
* Display artifacts upload view. * Display artifacts upload view.
*
*
*/ */
@UIScope
@SpringView(name = UploadArtifactView.VIEW_NAME, ui = HawkbitUI.class) @SpringView(name = UploadArtifactView.VIEW_NAME, ui = HawkbitUI.class)
@ViewScope
public class UploadArtifactView extends VerticalLayout implements View, BrowserWindowResizeListener { public class UploadArtifactView extends VerticalLayout implements View, BrowserWindowResizeListener {
public static final String VIEW_NAME = "spUpload"; public static final String VIEW_NAME = "spUpload";
private static final long serialVersionUID = 8754632011301553682L; private static final long serialVersionUID = 8754632011301553682L;
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final SpPermissionChecker permChecker;
private SpPermissionChecker permChecker;
@Autowired private final I18N i18n;
private I18N i18n;
@Autowired private final UINotification uiNotification;
private transient UINotification uiNotification;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState;
@Autowired private final SMTypeFilterLayout filterByTypeLayout;
private SMTypeFilterLayout filterByTypeLayout;
@Autowired private final SoftwareModuleTableLayout smTableLayout;
private SoftwareModuleTableLayout smTableLayout;
@Autowired private final ArtifactDetailsLayout artifactDetailsLayout;
private ArtifactDetailsLayout artifactDetailsLayout;
@Autowired private final UploadLayout uploadLayout;
private UploadLayout uploadLayout;
@Autowired private final SMDeleteActionsLayout deleteActionsLayout;
private SMDeleteActionsLayout deleteActionsLayout;
private VerticalLayout detailAndUploadLayout; private VerticalLayout detailAndUploadLayout;
@@ -94,8 +90,31 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
private GridLayout mainLayout; private GridLayout mainLayout;
private DragAndDropWrapper dadw; private DragAndDropWrapper dadw;
@Override @Autowired
public void enter(final ViewChangeEvent event) { UploadArtifactView(final UIEventBus eventBus, final SpPermissionChecker permChecker, final I18N i18n,
final UINotification uiNotification, final ArtifactUploadState artifactUploadState,
final TagManagement tagManagement, final EntityFactory entityFactory,
final SoftwareManagement softwareManagement, final UploadViewAcceptCriteria uploadViewAcceptCriteria,
final SPInfo spInfo, final ArtifactManagement artifactManagement) {
this.eventBus = eventBus;
this.permChecker = permChecker;
this.i18n = i18n;
this.uiNotification = uiNotification;
this.artifactUploadState = artifactUploadState;
this.filterByTypeLayout = new SMTypeFilterLayout(artifactUploadState, i18n, permChecker, eventBus,
tagManagement, entityFactory, uiNotification, softwareManagement, uploadViewAcceptCriteria);
this.smTableLayout = new SoftwareModuleTableLayout(i18n, permChecker, artifactUploadState, uiNotification,
eventBus, softwareManagement, entityFactory, uploadViewAcceptCriteria);
this.artifactDetailsLayout = new ArtifactDetailsLayout(i18n, eventBus, artifactUploadState, uiNotification,
artifactManagement);
this.uploadLayout = new UploadLayout(i18n, uiNotification, eventBus, artifactUploadState, spInfo,
artifactManagement);
this.deleteActionsLayout = new SMDeleteActionsLayout(i18n, permChecker, eventBus, uiNotification,
artifactUploadState, softwareManagement, uploadViewAcceptCriteria);
}
@PostConstruct
void init() {
buildLayout(); buildLayout();
restoreState(); restoreState();
checkNoDataAvaialble(); checkNoDataAvaialble();
@@ -109,7 +128,7 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
eventBus.unsubscribe(this); eventBus.unsubscribe(this);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent event) { void onEvent(final SoftwareModuleEvent event) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) { if (BaseEntityEventType.MINIMIZED == event.getEventType()) {
minimizeSwTable(); minimizeSwTable();
@@ -118,7 +137,7 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
} }
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final ArtifactDetailsEvent event) { void onEvent(final ArtifactDetailsEvent event) {
if (event == ArtifactDetailsEvent.MINIMIZED) { if (event == ArtifactDetailsEvent.MINIMIZED) {
minimizeArtifactoryDetails(); minimizeArtifactoryDetails();
@@ -272,4 +291,9 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
} }
} }
@Override
public void enter(final ViewChangeEvent event) {
// This view is constructed in the init() method()
}
} }

View File

@@ -14,9 +14,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.ArtifactDetailsEvent; import org.eclipse.hawkbit.ui.artifacts.event.ArtifactDetailsEvent;
@@ -34,14 +31,13 @@ import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition; import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -50,8 +46,6 @@ import com.google.common.collect.Maps;
import com.vaadin.data.Container; import com.vaadin.data.Container;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
@@ -65,12 +59,7 @@ import com.vaadin.ui.themes.ValoTheme;
/** /**
* Display the details of the artifacts for a selected software module. * Display the details of the artifacts for a selected software module.
*
*
*/ */
@SpringComponent
@ViewScope
public class ArtifactDetailsLayout extends VerticalLayout { public class ArtifactDetailsLayout extends VerticalLayout {
private static final long serialVersionUID = -5189069028037133891L; private static final long serialVersionUID = -5189069028037133891L;
@@ -91,17 +80,13 @@ public class ArtifactDetailsLayout extends VerticalLayout {
private static final String MD5HASH = "md5Hash"; private static final String MD5HASH = "md5Hash";
@Autowired private final I18N i18n;
private I18N i18n;
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState;
@Autowired private final UINotification uINotification;
private transient UINotification uINotification;
private Label titleOfArtifactDetails; private Label titleOfArtifactDetails;
@@ -111,15 +96,21 @@ public class ArtifactDetailsLayout extends VerticalLayout {
private Table maxArtifactDetailsTable; private Table maxArtifactDetailsTable;
private boolean fullWindowMode = false; private boolean fullWindowMode;
private boolean readOnly = false; private boolean readOnly;
private final transient ArtifactManagement artifactManagement;
public ArtifactDetailsLayout(final I18N i18n, final UIEventBus eventBus,
final ArtifactUploadState artifactUploadState, final UINotification uINotification,
final ArtifactManagement artifactManagement) {
this.i18n = i18n;
this.eventBus = eventBus;
this.artifactUploadState = artifactUploadState;
this.uINotification = uINotification;
this.artifactManagement = artifactManagement;
/**
* Initialize the artifact details layout.
*/
@PostConstruct
private void init() {
createComponents(); createComponents();
buildLayout(); buildLayout();
eventBus.subscribe(this); eventBus.subscribe(this);
@@ -133,18 +124,6 @@ public class ArtifactDetailsLayout extends VerticalLayout {
} }
} }
/**
* Initialize the artifact details layout in readonly mode (will not show
* the delete icon) .
*
* @param readOnly
* value true for read only.
*/
public void init(final boolean readOnly) {
this.readOnly = readOnly;
init();
}
private void createComponents() { private void createComponents() {
final String labelStr = artifactUploadState.getSelectedBaseSoftwareModule() final String labelStr = artifactUploadState.getSelectedBaseSoftwareModule()
.map(softwareModule -> HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), .map(softwareModule -> HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(),
@@ -192,7 +171,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
header.addComponents(titleOfArtifactDetails, maxMinButton); header.addComponents(titleOfArtifactDetails, maxMinButton);
header.setComponentAlignment(titleOfArtifactDetails, Alignment.TOP_LEFT); header.setComponentAlignment(titleOfArtifactDetails, Alignment.TOP_LEFT);
header.setComponentAlignment(maxMinButton, Alignment.TOP_RIGHT); header.setComponentAlignment(maxMinButton, Alignment.TOP_RIGHT);
header.setExpandRatio(titleOfArtifactDetails, 1.0f); header.setExpandRatio(titleOfArtifactDetails, 1.0F);
setSizeFull(); setSizeFull();
setImmediate(true); setImmediate(true);
@@ -202,7 +181,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
setComponentAlignment(header, Alignment.MIDDLE_CENTER); setComponentAlignment(header, Alignment.MIDDLE_CENTER);
addComponent(artifactDetailsTable); addComponent(artifactDetailsTable);
setComponentAlignment(artifactDetailsTable, Alignment.MIDDLE_CENTER); setComponentAlignment(artifactDetailsTable, Alignment.MIDDLE_CENTER);
setExpandRatio(artifactDetailsTable, 1.0f); setExpandRatio(artifactDetailsTable, 1.0F);
} }
@@ -276,8 +255,6 @@ public class ArtifactDetailsLayout extends VerticalLayout {
i18n.get("message.delete.artifact", new Object[] { fileName }), i18n.get("button.ok"), i18n.get("message.delete.artifact", new Object[] { fileName }), i18n.get("button.ok"),
i18n.get("button.cancel"), ok -> { i18n.get("button.cancel"), ok -> {
if (ok) { if (ok) {
final ArtifactManagement artifactManagement = SpringContextHelper
.getBean(ArtifactManagement.class);
artifactManagement.deleteArtifact(id); artifactManagement.deleteArtifact(id);
uINotification.displaySuccess(i18n.get("message.artifact.deleted", fileName)); uINotification.displaySuccess(i18n.get("message.artifact.deleted", fileName));
if (artifactUploadState.getSelectedBaseSwModuleId().isPresent()) { if (artifactUploadState.getSelectedBaseSwModuleId().isPresent()) {
@@ -308,15 +285,15 @@ public class ArtifactDetailsLayout extends VerticalLayout {
table.setColumnHeader(ACTION, i18n.get("upload.action")); table.setColumnHeader(ACTION, i18n.get("upload.action"));
} }
table.setColumnExpandRatio(PROVIDED_FILE_NAME, 3.5f); table.setColumnExpandRatio(PROVIDED_FILE_NAME, 3.5F);
table.setColumnExpandRatio(SIZE, 2f); table.setColumnExpandRatio(SIZE, 2f);
if (fullWindowMode) { if (fullWindowMode) {
table.setColumnExpandRatio(SHA1HASH, 2.8f); table.setColumnExpandRatio(SHA1HASH, 2.8F);
table.setColumnExpandRatio(MD5HASH, 2.4f); table.setColumnExpandRatio(MD5HASH, 2.4F);
} }
table.setColumnExpandRatio(CREATE_MODIFIED_DATE_UPLOAD, 3f); table.setColumnExpandRatio(CREATE_MODIFIED_DATE_UPLOAD, 3F);
if (!readOnly) { if (!readOnly) {
table.setColumnExpandRatio(ACTION, 2.5f); table.setColumnExpandRatio(ACTION, 2.5F);
} }
table.setVisibleColumns(getVisbleColumns().toArray()); table.setVisibleColumns(getVisbleColumns().toArray());
@@ -460,7 +437,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
setVisible(false); setVisible(false);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent softwareModuleEvent) { void onEvent(final SoftwareModuleEvent softwareModuleEvent) {
if (BaseEntityEventType.SELECTED_ENTITY == softwareModuleEvent.getEventType()) { if (BaseEntityEventType.SELECTED_ENTITY == softwareModuleEvent.getEventType()) {
UI.getCurrent().access(() -> { UI.getCurrent().access(() -> {
@@ -486,14 +463,6 @@ public class ArtifactDetailsLayout extends VerticalLayout {
} }
} }
@PreDestroy
void destroy() {
eventBus.unsubscribe(this); // It's good manners to do this, even though
// we should be
// automatically unsubscribed when the UI is
// garbage collected
}
public Table getArtifactDetailsTable() { public Table getArtifactDetailsTable() {
return artifactDetailsTable; return artifactDetailsTable;
} }

View File

@@ -14,10 +14,13 @@ import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria; import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope; import com.vaadin.spring.annotation.UIScope;
import com.vaadin.ui.Component; import com.vaadin.ui.Component;
/** /**
@@ -25,7 +28,7 @@ import com.vaadin.ui.Component;
* *
*/ */
@SpringComponent @SpringComponent
@ViewScope @UIScope
public class UploadViewAcceptCriteria extends AbstractAcceptCriteria { public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
private static final long serialVersionUID = 5158811326115667378L; private static final long serialVersionUID = 5158811326115667378L;
@@ -34,6 +37,11 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
private static final Map<String, Object> DROP_HINTS_CONFIGS = createDropHintConfigurations(); private static final Map<String, Object> DROP_HINTS_CONFIGS = createDropHintConfigurations();
@Autowired
UploadViewAcceptCriteria(final UINotification uiNotification, final UIEventBus eventBus) {
super(uiNotification, eventBus);
}
@Override @Override
protected String getComponentId(final Component component) { protected String getComponentId(final Component component) {
String id = component.getId(); String id = component.getId();

View File

@@ -10,22 +10,24 @@ package org.eclipse.hawkbit.ui.artifacts.footer;
import java.util.Set; import java.util.Set;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria; import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout; import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable; import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Component; import com.vaadin.ui.Component;
import com.vaadin.ui.Table; import com.vaadin.ui.Table;
import com.vaadin.ui.Table.TableTransferable; import com.vaadin.ui.Table.TableTransferable;
@@ -33,24 +35,30 @@ import com.vaadin.ui.UI;
/** /**
* Upload view footer layout implementation. * Upload view footer layout implementation.
*
*/ */
@SpringComponent
@ViewScope
public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
private static final long serialVersionUID = -3273982053389866299L; private static final long serialVersionUID = -3273982053389866299L;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState;
@Autowired private final UploadViewConfirmationWindowLayout uploadViewConfirmationWindowLayout;
private UploadViewConfirmationWindowLayout uploadViewConfirmationWindowLayout;
@Autowired private final UploadViewAcceptCriteria uploadViewAcceptCriteria;
private UploadViewAcceptCriteria uploadViewAcceptCriteria;
@EventBusListenerMethod(scope = EventScope.SESSION) public SMDeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
final UINotification notification, final ArtifactUploadState artifactUploadState,
final SoftwareManagement softwareManagement, final UploadViewAcceptCriteria uploadViewAcceptCriteria) {
super(i18n, permChecker, eventBus, notification);
this.artifactUploadState = artifactUploadState;
this.uploadViewConfirmationWindowLayout = new UploadViewConfirmationWindowLayout(i18n, eventBus,
softwareManagement, artifactUploadState);
this.uploadViewAcceptCriteria = uploadViewAcceptCriteria;
init();
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final UploadArtifactUIEvent event) { void onEvent(final UploadArtifactUIEvent event) {
if (isSoftwareEvent(event) || isSoftwareTypeEvent(event)) { if (isSoftwareEvent(event) || isSoftwareTypeEvent(event)) {
@@ -84,7 +92,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|| event == UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE_TYPE; || event == UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE_TYPE;
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent event) { void onEvent(final DragEvent event) {
if (event == DragEvent.HIDE_DROP_HINT) { if (event == DragEvent.HIDE_DROP_HINT) {
UI.getCurrent().access(() -> hideDropHints()); UI.getCurrent().access(() -> hideDropHints());
@@ -134,9 +142,8 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
final String swModuleTypeName = sourceComponent.getId() final String swModuleTypeName = sourceComponent.getId()
.replace(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, ""); .replace(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType()
&& artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName() .map(type -> type.getName().equalsIgnoreCase(swModuleTypeName)).orElse(false)) {
.equalsIgnoreCase(swModuleTypeName)) {
notification.displayValidationError( notification.displayValidationError(
i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName })); i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName }));
} else { } else {

View File

@@ -20,30 +20,24 @@ import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout; import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab; import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.vaadin.data.Container; import com.vaadin.data.Container;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table.Align; import com.vaadin.ui.Table.Align;
/** /**
* Abstract layout of confirm actions window. * Abstract layout of confirm actions window.
*
*
*
*/ */
@SpringComponent
@ViewScope
public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWindowLayout { public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWindowLayout {
private static final long serialVersionUID = 1804036019105286988L; private static final long serialVersionUID = 1804036019105286988L;
@@ -56,11 +50,16 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private static final String DISCARD = "Discard"; private static final String DISCARD = "Discard";
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState;
UploadViewConfirmationWindowLayout(final I18N i18n, final UIEventBus eventBus,
final SoftwareManagement softwareManagement, final ArtifactUploadState artifactUploadState) {
super(i18n, eventBus);
this.softwareManagement = softwareManagement;
this.artifactUploadState = artifactUploadState;
}
@Override @Override
protected Map<String, ConfirmationTab> getConfimrationTabs() { protected Map<String, ConfirmationTab> getConfimrationTabs() {

View File

@@ -8,8 +8,6 @@
*/ */
package org.eclipse.hawkbit.ui.artifacts.smtable; package org.eclipse.hawkbit.ui.artifacts.smtable;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -29,12 +27,10 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.ComboBox; import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CustomComponent; import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.FormLayout; import com.vaadin.ui.FormLayout;
@@ -46,26 +42,19 @@ import com.vaadin.ui.themes.ValoTheme;
/** /**
* Generates window for Software module add or update. * Generates window for Software module add or update.
*/ */
@SpringComponent
@ViewScope
public class SoftwareModuleAddUpdateWindow extends CustomComponent { public class SoftwareModuleAddUpdateWindow extends CustomComponent {
private static final long serialVersionUID = -5217675246477211483L; private static final long serialVersionUID = -5217675246477211483L;
@Autowired private final I18N i18n;
private I18N i18n;
@Autowired private final UINotification uiNotifcation;
private transient UINotification uiNotifcation;
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final transient EntityFactory entityFactory;
private transient EntityFactory entityFactory;
private TextField nameTextField; private TextField nameTextField;
@@ -77,14 +66,23 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
private TextArea descTextArea; private TextArea descTextArea;
private CommonDialogWindow window;
private Boolean editSwModule = Boolean.FALSE; private Boolean editSwModule = Boolean.FALSE;
private Long baseSwModuleId; private Long baseSwModuleId;
private FormLayout formLayout; private FormLayout formLayout;
public SoftwareModuleAddUpdateWindow(final I18N i18n, final UINotification uiNotifcation, final UIEventBus eventBus,
final SoftwareManagement softwareManagement, final EntityFactory entityFactory) {
this.i18n = i18n;
this.uiNotifcation = uiNotifcation;
this.eventBus = eventBus;
this.softwareManagement = softwareManagement;
this.entityFactory = entityFactory;
createRequiredComponents();
}
/** /**
* Save or update the sw module. * Save or update the sw module.
*/ */
@@ -104,14 +102,6 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
} }
} }
/**
* Initialize Distribution Add and Edit Window.
*/
@PostConstruct
void init() {
createRequiredComponents();
}
/** /**
* Create window for new software module. * Create window for new software module.
* *
@@ -133,9 +123,9 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
public CommonDialogWindow createUpdateSoftwareModuleWindow(final Long baseSwModuleId) { public CommonDialogWindow createUpdateSoftwareModuleWindow(final Long baseSwModuleId) {
this.baseSwModuleId = baseSwModuleId; this.baseSwModuleId = baseSwModuleId;
resetComponents(); resetComponents();
populateTypeNameCombo();
populateValuesOfSwModule(); populateValuesOfSwModule();
createWindow(); return createWindow();
return window;
} }
private void createRequiredComponents() { private void createRequiredComponents() {
@@ -157,7 +147,6 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY); typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
typeComboBox.setNewItemsAllowed(Boolean.FALSE); typeComboBox.setNewItemsAllowed(Boolean.FALSE);
typeComboBox.setImmediate(Boolean.TRUE); typeComboBox.setImmediate(Boolean.TRUE);
populateTypeNameCombo();
} }
private TextField createTextField(final String in18Key, final String id) { private TextField createTextField(final String in18Key, final String id) {
@@ -181,7 +170,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
editSwModule = Boolean.FALSE; editSwModule = Boolean.FALSE;
} }
private void createWindow() { private CommonDialogWindow createWindow() {
final Label madatoryStarLabel = new Label("*"); final Label madatoryStarLabel = new Label("*");
madatoryStarLabel.setStyleName("v-caption v-required-field-indicator"); madatoryStarLabel.setStyleName("v-caption v-required-field-indicator");
madatoryStarLabel.setWidth(null); madatoryStarLabel.setWidth(null);
@@ -198,7 +187,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
setCompositionRoot(formLayout); setCompositionRoot(formLayout);
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW) final CommonDialogWindow window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
.caption(i18n.get("upload.caption.add.new.swmodule")).content(this).layout(formLayout).i18n(i18n) .caption(i18n.get("upload.caption.add.new.swmodule")).content(this).layout(formLayout).i18n(i18n)
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow(); .saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
nameTextField.setEnabled(!editSwModule); nameTextField.setEnabled(!editSwModule);
@@ -206,6 +195,8 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
typeComboBox.setEnabled(!editSwModule); typeComboBox.setEnabled(!editSwModule);
typeComboBox.focus(); typeComboBox.focus();
return window;
} }
private void addNewBaseSoftware() { private void addNewBaseSoftware() {
@@ -271,6 +262,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
: HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getVendor())); : HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getVendor()));
descTextArea.setValue(swModle.getDescription() == null ? HawkbitCommonUtil.SP_STRING_EMPTY descTextArea.setValue(swModle.getDescription() == null ? HawkbitCommonUtil.SP_STRING_EMPTY
: HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getDescription())); : HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getDescription()));
if (swModle.getType().isDeleted()) { if (swModle.getType().isDeleted()) {
typeComboBox.addItem(swModle.getType().getName()); typeComboBox.addItem(swModle.getType().getName());
} }

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.artifacts.smtable;
import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.MetaData; import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
@@ -20,13 +21,12 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout; import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet;
@@ -36,44 +36,39 @@ import com.vaadin.ui.Window;
/** /**
* Software module details. * Software module details.
*
*
*/ */
@SpringComponent
@ViewScope
public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDetailsLayout<SoftwareModule> { public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDetailsLayout<SoftwareModule> {
private static final long serialVersionUID = -4900381301076646366L; private static final long serialVersionUID = -4900381301076646366L;
@Autowired private final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final SwMetadataPopupLayout swMetadataPopupLayout;
private SwMetadataPopupLayout swMetadataPopupLayout;
@Autowired private final SoftwareModuleMetadatadetailslayout swmMetadataTable;
private transient EntityFactory entityFactory;
private SoftwareModuleMetadatadetailslayout swmMetadataTable; SoftwareModuleDetails(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker,
final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow,
final ArtifactUploadState artifactUploadState, final SoftwareManagement softwareManagement,
final SwMetadataPopupLayout swMetadataPopupLayout, final EntityFactory entityFactory) {
super(i18n, eventBus, permissionChecker, null);
this.softwareModuleAddUpdateWindow = softwareModuleAddUpdateWindow;
this.artifactUploadState = artifactUploadState;
this.softwareManagement = softwareManagement;
this.swMetadataPopupLayout = swMetadataPopupLayout;
/**
* softwareLayout Initialize the component.
*/
@Override
protected void init() {
swmMetadataTable = new SoftwareModuleMetadatadetailslayout(); swmMetadataTable = new SoftwareModuleMetadatadetailslayout();
swmMetadataTable.init(getI18n(), getPermissionChecker(), softwareManagement, swMetadataPopupLayout, swmMetadataTable.init(getI18n(), getPermissionChecker(), softwareManagement, swMetadataPopupLayout,
entityFactory); entityFactory);
super.init(); addTabs(detailsTab);
restoreState();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final MetadataEvent event) { void onEvent(final MetadataEvent event) {
UI.getCurrent().access(() -> { UI.getCurrent().access(() -> {
final MetaData softwareModuleMetadata = event.getMetaData(); final MetaData softwareModuleMetadata = event.getMetaData();
@@ -168,7 +163,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
return artifactUploadState.isSwModuleTableMaximized(); return artifactUploadState.isSwModuleTableMaximized();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent softwareModuleEvent) { void onEvent(final SoftwareModuleEvent softwareModuleEvent) {
onBaseEntityEvent(softwareModuleEvent); onBaseEntityEvent(softwareModuleEvent);
} }
@@ -194,8 +189,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
} }
private boolean isSoftwareModuleSelected(final SoftwareModule softwareModule) { private boolean isSoftwareModuleSelected(final SoftwareModule softwareModule) {
final SoftwareModule selectedUploadSWModule = artifactUploadState.getSelectedBaseSoftwareModule().isPresent() final SoftwareModule selectedUploadSWModule = artifactUploadState.getSelectedBaseSoftwareModule().orElse(null);
? artifactUploadState.getSelectedBaseSoftwareModule().get() : null;
return softwareModule != null && selectedUploadSWModule != null return softwareModule != null && selectedUploadSWModule != null
&& selectedUploadSWModule.getName().equals(softwareModule.getName()) && selectedUploadSWModule.getName().equals(softwareModule.getName())
&& selectedUploadSWModule.getVersion().equals(softwareModule.getVersion()); && selectedUploadSWModule.getVersion().equals(softwareModule.getVersion());

View File

@@ -24,15 +24,17 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout; import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn; import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition; import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -42,34 +44,41 @@ import com.vaadin.data.Item;
import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Table; import com.vaadin.ui.Table;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
/** /**
* Header of Software module table. * The Software module table.
*/ */
@ViewScope
@SpringComponent
public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> { public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
private static final long serialVersionUID = 6469417305487144809L; private static final long serialVersionUID = 6469417305487144809L;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final UploadViewAcceptCriteria uploadViewAcceptCriteria;
private UploadViewAcceptCriteria uploadViewAcceptCriteria;
@Autowired private final SwMetadataPopupLayout swMetadataPopupLayout;
private SwMetadataPopupLayout swMetadataPopupLayout;
@EventBusListenerMethod(scope = EventScope.SESSION) SoftwareModuleTable(final UIEventBus eventBus, final I18N i18n, final UINotification uiNotification,
final ArtifactUploadState artifactUploadState, final SoftwareManagement softwareManagement,
final UploadViewAcceptCriteria uploadViewAcceptCriteria,
final SwMetadataPopupLayout swMetadataPopupLayout) {
super(eventBus, i18n, uiNotification);
this.artifactUploadState = artifactUploadState;
this.softwareManagement = softwareManagement;
this.uploadViewAcceptCriteria = uploadViewAcceptCriteria;
this.swMetadataPopupLayout = swMetadataPopupLayout;
addNewContainerDS();
setColumnProperties();
setDataAvailable(getContainerDataSource().size() != 0);
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SMFilterEvent filterEvent) { void onEvent(final SMFilterEvent filterEvent) {
UI.getCurrent().access(() -> { UI.getCurrent().access(() -> {
@@ -153,12 +162,12 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, lastSoftwareModule)); eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, lastSoftwareModule));
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent event) { void onEvent(final SoftwareModuleEvent event) {
onBaseEntityEvent(event); onBaseEntityEvent(event);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final UploadArtifactUIEvent event) { void onEvent(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) { if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) {
UI.getCurrent().access(this::refreshFilter); UI.getCurrent().access(this::refreshFilter);

View File

@@ -8,43 +8,41 @@
*/ */
package org.eclipse.hawkbit.ui.artifacts.smtable; package org.eclipse.hawkbit.ui.artifacts.smtable;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader; import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropHandler;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
/** /**
* Header of Software module table. * Header of Software module table.
*
*
*
*/ */
@SpringComponent
@ViewScope
public class SoftwareModuleTableHeader extends AbstractTableHeader { public class SoftwareModuleTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = 242961845006626297L; private static final long serialVersionUID = 242961845006626297L;
@Autowired private final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
private ArtifactUploadState artifactUploadState;
@Autowired SoftwareModuleTableHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus,
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow; final ArtifactUploadState artifactUploadState,
final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow) {
super(i18n, permChecker, eventbus, null, null, artifactUploadState);
this.softwareModuleAddUpdateWindow = softwareModuleAddUpdateWindow;
}
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final UploadArtifactUIEvent event) { void onEvent(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE) { if (event == UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE) {
setFilterButtonsIconVisible(true); setFilterButtonsIconVisible(true);
@@ -73,10 +71,7 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
@Override @Override
protected String onLoadSearchBoxValue() { protected String onLoadSearchBoxValue() {
if (artifactUploadState.getSoftwareModuleFilters().getSearchText().isPresent()) { return artifactUploadState.getSoftwareModuleFilters().getSearchText().orElse(null);
return artifactUploadState.getSoftwareModuleFilters().getSearchText().get();
}
return null;
} }
@Override @Override

View File

@@ -8,38 +8,42 @@
*/ */
package org.eclipse.hawkbit.ui.artifacts.smtable; package org.eclipse.hawkbit.ui.artifacts.smtable;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout; import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout;
import org.eclipse.hawkbit.ui.utils.I18N;
import com.vaadin.spring.annotation.SpringComponent; import org.eclipse.hawkbit.ui.utils.UINotification;
import com.vaadin.spring.annotation.ViewScope; import org.vaadin.spring.events.EventBus.UIEventBus;
/** /**
* Software module table layout. (Upload Management) * Software module table layout. (Upload Management)
*/ */
@SpringComponent
@ViewScope
public class SoftwareModuleTableLayout extends AbstractTableLayout { public class SoftwareModuleTableLayout extends AbstractTableLayout {
private static final long serialVersionUID = 6464291374980641235L; private static final long serialVersionUID = 6464291374980641235L;
@Autowired public SoftwareModuleTableLayout(final I18N i18n, final SpPermissionChecker permChecker,
private SoftwareModuleDetails softwareModuleDetails; final ArtifactUploadState artifactUploadState, final UINotification uiNotification,
final UIEventBus eventBus, final SoftwareManagement softwareManagement, final EntityFactory entityFactory,
final UploadViewAcceptCriteria uploadViewAcceptCriteria) {
@Autowired final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow = new SoftwareModuleAddUpdateWindow(i18n,
private SoftwareModuleTableHeader smTableHeader; uiNotification, eventBus, softwareManagement, entityFactory);
@Autowired final SwMetadataPopupLayout swMetadataPopupLayout = new SwMetadataPopupLayout(i18n, uiNotification, eventBus,
private SoftwareModuleTable smTable; softwareManagement, entityFactory, permChecker);
/** super.init(
* Initialize the filter layout. new SoftwareModuleTableHeader(i18n, permChecker, eventBus, artifactUploadState,
*/ softwareModuleAddUpdateWindow),
@PostConstruct new SoftwareModuleTable(eventBus, i18n, uiNotification, artifactUploadState, softwareManagement,
void init() { uploadViewAcceptCriteria, swMetadataPopupLayout),
super.init(smTableHeader, smTable, softwareModuleDetails); new SoftwareModuleDetails(i18n, eventBus, permChecker, softwareModuleAddUpdateWindow,
artifactUploadState, softwareManagement, swMetadataPopupLayout, entityFactory));
} }
} }

View File

@@ -11,7 +11,10 @@ package org.eclipse.hawkbit.ui.artifacts.smtype;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
@@ -23,17 +26,17 @@ import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout; import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.shared.ui.colorpicker.Color; import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.OptionGroup; import com.vaadin.ui.OptionGroup;
import com.vaadin.ui.TextField; import com.vaadin.ui.TextField;
@@ -44,15 +47,12 @@ import com.vaadin.ui.themes.ValoTheme;
* Layout for the create or update software module type. * Layout for the create or update software module type.
* *
*/ */
@SpringComponent
@ViewScope
public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<SoftwareModuleType> { public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<SoftwareModuleType> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateSoftwareTypeLayout.class); private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateSoftwareTypeLayout.class);
@Autowired private final transient SoftwareManagement swTypeManagementService;
private transient SoftwareManagement swTypeManagementService;
private String singleAssignStr; private String singleAssignStr;
private String multiAssignStr; private String multiAssignStr;
@@ -60,6 +60,13 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
private Label multiAssign; private Label multiAssign;
private OptionGroup assignOptiongroup; private OptionGroup assignOptiongroup;
public CreateUpdateSoftwareTypeLayout(final I18N i18n, final TagManagement tagManagement,
final EntityFactory entityFactory, final UIEventBus eventBus, final SpPermissionChecker permChecker,
final UINotification uiNotification, final SoftwareManagement swTypeManagementService) {
super(i18n, tagManagement, entityFactory, eventBus, permChecker, uiNotification);
this.swTypeManagementService = swTypeManagementService;
}
@Override @Override
protected void addListeners() { protected void addListeners() {
super.addListeners(); super.addListeners();

View File

@@ -15,52 +15,37 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
/** /**
* Single button click behaviour of filter buttons layout. * Single button click behaviour of filter buttons layout.
*
*
*
*/ */
@SpringComponent
@ViewScope
public class SMTypeFilterButtonClick extends AbstractFilterSingleButtonClick implements Serializable { public class SMTypeFilterButtonClick extends AbstractFilterSingleButtonClick implements Serializable {
private static final long serialVersionUID = 3707945900524967887L; private static final long serialVersionUID = 3707945900524967887L;
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
SMTypeFilterButtonClick(final UIEventBus eventBus, final ArtifactUploadState artifactUploadState,
final SoftwareManagement softwareManagement) {
this.eventBus = eventBus;
this.artifactUploadState = artifactUploadState;
this.softwareManagement = softwareManagement;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.layouts.SPFilterButtonClickBehaviour#
* filterUnClicked(com.vaadin.ui. Button)
*/
@Override @Override
protected void filterUnClicked(final Button clickedButton) { protected void filterUnClicked(final Button clickedButton) {
artifactUploadState.getSoftwareModuleFilters().setSoftwareModuleType(null); artifactUploadState.getSoftwareModuleFilters().setSoftwareModuleType(null);
eventBus.publish(this, SMFilterEvent.FILTER_BY_TYPE); eventBus.publish(this, SMFilterEvent.FILTER_BY_TYPE);
} }
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.layouts.SPFilterButtonClickBehaviour#filterClicked
* (com.vaadin.ui.Button )
*/
@Override @Override
protected void filterClicked(final Button clickedButton) { protected void filterClicked(final Button clickedButton) {
final SoftwareModuleType softwareModuleType = softwareManagement final SoftwareModuleType softwareModuleType = softwareManagement

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.artifacts.smtype;
import java.util.EnumSet; import java.util.EnumSet;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
@@ -19,35 +20,36 @@ import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/** /**
* Software module type filter buttons. * Software module type filter buttons.
* *
*/ */
@SpringComponent
@ViewScope
public class SMTypeFilterButtons extends AbstractFilterButtons { public class SMTypeFilterButtons extends AbstractFilterButtons {
private static final long serialVersionUID = 169198312654380358L; private static final long serialVersionUID = 169198312654380358L;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState;
@Autowired private final UploadViewAcceptCriteria uploadViewAcceptCriteria;
private UploadViewAcceptCriteria uploadViewAcceptCriteria;
@EventBusListenerMethod(scope = EventScope.SESSION) SMTypeFilterButtons(final UIEventBus eventBus, final ArtifactUploadState artifactUploadState,
final UploadViewAcceptCriteria uploadViewAcceptCriteria, final SoftwareManagement softwareManagement) {
super(eventBus, new SMTypeFilterButtonClick(eventBus, artifactUploadState, softwareManagement));
this.artifactUploadState = artifactUploadState;
this.uploadViewAcceptCriteria = uploadViewAcceptCriteria;
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleTypeEvent event) { void onEvent(final SoftwareModuleTypeEvent event) {
if (event.getSoftwareModuleType() != null if (event.getSoftwareModuleType() != null
&& EnumSet.allOf(SoftwareModuleTypeEnum.class).contains(event.getSoftwareModuleTypeEnum())) { && EnumSet.allOf(SoftwareModuleTypeEnum.class).contains(event.getSoftwareModuleTypeEnum())) {
@@ -56,7 +58,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final UploadArtifactUIEvent event) { void onEvent(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE_TYPE) { if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE_TYPE) {
refreshTable(); refreshTable();
@@ -70,14 +72,13 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@Override @Override
protected LazyQueryContainer createButtonsLazyQueryContainer() { protected LazyQueryContainer createButtonsLazyQueryContainer() {
return HawkbitCommonUtil.createLazyQueryContainer( return HawkbitCommonUtil.createLazyQueryContainer(new BeanQueryFactory<>(SoftwareModuleTypeBeanQuery.class));
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class));
} }
@Override @Override
protected boolean isClickedByDefault(final String typeName) { protected boolean isClickedByDefault(final String typeName) {
return artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() && artifactUploadState return artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType()
.getSoftwareModuleFilters().getSoftwareModuleType().get().getName().equals(typeName); .map(type -> type.getName().equals(typeName)).orElse(false);
} }
@Override @Override

View File

@@ -8,18 +8,20 @@
*/ */
package org.eclipse.hawkbit.ui.artifacts.smtype; package org.eclipse.hawkbit.ui.artifacts.smtype;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
@@ -27,25 +29,22 @@ import com.vaadin.ui.Window;
/** /**
* Software module type filter buttons header. * Software module type filter buttons header.
*/ */
@SpringComponent
@ViewScope
public class SMTypeFilterHeader extends AbstractFilterHeader { public class SMTypeFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = -4855810338059032342L; private static final long serialVersionUID = -4855810338059032342L;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState; private final CreateUpdateSoftwareTypeLayout createUpdateSWTypeLayout;
@Autowired SMTypeFilterHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
private CreateUpdateSoftwareTypeLayout createUpdateSWTypeLayout; final ArtifactUploadState artifactUploadState, final TagManagement tagManagement,
final EntityFactory entityFactory, final UINotification uiNotification,
final SoftwareManagement softwareManagement) {
super(permChecker, eventBus, i18n);
this.artifactUploadState = artifactUploadState;
this.createUpdateSWTypeLayout = new CreateUpdateSoftwareTypeLayout(i18n, tagManagement, entityFactory, eventBus,
permChecker, uiNotification, softwareManagement);
/**
* Initialize the components.
*/
@Override
@PostConstruct
protected void init() {
super.init();
if (permChecker.hasCreateDistributionPermission() || permChecker.hasUpdateDistributionPermission()) { if (permChecker.hasCreateDistributionPermission() || permChecker.hasUpdateDistributionPermission()) {
createUpdateSWTypeLayout.init(); createUpdateSWTypeLayout.init();
} }

View File

@@ -8,57 +8,44 @@
*/ */
package org.eclipse.hawkbit.ui.artifacts.smtype; package org.eclipse.hawkbit.ui.artifacts.smtype;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.EntityFactory;
import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.I18N;
import org.vaadin.spring.events.EventBus; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/** /**
* Software module type filter buttons layout. * Software module type filter buttons layout.
*
*
*
*/ */
@SpringComponent
@ViewScope
public class SMTypeFilterLayout extends AbstractFilterLayout { public class SMTypeFilterLayout extends AbstractFilterLayout {
private static final long serialVersionUID = 1581066345157393665L; private static final long serialVersionUID = 1581066345157393665L;
@Autowired private final ArtifactUploadState artifactUploadState;
private transient EventBus.SessionEventBus eventbus;
@Autowired public SMTypeFilterLayout(final ArtifactUploadState artifactUploadState, final I18N i18n,
private SMTypeFilterHeader smTypeFilterHeader; final SpPermissionChecker permChecker, final UIEventBus eventBus, final TagManagement tagManagement,
final EntityFactory entityFactory, final UINotification uiNotification,
final SoftwareManagement softwareManagement, final UploadViewAcceptCriteria uploadViewAcceptCriteria) {
super(new SMTypeFilterHeader(i18n, permChecker, eventBus, artifactUploadState, tagManagement, entityFactory,
uiNotification, softwareManagement),
new SMTypeFilterButtons(eventBus, artifactUploadState, uploadViewAcceptCriteria, softwareManagement));
@Autowired this.artifactUploadState = artifactUploadState;
private SMTypeFilterButtons smTypeFilterButtons; restoreState();
@Autowired eventBus.subscribe(this);
private SMTypeFilterButtonClick smTypeFilterButtonClick;
@Autowired
private ArtifactUploadState artifactUploadState;
/**
* Initialize the filter layout.
*/
@PostConstruct
void init() {
super.init(smTypeFilterHeader, smTypeFilterButtons, smTypeFilterButtonClick);
eventbus.subscribe(this);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final UploadArtifactUIEvent event) { void onEvent(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE) { if (event == UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE) {
setVisible(false); setVisible(false);
@@ -68,21 +55,6 @@ public class SMTypeFilterLayout extends AbstractFilterLayout {
} }
} }
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventbus.unsubscribe(this);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.common.filterlayout.SPFilterLayout#
* onLoadIsTypeFilterIsClosed()
*/
@Override @Override
public Boolean onLoadIsTypeFilterIsClosed() { public Boolean onLoadIsTypeFilterIsClosed() {
return artifactUploadState.isSwTypeFilterClosed(); return artifactUploadState.isSwTypeFilterClosed();

View File

@@ -38,8 +38,7 @@ public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializ
private static final long serialVersionUID = 8273440375917450859L; private static final long serialVersionUID = 8273440375917450859L;
@Autowired private final SoftwareModuleFilters softwareModuleFilters;
private SoftwareModuleFilters softwareModuleFilters;
private final Map<Long, String> deleteSofwareModules = new HashMap<>(); private final Map<Long, String> deleteSofwareModules = new HashMap<>();
@@ -75,6 +74,11 @@ public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializ
private final AtomicInteger numberOfFileUploadsFailed = new AtomicInteger(); private final AtomicInteger numberOfFileUploadsFailed = new AtomicInteger();
@Autowired
ArtifactUploadState(final SoftwareModuleFilters softwareModuleFilters) {
this.softwareModuleFilters = softwareModuleFilters;
}
public AtomicInteger getNumberOfFileUploadsFailed() { public AtomicInteger getNumberOfFileUploadsFailed() {
return numberOfFileUploadsFailed; return numberOfFileUploadsFailed;
} }

View File

@@ -85,16 +85,6 @@ public class CustomFile implements Serializable {
this.baseSoftwareModuleVersion = baseSoftwareModuleVersion; this.baseSoftwareModuleVersion = baseSoftwareModuleVersion;
} }
/**
* Default constructor with the immutable fileName set.
*
* @param fileName
* uploaded file name
*/
public CustomFile(final String fileName) {
this.fileName = fileName;
}
public String getBaseSoftwareModuleName() { public String getBaseSoftwareModuleName() {
return baseSoftwareModuleName; return baseSoftwareModuleName;
} }

View File

@@ -35,10 +35,10 @@ import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.IndexedContainer;
@@ -116,6 +116,10 @@ public class UploadConfirmationWindow implements Button.ClickListener {
private final ArtifactUploadState artifactUploadState; private final ArtifactUploadState artifactUploadState;
private final transient UIEventBus eventBus;
private final transient ArtifactManagement artifactManagement;
/** /**
* Initialize the upload confirmation window. * Initialize the upload confirmation window.
* *
@@ -124,10 +128,12 @@ public class UploadConfirmationWindow implements Button.ClickListener {
* @param artifactUploadState * @param artifactUploadState
* reference of session variable {@link ArtifactUploadState}. * reference of session variable {@link ArtifactUploadState}.
*/ */
public UploadConfirmationWindow(final UploadLayout artifactUploadView, UploadConfirmationWindow(final UploadLayout artifactUploadView, final ArtifactUploadState artifactUploadState,
final ArtifactUploadState artifactUploadState) { final UIEventBus eventBus, final ArtifactManagement artifactManagement) {
this.uploadLayout = artifactUploadView; this.uploadLayout = artifactUploadView;
this.artifactUploadState = artifactUploadState; this.artifactUploadState = artifactUploadState;
this.eventBus = eventBus;
this.artifactManagement = artifactManagement;
i18n = artifactUploadView.getI18n(); i18n = artifactUploadView.getI18n();
createRequiredComponents(); createRequiredComponents();
buildLayout(); buildLayout();
@@ -188,7 +194,6 @@ public class UploadConfirmationWindow implements Button.ClickListener {
*/ */
private void setWarningIcon(final Label warningIconLabel, final String fileName, final Object itemId) { private void setWarningIcon(final Label warningIconLabel, final String fileName, final Object itemId) {
final Item item = uploadDetailsTable.getItem(itemId); final Item item = uploadDetailsTable.getItem(itemId);
final ArtifactManagement artifactManagement = SpringContextHelper.getBean(ArtifactManagement.class);
if (HawkbitCommonUtil.trimAndNullIfEmpty(fileName) != null) { if (HawkbitCommonUtil.trimAndNullIfEmpty(fileName) != null) {
final Long baseSwId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue(); final Long baseSwId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue();
final List<Artifact> artifactList = artifactManagement.findByFilenameAndSoftwareModule(fileName, baseSwId); final List<Artifact> artifactList = artifactManagement.findByFilenameAndSoftwareModule(fileName, baseSwId);
@@ -432,7 +437,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
private void hideErrorIcon(final Label warningLabel, final int errorLabelCount, final int duplicateCount, private void hideErrorIcon(final Label warningLabel, final int errorLabelCount, final int duplicateCount,
final Label errorLabel, final String oldFileName, final Long currentSwId) { final Label errorLabel, final String oldFileName, final Long currentSwId) {
if (warningLabel == null && (errorLabelCount > 1 || (duplicateCount == 1 && errorLabelCount == 1))) { if (warningLabel == null && (errorLabelCount > 1 || (duplicateCount == 1 && errorLabelCount == 1))) {
final ArtifactManagement artifactManagement = SpringContextHelper.getBean(ArtifactManagement.class);
final List<Artifact> artifactList = artifactManagement.findByFilenameAndSoftwareModule(oldFileName, final List<Artifact> artifactList = artifactManagement.findByFilenameAndSoftwareModule(oldFileName,
currentSwId); currentSwId);
errorLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL); errorLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL);
@@ -577,7 +582,6 @@ public class UploadConfirmationWindow implements Button.ClickListener {
private void processArtifactUpload() { private void processArtifactUpload() {
final List<String> itemIds = (List<String>) uploadDetailsTable.getItemIds(); final List<String> itemIds = (List<String>) uploadDetailsTable.getItemIds();
if (preUploadValidation(itemIds)) { if (preUploadValidation(itemIds)) {
final ArtifactManagement artifactManagement = SpringContextHelper.getBean(ArtifactManagement.class);
Boolean refreshArtifactDetailsLayout = false; Boolean refreshArtifactDetailsLayout = false;
for (final String itemId : itemIds) { for (final String itemId : itemIds) {
final String[] itemDet = itemId.split("/"); final String[] itemDet = itemId.split("/");
@@ -602,7 +606,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
uploadLayout.clearFileList(); uploadLayout.clearFileList();
window.close(); window.close();
// call upload result window // call upload result window
currentUploadResultWindow = new UploadResultWindow(uploadResultList, i18n); currentUploadResultWindow = new UploadResultWindow(uploadResultList, i18n, eventBus);
UI.getCurrent().addWindow(currentUploadResultWindow.getUploadResultsWindow()); UI.getCurrent().addWindow(currentUploadResultWindow.getUploadResultsWindow());
currentUploadResultWindow.getUploadResultsWindow().addCloseListener(event -> onResultDetailsPopupClose()); currentUploadResultWindow.getUploadResultsWindow().addCloseListener(event -> onResultDetailsPopupClose());
uploadLayout.setResultPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), uploadLayout.setResultPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(),

View File

@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.ui.artifacts.upload;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException; import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.UploadFileStatus; import org.eclipse.hawkbit.ui.artifacts.event.UploadFileStatus;
@@ -60,15 +58,15 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
private final long maxSize; private final long maxSize;
private final Upload upload; private final Upload upload;
private volatile String fileName = null; private volatile String fileName;
private volatile String mimeType = null; private volatile String mimeType;
private volatile boolean streamingInterrupted = false; private volatile boolean streamingInterrupted;
private volatile boolean uploadInterrupted = false; private volatile boolean uploadInterrupted;
private volatile boolean aborted = false; private volatile boolean aborted;
private String failureReason; private String failureReason;
private final I18N i18n; private final I18N i18n;
private transient EventBus.SessionEventBus eventBus; private transient EventBus.UIEventBus eventBus;
private final SoftwareModule selectedSw; private final SoftwareModule selectedSw;
private SoftwareModule selectedSwForUpload; private SoftwareModule selectedSwForUpload;
private final ArtifactUploadState artifactUploadState; private final ArtifactUploadState artifactUploadState;
@@ -85,21 +83,12 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
this.mimeType = mimeType; this.mimeType = mimeType;
this.selectedSw = selectedSw; this.selectedSw = selectedSw;
this.i18n = SpringContextHelper.getBean(I18N.class); this.i18n = SpringContextHelper.getBean(I18N.class);
this.eventBus = SpringContextHelper.getBean(EventBus.SessionEventBus.class); this.eventBus = SpringContextHelper.getBean(EventBus.UIEventBus.class);
this.artifactUploadState = SpringContextHelper.getBean(ArtifactUploadState.class); this.artifactUploadState = SpringContextHelper.getBean(ArtifactUploadState.class);
eventBus.subscribe(this); eventBus.subscribe(this);
} }
@PreDestroy @EventBusListenerMethod(scope = EventScope.UI)
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadStatusEventType event) { void onEvent(final UploadStatusEventType event) {
if (event == UploadStatusEventType.ABORT_UPLOAD) { if (event == UploadStatusEventType.ABORT_UPLOAD) {
aborted = true; aborted = true;

View File

@@ -17,10 +17,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException; import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
@@ -43,9 +41,9 @@ import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.util.SPInfo; import org.eclipse.hawkbit.util.SPInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -58,8 +56,6 @@ import com.vaadin.server.FontAwesome;
import com.vaadin.server.Page; import com.vaadin.server.Page;
import com.vaadin.server.StreamVariable; import com.vaadin.server.StreamVariable;
import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.DragAndDropWrapper; import com.vaadin.ui.DragAndDropWrapper;
@@ -74,36 +70,24 @@ import com.vaadin.ui.VerticalLayout;
/** /**
* Upload files layout. * Upload files layout.
*/ */
@ViewScope
@SpringComponent
public class UploadLayout extends VerticalLayout { public class UploadLayout extends VerticalLayout {
/**
*
*/
private static final String HTML_DIV = "</div>"; private static final String HTML_DIV = "</div>";
private static final long serialVersionUID = -566164756606779220L; private static final long serialVersionUID = -566164756606779220L;
private static final Logger LOG = LoggerFactory.getLogger(UploadLayout.class); private static final Logger LOG = LoggerFactory.getLogger(UploadLayout.class);
@Autowired private final UploadStatusInfoWindow uploadInfoWindow;
private UploadStatusInfoWindow uploadInfoWindow;
@Autowired private final I18N i18n;
private I18N i18n;
@Autowired private final UINotification uiNotification;
private transient UINotification uiNotification;
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState;
@Autowired private final transient SPInfo spInfo;
private transient SPInfo spInfo;
private final List<String> duplicateFileNamesList = new ArrayList<>(); private final List<String> duplicateFileNamesList = new ArrayList<>();
@@ -115,7 +99,7 @@ public class UploadLayout extends VerticalLayout {
private VerticalLayout dropAreaLayout; private VerticalLayout dropAreaLayout;
private UI ui; private final UI ui;
private HorizontalLayout fileUploadLayout; private HorizontalLayout fileUploadLayout;
@@ -125,11 +109,19 @@ public class UploadLayout extends VerticalLayout {
private Button uploadStatusButton; private Button uploadStatusButton;
/** private final transient ArtifactManagement artifactManagement;
* Initialize the upload layout.
*/ public UploadLayout(final I18N i18n, final UINotification uiNotification, final UIEventBus eventBus,
@PostConstruct final ArtifactUploadState artifactUploadState, final SPInfo spInfo,
void init() { final ArtifactManagement artifactManagement) {
this.uploadInfoWindow = new UploadStatusInfoWindow(eventBus, artifactUploadState, i18n);
this.i18n = i18n;
this.uiNotification = uiNotification;
this.eventBus = eventBus;
this.artifactUploadState = artifactUploadState;
this.spInfo = spInfo;
this.artifactManagement = artifactManagement;
createComponents(); createComponents();
buildLayout(); buildLayout();
restoreState(); restoreState();
@@ -137,7 +129,7 @@ public class UploadLayout extends VerticalLayout {
ui = UI.getCurrent(); ui = UI.getCurrent();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final UploadArtifactUIEvent event) { void onEvent(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) { if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) {
ui.access(() -> updateActionCount()); ui.access(() -> updateActionCount());
@@ -150,32 +142,23 @@ public class UploadLayout extends VerticalLayout {
} }
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final UploadStatusEvent event) { void onEvent(final UploadStatusEvent event) {
if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STARTED) { if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STARTED) {
ui.access(() -> onStartOfUpload()); ui.access(this::onStartOfUpload);
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_FAILED) { } else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_FAILED) {
ui.access(() -> onUploadFailure(event)); ui.access(() -> onUploadFailure(event));
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_FINISHED) { } else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_FINISHED) {
ui.access(() -> onUploadCompletion()); ui.access(this::onUploadCompletion);
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_SUCCESSFUL) { } else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_SUCCESSFUL) {
ui.access(() -> onUploadSuccess(event)); ui.access(() -> onUploadSuccess(event));
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FAILED) { } else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FAILED) {
ui.access(() -> onUploadStreamingFailure(event)); ui.access(() -> onUploadStreamingFailure(event));
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FINISHED) { } else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FINISHED) {
ui.access(() -> onUploadStreamingSuccess()); ui.access(this::onUploadStreamingSuccess);
} }
} }
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
private void createComponents() { private void createComponents() {
createUploadStatusButton(); createUploadStatusButton();
createProcessButton(); createProcessButton();
@@ -643,7 +626,8 @@ public class UploadLayout extends VerticalLayout {
if (artifactUploadState.getFileSelected().isEmpty()) { if (artifactUploadState.getFileSelected().isEmpty()) {
uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); uiNotification.displayValidationError(i18n.get("message.error.noFileSelected"));
} else { } else {
currentUploadConfirmationwindow = new UploadConfirmationWindow(this, artifactUploadState); currentUploadConfirmationwindow = new UploadConfirmationWindow(this, artifactUploadState, eventBus,
artifactManagement);
UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow()); UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow());
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(),
Page.getCurrent().getBrowserWindowHeight()); Page.getCurrent().getBrowserWindowHeight());

View File

@@ -19,7 +19,6 @@ import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
@@ -37,11 +36,6 @@ import com.vaadin.ui.themes.ValoTheme;
/** /**
* Upload status popup. * Upload status popup.
*
*
*
*
*
*/ */
public class UploadResultWindow implements Button.ClickListener { public class UploadResultWindow implements Button.ClickListener {
@@ -66,9 +60,8 @@ public class UploadResultWindow implements Button.ClickListener {
private static final String UPLOAD_RESULT = "uploadResult"; private static final String UPLOAD_RESULT = "uploadResult";
private static final String REASON = "reason"; private static final String REASON = "reason";
private transient EventBus.SessionEventBus eventBus;
private transient EventBus.UIEventBus eventBus;
/** /**
* Initialize upload status popup. * Initialize upload status popup.
@@ -78,10 +71,10 @@ public class UploadResultWindow implements Button.ClickListener {
* @param i18n * @param i18n
* I18N * I18N
*/ */
public UploadResultWindow(final List<UploadStatus> uploadResultList, final I18N i18n) { UploadResultWindow(final List<UploadStatus> uploadResultList, final I18N i18n, final EventBus.UIEventBus eventBus) {
this.uploadResultList = uploadResultList; this.uploadResultList = uploadResultList;
this.i18n = i18n; this.i18n = i18n;
eventBus = SpringContextHelper.getBean( EventBus.SessionEventBus.class); this.eventBus = eventBus;
createComponents(); createComponents();
createLayout(); createLayout();
} }
@@ -190,7 +183,7 @@ public class UploadResultWindow implements Button.ClickListener {
if (event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE) if (event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE)
|| event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_POPUP_CLOSE)) { || event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_POPUP_CLOSE)) {
uploadResultsWindow.close(); uploadResultsWindow.close();
//close upload status popup if open // close upload status popup if open
eventBus.publish(this, UploadArtifactUIEvent.ARTIFACT_RESULT_POPUP_CLOSED); eventBus.publish(this, UploadArtifactUIEvent.ARTIFACT_RESULT_POPUP_CLOSED);
} }

View File

@@ -11,9 +11,6 @@ package org.eclipse.hawkbit.ui.artifacts.upload;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadFileStatus; import org.eclipse.hawkbit.ui.artifacts.event.UploadFileStatus;
@@ -28,8 +25,8 @@ import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -38,8 +35,6 @@ import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.window.WindowMode; import com.vaadin.shared.ui.window.WindowMode;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Grid; import com.vaadin.ui.Grid;
@@ -58,18 +53,13 @@ import elemental.json.JsonValue;
/** /**
* Shows upload status during upload. * Shows upload status during upload.
*/ */
@ViewScope
@SpringComponent
public class UploadStatusInfoWindow extends Window { public class UploadStatusInfoWindow extends Window {
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final ArtifactUploadState artifactUploadState;
private ArtifactUploadState artifactUploadState;
@Autowired private final I18N i18n;
private I18N i18n;
private static final String PROGRESS = "Progress"; private static final String PROGRESS = "Progress";
@@ -81,17 +71,17 @@ public class UploadStatusInfoWindow extends Window {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Grid grid; private final Grid grid;
private IndexedContainer uploads; private final IndexedContainer uploads;
private volatile boolean errorOccured = false; private volatile boolean errorOccured;
private volatile boolean uploadAborted = false; private volatile boolean uploadAborted;
private Button minimizeButton; private Button minimizeButton;
private VerticalLayout mainLayout; private final VerticalLayout mainLayout;
private Label windowCaption; private Label windowCaption;
@@ -99,15 +89,14 @@ public class UploadStatusInfoWindow extends Window {
private Button resizeButton; private Button resizeButton;
private UI ui; private final UI ui;
private ConfirmationDialog confirmDialog; private ConfirmationDialog confirmDialog;
/** UploadStatusInfoWindow(final UIEventBus eventBus, final ArtifactUploadState artifactUploadState, final I18N i18n) {
* Default Constructor. this.eventBus = eventBus;
*/ this.artifactUploadState = artifactUploadState;
@PostConstruct this.i18n = i18n;
void init() {
setPopupProperties(); setPopupProperties();
createStatusPopupHeaderComponents(); createStatusPopupHeaderComponents();
@@ -130,7 +119,7 @@ public class UploadStatusInfoWindow extends Window {
createConfirmDialog(); createConfirmDialog();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final UploadStatusEvent event) { void onEvent(final UploadStatusEvent event) {
final UploadFileStatus uploadStatus = event.getUploadStatus(); final UploadFileStatus uploadStatus = event.getUploadStatus();
@@ -166,15 +155,6 @@ public class UploadStatusInfoWindow extends Window {
uploadStarted(event.getUploadStatus().getFileName(), event.getUploadStatus().getSoftwareModule()); uploadStarted(event.getUploadStatus().getFileName(), event.getUploadStatus().getSoftwareModule());
} }
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
private void restoreState() { private void restoreState() {
final Indexed container = grid.getContainerDataSource(); final Indexed container = grid.getContainerDataSource();
if (container.getItemIds().isEmpty()) { if (container.getItemIds().isEmpty()) {

View File

@@ -27,15 +27,7 @@ public class UploadStatusObject implements Serializable {
private String reason; private String reason;
private final SoftwareModule selectedSoftwareModule; private final SoftwareModule selectedSoftwareModule;
public UploadStatusObject(final String status, final Double progress, final String fileName, final String reason, UploadStatusObject(final String fileName, final SoftwareModule selectedSoftwareModule) {
final SoftwareModule selectedSoftwareModule) {
this(fileName, selectedSoftwareModule);
this.status = status;
this.progress = progress;
this.reason = reason;
}
public UploadStatusObject(final String fileName, final SoftwareModule selectedSoftwareModule) {
this.filename = fileName; this.filename = fileName;
this.selectedSoftwareModule = selectedSoftwareModule; this.selectedSoftwareModule = selectedSoftwareModule;
} }

View File

@@ -62,7 +62,7 @@ public class ColorPickerLayout extends GridLayout {
addComponent(colorSelect, 1, 1, 1, 3); addComponent(colorSelect, 1, 1, 1, 3);
} }
public void init() { private void init() {
selectors = new HashSet<>(); selectors = new HashSet<>();
selectedColor = getDefaultColor(); selectedColor = getDefaultColor();
@@ -80,7 +80,7 @@ public class ColorPickerLayout extends GridLayout {
selectors.add(colorSelect); selectors.add(colorSelect);
} }
public Slider createRGBSlider(final String caption, final String styleName) { private Slider createRGBSlider(final String caption, final String styleName) {
final Slider slider = new Slider(caption, 0, 255); final Slider slider = new Slider(caption, 0, 255);
slider.setImmediate(true); slider.setImmediate(true);
slider.setWidth("150px"); slider.setWidth("150px");

View File

@@ -18,8 +18,8 @@ import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion; import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion;
@@ -39,11 +39,14 @@ public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
private int previousRowCount; private int previousRowCount;
@Autowired protected UINotification uiNotification;
protected transient UINotification uiNotification;
@Autowired protected transient EventBus.UIEventBus eventBus;
protected transient EventBus.SessionEventBus eventBus;
protected AbstractAcceptCriteria(final UINotification uiNotification, final UIEventBus eventBus) {
this.uiNotification = uiNotification;
this.eventBus = eventBus;
}
@Override @Override
public boolean accept(final DragAndDropEvent dragEvent) { public boolean accept(final DragAndDropEvent dragEvent) {

View File

@@ -11,8 +11,7 @@ package org.eclipse.hawkbit.ui.common;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.MetaData; import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity; import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
@@ -30,8 +29,8 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.IndexedContainer;
@@ -73,14 +72,11 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
private static final String KEY = "key"; private static final String KEY = "key";
@Autowired
protected I18N i18n; protected I18N i18n;
@Autowired private final UINotification uiNotification;
private UINotification uiNotification;
@Autowired protected transient EventBus.UIEventBus eventBus;
protected transient EventBus.SessionEventBus eventBus;
private TextField keyTextField; private TextField keyTextField;
@@ -97,6 +93,18 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
private E selectedEntity; private E selectedEntity;
private HorizontalLayout mainLayout; private HorizontalLayout mainLayout;
protected SpPermissionChecker permChecker;
protected AbstractMetadataPopupLayout(final I18N i18n, final UINotification uiNotification,
final UIEventBus eventBus, final SpPermissionChecker permChecker) {
this.i18n = i18n;
this.uiNotification = uiNotification;
this.eventBus = eventBus;
this.permChecker = permChecker;
createComponents();
buildLayout();
}
/** /**
* Save the metadata and never close the window after saving. * Save the metadata and never close the window after saving.
@@ -119,13 +127,6 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
} }
@PostConstruct
void init() {
createComponents();
buildLayout();
}
/** /**
* Returns metadata popup. * Returns metadata popup.
* *

View File

@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.ui.common.confirmwindow.layout;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -20,8 +18,8 @@ import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.ui.Accordion; import com.vaadin.ui.Accordion;
@@ -46,16 +44,15 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
private String consolidatedMessage; private String consolidatedMessage;
@Autowired
protected I18N i18n; protected I18N i18n;
@Autowired protected transient EventBus.UIEventBus eventBus;
protected transient EventBus.SessionEventBus eventBus;
protected AbstractConfirmationWindowLayout(final I18N i18n, final UIEventBus eventBus) {
this.i18n = i18n;
this.eventBus = eventBus;
}
/**
* PostConstruct.
*/
@PostConstruct
public void initialize() { public void initialize() {
removeAllComponents(); removeAllComponents();
consolidatedMessage = ""; consolidatedMessage = "";
@@ -69,8 +66,7 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
} }
private void createActionMessgaeLabel() { private void createActionMessgaeLabel() {
actionMessage = new LabelBuilder().name("").id(UIComponentIdProvider.ACTION_LABEL).visible(false) actionMessage = new LabelBuilder().name("").id(UIComponentIdProvider.ACTION_LABEL).visible(false).buildLabel();
.buildLabel();
actionMessage.addStyleName(SPUIStyleDefinitions.CONFIRM_WINDOW_INFO_BOX); actionMessage.addStyleName(SPUIStyleDefinitions.CONFIRM_WINDOW_INFO_BOX);
} }

View File

@@ -8,8 +8,12 @@
*/ */
package org.eclipse.hawkbit.ui.common.detailslayout; package org.eclipse.hawkbit.ui.common.detailslayout;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity; import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.vaadin.spring.events.EventBus.UIEventBus;
/** /**
* *
@@ -20,6 +24,11 @@ public abstract class AbstractNamedVersionedEntityTableDetailsLayout<T extends N
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected AbstractNamedVersionedEntityTableDetailsLayout(final I18N i18n, final UIEventBus eventBus,
final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState) {
super(i18n, eventBus, permissionChecker, managementUIState);
}
@Override @Override
protected String getName() { protected String getName() {
return HawkbitCommonUtil.getFormattedNameVersion(getSelectedBaseEntity().getName(), return HawkbitCommonUtil.getFormattedNameVersion(getSelectedBaseEntity().getName(),

View File

@@ -10,9 +10,6 @@ package org.eclipse.hawkbit.ui.common.detailslayout;
import java.util.Map; import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
@@ -22,13 +19,14 @@ import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.common.table.BaseUIEntityEvent; import org.eclipse.hawkbit.ui.common.table.BaseUIEntityEvent;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.shared.ui.label.ContentMode;
@@ -48,14 +46,11 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
private static final long serialVersionUID = 4862529368471627190L; private static final long serialVersionUID = 4862529368471627190L;
@Autowired private final I18N i18n;
private I18N i18n;
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final SpPermissionChecker permissionChecker;
private SpPermissionChecker permissionChecker;
private T selectedBaseEntity; private T selectedBaseEntity;
@@ -65,37 +60,38 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
private Button manageMetadataBtn; private Button manageMetadataBtn;
private TabSheet detailsTab; protected TabSheet detailsTab;
private VerticalLayout detailsLayout; private final VerticalLayout detailsLayout;
private VerticalLayout descriptionLayout; private final VerticalLayout descriptionLayout;
private VerticalLayout logLayout; private final VerticalLayout logLayout;
private VerticalLayout attributesLayout; private final VerticalLayout attributesLayout;
/** protected final ManagementUIState managementUIState;
* Initialize components.
*/ protected AbstractTableDetailsLayout(final I18N i18n, final UIEventBus eventBus,
@PostConstruct final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState) {
protected void init() { this.i18n = i18n;
this.eventBus = eventBus;
this.permissionChecker = permissionChecker;
this.managementUIState = managementUIState;
detailsLayout = getTabLayout();
descriptionLayout = getTabLayout();
logLayout = getTabLayout();
attributesLayout = getTabLayout();
createComponents(); createComponents();
buildLayout(); buildLayout();
restoreState();
eventBus.subscribe(this); eventBus.subscribe(this);
} }
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
protected SpPermissionChecker getPermissionChecker() { protected SpPermissionChecker getPermissionChecker() {
return permissionChecker; return permissionChecker;
} }
protected EventBus.SessionEventBus getEventBus() { protected EventBus.UIEventBus getEventBus() {
return eventBus; return eventBus;
} }
@@ -153,7 +149,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
detailsTab.setHeight(90, Unit.PERCENTAGE); detailsTab.setHeight(90, Unit.PERCENTAGE);
detailsTab.addStyleName(SPUIStyleDefinitions.DETAILS_LAYOUT_STYLE); detailsTab.addStyleName(SPUIStyleDefinitions.DETAILS_LAYOUT_STYLE);
detailsTab.setId(getTabSheetId()); detailsTab.setId(getTabSheetId());
addTabs(detailsTab);
} }
private void buildLayout() { private void buildLayout() {
@@ -196,7 +191,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
caption.setValue(HawkbitCommonUtil.getSoftwareModuleName(headerCaption, value)); caption.setValue(HawkbitCommonUtil.getSoftwareModuleName(headerCaption, value));
} }
private void restoreState() { protected void restoreState() {
if (onLoadIsTableRowSelected()) { if (onLoadIsTableRowSelected()) {
populateData(null); populateData(null);
editButton.setEnabled(true); editButton.setEnabled(true);
@@ -276,22 +271,18 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
} }
protected VerticalLayout createLogLayout() { protected VerticalLayout createLogLayout() {
logLayout = getTabLayout();
return logLayout; return logLayout;
} }
protected VerticalLayout createAttributesLayout() { protected VerticalLayout createAttributesLayout() {
attributesLayout = getTabLayout();
return attributesLayout; return attributesLayout;
} }
protected VerticalLayout createDetailsLayout() { protected VerticalLayout createDetailsLayout() {
detailsLayout = getTabLayout();
return detailsLayout; return detailsLayout;
} }
protected VerticalLayout createDescriptionLayout() { protected VerticalLayout createDescriptionLayout() {
descriptionLayout = getTabLayout();
return descriptionLayout; return descriptionLayout;
} }

View File

@@ -24,8 +24,6 @@ import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.IndexedContainer;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.Table; import com.vaadin.ui.Table;
@@ -33,13 +31,9 @@ import com.vaadin.ui.UI;
import com.vaadin.ui.themes.ValoTheme; import com.vaadin.ui.themes.ValoTheme;
/** /**
*
* DistributionSet Metadata details layout. * DistributionSet Metadata details layout.
* *
*/ */
@SpringComponent
@ViewScope
public class DistributionSetMetadatadetailslayout extends Table { public class DistributionSetMetadatadetailslayout extends Table {
private static final long serialVersionUID = 2913758299611837718L; private static final long serialVersionUID = 2913758299611837718L;
@@ -48,27 +42,19 @@ public class DistributionSetMetadatadetailslayout extends Table {
private static final String VIEW = "view"; private static final String VIEW = "view";
private transient DistributionSetManagement distributionSetManagement; private final transient DistributionSetManagement distributionSetManagement;
private DsMetadataPopupLayout dsMetadataPopupLayout; private final DsMetadataPopupLayout dsMetadataPopupLayout;
private SpPermissionChecker permissionChecker; private final SpPermissionChecker permissionChecker;
private transient EntityFactory entityFactory; private final transient EntityFactory entityFactory;
private I18N i18n; private final I18N i18n;
private Long selectedDistSetId; private Long selectedDistSetId;
/** public DistributionSetMetadatadetailslayout(final I18N i18n, final SpPermissionChecker permissionChecker,
*
* @param i18n
* @param permissionChecker
* @param distributionSetManagement
* @param dsMetadataPopupLayout
* @param entityFactory
*/
public void init(final I18N i18n, final SpPermissionChecker permissionChecker,
final DistributionSetManagement distributionSetManagement, final DistributionSetManagement distributionSetManagement,
final DsMetadataPopupLayout dsMetadataPopupLayout, final EntityFactory entityFactory) { final DsMetadataPopupLayout dsMetadataPopupLayout, final EntityFactory entityFactory) {
this.i18n = i18n; this.i18n = i18n;

View File

@@ -26,11 +26,10 @@ import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.vaadin.spring.events.EventBus.SessionEventBus; import org.vaadin.spring.events.EventBus;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.IndexedContainer;
@@ -46,9 +45,6 @@ import com.vaadin.ui.themes.ValoTheme;
/** /**
* Software module details table. * Software module details table.
* *
*
*
*
*/ */
public class SoftwareModuleDetailsTable extends Table { public class SoftwareModuleDetailsTable extends Table {
@@ -64,18 +60,18 @@ public class SoftwareModuleDetailsTable extends Table {
private boolean isTargetAssigned; private boolean isTargetAssigned;
private boolean isUnassignSoftModAllowed; private final boolean isUnassignSoftModAllowed;
private SpPermissionChecker permissionChecker; private final SpPermissionChecker permissionChecker;
private transient DistributionSetManagement distributionSetManagement; private final transient DistributionSetManagement distributionSetManagement;
private I18N i18n; private final I18N i18n;
private transient SessionEventBus eventBus; private final transient EventBus.UIEventBus eventBus;
private transient ManageDistUIState manageDistUIState; private final ManageDistUIState manageDistUIState;
private transient UINotification uiNotification; private final UINotification uiNotification;
/** /**
* Initialize software module table- to be displayed in details layout. * Initialize software module table- to be displayed in details layout.
@@ -94,16 +90,17 @@ public class SoftwareModuleDetailsTable extends Table {
* @param manageDistUIState * @param manageDistUIState
* ManageDistUIState * ManageDistUIState
*/ */
public void init(final I18N i18n, final boolean isUnassignSoftModAllowed, public SoftwareModuleDetailsTable(final I18N i18n, final boolean isUnassignSoftModAllowed,
final SpPermissionChecker permissionChecker, final DistributionSetManagement distributionSetManagement, final SpPermissionChecker permissionChecker, final DistributionSetManagement distributionSetManagement,
final SessionEventBus eventBus, final ManageDistUIState manageDistUIState) { final EventBus.UIEventBus eventBus, final ManageDistUIState manageDistUIState,
final UINotification uiNotification) {
this.i18n = i18n; this.i18n = i18n;
this.isUnassignSoftModAllowed = isUnassignSoftModAllowed; this.isUnassignSoftModAllowed = isUnassignSoftModAllowed;
this.permissionChecker = permissionChecker; this.permissionChecker = permissionChecker;
this.distributionSetManagement = distributionSetManagement; this.distributionSetManagement = distributionSetManagement;
this.manageDistUIState = manageDistUIState; this.manageDistUIState = manageDistUIState;
this.eventBus = eventBus; this.eventBus = eventBus;
this.uiNotification = SpringContextHelper.getBean(UINotification.class); this.uiNotification = uiNotification;
createSwModuleTable(); createSwModuleTable();
} }

View File

@@ -25,7 +25,7 @@ import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.IndexedContainer;
import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope; import com.vaadin.spring.annotation.UIScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Table; import com.vaadin.ui.Table;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
@@ -38,7 +38,7 @@ import com.vaadin.ui.themes.ValoTheme;
*/ */
@SpringComponent @SpringComponent
@ViewScope @UIScope
public class SoftwareModuleMetadatadetailslayout extends Table { public class SoftwareModuleMetadatadetailslayout extends Table {
private static final long serialVersionUID = 2913758299611838818L; private static final long serialVersionUID = 2913758299611838818L;

View File

@@ -18,19 +18,13 @@ import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import com.vaadin.data.Container; import com.vaadin.data.Container;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.IndexedContainer;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.VaadinSessionScope;
import com.vaadin.ui.Table; import com.vaadin.ui.Table;
import com.vaadin.ui.themes.ValoTheme; import com.vaadin.ui.themes.ValoTheme;
/** /**
*
* DistributionSet TargetFilterQuery table * DistributionSet TargetFilterQuery table
* *
*/ */
@SpringComponent
@VaadinSessionScope
public class TargetFilterQueryDetailsTable extends Table { public class TargetFilterQueryDetailsTable extends Table {
private static final long serialVersionUID = 2913758299611837718L; private static final long serialVersionUID = 2913758299611837718L;
@@ -38,13 +32,9 @@ public class TargetFilterQueryDetailsTable extends Table {
private static final String TFQ_NAME = "name"; private static final String TFQ_NAME = "name";
private static final String TFQ_QUERY = "query"; private static final String TFQ_QUERY = "query";
private I18N i18n; private final I18N i18n;
/** public TargetFilterQueryDetailsTable(final I18N i18n) {
*
* @param i18n
*/
public void init(final I18N i18n) {
this.i18n = i18n; this.i18n = i18n;
createTable(); createTable();
} }
@@ -52,7 +42,8 @@ public class TargetFilterQueryDetailsTable extends Table {
/** /**
* Populate software module metadata. * Populate software module metadata.
* *
* @param distributionSet the selected distribution set * @param distributionSet
* the selected distribution set
*/ */
public void populateTableByDistributionSet(final DistributionSet distributionSet) { public void populateTableByDistributionSet(final DistributionSet distributionSet) {
removeAllItems(); removeAllItems();
@@ -60,11 +51,11 @@ public class TargetFilterQueryDetailsTable extends Table {
return; return;
} }
Container dataSource = getContainerDataSource(); final Container dataSource = getContainerDataSource();
List<TargetFilterQuery> filters = distributionSet.getAutoAssignFilters(); final List<TargetFilterQuery> filters = distributionSet.getAutoAssignFilters();
filters.forEach(query -> { filters.forEach(query -> {
Object itemId = dataSource.addItem(); final Object itemId = dataSource.addItem();
Item item = dataSource.getItem(itemId); final Item item = dataSource.getItem(itemId);
item.getItemProperty(TFQ_NAME).setValue(query.getName()); item.getItemProperty(TFQ_NAME).setValue(query.getName());
item.getItemProperty(TFQ_QUERY).setValue(query.getQuery()); item.getItemProperty(TFQ_QUERY).setValue(query.getQuery());
}); });
@@ -103,5 +94,4 @@ public class TargetFilterQueryDetailsTable extends Table {
setColumnHeader(TFQ_QUERY, i18n.get("header.target.filter.query")); setColumnHeader(TFQ_QUERY, i18n.get("header.target.filter.query"));
} }
} }

View File

@@ -14,10 +14,6 @@ import com.vaadin.ui.Button;
/** /**
* Abstract button click behaviour of filter buttons layout. * Abstract button click behaviour of filter buttons layout.
*
*
*
*
*/ */
public abstract class AbstractFilterButtonClickBehaviour implements Serializable { public abstract class AbstractFilterButtonClickBehaviour implements Serializable {

View File

@@ -13,17 +13,15 @@ import static org.eclipse.hawkbit.ui.utils.SPUIDefinitions.NO_TAG_BUTTON_ID;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUITagButtonStyle; import org.eclipse.hawkbit.ui.decorators.SPUITagButtonStyle;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropHandler;
@@ -45,28 +43,19 @@ public abstract class AbstractFilterButtons extends Table {
protected static final String FILTER_BUTTON_COLUMN = "filterButton"; protected static final String FILTER_BUTTON_COLUMN = "filterButton";
@Autowired protected transient EventBus.UIEventBus eventBus;
protected transient EventBus.SessionEventBus eventBus;
private AbstractFilterButtonClickBehaviour filterButtonClickBehaviour; protected final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour;
protected AbstractFilterButtons(final UIEventBus eventBus,
final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
this.eventBus = eventBus;
/**
* Initialize layout of filter buttons.
*
* @param filterButtonClickBehaviour
* click behaviour of filter buttons.
*/
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
this.filterButtonClickBehaviour = filterButtonClickBehaviour; this.filterButtonClickBehaviour = filterButtonClickBehaviour;
createTable(); createTable();
eventBus.subscribe(this); eventBus.subscribe(this);
} }
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
private void createTable() { private void createTable() {
setImmediate(true); setImmediate(true);
setId(getButtonsTableId()); setId(getButtonsTableId());

View File

@@ -12,9 +12,10 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
@@ -25,20 +26,14 @@ import com.vaadin.ui.VerticalLayout;
/** /**
* Parent class for filter button header layout. * Parent class for filter button header layout.
*
*
*
*
*/ */
public abstract class AbstractFilterHeader extends VerticalLayout { public abstract class AbstractFilterHeader extends VerticalLayout {
private static final long serialVersionUID = -1388340600522323332L; private static final long serialVersionUID = -1388340600522323332L;
@Autowired
protected SpPermissionChecker permChecker; protected SpPermissionChecker permChecker;
@Autowired protected transient EventBus.UIEventBus eventBus;
protected transient EventBus.SessionEventBus eventBus;
private Label title; private Label title;
@@ -46,10 +41,12 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
private Button hideIcon; private Button hideIcon;
/** protected final I18N i18n;
* Initialize the header layout.
*/ protected AbstractFilterHeader(final SpPermissionChecker permChecker, final UIEventBus eventBus, final I18N i18n) {
protected void init() { this.permChecker = permChecker;
this.eventBus = eventBus;
this.i18n = i18n;
createComponents(); createComponents();
buildLayout(); buildLayout();
} }

View File

@@ -15,35 +15,25 @@ import com.vaadin.ui.VerticalLayout;
/** /**
* Parent class for filter button layout. * Parent class for filter button layout.
*
*
*
*
*/ */
public abstract class AbstractFilterLayout extends VerticalLayout { public abstract class AbstractFilterLayout extends VerticalLayout {
private static final long serialVersionUID = 9190616426688385851L; private static final long serialVersionUID = 9190616426688385851L;
private AbstractFilterHeader filterHeader; private final AbstractFilterHeader filterHeader;
private AbstractFilterButtons filterButtons; private final AbstractFilterButtons filterButtons;
/** protected AbstractFilterLayout(final AbstractFilterHeader filterHeader, final AbstractFilterButtons filterButtons) {
* Initialize the artifact details layout.
*/
protected void init(final AbstractFilterHeader filterHeader, final AbstractFilterButtons filterButtons,
final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
this.filterHeader = filterHeader; this.filterHeader = filterHeader;
this.filterButtons = filterButtons; this.filterButtons = filterButtons;
filterButtons.init(filterButtonClickBehaviour);
buildLayout(); buildLayout();
restoreState();
} }
private void buildLayout() { private void buildLayout() {
setWidth(SPUIDefinitions.FILTER_BY_TYPE_WIDTH, Unit.PIXELS); setWidth(SPUIDefinitions.FILTER_BY_TYPE_WIDTH, Unit.PIXELS);
setStyleName("filter-btns-main-layout"); setStyleName("filter-btns-main-layout");
setHeight(100.0f, Unit.PERCENTAGE); setHeight(100.0F, Unit.PERCENTAGE);
setSpacing(false); setSpacing(false);
setMargin(false); setMargin(false);
@@ -52,10 +42,10 @@ public abstract class AbstractFilterLayout extends VerticalLayout {
setComponentAlignment(filterHeader, Alignment.TOP_CENTER); setComponentAlignment(filterHeader, Alignment.TOP_CENTER);
setComponentAlignment(filterButtons, Alignment.TOP_CENTER); setComponentAlignment(filterButtons, Alignment.TOP_CENTER);
setExpandRatio(filterButtons, 1.0f); setExpandRatio(filterButtons, 1.0F);
} }
private void restoreState() { protected void restoreState() {
if (onLoadIsTypeFilterIsClosed()) { if (onLoadIsTypeFilterIsClosed()) {
setVisible(false); setVisible(false);
} }

View File

@@ -25,12 +25,6 @@ public abstract class AbstractFilterMultiButtonClick extends AbstractFilterButto
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected final transient Set<Button> alreadyClickedButtons = new HashSet<>(); protected final transient Set<Button> alreadyClickedButtons = new HashSet<>();
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.layouts.SPFilterButtonClick#
* processFilterButtonClick(com.vaadin.ui. Button.ClickEvent)
*/
@Override @Override
public void processFilterButtonClick(final ClickEvent event) { public void processFilterButtonClick(final ClickEvent event) {
final Button clickedButton = (Button) event.getComponent(); final Button clickedButton = (Button) event.getComponent();
@@ -46,12 +40,6 @@ public abstract class AbstractFilterMultiButtonClick extends AbstractFilterButto
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.layouts.SPFilterButtonClickBehaviour#
* setDefaultClickedButton(com.vaadin .ui.Button)
*/
@Override @Override
protected void setDefaultClickedButton(final Button button) { protected void setDefaultClickedButton(final Button button) {
if (button != null) { if (button != null) {
@@ -60,10 +48,6 @@ public abstract class AbstractFilterMultiButtonClick extends AbstractFilterButto
} }
} }
/**
* @param clickedButton
* @return
*/
private boolean isButtonUnClicked(final Button clickedButton) { private boolean isButtonUnClicked(final Button clickedButton) {
return !alreadyClickedButtons.isEmpty() && alreadyClickedButtons.contains(clickedButton); return !alreadyClickedButtons.isEmpty() && alreadyClickedButtons.contains(clickedButton);
} }

View File

@@ -16,9 +16,6 @@ import com.vaadin.ui.Button.ClickEvent;
/** /**
* Abstract Single button click behaviour of filter buttons layout. * Abstract Single button click behaviour of filter buttons layout.
* *
*
*
*
*/ */
public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButtonClickBehaviour { public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButtonClickBehaviour {
@@ -26,12 +23,6 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
private Button alreadyClickedButton; private Button alreadyClickedButton;
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.layouts.SPFilterButtonClick#
* processFilterButtonClick(com.vaadin.ui. Button.ClickEvent)
*/
@Override @Override
protected void processFilterButtonClick(final ClickEvent event) { protected void processFilterButtonClick(final ClickEvent event) {
final Button clickedButton = (Button) event.getComponent(); final Button clickedButton = (Button) event.getComponent();
@@ -54,20 +45,10 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
} }
} }
/**
* @param clickedButton
* @return
*/
private boolean isButtonUnClicked(final Button clickedButton) { private boolean isButtonUnClicked(final Button clickedButton) {
return alreadyClickedButton != null && alreadyClickedButton.equals(clickedButton); return alreadyClickedButton != null && alreadyClickedButton.equals(clickedButton);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.layouts.SPFilterButtonClickBehaviour#
* setDefaultClickedButton(com.vaadin .ui.Button)
*/
@Override @Override
protected void setDefaultClickedButton(final Button button) { protected void setDefaultClickedButton(final Button button) {
alreadyClickedButton = button; alreadyClickedButton = button;
@@ -76,17 +57,10 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
} }
} }
/**
* @return the alreadyClickedButton
*/
public Button getAlreadyClickedButton() { public Button getAlreadyClickedButton() {
return alreadyClickedButton; return alreadyClickedButton;
} }
/**
* @param alreadyClickedButton
* the alreadyClickedButton to set
*/
public void setAlreadyClickedButton(final Button alreadyClickedButton) { public void setAlreadyClickedButton(final Button alreadyClickedButton) {
this.alreadyClickedButton = alreadyClickedButton; this.alreadyClickedButton = alreadyClickedButton;
} }

View File

@@ -8,9 +8,6 @@
*/ */
package org.eclipse.hawkbit.ui.common.footer; package org.eclipse.hawkbit.ui.common.footer;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder; import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -21,8 +18,8 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropHandler;
@@ -48,17 +45,13 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
private static final long serialVersionUID = -6047975388519155509L; private static final long serialVersionUID = -6047975388519155509L;
@Autowired
protected I18N i18n; protected I18N i18n;
@Autowired
protected SpPermissionChecker permChecker; protected SpPermissionChecker permChecker;
@Autowired protected transient EventBus.UIEventBus eventBus;
protected transient EventBus.SessionEventBus eventBus;
@Autowired protected UINotification notification;
protected transient UINotification notification;
private DragAndDropWrapper deleteWrapper; private DragAndDropWrapper deleteWrapper;
@@ -68,30 +61,30 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
private Button bulkUploadStatusButton; private Button bulkUploadStatusButton;
/** protected AbstractDeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker,
* Initialize. final UIEventBus eventBus, final UINotification notification) {
*/ this.i18n = i18n;
@PostConstruct this.permChecker = permChecker;
this.eventBus = eventBus;
this.notification = notification;
eventBus.subscribe(this);
}
protected void init() { protected void init() {
if (hasCountMessage() || hasDeletePermission() || hasUpdatePermission() || hasBulkUploadPermission()) { if (hasCountMessage() || hasDeletePermission() || hasUpdatePermission() || hasBulkUploadPermission()) {
createComponents(); createComponents();
buildLayout(); buildLayout();
reload(); reload();
} }
eventBus.subscribe(this);
} }
@PreDestroy protected void reload() {
void destroy() {
eventBus.unsubscribe(this);
}
private void reload() {
restoreActionCount(); restoreActionCount();
restoreBulkUploadStatusCount(); restoreBulkUploadStatusCount();
} }
private void createComponents() { protected void createComponents() {
if (hasDeletePermission()) { if (hasDeletePermission()) {
deleteWrapper = createDeleteWrapperLayout(); deleteWrapper = createDeleteWrapperLayout();
} }
@@ -103,7 +96,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
} }
} }
private void buildLayout() { protected void buildLayout() {
final HorizontalLayout dropHintLayout = new HorizontalLayout(); final HorizontalLayout dropHintLayout = new HorizontalLayout();
if (hasCountMessage()) { if (hasCountMessage()) {
dropHintLayout.addComponent(getCountMessageLabel()); dropHintLayout.addComponent(getCountMessageLabel());

View File

@@ -8,13 +8,11 @@
*/ */
package org.eclipse.hawkbit.ui.common.grid; package org.eclipse.hawkbit.ui.common.grid;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.data.Container; import com.vaadin.data.Container;
import com.vaadin.data.Container.Indexed; import com.vaadin.data.Container.Indexed;
@@ -27,19 +25,18 @@ import com.vaadin.ui.Grid;
public abstract class AbstractGrid extends Grid { public abstract class AbstractGrid extends Grid {
private static final long serialVersionUID = 4856562746502217630L; private static final long serialVersionUID = 4856562746502217630L;
@Autowired
protected I18N i18n;
@Autowired protected final I18N i18n;
protected transient EventBus.SessionEventBus eventBus;
protected final transient EventBus.UIEventBus eventBus;
protected final SpPermissionChecker permissionChecker;
protected AbstractGrid(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker) {
this.i18n = i18n;
this.eventBus = eventBus;
this.permissionChecker = permissionChecker;
/**
* Initialize the components.
*/
@PostConstruct
protected void init() {
setSizeFull(); setSizeFull();
setImmediate(true); setImmediate(true);
setId(getGridId()); setId(getGridId());
@@ -48,13 +45,8 @@ public abstract class AbstractGrid extends Grid {
addNewContainerDS(); addNewContainerDS();
eventBus.subscribe(this); eventBus.subscribe(this);
} }
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
public void addNewContainerDS() { private void addNewContainerDS() {
final Container container = createContainer(); final Container container = createContainer();
setContainerDataSource((Indexed) container); setContainerDataSource((Indexed) container);
addContainerProperties(); addContainerProperties();

View File

@@ -8,10 +8,13 @@
*/ */
package org.eclipse.hawkbit.ui.common.grid; package org.eclipse.hawkbit.ui.common.grid;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -42,7 +45,17 @@ public abstract class AbstractGridHeader extends VerticalLayout {
private Button closeButton; private Button closeButton;
protected void init() { protected final SpPermissionChecker permissionChecker;
protected final RolloutUIState rolloutUIState;
protected final I18N i18n;
protected AbstractGridHeader(final SpPermissionChecker permissionChecker, final RolloutUIState rolloutUIState,
final I18N i18n) {
this.permissionChecker = permissionChecker;
this.rolloutUIState = rolloutUIState;
this.i18n = i18n;
createComponents(); createComponents();
buildLayout(); buildLayout();
restoreState(); restoreState();

View File

@@ -18,27 +18,24 @@ import com.vaadin.ui.VerticalLayout;
/** /**
* *
* Abstract grid layout class which builds layout with grid * Abstract grid layout class which builds layout with grid {@link AbstractGrid}
* {@link AbstractGrid} and table header * and table header {@link AbstractGridHeader}.
* {@link AbstractGridHeader}.
* *
*/ */
public abstract class AbstractGridLayout extends VerticalLayout { public abstract class AbstractGridLayout extends VerticalLayout {
private static final long serialVersionUID = 8611248179949245460L; private static final long serialVersionUID = 8611248179949245460L;
private AbstractGridHeader tableHeader; private final AbstractGridHeader tableHeader;
private AbstractGrid grid;
protected final AbstractGrid grid;
protected void init(final AbstractGridHeader tableHeader,final AbstractGrid grid) { protected AbstractGridLayout(final AbstractGridHeader tableHeader, final AbstractGrid grid) {
this.tableHeader = tableHeader; this.tableHeader = tableHeader;
this.grid = grid; this.grid = grid;
buildLayout();
} }
private void buildLayout() { protected void buildLayout() {
setSizeFull(); setSizeFull();
setSpacing(true); setSpacing(true);
setMargin(false); setMargin(false);
@@ -54,18 +51,17 @@ public abstract class AbstractGridLayout extends VerticalLayout {
tableHeaderLayout.setComponentAlignment(tableHeader, Alignment.TOP_CENTER); tableHeaderLayout.setComponentAlignment(tableHeader, Alignment.TOP_CENTER);
tableHeaderLayout.addComponent(grid); tableHeaderLayout.addComponent(grid);
tableHeaderLayout.setComponentAlignment(grid, Alignment.TOP_CENTER); tableHeaderLayout.setComponentAlignment(grid, Alignment.TOP_CENTER);
tableHeaderLayout.setExpandRatio(grid, 1.0f); tableHeaderLayout.setExpandRatio(grid, 1.0F);
addComponent(tableHeaderLayout); addComponent(tableHeaderLayout);
setComponentAlignment(tableHeaderLayout, Alignment.TOP_CENTER); setComponentAlignment(tableHeaderLayout, Alignment.TOP_CENTER);
setExpandRatio(tableHeaderLayout, 1.0f); setExpandRatio(tableHeaderLayout, 1.0F);
if (hasCountMessage()) { if (hasCountMessage()) {
final HorizontalLayout rolloutGroupTargetsCountLayout = createCountMessageComponent(); final HorizontalLayout rolloutGroupTargetsCountLayout = createCountMessageComponent();
addComponent(rolloutGroupTargetsCountLayout); addComponent(rolloutGroupTargetsCountLayout);
setComponentAlignment(rolloutGroupTargetsCountLayout, Alignment.BOTTOM_CENTER); setComponentAlignment(rolloutGroupTargetsCountLayout, Alignment.BOTTOM_CENTER);
} }
} }
private HorizontalLayout createCountMessageComponent() { private HorizontalLayout createCountMessageComponent() {

View File

@@ -11,8 +11,11 @@ package org.eclipse.hawkbit.ui.common.table;
import java.util.List; import java.util.List;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity; import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn; import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DragAndDropEvent;
@@ -30,12 +33,8 @@ public abstract class AbstractNamedVersionTable<E extends NamedVersionedEntity,
private static final long serialVersionUID = 780050712209750719L; private static final long serialVersionUID = 780050712209750719L;
/** protected AbstractNamedVersionTable(final UIEventBus eventBus, final I18N i18n, final UINotification notification) {
* Initialize the component. super(eventBus, i18n, notification);
*/
@Override
protected void init() {
super.init();
setMultiSelect(true); setMultiSelect(true);
setSelectable(true); setSelectable(true);
} }

View File

@@ -15,9 +15,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState; import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
@@ -28,8 +25,8 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn; import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@@ -61,20 +58,16 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
protected static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed"; protected static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
@Autowired protected transient EventBus.UIEventBus eventBus;
protected transient EventBus.SessionEventBus eventBus;
@Autowired
protected I18N i18n; protected I18N i18n;
@Autowired
protected UINotification notification; protected UINotification notification;
/** protected AbstractTable(final UIEventBus eventBus, final I18N i18n, final UINotification notification) {
* Initialize the components. this.eventBus = eventBus;
*/ this.i18n = i18n;
@PostConstruct this.notification = notification;
protected void init() {
setStyleName("sp-table"); setStyleName("sp-table");
setSizeFull(); setSizeFull();
setImmediate(true); setImmediate(true);
@@ -84,22 +77,13 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
setSortEnabled(false); setSortEnabled(false);
setId(getTableId()); setId(getTableId());
addCustomGeneratedColumns(); addCustomGeneratedColumns();
addNewContainerDS();
setColumnProperties();
setDefault(); setDefault();
addValueChangeListener(event -> onValueChange()); addValueChangeListener(event -> onValueChange());
selectRow();
setPageLength(SPUIDefinitions.PAGE_SIZE); setPageLength(SPUIDefinitions.PAGE_SIZE);
setDataAvailable(getContainerDataSource().size() != 0);
eventBus.subscribe(this); eventBus.subscribe(this);
} }
@PreDestroy
protected void destroy() {
eventBus.unsubscribe(this);
}
/** /**
* Gets the selected item id or in multiselect mode a set of selected ids. * Gets the selected item id or in multiselect mode a set of selected ids.
* *
@@ -148,7 +132,7 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
setDropHandler(getTableDropHandler()); setDropHandler(getTableDropHandler());
} }
private void addNewContainerDS() { protected void addNewContainerDS() {
final Container container = createContainer(); final Container container = createContainer();
addContainerProperties(container); addContainerProperties(container);
setContainerDataSource(container); setContainerDataSource(container);
@@ -178,7 +162,7 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
} }
} }
private void setColumnProperties() { protected void setColumnProperties() {
final List<TableColumn> columnList = getTableVisibleColumns(); final List<TableColumn> columnList = getTableVisibleColumns();
final List<Object> swColumnIds = new ArrayList<>(); final List<Object> swColumnIds = new ArrayList<>();
for (final TableColumn column : columnList) { for (final TableColumn column : columnList) {
@@ -249,9 +233,9 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
protected void onBaseEntityEvent(final BaseUIEntityEvent<E> event) { protected void onBaseEntityEvent(final BaseUIEntityEvent<E> event) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) { if (BaseEntityEventType.MINIMIZED == event.getEventType()) {
UI.getCurrent().access(() -> applyMinTableSettings()); UI.getCurrent().access(this::applyMinTableSettings);
} else if (BaseEntityEventType.MAXIMIZED == event.getEventType()) { } else if (BaseEntityEventType.MAXIMIZED == event.getEventType()) {
UI.getCurrent().access(() -> applyMaxTableSettings()); UI.getCurrent().access(this::applyMaxTableSettings);
} else if (BaseEntityEventType.NEW_ENTITY == event.getEventType()) { } else if (BaseEntityEventType.NEW_ENTITY == event.getEventType()) {
UI.getCurrent().access(() -> addEntity(event.getEntity())); UI.getCurrent().access(() -> addEntity(event.getEntity()));
} }

View File

@@ -8,21 +8,21 @@
*/ */
package org.eclipse.hawkbit.ui.common.table; package org.eclipse.hawkbit.ui.common.table;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropHandler;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
@@ -41,14 +41,11 @@ public abstract class AbstractTableHeader extends VerticalLayout {
private static final long serialVersionUID = 4881626370291837175L; private static final long serialVersionUID = 4881626370291837175L;
@Autowired
protected I18N i18n; protected I18N i18n;
@Autowired
protected SpPermissionChecker permChecker; protected SpPermissionChecker permChecker;
@Autowired protected transient EventBus.UIEventBus eventbus;
protected transient EventBus.SessionEventBus eventbus;
private Label headerCaption; private Label headerCaption;
@@ -64,26 +61,27 @@ public abstract class AbstractTableHeader extends VerticalLayout {
private HorizontalLayout filterDroppedInfo; private HorizontalLayout filterDroppedInfo;
private DragAndDropWrapper dropFilterLayout;
private Button bulkUploadIcon; private Button bulkUploadIcon;
/** protected final ManagementUIState managementUIState;
* Initialze components. protected final ManageDistUIState manageDistUIstate;
*/ protected final ArtifactUploadState artifactUploadState;
@PostConstruct
protected void init() { protected AbstractTableHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus,
final ManagementUIState managementUIState, final ManageDistUIState manageDistUIstate,
final ArtifactUploadState artifactUploadState) {
this.i18n = i18n;
this.permChecker = permChecker;
this.eventbus = eventbus;
this.managementUIState = managementUIState;
this.manageDistUIstate = manageDistUIstate;
this.artifactUploadState = artifactUploadState;
createComponents(); createComponents();
buildLayout(); buildLayout();
restoreState(); restoreState();
eventbus.subscribe(this); eventbus.subscribe(this);
} }
@PreDestroy
void destroy() {
eventbus.unsubscribe(this);
}
private void createComponents() { private void createComponents() {
headerCaption = createHeaderCaption(); headerCaption = createHeaderCaption();
searchField = new TextFieldBuilder(getSearchBoxId()).createSearchField(event -> searchBy(event.getText())); searchField = new TextFieldBuilder(getSearchBoxId()).createSearchField(event -> searchBy(event.getText()));
@@ -181,7 +179,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
filterDroppedInfo.setHeightUndefined(); filterDroppedInfo.setHeightUndefined();
filterDroppedInfo.setSizeUndefined(); filterDroppedInfo.setSizeUndefined();
displayFilterDropedInfoOnLoad(); displayFilterDropedInfoOnLoad();
dropFilterLayout = new DragAndDropWrapper(filterDroppedInfo); final DragAndDropWrapper dropFilterLayout = new DragAndDropWrapper(filterDroppedInfo);
dropFilterLayout.setId(getDropFilterId()); dropFilterLayout.setId(getDropFilterId());
dropFilterLayout.setDropHandler(getDropFilterHandler()); dropFilterLayout.setDropHandler(getDropFilterHandler());

View File

@@ -38,6 +38,8 @@ public abstract class AbstractTableLayout extends VerticalLayout {
this.table = table; this.table = table;
this.detailsLayout = detailsLayout; this.detailsLayout = detailsLayout;
buildLayout(); buildLayout();
table.selectRow();
} }
private void buildLayout() { private void buildLayout() {

View File

@@ -13,9 +13,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
@@ -25,8 +22,8 @@ import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.tokenfield.TokenField; import org.vaadin.tokenfield.TokenField;
import org.vaadin.tokenfield.TokenField.InsertPosition; import org.vaadin.tokenfield.TokenField.InsertPosition;
@@ -65,19 +62,14 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
protected CssLayout tokenLayout = new CssLayout(); protected CssLayout tokenLayout = new CssLayout();
@Autowired
protected SpPermissionChecker checker; protected SpPermissionChecker checker;
@Autowired
protected I18N i18n; protected I18N i18n;
@Autowired
protected UINotification uinotification; protected UINotification uinotification;
@Autowired protected transient EventBus.UIEventBus eventBus;
protected transient EventBus.SessionEventBus eventBus;
@Autowired
protected ManagementUIState managementUIState; protected ManagementUIState managementUIState;
// BaseEntity implements Serializable so this entity is serializable. Maybe // BaseEntity implements Serializable so this entity is serializable. Maybe
@@ -85,18 +77,18 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
@SuppressWarnings("squid:S1948") @SuppressWarnings("squid:S1948")
protected T selectedEntity; protected T selectedEntity;
@PostConstruct protected AbstractTagToken(final SpPermissionChecker checker, final I18N i18n, final UINotification uinotification,
protected void init() { final UIEventBus eventBus, final ManagementUIState managementUIState) {
this.checker = checker;
this.i18n = i18n;
this.uinotification = uinotification;
this.eventBus = eventBus;
this.managementUIState = managementUIState;
createTokenField(); createTokenField();
checkIfTagAssignedIsAllowed(); checkIfTagAssignedIsAllowed();
eventBus.subscribe(this); eventBus.subscribe(this);
} }
@PreDestroy
protected void destroy() {
eventBus.unsubscribe(this);
}
protected void onBaseEntityEvent(final BaseUIEntityEvent<T> baseEntityEvent) { protected void onBaseEntityEvent(final BaseUIEntityEvent<T> baseEntityEvent) {
if (BaseEntityEventType.SELECTED_ENTITY != baseEntityEvent.getEventType()) { if (BaseEntityEventType.SELECTED_ENTITY != baseEntityEvent.getEventType()) {
return; return;

View File

@@ -10,12 +10,16 @@ package org.eclipse.hawkbit.ui.common.tagdetails;
import java.util.List; import java.util.List;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdateEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer; import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer; import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -31,24 +35,30 @@ public abstract class AbstractTargetTagToken<T extends BaseEntity> extends Abstr
private static final long serialVersionUID = 7772876588903171201L; private static final long serialVersionUID = 7772876588903171201L;
@Autowired protected final transient TagManagement tagManagement;
protected transient TagManagement tagManagement;
@EventBusListenerMethod(scope = EventScope.SESSION) protected AbstractTargetTagToken(final SpPermissionChecker checker, final I18N i18n,
final UINotification uinotification, final UIEventBus eventBus, final ManagementUIState managementUIState,
final TagManagement tagManagement) {
super(checker, i18n, uinotification, eventBus, managementUIState);
this.tagManagement = tagManagement;
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEventTargetTagCreated(final TargetTagCreatedEventContainer container) { void onEventTargetTagCreated(final TargetTagCreatedEventContainer container) {
container.getEvents().stream().map(event -> event.getEntity()) container.getEvents().stream().map(event -> event.getEntity())
.forEach(tag -> setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour())); .forEach(tag -> setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour()));
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onTargetTagDeletedEvent(final TargetTagDeletedEventContainer container) { void onTargetTagDeletedEvent(final TargetTagDeletedEventContainer container) {
container.getEvents().stream().map(event -> getTagIdByTagName(event.getEntityId())) container.getEvents().stream().map(event -> getTagIdByTagName(event.getEntityId()))
.forEach(this::removeTagFromCombo); .forEach(this::removeTagFromCombo);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onTargetTagUpdateEvent(final List<TargetTagUpdateEvent> events) { void onTargetTagUpdateEvent(final List<TargetTagUpdateEvent> events) {
events.stream().map(event -> event.getEntity()).forEach(entity -> { events.stream().map(TargetTagUpdateEvent::getEntity).forEach(entity -> {
final Item item = container.getItem(entity.getId()); final Item item = container.getItem(entity.getId());
if (item != null) { if (item != null) {
updateItem(entity.getName(), entity.getColour(), item); updateItem(entity.getName(), entity.getColour(), item);

View File

@@ -12,43 +12,50 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult; import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.push.DistributionSetTagCreatedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetTagCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetTagDeletedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetTagDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetTagUpdatedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetTagUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/** /**
* Implementation of target/ds tag token layout. * Implementation of target/ds tag token layout.
* *
*/ */
@SpringComponent
@ViewScope
public class DistributionTagToken extends AbstractTagToken<DistributionSet> { public class DistributionTagToken extends AbstractTagToken<DistributionSet> {
private static final long serialVersionUID = -8022738301736043396L; private static final long serialVersionUID = -8022738301736043396L;
@Autowired
private transient TagManagement tagManagement;
@Autowired private final transient TagManagement tagManagement;
private transient DistributionSetManagement distributionSetManagement;
private final transient DistributionSetManagement distributionSetManagement;
// To Be Done : have to set this value based on view??? // To Be Done : have to set this value based on view???
private static final Boolean NOTAGS_SELECTED = Boolean.FALSE; private static final Boolean NOTAGS_SELECTED = Boolean.FALSE;
public DistributionTagToken(final SpPermissionChecker checker, final I18N i18n, final UINotification uinotification,
final UIEventBus eventBus, final ManagementUIState managementUIState, final TagManagement tagManagement,
final DistributionSetManagement distributionSetManagement) {
super(checker, i18n, uinotification, eventBus, managementUIState);
this.tagManagement = tagManagement;
this.distributionSetManagement = distributionSetManagement;
}
@Override @Override
protected String getTagStyleName() { protected String getTagStyleName() {
return "distribution-tag-"; return "distribution-tag-";
@@ -111,25 +118,25 @@ public class DistributionTagToken extends AbstractTagToken<DistributionSet> {
} }
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionTableEvent distributionTableEvent) { void onEvent(final DistributionTableEvent distributionTableEvent) {
onBaseEntityEvent(distributionTableEvent); onBaseEntityEvent(distributionTableEvent);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedEventContainer eventContainer) { void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedEventContainer eventContainer) {
eventContainer.getEvents().stream().map(event -> event.getEntity()) eventContainer.getEvents().stream().map(event -> event.getEntity())
.forEach(distributionSetTag -> setContainerPropertValues(distributionSetTag.getId(), .forEach(distributionSetTag -> setContainerPropertValues(distributionSetTag.getId(),
distributionSetTag.getName(), distributionSetTag.getColour())); distributionSetTag.getName(), distributionSetTag.getColour()));
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEventContainer eventContainer) { void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEventContainer eventContainer) {
eventContainer.getEvents().stream().map(event -> getTagIdByTagName(event.getEntityId())) eventContainer.getEvents().stream().map(event -> getTagIdByTagName(event.getEntityId()))
.forEach(this::removeTagFromCombo); .forEach(this::removeTagFromCombo);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdatedEventContainer eventContainer) { void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdatedEventContainer eventContainer) {
eventContainer.getEvents().stream().map(event -> event.getEntity()).forEach(entity -> { eventContainer.getEvents().stream().map(event -> event.getEntity()).forEach(entity -> {
final Item item = container.getItem(entity.getId()); final Item item = container.getItem(entity.getId());

View File

@@ -11,27 +11,27 @@ package org.eclipse.hawkbit.ui.common.tagdetails;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/** /**
* Implementation of Target tag token. * Implementation of Target tag token.
* *
* *
*/ */
@SpringComponent
@ViewScope
public class TargetTagToken extends AbstractTargetTagToken<Target> { public class TargetTagToken extends AbstractTargetTagToken<Target> {
private static final long serialVersionUID = 7124887018280196721L; private static final long serialVersionUID = 7124887018280196721L;
@@ -39,8 +39,14 @@ public class TargetTagToken extends AbstractTargetTagToken<Target> {
// To Be Done : have to set this value based on view??? // To Be Done : have to set this value based on view???
private static final Boolean NOTAGS_SELECTED = Boolean.FALSE; private static final Boolean NOTAGS_SELECTED = Boolean.FALSE;
@Autowired private final transient TargetManagement targetManagement;
private transient TargetManagement targetManagement;
public TargetTagToken(final SpPermissionChecker checker, final I18N i18n, final UINotification uinotification,
final UIEventBus eventBus, final ManagementUIState managementUIState, final TagManagement tagManagement,
final TargetManagement targetManagement) {
super(checker, i18n, uinotification, eventBus, managementUIState, tagManagement);
this.targetManagement = targetManagement;
}
@Override @Override
protected String getTagStyleName() { protected String getTagStyleName() {
@@ -136,7 +142,7 @@ public class TargetTagToken extends AbstractTargetTagToken<Target> {
return false; return false;
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final TargetTableEvent targetTableEvent) { void onEvent(final TargetTableEvent targetTableEvent) {
onBaseEntityEvent(targetTableEvent); onBaseEntityEvent(targetTableEvent);
} }

View File

@@ -19,9 +19,6 @@ import com.vaadin.ui.VerticalLayout;
/** /**
* Distribution set panel for Target. * Distribution set panel for Target.
*
*
*
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class DistributionSetInfoPanel extends Panel { public class DistributionSetInfoPanel extends Panel {
@@ -38,9 +35,8 @@ public class DistributionSetInfoPanel extends Panel {
* @param style2 * @param style2
* as String * as String
*/ */
public DistributionSetInfoPanel(final DistributionSet distributionSet, final String caption, final String style1, DistributionSetInfoPanel(final DistributionSet distributionSet, final String caption, final String style1,
final String style2) { final String style2) {
super();
setImmediate(false); setImmediate(false);
decorate(distributionSet, caption, style1, style2); decorate(distributionSet, caption, style1, style2);
} }

View File

@@ -21,9 +21,6 @@ import com.vaadin.ui.VerticalLayout;
/** /**
* Attributes Vertical layout for Target. * Attributes Vertical layout for Target.
*
*
*
*/ */
public class SPTargetAttributesLayout { public class SPTargetAttributesLayout {
private final VerticalLayout targetAttributesLayout; private final VerticalLayout targetAttributesLayout;
@@ -35,7 +32,7 @@ public class SPTargetAttributesLayout {
* controller attributes * controller attributes
* *
*/ */
public SPTargetAttributesLayout(final Map<String, String> controllerAttibs) { SPTargetAttributesLayout(final Map<String, String> controllerAttibs) {
targetAttributesLayout = new VerticalLayout(); targetAttributesLayout = new VerticalLayout();
targetAttributesLayout.setSpacing(true); targetAttributesLayout.setSpacing(true);
targetAttributesLayout.setMargin(true); targetAttributesLayout.setMargin(true);

View File

@@ -13,29 +13,11 @@ import com.vaadin.ui.Button;
/** /**
* Basic button for SPUI. Any commonality can be decorated. * Basic button for SPUI. Any commonality can be decorated.
*
*
*
*/ */
public class SPUIButton extends Button { public class SPUIButton extends Button {
/**
* ID.
*/
private static final long serialVersionUID = -7327726430436273739L; private static final long serialVersionUID = -7327726430436273739L;
/** SPUIButton(final String id, final String buttonName, final String buttonDesc) {
* Parametric constructor.
*
* @param id
* as String
* @param buttonName
* as String
* @param buttonDesc
* as String
*/
public SPUIButton(final String id, final String buttonName, final String buttonDesc) {
super(buttonName); super(buttonName);
setDescription(buttonDesc); setDescription(buttonDesc);
setImmediate(false); setImmediate(false);
@@ -50,7 +32,7 @@ public class SPUIButton extends Button {
* @param icon * @param icon
* as Resource * as Resource
*/ */
public void togleIcon(Resource icon) { public void togleIcon(final Resource icon) {
setIcon(icon); setIcon(icon);
} }
} }

View File

@@ -13,32 +13,13 @@ import com.vaadin.ui.themes.ValoTheme;
/** /**
* ComboBox with required style. * ComboBox with required style.
*
*
*
*/ */
public class SPUICheckBox extends CheckBox { public class SPUICheckBox extends CheckBox {
private static final long serialVersionUID = 2270323611612189225L; private static final long serialVersionUID = 2270323611612189225L;
/** SPUICheckBox(final String caption, final String style, final String styleName, final boolean required,
* Parametric constructor to decorate.
*
* @param caption
* as caption for checkbox
* @param style
* style of the CheckBox
* @param styleName
* styleName of the CheckBox
* @param required
* required check for Checkbox
* @param data
* data of the CheckBox
*
*/
public SPUICheckBox(final String caption, final String style, final String styleName, final boolean required,
final String data) { final String data) {
super();
decorate(caption, style, styleName, required, data); decorate(caption, style, styleName, required, data);
} }

View File

@@ -8,14 +8,24 @@
*/ */
package org.eclipse.hawkbit.ui.distributions; package org.eclipse.hawkbit.ui.distributions;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.HawkbitUI; import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.distributions.disttype.DSTypeFilterLayout; import org.eclipse.hawkbit.ui.distributions.disttype.DSTypeFilterLayout;
import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTableLayout; import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTableLayout;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.DragEvent; import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.footer.DSDeleteActionsLayout; import org.eclipse.hawkbit.ui.distributions.footer.DSDeleteActionsLayout;
import org.eclipse.hawkbit.ui.distributions.smtable.SwModuleTableLayout; import org.eclipse.hawkbit.ui.distributions.smtable.SwModuleTableLayout;
@@ -27,6 +37,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -37,7 +48,7 @@ import com.vaadin.server.Page;
import com.vaadin.server.Page.BrowserWindowResizeEvent; import com.vaadin.server.Page.BrowserWindowResizeEvent;
import com.vaadin.server.Page.BrowserWindowResizeListener; import com.vaadin.server.Page.BrowserWindowResizeListener;
import com.vaadin.spring.annotation.SpringView; import com.vaadin.spring.annotation.SpringView;
import com.vaadin.spring.annotation.ViewScope; import com.vaadin.spring.annotation.UIScope;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.GridLayout; import com.vaadin.ui.GridLayout;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
@@ -45,58 +56,67 @@ import com.vaadin.ui.VerticalLayout;
/** /**
* Manage distributions and distributions type view. * Manage distributions and distributions type view.
*
*
*
*/ */
@UIScope
@SpringView(name = DistributionsView.VIEW_NAME, ui = HawkbitUI.class) @SpringView(name = DistributionsView.VIEW_NAME, ui = HawkbitUI.class)
@ViewScope
public class DistributionsView extends VerticalLayout implements View, BrowserWindowResizeListener { public class DistributionsView extends VerticalLayout implements View, BrowserWindowResizeListener {
public static final String VIEW_NAME = "distributions"; public static final String VIEW_NAME = "distributions";
private static final long serialVersionUID = 3887435076372276300L; private static final long serialVersionUID = 3887435076372276300L;
@Autowired private final SpPermissionChecker permChecker;
private SpPermissionChecker permChecker;
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final I18N i18n;
private I18N i18n;
@Autowired private final UINotification uiNotification;
private transient UINotification uiNotification;
@Autowired private final DSTypeFilterLayout filterByDSTypeLayout;
private DSTypeFilterLayout filterByDSTypeLayout;
@Autowired private final DistributionSetTableLayout distributionTableLayout;
private DistributionSetTableLayout distributionTableLayout;
@Autowired private final SwModuleTableLayout softwareModuleTableLayout;
private SwModuleTableLayout softwareModuleTableLayout;
@Autowired private final DistSMTypeFilterLayout filterBySMTypeLayout;
private DistSMTypeFilterLayout filterBySMTypeLayout;
@Autowired private final DSDeleteActionsLayout deleteActionsLayout;
private DSDeleteActionsLayout deleteActionsLayout;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
private GridLayout mainLayout; private GridLayout mainLayout;
/* @Autowired
* (non-Javadoc) DistributionsView(final SpPermissionChecker permChecker, final UIEventBus eventBus, final I18N i18n,
* final UINotification uiNotification, final ManageDistUIState manageDistUIState,
* @see final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement,
* com.vaadin.navigator.View#enter(com.vaadin.navigator.ViewChangeListener. final TargetManagement targetManagement, final EntityFactory entityFactory,
* ViewChangeEvent) final TagManagement tagManagement, final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
*/ final ArtifactUploadState artifactUploadState, final SystemManagement systemManagement,
@Override final ArtifactManagement artifactManagement) {
public void enter(final ViewChangeEvent event) { this.permChecker = permChecker;
this.eventBus = eventBus;
this.i18n = i18n;
this.uiNotification = uiNotification;
this.filterByDSTypeLayout = new DSTypeFilterLayout(manageDistUIState, i18n, permChecker, eventBus,
tagManagement, entityFactory, uiNotification, softwareManagement, distributionSetManagement,
distributionsViewAcceptCriteria);
this.distributionTableLayout = new DistributionSetTableLayout(i18n, eventBus, permChecker, manageDistUIState,
softwareManagement, distributionSetManagement, targetManagement, entityFactory, uiNotification,
tagManagement, distributionsViewAcceptCriteria, systemManagement);
this.softwareModuleTableLayout = new SwModuleTableLayout(i18n, uiNotification, eventBus, softwareManagement,
entityFactory, manageDistUIState, permChecker, distributionsViewAcceptCriteria, artifactUploadState,
artifactManagement);
this.filterBySMTypeLayout = new DistSMTypeFilterLayout(eventBus, i18n, permChecker, manageDistUIState,
tagManagement, entityFactory, uiNotification, softwareManagement, distributionsViewAcceptCriteria);
this.deleteActionsLayout = new DSDeleteActionsLayout(i18n, permChecker, eventBus, uiNotification,
systemManagement, manageDistUIState, distributionsViewAcceptCriteria, distributionSetManagement,
softwareManagement);
this.manageDistUIState = manageDistUIState;
}
@PostConstruct
void init() {
// Build the Distributions view layout with all the required components. // Build the Distributions view layout with all the required components.
buildLayout(); buildLayout();
restoreState(); restoreState();
@@ -142,9 +162,9 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
mainLayout.addComponent(softwareModuleTableLayout, 2, 0); mainLayout.addComponent(softwareModuleTableLayout, 2, 0);
mainLayout.addComponent(filterBySMTypeLayout, 3, 0); mainLayout.addComponent(filterBySMTypeLayout, 3, 0);
mainLayout.addComponent(deleteActionsLayout, 1, 1, 2, 1); mainLayout.addComponent(deleteActionsLayout, 1, 1, 2, 1);
mainLayout.setRowExpandRatio(0, 1.0f); mainLayout.setRowExpandRatio(0, 1.0F);
mainLayout.setColumnExpandRatio(1, 0.5f); mainLayout.setColumnExpandRatio(1, 0.5F);
mainLayout.setColumnExpandRatio(2, 0.5f); mainLayout.setColumnExpandRatio(2, 0.5F);
mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER); mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER);
} }
@@ -157,7 +177,7 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
}); });
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionTableEvent event) { void onEvent(final DistributionTableEvent event) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) { if (BaseEntityEventType.MINIMIZED == event.getEventType()) {
minimizeDistTable(); minimizeDistTable();
@@ -166,7 +186,7 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
} }
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent event) { void onEvent(final SoftwareModuleEvent event) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) { if (BaseEntityEventType.MINIMIZED == event.getEventType()) {
minimizeSwTable(); minimizeSwTable();
@@ -179,17 +199,17 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
mainLayout.removeComponent(filterByDSTypeLayout); mainLayout.removeComponent(filterByDSTypeLayout);
mainLayout.removeComponent(distributionTableLayout); mainLayout.removeComponent(distributionTableLayout);
mainLayout.removeComponent(deleteActionsLayout); mainLayout.removeComponent(deleteActionsLayout);
mainLayout.setColumnExpandRatio(2, 1f); mainLayout.setColumnExpandRatio(2, 1F);
mainLayout.setColumnExpandRatio(0, 0f); mainLayout.setColumnExpandRatio(0, 0F);
mainLayout.setColumnExpandRatio(1, 0f); mainLayout.setColumnExpandRatio(1, 0F);
} }
private void minimizeSwTable() { private void minimizeSwTable() {
mainLayout.addComponent(filterByDSTypeLayout, 0, 0); mainLayout.addComponent(filterByDSTypeLayout, 0, 0);
mainLayout.addComponent(distributionTableLayout, 1, 0); mainLayout.addComponent(distributionTableLayout, 1, 0);
mainLayout.addComponent(deleteActionsLayout, 1, 1, 2, 1); mainLayout.addComponent(deleteActionsLayout, 1, 1, 2, 1);
mainLayout.setColumnExpandRatio(1, 0.5f); mainLayout.setColumnExpandRatio(1, 0.5F);
mainLayout.setColumnExpandRatio(2, 0.5f); mainLayout.setColumnExpandRatio(2, 0.5F);
mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER); mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER);
} }
@@ -197,8 +217,8 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
mainLayout.addComponent(softwareModuleTableLayout, 2, 0); mainLayout.addComponent(softwareModuleTableLayout, 2, 0);
mainLayout.addComponent(filterBySMTypeLayout, 3, 0); mainLayout.addComponent(filterBySMTypeLayout, 3, 0);
mainLayout.addComponent(deleteActionsLayout, 1, 1, 2, 1); mainLayout.addComponent(deleteActionsLayout, 1, 1, 2, 1);
mainLayout.setColumnExpandRatio(1, 0.5f); mainLayout.setColumnExpandRatio(1, 0.5F);
mainLayout.setColumnExpandRatio(2, 0.5f); mainLayout.setColumnExpandRatio(2, 0.5F);
mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER); mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER);
} }
@@ -206,9 +226,9 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
mainLayout.removeComponent(softwareModuleTableLayout); mainLayout.removeComponent(softwareModuleTableLayout);
mainLayout.removeComponent(filterBySMTypeLayout); mainLayout.removeComponent(filterBySMTypeLayout);
mainLayout.removeComponent(deleteActionsLayout); mainLayout.removeComponent(deleteActionsLayout);
mainLayout.setColumnExpandRatio(1, 1f); mainLayout.setColumnExpandRatio(1, 1F);
mainLayout.setColumnExpandRatio(2, 0f); mainLayout.setColumnExpandRatio(2, 0F);
mainLayout.setColumnExpandRatio(3, 0f); mainLayout.setColumnExpandRatio(3, 0F);
} }
private void checkNoDataAvaialble() { private void checkNoDataAvaialble() {
@@ -243,4 +263,9 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
} }
} }
@Override
public void enter(final ViewChangeEvent event) {
// This view is constructed in the init() method()
}
} }

View File

@@ -13,7 +13,10 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate; import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -28,21 +31,21 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent.DistributionSetTypeEnum; import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent.DistributionSetTypeEnum;
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout; import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.colorpicker.Color; import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator; import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
@@ -57,8 +60,6 @@ import com.vaadin.ui.themes.ValoTheme;
/** /**
* Window for create update Distribution Set Type. * Window for create update Distribution Set Type.
*/ */
@SpringComponent
@ViewScope
public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<DistributionSetType> { public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<DistributionSetType> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -67,11 +68,9 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
private static final String DIST_TYPE_MANDATORY = "mandatory"; private static final String DIST_TYPE_MANDATORY = "mandatory";
private static final String STAR = " * "; private static final String STAR = " * ";
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final transient DistributionSetManagement distributionSetManagement;
private transient DistributionSetManagement distributionSetManagement;
private HorizontalLayout distTypeSelectLayout; private HorizontalLayout distTypeSelectLayout;
private Table sourceTable; private Table sourceTable;
@@ -82,6 +81,15 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
private IndexedContainer originalSelectedTableContainer; private IndexedContainer originalSelectedTableContainer;
public CreateUpdateDistSetTypeLayout(final I18N i18n, final TagManagement tagManagement,
final EntityFactory entityFactory, final UIEventBus eventBus, final SpPermissionChecker permChecker,
final UINotification uiNotification, final SoftwareManagement softwareManagement,
final DistributionSetManagement distributionSetManagement) {
super(i18n, tagManagement, entityFactory, eventBus, permChecker, uiNotification);
this.softwareManagement = softwareManagement;
this.distributionSetManagement = distributionSetManagement;
}
@Override @Override
protected void createRequiredComponents() { protected void createRequiredComponents() {

View File

@@ -15,41 +15,31 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
/** /**
* Single button click behaviour of filter buttons layout. * Single button click behaviour of filter buttons layout.
*
*
*
*/ */
@SpringComponent
@ViewScope
public class DSTypeFilterButtonClick extends AbstractFilterSingleButtonClick implements Serializable { public class DSTypeFilterButtonClick extends AbstractFilterSingleButtonClick implements Serializable {
private static final long serialVersionUID = -584783755917528648L; private static final long serialVersionUID = -584783755917528648L;
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
@Autowired private final transient DistributionSetManagement distributionSetManagement;
private transient DistributionSetManagement distributionSetManagement;
DSTypeFilterButtonClick(final UIEventBus eventBus, final ManageDistUIState manageDistUIState,
final DistributionSetManagement distributionSetManagement) {
this.eventBus = eventBus;
this.manageDistUIState = manageDistUIState;
this.distributionSetManagement = distributionSetManagement;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.common.filterlayout.
* AbstractFilterButtonClickBehaviour#filterUnClicked (com.vaadin.ui.Button)
*/
@Override @Override
protected void filterUnClicked(final Button clickedButton) { protected void filterUnClicked(final Button clickedButton) {
manageDistUIState.getManageDistFilters().setClickedDistSetType(null); manageDistUIState.getManageDistFilters().setClickedDistSetType(null);
@@ -57,12 +47,6 @@ public class DSTypeFilterButtonClick extends AbstractFilterSingleButtonClick imp
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.common.filterlayout.
* AbstractFilterButtonClickBehaviour#filterClicked (com.vaadin.ui.Button)
*/
@Override @Override
protected void filterClicked(final Button clickedButton) { protected void filterClicked(final Button clickedButton) {
final DistributionSetType distSetType = distributionSetManagement final DistributionSetType distSetType = distributionSetManagement

View File

@@ -8,6 +8,7 @@
*/ */
package org.eclipse.hawkbit.ui.distributions.disttype; package org.eclipse.hawkbit.ui.distributions.disttype;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery; import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent; import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
@@ -17,32 +18,34 @@ import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/** /**
* Distribution Set Type filter buttons. * Distribution Set Type filter buttons.
*/ */
@SpringComponent
@ViewScope
public class DSTypeFilterButtons extends AbstractFilterButtons { public class DSTypeFilterButtons extends AbstractFilterButtons {
private static final long serialVersionUID = 771251569981876005L; private static final long serialVersionUID = 771251569981876005L;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
@Autowired private final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
DSTypeFilterButtons(final UIEventBus eventBus, final ManageDistUIState manageDistUIState,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final DistributionSetManagement distributionSetManagement) {
super(eventBus, new DSTypeFilterButtonClick(eventBus, manageDistUIState, distributionSetManagement));
this.manageDistUIState = manageDistUIState;
this.distributionsViewAcceptCriteria = distributionsViewAcceptCriteria;
}
@Override @Override
protected String getButtonsTableId() { protected String getButtonsTableId() {
@@ -52,8 +55,7 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
@Override @Override
protected LazyQueryContainer createButtonsLazyQueryContainer() { protected LazyQueryContainer createButtonsLazyQueryContainer() {
return HawkbitCommonUtil.createLazyQueryContainer( return HawkbitCommonUtil.createLazyQueryContainer(new BeanQueryFactory<>(DistributionSetTypeBeanQuery.class));
new BeanQueryFactory<DistributionSetTypeBeanQuery>(DistributionSetTypeBeanQuery.class));
} }
@Override @Override
@@ -97,7 +99,7 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
return SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS; return SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS;
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionSetTypeEvent event) { void onEvent(final DistributionSetTypeEvent event) {
if (event.getDistributionSetTypeEnum() == DistributionSetTypeEvent.DistributionSetTypeEnum.ADD_DIST_SET_TYPE if (event.getDistributionSetTypeEnum() == DistributionSetTypeEvent.DistributionSetTypeEnum.ADD_DIST_SET_TYPE
|| event.getDistributionSetTypeEnum() == DistributionSetTypeEvent.DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE) { || event.getDistributionSetTypeEnum() == DistributionSetTypeEvent.DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE) {
@@ -106,7 +108,7 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SaveActionWindowEvent event) { void onEvent(final SaveActionWindowEvent event) {
if (event == SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES) { if (event == SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES) {
refreshTypeTable(); refreshTypeTable();

View File

@@ -8,42 +8,43 @@
*/ */
package org.eclipse.hawkbit.ui.distributions.disttype; package org.eclipse.hawkbit.ui.distributions.disttype;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow; import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
/** /**
* Distribution Set Type filter buttons header. * Distribution Set Type filter buttons header.
*/ */
@SpringComponent
@ViewScope
public class DSTypeFilterHeader extends AbstractFilterHeader { public class DSTypeFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = 3433417459392880222L; private static final long serialVersionUID = 3433417459392880222L;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
@Autowired private final CreateUpdateDistSetTypeLayout createUpdateDistSetTypeLayout;
private CreateUpdateDistSetTypeLayout createUpdateDistSetTypeLayout;
private CommonDialogWindow addUpdateWindow; DSTypeFilterHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
final ManageDistUIState manageDistUIState, final TagManagement tagManagement,
@Override final EntityFactory entityFactory, final UINotification uiNotification,
@PostConstruct final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement) {
public void init() { super(permChecker, eventBus, i18n);
super.init(); this.manageDistUIState = manageDistUIState;
this.createUpdateDistSetTypeLayout = new CreateUpdateDistSetTypeLayout(i18n, tagManagement, entityFactory,
eventBus, permChecker, uiNotification, softwareManagement, distributionSetManagement);
if (hasCreateUpdatePermission()) { if (hasCreateUpdatePermission()) {
createUpdateDistSetTypeLayout.init(); createUpdateDistSetTypeLayout.init();
} }
@@ -61,7 +62,7 @@ public class DSTypeFilterHeader extends AbstractFilterHeader {
@Override @Override
protected void settingsIconClicked(final ClickEvent event) { protected void settingsIconClicked(final ClickEvent event) {
addUpdateWindow = createUpdateDistSetTypeLayout.getWindow(); final CommonDialogWindow addUpdateWindow = createUpdateDistSetTypeLayout.getWindow();
UI.getCurrent().addWindow(addUpdateWindow); UI.getCurrent().addWindow(addUpdateWindow);
} }

View File

@@ -8,58 +8,46 @@
*/ */
package org.eclipse.hawkbit.ui.distributions.disttype; package org.eclipse.hawkbit.ui.distributions.disttype;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.I18N;
import org.vaadin.spring.events.EventBus; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/** /**
* Distribution Set Type filter buttons layout. * Distribution Set Type filter buttons layout.
*
*
*
*/ */
@SpringComponent
@ViewScope
public class DSTypeFilterLayout extends AbstractFilterLayout { public class DSTypeFilterLayout extends AbstractFilterLayout {
private static final long serialVersionUID = 2689002932344750781L; private static final long serialVersionUID = 2689002932344750781L;
@Autowired private final ManageDistUIState manageDistUIState;
private transient EventBus.SessionEventBus eventbus;
@Autowired public DSTypeFilterLayout(final ManageDistUIState manageDistUIState, final I18N i18n,
private DSTypeFilterHeader dsTypeFilterHeader; final SpPermissionChecker permChecker, final UIEventBus eventBus, final TagManagement tagManagement,
final EntityFactory entityFactory, final UINotification uiNotification,
final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria) {
super(new DSTypeFilterHeader(i18n, permChecker, eventBus, manageDistUIState, tagManagement, entityFactory,
uiNotification, softwareManagement, distributionSetManagement),
new DSTypeFilterButtons(eventBus, manageDistUIState, distributionsViewAcceptCriteria,
distributionSetManagement));
this.manageDistUIState = manageDistUIState;
@Autowired restoreState();
private DSTypeFilterButtons dsTypeFilterButtons; eventBus.subscribe(this);
@Autowired
private DSTypeFilterButtonClick dsTypeFilterButtonClick;
@Autowired
private ManageDistUIState manageDistUIState;
/**
* Initialize the filter layout.
*/
@PostConstruct
public void init() {
super.init(dsTypeFilterHeader, dsTypeFilterButtons, dsTypeFilterButtonClick);
eventbus.subscribe(this);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionsUIEvent event) { void onEvent(final DistributionsUIEvent event) {
if (event == DistributionsUIEvent.HIDE_DIST_FILTER_BY_TYPE) { if (event == DistributionsUIEvent.HIDE_DIST_FILTER_BY_TYPE) {
setVisible(false); setVisible(false);
@@ -69,22 +57,6 @@ public class DSTypeFilterLayout extends AbstractFilterLayout {
} }
} }
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventbus.unsubscribe(this);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterLayout#
* onLoadIsTypeFilterIsClosed()
*/
@Override @Override
public Boolean onLoadIsTypeFilterIsClosed() { public Boolean onLoadIsTypeFilterIsClosed() {

View File

@@ -16,6 +16,9 @@ import java.util.Set;
import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName; import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
@@ -33,16 +36,17 @@ import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout; import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
@@ -54,66 +58,63 @@ import com.vaadin.ui.Window;
/** /**
* Distribution set details layout. * Distribution set details layout.
*
*
*
*/ */
@SpringComponent
@ViewScope
public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDetailsLayout<DistributionSet> { public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDetailsLayout<DistributionSet> {
private static final long serialVersionUID = -4595004466943546669L; private static final long serialVersionUID = -4595004466943546669L;
private static final String SOFT_MODULE = "softwareModule"; private static final String SOFT_MODULE = "softwareModule";
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
@Autowired private final DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout;
private DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout;
@Autowired private final DistributionTagToken distributionTagToken;
private DistributionTagToken distributionTagToken;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final transient DistributionSetManagement distributionSetManagement;
private transient DistributionSetManagement distributionSetManagement;
@Autowired private final transient TargetManagement targetManagement;
private DsMetadataPopupLayout dsMetadataPopupLayout;
@Autowired private final DsMetadataPopupLayout dsMetadataPopupLayout;
private transient EntityFactory entityFactory;
private SoftwareModuleDetailsTable softwareModuleTable; private final SoftwareModuleDetailsTable softwareModuleTable;
private DistributionSetMetadatadetailslayout dsMetadataTable; private final DistributionSetMetadatadetailslayout dsMetadataTable;
private TargetFilterQueryDetailsTable tfqDetailsTable; private final TargetFilterQueryDetailsTable tfqDetailsTable;
private VerticalLayout tagsLayout; private VerticalLayout tagsLayout;
private Map<String, StringBuilder> assignedSWModule; private Map<String, StringBuilder> assignedSWModule;
/** DistributionSetDetails(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker,
* softwareLayout Initialize the component. final ManageDistUIState manageDistUIState, final ManagementUIState managementUIState,
*/ final DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout,
@Override final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement,
protected void init() { final TargetManagement targetManagement, final EntityFactory entityFactory,
softwareModuleTable = new SoftwareModuleDetailsTable(); final UINotification uinotification, final TagManagement tagManagement,
softwareModuleTable.init(getI18n(), true, getPermissionChecker(), distributionSetManagement, getEventBus(), final DsMetadataPopupLayout popupLayout, final UINotification uiNotification) {
manageDistUIState); super(i18n, eventBus, permissionChecker, managementUIState);
this.manageDistUIState = manageDistUIState;
this.distributionAddUpdateWindowLayout = distributionAddUpdateWindowLayout;
this.distributionTagToken = new DistributionTagToken(permissionChecker, i18n, uinotification, eventBus,
managementUIState, tagManagement, distributionSetManagement);
this.softwareManagement = softwareManagement;
this.distributionSetManagement = distributionSetManagement;
this.targetManagement = targetManagement;
this.dsMetadataPopupLayout = popupLayout;
dsMetadataTable = new DistributionSetMetadatadetailslayout(); softwareModuleTable = new SoftwareModuleDetailsTable(i18n, true, permissionChecker, distributionSetManagement,
dsMetadataTable.init(getI18n(), getPermissionChecker(), distributionSetManagement, dsMetadataPopupLayout, eventBus, manageDistUIState, uiNotification);
entityFactory);
tfqDetailsTable = new TargetFilterQueryDetailsTable(); dsMetadataTable = new DistributionSetMetadatadetailslayout(i18n, permissionChecker, distributionSetManagement,
tfqDetailsTable.init(getI18n()); dsMetadataPopupLayout, entityFactory);
super.init(); tfqDetailsTable = new TargetFilterQueryDetailsTable(i18n);
addTabs(detailsTab);
restoreState();
} }
protected VerticalLayout createTagsLayout() { protected VerticalLayout createTagsLayout() {
@@ -183,9 +184,8 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
private Button assignSoftModuleButton(final String softwareModuleName) { private Button assignSoftModuleButton(final String softwareModuleName) {
if (getPermissionChecker().hasUpdateDistributionPermission() if (getPermissionChecker().hasUpdateDistributionPermission()
&& manageDistUIState.getLastSelectedDistribution().isPresent() && manageDistUIState.getLastSelectedDistribution().isPresent()
&& distributionSetManagement && targetManagement.countTargetByAssignedDistributionSet(
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId()) manageDistUIState.getLastSelectedDistribution().get().getId()) <= 0) {
.getAssignedTargets().isEmpty()) {
final Button reassignSoftModule = SPUIComponentProvider.getButton(softwareModuleName, "", "", "", true, final Button reassignSoftModule = SPUIComponentProvider.getButton(softwareModuleName, "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
reassignSoftModule.setEnabled(false); reassignSoftModule.setEnabled(false);
@@ -352,19 +352,19 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
return getPermissionChecker().hasUpdateDistributionPermission(); return getPermissionChecker().hasUpdateDistributionPermission();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent event) { void onEvent(final SoftwareModuleEvent event) {
if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE) { if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE) {
UI.getCurrent().access(() -> updateSoftwareModule(event.getEntity())); UI.getCurrent().access(() -> updateSoftwareModule(event.getEntity()));
} }
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionTableEvent distributionTableEvent) { void onEvent(final DistributionTableEvent distributionTableEvent) {
onBaseEntityEvent(distributionTableEvent); onBaseEntityEvent(distributionTableEvent);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SaveActionWindowEvent saveActionWindowEvent) { void onEvent(final SaveActionWindowEvent saveActionWindowEvent) {
if ((saveActionWindowEvent == SaveActionWindowEvent.SAVED_ASSIGNMENTS if ((saveActionWindowEvent == SaveActionWindowEvent.SAVED_ASSIGNMENTS
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS) || saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS)
@@ -374,11 +374,11 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
} }
setSelectedBaseEntity( setSelectedBaseEntity(
distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId())); distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()));
UI.getCurrent().access(() -> populateModule()); UI.getCurrent().access(this::populateModule);
} }
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEventDiscard(final SaveActionWindowEvent saveActionWindowEvent) { void onEventDiscard(final SaveActionWindowEvent saveActionWindowEvent) {
if (saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ASSIGNMENT if (saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ASSIGNMENT
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS || saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS

View File

@@ -45,17 +45,19 @@ import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn; import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition; import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -65,8 +67,6 @@ import com.vaadin.data.Item;
import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Component; import com.vaadin.ui.Component;
import com.vaadin.ui.Table; import com.vaadin.ui.Table;
@@ -75,8 +75,6 @@ import com.vaadin.ui.UI;
/** /**
* Distribution set table. * Distribution set table.
*/ */
@SpringComponent
@ViewScope
public class DistributionSetTable extends AbstractNamedVersionTable<DistributionSet, DistributionSetIdName> { public class DistributionSetTable extends AbstractNamedVersionTable<DistributionSet, DistributionSetIdName> {
private static final long serialVersionUID = -7731776093470487988L; private static final long serialVersionUID = -7731776093470487988L;
@@ -86,37 +84,41 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
private static final List<Object> DISPLAY_DROP_HINT_EVENTS = new ArrayList<>( private static final List<Object> DISPLAY_DROP_HINT_EVENTS = new ArrayList<>(
Arrays.asList(DragEvent.SOFTWAREMODULE_DRAG)); Arrays.asList(DragEvent.SOFTWAREMODULE_DRAG));
@Autowired private final SpPermissionChecker permissionChecker;
private SpPermissionChecker permissionChecker;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
@Autowired private final transient DistributionSetManagement distributionSetManagement;
private transient DistributionSetManagement distributionSetManagement;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
@Autowired private final transient TargetManagement targetManagement;
private transient TargetManagement targetManagement;
@Autowired private final DsMetadataPopupLayout dsMetadataPopupLayout;
private DsMetadataPopupLayout dsMetadataPopupLayout;
/** DistributionSetTable(final UIEventBus eventBus, final I18N i18n, final UINotification notification,
* Initialize the component. final SpPermissionChecker permissionChecker, final ManageDistUIState manageDistUIState,
*/ final DistributionSetManagement distributionSetManagement, final SoftwareManagement softwareManagement,
@Override final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
protected void init() { final TargetManagement targetManagement, final DsMetadataPopupLayout dsMetadataPopupLayout) {
super.init(); super(eventBus, i18n, notification);
this.permissionChecker = permissionChecker;
this.manageDistUIState = manageDistUIState;
this.distributionSetManagement = distributionSetManagement;
this.softwareManagement = softwareManagement;
this.distributionsViewAcceptCriteria = distributionsViewAcceptCriteria;
this.targetManagement = targetManagement;
this.dsMetadataPopupLayout = dsMetadataPopupLayout;
addTableStyleGenerator(); addTableStyleGenerator();
addNewContainerDS();
setColumnProperties();
setDataAvailable(getContainerDataSource().size() != 0);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent event) { void onEvent(final DragEvent event) {
if (event == DragEvent.HIDE_DROP_HINT) { if (event == DragEvent.HIDE_DROP_HINT) {
UI.getCurrent().access(() -> removeStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_TABLE)); UI.getCurrent().access(() -> removeStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_TABLE));
@@ -125,7 +127,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
} }
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onDistributionSetUpdateEvents(final DistributionSetUpdatedEventContainer eventContainer) { void onDistributionSetUpdateEvents(final DistributionSetUpdatedEventContainer eventContainer) {
final List<DistributionSetIdName> visibleItemIds = (List<DistributionSetIdName>) getVisibleItemIds(); final List<DistributionSetIdName> visibleItemIds = (List<DistributionSetIdName>) getVisibleItemIds();
@@ -150,12 +152,12 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
.forEach(event -> updateDistributionInTable(event.getEntity())); .forEach(event -> updateDistributionInTable(event.getEntity()));
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onDistributionCreatedEvents(final DistributionCreatedEventContainer eventContainer) { void onDistributionCreatedEvents(final DistributionCreatedEventContainer eventContainer) {
refreshDistributions(); refreshDistributions();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onDistributionDeletedEvents(final DistributionDeletedEventContainer eventContainer) { void onDistributionDeletedEvents(final DistributionDeletedEventContainer eventContainer) {
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource(); final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds(); final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
@@ -470,7 +472,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
}); });
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionTableEvent event) { void onEvent(final DistributionTableEvent event) {
onBaseEntityEvent(event); onBaseEntityEvent(event);
if (BaseEntityEventType.UPDATED_ENTITY != event.getEventType()) { if (BaseEntityEventType.UPDATED_ENTITY != event.getEventType()) {
@@ -479,7 +481,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity())); UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SaveActionWindowEvent event) { void onEvent(final SaveActionWindowEvent event) {
if (event == SaveActionWindowEvent.DELETED_DISTRIBUTIONS || event == SaveActionWindowEvent.SAVED_ASSIGNMENTS) { if (event == SaveActionWindowEvent.DELETED_DISTRIBUTIONS || event == SaveActionWindowEvent.SAVED_ASSIGNMENTS) {
UI.getCurrent().access(this::refreshFilter); UI.getCurrent().access(this::refreshFilter);
@@ -492,7 +494,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
* @param event * @param event
* as instance of {@link DistributionTableFilterEvent} * as instance of {@link DistributionTableFilterEvent}
*/ */
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
public void onEvent(final DistributionTableFilterEvent event) { public void onEvent(final DistributionTableFilterEvent event) {
if (event == DistributionTableFilterEvent.FILTER_BY_TEXT if (event == DistributionTableFilterEvent.FILTER_BY_TEXT
|| event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT || event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT

View File

@@ -8,6 +8,7 @@
*/ */
package org.eclipse.hawkbit.ui.distributions.dstable; package org.eclipse.hawkbit.ui.distributions.dstable;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader; import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
@@ -16,14 +17,13 @@ import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout; import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropHandler;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
@@ -31,19 +31,19 @@ import com.vaadin.ui.Window;
/** /**
* Distribution table header. * Distribution table header.
*/ */
@SpringComponent
@ViewScope
public class DistributionSetTableHeader extends AbstractTableHeader { public class DistributionSetTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = -3483238438474530748L; private static final long serialVersionUID = -3483238438474530748L;
@Autowired private final DistributionAddUpdateWindowLayout addUpdateWindowLayout;
private ManageDistUIState manageDistUIstate;
@Autowired DistributionSetTableHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus,
private DistributionAddUpdateWindowLayout addUpdateWindowLayout; final ManageDistUIState manageDistUIstate, final DistributionAddUpdateWindowLayout addUpdateWindowLayout) {
super(i18n, permChecker, eventbus, null, manageDistUIstate, null);
this.addUpdateWindowLayout = addUpdateWindowLayout;
}
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionsUIEvent event) { void onEvent(final DistributionsUIEvent event) {
if (event == DistributionsUIEvent.HIDE_DIST_FILTER_BY_TYPE) { if (event == DistributionsUIEvent.HIDE_DIST_FILTER_BY_TYPE) {
setFilterButtonsIconVisible(true); setFilterButtonsIconVisible(true);

View File

@@ -8,42 +8,54 @@
*/ */
package org.eclipse.hawkbit.ui.distributions.dstable; package org.eclipse.hawkbit.ui.distributions.dstable;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout; import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import com.vaadin.spring.annotation.SpringComponent; import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout;
import com.vaadin.spring.annotation.ViewScope; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
/** /**
* DistributionSet table layout * DistributionSet table layout
*/ */
@SpringComponent
@ViewScope
public class DistributionSetTableLayout extends AbstractTableLayout { public class DistributionSetTableLayout extends AbstractTableLayout {
private static final long serialVersionUID = 6464291374980641235L; private static final long serialVersionUID = 6464291374980641235L;
/** public DistributionSetTableLayout(final I18N i18n, final UIEventBus eventBus,
* Details to be autowired before table as details listens to value change final SpPermissionChecker permissionChecker, final ManageDistUIState manageDistUIState,
* of table. final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement,
*/ final TargetManagement targetManagement, final EntityFactory entityFactory,
@Autowired final UINotification uiNotification, final TagManagement tagManagement,
private DistributionSetDetails distributionDetails; final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final SystemManagement systemManagement) {
@Autowired final DsMetadataPopupLayout popupLayout = new DsMetadataPopupLayout(i18n, uiNotification, eventBus,
private DistributionSetTableHeader dsTableHeader; distributionSetManagement, entityFactory, permissionChecker);
@Autowired final DistributionSetTable distributionSetTable = new DistributionSetTable(eventBus, i18n, uiNotification,
private DistributionSetTable dsTable; permissionChecker, manageDistUIState, distributionSetManagement, softwareManagement,
distributionsViewAcceptCriteria, targetManagement, popupLayout);
/** final DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout = new DistributionAddUpdateWindowLayout(
* Initialize the filter layout. i18n, uiNotification, eventBus, distributionSetManagement, systemManagement, entityFactory,
*/ distributionSetTable);
@PostConstruct
void init() { super.init(
super.init(dsTableHeader, dsTable, distributionDetails); new DistributionSetTableHeader(i18n, permissionChecker, eventBus, manageDistUIState,
distributionAddUpdateWindowLayout),
distributionSetTable,
new DistributionSetDetails(i18n, eventBus, permissionChecker, manageDistUIState, null,
distributionAddUpdateWindowLayout, softwareManagement, distributionSetManagement,
targetManagement, entityFactory, uiNotification, tagManagement, popupLayout, uiNotification));
} }
} }

View File

@@ -18,29 +18,30 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.MetaData; import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout; import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/** /**
* Pop up layout to display distribution metadata. * Pop up layout to display distribution metadata.
*/ */
@SpringComponent
@ViewScope
public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<DistributionSet, MetaData> { public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<DistributionSet, MetaData> {
private static final long serialVersionUID = -7778944849012048106L; private static final long serialVersionUID = -7778944849012048106L;
@Autowired private final transient DistributionSetManagement distributionSetManagement;
private transient DistributionSetManagement distributionSetManagement;
@Autowired private final transient EntityFactory entityFactory;
private transient EntityFactory entityFactory;
@Autowired public DsMetadataPopupLayout(final I18N i18n, final UINotification uiNotification, final UIEventBus eventBus,
protected SpPermissionChecker permChecker; final DistributionSetManagement distributionSetManagement, final EntityFactory entityFactory,
final SpPermissionChecker permChecker) {
super(i18n, uiNotification, eventBus, permChecker);
this.distributionSetManagement = distributionSetManagement;
this.entityFactory = entityFactory;
}
@Override @Override
protected void checkForDuplicate(final DistributionSet entity, final String value) { protected void checkForDuplicate(final DistributionSet entity, final String value) {
@@ -73,7 +74,8 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
@Override @Override
protected List<MetaData> getMetadataList() { protected List<MetaData> getMetadataList() {
return Collections.unmodifiableList(getSelectedEntity().getMetadata()); return Collections.unmodifiableList(
distributionSetManagement.findDistributionSetMetadataByDistributionSetId(getSelectedEntity().getId()));
} }
/** /**

View File

@@ -15,10 +15,13 @@ import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria; import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope; import com.vaadin.spring.annotation.UIScope;
import com.vaadin.ui.Component; import com.vaadin.ui.Component;
/** /**
@@ -26,7 +29,7 @@ import com.vaadin.ui.Component;
* *
*/ */
@SpringComponent @SpringComponent
@ViewScope @UIScope
public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria { public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
private static final long serialVersionUID = -7686564967583118935L; private static final long serialVersionUID = -7686564967583118935L;
@@ -35,6 +38,11 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
private static final Map<String, List<String>> DROP_CONFIGS = createDropConfigurations(); private static final Map<String, List<String>> DROP_CONFIGS = createDropConfigurations();
@Autowired
DistributionsViewAcceptCriteria(final UINotification uiNotification, final UIEventBus eventBus) {
super(uiNotification, eventBus);
}
@Override @Override
protected String getComponentId(final Component component) { protected String getComponentId(final Component component) {
String id = component.getId(); String id = component.getId();

View File

@@ -15,6 +15,9 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName; import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
@@ -27,16 +30,17 @@ import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Component; import com.vaadin.ui.Component;
import com.vaadin.ui.Table; import com.vaadin.ui.Table;
import com.vaadin.ui.Table.TableTransferable; import com.vaadin.ui.Table.TableTransferable;
@@ -44,12 +48,7 @@ import com.vaadin.ui.UI;
/** /**
* Distributions footer layout implementation. * Distributions footer layout implementation.
*
*
*
*/ */
@org.springframework.stereotype.Component
@ViewScope
public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
private static final long serialVersionUID = 3494052985006132714L; private static final long serialVersionUID = 3494052985006132714L;
@@ -58,19 +57,30 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
Arrays.asList(DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG, Arrays.asList(DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG,
DragEvent.SOFTWAREMODULE_TYPE_DRAG)); DragEvent.SOFTWAREMODULE_TYPE_DRAG));
@Autowired private final transient SystemManagement systemManagement;
private transient SystemManagement systemManagement;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
@Autowired private final DistributionsConfirmationWindowLayout distConfirmationWindowLayout;
private DistributionsConfirmationWindowLayout distConfirmationWindowLayout;
@Autowired private final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
@EventBusListenerMethod(scope = EventScope.SESSION) public DSDeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
final UINotification notification, final SystemManagement systemManagement,
final ManageDistUIState manageDistUIState,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final DistributionSetManagement dsManagement, final SoftwareManagement softwareManagement) {
super(i18n, permChecker, eventBus, notification);
this.systemManagement = systemManagement;
this.manageDistUIState = manageDistUIState;
this.distConfirmationWindowLayout = new DistributionsConfirmationWindowLayout(i18n, eventBus, dsManagement,
softwareManagement, manageDistUIState);
this.distributionsViewAcceptCriteria = distributionsViewAcceptCriteria;
init();
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent event) { void onEvent(final DragEvent event) {
if (event == DragEvent.HIDE_DROP_HINT) { if (event == DragEvent.HIDE_DROP_HINT) {
hideDropHints(); hideDropHints();
@@ -79,7 +89,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
} }
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SaveActionWindowEvent event) { void onEvent(final SaveActionWindowEvent event) {
if (event != null) { if (event != null) {
UI.getCurrent().access(() -> { UI.getCurrent().access(() -> {
@@ -253,7 +263,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* @param event * @param event
* as instance of {@link DistributionsUIEvent} * as instance of {@link DistributionsUIEvent}
*/ */
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
public void onEvent(final DistributionsUIEvent event) { public void onEvent(final DistributionsUIEvent event) {
if (event == DistributionsUIEvent.UPDATE_COUNT) { if (event == DistributionsUIEvent.UPDATE_COUNT) {
updateDSActionCount(); updateDSActionCount();

View File

@@ -26,11 +26,12 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -39,7 +40,6 @@ import com.vaadin.data.Container;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table.Align; import com.vaadin.ui.Table.Align;
@@ -48,11 +48,7 @@ import com.vaadin.ui.themes.ValoTheme;
/** /**
* Abstract layout of confirm actions window. * Abstract layout of confirm actions window.
* *
*
*
*/ */
@org.springframework.stereotype.Component
@ViewScope
public class DistributionsConfirmationWindowLayout extends AbstractConfirmationWindowLayout { public class DistributionsConfirmationWindowLayout extends AbstractConfirmationWindowLayout {
private static final long serialVersionUID = 3641621131320823058L; private static final long serialVersionUID = 3641621131320823058L;
@@ -77,14 +73,20 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private ConfirmationTab assignmnetTab; private ConfirmationTab assignmnetTab;
@Autowired private final transient DistributionSetManagement dsManagement;
private transient DistributionSetManagement dsManagement;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
DistributionsConfirmationWindowLayout(final I18N i18n, final UIEventBus eventBus,
final DistributionSetManagement dsManagement, final SoftwareManagement softwareManagement,
final ManageDistUIState manageDistUIState) {
super(i18n, eventBus);
this.dsManagement = dsManagement;
this.softwareManagement = softwareManagement;
this.manageDistUIState = manageDistUIState;
}
@Override @Override
protected Map<String, ConfirmationTab> getConfimrationTabs() { protected Map<String, ConfirmationTab> getConfimrationTabs() {
@@ -630,7 +632,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEventDiscard(final SaveActionWindowEvent saveActionWindowEvent) { void onEventDiscard(final SaveActionWindowEvent saveActionWindowEvent) {
if (saveActionWindowEvent == SaveActionWindowEvent.DELETE_ALL_SOFWARE) { if (saveActionWindowEvent == SaveActionWindowEvent.DELETE_ALL_SOFWARE) {
getSWAssignmentsTableContainer(); getSWAssignmentsTableContainer();

View File

@@ -20,28 +20,28 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout; import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent; import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
import com.vaadin.spring.annotation.SpringComponent; import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.spring.annotation.ViewScope;
/** /**
* Pop up layout to display software module metadata. * Pop up layout to display software module metadata.
*/ */
@SpringComponent
@ViewScope
public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareModule, MetaData> { public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareModule, MetaData> {
private static final long serialVersionUID = -1252090014161012563L; private static final long serialVersionUID = -1252090014161012563L;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final transient EntityFactory entityFactory;
private transient EntityFactory entityFactory;
@Autowired public SwMetadataPopupLayout(final I18N i18n, final UINotification uiNotification, final UIEventBus eventBus,
protected SpPermissionChecker permChecker; final SoftwareManagement softwareManagement, final EntityFactory entityFactory,
final SpPermissionChecker permChecker) {
super(i18n, uiNotification, eventBus, permChecker);
this.softwareManagement = softwareManagement;
this.entityFactory = entityFactory;
}
@Override @Override
protected void checkForDuplicate(final SoftwareModule entity, final String value) { protected void checkForDuplicate(final SoftwareModule entity, final String value) {

View File

@@ -57,7 +57,7 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
super(definition, queryConfig, sortIds, sortStates); super(definition, queryConfig, sortIds, sortStates);
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) { if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
type = Optional.ofNullable((SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE)) type = Optional.ofNullable((SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE))
.map(t -> t.getId()).orElse(null); .map(SoftwareModuleType::getId).orElse(null);
final String text = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT); final String text = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
if (!Strings.isNullOrEmpty(text)) { if (!Strings.isNullOrEmpty(text)) {
searchText = String.format("%%%s%%", text); searchText = String.format("%%%s%%", text);

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.distributions.smtable;
import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.MetaData; import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
@@ -20,13 +21,12 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet;
@@ -38,38 +38,35 @@ import com.vaadin.ui.Window;
* Implementation of software module details block using generic abstract * Implementation of software module details block using generic abstract
* details style . * details style .
*/ */
@SpringComponent
@ViewScope
public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLayout<SoftwareModule> { public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLayout<SoftwareModule> {
private static final long serialVersionUID = -1052279281066089812L; private static final long serialVersionUID = -1052279281066089812L;
@Autowired private final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final SwMetadataPopupLayout swMetadataPopupLayout;
private SwMetadataPopupLayout swMetadataPopupLayout;
@Autowired private final SoftwareModuleMetadatadetailslayout swmMetadataTable;
private transient EntityFactory entityFactory;
private SoftwareModuleMetadatadetailslayout swmMetadataTable; SwModuleDetails(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker,
final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow,
final ManageDistUIState manageDistUIState, final SoftwareManagement softwareManagement,
final SwMetadataPopupLayout swMetadataPopupLayout, final EntityFactory entityFactory) {
super(i18n, eventBus, permissionChecker, null);
this.softwareModuleAddUpdateWindow = softwareModuleAddUpdateWindow;
this.manageDistUIState = manageDistUIState;
this.softwareManagement = softwareManagement;
this.swMetadataPopupLayout = swMetadataPopupLayout;
/**
* softwareLayout Initialize the component.
*/
@Override
protected void init() {
swmMetadataTable = new SoftwareModuleMetadatadetailslayout(); swmMetadataTable = new SoftwareModuleMetadatadetailslayout();
swmMetadataTable.init(getI18n(), getPermissionChecker(), softwareManagement, swMetadataPopupLayout, swmMetadataTable.init(getI18n(), getPermissionChecker(), softwareManagement, swMetadataPopupLayout,
entityFactory); entityFactory);
super.init(); addTabs(detailsTab);
restoreState();
} }
/** /**
@@ -79,7 +76,7 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
* as instance of {@link MetadataEvent} * as instance of {@link MetadataEvent}
*/ */
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final MetadataEvent event) { void onEvent(final MetadataEvent event) {
UI.getCurrent().access(() -> { UI.getCurrent().access(() -> {
final MetaData softwareModuleMetadata = event.getMetaData(); final MetaData softwareModuleMetadata = event.getMetaData();
@@ -94,7 +91,7 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
}); });
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent softwareModuleEvent) { void onEvent(final SoftwareModuleEvent softwareModuleEvent) {
onBaseEntityEvent(softwareModuleEvent); onBaseEntityEvent(softwareModuleEvent);
} }
@@ -203,10 +200,12 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
} }
private boolean isSoftwareModuleSelected(final SoftwareModule softwareModule) { private boolean isSoftwareModuleSelected(final SoftwareModule softwareModule) {
final Long selectedDistSWModuleId = manageDistUIState.getSelectedBaseSwModuleId().isPresent() if (softwareModule == null) {
? manageDistUIState.getSelectedBaseSwModuleId().get() : null; return false;
return softwareModule != null && selectedDistSWModuleId != null }
&& selectedDistSWModuleId.equals(softwareModule.getId());
return manageDistUIState.getSelectedBaseSwModuleId().map(module -> module.equals(softwareModule.getId()))
.orElse(false);
} }
@Override @Override

View File

@@ -12,11 +12,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout; import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState; import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable; import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
@@ -27,15 +29,17 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteri
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn; import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition; import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -47,8 +51,6 @@ import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.server.Page; import com.vaadin.server.Page;
import com.vaadin.shared.ui.window.WindowMode; import com.vaadin.shared.ui.window.WindowMode;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.JavaScript; import com.vaadin.ui.JavaScript;
@@ -60,39 +62,42 @@ import com.vaadin.ui.Window;
* Implementation of software module table using generic abstract table styles . * Implementation of software module table using generic abstract table styles .
* *
*/ */
@SpringComponent
@ViewScope
public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> { public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
private static final long serialVersionUID = 6785314784507424750L; private static final long serialVersionUID = 6785314784507424750L;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
@Autowired private final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
@Autowired private final ArtifactDetailsLayout artifactDetailsLayout;
private ArtifactDetailsLayout artifactDetailsLayout;
@Autowired private final SwMetadataPopupLayout swMetadataPopupLayout;
private SwMetadataPopupLayout swMetadataPopupLayout;
/** SwModuleTable(final UIEventBus eventBus, final I18N i18n, final UINotification uiNotification,
* Initialize the filter layout. final ManageDistUIState manageDistUIState, final SoftwareManagement softwareManagement,
*/ final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
@Override final ArtifactManagement artifactManagement, final SwMetadataPopupLayout swMetadataPopupLayout,
protected void init() { final ArtifactUploadState artifactUploadState) {
super.init(); super(eventBus, i18n, uiNotification);
this.manageDistUIState = manageDistUIState;
this.softwareManagement = softwareManagement;
this.distributionsViewAcceptCriteria = distributionsViewAcceptCriteria;
this.artifactDetailsLayout = new ArtifactDetailsLayout(i18n, eventBus, artifactUploadState, uiNotification,
artifactManagement);
this.swMetadataPopupLayout = swMetadataPopupLayout;
addNewContainerDS();
setColumnProperties();
setDataAvailable(getContainerDataSource().size() != 0);
styleTableOnDistSelection(); styleTableOnDistSelection();
} }
/* All event Listeners */ /* All event Listeners */
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SMFilterEvent filterEvent) { void onEvent(final SMFilterEvent filterEvent) {
UI.getCurrent().access(() -> { UI.getCurrent().access(() -> {
@@ -105,7 +110,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
}); });
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionsUIEvent event) { void onEvent(final DistributionsUIEvent event) {
UI.getCurrent().access(() -> { UI.getCurrent().access(() -> {
if (event == DistributionsUIEvent.ORDER_BY_DISTRIBUTION) { if (event == DistributionsUIEvent.ORDER_BY_DISTRIBUTION) {
@@ -115,14 +120,14 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
}); });
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SaveActionWindowEvent event) { void onEvent(final SaveActionWindowEvent event) {
if (event == SaveActionWindowEvent.DELETE_ALL_SOFWARE) { if (event == SaveActionWindowEvent.DELETE_ALL_SOFWARE) {
UI.getCurrent().access(this::refreshFilter); UI.getCurrent().access(this::refreshFilter);
} }
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent event) { void onEvent(final SoftwareModuleEvent event) {
onBaseEntityEvent(event); onBaseEntityEvent(event);
} }

View File

@@ -8,6 +8,7 @@
*/ */
package org.eclipse.hawkbit.ui.distributions.smtable; package org.eclipse.hawkbit.ui.distributions.smtable;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow; import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow;
@@ -15,14 +16,13 @@ import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropHandler;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
@@ -31,19 +31,20 @@ import com.vaadin.ui.Window;
* Implementation of software module Header block using generic abstract details * Implementation of software module Header block using generic abstract details
* style . * style .
*/ */
@SpringComponent
@ViewScope
public class SwModuleTableHeader extends AbstractTableHeader { public class SwModuleTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = 242961845006626297L; private static final long serialVersionUID = 242961845006626297L;
@Autowired private final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
private ManageDistUIState manageDistUIState;
@Autowired SwModuleTableHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus,
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow; final ManageDistUIState manageDistUIstate,
final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow) {
super(i18n, permChecker, eventbus, null, manageDistUIstate, null);
this.softwareModuleAddUpdateWindow = softwareModuleAddUpdateWindow;
}
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionsUIEvent event) { void onEvent(final DistributionsUIEvent event) {
if (event == DistributionsUIEvent.HIDE_SM_FILTER_BY_TYPE) { if (event == DistributionsUIEvent.HIDE_SM_FILTER_BY_TYPE) {
setFilterButtonsIconVisible(true); setFilterButtonsIconVisible(true);
@@ -72,10 +73,7 @@ public class SwModuleTableHeader extends AbstractTableHeader {
@Override @Override
protected String onLoadSearchBoxValue() { protected String onLoadSearchBoxValue() {
if (manageDistUIState.getSoftwareModuleFilters().getSearchText().isPresent()) { return manageDistUIstate.getSoftwareModuleFilters().getSearchText().orElse(null);
return manageDistUIState.getSoftwareModuleFilters().getSearchText().get();
}
return null;
} }
@Override @Override
@@ -102,14 +100,14 @@ public class SwModuleTableHeader extends AbstractTableHeader {
@Override @Override
protected void showFilterButtonsLayout() { protected void showFilterButtonsLayout() {
manageDistUIState.setSwTypeFilterClosed(false); manageDistUIstate.setSwTypeFilterClosed(false);
eventbus.publish(this, DistributionsUIEvent.SHOW_SM_FILTER_BY_TYPE); eventbus.publish(this, DistributionsUIEvent.SHOW_SM_FILTER_BY_TYPE);
} }
@Override @Override
protected void resetSearchText() { protected void resetSearchText() {
if (manageDistUIState.getSoftwareModuleFilters().getSearchText().isPresent()) { if (manageDistUIstate.getSoftwareModuleFilters().getSearchText().isPresent()) {
manageDistUIState.getSoftwareModuleFilters().setSearchText(null); manageDistUIstate.getSoftwareModuleFilters().setSearchText(null);
eventbus.publish(this, SMFilterEvent.REMOVER_FILTER_BY_TEXT); eventbus.publish(this, SMFilterEvent.REMOVER_FILTER_BY_TEXT);
} }
} }
@@ -121,30 +119,30 @@ public class SwModuleTableHeader extends AbstractTableHeader {
@Override @Override
public void maximizeTable() { public void maximizeTable() {
manageDistUIState.setSwModuleTableMaximized(Boolean.TRUE); manageDistUIstate.setSwModuleTableMaximized(Boolean.TRUE);
eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MAXIMIZED, null)); eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MAXIMIZED, null));
} }
@Override @Override
public void minimizeTable() { public void minimizeTable() {
manageDistUIState.setSwModuleTableMaximized(Boolean.FALSE); manageDistUIstate.setSwModuleTableMaximized(Boolean.FALSE);
eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MINIMIZED, null)); eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MINIMIZED, null));
} }
@Override @Override
public Boolean onLoadIsTableMaximized() { public Boolean onLoadIsTableMaximized() {
return manageDistUIState.isSwModuleTableMaximized(); return manageDistUIstate.isSwModuleTableMaximized();
} }
@Override @Override
public Boolean onLoadIsShowFilterButtonDisplayed() { public Boolean onLoadIsShowFilterButtonDisplayed() {
return manageDistUIState.isSwTypeFilterClosed(); return manageDistUIstate.isSwTypeFilterClosed();
} }
@Override @Override
protected void searchBy(final String newSearchText) { protected void searchBy(final String newSearchText) {
manageDistUIState.getSoftwareModuleFilters().setSearchText(newSearchText); manageDistUIstate.getSoftwareModuleFilters().setSearchText(newSearchText);
eventbus.publish(this, SMFilterEvent.FILTER_BY_TEXT); eventbus.publish(this, SMFilterEvent.FILTER_BY_TEXT);
} }

View File

@@ -8,37 +8,44 @@
*/ */
package org.eclipse.hawkbit.ui.distributions.smtable; package org.eclipse.hawkbit.ui.distributions.smtable;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout; import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import com.vaadin.spring.annotation.SpringComponent; import org.eclipse.hawkbit.ui.utils.I18N;
import com.vaadin.spring.annotation.ViewScope; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
/** /**
* Implementation of software module Layout * Implementation of software module Layout
*/ */
@SpringComponent
@ViewScope
public class SwModuleTableLayout extends AbstractTableLayout { public class SwModuleTableLayout extends AbstractTableLayout {
private static final long serialVersionUID = 6464291374980641235L; private static final long serialVersionUID = 6464291374980641235L;
@Autowired public SwModuleTableLayout(final I18N i18n, final UINotification uiNotification, final UIEventBus eventBus,
private SwModuleTableHeader swModuleTableHeader; final SoftwareManagement softwareManagement, final EntityFactory entityFactory,
final ManageDistUIState manageDistUIState, final SpPermissionChecker permChecker,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final ArtifactUploadState artifactUploadState, final ArtifactManagement artifactManagement) {
@Autowired final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow = new SoftwareModuleAddUpdateWindow(i18n,
private SwModuleDetails swModuleDetails; uiNotification, eventBus, softwareManagement, entityFactory);
@Autowired final SwMetadataPopupLayout swMetadataPopupLayout = new SwMetadataPopupLayout(i18n, uiNotification, eventBus,
private SwModuleTable swModuleTable; softwareManagement, entityFactory, permChecker);
/** super.init(
* Initialize the filter layout. new SwModuleTableHeader(i18n, permChecker, eventBus, manageDistUIState, softwareModuleAddUpdateWindow),
*/ new SwModuleTable(eventBus, i18n, uiNotification, manageDistUIState, softwareManagement,
@PostConstruct distributionsViewAcceptCriteria, artifactManagement, swMetadataPopupLayout,
void init() { artifactUploadState),
super.init(swModuleTableHeader, swModuleTable, swModuleDetails); new SwModuleDetails(i18n, eventBus, permChecker, softwareModuleAddUpdateWindow, manageDistUIState,
softwareManagement, swMetadataPopupLayout, entityFactory));
} }
} }

View File

@@ -15,54 +15,37 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
/** /**
* Single button click behaviour of filter buttons layout. * Single button click behaviour of filter buttons layout.
*
*
*
*/ */
@SpringComponent
@ViewScope
public class DistSMTypeFilterButtonClick extends AbstractFilterSingleButtonClick implements Serializable { public class DistSMTypeFilterButtonClick extends AbstractFilterSingleButtonClick implements Serializable {
private static final long serialVersionUID = -4166632002904286983L; private static final long serialVersionUID = -4166632002904286983L;
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
@Autowired private final transient SoftwareManagement softwareManagement;
private transient SoftwareManagement softwareManagement;
DistSMTypeFilterButtonClick(final UIEventBus eventBus, final ManageDistUIState manageDistUIState,
final SoftwareManagement softwareManagement) {
this.eventBus = eventBus;
this.manageDistUIState = manageDistUIState;
this.softwareManagement = softwareManagement;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.common.filterlayout.
* AbstractFilterButtonClickBehaviour#filterUnClicked (com.vaadin.ui.Button)
*/
@Override @Override
protected void filterUnClicked(final Button clickedButton) { protected void filterUnClicked(final Button clickedButton) {
manageDistUIState.getSoftwareModuleFilters().setSoftwareModuleType(null); manageDistUIState.getSoftwareModuleFilters().setSoftwareModuleType(null);
eventBus.publish(this, SMFilterEvent.FILTER_BY_TYPE); eventBus.publish(this, SMFilterEvent.FILTER_BY_TYPE);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.common.filterlayout.
* AbstractFilterButtonClickBehaviour#filterClicked (com.vaadin.ui.Button)
*/
@Override @Override
protected void filterClicked(final Button clickedButton) { protected void filterClicked(final Button clickedButton) {
final SoftwareModuleType smType = softwareManagement final SoftwareModuleType smType = softwareManagement

View File

@@ -15,6 +15,7 @@ import static org.eclipse.hawkbit.ui.utils.UIComponentIdProvider.SW_MODULE_TYPE_
import java.util.Collections; import java.util.Collections;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery; import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
@@ -23,33 +24,35 @@ import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition; import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/** /**
* Software Module Type filter buttons. * Software Module Type filter buttons.
*/ */
@ViewScope
@SpringComponent
public class DistSMTypeFilterButtons extends AbstractFilterButtons { public class DistSMTypeFilterButtons extends AbstractFilterButtons {
private static final long serialVersionUID = 6804534533362387433L; private static final long serialVersionUID = 6804534533362387433L;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState;
@Autowired private final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
DistSMTypeFilterButtons(final UIEventBus eventBus, final ManageDistUIState manageDistUIState,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final SoftwareManagement softwareManagement) {
super(eventBus, new DistSMTypeFilterButtonClick(eventBus, manageDistUIState, softwareManagement));
this.manageDistUIState = manageDistUIState;
this.distributionsViewAcceptCriteria = distributionsViewAcceptCriteria;
}
@Override @Override
protected String getButtonsTableId() { protected String getButtonsTableId() {
@@ -103,7 +106,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
return SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS; return SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS;
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleTypeEvent event) { void onEvent(final SoftwareModuleTypeEvent event) {
if (isCreateOrUpdate(event) && event.getSoftwareModuleType() != null) { if (isCreateOrUpdate(event) && event.getSoftwareModuleType() != null) {
refreshTypeTable(); refreshTypeTable();
@@ -115,7 +118,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|| event.getSoftwareModuleTypeEnum() == UPDATE_SOFTWARE_MODULE_TYPE; || event.getSoftwareModuleTypeEnum() == UPDATE_SOFTWARE_MODULE_TYPE;
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SaveActionWindowEvent event) { void onEvent(final SaveActionWindowEvent event) {
if (event == SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES) { if (event == SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES) {
refreshTypeTable(); refreshTypeTable();

View File

@@ -8,19 +8,21 @@
*/ */
package org.eclipse.hawkbit.ui.distributions.smtype; package org.eclipse.hawkbit.ui.distributions.smtype;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.artifacts.smtype.CreateUpdateSoftwareTypeLayout; import org.eclipse.hawkbit.ui.artifacts.smtype.CreateUpdateSoftwareTypeLayout;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
@@ -28,22 +30,21 @@ import com.vaadin.ui.Window;
/** /**
* Software Module Type filter buttons header. * Software Module Type filter buttons header.
*/ */
@SpringComponent
@ViewScope
public class DistSMTypeFilterHeader extends AbstractFilterHeader { public class DistSMTypeFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = -8763788280848718344L; private static final long serialVersionUID = -8763788280848718344L;
@Autowired private final ManageDistUIState manageDistUIState;
private ManageDistUIState manageDistUIState; private final CreateUpdateSoftwareTypeLayout createUpdateSWTypeLayout;
@Autowired DistSMTypeFilterHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
private CreateUpdateSoftwareTypeLayout createUpdateSWTypeLayout; final ManageDistUIState manageDistUIState, final TagManagement tagManagement,
final EntityFactory entityFactory, final UINotification uiNotification,
final SoftwareManagement swTypeManagementService) {
super(permChecker, eventBus, i18n);
this.manageDistUIState = manageDistUIState;
this.createUpdateSWTypeLayout = new CreateUpdateSoftwareTypeLayout(i18n, tagManagement, entityFactory, eventBus,
permChecker, uiNotification, swTypeManagementService);
@Override
@PostConstruct
public void init() {
super.init();
if (hasCreateUpdatePermission()) { if (hasCreateUpdatePermission()) {
createUpdateSWTypeLayout.init(); createUpdateSWTypeLayout.init();
} }

View File

@@ -8,58 +8,45 @@
*/ */
package org.eclipse.hawkbit.ui.distributions.smtype; package org.eclipse.hawkbit.ui.distributions.smtype;
import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.EntityFactory;
import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.springframework.beans.factory.annotation.Autowired; import org.eclipse.hawkbit.ui.utils.I18N;
import org.vaadin.spring.events.EventBus; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/** /**
* Software Module Type filter layout. * Software Module Type filter layout.
*
*
*
*/ */
@SpringComponent
@ViewScope
public class DistSMTypeFilterLayout extends AbstractFilterLayout { public class DistSMTypeFilterLayout extends AbstractFilterLayout {
private static final long serialVersionUID = 3042297420534417538L; private static final long serialVersionUID = 3042297420534417538L;
@Autowired private final ManageDistUIState manageDistUIState;
private transient EventBus.SessionEventBus eventbus;
@Autowired public DistSMTypeFilterLayout(final UIEventBus eventBus, final I18N i18n, final SpPermissionChecker permChecker,
private DistSMTypeFilterHeader smTypeFilterHeader; final ManageDistUIState manageDistUIState, final TagManagement tagManagement,
final EntityFactory entityFactory, final UINotification uiNotification,
final SoftwareManagement softwareManagement,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria) {
super(new DistSMTypeFilterHeader(i18n, permChecker, eventBus, manageDistUIState, tagManagement, entityFactory,
uiNotification, softwareManagement),
new DistSMTypeFilterButtons(eventBus, manageDistUIState, distributionsViewAcceptCriteria,
softwareManagement));
this.manageDistUIState = manageDistUIState;
@Autowired restoreState();
private DistSMTypeFilterButtons smTypeFilterButtons; eventBus.subscribe(this);
@Autowired
private DistSMTypeFilterButtonClick smTypeFilterButtonClick;
@Autowired
private ManageDistUIState manageDistUIState;
/**
* Initialize the filter layout.
*/
@PostConstruct
public void init() {
super.init(smTypeFilterHeader, smTypeFilterButtons, smTypeFilterButtonClick);
eventbus.subscribe(this);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionsUIEvent event) { void onEvent(final DistributionsUIEvent event) {
if (event == DistributionsUIEvent.HIDE_SM_FILTER_BY_TYPE) { if (event == DistributionsUIEvent.HIDE_SM_FILTER_BY_TYPE) {
setVisible(false); setVisible(false);
@@ -69,22 +56,6 @@ public class DistSMTypeFilterLayout extends AbstractFilterLayout {
} }
} }
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventbus.unsubscribe(this);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterLayout#
* onLoadIsTypeFilterIsClosed()
*/
@Override @Override
public Boolean onLoadIsTypeFilterIsClosed() { public Boolean onLoadIsTypeFilterIsClosed() {

View File

@@ -36,11 +36,9 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
private static final long serialVersionUID = -7569047247017742928L; private static final long serialVersionUID = -7569047247017742928L;
@Autowired private final ManageDistFilters manageDistFilters;
private ManageDistFilters manageDistFilters;
@Autowired private final ManageSoftwareModuleFilters softwareModuleFilters;
private ManageSoftwareModuleFilters softwareModuleFilters;
private final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = new HashMap<>(); private final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = new HashMap<>();
@@ -76,6 +74,13 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
private boolean noDataAvailableDist; private boolean noDataAvailableDist;
@Autowired
ManageDistUIState(final ManageDistFilters manageDistFilters,
final ManageSoftwareModuleFilters softwareModuleFilters) {
this.manageDistFilters = manageDistFilters;
this.softwareModuleFilters = softwareModuleFilters;
}
/** /**
* @return the manageDistFilters * @return the manageDistFilters
*/ */

View File

@@ -25,13 +25,14 @@ import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope; import com.vaadin.spring.annotation.UIScope;
import com.vaadin.ui.AbstractTextField.TextChangeEventMode; import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
@@ -44,33 +45,39 @@ import com.vaadin.ui.UI;
* suggestions in a suggestion-pop-up window while typing. * suggestions in a suggestion-pop-up window while typing.
*/ */
@SpringComponent @SpringComponent
@ViewScope @UIScope
public class AutoCompleteTextFieldComponent extends HorizontalLayout { public class AutoCompleteTextFieldComponent extends HorizontalLayout {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Autowired private final FilterManagementUIState filterManagementUIState;
private FilterManagementUIState filterManagementUIState;
private final transient EventBus.UIEventBus eventBus;
private final transient RsqlValidationOracle rsqlValidationOracle;
private final transient Executor executor;
private final transient List<FilterQueryChangeListener> listeners = new LinkedList<>();
private Label validationIcon;
private TextField queryTextField;
@Autowired @Autowired
private transient EventBus.SessionEventBus eventBus; public AutoCompleteTextFieldComponent(final FilterManagementUIState filterManagementUIState,
final UIEventBus eventBus, final RsqlValidationOracle rsqlValidationOracle,
@Autowired @Qualifier("uiExecutor") final Executor executor) {
private transient RsqlValidationOracle rsqlValidationOracle; this.filterManagementUIState = filterManagementUIState;
this.eventBus = eventBus;
@Autowired this.rsqlValidationOracle = rsqlValidationOracle;
@Qualifier("uiExecutor") this.executor = executor;
private transient Executor executor; }
private transient List<FilterQueryChangeListener> listeners = new LinkedList<>();
private final Label validationIcon;
private final TextField queryTextField;
/** /**
* Constructor. * Constructor.
*/ */
public AutoCompleteTextFieldComponent() { @PostConstruct
void init() {
queryTextField = createSearchField(); queryTextField = createSearchField();
validationIcon = createStatusIcon(); validationIcon = createStatusIcon();
@@ -80,13 +87,7 @@ public class AutoCompleteTextFieldComponent extends HorizontalLayout {
addStyleName("custom-search-layout"); addStyleName("custom-search-layout");
addComponents(validationIcon, queryTextField); addComponents(validationIcon, queryTextField);
setComponentAlignment(validationIcon, Alignment.TOP_CENTER); setComponentAlignment(validationIcon, Alignment.TOP_CENTER);
}
/**
* Called by the spring-framework when this bean has be post-constructed.
*/
@PostConstruct
public void postConstruct() {
eventBus.subscribe(this); eventBus.subscribe(this);
new TextFieldSuggestionBox(rsqlValidationOracle, this).extend(queryTextField); new TextFieldSuggestionBox(rsqlValidationOracle, this).extend(queryTextField);
} }
@@ -96,7 +97,7 @@ public class AutoCompleteTextFieldComponent extends HorizontalLayout {
eventBus.unsubscribe(this); eventBus.unsubscribe(this);
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final CustomFilterUIEvent custFUIEvent) { void onEvent(final CustomFilterUIEvent custFUIEvent) {
if (custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) { if (custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) {
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
@@ -222,7 +223,7 @@ public class AutoCompleteTextFieldComponent extends HorizontalLayout {
class StatusCircledAsync implements Runnable { class StatusCircledAsync implements Runnable {
private final UI current; private final UI current;
public StatusCircledAsync(final UI current) { StatusCircledAsync(final UI current) {
this.current = current; this.current = current;
} }

View File

@@ -10,9 +10,6 @@ package org.eclipse.hawkbit.ui.filtermanagement;
import java.util.Optional; import java.util.Optional;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
@@ -30,8 +27,8 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -40,8 +37,6 @@ import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.TextChangeEvent; import com.vaadin.event.FieldEvents.TextChangeEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.event.LayoutEvents.LayoutClickListener;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
@@ -56,40 +51,29 @@ import com.vaadin.ui.themes.ValoTheme;
/** /**
* A Vaadin layout for create or update the target filter. * A Vaadin layout for create or update the target filter.
*/ */
@SpringComponent
@ViewScope
public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button.ClickListener { public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button.ClickListener {
private static final long serialVersionUID = 7474232427119031474L; private static final long serialVersionUID = 7474232427119031474L;
private static final String BREADCRUMB_CUSTOM_FILTERS = "breadcrumb.target.filter.custom.filters"; private static final String BREADCRUMB_CUSTOM_FILTERS = "breadcrumb.target.filter.custom.filters";
@Autowired private final I18N i18n;
private I18N i18n;
@Autowired private final transient EventBus.UIEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired private final FilterManagementUIState filterManagementUIState;
private FilterManagementUIState filterManagementUIState;
@Autowired private final transient TargetFilterQueryManagement targetFilterQueryManagement;
private transient TargetFilterQueryManagement targetFilterQueryManagement;
@Autowired private final SpPermissionChecker permissionChecker;
private SpPermissionChecker permissionChecker;
@Autowired private final UINotification notification;
private UINotification notification;
@Autowired private final UiProperties uiProperties;
private transient UiProperties uiProperties;
@Autowired private final transient EntityFactory entityFactory;
private transient EntityFactory entityFactory;
@Autowired private final AutoCompleteTextFieldComponent queryTextField;
private AutoCompleteTextFieldComponent queryTextField;
private Button breadcrumbButton; private Button breadcrumbButton;
@@ -121,11 +105,21 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
private LayoutClickListener nameLayoutClickListner; private LayoutClickListener nameLayoutClickListner;
/** CreateOrUpdateFilterHeader(final I18N i18n, final UIEventBus eventBus,
* Initialize the Campaign Status History Header. final FilterManagementUIState filterManagementUIState,
*/ final TargetFilterQueryManagement targetFilterQueryManagement, final SpPermissionChecker permissionChecker,
@PostConstruct final UINotification notification, final UiProperties uiProperties, final EntityFactory entityFactory,
public void init() { final AutoCompleteTextFieldComponent queryTextField) {
this.i18n = i18n;
this.eventBus = eventBus;
this.filterManagementUIState = filterManagementUIState;
this.targetFilterQueryManagement = targetFilterQueryManagement;
this.permissionChecker = permissionChecker;
this.notification = notification;
this.uiProperties = uiProperties;
this.entityFactory = entityFactory;
this.queryTextField = queryTextField;
createComponents(); createComponents();
createListeners(); createListeners();
buildLayout(); buildLayout();
@@ -140,12 +134,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
} }
@PreDestroy @EventBusListenerMethod(scope = EventScope.UI)
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final CustomFilterUIEvent custFUIEvent) { void onEvent(final CustomFilterUIEvent custFUIEvent) {
if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) { if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
populateComponents(); populateComponents();

Some files were not shown because too many files have changed in this diff Show More