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
This commit is contained in:
Giancarlo Panichi 2014-09-26 15:48:37 +00:00 committed by Giancarlo Panichi
parent c138fd5d41
commit 1220c8af3f
4 changed files with 71 additions and 114 deletions

View File

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

View File

@ -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.<ColumnConfig<TabResource, ?>> 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<TabResource> result) {
Log.debug("loaded " + result.size()
+ " TabularResources");
ArrayList<TabResource> avaibles=new ArrayList<TabResource>();
for(TabResource tResource:result){
if(!tResource.isLocked()){
ArrayList<TabResource> avaibles = new ArrayList<TabResource>();
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");
}

View File

@ -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"
* <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,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"
* <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 info(String title, String message) {
final InfoMessageBox d = new InfoMessageBox(title, message);
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
}
});
d.show();
}
}