Fixed Final and Lock error
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-import-widget@100228 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
52a78e6f61
commit
49221aac9f
|
@ -3,10 +3,6 @@ package org.gcube.portlets.user.td.csvimportwidget.client;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.csvimportwidget.client.csvgrid.CSVGrid;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
import org.gcube.portlets.user.td.csvimportwidget.client.util.ErrorMessageBox;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
|
||||
|
@ -14,6 +10,10 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CheckCSVSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -257,23 +257,21 @@ public class CSVConfigCard extends WizardCard {
|
|||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
|
||||
ErrorMessageBox
|
||||
.showError(
|
||||
"An error occured checking the file",
|
||||
"Please retry, if the error perstists change the CSV configuration",
|
||||
"");
|
||||
UtilsGXT3
|
||||
.alert("An error occured checking the file",
|
||||
"Please retry, if the error perstists change the CSV configuration");
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(CheckCSVSession checkCSVSession) {
|
||||
ArrayList<CSVRowError> errors=checkCSVSession.getCsvRowErrorList();
|
||||
ArrayList<CSVRowError> errors = checkCSVSession
|
||||
.getCsvRowErrorList();
|
||||
csvCheckPanel.getCheckConfiguration().setEnabled(true);
|
||||
|
||||
if (errors.size() == 0) {
|
||||
if(checkCSVSession.isCsvFileUpperMaxSizeCheck()){
|
||||
if (checkCSVSession.isCsvFileUpperMaxSizeCheck()) {
|
||||
CSVConfigCard.this.csvImportSession
|
||||
.setSkipInvalidLines(true);
|
||||
.setSkipInvalidLines(true);
|
||||
}
|
||||
setCheckCorrectMessage();
|
||||
} else {
|
||||
|
@ -309,14 +307,11 @@ public class CSVConfigCard extends WizardCard {
|
|||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
|
||||
Log.error("Failed updating CSV config", caught);
|
||||
setEnableNextButton(false);
|
||||
ErrorMessageBox
|
||||
.showError(
|
||||
"An error occured checking the file",
|
||||
"Please retry, if the error perstists change the CSV configuration",
|
||||
caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("An error occured checking the file",
|
||||
"Please retry, if the error perstists change the CSV configuration");
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -387,9 +382,9 @@ public class CSVConfigCard extends WizardCard {
|
|||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
GWT.log("Error loading charset list", caught);
|
||||
Log.error("Error loading charset list", caught);
|
||||
showErrorAndHide("Error loading charset list",
|
||||
"Error loading charset list", "", caught);
|
||||
"Error loading charset list", caught);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredE
|
|||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
|
@ -20,14 +21,10 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||
import com.google.gwt.user.client.ui.FlexTable;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -77,20 +74,16 @@ public class CSVOperationInProgressCard extends WizardCard implements
|
|||
operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20,
|
||||
5, 10, 5)));
|
||||
|
||||
resultField = new HtmlLayoutContainer("<div></div>");
|
||||
|
||||
resultField= new HtmlLayoutContainer("<div></div>");
|
||||
|
||||
operationInProgressPanel.add(resultField, new BoxLayoutData( new
|
||||
Margins(10, 5, 10, 5)));
|
||||
|
||||
operationInProgressPanel.add(resultField, new BoxLayoutData(
|
||||
new Margins(10, 5, 10, 5)));
|
||||
|
||||
setContent(operationInProgressPanel);
|
||||
resultField.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void importCSV() {
|
||||
TDGWTServiceAsync.INSTANCE.startCSVImport(importSession,
|
||||
new AsyncCallback<String>() {
|
||||
|
@ -111,7 +104,7 @@ public class CSVOperationInProgressCard extends WizardCard implements
|
|||
"Error in importCSV",
|
||||
"An error occured in importCSV: "
|
||||
+ caught.getLocalizedMessage(),
|
||||
caught.getStackTrace().toString(), caught);
|
||||
caught);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -137,8 +130,9 @@ public class CSVOperationInProgressCard extends WizardCard implements
|
|||
@Override
|
||||
public void operationComplete(TRId trId) {
|
||||
newTrId = trId;
|
||||
SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder();
|
||||
safeHtmlBuilder.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed</div>");
|
||||
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||
safeHtmlBuilder
|
||||
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed</div>");
|
||||
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||
resultField.setVisible(true);
|
||||
Command sayComplete = new Command() {
|
||||
|
@ -165,8 +159,9 @@ public class CSVOperationInProgressCard extends WizardCard implements
|
|||
|
||||
@Override
|
||||
public void operationFailed(Throwable caught, String reason, String details) {
|
||||
SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder();
|
||||
safeHtmlBuilder.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color:red;'>Operation Failed</div>");
|
||||
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||
safeHtmlBuilder
|
||||
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color:red;'>Operation Failed</div>");
|
||||
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||
resultField.setVisible(true);
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
|
@ -175,13 +170,7 @@ public class CSVOperationInProgressCard extends WizardCard implements
|
|||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
AlertMessageBox d = new AlertMessageBox("Error in CSV Import",
|
||||
reason);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
public void onHide(HideEvent event) {
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
UtilsGXT3.alert("Error in CSV Import", reason);
|
||||
}
|
||||
forceLayout();
|
||||
}
|
||||
|
@ -189,8 +178,9 @@ public class CSVOperationInProgressCard extends WizardCard implements
|
|||
@Override
|
||||
public void operationStopped(TRId trId, String reason, String details) {
|
||||
newTrId = trId;
|
||||
SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder();
|
||||
safeHtmlBuilder.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #FF9900;'>Problems in the Operation</div>");
|
||||
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||
safeHtmlBuilder
|
||||
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #FF9900;'>Problems in the Operation</div>");
|
||||
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||
resultField.setVisible(true);
|
||||
|
||||
|
@ -219,8 +209,9 @@ public class CSVOperationInProgressCard extends WizardCard implements
|
|||
|
||||
@Override
|
||||
public void operationAborted() {
|
||||
SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder();
|
||||
safeHtmlBuilder.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #AA00AA;'>Operation Aborted</div>");
|
||||
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||
safeHtmlBuilder
|
||||
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #AA00AA;'>Operation Aborted</div>");
|
||||
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||
resultField.setVisible(true);
|
||||
|
||||
|
@ -248,8 +239,9 @@ public class CSVOperationInProgressCard extends WizardCard implements
|
|||
|
||||
@Override
|
||||
public void operationPutInBackground() {
|
||||
SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder();
|
||||
safeHtmlBuilder.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #00AAAA;'>Operation in Background</div>");
|
||||
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||
safeHtmlBuilder
|
||||
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #00AAAA;'>Operation in Background</div>");
|
||||
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||
resultField.setVisible(true);
|
||||
|
||||
|
@ -262,7 +254,8 @@ public class CSVOperationInProgressCard extends WizardCard implements
|
|||
getWizardWindow().firePutInBackground();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("fire Operation In Background :" + e.getLocalizedMessage());
|
||||
Log.error("fire Operation In Background :"
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -12,10 +12,10 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
|
|
@ -134,7 +134,7 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
|
|||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
thisCard.showErrorAndHide("Error", "Error retrieving the file from the workspace: "+caught.getLocalizedMessage(),
|
||||
caught.toString(), caught);
|
||||
caught);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.csvimportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.csvimportwidget.client.progress.FileUploadProgressBarUpdater;
|
||||
import org.gcube.portlets.user.td.csvimportwidget.client.progress.FileUploadProgressListener;
|
||||
import org.gcube.portlets.user.td.csvimportwidget.client.progress.FileUploadProgressUpdater;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -16,7 +17,6 @@ import com.google.gwt.event.dom.client.ChangeHandler;
|
|||
import com.sencha.gxt.core.client.Style.HideMode;
|
||||
import com.sencha.gxt.core.client.util.Padding;
|
||||
import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
|
@ -60,7 +60,6 @@ public class FileUploadPanel extends FormPanel {
|
|||
|
||||
addShowHandler(new ShowHandler() {
|
||||
|
||||
|
||||
public void onShow(ShowEvent event) {
|
||||
doLayout();
|
||||
|
||||
|
@ -94,12 +93,12 @@ public class FileUploadPanel extends FormPanel {
|
|||
uploadButton.setEnabled(fileUploadField.isValid());
|
||||
String path = fileUploadField.getValue();
|
||||
int punto = path.lastIndexOf(".");
|
||||
if(punto<0){
|
||||
punto=path.length();
|
||||
if (punto < 0) {
|
||||
punto = path.length();
|
||||
}
|
||||
int slash = path.lastIndexOf("/");
|
||||
int backslash = path.lastIndexOf("\\");
|
||||
String filename="";
|
||||
String filename = "";
|
||||
if (slash > backslash) {
|
||||
if (slash != -1) {
|
||||
filename = path.substring(slash + 1, punto);
|
||||
|
@ -109,7 +108,6 @@ public class FileUploadPanel extends FormPanel {
|
|||
filename = path.substring(backslash + 1, punto);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
importSession.setLocalFileName(filename);
|
||||
}
|
||||
|
@ -133,9 +131,9 @@ public class FileUploadPanel extends FormPanel {
|
|||
if (fileUploadField.getValue() == null
|
||||
|| fileUploadField.getValue().equals("")) {
|
||||
Log.info("fileUploadField is null or empty");
|
||||
AlertMessageBox alertMessageBox = new AlertMessageBox(
|
||||
"CSV file missing", "Please specify a CSV file.");
|
||||
alertMessageBox.show();
|
||||
UtilsGXT3.alert("CSV file missing",
|
||||
"Please specify a CSV file.");
|
||||
|
||||
return;
|
||||
} else {
|
||||
Log.info("startUpload call");
|
||||
|
@ -157,13 +155,12 @@ public class FileUploadPanel extends FormPanel {
|
|||
|
||||
public void operationInitializing() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void operationFailed(Throwable caught, String reason,
|
||||
String failureDetails) {
|
||||
card.showErrorAndHide("Error uploading the csv file", reason,
|
||||
failureDetails, caught);
|
||||
caught);
|
||||
}
|
||||
|
||||
public void operationComplete() {
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.csvimportwidget.client.util;
|
||||
|
||||
import com.google.gwt.core.client.Callback;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.sencha.gxt.widget.core.client.Dialog;
|
||||
import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
|
||||
import com.sencha.gxt.widget.core.client.box.MessageBox;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ErrorMessageBox {
|
||||
|
||||
|
||||
private static final String DETAILS = "Details";
|
||||
|
||||
|
||||
public static void showError(String title, String failureReason, final String failureDetails)
|
||||
{
|
||||
showError(title, failureReason, failureDetails, new NOPCallBack<Dialog, Void>());
|
||||
}
|
||||
|
||||
public static void showError(String title, String failureReason, final String failureDetails, final Callback<Dialog, Void> callback)
|
||||
{
|
||||
final MessageBox box = new MessageBox(title);
|
||||
box.setMessage(failureReason);
|
||||
box.addHideHandler(new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
Dialog dialog = (Dialog) event.getSource();
|
||||
|
||||
if (dialog.getHideButton().getText().equals(DETAILS)){
|
||||
//box.close();
|
||||
showErrorDetails("Error details", failureDetails);
|
||||
} else callback.onSuccess(dialog);
|
||||
}
|
||||
});
|
||||
|
||||
box.show();
|
||||
}
|
||||
|
||||
public static void showErrorDetails(String title, String failureDetails)
|
||||
{
|
||||
final Dialog simple = new Dialog();
|
||||
simple.setHeadingText(title);
|
||||
simple.setPredefinedButtons(PredefinedButton.OK);
|
||||
simple.setBodyStyleName("pad-text");
|
||||
|
||||
|
||||
simple.add(new Label("<PRE>"+failureDetails+"</PRE>"));
|
||||
|
||||
|
||||
simple.setHideOnButtonClick(true);
|
||||
simple.setWidth(400);
|
||||
simple.setHeight(400);
|
||||
simple.show();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.csvimportwidget.client.util;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class Format {
|
||||
|
||||
/**
|
||||
* Converts a file size into a {@link String} representation adding the misure unit.
|
||||
* @param size the file size.
|
||||
* @return the textual representation.
|
||||
*/
|
||||
public static String fileSize(long size) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
if (size < 1024) {
|
||||
text.append(size);
|
||||
text.append(" bytes");
|
||||
} else if (size < 1048576) {
|
||||
text.append(Math.round(((size * 10) / 1024)) / 10);
|
||||
text.append(" KB");
|
||||
} else if (size < 1073741824) {
|
||||
text.append(Math.round(((size * 10) / 1048576)) / 10);
|
||||
text.append(" MB");
|
||||
} else {
|
||||
text.append(Math.round(((size * 10) / 1073741824)) / 10);
|
||||
text.append(" GB");
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.csvimportwidget.client.util;
|
||||
|
||||
import com.google.gwt.core.client.Callback;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
* @param <T>
|
||||
* @param <F>
|
||||
*/
|
||||
public class NOPCallBack<T,F> implements Callback<T, F> {
|
||||
|
||||
public void onFailure(F reason) {}
|
||||
|
||||
public void onSuccess(T result) {}
|
||||
|
||||
}
|
Loading…
Reference in New Issue