use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class RunInBackgroundCommand method checkSchedulePermissionAndDialog.
protected void checkSchedulePermissionAndDialog() {
// $NON-NLS-1$
final String url = getFullyQualifiedURL() + "api/scheduler/isScheduleAllowed?id=" + repositoryFile.getRepositoryFile().getId();
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
requestBuilder.setHeader("accept", "text/plain");
requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
final MessageDialogBox errorDialog = new MessageDialogBox(Messages.getString("error"), Messages.getString("noSchedulePermission"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
true);
try {
requestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable caught) {
errorDialog.center();
}
public void onResponseReceived(Request request, Response response) {
if ("true".equalsIgnoreCase(response.getText())) {
showDialog(true);
} else {
errorDialog.center();
}
}
});
} catch (RequestException re) {
errorDialog.center();
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class SwitchThemeCommand method performOperation.
protected void performOperation(boolean feedback) {
final HTML messageTextBox = new HTML(Messages.getString("confirmSwitchTheme.message"));
final PromptDialogBox fileMoveToTrashWarningDialogBox = new PromptDialogBox(Messages.getString("confirmSwitchTheme.title"), Messages.getString("confirmSwitchTheme.ok"), Messages.getString("confirmSwitchTheme.cancel"), true, true);
fileMoveToTrashWarningDialogBox.setContent(messageTextBox);
final IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
}
public void okPressed() {
// $NON-NLS-1$
final String url = GWT.getHostPageBaseURL() + "api/theme/set";
RequestBuilder setThemeRequestBuilder = new CsrfRequestBuilder(RequestBuilder.POST, url);
setThemeRequestBuilder.setHeader("accept", "text/plain");
setThemeRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
setThemeRequestBuilder.sendRequest(theme, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// showError(exception);
}
public void onResponseReceived(Request request, Response response) {
// forcing a setTimeout to fix a problem in IE BISERVER-6385
Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
Window.Location.reload();
}
});
}
});
} catch (RequestException e) {
Window.alert(e.getMessage());
// showError(e);
}
}
};
fileMoveToTrashWarningDialogBox.setCallback(callback);
fileMoveToTrashWarningDialogBox.center();
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class SolutionBrowserPanel method initializeExecutableFileTypes.
protected void initializeExecutableFileTypes() {
final String moduleBaseURL = GWT.getModuleBaseURL();
final String moduleName = GWT.getModuleName();
final String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
// $NON-NLS-1$
final String url = contextURL + "api/repos/executableTypes";
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
executableTypesRequestBuilder.setHeader("accept", "application/json");
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// showError(exception);
}
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == Response.SC_OK) {
JSONObject jsonObject = (JSONObject) JSONParser.parse(response.getText());
JSONArray jsonList = (JSONArray) jsonObject.get("executableFileTypeDto");
for (int i = 0; i < jsonList.size(); i++) {
JSONObject executableType = (JSONObject) jsonList.get(i);
executableFileExtensions.add(executableType.get("extension").isString().stringValue());
}
}
}
});
} catch (RequestException e) {
// showError(e);
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class SolutionBrowserPanel method executeActionSequence.
public void executeActionSequence(final FileCommand.COMMAND mode) {
if (filesListPanel.getSelectedFileItems() == null || filesListPanel.getSelectedFileItems().size() != 1) {
return;
}
// open in content panel
AbstractCommand authCmd = new AbstractCommand() {
protected void performOperation() {
performOperation(false);
}
protected void performOperation(boolean feedback) {
final FileItem selectedFileItem = filesListPanel.getSelectedFileItems().get(0);
String url = null;
url = // $NON-NLS-1$ //$NON-NLS-2$
"api/repo/files/" + SolutionBrowserPanel.pathToId(filesListPanel.getSelectedFileItems().get(0).getRepositoryFile().getPath()) + "/generatedContent";
url = getPath() + url;
if (mode == FileCommand.COMMAND.BACKGROUND) {
MessageDialogBox dialogBox = new // $NON-NLS-1$
MessageDialogBox(// $NON-NLS-1$
Messages.getString("info"), // $NON-NLS-1$
Messages.getString("backgroundExecutionWarning"), true, false, true);
dialogBox.center();
// $NON-NLS-1$
url += "&background=true";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
try {
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("couldNotBackgroundExecute"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
true);
dialogBox.center();
}
public void onResponseReceived(Request request, Response response) {
}
});
} catch (RequestException e) {
// ignored
}
} else if (mode == FileCommand.COMMAND.NEWWINDOW) {
// popup blockers might attack this
// $NON-NLS-1$ //$NON-NLS-2$
Window.open(url, "_blank", "menubar=yes,location=no,resizable=yes,scrollbars=yes,status=no");
} else if (mode == FileCommand.COMMAND.SUBSCRIBE) {
// $NON-NLS-1$
final String myurl = url + "&subscribepage=yes";
contentTabPanel.showNewURLTab(selectedFileItem.getLocalizedName(), selectedFileItem.getLocalizedName(), myurl, true);
} else {
contentTabPanel.showNewURLTab(selectedFileItem.getLocalizedName(), selectedFileItem.getLocalizedName(), url, true);
}
}
};
authCmd.execute();
}
use of com.google.gwt.http.client.RequestCallback 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
}
}
Aggregations