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()) {
|
if (distributionIdNameSet.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
checkDeletedDistributionSets(distributionIdNameSet);
|
||||||
* Flags to identify whether all dropped distributions are already in
|
}
|
||||||
* the deleted list (or) some distributions are already in the deleted
|
|
||||||
* distribution list.
|
private void checkDeletedDistributionSets(final Set<DistributionSetIdName> distributionIdNameSet) {
|
||||||
*/
|
|
||||||
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 are
|
|
||||||
* already available in the delete list. Hence display warning
|
|
||||||
* message accordingly.
|
|
||||||
*/
|
|
||||||
notification.displayValidationError(i18n.get("message.targets.already.deleted"));
|
notification.displayValidationError(i18n.get("message.targets.already.deleted"));
|
||||||
} else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
|
return;
|
||||||
/*
|
}
|
||||||
* Not the all distributions dropped now are added to the delete
|
|
||||||
* list. There are some distributions are already there in the
|
if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
|
||||||
* delete list. Hence display warning message accordingly.
|
|
||||||
*/
|
|
||||||
notification.displayValidationError(i18n.get("message.dist.deleted.pending"));
|
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 AbstractTable<?, TargetIdName> targetTable = (AbstractTable<?, TargetIdName>) sourceTable;
|
||||||
final Set<TargetIdName> targetIdNameSet = targetTable.getDeletedEntityByTransferable(transferable);
|
final Set<TargetIdName> targetIdNameSet = targetTable.getDeletedEntityByTransferable(transferable);
|
||||||
|
|
||||||
/*
|
checkDeletedTargets(targetIdNameSet);
|
||||||
* Flags to identify whether all dropped targets are already in the
|
}
|
||||||
* deleted list (or) some target are already in the deleted distribution
|
|
||||||
* list.
|
private void checkDeletedTargets(final Set<TargetIdName> targetIdNameSet) {
|
||||||
*/
|
|
||||||
final int existingDeletedTargetsSize = managementUIState.getDeletedTargetList().size();
|
final int existingDeletedTargetsSize = managementUIState.getDeletedTargetList().size();
|
||||||
managementUIState.getDeletedTargetList().addAll(targetIdNameSet);
|
managementUIState.getDeletedTargetList().addAll(targetIdNameSet);
|
||||||
final int newDeletedTargetsSize = managementUIState.getDeletedTargetList().size();
|
final int newDeletedTargetsSize = managementUIState.getDeletedTargetList().size();
|
||||||
|
|
||||||
if (newDeletedTargetsSize == existingDeletedTargetsSize) {
|
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"));
|
notification.displayValidationError(i18n.get("message.targets.already.deleted"));
|
||||||
} else if (newDeletedTargetsSize - existingDeletedTargetsSize != targetIdNameSet.size()) {
|
return;
|
||||||
/*
|
}
|
||||||
* Not the all targets dropped now are added to the delete list.
|
|
||||||
* There are some targets are already there in the delete list.
|
if (newDeletedTargetsSize - existingDeletedTargetsSize != targetIdNameSet.size()) {
|
||||||
* Hence display warning message accordingly.
|
|
||||||
*/
|
|
||||||
notification.displayValidationError(i18n.get("message.target.deleted.pending"));
|
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(),
|
final String targTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(),
|
||||||
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
||||||
|
|
||||||
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
|
|
||||||
|
|
||||||
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
|
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
|
||||||
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, i18n));
|
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, i18n));
|
||||||
|
|
||||||
if (result.getAssigned() >= 1 && managementUIState.getTargetTableFilters().isNoTagSelected()) {
|
publishAssignTargetTagEvent(result);
|
||||||
eventBus.publish(this, ManagementUIEvent.ASSIGN_TARGET_TAG);
|
|
||||||
}
|
|
||||||
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty() && tagsClickedList.contains(targTagName)) {
|
|
||||||
eventBus.publish(this, ManagementUIEvent.UNASSIGN_TARGET_TAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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) {
|
private boolean validateIfSourceisTargetTable(final Table source) {
|
||||||
@@ -281,6 +296,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void addNewTargetTag(final TargetTag newTargetTag) {
|
private void addNewTargetTag(final TargetTag newTargetTag) {
|
||||||
final LazyQueryContainer targetTagContainer = (LazyQueryContainer) getContainerDataSource();
|
final LazyQueryContainer targetTagContainer = (LazyQueryContainer) getContainerDataSource();
|
||||||
final Object addItem = targetTagContainer.addItem();
|
final Object addItem = targetTagContainer.addItem();
|
||||||
|
|||||||
Reference in New Issue
Block a user