Review comments addresses
Signed-off-by: asharani-murugesh <asharani.murugesh@in.bosch.com>
This commit is contained in:
@@ -111,7 +111,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
|||||||
//reset has directory flag before upload
|
//reset has directory flag before upload
|
||||||
view.setHasDirectory(false);
|
view.setHasDirectory(false);
|
||||||
try {
|
try {
|
||||||
if (view.validate()) {
|
if (view.checkIfSoftwareModuleIsSelected()) {
|
||||||
if (view.checkForDuplicate(fileName)) {
|
if (view.checkForDuplicate(fileName)) {
|
||||||
view.showDuplicateMessage();
|
view.showDuplicateMessage();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ import com.vaadin.spring.annotation.SpringComponent;
|
|||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.Alignment;
|
import com.vaadin.ui.Alignment;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.Component;
|
|
||||||
import com.vaadin.ui.DragAndDropWrapper;
|
import com.vaadin.ui.DragAndDropWrapper;
|
||||||
import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable;
|
import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
@@ -188,24 +187,22 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(final DragAndDropEvent event) {
|
public void drop(final DragAndDropEvent event) {
|
||||||
if (event.getTransferable() instanceof WrapperTransferable && validate()) {
|
if (validate(event)) {
|
||||||
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
|
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
|
||||||
if (files != null) {
|
// reset the flag
|
||||||
// reset the flag
|
hasDirectory = Boolean.FALSE;
|
||||||
hasDirectory = Boolean.FALSE;
|
for (final Html5File file : files) {
|
||||||
for (final Html5File file : files) {
|
processFile(file);
|
||||||
processFile(file);
|
}
|
||||||
}
|
if (numberOfFileUploadsExpected.get() > 0) {
|
||||||
if (numberOfFileUploadsExpected.get() > 0) {
|
processBtn.setEnabled(false);
|
||||||
processBtn.setEnabled(false);
|
// reset before we start
|
||||||
// reset before we start
|
uploadInfoWindow.uploadSessionStarted();
|
||||||
uploadInfoWindow.uploadSessionStarted();
|
} else {
|
||||||
} else {
|
// If the upload is not started, it signifies all
|
||||||
// If the upload is not started, it signifies all
|
// dropped files as either duplicate or directory.So
|
||||||
// dropped files as either duplicate or directory.So
|
// display message accordingly
|
||||||
// display message accordingly
|
displayCompositeMessage();
|
||||||
displayCompositeMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,10 +351,33 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean validate() {
|
Boolean validate(DragAndDropEvent event) {
|
||||||
|
// check if drop is valid.If valid ,check if software module is
|
||||||
|
// selected.
|
||||||
|
if(!isFilesDropped(event)){
|
||||||
|
uiNotification.displayValidationError(i18n.get("message.action.not.allowed"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return checkIfSoftwareModuleIsSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isFilesDropped(DragAndDropEvent event) {
|
||||||
|
if (event.getTransferable() instanceof WrapperTransferable) {
|
||||||
|
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
|
||||||
|
// other components can also be wrapped in WrapperTransferable , so
|
||||||
|
// additional check on files
|
||||||
|
if (files == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean checkIfSoftwareModuleIsSelected() {
|
||||||
if (!isSoftwareModuleSelected()) {
|
if (!isSoftwareModuleSelected()) {
|
||||||
uiNotification.displayValidationError(i18n.get("message.error.noSwModuleSelected"));
|
uiNotification.displayValidationError(i18n.get("message.error.noSwModuleSelected"));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user