use of com.google.gwt.http.client.RequestBuilder in project gerrit by GerritCodeReview.
the class NewAgreementScreen method showCLA.
private void showCLA(AgreementInfo cla) {
current = cla;
String url = cla.url();
if (url != null && url.length() > 0) {
agreementGroup.setVisible(true);
agreementHtml.setText(Gerrit.C.rpcStatusWorking());
if (!url.startsWith("http:") && !url.startsWith("https:")) {
url = GWT.getHostPageBaseURL() + url;
}
final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
rb.setCallback(new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
new ErrorDialog(exception).center();
}
@Override
public void onResponseReceived(Request request, Response response) {
final String ct = response.getHeader("Content-Type");
if (response.getStatusCode() == 200 && ct != null && (ct.equals("text/html") || ct.startsWith("text/html;"))) {
agreementHtml.setHTML(response.getText());
} else {
new ErrorDialog(response.getStatusText()).center();
}
}
});
try {
rb.send();
} catch (RequestException e) {
new ErrorDialog(e).show();
}
} else {
agreementGroup.setVisible(false);
}
finalGroup.setVisible(cla.autoVerifyGroup() != null);
yesIAgreeBox.setText("");
submit.setEnabled(false);
}
use of com.google.gwt.http.client.RequestBuilder in project opennms by OpenNMS.
the class DefaultChartService method sendRequest.
private void sendRequest(String url, RequestCallback callback) {
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
builder.setHeader("Accept", "application/json");
builder.setUser("ipv6Rest");
builder.setPassword("ipv6Rest");
try {
builder.sendRequest(null, callback);
} catch (RequestException e) {
e.printStackTrace();
}
}
use of com.google.gwt.http.client.RequestBuilder 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);
}
}
use of com.google.gwt.http.client.RequestBuilder 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);
}
}
use of com.google.gwt.http.client.RequestBuilder 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);
}
}
Aggregations