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:
Giancarlo Panichi 2014-09-26 15:04:16 +00:00
parent 52a78e6f61
commit 49221aac9f
8 changed files with 62 additions and 203 deletions

View File

@ -3,10 +3,6 @@ package org.gcube.portlets.user.td.csvimportwidget.client;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.user.td.csvimportwidget.client.csvgrid.CSVGrid; 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.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList; import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; 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.csv.CheckCSVSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; 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.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.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
@ -257,23 +257,21 @@ public class CSVConfigCard extends WizardCard {
new SessionExpiredEvent( new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
UtilsGXT3
ErrorMessageBox .alert("An error occured checking the file",
.showError( "Please retry, if the error perstists change the CSV configuration");
"An error occured checking the file",
"Please retry, if the error perstists change the CSV configuration",
"");
} }
} }
public void onSuccess(CheckCSVSession checkCSVSession) { public void onSuccess(CheckCSVSession checkCSVSession) {
ArrayList<CSVRowError> errors=checkCSVSession.getCsvRowErrorList(); ArrayList<CSVRowError> errors = checkCSVSession
.getCsvRowErrorList();
csvCheckPanel.getCheckConfiguration().setEnabled(true); csvCheckPanel.getCheckConfiguration().setEnabled(true);
if (errors.size() == 0) { if (errors.size() == 0) {
if(checkCSVSession.isCsvFileUpperMaxSizeCheck()){ if (checkCSVSession.isCsvFileUpperMaxSizeCheck()) {
CSVConfigCard.this.csvImportSession CSVConfigCard.this.csvImportSession
.setSkipInvalidLines(true); .setSkipInvalidLines(true);
} }
setCheckCorrectMessage(); setCheckCorrectMessage();
} else { } else {
@ -309,14 +307,11 @@ public class CSVConfigCard extends WizardCard {
new SessionExpiredEvent( new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("Failed updating CSV config", caught); Log.error("Failed updating CSV config", caught);
setEnableNextButton(false); setEnableNextButton(false);
ErrorMessageBox UtilsGXT3
.showError( .alert("An error occured checking the file",
"An error occured checking the file", "Please retry, if the error perstists change the CSV configuration");
"Please retry, if the error perstists change the CSV configuration",
caught.getLocalizedMessage());
} }
} }
@ -387,9 +382,9 @@ public class CSVConfigCard extends WizardCard {
new SessionExpiredEvent( new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
GWT.log("Error loading charset list", caught); Log.error("Error loading charset list", caught);
showErrorAndHide("Error loading charset list", showErrorAndHide("Error loading charset list",
"Error loading charset list", "", caught); "Error loading charset list", caught);
} }
} }
}); });

View File

@ -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.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; 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.WizardCard;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; 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.google.gwt.user.client.ui.FlexTable;
import com.sencha.gxt.core.client.util.Margins; import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel; 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.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer; 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;
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign; 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;
/** /**
* *
@ -76,20 +73,16 @@ public class CSVOperationInProgressCard extends WizardCard implements
summary.add(description); summary.add(description);
operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20, operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20,
5, 10, 5))); 5, 10, 5)));
resultField = new HtmlLayoutContainer("<div></div>");
resultField= new HtmlLayoutContainer("<div></div>");
operationInProgressPanel.add(resultField, new BoxLayoutData(
operationInProgressPanel.add(resultField, new BoxLayoutData( new new Margins(10, 5, 10, 5)));
Margins(10, 5, 10, 5)));
setContent(operationInProgressPanel); setContent(operationInProgressPanel);
resultField.setVisible(false); resultField.setVisible(false);
}
}
public void importCSV() { public void importCSV() {
TDGWTServiceAsync.INSTANCE.startCSVImport(importSession, TDGWTServiceAsync.INSTANCE.startCSVImport(importSession,
@ -97,7 +90,7 @@ public class CSVOperationInProgressCard extends WizardCard implements
public void onSuccess(String taskId) { public void onSuccess(String taskId) {
openMonitorDialog(taskId); openMonitorDialog(taskId);
} }
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -111,7 +104,7 @@ public class CSVOperationInProgressCard extends WizardCard implements
"Error in importCSV", "Error in importCSV",
"An error occured in importCSV: " "An error occured in importCSV: "
+ caught.getLocalizedMessage(), + caught.getLocalizedMessage(),
caught.getStackTrace().toString(), caught); caught);
} }
} }
}); });
@ -127,7 +120,7 @@ public class CSVOperationInProgressCard extends WizardCard implements
importCSV(); importCSV();
} }
// //
protected void openMonitorDialog(String taskId) { protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, getEventBus()); MonitorDialog monitorDialog = new MonitorDialog(taskId, getEventBus());
monitorDialog.addProgressDialogListener(this); monitorDialog.addProgressDialogListener(this);
@ -137,8 +130,9 @@ public class CSVOperationInProgressCard extends WizardCard implements
@Override @Override
public void operationComplete(TRId trId) { public void operationComplete(TRId trId) {
newTrId = trId; newTrId = trId;
SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder(); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
safeHtmlBuilder.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed</div>"); safeHtmlBuilder
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed</div>");
resultField.setHTML(safeHtmlBuilder.toSafeHtml()); resultField.setHTML(safeHtmlBuilder.toSafeHtml());
resultField.setVisible(true); resultField.setVisible(true);
Command sayComplete = new Command() { Command sayComplete = new Command() {
@ -165,8 +159,9 @@ public class CSVOperationInProgressCard extends WizardCard implements
@Override @Override
public void operationFailed(Throwable caught, String reason, String details) { public void operationFailed(Throwable caught, String reason, String details) {
SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder(); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
safeHtmlBuilder.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color:red;'>Operation Failed</div>"); safeHtmlBuilder
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color:red;'>Operation Failed</div>");
resultField.setHTML(safeHtmlBuilder.toSafeHtml()); resultField.setHTML(safeHtmlBuilder.toSafeHtml());
resultField.setVisible(true); resultField.setVisible(true);
if (caught instanceof TDGWTSessionExpiredException) { if (caught instanceof TDGWTSessionExpiredException) {
@ -175,13 +170,7 @@ public class CSVOperationInProgressCard extends WizardCard implements
new SessionExpiredEvent( new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
AlertMessageBox d = new AlertMessageBox("Error in CSV Import", UtilsGXT3.alert("Error in CSV Import", reason);
reason);
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
}
});
d.show();
} }
forceLayout(); forceLayout();
} }
@ -189,11 +178,12 @@ public class CSVOperationInProgressCard extends WizardCard implements
@Override @Override
public void operationStopped(TRId trId, String reason, String details) { public void operationStopped(TRId trId, String reason, String details) {
newTrId = trId; newTrId = trId;
SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder(); 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
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #FF9900;'>Problems in the Operation</div>");
resultField.setHTML(safeHtmlBuilder.toSafeHtml()); resultField.setHTML(safeHtmlBuilder.toSafeHtml());
resultField.setVisible(true); resultField.setVisible(true);
Command sayComplete = new Command() { Command sayComplete = new Command() {
public void execute() { public void execute() {
try { try {
@ -219,17 +209,18 @@ public class CSVOperationInProgressCard extends WizardCard implements
@Override @Override
public void operationAborted() { public void operationAborted() {
SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder(); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
safeHtmlBuilder.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #AA00AA;'>Operation Aborted</div>"); safeHtmlBuilder
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #AA00AA;'>Operation Aborted</div>");
resultField.setHTML(safeHtmlBuilder.toSafeHtml()); resultField.setHTML(safeHtmlBuilder.toSafeHtml());
resultField.setVisible(true); resultField.setVisible(true);
Command sayComplete = new Command() { Command sayComplete = new Command() {
public void execute() { public void execute() {
try { try {
getWizardWindow().close(false); getWizardWindow().close(false);
Log.info("fire Aborted"); Log.info("fire Aborted");
getWizardWindow().fireAborted(); getWizardWindow().fireAborted();
} catch (Exception e) { } catch (Exception e) {
@ -248,21 +239,23 @@ public class CSVOperationInProgressCard extends WizardCard implements
@Override @Override
public void operationPutInBackground() { public void operationPutInBackground() {
SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder(); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
safeHtmlBuilder.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #00AAAA;'>Operation in Background</div>"); safeHtmlBuilder
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #00AAAA;'>Operation in Background</div>");
resultField.setHTML(safeHtmlBuilder.toSafeHtml()); resultField.setHTML(safeHtmlBuilder.toSafeHtml());
resultField.setVisible(true); resultField.setVisible(true);
Command sayComplete = new Command() { Command sayComplete = new Command() {
public void execute() { public void execute() {
try { try {
getWizardWindow().close(false); getWizardWindow().close(false);
Log.info("fire Operation In Background"); Log.info("fire Operation In Background");
getWizardWindow().firePutInBackground(); getWizardWindow().firePutInBackground();
} catch (Exception e) { } catch (Exception e) {
Log.error("fire Operation In Background :" + e.getLocalizedMessage()); Log.error("fire Operation In Background :"
+ e.getLocalizedMessage());
} }
} }
}; };
@ -272,7 +265,7 @@ public class CSVOperationInProgressCard extends WizardCard implements
setNextButtonVisible(true); setNextButtonVisible(true);
getWizardWindow().setEnableNextButton(true); getWizardWindow().setEnableNextButton(true);
forceLayout(); forceLayout();
} }
} }

View File

@ -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.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData; 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.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.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; 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.WizardCard;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;

View File

@ -134,7 +134,7 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
thisCard.showErrorAndHide("Error", "Error retrieving the file from the workspace: "+caught.getLocalizedMessage(), thisCard.showErrorAndHide("Error", "Error retrieving the file from the workspace: "+caught.getLocalizedMessage(),
caught.toString(), caught); caught);
} }
} }

View File

@ -3,11 +3,12 @@
*/ */
package org.gcube.portlets.user.td.csvimportwidget.client; 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.FileUploadProgressBarUpdater;
import org.gcube.portlets.user.td.csvimportwidget.client.progress.FileUploadProgressListener; 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.csvimportwidget.client.progress.FileUploadProgressUpdater;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; 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.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT; 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.Style.HideMode;
import com.sencha.gxt.core.client.util.Padding; import com.sencha.gxt.core.client.util.Padding;
import com.sencha.gxt.widget.core.client.ProgressBar; 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.button.TextButton;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
@ -60,7 +60,6 @@ public class FileUploadPanel extends FormPanel {
addShowHandler(new ShowHandler() { addShowHandler(new ShowHandler() {
public void onShow(ShowEvent event) { public void onShow(ShowEvent event) {
doLayout(); doLayout();
@ -94,12 +93,12 @@ public class FileUploadPanel extends FormPanel {
uploadButton.setEnabled(fileUploadField.isValid()); uploadButton.setEnabled(fileUploadField.isValid());
String path = fileUploadField.getValue(); String path = fileUploadField.getValue();
int punto = path.lastIndexOf("."); int punto = path.lastIndexOf(".");
if(punto<0){ if (punto < 0) {
punto=path.length(); punto = path.length();
} }
int slash = path.lastIndexOf("/"); int slash = path.lastIndexOf("/");
int backslash = path.lastIndexOf("\\"); int backslash = path.lastIndexOf("\\");
String filename=""; String filename = "";
if (slash > backslash) { if (slash > backslash) {
if (slash != -1) { if (slash != -1) {
filename = path.substring(slash + 1, punto); filename = path.substring(slash + 1, punto);
@ -108,8 +107,7 @@ public class FileUploadPanel extends FormPanel {
if (backslash != -1) { if (backslash != -1) {
filename = path.substring(backslash + 1, punto); filename = path.substring(backslash + 1, punto);
} }
} }
importSession.setLocalFileName(filename); importSession.setLocalFileName(filename);
} }
@ -133,9 +131,9 @@ public class FileUploadPanel extends FormPanel {
if (fileUploadField.getValue() == null if (fileUploadField.getValue() == null
|| fileUploadField.getValue().equals("")) { || fileUploadField.getValue().equals("")) {
Log.info("fileUploadField is null or empty"); Log.info("fileUploadField is null or empty");
AlertMessageBox alertMessageBox = new AlertMessageBox( UtilsGXT3.alert("CSV file missing",
"CSV file missing", "Please specify a CSV file."); "Please specify a CSV file.");
alertMessageBox.show();
return; return;
} else { } else {
Log.info("startUpload call"); Log.info("startUpload call");
@ -156,14 +154,13 @@ public class FileUploadPanel extends FormPanel {
} }
public void operationInitializing() { public void operationInitializing() {
} }
public void operationFailed(Throwable caught, String reason, public void operationFailed(Throwable caught, String reason,
String failureDetails) { String failureDetails) {
card.showErrorAndHide("Error uploading the csv file", reason, card.showErrorAndHide("Error uploading the csv file", reason,
failureDetails, caught); caught);
} }
public void operationComplete() { public void operationComplete() {

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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) {}
}