Search in sources :

Example 71 with RequestBuilder

use of com.google.gwt.http.client.RequestBuilder in project gerrit by GerritCodeReview.

the class NewAgreementScreen method showCLA.

private void showCLA(AgreementInfo cla) {
    current = cla;
    String url = cla.url();
    if (url != null && url.length() > 0) {
        agreementGroup.setVisible(true);
        agreementHtml.setText(Gerrit.C.rpcStatusWorking());
        if (!url.startsWith("http:") && !url.startsWith("https:")) {
            url = GWT.getHostPageBaseURL() + url;
        }
        final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
        rb.setCallback(new RequestCallback() {

            @Override
            public void onError(Request request, Throwable exception) {
                new ErrorDialog(exception).center();
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                final String ct = response.getHeader("Content-Type");
                if (response.getStatusCode() == 200 && ct != null && (ct.equals("text/html") || ct.startsWith("text/html;"))) {
                    agreementHtml.setHTML(response.getText());
                } else {
                    new ErrorDialog(response.getStatusText()).center();
                }
            }
        });
        try {
            rb.send();
        } catch (RequestException e) {
            new ErrorDialog(e).show();
        }
    } else {
        agreementGroup.setVisible(false);
    }
    finalGroup.setVisible(cla.autoVerifyGroup() != null);
    yesIAgreeBox.setText("");
    submit.setEnabled(false);
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) ErrorDialog(com.google.gerrit.client.ErrorDialog) NativeString(com.google.gerrit.client.rpc.NativeString) RequestException(com.google.gwt.http.client.RequestException)

Example 72 with RequestBuilder

use of com.google.gwt.http.client.RequestBuilder in project opennms by OpenNMS.

the class DefaultChartService method sendRequest.

private void sendRequest(String url, RequestCallback callback) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
    builder.setHeader("Accept", "application/json");
    builder.setUser("ipv6Rest");
    builder.setPassword("ipv6Rest");
    try {
        builder.sendRequest(null, callback);
    } catch (RequestException e) {
        e.printStackTrace();
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestException(com.google.gwt.http.client.RequestException)

Example 73 with RequestBuilder

use of com.google.gwt.http.client.RequestBuilder in project pentaho-platform by pentaho.

the class SchedulesPanel method updateControlSchedulerButtonState.

private void updateControlSchedulerButtonState(final ToolbarButton controlSchedulerButton, final boolean isScheduler) {
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "api/scheduler/state";
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
    builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        builder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            // showError(exception);
            }

            public void onResponseReceived(Request request, Response response) {
                boolean isRunning = "RUNNING".equalsIgnoreCase(response.getText());
                if (isRunning) {
                    controlSchedulerButton.setToolTip(Messages.getString("stopScheduler"));
                    controlSchedulerButton.setImage(ImageUtil.getThemeableImage("icon-small", "icon-stop-scheduler"));
                } else {
                    controlSchedulerButton.setToolTip(Messages.getString("startScheduler"));
                    controlSchedulerButton.setImage(ImageUtil.getThemeableImage("icon-small", "icon-start-scheduler"));
                }
                if (!isScheduler) {
                    controlSchedulerButton.setEnabled(false);
                } else {
                    controlSchedulerButton.setEnabled(true);
                }
            }
        });
    } catch (RequestException e) {
    // showError(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException)

Example 74 with RequestBuilder

use of com.google.gwt.http.client.RequestBuilder in project pentaho-platform by pentaho.

the class SchedulesPanel method toggleSchedulerOnOff.

private void toggleSchedulerOnOff(final ToolbarButton controlSchedulerButton, final boolean isScheduler) {
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "api/scheduler/state";
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
    builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        builder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            // showError(exception);
            }

            public void onResponseReceived(Request request, Response response) {
                boolean isRunning = "RUNNING".equalsIgnoreCase(response.getText());
                if (isRunning) {
                    controlScheduler(controlSchedulerButton, "pause", isScheduler);
                } else {
                    controlScheduler(controlSchedulerButton, "start", isScheduler);
                }
            }
        });
    } catch (RequestException e) {
    // showError(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException)

Example 75 with RequestBuilder

use of com.google.gwt.http.client.RequestBuilder in project pentaho-platform by pentaho.

the class SchedulesPanel method controlScheduler.

private void controlScheduler(final ToolbarButton controlSchedulerButton, final String function, final boolean isScheduler) {
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "api/scheduler/" + function;
    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);
    builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        builder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            // showError(exception);
            }

            public void onResponseReceived(Request request, Response response) {
                boolean isRunning = "RUNNING".equalsIgnoreCase(response.getText());
                if (isRunning) {
                    controlSchedulerButton.setToolTip(Messages.getString("stopScheduler"));
                    controlSchedulerButton.setImage(ImageUtil.getThemeableImage("icon-small", "icon-stop-scheduler"));
                } else {
                    controlSchedulerButton.setToolTip(Messages.getString("startScheduler"));
                    controlSchedulerButton.setImage(ImageUtil.getThemeableImage("icon-small", "icon-start-scheduler"));
                }
                if (!isScheduler) {
                    controlSchedulerButton.setEnabled(false);
                } else {
                    controlSchedulerButton.setEnabled(true);
                }
            }
        });
    } catch (RequestException e) {
    // showError(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException)

Aggregations

RequestBuilder (com.google.gwt.http.client.RequestBuilder)132 RequestException (com.google.gwt.http.client.RequestException)116 RequestCallback (com.google.gwt.http.client.RequestCallback)113 Response (com.google.gwt.http.client.Response)111 Request (com.google.gwt.http.client.Request)110 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)27 CsrfRequestBuilder (org.pentaho.mantle.client.csrf.CsrfRequestBuilder)22 JSONString (com.google.gwt.json.client.JSONString)19 ArrayList (java.util.ArrayList)16 Bindable (org.pentaho.ui.xul.stereotype.Bindable)15 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)13 JSONObject (com.google.gwt.json.client.JSONObject)11 JsArrayString (com.google.gwt.core.client.JsArrayString)9 JSONArray (com.google.gwt.json.client.JSONArray)8 List (java.util.List)8 HTML (com.google.gwt.user.client.ui.HTML)7 IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)7 EmptyRequestCallback (org.pentaho.mantle.client.EmptyRequestCallback)7 PromptDialogBox (org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox)6 RepositoryFile (org.pentaho.gwt.widgets.client.filechooser.RepositoryFile)6