Example #1
0
 private void rePinDistribution(final Button pinBtn, final Long distID) {
   if (managementUIState.getTargetTableFilters().getPinnedDistId().isPresent()
       && distID.equals(managementUIState.getTargetTableFilters().getPinnedDistId().get())) {
     applyPinStyle(pinBtn);
     isDistPinned = Boolean.TRUE;
     distributinPinnedBtn = pinBtn;
     eventBus.publish(this, PinUnpinEvent.PIN_DISTRIBUTION);
   }
 }
Example #2
0
 /**
  * TenantAwareEvent Listener for Pinning Distribution.
  *
  * @param event
  */
 @EventBusListenerMethod(scope = EventScope.UI)
 public void onEvent(final PinUnpinEvent event) {
   if (event == PinUnpinEvent.PIN_DISTRIBUTION
       && managementUIState.getTargetTableFilters().getPinnedDistId().isPresent()) {
     displayCountLabel(managementUIState.getTargetTableFilters().getPinnedDistId().get());
   } else {
     setValue("");
     displayTargetCountStatus();
   }
 }
Example #3
0
 private void saveDistributionPinnedBtn(final Button pinBtn) {
   if (managementUIState.getTargetTableFilters().getPinnedDistId().isPresent()
       && managementUIState
           .getTargetTableFilters()
           .getPinnedDistId()
           .get()
           .equals(((DistributionSetIdName) pinBtn.getData()).getId())) {
     setDistributinPinnedBtn(pinBtn);
   }
 }
Example #4
0
  private void displayTargetCountStatus() {
    final TargetTableFilters targFilParams = managementUIState.getTargetTableFilters();
    final StringBuilder message = getTotalTargetMessage();

    if (targFilParams.hasFilter()) {
      message.append(HawkbitCommonUtil.SP_STRING_PIPE);
      message.append(i18n.get("label.filter.targets"));
      if (managementUIState.getTargetsTruncated() != null) {
        message.append(targetTable.size() + managementUIState.getTargetsTruncated());
      } else {
        message.append(targetTable.size());
      }
      message.append(HawkbitCommonUtil.SP_STRING_PIPE);
      final String status = i18n.get("label.filter.status");
      final String overdue = i18n.get("label.filter.overdue");
      final String tags = i18n.get("label.filter.tags");
      final String text = i18n.get("label.filter.text");
      final String dists = i18n.get("label.filter.dist");
      final String custom = i18n.get("label.filter.custom");
      final StringBuilder filterMesgBuf = new StringBuilder(i18n.get("label.filter"));
      filterMesgBuf.append(HawkbitCommonUtil.SP_STRING_SPACE);
      filterMesgBuf.append(getStatusMsg(targFilParams.getClickedStatusTargetTags(), status));
      filterMesgBuf.append(getOverdueStateMsg(targFilParams.isOverdueFilterEnabled(), overdue));
      filterMesgBuf.append(
          getTagsMsg(targFilParams.isNoTagSelected(), targFilParams.getClickedTargetTags(), tags));
      filterMesgBuf.append(
          targFilParams
              .getSearchText()
              .map(search -> text)
              .orElse(HawkbitCommonUtil.SP_STRING_SPACE));
      filterMesgBuf.append(
          targFilParams
              .getDistributionSet()
              .map(set -> dists)
              .orElse(HawkbitCommonUtil.SP_STRING_SPACE));
      filterMesgBuf.append(
          targFilParams
              .getTargetFilterQuery()
              .map(query -> custom)
              .orElse(HawkbitCommonUtil.SP_STRING_SPACE));
      final String filterMesageChk = filterMesgBuf.toString().trim();
      String filterMesage = filterMesageChk;
      if (filterMesage.endsWith(",")) {
        filterMesage = filterMesageChk.substring(0, filterMesageChk.length() - 1);
      }
      message.append(filterMesage);
    }

    if ((targetTable.size() + Optional.fromNullable(managementUIState.getTargetsTruncated()).or(0L))
        > SPUIDefinitions.MAX_TABLE_ENTRIES) {
      message.append(HawkbitCommonUtil.SP_STRING_PIPE);
      message.append(i18n.get("label.filter.shown"));
      message.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
    }

    setCaption(message.toString());
  }
Example #5
0
  private void checkifAlreadyPinned(final Button eventBtn) {
    final Long newPinnedDistItemId = ((DistributionSetIdName) eventBtn.getData()).getId();
    Long pinnedDistId = null;
    if (managementUIState.getTargetTableFilters().getPinnedDistId().isPresent()) {
      pinnedDistId = managementUIState.getTargetTableFilters().getPinnedDistId().get();
    }
    if (pinnedDistId == null) {
      isDistPinned = !isDistPinned;
      managementUIState.getTargetTableFilters().setPinnedDistId(newPinnedDistItemId);
    } else if (newPinnedDistItemId.equals(pinnedDistId)) {
      isDistPinned = Boolean.FALSE;
    } else {
      isDistPinned = true;
      managementUIState.getTargetTableFilters().setPinnedDistId(newPinnedDistItemId);
      distributinPinnedBtn.setStyleName(getPinStyle());
    }

    distributinPinnedBtn = eventBtn;
  }
Example #6
0
 private void unPinDistribution(final Button eventBtn) {
   managementUIState.getTargetTableFilters().setPinnedDistId(null);
   eventBus.publish(this, PinUnpinEvent.UNPIN_DISTRIBUTION);
   resetPinStyle(eventBtn);
 }