exportRequest.setQuoteChar(messages.exportToCsvQuoteChar());
exportRequest.setLayerId(layer.getServerLayerId());
GwtCommand command = new GwtCommand(ExportToCsvRequest.COMMAND);
command.setCommandRequest(exportRequest);
Deferred deferred = GwtCommandDispatcher.getInstance().execute(command, new CommandCallback() {
private static final String CONTENT_PRE = "<div style='margin-top: 20px; width: 200px; text-align: "
+ "center'><b>";
private static final String CONTENT_POST = "</b><br />";
private static final String LINK_POST = "</div>";
public void execute(CommandResponse response) {
if (response instanceof ExportToCsvResponse) {
ExportToCsvResponse resp = (ExportToCsvResponse) response;
if (resp.getDocumentId() != null) {
UrlBuilder ub = new UrlBuilder();
ub.setPath("d/csvDownload");
ub.setParameter("id", resp.getDocumentId());
String link = ub.buildString().replaceFirst("http:///", GWT.getHostPageBaseURL());
Window window = new DockableWindow();
window.setTitle(messages.exportToCsvWindowTitle());
String content = CONTENT_PRE + messages.exportToCsvContentReady() + CONTENT_POST;
String linktocsv = messages.exportToCsvDownloadLink(link) + LINK_POST;
window.addItem(new HTMLFlow(content + linktocsv));
window.centerInPage();
window.setAutoSize(true);
window.show();
window.setKeepInParentRect(true);
}
if (onFinished != null) {
onFinished.execute();
}
}
}
});
deferred.addErrorCallback(new Function() {
public void execute() {
if (onFinished != null) {
onFinished.execute();
}
}