Пример #1
0
  private void assignDsTag(final DragAndDropEvent event) {
    final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails();
    final Table distTable = (Table) taregtDet.getTarget();
    final Set<DistributionSetIdName> distsSelected = getTableValue(distTable);
    final Set<Long> distList = new HashSet<>();

    final AbstractSelectTargetDetails dropData =
        (AbstractSelectTargetDetails) event.getTargetDetails();
    final Object distItemId = dropData.getItemIdOver();

    if (!distsSelected.contains(distItemId)) {
      distList.add(((DistributionSetIdName) distItemId).getId());
    } else {
      distList.addAll(distsSelected.stream().map(t -> t.getId()).collect(Collectors.toList()));
    }

    final String distTagName =
        HawkbitCommonUtil.removePrefix(
            event.getTransferable().getSourceComponent().getId(),
            SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS);

    final DistributionSetTagAssignmentResult result =
        distributionSetManagement.toggleTagAssignment(distList, distTagName);

    uiNotification.displaySuccess(
        HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
    if (result.getAssigned() >= 1
        && managementUIState.getDistributionTableFilters().isNoTagSelected()) {
      refreshFilter();
    }
  }
Пример #2
0
    /*
     * (non-Javadoc)
     *
     * @see
     * com.vaadin.event.dd.acceptCriteria.AcceptCriterion#accepts(com.vaadin
     * .event.dd.DragAndDropEvent)
     */
    @Override
    public boolean accept(DragAndDropEvent dragEvent) {
      AbstractSelectTargetDetails dropTargetData =
          (AbstractSelectTargetDetails) dragEvent.getTargetDetails();
      tree = (Tree) dragEvent.getTargetDetails().getTarget();
      allowedItemIds = getAllowedItemIds(dragEvent, tree);

      return allowedItemIds.contains(dropTargetData.getItemIdOver());
    }
Пример #3
0
  @SuppressWarnings("unchecked")
  private void assignTargetToDs(final DragAndDropEvent event) {
    final TableTransferable transferable = (TableTransferable) event.getTransferable();
    final AbstractTable<?, TargetIdName> source =
        (AbstractTable<?, TargetIdName>) transferable.getSourceComponent();
    final Set<TargetIdName> targetDetailsList = source.getDeletedEntityByTransferable(transferable);

    final AbstractSelectTargetDetails dropData =
        (AbstractSelectTargetDetails) event.getTargetDetails();

    final Object distItemId = dropData.getItemIdOver();
    assignTargetToDs(getItem(distItemId), targetDetailsList);
  }
Пример #4
0
 private void assignTargetTag(final DragAndDropEvent event) {
   final AbstractSelectTargetDetails dropData =
       (AbstractSelectTargetDetails) event.getTargetDetails();
   final Object distItemId = dropData.getItemIdOver();
   final String targetTagName =
       HawkbitCommonUtil.removePrefix(
           event.getTransferable().getSourceComponent().getId(),
           SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
   // get all the targets assigned to the tag
   // assign dist to those targets
   final List<Target> assignedTargets = targetService.findTargetsByTag(targetTagName);
   if (!assignedTargets.isEmpty()) {
     final Set<TargetIdName> targetDetailsList = new HashSet<>();
     assignedTargets.forEach(
         target ->
             targetDetailsList.add(
                 new TargetIdName(target.getId(), target.getControllerId(), target.getName())));
     assignTargetToDs(getItem(distItemId), targetDetailsList);
   } else {
     uiNotification.displaySuccess(
         i18n.get("message.no.targets.assiged.fortag", new Object[] {targetTagName}));
   }
 }