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
This commit is contained in:
Giancarlo Panichi 2014-09-26 16:16:23 +00:00 committed by Giancarlo Panichi
parent f4cbe52634
commit 112fe74d42
7 changed files with 134 additions and 111 deletions

View File

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

View File

@ -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 <code>null</code>.
* @param throwable the exception or <code>null</code>.
* @param reason the failure reason or <code>null</code>.
* @param details the failure details or <code>null</code>.
*/
public void failed(Throwable throwable, String reason, String details);
public void failed(String title, String message, Throwable throwable);
}

View File

@ -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<Dialog, Void>() {
public void showErrorAndHide(final String title, final String message,
final Throwable throwable) {
UtilsGXT3.alert(title, message, new Callback<Component,Void>() {
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);
}
}

View File

@ -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"
* <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)){
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

@ -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"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
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());
}
}

View File

@ -1,23 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.wizardwidget.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) {}
}

View File

@ -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"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class UtilsGXT3 {
public static void mask(Element element) {
XElement el = element.<XElement> cast();
el.mask("Loading...");
}
public static void umask(Element element) {
element.<XElement> 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<Component, Void> 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<Component, Void> 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();
}
}