diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVConfigCard.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVConfigCard.java index 7711f9e..3ee5b6c 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVConfigCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVConfigCard.java @@ -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 errors=checkCSVSession.getCsvRowErrorList(); + ArrayList 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); } } }); diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVOperationInProgressCard.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVOperationInProgressCard.java index c349124..69f133d 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVOperationInProgressCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVOperationInProgressCard.java @@ -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; - /** * @@ -76,20 +73,16 @@ public class CSVOperationInProgressCard extends WizardCard implements summary.add(description); operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20, 5, 10, 5))); - - - resultField= new HtmlLayoutContainer("
"); - - operationInProgressPanel.add(resultField, new BoxLayoutData( new - Margins(10, 5, 10, 5))); - + + resultField = new HtmlLayoutContainer("
"); + + operationInProgressPanel.add(resultField, new BoxLayoutData( + new Margins(10, 5, 10, 5))); setContent(operationInProgressPanel); resultField.setVisible(false); - - } - + } public void importCSV() { TDGWTServiceAsync.INSTANCE.startCSVImport(importSession, @@ -97,7 +90,7 @@ public class CSVOperationInProgressCard extends WizardCard implements public void onSuccess(String taskId) { openMonitorDialog(taskId); - + } public void onFailure(Throwable caught) { @@ -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); } } }); @@ -127,7 +120,7 @@ public class CSVOperationInProgressCard extends WizardCard implements importCSV(); } - // + // protected void openMonitorDialog(String taskId) { MonitorDialog monitorDialog = new MonitorDialog(taskId, getEventBus()); monitorDialog.addProgressDialogListener(this); @@ -137,8 +130,9 @@ public class CSVOperationInProgressCard extends WizardCard implements @Override public void operationComplete(TRId trId) { newTrId = trId; - SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder(); - safeHtmlBuilder.appendHtmlConstant("
Operation Completed
"); + SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); + safeHtmlBuilder + .appendHtmlConstant("
Operation Completed
"); 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("
Operation Failed
"); + SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); + safeHtmlBuilder + .appendHtmlConstant("
Operation Failed
"); 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,11 +178,12 @@ public class CSVOperationInProgressCard extends WizardCard implements @Override public void operationStopped(TRId trId, String reason, String details) { newTrId = trId; - SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder(); - safeHtmlBuilder.appendHtmlConstant("
Problems in the Operation
"); + SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); + safeHtmlBuilder + .appendHtmlConstant("
Problems in the Operation
"); resultField.setHTML(safeHtmlBuilder.toSafeHtml()); resultField.setVisible(true); - + Command sayComplete = new Command() { public void execute() { try { @@ -219,17 +209,18 @@ public class CSVOperationInProgressCard extends WizardCard implements @Override public void operationAborted() { - SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder(); - safeHtmlBuilder.appendHtmlConstant("
Operation Aborted
"); + SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); + safeHtmlBuilder + .appendHtmlConstant("
Operation Aborted
"); resultField.setHTML(safeHtmlBuilder.toSafeHtml()); resultField.setVisible(true); - + Command sayComplete = new Command() { public void execute() { try { getWizardWindow().close(false); Log.info("fire Aborted"); - + getWizardWindow().fireAborted(); } catch (Exception e) { @@ -248,21 +239,23 @@ public class CSVOperationInProgressCard extends WizardCard implements @Override public void operationPutInBackground() { - SafeHtmlBuilder safeHtmlBuilder=new SafeHtmlBuilder(); - safeHtmlBuilder.appendHtmlConstant("
Operation in Background
"); + SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); + safeHtmlBuilder + .appendHtmlConstant("
Operation in Background
"); resultField.setHTML(safeHtmlBuilder.toSafeHtml()); resultField.setVisible(true); - + Command sayComplete = new Command() { public void execute() { try { getWizardWindow().close(false); Log.info("fire Operation In Background"); - + getWizardWindow().firePutInBackground(); } 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); getWizardWindow().setEnableNextButton(true); forceLayout(); - + } } diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java index 3bb4873..1832da5 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java @@ -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; diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVWorkSpaceSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVWorkSpaceSelectionCard.java index b9782a8..8add550 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVWorkSpaceSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVWorkSpaceSelectionCard.java @@ -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); } } diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/FileUploadPanel.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/FileUploadPanel.java index 7696e18..5942f68 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/FileUploadPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/FileUploadPanel.java @@ -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); @@ -108,8 +107,7 @@ public class FileUploadPanel extends FormPanel { if (backslash != -1) { 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"); @@ -156,14 +154,13 @@ 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() { diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/util/ErrorMessageBox.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/util/ErrorMessageBox.java deleted file mode 100644 index 167b3d1..0000000 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/util/ErrorMessageBox.java +++ /dev/null @@ -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" - * g.panichi@isti.cnr.it - * - */ -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()); - } - - public static void showError(String title, String failureReason, final String failureDetails, final Callback 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("
"+failureDetails+"
")); - - - simple.setHideOnButtonClick(true); - simple.setWidth(400); - simple.setHeight(400); - simple.show(); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/util/Format.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/util/Format.java deleted file mode 100644 index e74ab33..0000000 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/util/Format.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * - */ -package org.gcube.portlets.user.td.csvimportwidget.client.util; - -/** - * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * - */ -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(); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/util/NOPCallBack.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/util/NOPCallBack.java deleted file mode 100644 index 59c6279..0000000 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/util/NOPCallBack.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * - */ -package org.gcube.portlets.user.td.csvimportwidget.client.util; - -import com.google.gwt.core.client.Callback; - -/** - * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * - * @param - * @param - */ -public class NOPCallBack implements Callback { - - public void onFailure(F reason) {} - - public void onSuccess(T result) {} - -}