Added auto open map

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-map-widget@113607 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-03-13 17:36:22 +00:00 committed by Giancarlo Panichi
parent 20f345dfb9
commit a2b2f1fa80
1 changed files with 108 additions and 2 deletions

View File

@ -3,21 +3,33 @@
*/
package org.gcube.portlets.user.td.mapwidget.client;
import java.util.ArrayList;
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.map.MapCreationSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.InternalURITD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.StringResourceTD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.TableResourceTD;
import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.OperationResult;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType;
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.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlexTable;
import com.sencha.gxt.core.client.util.Margins;
@ -150,7 +162,7 @@ public class MapWidgetOperationInProgressCard extends WizardCard implements
try {
getWizardWindow().close(false);
Log.info("fire Complete: " + newTrId);
openMap();
getWizardWindow().fireCompleted(newTrId);
} catch (Exception e) {
@ -188,7 +200,8 @@ public class MapWidgetOperationInProgressCard extends WizardCard implements
}
@Override
public void operationStopped(OperationResult operationResult, String reason, String details) {
public void operationStopped(OperationResult operationResult,
String reason, String details) {
newTrId = operationResult.getTrId();
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
safeHtmlBuilder
@ -281,4 +294,97 @@ public class MapWidgetOperationInProgressCard extends WizardCard implements
}
protected void openMap() {
TDGWTServiceAsync.INSTANCE.getResourcesTD(newTrId,
new AsyncCallback<ArrayList<ResourceTDDescriptor>>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert("Error Locked",
caught.getLocalizedMessage());
} else {
Log.error("Error Retrieving Resources: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving resources",
"Error retrieving resources");
}
}
}
public void onSuccess(ArrayList<ResourceTDDescriptor> result) {
Log.debug("loaded " + result.size());
if (result != null && result.size() > 0) {
ResourceTDDescriptor resourceTDDescriptor=result.get(0);
if(resourceTDDescriptor.getResourceType().compareTo(ResourceTDType.MAP)==0){
requestOpenMap(resourceTDDescriptor);
}
}
}
});
}
protected void requestOpenMap(
final ResourceTDDescriptor resourceTDDescriptor) {
ResourceTD resource = resourceTDDescriptor.getResourceTD();
if (resource instanceof StringResourceTD) {
StringResourceTD stringResourceTD = (StringResourceTD) resource;
UriResolverSession uriResolverSession = new UriResolverSession(
stringResourceTD.getValue(), ApplicationType.GIS);
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error with uri resolver: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
"Error retrieving uri from resolver");
}
}
public void onSuccess(String link) {
Log.debug("Retrieved link: " + link);
Window.open(link, resourceTDDescriptor.getName(),
"");
}
});
} else {
if (resource instanceof InternalURITD) {
} else {
if (resource instanceof TableResourceTD) {
} else {
Log.error("Error with resource: no valid resource");
UtilsGXT3.alert("Error with resource",
"Error no valid InternalUri");
}
}
}
}
}