@Override protected void processDroppedComponent(final DragAndDropEvent event) { final Component sourceComponent = event.getTransferable().getSourceComponent(); if (sourceComponent instanceof Table) { final Table sourceTable = (Table) event.getTransferable().getSourceComponent(); addToDeleteList(sourceTable, (TableTransferable) event.getTransferable()); updateSWActionCount(); } if (sourceComponent.getId().startsWith(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) { final String swModuleTypeName = sourceComponent.getId() .replace(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, ""); if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType() .map(type -> type.getName().equalsIgnoreCase(swModuleTypeName)).orElse(false)) { notification.displayValidationError( i18n.getMessage("message.swmodule.type.check.delete", new Object[] { swModuleTypeName })); } else { deleteSWModuleType(swModuleTypeName); updateSWActionCount(); } } }
private void filterByDroppedDist(final DragAndDropEvent event) { if (doValidations(event)) { final TableTransferable tableTransferable = (TableTransferable) event.getTransferable(); final Table source = tableTransferable.getSourceComponent(); if (!UIComponentIdProvider.DIST_TABLE_ID.equals(source.getId())) { return; } final Set<Long> distributionIdSet = getDropppedDistributionDetails(tableTransferable); if (CollectionUtils.isEmpty(distributionIdSet)) { return; } final Long distributionSetId = distributionIdSet.iterator().next(); final Optional<DistributionSet> distributionSet = distributionSetManagement .get(distributionSetId); if (!distributionSet.isPresent()) { notification.displayWarning(i18n.getMessage("distributionset.not.exists")); return; } final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distributionSet.get()); getManagementUIState().getTargetTableFilters().setDistributionSet(distributionSetIdName); addFilterTextField(distributionSetIdName); } }
/** * Validation for drag event. * * @param dragEvent * @return */ private Boolean doValidations(final DragAndDropEvent dragEvent) { final Component compsource = dragEvent.getTransferable().getSourceComponent(); Boolean isValid = Boolean.TRUE; if (compsource instanceof Table && !isComplexFilterViewDisplayed) { final TableTransferable transferable = (TableTransferable) dragEvent.getTransferable(); final Table source = transferable.getSourceComponent(); if (!source.getId().equals(UIComponentIdProvider.DIST_TABLE_ID)) { notification.displayValidationError(i18n.getMessage("message.action.not.allowed")); isValid = Boolean.FALSE; } else { if (getDropppedDistributionDetails(transferable).size() > 1) { notification.displayValidationError(i18n.getMessage("message.onlyone.distribution.dropallowed")); isValid = Boolean.FALSE; } } } else { notification.displayValidationError(i18n.getMessage("message.action.not.allowed")); isValid = Boolean.FALSE; } return isValid; }
private void processDistributionDrop(final DragAndDropEvent event) { final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails(); final TableTransferable transferable = (TableTransferable) event.getTransferable(); final AbstractTable<?> source = (AbstractTable<?>) transferable.getSourceComponent(); final Set<Long> distSelected = source.getDeletedEntityByTransferable(transferable); final String distTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(), SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS); final List<String> tagsClickedList = distFilterParameters.getDistSetTags(); final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distSelected, distTagName); notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n)); if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) { eventBus.publish(this, TargetFilterEvent.FILTER_BY_TAG); } }
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) { final AbstractTable<?> distTable = (AbstractTable<?>) sourceTable; final Set<Long> ids = distTable.getDeletedEntityByTransferable(transferable); final Long dsInBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload().getDsNameAndVersion(); if (isDsInUseInBulkUpload(ids, dsInBulkUpload)) { ids.remove(dsInBulkUpload); } if (ids.isEmpty()) { return; } final List<DistributionSet> findDistributionSetAllById = distributionSetManagement.get(ids); if (findDistributionSetAllById.isEmpty()) { notification.displayWarning(i18n.getMessage("distributionsets.not.exists")); return; } final Set<DistributionSetIdName> distributionIdNameSet = findDistributionSetAllById.stream() .map(distributionSet -> new DistributionSetIdName(distributionSet)).collect(Collectors.toSet()); checkDeletedDistributionSets(distributionIdNameSet); }
@Override protected void processDroppedComponent(final DragAndDropEvent event) { final Component sourceComponent = event.getTransferable().getSourceComponent(); if (sourceComponent instanceof Table) { final Table sourceTable = (Table) event.getTransferable().getSourceComponent(); if (isDistributionTable(sourceTable)) { addInDeleteDistributionList(sourceTable, (TableTransferable) event.getTransferable()); updateDSActionCount(); } else if (isSoftwareModuleTable(sourceTable)) { addToSWDeleteList(sourceTable, (TableTransferable) event.getTransferable()); updateDSActionCount(); } } else if (sourceComponent.getId().startsWith(SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS)) { processDeleteDitSetType(sourceComponent.getId()); } else if (sourceComponent.getId().startsWith(SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS)) { processDeleteSWType(sourceComponent.getId()); } }
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) { final AbstractTable<?> table = (AbstractTable<?>) sourceTable; final Set<Long> ids = table.getDeletedEntityByTransferable(transferable); final List<DistributionSet> findDistributionSetAllById = distributionSetManagement .get(ids); if (findDistributionSetAllById.isEmpty()) { notification.displayWarning(i18n.getMessage("distributionsets.not.exists")); return; } final Set<DistributionSetIdName> distributionIdNameSet = findDistributionSetAllById.stream() .map(DistributionSetIdName::new).collect(Collectors.toSet()); final int existingDeletedDistributionsSize = manageDistUIState.getDeletedDistributionList().size(); manageDistUIState.getDeletedDistributionList().addAll(distributionIdNameSet); final int newDeletedDistributionsSize = manageDistUIState.getDeletedDistributionList().size(); if (newDeletedDistributionsSize == existingDeletedDistributionsSize) { notification.displayValidationError(i18n.getMessage("message.targets.already.deleted")); } else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) { notification.displayValidationError(i18n.getMessage("message.dist.deleted.pending")); } }
private void addToDeleteList(final Table sourceTable, final TableTransferable transferable) { final AbstractTable<?> swTable = (AbstractTable<?>) sourceTable; final Set<Long> swModuleIdNameSet = swTable.getDeletedEntityByTransferable(transferable); swModuleIdNameSet.forEach(id -> { final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id) .getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue(); artifactUploadState.getDeleteSofwareModules().put(id, swModuleName); }); }
@Override public void drop(final DragAndDropEvent event) { if (validate(event) && isNoTagAssigned(event)) { final TableTransferable tbl = (TableTransferable) event.getTransferable(); final Table source = tbl.getSourceComponent(); if (source.getId().equals(UIComponentIdProvider.DIST_TABLE_ID)) { processDistributionDrop(event); } } }
private Boolean validate(final DragAndDropEvent event) { final Component compsource = event.getTransferable().getSourceComponent(); if (!(compsource instanceof Table)) { notification.displayValidationError(i18n.getMessage(SPUILabelDefinitions.ACTION_NOT_ALLOWED)); return false; } else { final Table source = ((TableTransferable) event.getTransferable()).getSourceComponent(); if (!validateIfSourceIsDs(source) && !checkForDSUpdatePermission()) { return false; } } return true; }
private void processDeletion(final DragAndDropEvent event, final Component source) { if (DeleteActionsLayoutHelper.isTargetTable(source) && canTargetBeDeleted()) { addInDeleteTargetList((Table) source, (TableTransferable) event.getTransferable()); updateActionCount(); } else if (DeleteActionsLayoutHelper.isDistributionTable(source) && canDSBeDeleted()) { addInDeleteDistributionList((Table) source, (TableTransferable) event.getTransferable()); updateActionCount(); } else if (DeleteActionsLayoutHelper.isTargetTag(source) && canTargetBeDeleted() && tagNotInUSeInBulkUpload(source)) { deleteTargetTag(source); } else if (DeleteActionsLayoutHelper.isDistributionTag(source) && canDSBeDeleted()) { deleteDistributionTag(source); } }
private void addInDeleteTargetList(final Table sourceTable, final TableTransferable transferable) { final TargetTable targetTable = (TargetTable) sourceTable; final Set<Long> targetIdSet = targetTable.getDeletedEntityByTransferable(transferable); final Collection<Target> findTargetAllById = targetManagement.get(targetIdSet); if (findTargetAllById.isEmpty()) { notification.displayWarning(i18n.getMessage("targets.not.exists")); return; } final Set<TargetIdName> targetIdNames = findTargetAllById.stream().map(target -> new TargetIdName(target)) .collect(Collectors.toSet()); checkDeletedTargets(targetIdNames); }
private void addToSWDeleteList(final Table sourceTable, final TableTransferable transferable) { final AbstractTable<?> swTable = (AbstractTable<?>) sourceTable; final Set<Long> swModuleIdNameSet = swTable.getDeletedEntityByTransferable(transferable); swModuleIdNameSet.forEach(id -> { final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id) .getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue(); manageDistUIState.getDeleteSofwareModulesList().put(id, swModuleName); }); }
@Override public void drop(DragAndDropEvent event) { Transferable t = event.getTransferable(); Component source = t.getSourceComponent(); if (source != this.treeWorkspace) { assert(false); throw new IllegalArgumentException(); } TableTransferable tt = (TableTransferable) t; File sourceFile = (File) tt.getItemId(); AbstractSelectTargetDetails target = (AbstractSelectTargetDetails)event.getTargetDetails(); File targetFile = (File) target.getItemIdOver(); if (sourceFile.isFile() && targetFile != null && targetFile.isDirectory()) { // // Construct destination filename // Path dest = targetFile.toPath().resolve(sourceFile.getName()); // // Check if the target domain exists // if (Files.exists(dest)) { // // Prompt the user // Notification.show("A policy file with that name already exists in that directory.", Notification.Type.ERROR_MESSAGE); } else { // // Go ahead and rename it // this.renamePolicyFile(sourceFile, dest.toFile(), targetFile); } } }
private static Set<Long> getDropppedDistributionDetails(final TableTransferable transferable) { final AbstractTable<?> distTable = (AbstractTable<?>) transferable.getSourceComponent(); return distTable.getDeletedEntityByTransferable(transferable); }