Search in sources :

Example 91 with RequestCallback

use of com.google.gwt.http.client.RequestCallback 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 92 with RequestCallback

use of com.google.gwt.http.client.RequestCallback 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 93 with RequestCallback

use of com.google.gwt.http.client.RequestCallback 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)

Example 94 with RequestCallback

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

the class SwitchLocaleCommand method performOperation.

protected void performOperation(boolean feedback) {
    // stuff the locale in the server's session so we can use it
    // to override the browser setting, as needed
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "api/mantle/locale";
    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);
    try {
        builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        builder.sendRequest(locale, new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
            }
        });
    } catch (RequestException e) {
    // showError(e);
    }
    String newLocalePath = "Home?locale=" + locale;
    String baseUrl = GWT.getModuleBaseURL();
    int index = baseUrl.indexOf("/mantle/");
    if (index >= 0) {
        newLocalePath = baseUrl.substring(0, index) + "/Home?locale=" + locale;
    }
    Window.Location.replace(newLocalePath);
}
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) RequestException(com.google.gwt.http.client.RequestException)

Example 95 with RequestCallback

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

the class Application method onModuleLoad.

/**
 * This is the entry point method.
 */
public void onModuleLoad() {
    m_chartService = new DefaultChartService();
    Image img = new Image();
    img.setUrl("../images/logo.png");
    img.getElement().getStyle().setPaddingTop(14, Unit.PX);
    img.getElement().getStyle().setPaddingLeft(14, Unit.PX);
    FlowPanel header = new FlowPanel();
    header.getElement().setId("header");
    header.add(img);
    final DockLayoutPanel dockLayoutPanel = new DockLayoutPanel(Unit.PX);
    dockLayoutPanel.addNorth(header, 75.00);
    RootLayoutPanel.get().add(dockLayoutPanel);
    m_nav = new Navigation();
    m_nav.addLocationUpdateEventHandler(this);
    m_nav.addHostUpdateEventHandler(this);
    m_flowPanel = new FlowPanel();
    Runnable timelineCallback = new Runnable() {

        public void run() {
            m_chartService.getAllLocationsAvailability(new RequestCallback() {

                @Override
                public void onResponseReceived(Request request, Response response) {
                    if (response.getStatusCode() == 200) {
                        m_timeline = new AnnotatedTimeLine(ChartUtils.convertJSONToDataTable(response.getText()), createTimelineOptions(), "440px", "250px");
                        m_flowPanel.add(m_timeline);
                        m_flowPanel.add(m_nav);
                        dockLayoutPanel.add(m_flowPanel);
                    }
                }

                @Override
                public void onError(Request request, Throwable exception) {
                    Window.alert("Error Initializing Chart");
                }
            });
        }
    };
    VisualizationUtils.loadVisualizationApi(timelineCallback, AnnotatedTimeLine.PACKAGE);
    initializeNav();
}
Also used : Response(com.google.gwt.http.client.Response) AnnotatedTimeLine(com.google.gwt.visualization.client.visualizations.AnnotatedTimeLine) RequestCallback(com.google.gwt.http.client.RequestCallback) DockLayoutPanel(com.google.gwt.user.client.ui.DockLayoutPanel) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Request(com.google.gwt.http.client.Request) Image(com.google.gwt.user.client.ui.Image)

Aggregations

RequestCallback (com.google.gwt.http.client.RequestCallback)175 Response (com.google.gwt.http.client.Response)170 Request (com.google.gwt.http.client.Request)169 RequestException (com.google.gwt.http.client.RequestException)162 RequestBuilder (com.google.gwt.http.client.RequestBuilder)113 JSONException (com.google.gwt.json.client.JSONException)55 HttpException (com.willshex.gson.web.service.client.HttpException)55 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)16 CsrfRequestBuilder (org.pentaho.mantle.client.csrf.CsrfRequestBuilder)14 BlockUsersRequest (com.willshex.blogwt.shared.api.user.call.BlockUsersRequest)12 BlockUsersResponse (com.willshex.blogwt.shared.api.user.call.BlockUsersResponse)12 ChangePasswordRequest (com.willshex.blogwt.shared.api.user.call.ChangePasswordRequest)12 ChangePasswordResponse (com.willshex.blogwt.shared.api.user.call.ChangePasswordResponse)12 ChangeUserAccessRequest (com.willshex.blogwt.shared.api.user.call.ChangeUserAccessRequest)12 ChangeUserAccessResponse (com.willshex.blogwt.shared.api.user.call.ChangeUserAccessResponse)12 ChangeUserDetailsRequest (com.willshex.blogwt.shared.api.user.call.ChangeUserDetailsRequest)12 ChangeUserDetailsResponse (com.willshex.blogwt.shared.api.user.call.ChangeUserDetailsResponse)12 CheckUsernameRequest (com.willshex.blogwt.shared.api.user.call.CheckUsernameRequest)12 CheckUsernameResponse (com.willshex.blogwt.shared.api.user.call.CheckUsernameResponse)12 FollowUsersRequest (com.willshex.blogwt.shared.api.user.call.FollowUsersRequest)12