From 112fe74d42bf8f14748bfaa080126d5104da7c42 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 26 Sep 2014 16:16:23 +0000 Subject: [PATCH] Fixed Final and Lock error git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-wizard-widget@100237 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../td/wizardwidget/client/WizardCard.java | 4 +- .../wizardwidget/client/WizardListener.java | 6 +- .../td/wizardwidget/client/WizardWindow.java | 38 +++++---- .../client/util/ErrorMessageBox.java | 67 ---------------- .../client/util/InfoMessageBox.java | 28 +++++++ .../wizardwidget/client/util/NOPCallBack.java | 23 ------ .../wizardwidget/client/util/UtilsGXT3.java | 79 +++++++++++++++++++ 7 files changed, 134 insertions(+), 111 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/ErrorMessageBox.java create mode 100644 src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/InfoMessageBox.java delete mode 100644 src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/NOPCallBack.java create mode 100644 src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/UtilsGXT3.java diff --git a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardCard.java b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardCard.java index 9064301..8342645 100644 --- a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardCard.java +++ b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardCard.java @@ -263,9 +263,9 @@ public class WizardCard extends BorderLayoutContainer { return (indexPosition>=0)?indexPosition+1:indexPosition; } - public void showErrorAndHide(String title, final String failureReason, final String failureDetails, final Throwable throwable) + public void showErrorAndHide(String title, final String message, final Throwable throwable) { - wizardWindow.showErrorAndHide(title, failureReason, failureDetails, throwable); + wizardWindow.showErrorAndHide(title, message, throwable); } public void hideWindow() diff --git a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardListener.java b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardListener.java index b9255e3..4e9608e 100644 --- a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardListener.java +++ b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardListener.java @@ -32,10 +32,10 @@ public interface WizardListener { /** * Called when the something in the wizard is failed. + * @param title TODO + * @param message the failure reason or null. * @param throwable the exception or null. - * @param reason the failure reason or null. - * @param details the failure details or null. */ - public void failed(Throwable throwable, String reason, String details); + public void failed(String title, String message, Throwable throwable); } diff --git a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardWindow.java b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardWindow.java index 9da37bc..93b1fcc 100644 --- a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardWindow.java +++ b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardWindow.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle; -import org.gcube.portlets.user.td.wizardwidget.client.util.ErrorMessageBox; +import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.Callback; @@ -18,7 +18,7 @@ import com.google.web.bindery.event.shared.SimpleEventBus; import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; import com.sencha.gxt.core.client.resources.ThemeStyles; import com.sencha.gxt.core.client.util.Margins; -import com.sencha.gxt.widget.core.client.Dialog; +import com.sencha.gxt.widget.core.client.Component; import com.sencha.gxt.widget.core.client.Window; import com.sencha.gxt.widget.core.client.button.TextButton; import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData; @@ -450,20 +450,26 @@ public class WizardWindow extends Window { return cardStack; } - public void showErrorAndHide(String title, final String failureReason, - final String failureDetails, final Throwable throwable) { - ErrorMessageBox.showError(title, failureReason, failureDetails, - new Callback() { + public void showErrorAndHide(final String title, final String message, + final Throwable throwable) { + UtilsGXT3.alert(title, message, new Callback() { - - public void onSuccess(Dialog result) { - } + @Override + public void onFailure(Void reason) { + hide(); + fireFailed(title, message, throwable); + + } - public void onFailure(Void reason) { - hide(); - fireFailed(throwable, failureReason, failureDetails); - } - }); + @Override + public void onSuccess(Component result) { + hide(); + fireAborted(); + + } + + }); + } public void fireCompleted(TRId id) { @@ -482,8 +488,8 @@ public class WizardWindow extends Window { listener.aborted(); } - public void fireFailed(Throwable throwable, String reason, String details) { + public void fireFailed(String title, String message, Throwable throwable) { for (WizardListener listener : listeners) - listener.failed(throwable, reason, details); + listener.failed(title, message, throwable); } } diff --git a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/ErrorMessageBox.java b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/ErrorMessageBox.java deleted file mode 100644 index ba120c0..0000000 --- a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/ErrorMessageBox.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * - */ -package org.gcube.portlets.user.td.wizardwidget.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)){ - - 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/wizardwidget/client/util/InfoMessageBox.java b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/InfoMessageBox.java new file mode 100644 index 0000000..3e3fa8c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/InfoMessageBox.java @@ -0,0 +1,28 @@ +package org.gcube.portlets.user.td.wizardwidget.client.util; + +import com.sencha.gxt.widget.core.client.box.MessageBox; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class InfoMessageBox extends MessageBox { + + /** + * Creates a message box with an info icon and the specified title and + * message. + * + * @param title + * the message box title + * @param message + * the message displayed in the message box + */ + public InfoMessageBox(String title, String message) { + super(title, message); + + setIcon(ICONS.info()); + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/NOPCallBack.java b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/NOPCallBack.java deleted file mode 100644 index 5fbc627..0000000 --- a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/NOPCallBack.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * - */ -package org.gcube.portlets.user.td.wizardwidget.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) {} - -} diff --git a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/UtilsGXT3.java b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/UtilsGXT3.java new file mode 100644 index 0000000..bd767d7 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/util/UtilsGXT3.java @@ -0,0 +1,79 @@ +package org.gcube.portlets.user.td.wizardwidget.client.util; + + +import com.google.gwt.core.client.Callback; +import com.google.gwt.user.client.Element; +import com.sencha.gxt.core.client.dom.XElement; +import com.sencha.gxt.widget.core.client.Component; +import com.sencha.gxt.widget.core.client.box.AlertMessageBox; +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 UtilsGXT3 { + public static void mask(Element element) { + XElement el = element. cast(); + el.mask("Loading..."); + } + + public static void umask(Element element) { + element. cast().unmask(); + } + + + public static void alert(String title, String message) { + final AlertMessageBox d = new AlertMessageBox(title, message); + d.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + + } + }); + d.show(); + + } + + public static void alert(String title, String message, final Callback callback) { + final AlertMessageBox d = new AlertMessageBox(title, message); + d.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + Component comp=event.getSource(); + callback.onSuccess(comp); + } + }); + d.show(); + } + + + public static void info(String title, String message) { + final InfoMessageBox d = new InfoMessageBox(title, message); + d.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + + } + }); + d.show(); + + } + + public static void info(String title, String message, final Callback callback) { + final InfoMessageBox d = new InfoMessageBox(title, message); + d.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + Component comp=event.getSource(); + callback.onSuccess(comp); + } + }); + d.show(); + + } + +}