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); } } }
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); }
/** Automatically close if not error has occured. */ void uploadSessionFinished() { uploadAborted = false; if (!errorOccured && !artifactUploadState.isStatusPopupMinimized()) { clearWindow(); } artifactUploadState.setUploadCompleted(true); minimizeButton.setEnabled(false); closeButton.setEnabled(true); confirmDialog.getWindow().close(); UI.getCurrent().removeWindow(confirmDialog.getWindow()); }
void uploadSessionStarted() { if (artifactUploadState.getNumberOfFilesActuallyUpload().intValue() == 0 && artifactUploadState.getNumberOfFileUploadsFailed().intValue() == 0 && !artifactUploadState.isStatusPopupMinimized()) { openWindow(); } if (!uploadAborted) { minimizeButton.setEnabled(true); closeButton.setEnabled(true); artifactUploadState.setUploadCompleted(false); } }
private void onClose() { if (!artifactUploadState.isUploadCompleted()) { confirmAbortAction(); } else { clearWindow(); } }
@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); } }
/** * 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); } }
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); } }
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); } }
private void minimizeWindow() { this.close(); artifactUploadState.setStatusPopupMinimized(true); eventBus.publish(this, UploadArtifactUIEvent.MINIMIZED_STATUS_POPUP); }