2013-10-24 12:12:33 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2013-10-24 16:12:50 +02:00
|
|
|
package org.gcube.portlets.user.td.openwidget.client;
|
2013-10-24 12:12:33 +02:00
|
|
|
|
2013-10-24 16:12:50 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.TDOpenSession;
|
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.TabResource;
|
|
|
|
import org.gcube.portlets.user.td.openwidget.client.general.WizardCard;
|
2013-10-24 12:12:33 +02:00
|
|
|
|
|
|
|
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 {
|
2013-10-25 14:54:53 +02:00
|
|
|
protected final String GRIDWIDTH = "538px";
|
|
|
|
protected final String GRIDHEIGHT = "430px";
|
|
|
|
|
2013-10-24 12:12:33 +02:00
|
|
|
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;
|
|
|
|
|
2013-10-25 14:54:53 +02:00
|
|
|
tabResourcesSelectionPanel = new TabResourcesSelectionPanel(res);
|
2013-10-24 12:12:33 +02:00
|
|
|
|
2013-10-25 14:54:53 +02:00
|
|
|
tabResourcesSelectionPanel.setResize(false);
|
|
|
|
tabResourcesSelectionPanel.setSize(GRIDWIDTH, GRIDHEIGHT);
|
|
|
|
|
2013-10-24 12:12:33 +02:00
|
|
|
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();
|
|
|
|
|
2013-10-24 16:12:50 +02:00
|
|
|
TDGWTServiceAsync.INSTANCE.setTabResource(tabResource,
|
2013-10-24 12:12:33 +02:00
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|