use of com.google.gwt.http.client.RequestCallback 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.RequestCallback 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.RequestCallback 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);
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class SwitchLocaleCommand method performOperation.
protected void performOperation(boolean feedback) {
// stuff the locale in the server's session so we can use it
// to override the browser setting, as needed
// $NON-NLS-1$
final String url = GWT.getHostPageBaseURL() + "api/mantle/locale";
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);
try {
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
builder.sendRequest(locale, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// showError(exception);
}
public void onResponseReceived(Request request, Response response) {
}
});
} catch (RequestException e) {
// showError(e);
}
String newLocalePath = "Home?locale=" + locale;
String baseUrl = GWT.getModuleBaseURL();
int index = baseUrl.indexOf("/mantle/");
if (index >= 0) {
newLocalePath = baseUrl.substring(0, index) + "/Home?locale=" + locale;
}
Window.Location.replace(newLocalePath);
}
use of com.google.gwt.http.client.RequestCallback in project opennms by OpenNMS.
the class Application method onModuleLoad.
/**
* This is the entry point method.
*/
public void onModuleLoad() {
m_chartService = new DefaultChartService();
Image img = new Image();
img.setUrl("../images/logo.png");
img.getElement().getStyle().setPaddingTop(14, Unit.PX);
img.getElement().getStyle().setPaddingLeft(14, Unit.PX);
FlowPanel header = new FlowPanel();
header.getElement().setId("header");
header.add(img);
final DockLayoutPanel dockLayoutPanel = new DockLayoutPanel(Unit.PX);
dockLayoutPanel.addNorth(header, 75.00);
RootLayoutPanel.get().add(dockLayoutPanel);
m_nav = new Navigation();
m_nav.addLocationUpdateEventHandler(this);
m_nav.addHostUpdateEventHandler(this);
m_flowPanel = new FlowPanel();
Runnable timelineCallback = new Runnable() {
public void run() {
m_chartService.getAllLocationsAvailability(new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == 200) {
m_timeline = new AnnotatedTimeLine(ChartUtils.convertJSONToDataTable(response.getText()), createTimelineOptions(), "440px", "250px");
m_flowPanel.add(m_timeline);
m_flowPanel.add(m_nav);
dockLayoutPanel.add(m_flowPanel);
}
}
@Override
public void onError(Request request, Throwable exception) {
Window.alert("Error Initializing Chart");
}
});
}
};
VisualizationUtils.loadVisualizationApi(timelineCallback, AnnotatedTimeLine.PACKAGE);
initializeNav();
}
Aggregations