From 1220c8af3f765cca043fbcf7a9b58fc376d7f7ff Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 26 Sep 2014 15:48:37 +0000 Subject: [PATCH] Updated utils git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-open-widget@100232 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/TabResourcesSelectionCard.java | 52 ++++++++++++------ .../client/TabResourcesSelectionPanel.java | 54 ++++++++++++------- .../client/utils/InfoMessageBox.java | 28 ---------- .../td/openwidget/client/utils/UtilsGXT3.java | 51 ------------------ 4 files changed, 71 insertions(+), 114 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/td/openwidget/client/utils/InfoMessageBox.java delete mode 100644 src/main/java/org/gcube/portlets/user/td/openwidget/client/utils/UtilsGXT3.java diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java index d64a96d..922b643 100644 --- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java @@ -3,19 +3,20 @@ */ package org.gcube.portlets.user.td.openwidget.client; - import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData; import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession; -import org.gcube.portlets.user.td.openwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.widgetcommonevent.client.event.RibbonEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.RibbonType; 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.event.logical.shared.SelectionEvent; @@ -150,16 +151,28 @@ public class TabResourcesSelectionCard extends WizardCard { public void onFailure(Throwable caught) { if (caught instanceof TDGWTSessionExpiredException) { - getEventBus() - .fireEvent( - new SessionExpiredEvent( - SessionExpiredType.EXPIREDONSERVER)); + getEventBus().fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); } else { - Log.error("Error on delete TabResource: " - + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error", - "Error on delete TabResource: " + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + } else { + if (caught instanceof TDGWTIsFinalException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Final", + caught.getLocalizedMessage()); + } else { + Log.error("Error on delete TabResource: " + caught.getLocalizedMessage()); + UtilsGXT3.alert( + "Error", + "Error on delete TabResource: " + + caught.getLocalizedMessage()); + } + } } } @@ -202,11 +215,20 @@ public class TabResourcesSelectionCard extends WizardCard { new SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else { - Log.error("Error on set TabResource: " - + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error", - "Error on set TabResource: " - + caught.getLocalizedMessage()); + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + + } else { + Log.error("Error on set TabResource: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert( + "Error", + "Error on set TabResource: " + + caught.getLocalizedMessage()); + } + } } diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java index 5b77bc1..816b819 100644 --- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java @@ -8,15 +8,16 @@ import java.util.Arrays; import java.util.List; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.openwidget.client.resources.ResourceBundleTDOpen; -import org.gcube.portlets.user.td.openwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.widgetcommonevent.client.event.RibbonEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.RibbonType; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; 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; @@ -93,7 +94,8 @@ public class TabResourcesSelectionPanel extends ContentPanel implements private TabResourcesSelectionCard parent; - public TabResourcesSelectionPanel(TabResourcesSelectionCard parent, ResourceBundle res) { + public TabResourcesSelectionPanel(TabResourcesSelectionCard parent, + ResourceBundle res) { this.res = res; this.parent = parent; Log.debug("TabResourcesSelectionPanel"); @@ -107,7 +109,8 @@ public class TabResourcesSelectionPanel extends ContentPanel implements try { buildPanel(properties.id(), Arrays.> asList(nameColumn, - typeColumn, ownerColumn, agencyColumn, dateColumn), nameColumn); + typeColumn, ownerColumn, agencyColumn, dateColumn), + nameColumn); } catch (Throwable e) { Log.debug("Error building panel:" + e.getMessage()); @@ -117,7 +120,7 @@ public class TabResourcesSelectionPanel extends ContentPanel implements protected void init() { setHeaderVisible(false); - //new Resizable(this, Dir.E, Dir.SE, Dir.S); + // new Resizable(this, Dir.E, Dir.SE, Dir.S); } @@ -280,8 +283,10 @@ public class TabResourcesSelectionPanel extends ContentPanel implements } else { Log.error("Error retrieving tabular resource: " + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error", - "Error retrieving tabular resources on server!"); + parent.showErrorAndHide( + "Error", + "Error retrieving tabular resources on server!", + caught); } callback.onFailure(caught); } @@ -289,13 +294,13 @@ public class TabResourcesSelectionPanel extends ContentPanel implements public void onSuccess(ArrayList result) { Log.debug("loaded " + result.size() + " TabularResources"); - ArrayList avaibles=new ArrayList(); - for(TabResource tResource:result){ - if(!tResource.isLocked()){ + ArrayList avaibles = new ArrayList(); + for (TabResource tResource : result) { + if (!tResource.isLocked()) { avaibles.add(tResource); } } - + /* * for(TabResource tr:result){ Log.debug("TR:"+tr); } */ @@ -362,22 +367,31 @@ public class TabResourcesSelectionPanel extends ContentPanel implements new SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else { - Log.error("Error on delete TabResource: " - + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error", - "Error on delete TabResource: " - + caught.getLocalizedMessage()); + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + + } else { + Log.error("Error on delete TabResource: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert("Error", + "Error on delete TabResource: " + + caught.getLocalizedMessage()); + } } } public void onSuccess(Void result) { Log.debug("Remove tabular resource success"); - Log.debug("Check current tr for close: "+parent.trId); - if (parent.trId!=null && parent.trId.getId()!=null && parent.trId.getId().compareTo( - removableTR.getTrId() - .getId()) == 0) { + Log.debug("Check current tr for close: " + parent.trId); + if (parent.trId != null + && parent.trId.getId() != null + && parent.trId.getId().compareTo( + removableTR.getTrId().getId()) == 0) { Log.debug("Fire Close Event on current TR"); - parent.getEventBus().fireEvent(new RibbonEvent(RibbonType.CLOSE)); + parent.getEventBus().fireEvent( + new RibbonEvent(RibbonType.CLOSE)); } else { Log.debug("No tr opened"); } diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/utils/InfoMessageBox.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/utils/InfoMessageBox.java deleted file mode 100644 index 0c051cf..0000000 --- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/utils/InfoMessageBox.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.gcube.portlets.user.td.openwidget.client.utils; - -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/openwidget/client/utils/UtilsGXT3.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/utils/UtilsGXT3.java deleted file mode 100644 index 97eb4aa..0000000 --- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/utils/UtilsGXT3.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.gcube.portlets.user.td.openwidget.client.utils; - - -import com.google.gwt.user.client.Element; -import com.sencha.gxt.core.client.dom.XElement; -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 info(String title, String message) { - final InfoMessageBox d = new InfoMessageBox(title, message); - d.addHideHandler(new HideHandler() { - - public void onHide(HideEvent event) { - - } - }); - d.show(); - - } - -}