Example usage for com.google.gwt.user.client.ui Anchor setHorizontalAlignment

List of usage examples for com.google.gwt.user.client.ui Anchor setHorizontalAlignment

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Anchor setHorizontalAlignment.

Prototype

public void setHorizontalAlignment(HorizontalAlignmentConstant align) 

Source Link

Usage

From source file:org.geomajas.widget.searchandfilter.client.widget.multifeaturelistgrid.ExportSearchToCsvHandler.java

License:Open Source License

@Override
public void execute(final VectorLayer vectorLayer, final Runnable onFinished) {
    if (this.layer.equals(vectorLayer)) {
        ExportToCsvRequest exportRequest = new ExportToCsvRequest();
        exportRequest.setSearchFeatureRequest(getSearchFeatureRequest());
        exportRequest.setSearchByLocationRequest(getSearchByLocationRequest(vectorLayer));
        exportRequest.setSearchByCriterionRequest(getSearchCriterionRequest());
        exportRequest.setEncoding(messages.exportToCsvEncoding());
        exportRequest.setLocale(messages.exportToCsvLocale());
        exportRequest.setSeparatorChar(messages.exportToCsvSeparatorChar());
        exportRequest.setQuoteChar(messages.exportToCsvQuoteChar());
        exportRequest.setLayerId(layer.getServerLayerId());

        GwtCommand command = new GwtCommand(ExportToCsvRequest.COMMAND);
        command.setCommandRequest(exportRequest);
        GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<ExportToCsvResponse>() {

            public void execute(ExportToCsvResponse response) {
                if (response.getDocumentId() != null) {
                    UrlBuilder ub = new UrlBuilder();
                    ub.setPath("d/csvDownload");
                    ub.setParameter("id", response.getDocumentId());
                    String link = ub.buildString().replaceFirst("http:///", GWT.getHostPageBaseURL());

                    final Window window = new DockableWindow();
                    window.setTitle(messages.exportToCsvWindowTitle());
                    window.setWidth(200);

                    String content = "<div style='margin-top: 20px; width: 200px; text-align: center'>";
                    content += "<b>" + messages.exportToCsvContentReady() + "</b><br />";
                    content += messages.exportToCsvDownloadLinkDescription() + "</b></div>";
                    HTMLFlow infoSpinnerCanvas = new HTMLFlow(content);
                    infoSpinnerCanvas.setAutoHeight();
                    Anchor anchor = new Anchor(messages.exportToCsvDownloadLinkName(), link);
                    anchor.setHeight("20px");
                    anchor.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
                    anchor.addClickHandler(new com.google.gwt.event.dom.client.ClickHandler() {
                        public void onClick(com.google.gwt.event.dom.client.ClickEvent event) {
                            window.hide();
                            window.destroy();
                        }/*from   www. ja  va 2 s .c om*/
                    });
                    VerticalPanel panel = new VerticalPanel();
                    panel.setHeight("22px");
                    panel.setWidth("198px");
                    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
                    panel.add(anchor);

                    VLayout lay = new VLayout(0);
                    lay.setWidth100();
                    lay.setLayoutAlign(Alignment.CENTER);
                    lay.addMember(infoSpinnerCanvas);
                    lay.addMember(panel);
                    lay.setAutoHeight();
                    window.addItem(lay);
                    window.centerInPage();
                    window.setAutoSize(true);
                    window.show();
                    window.setKeepInParentRect(true);
                }
                if (onFinished != null) {
                    onFinished.run();
                }
            }

            @Override
            public void onCommunicationException(Throwable error) {
                if (onFinished != null) {
                    onFinished.run();
                }
                super.onCommunicationException(error);
            }

            @Override
            public void onCommandException(CommandResponse response) {
                if (onFinished != null) {
                    onFinished.run();
                }
                super.onCommandException(response);
            }
        });
    }
}