Java 类com.vaadin.ui.Html5File 实例源码

项目:hawkbit    文件:UploadLayout.java   
@Override
public void drop(final DragAndDropEvent event) {
    if (validate(event)) {
        final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
        // selected software module at the time of file drop is
        // considered for upload

        artifactUploadState.getSelectedBaseSwModuleId().ifPresent(selectedSwId -> {
            // reset the flag
            hasDirectory = false;
            final SoftwareModule softwareModule = softwareModuleManagement.get(selectedSwId)
                    .orElse(null);
            for (final Html5File file : files) {
                processFile(file, softwareModule);
            }
            if (artifactUploadState.getNumberOfFileUploadsExpected().get() > 0) {
                processBtn.setEnabled(false);
            } else {
                // If the upload is not started, it signifies all
                // dropped files as either duplicate or directory.So
                // display message accordingly
                displayCompositeMessage();
            }
        });
    }
}
项目:hawkbit    文件:UploadLayout.java   
private boolean isFilesDropped(final DragAndDropEvent event) {
    if (event.getTransferable() instanceof WrapperTransferable) {
        final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
        return files != null;
    }
    return false;
}
项目:hawkbit    文件:UploadLayout.java   
private void processFile(final Html5File file, final SoftwareModule selectedSw) {
    if (!isDirectory(file)) {
        if (!checkForDuplicate(file.getFileName(), selectedSw)) {

            eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.RECEIVE_UPLOAD,
                    new UploadFileStatus(file.getFileName(), 0, -1, selectedSw)));

            artifactUploadState.getNumberOfFileUploadsExpected().incrementAndGet();
            file.setStreamVariable(createStreamVariable(file, selectedSw));
        }
    } else {
        hasDirectory = Boolean.TRUE;
    }
}
项目:hawkbit    文件:UploadLayout.java   
private StreamVariable createStreamVariable(final Html5File file, final SoftwareModule selectedSw) {
    return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this,
            multipartConfigElement.getMaxFileSize(), null, file.getType(), selectedSw, softwareModuleManagement);
}
项目:hawkbit    文件:UploadLayout.java   
private boolean isDirectory(final Html5File file) {
    return StringUtils.isEmpty(file.getType()) && file.getFileSize() % 4096 == 0;
}