コード例 #1
0
 private void restoreState() {
   final Indexed container = grid.getContainerDataSource();
   if (container.getItemIds().isEmpty()) {
     container.removeAllItems();
     for (final UploadStatusObject statusObject :
         artifactUploadState.getUploadedFileStatusList()) {
       final Item item =
           container.addItem(
               getItemid(statusObject.getFilename(), statusObject.getSelectedSoftwareModule()));
       item.getItemProperty(REASON)
           .setValue(statusObject.getReason() != null ? statusObject.getReason() : "");
       if (statusObject.getStatus() != null) {
         item.getItemProperty(STATUS).setValue(statusObject.getStatus());
       }
       if (statusObject.getProgress() != null) {
         item.getItemProperty(PROGRESS).setValue(statusObject.getProgress());
       }
       item.getItemProperty(FILE_NAME).setValue(statusObject.getFilename());
       final SoftwareModule sw = statusObject.getSelectedSoftwareModule();
       item.getItemProperty(SPUILabelDefinitions.NAME_VERSION)
           .setValue(HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), sw.getVersion()));
     }
     if (artifactUploadState.isUploadCompleted()) {
       minimizeButton.setEnabled(false);
     }
   }
 }
コード例 #2
0
 protected void clearWindow() {
   errorOccured = false;
   uploads.removeAllItems();
   setWindowMode(WindowMode.NORMAL);
   setColumnWidth();
   setPopupSizeInMinMode();
   resizeButton.setIcon(FontAwesome.EXPAND);
   this.close();
   artifactUploadState.getUploadedFileStatusList().clear();
   artifactUploadState.getNumberOfFileUploadsFailed().set(0);
 }
コード例 #3
0
 @SuppressWarnings("unchecked")
 private void uploadRecevied(final String filename, final SoftwareModule softwareModule) {
   final Item item = uploads.addItem(getItemid(filename, softwareModule));
   if (item != null) {
     item.getItemProperty(FILE_NAME).setValue(filename);
     item.getItemProperty(SPUILabelDefinitions.NAME_VERSION)
         .setValue(
             HawkbitCommonUtil.getFormattedNameVersion(
                 softwareModule.getName(), softwareModule.getVersion()));
     final UploadStatusObject uploadStatus = new UploadStatusObject(filename, softwareModule);
     uploadStatus.setStatus("Active");
     artifactUploadState.getUploadedFileStatusList().add(uploadStatus);
   }
 }
コード例 #4
0
 /**
  * Called when each file upload is success.
  *
  * @param filename of the uploaded file.
  * @param softwareModule selected software module
  */
 public void uploadSucceeded(final String filename, final SoftwareModule softwareModule) {
   final Item item = uploads.getItem(getItemid(filename, softwareModule));
   final String status = "Finished";
   if (item != null) {
     item.getItemProperty(STATUS).setValue(status);
   }
   final List<UploadStatusObject> uploadStatusObjectList =
       artifactUploadState
           .getUploadedFileStatusList()
           .stream()
           .filter(e -> e.getFilename().equals(filename))
           .collect(Collectors.toList());
   if (!uploadStatusObjectList.isEmpty()) {
     final UploadStatusObject uploadStatusObject = uploadStatusObjectList.get(0);
     uploadStatusObject.setStatus(status);
     uploadStatusObject.setProgress(1d);
   }
 }
コード例 #5
0
 void uploadFailed(
     final String filename, final String errorReason, final SoftwareModule softwareModule) {
   errorOccured = true;
   final String status = "Failed";
   final Item item = uploads.getItem(getItemid(filename, softwareModule));
   if (item != null) {
     item.getItemProperty(REASON).setValue(errorReason);
     item.getItemProperty(STATUS).setValue(status);
   }
   final List<UploadStatusObject> uploadStatusObjectList =
       artifactUploadState
           .getUploadedFileStatusList()
           .stream()
           .filter(e -> e.getFilename().equals(filename))
           .collect(Collectors.toList());
   if (!uploadStatusObjectList.isEmpty()) {
     final UploadStatusObject uploadStatusObject = uploadStatusObjectList.get(0);
     uploadStatusObject.setStatus(status);
     uploadStatusObject.setReason(errorReason);
   }
 }
コード例 #6
0
 void updateProgress(
     final String filename,
     final long readBytes,
     final long contentLength,
     final SoftwareModule softwareModule) {
   final Item item = uploads.getItem(getItemid(filename, softwareModule));
   final double progress = (double) readBytes / (double) contentLength;
   if (item != null) {
     item.getItemProperty(PROGRESS).setValue(progress);
   }
   final List<UploadStatusObject> uploadStatusObjectList =
       artifactUploadState
           .getUploadedFileStatusList()
           .stream()
           .filter(e -> e.getFilename().equals(filename))
           .collect(Collectors.toList());
   if (!uploadStatusObjectList.isEmpty()) {
     final UploadStatusObject uploadStatusObject = uploadStatusObjectList.get(0);
     uploadStatusObject.setProgress(progress);
   }
 }