This commit is contained in:
Giancarlo Panichi 2013-12-06 11:18:37 +00:00 committed by Giancarlo Panichi
parent ea3fec0985
commit e59c1bfb8e
3 changed files with 0 additions and 133 deletions

View File

@ -1,72 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.openwidget.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() {
@Override
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);
}
});
/*FIXME box.setIcon(MessageBox.ERROR);
box.getDialog().cancelText = DETAILS;
box.getDialog().setButtons(MessageBox.OKCANCEL);*/
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.getItem(0).getFocusSupport().setIgnore(true);
//FIXME simple.setScrollMode(ScrollMode.AUTO);
simple.setHideOnButtonClick(true);
simple.setWidth(400);
simple.setHeight(400);
simple.show();
}
}

View File

@ -1,37 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.openwidget.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,24 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.openwidget.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> {
@Override
public void onFailure(F reason) {}
@Override
public void onSuccess(T result) {}
}