Java 类com.vaadin.server.StreamVariable 实例源码

项目:mycollab    文件:ProjectCommentInputView.java   
@Override
public void streamingFinished(StreamVariable.StreamingEndEvent event) {
    String fileName = event.getFileName();
    int index = fileName.lastIndexOf(".");
    if (index > 0) {
        String fileExt = fileName.substring(index + 1, fileName.length());
        fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis() + "." + fileExt;
    }

    if (!indicators.isEmpty()) {
        statusWrapper.replaceComponent(indicators.remove(0), createAttachmentRow(fileName));
    }

    File file = receiver.getFile();
    receiveFile(file, fileName, event.getMimeType(), event.getBytesReceived());
    receiver.setValue(null);
}
项目:mycollab    文件:ProjectCommentInputView.java   
@Override
public void streamingFailed(StreamVariable.StreamingErrorEvent event) {
    if (!indicators.isEmpty()) {
        Label uploadResult = new Label("Upload failed! File: " + event.getFileName());
        uploadResult.setStyleName("upload-status");
        statusWrapper.replaceComponent(indicators.remove(0), uploadResult);
    }
}
项目:mycollab    文件:ProjectCommentInputView.java   
@Override
public void onProgress(StreamVariable.StreamingProgressEvent event) {
    long readBytes = event.getBytesReceived();
    long contentLength = event.getContentLength();
    float f = (float) readBytes / (float) contentLength;
    indicators.get(0).setValue(f);
}
项目: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);
}
项目:mycollab    文件:ProjectCommentInputView.java   
@Override
public void streamingStarted(StreamVariable.StreamingStartEvent event) {
}