Added delete option for tabular resource without table

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-open-widget@93992 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-04-01 14:21:02 +00:00 committed by Giancarlo Panichi
parent 12a91b9740
commit 26084460f9
2 changed files with 91 additions and 36 deletions

View File

@ -4,9 +4,9 @@
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.tr.open.TDOpenSession;
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.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
@ -15,7 +15,9 @@ import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
@ -48,7 +50,6 @@ public class TabResourcesSelectionCard extends WizardCard {
tabResourcesSelectionPanel
.addSelectionHandler(new SelectionHandler<TabResource>() {
public void onSelection(SelectionEvent<TabResource> event) {
tdOpenSession
.setSelectedTabResource(tabResourcesSelectionPanel
@ -79,18 +80,19 @@ public class TabResourcesSelectionCard extends WizardCard {
protected void retrieveLastTable() {
TDGWTServiceAsync.INSTANCE.getLastTable(tdOpenSession
.getSelectedTabResource().getTrId(), new AsyncCallback<TableData>(){
.getSelectedTabResource().getTrId(),
new AsyncCallback<TableData>() {
@Override
public void onFailure(Throwable caught) {
Log.debug("Attention", "This tabular resource does not have a valid table");
AlertMessageBox d = new AlertMessageBox(
"Attention", "This tabular resource does not have a valid table"
+ caught.getLocalizedMessage());
Log.debug("Attention",
"This tabular resource does not have a valid table");
AlertMessageBox d = new AlertMessageBox("Attention",
"This tabular resource does not have a valid table");
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
// TODO Auto-generated method stub
removeTRWithLastTableNull();
}
});
@ -108,6 +110,55 @@ public class TabResourcesSelectionCard extends WizardCard {
}
protected void removeTRWithLastTableNull() {
final ConfirmMessageBox mb = new ConfirmMessageBox("Remove",
"Would you like to remove this tabular resource without table?");
mb.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES
.name())) {
callRemoveLastTable();
} else if (mb.getHideButton() == mb
.getButtonById(PredefinedButton.NO.name())) {
// perform NO action
}
}
});
mb.setWidth(300);
mb.show();
}
protected void callRemoveLastTable(){
Log.debug("Remove TR:" + tdOpenSession
.getSelectedTabResource().getTrId());
TDGWTServiceAsync.INSTANCE.removeTabularResource(tdOpenSession
.getSelectedTabResource().getTrId(),
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
AlertMessageBox d = new AlertMessageBox("Error",
"Error on remove TabResource: "
+ caught.getLocalizedMessage());
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
// TODO Auto-generated method stub
}
});
d.show();
}
public void onSuccess(Void result) {
tabResourcesSelectionPanel.gridReload();
}
});
}
protected void updateTDOpenSessionInfo(TableData table) {
TabResource tabResource = tdOpenSession.getSelectedTabResource();
TRId trId = tabResource.getTrId();
@ -119,14 +170,13 @@ public class TabResourcesSelectionCard extends WizardCard {
setTabularResource();
}
protected void setTabularResource() {
TDGWTServiceAsync.INSTANCE.setTabResource(tdOpenSession
.getSelectedTabResource(),
TDGWTServiceAsync.INSTANCE.setTabResource(
tdOpenSession.getSelectedTabResource(),
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
AlertMessageBox d = new AlertMessageBox(
"Error", "Error on set TabResource: "
AlertMessageBox d = new AlertMessageBox("Error",
"Error on set TabResource: "
+ caught.getLocalizedMessage());
d.addHideHandler(new HideHandler() {
@ -141,16 +191,16 @@ public class TabResourcesSelectionCard extends WizardCard {
}
public void onSuccess(Void result) {
getWizardWindow().fireCompleted(tdOpenSession
.getSelectedTabResource().getTrId());
getWizardWindow().fireCompleted(
tdOpenSession.getSelectedTabResource()
.getTrId());
getWizardWindow().close(false);
Log.info("OpenTD Tabular Resource selected :" + tdOpenSession
.getSelectedTabResource());
Log.info("OpenTD Tabular Resource selected :"
+ tdOpenSession.getSelectedTabResource());
}
});
}
}

View File

@ -236,5 +236,10 @@ public class TabResourcesSelectionPanel extends ContentPanel implements HasSelec
}
public void gridReload(){
grid.getLoader().load();
}
}