Fix null handling for all drag and drop table
Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -8,16 +8,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.artifacts.footer;
|
package org.eclipse.hawkbit.ui.artifacts.footer;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
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.management.event.DragEvent;
|
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||||
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.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventScope;
|
import org.vaadin.spring.events.EventScope;
|
||||||
@@ -155,13 +154,9 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
|
|
||||||
private void addToDeleteList(final Table sourceTable, final TableTransferable transferable) {
|
private void addToDeleteList(final Table sourceTable, final TableTransferable transferable) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Set<Long> swModuleSelected = (Set<Long>) sourceTable.getValue();
|
final AbstractTable<?, Long> swTable = (AbstractTable<?, Long>) sourceTable;
|
||||||
final Set<Long> swModuleIdNameSet = new HashSet<>();
|
final Set<Long> swModuleIdNameSet = swTable.getDeletedEntityByTransferable(transferable);
|
||||||
if (!swModuleSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
|
|
||||||
swModuleIdNameSet.add((Long) transferable.getData(SPUIDefinitions.ITEMID));
|
|
||||||
} else {
|
|
||||||
swModuleIdNameSet.addAll(swModuleSelected);
|
|
||||||
}
|
|
||||||
swModuleIdNameSet.forEach(id -> {
|
swModuleIdNameSet.forEach(id -> {
|
||||||
final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id)
|
final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id)
|
||||||
.getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue();
|
.getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.common.table;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -231,6 +232,30 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the entity which should be deleted by a transferable
|
||||||
|
*
|
||||||
|
* @param transferable
|
||||||
|
* the table transferable
|
||||||
|
* @return set of entities id which will deleted
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Set<I> getDeletedEntityByTransferable(final TableTransferable transferable) {
|
||||||
|
final Set<I> selectedEntities = (Set<I>) getTableValue(this);
|
||||||
|
final Set<I> ids = new HashSet<>();
|
||||||
|
final Object tranferableData = transferable.getData(SPUIDefinitions.ITEMID);
|
||||||
|
if (tranferableData == null) {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selectedEntities.contains(tranferableData)) {
|
||||||
|
ids.add((I) tranferableData);
|
||||||
|
} else {
|
||||||
|
ids.addAll(selectedEntities);
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract E findEntityByTableValue(I lastSelectedId);
|
protected abstract E findEntityByTableValue(I lastSelectedId);
|
||||||
|
|
||||||
protected abstract void publishEntityAfterValueChange(E selectedLastEntity);
|
protected abstract void publishEntityAfterValueChange(E selectedLastEntity);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
|||||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
||||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
|
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
|
||||||
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
|
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
|
||||||
|
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
|
||||||
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.event.DistributionsViewAcceptCriteria;
|
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
|
||||||
@@ -208,17 +209,11 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void onDrop(final DragAndDropEvent event) {
|
private void onDrop(final DragAndDropEvent event) {
|
||||||
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
||||||
final Table source = transferable.getSourceComponent();
|
final AbstractTable<?, Long> source = (AbstractTable<SoftwareModule, Long>) transferable.getSourceComponent();
|
||||||
final Set<Long> softwareModuleSelected = (Set<Long>) source.getValue();
|
final Set<Long> softwareModulesIdList = source.getDeletedEntityByTransferable(transferable);
|
||||||
final Set<Long> softwareModulesIdList = new HashSet<>();
|
|
||||||
|
|
||||||
if (!softwareModuleSelected.contains(transferable.getData("itemId"))) {
|
|
||||||
softwareModulesIdList.add((Long) transferable.getData("itemId"));
|
|
||||||
} else {
|
|
||||||
softwareModulesIdList.addAll(softwareModuleSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
|
|||||||
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;
|
||||||
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.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.event.DistributionsViewAcceptCriteria;
|
||||||
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
|
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
|
||||||
@@ -188,13 +189,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
|
|
||||||
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
|
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Set<DistributionSetIdName> distSelected = (Set<DistributionSetIdName>) sourceTable.getValue();
|
final AbstractTable<?, DistributionSetIdName> table = (AbstractTable<?, DistributionSetIdName>) sourceTable;
|
||||||
final Set<DistributionSetIdName> distributionIdNameSet = new HashSet<>();
|
final Set<DistributionSetIdName> distributionIdNameSet = table.getDeletedEntityByTransferable(transferable);
|
||||||
if (!distSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
|
|
||||||
distributionIdNameSet.add((DistributionSetIdName) transferable.getData(SPUIDefinitions.ITEMID));
|
|
||||||
} else {
|
|
||||||
distributionIdNameSet.addAll(distSelected);
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Flags to identify whether all dropped distributions are already in
|
* Flags to identify whether all dropped distributions are already in
|
||||||
* the deleted list (or) some distributions are already in the deleted
|
* the deleted list (or) some distributions are already in the deleted
|
||||||
@@ -224,15 +220,10 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addToSWDeleteList(final Table sourceTable, final TableTransferable transferable) {
|
private void addToSWDeleteList(final Table sourceTable, final TableTransferable transferable) {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Set<Long> swModuleSelected = (Set<Long>) sourceTable.getValue();
|
final AbstractTable<?, Long> swTable = (AbstractTable<?, Long>) sourceTable;
|
||||||
final Set<Long> swModuleIdNameSet = new HashSet<>();
|
final Set<Long> swModuleIdNameSet = swTable.getDeletedEntityByTransferable(transferable);
|
||||||
if (!swModuleSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
|
|
||||||
swModuleIdNameSet.add((Long) transferable.getData(SPUIDefinitions.ITEMID));
|
|
||||||
} else {
|
|
||||||
swModuleIdNameSet.addAll(swModuleSelected);
|
|
||||||
}
|
|
||||||
swModuleIdNameSet.forEach(id -> {
|
swModuleIdNameSet.forEach(id -> {
|
||||||
final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id)
|
final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id)
|
||||||
.getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue();
|
.getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
|||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||||
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
|
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
|
||||||
|
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
|
||||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||||
@@ -350,17 +351,12 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void assignTargetToDs(final DragAndDropEvent event) {
|
private void assignTargetToDs(final DragAndDropEvent event) {
|
||||||
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
||||||
final Table source = transferable.getSourceComponent();
|
final AbstractTable<?, TargetIdName> source = (AbstractTable<?, TargetIdName>) transferable
|
||||||
final Set<TargetIdName> targetsSelected = getTableValue(source);
|
.getSourceComponent();
|
||||||
final Set<TargetIdName> targetDetailsList = new HashSet<>();
|
final Set<TargetIdName> targetDetailsList = source.getDeletedEntityByTransferable(transferable);
|
||||||
|
|
||||||
if (!targetsSelected.contains(transferable.getData("itemId"))) {
|
|
||||||
targetDetailsList.add((TargetIdName) transferable.getData("itemId"));
|
|
||||||
} else {
|
|
||||||
targetDetailsList.addAll(targetsSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.management.event;
|
package org.eclipse.hawkbit.ui.management.event;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -17,6 +16,7 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
|||||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
|
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||||
|
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
|
||||||
import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters;
|
import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters;
|
||||||
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;
|
||||||
@@ -127,28 +127,25 @@ public class DistributionTagDropEvent implements DropHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void processDistributionDrop(final DragAndDropEvent event) {
|
private void processDistributionDrop(final DragAndDropEvent event) {
|
||||||
|
|
||||||
final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails();
|
final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails();
|
||||||
|
|
||||||
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
||||||
final Table source = transferable.getSourceComponent();
|
final AbstractTable<?, DistributionSetIdName> source = (AbstractTable<?, DistributionSetIdName>) transferable
|
||||||
|
.getSourceComponent();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
final Set<DistributionSetIdName> distSelected = source.getDeletedEntityByTransferable(transferable);
|
||||||
final Set<DistributionSetIdName> distSelected = (Set<DistributionSetIdName>) source.getValue();
|
final Set<Long> distributionList = distSelected.stream().map(entity -> entity.getId())
|
||||||
final Set<Long> distributionList = new HashSet<>();
|
.collect(Collectors.toSet());
|
||||||
if (!distSelected.contains(transferable.getData(ITEMID))) {
|
|
||||||
distributionList.add(((DistributionSetIdName) transferable.getData(ITEMID)).getId());
|
|
||||||
} else {
|
|
||||||
distributionList.addAll(distSelected.stream().map(t -> t.getId()).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final String distTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(),
|
final String distTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(),
|
||||||
SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS);
|
SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS);
|
||||||
|
|
||||||
final List<String> tagsClickedList = distFilterParameters.getDistSetTags();
|
final List<String> tagsClickedList = distFilterParameters.getDistSetTags();
|
||||||
final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distributionList,
|
final DistributionSetTagAssignmentResult result = distributionSetManagement
|
||||||
distTagName);
|
.toggleTagAssignment(distributionList, distTagName);
|
||||||
|
|
||||||
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
|
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
|
||||||
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) {
|
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.management.footer;
|
package org.eclipse.hawkbit.ui.management.footer;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
import org.eclipse.hawkbit.repository.TagManagement;
|
||||||
@@ -257,15 +256,10 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
|
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
|
||||||
final Set<DistributionSetIdName> distSelected = AbstractTable.getTableValue(sourceTable);
|
final AbstractTable<?, DistributionSetIdName> distTable = (AbstractTable<?, DistributionSetIdName>) sourceTable;
|
||||||
final Set<DistributionSetIdName> distributionIdNameSet = new HashSet<>();
|
final Set<DistributionSetIdName> distributionIdNameSet = distTable.getDeletedEntityByTransferable(transferable);
|
||||||
|
|
||||||
if (!distSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
|
|
||||||
distributionIdNameSet.add((DistributionSetIdName) transferable.getData(SPUIDefinitions.ITEMID));
|
|
||||||
} else {
|
|
||||||
distributionIdNameSet.addAll(distSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
final DistributionSetIdName dsInBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload()
|
final DistributionSetIdName dsInBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload()
|
||||||
.getDsNameAndVersion();
|
.getDsNameAndVersion();
|
||||||
@@ -273,21 +267,22 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
distributionIdNameSet.remove(dsInBulkUpload);
|
distributionIdNameSet.remove(dsInBulkUpload);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!distributionIdNameSet.isEmpty()) {
|
if (distributionIdNameSet.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Flags to identify whether all dropped distributions are already
|
* Flags to identify whether all dropped distributions are already in
|
||||||
* in the deleted list (or) some distributions are already in the
|
* the deleted list (or) some distributions are already in the deleted
|
||||||
* deleted distribution list.
|
* distribution list.
|
||||||
*/
|
*/
|
||||||
final int existingDeletedDistributionsSize = managementUIState.getDeletedDistributionList().size();
|
final int existingDeletedDistributionsSize = managementUIState.getDeletedDistributionList().size();
|
||||||
managementUIState.getDeletedDistributionList().addAll(distributionIdNameSet);
|
managementUIState.getDeletedDistributionList().addAll(distributionIdNameSet);
|
||||||
final int newDeletedDistributionsSize = managementUIState.getDeletedDistributionList().size();
|
final int newDeletedDistributionsSize = managementUIState.getDeletedDistributionList().size();
|
||||||
if (newDeletedDistributionsSize == existingDeletedDistributionsSize) {
|
if (newDeletedDistributionsSize == existingDeletedDistributionsSize) {
|
||||||
/*
|
/*
|
||||||
* No new distributions are added, all distributions dropped now
|
* No new distributions are added, all distributions dropped now are
|
||||||
* are already available in the delete list. Hence display
|
* already available in the delete list. Hence display warning
|
||||||
* warning message accordingly.
|
* message accordingly.
|
||||||
*/
|
*/
|
||||||
notification.displayValidationError(i18n.get("message.targets.already.deleted"));
|
notification.displayValidationError(i18n.get("message.targets.already.deleted"));
|
||||||
} else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
|
} else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
|
||||||
@@ -299,7 +294,6 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
notification.displayValidationError(i18n.get("message.dist.deleted.pending"));
|
notification.displayValidationError(i18n.get("message.dist.deleted.pending"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isDsInUseInBulkUpload(final Set<DistributionSetIdName> distributionIdNameSet,
|
private boolean isDsInUseInBulkUpload(final Set<DistributionSetIdName> distributionIdNameSet,
|
||||||
final DistributionSetIdName dsInBulkUpload) {
|
final DistributionSetIdName dsInBulkUpload) {
|
||||||
@@ -311,15 +305,10 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void addInDeleteTargetList(final Table sourceTable, final TableTransferable transferable) {
|
private void addInDeleteTargetList(final Table sourceTable, final TableTransferable transferable) {
|
||||||
final Set<TargetIdName> targetSelected = AbstractTable.getTableValue(sourceTable);
|
final AbstractTable<?, TargetIdName> targetTable = (AbstractTable<?, TargetIdName>) sourceTable;
|
||||||
|
final Set<TargetIdName> targetIdNameSet = targetTable.getDeletedEntityByTransferable(transferable);
|
||||||
final Set<TargetIdName> targetIdNameSet = new HashSet<>();
|
|
||||||
if (!targetSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
|
|
||||||
targetIdNameSet.add((TargetIdName) transferable.getData(SPUIDefinitions.ITEMID));
|
|
||||||
} else {
|
|
||||||
targetIdNameSet.addAll(targetSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flags to identify whether all dropped targets are already in the
|
* Flags to identify whether all dropped targets are already in the
|
||||||
|
|||||||
@@ -632,16 +632,11 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static Set<DistributionSetIdName> getDraggedDistributionSet(final TableTransferable transferable,
|
private static Set<DistributionSetIdName> getDraggedDistributionSet(final TableTransferable transferable,
|
||||||
final Table source) {
|
final Table source) {
|
||||||
final Set<DistributionSetIdName> distSelected = getTableValue(source);
|
final AbstractTable<?, DistributionSetIdName> distTable = (AbstractTable<?, DistributionSetIdName>) source;
|
||||||
final Set<DistributionSetIdName> distributionIdSet = new HashSet<>();
|
return distTable.getDeletedEntityByTransferable(transferable);
|
||||||
if (!distSelected.contains(transferable.getData(ITEMID))) {
|
|
||||||
distributionIdSet.add((DistributionSetIdName) transferable.getData(ITEMID));
|
|
||||||
} else {
|
|
||||||
distributionIdSet.addAll(distSelected);
|
|
||||||
}
|
|
||||||
return distributionIdSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean validateDragAndDropWrapper(final Component compsource) {
|
private Boolean validateDragAndDropWrapper(final Component compsource) {
|
||||||
|
|||||||
@@ -378,16 +378,10 @@ public class TargetTableHeader extends AbstractTableHeader {
|
|||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private Set<DistributionSetIdName> getDropppedDistributionDetails(final TableTransferable transferable) {
|
private Set<DistributionSetIdName> getDropppedDistributionDetails(final TableTransferable transferable) {
|
||||||
final Set<DistributionSetIdName> distSelected = AbstractTable.getTableValue(transferable.getSourceComponent());
|
final AbstractTable<?, DistributionSetIdName> distTable = (AbstractTable<?, DistributionSetIdName>) transferable.getSourceComponent();
|
||||||
final Set<DistributionSetIdName> distributionIdSet = new HashSet<>();
|
return distTable.getDeletedEntityByTransferable(transferable);
|
||||||
if (!distSelected.contains(transferable.getData("itemId"))) {
|
|
||||||
distributionIdSet.add((DistributionSetIdName) transferable.getData("itemId"));
|
|
||||||
} else {
|
|
||||||
distributionIdSet.addAll(distSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
return distributionIdSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFilterTextField(final DistributionSetIdName distributionSetIdName) {
|
private void addFilterTextField(final DistributionSetIdName distributionSetIdName) {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.management.targettag;
|
package org.eclipse.hawkbit.ui.management.targettag;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -212,20 +211,16 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void processTargetDrop(final DragAndDropEvent event) {
|
private void processTargetDrop(final DragAndDropEvent event) {
|
||||||
|
|
||||||
final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails();
|
final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails();
|
||||||
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
||||||
final Table source = transferable.getSourceComponent();
|
final AbstractTable<?, TargetIdName> targetTable = (AbstractTable<?, TargetIdName>) transferable
|
||||||
|
.getSourceComponent();
|
||||||
|
|
||||||
final Set<TargetIdName> targetSelected = AbstractTable.getTableValue(source);
|
final Set<TargetIdName> targetSelected = targetTable.getDeletedEntityByTransferable(transferable);
|
||||||
final Set<String> targetList = new HashSet<>();
|
final Set<String> targetList = targetSelected.stream().map(t -> t.getControllerId())
|
||||||
if (transferable.getData(ITEMID) != null) {
|
.collect(Collectors.toSet());
|
||||||
if (!targetSelected.contains(transferable.getData(ITEMID))) {
|
|
||||||
targetList.add(((TargetIdName) transferable.getData(ITEMID)).getControllerId());
|
|
||||||
} else {
|
|
||||||
targetList.addAll(targetSelected.stream().map(t -> t.getControllerId()).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final String targTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(),
|
final String targTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(),
|
||||||
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
||||||
@@ -241,7 +236,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
|||||||
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty() && tagsClickedList.contains(targTagName)) {
|
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty() && tagsClickedList.contains(targTagName)) {
|
||||||
eventBus.publish(this, ManagementUIEvent.UNASSIGN_TARGET_TAG);
|
eventBus.publish(this, ManagementUIEvent.UNASSIGN_TARGET_TAG);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateIfSourceisTargetTable(final Table source) {
|
private boolean validateIfSourceisTargetTable(final Table source) {
|
||||||
|
|||||||
Reference in New Issue
Block a user