106 lines
2.8 KiB
Java
106 lines
2.8 KiB
Java
|
/**
|
||
|
*
|
||
|
*/
|
||
|
package org.gcube.portlets.user.td.open.client;
|
||
|
|
||
|
import org.gcube.portlets.user.td.gxtservice.client.rpc.TDGXTServiceAsync;
|
||
|
import org.gcube.portlets.user.td.gxtservice.shared.TDOpenSession;
|
||
|
import org.gcube.portlets.user.td.gxtservice.shared.TabResource;
|
||
|
import org.gcube.portlets.user.td.open.client.general.WizardCard;
|
||
|
|
||
|
import com.allen_sauer.gwt.log.client.Log;
|
||
|
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.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 TabResourcesSelectionCard extends WizardCard {
|
||
|
|
||
|
protected TabResourcesSelectionCard thisCard;
|
||
|
protected TDOpenSession tdOpenSession;
|
||
|
protected TabResourcesSelectionPanel tabResourcesSelectionPanel;
|
||
|
protected TabResource selectedTabResource = null;
|
||
|
|
||
|
public TabResourcesSelectionCard(final TDOpenSession tdOpenSession) {
|
||
|
super("Select a Tabular Resource", "");
|
||
|
|
||
|
this.tdOpenSession = tdOpenSession;
|
||
|
thisCard = this;
|
||
|
|
||
|
this.tabResourcesSelectionPanel = new TabResourcesSelectionPanel(res);
|
||
|
|
||
|
tabResourcesSelectionPanel
|
||
|
.addSelectionHandler(new SelectionHandler<TabResource>() {
|
||
|
|
||
|
@Override
|
||
|
public void onSelection(SelectionEvent<TabResource> event) {
|
||
|
tdOpenSession
|
||
|
.setSelectedTabResource(tabResourcesSelectionPanel
|
||
|
.getSelectedItem());
|
||
|
getWizardWindow().setEnableNextButton(true);
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
setContent(tabResourcesSelectionPanel);
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void setup() {
|
||
|
Command sayFinish = new Command() {
|
||
|
|
||
|
@Override
|
||
|
public void execute() {
|
||
|
TabResource tabResource = tdOpenSession
|
||
|
.getSelectedTabResource();
|
||
|
|
||
|
TDGXTServiceAsync.INSTANCE.setTabResource(tabResource,
|
||
|
new AsyncCallback<Void>() {
|
||
|
@Override
|
||
|
public void onFailure(Throwable caught) {
|
||
|
AlertMessageBox d = new AlertMessageBox(
|
||
|
"Error", "Error on set TabResource: "
|
||
|
+ caught.getLocalizedMessage());
|
||
|
d.addHideHandler(new HideHandler() {
|
||
|
|
||
|
@Override
|
||
|
public void onHide(HideEvent event) {
|
||
|
// TODO Auto-generated method stub
|
||
|
|
||
|
}
|
||
|
|
||
|
});
|
||
|
d.show();
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onSuccess(Void result) {
|
||
|
|
||
|
}
|
||
|
|
||
|
});
|
||
|
getWizardWindow().fireCompleted(tabResource.getTrId());
|
||
|
Log.info("OpenTD Tabular Resource selected :" + tabResource);
|
||
|
getWizardWindow().close(false);
|
||
|
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
getWizardWindow().setFinishCommand(sayFinish);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|