diff --git a/hawkbit-ui/pom.xml b/hawkbit-ui/pom.xml index 9b136204c..cda6da026 100644 --- a/hawkbit-ui/pom.xml +++ b/hawkbit-ui/pom.xml @@ -252,7 +252,6 @@ spring-boot-configuration-processor true - org.eclipse.hawkbit @@ -265,6 +264,11 @@ mockito-core test + + com.google.gwt.gwtmockito + gwtmockito + test + org.easytesting fest-assert-core diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml index 5479eab26..8cd465d82 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml @@ -33,9 +33,11 @@ + + diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java index 427eabf66..4b7b8860f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java @@ -20,14 +20,13 @@ import org.eclipse.hawkbit.ui.HawkbitUI; import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout; import org.eclipse.hawkbit.ui.artifacts.event.ArtifactDetailsEvent; 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.smtable.SoftwareModuleTableLayout; import org.eclipse.hawkbit.ui.artifacts.smtype.SMTypeFilterLayout; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.upload.UploadLayout; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; -import org.eclipse.hawkbit.ui.management.event.DragEvent; +import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -38,7 +37,6 @@ import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.annotation.EventBusListenerMethod; -import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.server.Page; @@ -50,7 +48,6 @@ import com.vaadin.ui.Alignment; import com.vaadin.ui.DragAndDropWrapper; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; /** @@ -94,7 +91,7 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW 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 SoftwareManagement softwareManagement, final UploadViewClientCriterion uploadViewClientCriterion, final SPInfo spInfo, final ArtifactManagement artifactManagement) { this.eventBus = eventBus; this.permChecker = permChecker; @@ -102,15 +99,15 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW this.uiNotification = uiNotification; this.artifactUploadState = artifactUploadState; this.filterByTypeLayout = new SMTypeFilterLayout(artifactUploadState, i18n, permChecker, eventBus, - tagManagement, entityFactory, uiNotification, softwareManagement, uploadViewAcceptCriteria); + tagManagement, entityFactory, uiNotification, softwareManagement, uploadViewClientCriterion); this.smTableLayout = new SoftwareModuleTableLayout(i18n, permChecker, artifactUploadState, uiNotification, - eventBus, softwareManagement, entityFactory, uploadViewAcceptCriteria); + eventBus, softwareManagement, entityFactory, uploadViewClientCriterion); 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); + artifactUploadState, softwareManagement, uploadViewClientCriterion); } @PostConstruct @@ -161,7 +158,6 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW createMainLayout(); addComponents(mainLayout); setExpandRatio(mainLayout, 1); - hideDropHints(); } } @@ -257,17 +253,6 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW } - private void hideDropHints() { - UI.getCurrent().addClickListener(new ClickListener() { - private static final long serialVersionUID = 1L; - - @Override - public void click(final com.vaadin.event.MouseEvents.ClickEvent event) { - eventBus.publish(this, DragEvent.HIDE_DROP_HINT); - } - }); - } - private void checkNoDataAvaialble() { if (artifactUploadState.isNoDataAvilableSoftwareModule()) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadViewAcceptCriteria.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadViewAcceptCriteria.java deleted file mode 100644 index 98d9b49c8..000000000 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadViewAcceptCriteria.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.hawkbit.ui.artifacts.event; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria; -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.vaadin.spring.annotation.SpringComponent; -import com.vaadin.spring.annotation.UIScope; -import com.vaadin.ui.Component; - -/** - * Upload UI View for Accept criteria. - * - */ -@SpringComponent -@UIScope -public class UploadViewAcceptCriteria extends AbstractAcceptCriteria { - - private static final long serialVersionUID = 5158811326115667378L; - - private static final Map> DROP_CONFIGS = createDropConfigurations(); - - private static final Map DROP_HINTS_CONFIGS = createDropHintConfigurations(); - - @Autowired - UploadViewAcceptCriteria(final UINotification uiNotification, final UIEventBus eventBus) { - super(uiNotification, eventBus); - } - - @Override - protected String getComponentId(final Component component) { - String id = component.getId(); - if (id != null && id.startsWith(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) { - id = UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX; - } - return id; - } - - @Override - protected Map getDropHintConfigurations() { - return DROP_HINTS_CONFIGS; - } - - @Override - protected Map> getDropConfigurations() { - return DROP_CONFIGS; - } - - private static Map> createDropConfigurations() { - final Map> config = Maps.newHashMapWithExpectedSize(1); - // Delete drop area droppable components - config.put(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID, Arrays.asList( - UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)); - - return config; - } - - private static Map createDropHintConfigurations() { - final Map config = Maps.newHashMapWithExpectedSize(2); - config.put(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START); - config.put(UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UploadArtifactUIEvent.SOFTWARE_DRAG_START); - return config; - } -} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java index b6bdb4546..8910fcc8d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java @@ -13,11 +13,10 @@ 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.UploadViewAcceptCriteria; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout; import org.eclipse.hawkbit.ui.common.table.AbstractTable; -import org.eclipse.hawkbit.ui.management.event.DragEvent; +import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -44,16 +43,16 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { private final UploadViewConfirmationWindowLayout uploadViewConfirmationWindowLayout; - private final UploadViewAcceptCriteria uploadViewAcceptCriteria; + private final UploadViewClientCriterion uploadViewClientCriterion; public SMDeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus, final UINotification notification, final ArtifactUploadState artifactUploadState, - final SoftwareManagement softwareManagement, final UploadViewAcceptCriteria uploadViewAcceptCriteria) { + final SoftwareManagement softwareManagement, final UploadViewClientCriterion uploadViewClientCriterion) { super(i18n, permChecker, eventBus, notification); this.artifactUploadState = artifactUploadState; this.uploadViewConfirmationWindowLayout = new UploadViewConfirmationWindowLayout(i18n, eventBus, softwareManagement, artifactUploadState); - this.uploadViewAcceptCriteria = uploadViewAcceptCriteria; + this.uploadViewClientCriterion = uploadViewClientCriterion; init(); } @@ -74,10 +73,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { updateSWActionCount(); }); } - if (event == UploadArtifactUIEvent.SOFTWARE_DRAG_START - || event == UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START) { - showDropHints(); - } } private boolean isSoftwareEvent(final UploadArtifactUIEvent event) { @@ -92,14 +87,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { || event == UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE_TYPE; } - @EventBusListenerMethod(scope = EventScope.UI) - void onEvent(final DragEvent event) { - if (event == DragEvent.HIDE_DROP_HINT) { - UI.getCurrent().access(() -> hideDropHints()); - } - - } - @Override protected boolean hasDeletePermission() { return permChecker.hasDeleteDistributionPermission(); @@ -127,7 +114,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { @Override protected AcceptCriterion getDeleteLayoutAcceptCriteria() { - return uploadViewAcceptCriteria; + return uploadViewClientCriterion; } @Override @@ -152,7 +139,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { } } - hideDropHints(); } private void deleteSWModuleType(final String swModuleTypeName) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java index c9f4589b9..3ee219a0a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java @@ -16,11 +16,11 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; 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.common.table.AbstractNamedVersionTable; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -59,18 +59,18 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable targetSelectedList = new HashSet<>((Set) compsource.getValue()); - /** - * Remove null value if any . - */ - targetSelectedList.remove(null); - - if (previousRowCount != targetSelectedList.size()) { - previousRowCount = targetSelectedList.size(); - /* - * Prepare the hava script to add the