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
}
}
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);
}
Aggregations