Search in sources :

Example 1 with GenericEvent

use of org.pentaho.mantle.client.events.GenericEvent in project pentaho-platform by pentaho.

the class FilePropertiesDialog method applyPanel.

/**
 */
private void applyPanel() {
    ArrayList<RequestBuilder> requestBuilders = new ArrayList<RequestBuilder>();
    for (int i = 0; i < propertyTabs.getTabCount(); i++) {
        Widget w = propertyTabs.getTab(i).getContent();
        if (w instanceof IFileModifier) {
            // get requests from sub panels
            if (((IFileModifier) w).prepareRequests() != null) {
                requestBuilders.addAll(((IFileModifier) w).prepareRequests());
            }
        }
    }
    RequestCallback requestCallback;
    // chain requests from subpanels using callbacks to try and avoid any StaleItemStateExceptions
    for (int i = 0; i <= requestBuilders.size() - 1; i++) {
        RequestBuilder requestBuilder = requestBuilders.get(i);
        if (i < requestBuilders.size() - 1) {
            final RequestBuilder nextRequest = requestBuilders.get(i + 1);
            // This header is required to force Internet Explorer to not cache values from the GET response.
            nextRequest.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
            requestCallback = new ChainedRequestCallback(nextRequest);
        } else {
            requestCallback = new RequestCallback() {

                @Override
                public void onError(Request request, Throwable th) {
                    WaitPopup.getInstance().setVisible(false);
                    MessageDialogBox dialogBox = // $NON-NLS-1$
                    new MessageDialogBox(Messages.getString("error"), th.toString(), false, false, true);
                    dialogBox.center();
                }

                @Override
                public void onResponseReceived(Request arg0, Response arg1) {
                    WaitPopup.getInstance().setVisible(false);
                    if (arg1.getStatusCode() == Response.SC_OK) {
                        dirty = false;
                        // Refresh current folder or parent folder
                        PerspectiveManager.getInstance().setPerspective(PerspectiveManager.BROWSER_PERSPECTIVE);
                        GenericEvent ge = new GenericEvent();
                        ge.setEventSubType("RefreshFolderEvent");
                        ge.setStringParam(parentPath);
                        EventBusUtil.EVENT_BUS.fireEvent(ge);
                    } else {
                        MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("operationPermissionDenied"), false, false, // $NON-NLS-1$
                        true);
                        dialogBox.center();
                    }
                }
            };
        }
        requestBuilder.setCallback(requestCallback);
    }
    // start the chain
    try {
        if (!requestBuilders.isEmpty()) {
            WaitPopup.getInstance().setVisible(true);
            requestBuilders.get(0).send();
        }
    } catch (RequestException e) {
    // ignored
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) ArrayList(java.util.ArrayList) Widget(com.google.gwt.user.client.ui.Widget) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) RequestCallback(com.google.gwt.http.client.RequestCallback) GenericEvent(org.pentaho.mantle.client.events.GenericEvent)

Example 2 with GenericEvent

use of org.pentaho.mantle.client.events.GenericEvent in project pentaho-platform by pentaho.

the class SchedulesPanel method openOutputLocation.

private void openOutputLocation(final String outputLocation) {
    final String url = GWT.getHostPageBaseURL() + "api/mantle/session-variable?key=scheduler_folder&value=" + outputLocation;
    PerspectiveManager.getInstance().setPerspective(PerspectiveManager.BROWSER_PERSPECTIVE);
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.POST, url);
    try {
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
            }
        });
    } catch (RequestException e) {
    // IGNORE
    }
    GenericEvent event = new GenericEvent();
    event.setEventSubType("RefreshFolderEvent");
    event.setStringParam(outputLocation);
    EventBusUtil.EVENT_BUS.fireEvent(event);
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) GenericEvent(org.pentaho.mantle.client.events.GenericEvent) Request(com.google.gwt.http.client.Request) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException)

Aggregations

Request (com.google.gwt.http.client.Request)2 RequestBuilder (com.google.gwt.http.client.RequestBuilder)2 RequestCallback (com.google.gwt.http.client.RequestCallback)2 RequestException (com.google.gwt.http.client.RequestException)2 Response (com.google.gwt.http.client.Response)2 GenericEvent (org.pentaho.mantle.client.events.GenericEvent)2 JSONString (com.google.gwt.json.client.JSONString)1 Widget (com.google.gwt.user.client.ui.Widget)1 ArrayList (java.util.ArrayList)1 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)1