Exemplo n.º 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();
    }
  }
Exemplo n.º 2
0
  private void onDelete(final ClickEvent event) {
    /* Display the confirmation */
    final ConfirmationDialog confirmDialog =
        new ConfirmationDialog(
            i18n.get("caption.filter.delete.confirmbox"),
            i18n.get("message.delete.filter.confirm"),
            i18n.get("button.ok"),
            i18n.get("button.cancel"),
            ok -> {
              if (ok) {
                final Long rowId = (Long) ((Button) event.getComponent()).getData();
                final String deletedFilterName =
                    targetFilterQueryManagement.findTargetFilterQueryById(rowId).getName();
                targetFilterQueryManagement.deleteTargetFilterQuery(rowId);

                /*
                 * Refresh the custom filter table to show latest change
                 * of the deleted custom filter.
                 */

                notification.displaySuccess(
                    i18n.get("message.delete.filter.success", new Object[] {deletedFilterName}));
                refreshContainer();
              }
            });
    UI.getCurrent().addWindow(confirmDialog.getWindow());
    confirmDialog.getWindow().bringToFront();
  }
  private void saveConfiguration() {
    defaultDistributionSetTypeLayout.save();
    authenticationConfigurationView.save();

    // More methods
    saveConfigurationBtn.setEnabled(false);
    undoConfigurationBtn.setEnabled(false);
    uINotification.displaySuccess(i18n.get("notification.configuration.save"));
  }
Exemplo n.º 4
0
 private void showOrHidePopupAndNotification(final String message) {
   if (null != managementUIState.getAssignedList()
       && !managementUIState.getAssignedList().isEmpty()) {
     eventBus.publish(this, ManagementUIEvent.UPDATE_COUNT);
   }
   if (null != message) {
     uiNotification.displayValidationError(message);
   }
 }
Exemplo n.º 5
0
 private Boolean isNoTagButton(final String tagData, final String targetNoTagData) {
   if (tagData.equals(targetNoTagData)) {
     uiNotification.displayValidationError(
         i18n.get(
             "message.tag.cannot.be.assigned", new Object[] {i18n.get("label.no.tag.assigned")}));
     return true;
   }
   return false;
 }
Exemplo n.º 6
0
 @Override
 protected boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource) {
   final String tagData = wrapperSource.getData().toString();
   if (wrapperSource.getId().startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)) {
     return !isNoTagButton(tagData, SPUIDefinitions.DISTRIBUTION_TAG_BUTTON);
   } else if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) {
     return !isNoTagButton(tagData, SPUIDefinitions.TARGET_TAG_BUTTON);
   }
   uiNotification.displayValidationError(notAllowedMsg);
   return false;
 }
Exemplo n.º 7
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}));
   }
 }