Refactoring: Extract some staff to private methods
Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -270,27 +270,20 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
|
||||
if (distributionIdNameSet.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Flags to identify whether all dropped distributions are already in
|
||||
* the deleted list (or) some distributions are already in the deleted
|
||||
* distribution list.
|
||||
*/
|
||||
checkDeletedDistributionSets(distributionIdNameSet);
|
||||
}
|
||||
|
||||
private void checkDeletedDistributionSets(final Set<DistributionSetIdName> distributionIdNameSet) {
|
||||
final int existingDeletedDistributionsSize = managementUIState.getDeletedDistributionList().size();
|
||||
managementUIState.getDeletedDistributionList().addAll(distributionIdNameSet);
|
||||
final int newDeletedDistributionsSize = managementUIState.getDeletedDistributionList().size();
|
||||
|
||||
if (newDeletedDistributionsSize == existingDeletedDistributionsSize) {
|
||||
/*
|
||||
* No new distributions are added, all distributions dropped now are
|
||||
* already available in the delete list. Hence display warning
|
||||
* message accordingly.
|
||||
*/
|
||||
notification.displayValidationError(i18n.get("message.targets.already.deleted"));
|
||||
} else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
|
||||
/*
|
||||
* Not the all distributions dropped now are added to the delete
|
||||
* list. There are some distributions are already there in the
|
||||
* delete list. Hence display warning message accordingly.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
|
||||
notification.displayValidationError(i18n.get("message.dist.deleted.pending"));
|
||||
}
|
||||
}
|
||||
@@ -310,28 +303,22 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
|
||||
final AbstractTable<?, TargetIdName> targetTable = (AbstractTable<?, TargetIdName>) sourceTable;
|
||||
final Set<TargetIdName> targetIdNameSet = targetTable.getDeletedEntityByTransferable(transferable);
|
||||
|
||||
/*
|
||||
* Flags to identify whether all dropped targets are already in the
|
||||
* deleted list (or) some target are already in the deleted distribution
|
||||
* list.
|
||||
*/
|
||||
checkDeletedTargets(targetIdNameSet);
|
||||
}
|
||||
|
||||
private void checkDeletedTargets(final Set<TargetIdName> targetIdNameSet) {
|
||||
final int existingDeletedTargetsSize = managementUIState.getDeletedTargetList().size();
|
||||
managementUIState.getDeletedTargetList().addAll(targetIdNameSet);
|
||||
final int newDeletedTargetsSize = managementUIState.getDeletedTargetList().size();
|
||||
|
||||
if (newDeletedTargetsSize == existingDeletedTargetsSize) {
|
||||
/*
|
||||
* No new targets are added, all targets dropped now are already
|
||||
* available in the delete list. Hence display warning message
|
||||
* accordingly.
|
||||
*/
|
||||
notification.displayValidationError(i18n.get("message.targets.already.deleted"));
|
||||
} else if (newDeletedTargetsSize - existingDeletedTargetsSize != targetIdNameSet.size()) {
|
||||
/*
|
||||
* Not the all targets dropped now are added to the delete list.
|
||||
* There are some targets are already there in the delete list.
|
||||
* Hence display warning message accordingly.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
if (newDeletedTargetsSize - existingDeletedTargetsSize != targetIdNameSet.size()) {
|
||||
notification.displayValidationError(i18n.get("message.target.deleted.pending"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -223,18 +223,33 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
||||
final String targTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(),
|
||||
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
||||
|
||||
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
|
||||
|
||||
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
|
||||
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, i18n));
|
||||
|
||||
if (result.getAssigned() >= 1 && managementUIState.getTargetTableFilters().isNoTagSelected()) {
|
||||
eventBus.publish(this, ManagementUIEvent.ASSIGN_TARGET_TAG);
|
||||
}
|
||||
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty() && tagsClickedList.contains(targTagName)) {
|
||||
eventBus.publish(this, ManagementUIEvent.UNASSIGN_TARGET_TAG);
|
||||
}
|
||||
publishAssignTargetTagEvent(result);
|
||||
|
||||
publishUnAssignTargetTagEvent(targTagName, result);
|
||||
|
||||
}
|
||||
|
||||
private void publishUnAssignTargetTagEvent(final String targTagName, final TargetTagAssignmentResult result) {
|
||||
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
|
||||
final boolean isTargetTagUnAssigned = result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()
|
||||
&& tagsClickedList.contains(targTagName);
|
||||
|
||||
if (!isTargetTagUnAssigned) {
|
||||
return;
|
||||
}
|
||||
eventBus.publish(this, ManagementUIEvent.UNASSIGN_TARGET_TAG);
|
||||
}
|
||||
|
||||
private void publishAssignTargetTagEvent(final TargetTagAssignmentResult result) {
|
||||
final boolean isNewTargetTagAssigned = result.getAssigned() >= 1
|
||||
&& managementUIState.getTargetTableFilters().isNoTagSelected();
|
||||
if (!isNewTargetTagAssigned) {
|
||||
return;
|
||||
}
|
||||
eventBus.publish(this, ManagementUIEvent.ASSIGN_TARGET_TAG);
|
||||
}
|
||||
|
||||
private boolean validateIfSourceisTargetTable(final Table source) {
|
||||
@@ -281,6 +296,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void addNewTargetTag(final TargetTag newTargetTag) {
|
||||
final LazyQueryContainer targetTagContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final Object addItem = targetTagContainer.addItem();
|
||||
|
||||
Reference in New Issue
Block a user