use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method initializeList.
private void initializeList(final String type, final String defaultValue, String serviceUrl, final ListBox listBox) {
final String url = GWT.getHostPageBaseURL() + serviceUrl;
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
executableTypesRequestBuilder.setHeader("accept", "application/xml");
try {
executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
displayErrorInMessageBox(Messages.getString("Error"), exception.getLocalizedMessage());
}
public void onResponseReceived(Request request, Response response) {
listBox.clear();
NativeEvent event = com.google.gwt.dom.client.Document.get().createChangeEvent();
for (String role : getSortedItems(type, response)) {
listBox.addItem(role);
if (!StringUtils.isEmpty(defaultValue)) {
if (role.equals(defaultValue)) {
listBox.setSelectedIndex(listBox.getItemCount() - 1);
DomEvent.fireNativeEvent(event, listBox);
}
}
}
if (listBox.getSelectedIndex() == -1 && listBox.getItemCount() > 0) {
listBox.setSelectedIndex(0);
DomEvent.fireNativeEvent(event, listBox);
}
updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(listBox));
}
});
} catch (RequestException e) {
displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method modifyRoleUsers.
private void modifyRoleUsers(final String roleName, String serviceUrl) {
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, serviceUrl);
try {
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
displayErrorInMessageBox(Messages.getString("Error"), exception.getLocalizedMessage());
}
public void onResponseReceived(Request request, Response response) {
checkForError(Messages.getString("Error"), response);
getUsersInRole(roleName);
initializeAvailableUsers(usersListBox.getValue(usersListBox.getSelectedIndex()));
}
});
} catch (RequestException e) {
displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method deleteUsers.
public void deleteUsers() {
StringBuilder selectedUsers = new StringBuilder();
for (int i = 0; i < usersListBox.getItemCount(); i++) {
if (usersListBox.isItemSelected(i)) {
selectedUsers.append(encodeUri(usersListBox.getValue(i) + delimiter));
}
}
String serviceUrl = GWT.getHostPageBaseURL() + "api/userroledao/deleteUsers?userNames=" + selectedUsers.toString();
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, serviceUrl);
try {
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
displayErrorInMessageBox(Messages.getString("Error"), exception.getLocalizedMessage());
}
public void onResponseReceived(Request request, Response response) {
checkForError(Messages.getString("Error"), response);
userPasswordTextBox.setText("");
availableRolesListBox.clear();
selectedRolesListBox.clear();
updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(availableMembersListBox));
updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(selectedMembersListBox));
editPasswordButton.setEnabled(false);
initializeAvailableUsers(null);
initializeRoles(rolesListBox.getValue(rolesListBox.getSelectedIndex()), "api/userroledao/roles", rolesListBox);
}
});
} catch (RequestException e) {
displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class AboutCommand method performOperation.
protected void performOperation(boolean feedback) {
if (StringUtils.isEmpty(MantleApplication.mantleRevisionOverride) == false) {
showAboutDialog(MantleApplication.mantleRevisionOverride);
} else {
// $NON-NLS-1$
final String url = GWT.getHostPageBaseURL() + "api/version/show";
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
requestBuilder.setHeader("accept", "text/plain");
try {
requestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// showError(exception);
}
public void onResponseReceived(Request request, Response response) {
showAboutDialog(response.getText());
}
});
} catch (RequestException e) {
Window.alert(e.getMessage());
// showError(e);
}
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class CheckForSoftwareUpdatesCommand method performOperation.
protected void performOperation(boolean feedback) {
// $NON-NLS-1$
final String url = GWT.getHostPageBaseURL() + "api/version/softwareUpdates";
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
requestBuilder.setHeader("accept", "text/plain");
try {
requestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("softwareUpdates"), Messages.getString("noUpdatesAvailable"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
true);
dialogBox.center();
}
public void onResponseReceived(Request request, Response response) {
Document doc = XMLParser.parse(response.getText());
// $NON-NLS-1$
NodeList updates = doc.getElementsByTagName("update");
if (updates.getLength() > 0) {
FlexTable updateTable = new FlexTable();
// $NON-NLS-1$
updateTable.setStyleName("backgroundContentTable");
// $NON-NLS-1$
updateTable.setWidget(0, 0, new Label(Messages.getString("version")));
// $NON-NLS-1$
updateTable.setWidget(0, 1, new Label(Messages.getString("type")));
// $NON-NLS-1$
updateTable.setWidget(0, 2, new Label(Messages.getString("os")));
// $NON-NLS-1$
updateTable.setWidget(0, 3, new Label(Messages.getString("link")));
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(0, 0, "backgroundContentHeaderTableCell");
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(0, 1, "backgroundContentHeaderTableCell");
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(0, 2, "backgroundContentHeaderTableCell");
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(0, 3, "backgroundContentHeaderTableCellRight");
for (int i = 0; i < updates.getLength(); i++) {
Element updateElement = (Element) updates.item(i);
// $NON-NLS-1$
String version = updateElement.getAttribute("version");
// $NON-NLS-1$
String type = updateElement.getAttribute("type");
// $NON-NLS-1$
String os = updateElement.getAttribute("os");
// String title = updateElement.getAttribute("title");
// $NON-NLS-1$
String downloadURL = updateElement.getElementsByTagName("downloadurl").item(0).toString();
// $NON-NLS-1$ //$NON-NLS-2$
downloadURL = downloadURL.substring(downloadURL.indexOf("http"), downloadURL.indexOf("]"));
updateTable.setWidget(i + 1, 0, new Label(version));
updateTable.setWidget(i + 1, 1, new Label(type));
updateTable.setWidget(i + 1, 2, new Label(os));
updateTable.setWidget(i + 1, 3, new HTML("<A HREF=\"" + downloadURL + "\" target=\"_blank\" title=\"" + downloadURL + "\">" + Messages.getString("download") + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"</A>"));
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(i + 1, 0, "backgroundContentTableCell");
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(i + 1, 1, "backgroundContentTableCell");
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(i + 1, 2, "backgroundContentTableCell");
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(i + 1, 3, "backgroundContentTableCellRight");
if (i == updates.getLength() - 1) {
// last
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(i + 1, 0, "backgroundContentTableCellBottom");
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(i + 1, 1, "backgroundContentTableCellBottom");
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(i + 1, 2, "backgroundContentTableCellBottom");
// $NON-NLS-1$
updateTable.getCellFormatter().setStyleName(i + 1, 3, "backgroundContentTableCellBottomRight");
}
}
PromptDialogBox versionPromptDialog = new PromptDialogBox(Messages.getString("softwareUpdateAvailable"), Messages.getString("ok"), null, false, true, // $NON-NLS-1$ //$NON-NLS-2$
updateTable);
versionPromptDialog.center();
} else {
MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("softwareUpdates"), Messages.getString("noUpdatesAvailable"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
true);
dialogBox.center();
}
}
});
} catch (RequestException e) {
Window.alert(e.getMessage());
// showError(e);
}
}
Aggregations