List of usage examples for com.google.gwt.http.client RequestBuilder GET
Method GET
To view the source code for com.google.gwt.http.client RequestBuilder GET.
Click Source Link
From source file:org.pentaho.gwt.widgets.client.filechooser.FileChooser.java
License:Open Source License
public void fetchRepository(final IDialogCallback completedCallback) throws RequestException { RequestBuilder builder = null;//ww w .j a v a 2 s . c o m builder = new RequestBuilder(RequestBuilder.GET, getFullyQualifiedURL() + "api/repo/files/:/tree?showHidden=" + showHiddenFiles + "&depth=-1&filter=*"); //$NON-NLS-1$ builder.setHeader("accept", "application/json"); //$NON-NLS-1$ //$NON-NLS-2$ RequestCallback callback = new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert(exception.toString()); } public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == Response.SC_OK) { String jsonData = response.getText(); JsonToRepositoryFileTreeConverter converter = new JsonToRepositoryFileTreeConverter(jsonData); repositoryTree = TreeBuilder.buildSolutionTree(converter.getTree(), showHiddenFiles, showLocalizedFileNames, fileFilter); selectedTreeItem = repositoryTree.getItem(0); initUI(); if (completedCallback != null) { completedCallback.okPressed(); } } else { Window.alert("Solution Repository not found."); //$NON-NLS-1$ } } }; builder.sendRequest(null, callback); }
From source file:org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle.java
License:Open Source License
public void loadBundle(String path, final String bundleName, boolean attemptLocalizedFetches, IResourceBundleLoadCallback bundleLoadCallback) { this.bundleName = bundleName; this.bundleLoadCallback = bundleLoadCallback; this.attemptLocalizedFetches = attemptLocalizedFetches; if (!StringUtils.isEmpty(path) && !path.endsWith("/")) { //$NON-NLS-1$ path = path + "/"; //$NON-NLS-1$ }//from w w w . j a va2s. co m this.path = path; // get the locale meta property if the url parameter is missing initCallbacks(); // decompose locale // _en_US // 1. bundleName.properties // 2. bundleName_en.properties // 3. bundleName_en_US.properties final ResourceBundle supportedLanguagesBundle = new ResourceBundle(); // callback for when supported_locales has been fetched (if desired) IResourceBundleLoadCallback supportedLangCallback = new IResourceBundleLoadCallback() { public void bundleLoaded(String ignore) { // supportedLanguages will be null if the user did not set them prior to loadBundle // if the user already set them, keep 'em, it's an override if (ResourceBundle.this.supportedLanguages == null) { ResourceBundle.this.supportedLanguages = supportedLanguagesBundle.getMap(); decodeMapValues(ResourceBundle.this.supportedLanguages); } // always fetch the base first currentAttemptUrl = ResourceBundle.this.path + bundleName + PROPERTIES_EXTENSION + getUrlExtras(); if (bundleCache.containsKey(currentAttemptUrl)) { // call in a separate timeout, to simulate the request builder call as closely as possible Scheduler.get().scheduleDeferred(new Command() { public void execute() { baseCallback.onResponseReceived(null, new FakeResponse(bundleCache.get(currentAttemptUrl))); } }); } else { RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, currentAttemptUrl); try { requestBuilder.sendRequest(null, baseCallback); } catch (RequestException e) { Window.alert("base load: " + e.getMessage()); //$NON-NLS-1$ fireBundleLoadCallback(); } } } }; // supportedLanguages will not be null if they've already been set by the user, and in that case, // we do not want attempt to load that bundle.. if (attemptLocalizedFetches && supportedLanguages == null) { // load supported_languages bundle supportedLanguagesBundle.loadBundle(path, bundleName + "_supported_languages", false, //$NON-NLS-1$ supportedLangCallback); } else { // simulate callback supportedLangCallback.bundleLoaded(bundleName + "_supported_languages"); //$NON-NLS-1$ } }
From source file:org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle.java
License:Open Source License
private void initCallbacks() { baseCallback = new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("baseCallback: " + exception.getMessage()); //$NON-NLS-1$ fireBundleLoadCallback();/*from w w w. j a v a 2 s. c o m*/ } public void onResponseReceived(Request request, Response response) { String propertiesFileText = response.getText(); // build a simple map of key/value pairs from the properties file if (response.getStatusCode() == Response.SC_OK) { bundle = PropertiesUtil.buildProperties(propertiesFileText, bundle); if (response instanceof FakeResponse == false) { // this is a real bundle load bundleCache.put(currentAttemptUrl, propertiesFileText); } } else { // put empty bundle in cache (not found, but we want to remember it was not found) bundleCache.put(currentAttemptUrl, ""); //$NON-NLS-1$ } // if we are not attempting to fetch any localized bundles // then fire our callback and then return, we're done if (!attemptLocalizedFetches) { fireBundleLoadCallback(); return; } // now fetch the the lang/country variants if (localeName.equalsIgnoreCase("default")) { //$NON-NLS-1$ // process only bundleName.properties fireBundleLoadCallback(); return; } else { StringTokenizer st = new StringTokenizer(localeName, '_'); if (st.countTokens() > 0) { String lang = st.tokenAt(0); // 2. fetch bundleName_lang.properties // 3. fetch bundleName_lang_country.properties currentAttemptUrl = path + bundleName + "_" + lang + PROPERTIES_EXTENSION + getUrlExtras(); //$NON-NLS-1$ // IE caches the file and causes an issue with the request if (!isSupportedLanguage(lang) || bundleCache.containsKey(currentAttemptUrl)) { langCallback.onResponseReceived(null, new FakeResponse(bundleCache.get(currentAttemptUrl))); } else { RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, currentAttemptUrl); // Caching causing some strange behavior with IE6. // TODO: Investigate caching issue. requestBuilder.setHeader("Cache-Control", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$ try { requestBuilder.sendRequest(null, langCallback); } catch (RequestException e) { Window.alert("lang: " + e.getMessage()); //$NON-NLS-1$ fireBundleLoadCallback(); } } } else if (st.countTokens() == 0) { // already fetched fireBundleLoadCallback(); return; } } } }; langCallback = new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("langCallback: " + exception.getMessage()); //$NON-NLS-1$ fireBundleLoadCallback(); } public void onResponseReceived(Request request, Response response) { String propertiesFileText = response.getText(); // build a simple map of key/value pairs from the properties file if (response.getStatusCode() == Response.SC_OK) { bundle = PropertiesUtil.buildProperties(propertiesFileText, bundle); if (response instanceof FakeResponse == false) { // this is a real bundle load bundleCache.put(currentAttemptUrl, propertiesFileText); } } else { // put empty bundle in cache (not found, but we want to remember it was not found) bundleCache.put(currentAttemptUrl, ""); //$NON-NLS-1$ } StringTokenizer st = new StringTokenizer(localeName, '_'); if (st.countTokens() == 2) { // 3. fetch bundleName_lang_country.properties // need to match case-insensitive on country if (!isSupportedLanguage(localeName)) { // try to switch the case on the trailing characters if (isSupportedLanguage(st.tokenAt(0) + "_" + st.tokenAt(1).toUpperCase())) { localeName = st.tokenAt(0) + "_" + st.tokenAt(1).toUpperCase(); } } currentAttemptUrl = path + bundleName + "_" + localeName + PROPERTIES_EXTENSION //$NON-NLS-1$ + getUrlExtras(); if (!isSupportedLanguage(localeName) || bundleCache.containsKey(currentAttemptUrl)) { langCountryCallback.onResponseReceived(null, new FakeResponse(bundleCache.get(currentAttemptUrl))); } else { RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, currentAttemptUrl); try { requestBuilder.sendRequest(null, langCountryCallback); } catch (RequestException e) { Window.alert("langCountry: " + e.getMessage()); //$NON-NLS-1$ fireBundleLoadCallback(); } } } else { // already fetched fireBundleLoadCallback(); return; } } }; langCountryCallback = new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("langCountryCallback: " + exception.getMessage()); //$NON-NLS-1$ fireBundleLoadCallback(); } public void onResponseReceived(Request request, Response response) { String propertiesFileText = response.getText(); // build a simple map of key/value pairs from the properties file if (response.getStatusCode() == Response.SC_OK) { bundle = PropertiesUtil.buildProperties(propertiesFileText, bundle); if (response instanceof FakeResponse == false) { // this is a real bundle load bundleCache.put(currentAttemptUrl, propertiesFileText); } } else { // put empty bundle in cache (not found, but we want to remember it was not found) bundleCache.put(currentAttemptUrl, ""); //$NON-NLS-1$ } fireBundleLoadCallback(); } }; }
From source file:org.pentaho.gwt.widgets.client.utils.MessageBundle.java
License:Open Source License
/** * The MessageBundle class fetches localized properties files by using the GWT RequestBuilder against the supplied * path. Ideally the path should be relative, but absolute paths are accepted. When the ResourceBundle has fetched and * loaded all available resources it will notify the caller by way of IMessageBundleLoadCallback. This is necessary * due to the asynchronous nature of the loading process. Care should be taken to be sure not to request resources * until loading has finished as inconsistent and incomplete results will be likely. * /* w ww . j a v a2s.c om*/ * @param path * The path to the resources (mantle/messages) * @param bundleName * The base name of the set of resource bundles, for example 'messages' * @param bundleLoadCallback * The callback to invoke when the bundle has finished loading */ @Deprecated public MessageBundle(String path, String bundleName, IMessageBundleLoadCallback bundleLoadCallback) { this.path = path; this.bundleName = bundleName; this.bundleLoadCallback = bundleLoadCallback; // get the locale meta property if the url parameter is missing this.localeName = StringUtils.defaultIfEmpty(Window.Location.getParameter("locale"), //$NON-NLS-1$ getLanguagePreference()); initCallbacks(); // decompose locale // _en_US // 1. bundleName.properties // 2. bundleName_en.properties // 3. bundleName_en_US.properties // always fetch the base first currentAttemptUrl = path + bundleName + PROPERTIES_EXTENSION + getUrlExtras(); if (bundleCache.containsKey(currentAttemptUrl)) { baseCallback.onResponseReceived(null, new FakeResponse(bundleCache.get(currentAttemptUrl))); } else { RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, currentAttemptUrl); try { requestBuilder.sendRequest(null, baseCallback); } catch (RequestException e) { Window.alert("base load " + MSGS.error() + ":" + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ fireBundleLoadCallback(); } } }
From source file:org.pentaho.gwt.widgets.client.utils.MessageBundle.java
License:Open Source License
@Deprecated private void initCallbacks() { baseCallback = new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("baseCallback " + MSGS.error() + ":" + exception.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ fireBundleLoadCallback();/*from ww w. ja va 2s . c o m*/ } public void onResponseReceived(Request request, Response response) { String propertiesFileText = response.getText(); // build a simple map of key/value pairs from the properties file if (response.getStatusCode() == Response.SC_OK) { bundle = PropertiesUtil.buildProperties(propertiesFileText, bundle); if (response instanceof FakeResponse == false) { // this is a real bundle load bundleCache.put(currentAttemptUrl, propertiesFileText); } } else { // put empty bundle in cache (not found, but we want to remember it was not found) bundleCache.put(currentAttemptUrl, ""); //$NON-NLS-1$ } // now fetch the the lang/country variants if (localeName.equalsIgnoreCase("default")) { //$NON-NLS-1$ // process only bundleName.properties fireBundleLoadCallback(); return; } else { StringTokenizer st = new StringTokenizer(localeName, '_'); if (st.countTokens() > 0) { String lang = st.tokenAt(0); // 2. fetch bundleName_lang.properties // 3. fetch bundleName_lang_country.properties currentAttemptUrl = path + bundleName + "_" + lang + PROPERTIES_EXTENSION + getUrlExtras(); //$NON-NLS-1$ // IE caches the file and causes an issue with the request if (bundleCache.containsKey(currentAttemptUrl)) { langCallback.onResponseReceived(null, new FakeResponse(bundleCache.get(currentAttemptUrl))); } else { RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, currentAttemptUrl); // Caching causing some strange behavior with IE6. // TODO: Investigate caching issue. requestBuilder.setHeader("Cache-Control", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$ try { requestBuilder.sendRequest(null, langCallback); } catch (RequestException e) { Window.alert("lang " + MSGS.error() + ":" + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ fireBundleLoadCallback(); } } } else if (st.countTokens() == 0) { // already fetched fireBundleLoadCallback(); return; } } } }; langCallback = new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("langCallback " + MSGS.error() + ":" + exception.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ fireBundleLoadCallback(); } public void onResponseReceived(Request request, Response response) { String propertiesFileText = response.getText(); // build a simple map of key/value pairs from the properties file if (response.getStatusCode() == Response.SC_OK) { bundle = PropertiesUtil.buildProperties(propertiesFileText, bundle); if (response instanceof FakeResponse == false) { // this is a real bundle load bundleCache.put(currentAttemptUrl, propertiesFileText); } } else { // put empty bundle in cache (not found, but we want to remember it was not found) bundleCache.put(currentAttemptUrl, ""); //$NON-NLS-1$ } StringTokenizer st = new StringTokenizer(localeName, '_'); if (st.countTokens() == 2) { // 3. fetch bundleName_lang_country.properties currentAttemptUrl = path + bundleName + "_" + localeName + PROPERTIES_EXTENSION //$NON-NLS-1$ + getUrlExtras(); if (bundleCache.containsKey(currentAttemptUrl)) { langCountryCallback.onResponseReceived(null, new FakeResponse(bundleCache.get(currentAttemptUrl))); } else { RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, currentAttemptUrl); try { requestBuilder.sendRequest(null, langCountryCallback); } catch (RequestException e) { Window.alert("langCountry " + MSGS.error() + ":" + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ fireBundleLoadCallback(); } } } else { // already fetched fireBundleLoadCallback(); return; } } }; langCountryCallback = new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("langCountryCallback " + MSGS.error() + ":" + exception.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ fireBundleLoadCallback(); } public void onResponseReceived(Request request, Response response) { String propertiesFileText = response.getText(); // build a simple map of key/value pairs from the properties file if (response.getStatusCode() == Response.SC_OK) { bundle = PropertiesUtil.buildProperties(propertiesFileText, bundle); if (response instanceof FakeResponse == false) { // this is a real bundle load bundleCache.put(currentAttemptUrl, propertiesFileText); } } else { // put empty bundle in cache (not found, but we want to remember it was not found) bundleCache.put(currentAttemptUrl, ""); //$NON-NLS-1$ } fireBundleLoadCallback(); } }; }
From source file:org.pentaho.gwt.widgets.login.client.AuthenticatedGwtServiceUtil.java
License:Open Source License
/** * invokeCommand method tries to execute the service and incase of SC_UNAUTHORIZED error the login dialog is presented * where the user can enter their credentials. Once you are successfully logged in, the requested services is * performed again//from www . ja va2 s .c o m * * @param command * @param theirCallback */ public static void invokeCommand(final IAuthenticatedGwtCommand command, final AsyncCallback theirCallback) { command.execute(new AsyncCallback() { public void onFailure(final Throwable caught) { // The request has failed. We need to check if the request failed due to authentication // We will simply to a get of an image and if it responds back with Response.SC_UNAUTHORIZED // We will display a login page to the user otherwise we will return the error back to the // user String[] pathArray = Window.Location.getPath().split("/"); String webAppPath = "/" + pathArray[1] + "/"; RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, webAppPath + "mantle/images/spacer.gif"); //$NON-NLS-1$ builder.setHeader("Content-Type", "application/xml"); RequestCallback callback = new RequestCallback() { public void onError(Request request, Throwable exception) { theirCallback.onFailure(caught); } public void onResponseReceived(Request request, Response response) { if (Response.SC_UNAUTHORIZED == response.getStatusCode()) { doLogin(command, theirCallback); } else { theirCallback.onFailure(caught); } } }; try { builder.sendRequest("", callback); //$NON-NLS-1$ //$NON-NLS-2$ } catch (RequestException e) { e.printStackTrace(); } } public void onSuccess(Object result) { theirCallback.onSuccess(result); } }); }
From source file:org.pentaho.mantle.client.admin.ContentCleanerPanel.java
License:Open Source License
public void activate() { clear();/*ww w . j av a 2 s. c om*/ String moduleBaseURL = GWT.getModuleBaseURL(); String moduleName = GWT.getModuleName(); String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName)); RequestBuilder scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.GET, contextURL + "api/scheduler/getContentCleanerJob?cb=" + System.currentTimeMillis()); scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); scheduleFileRequestBuilder.setHeader("Content-Type", "application/json"); //$NON-NLS-1$//$NON-NLS-2$ scheduleFileRequestBuilder.setHeader("accept", "application/json"); //$NON-NLS-1$//$NON-NLS-2$ try { scheduleFileRequestBuilder.sendRequest("", new RequestCallback() { public void onError(Request request, Throwable exception) { } public void onResponseReceived(Request request, Response response) { final TextBox nowTextBox = new TextBox(); nowTextBox.setWidth("24px"); nowTextBox.getElement().getStyle().setPadding(5, Unit.PX); nowTextBox.getElement().getStyle().setMarginLeft(5, Unit.PX); nowTextBox.getElement().getStyle().setMarginRight(5, Unit.PX); final TextBox scheduleTextBox = new TextBox(); scheduleTextBox.setVisibleLength(4); JsJob tmpJsJob = parseJsonJob(JsonUtils.escapeJsonForEval(response.getText())); boolean fakeJob = false; if (tmpJsJob == null) { tmpJsJob = createJsJob(); fakeJob = true; } final JsJob jsJob = tmpJsJob; if (jsJob != null) { scheduleTextBox.setValue("" + (Long.parseLong(jsJob.getJobParamValue("age")) / 86400L)); } else { scheduleTextBox.setText("180"); } scheduleTextBox.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { if (jsJob != null) { JsArray<JsJobParam> params = jsJob.getJobParams(); for (int i = 0; i < params.length(); i++) { if (params.get(i).getName().equals("age")) { params.get(i).setValue( "" + (Long.parseLong(scheduleTextBox.getText()) * 86400L)); break; } } } } }); Label settingsLabel = new Label(Messages.getString("settings")); settingsLabel.setStyleName("pentaho-fieldgroup-major"); add(settingsLabel, DockPanel.NORTH); VerticalPanel nowPanelWrapper = new VerticalPanel(); Label deleteNowLabel = new Label(Messages.getString("deleteGeneratedFilesNow")); deleteNowLabel.getElement().getStyle().setPaddingTop(15, Unit.PX); deleteNowLabel.setStyleName("pentaho-fieldgroup-minor"); nowPanelWrapper.add(deleteNowLabel); HorizontalPanel nowLabelPanel = new HorizontalPanel(); nowLabelPanel.getElement().getStyle().setPaddingTop(10, Unit.PX); nowLabelPanel.getElement().getStyle().setPaddingBottom(10, Unit.PX); Label deleteGeneratedFilesOlderThan = new Label( Messages.getString("deleteGeneratedFilesOlderThan")); deleteGeneratedFilesOlderThan.getElement().getStyle().setPaddingTop(7, Unit.PX); nowLabelPanel.add(deleteGeneratedFilesOlderThan); nowLabelPanel.add(nowTextBox); nowTextBox.setText("180"); Label days = new Label(Messages.getString("daysDot")); days.getElement().getStyle().setPaddingTop(7, Unit.PX); nowLabelPanel.add(days); Button deleteNowButton = new Button(Messages.getString("deleteNow")); deleteNowButton.setStylePrimaryName("pentaho-button"); deleteNowButton.addStyleName("first"); deleteNowButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { MessageDialogBox warning = new MessageDialogBox(Messages.getString("deleteNow"), Messages.getString("confirmDeleteGeneratedContentNow"), false, false, true, Messages.getString("yes"), null, Messages.getString("no")); warning.setCallback(new IDialogCallback() { @Override public void okPressed() { deleteContentNow(Long.parseLong(nowTextBox.getValue()) * 86400L); } @Override public void cancelPressed() { } }); warning.center(); } }); nowPanelWrapper.add(nowLabelPanel); nowPanelWrapper.add(deleteNowButton); add(nowPanelWrapper, DockPanel.NORTH); // scheduled VerticalPanel scheduledPanel = new VerticalPanel(); Label deleteScheduleLabel = new Label(Messages.getString("scheduleDeletionOfGeneratedFiles")); deleteScheduleLabel.setStyleName("pentaho-fieldgroup-minor"); deleteScheduleLabel.getElement().getStyle().setPaddingTop(15, Unit.PX); scheduledPanel.add(deleteScheduleLabel); Label descLabel; if (!fakeJob) { String desc = jsJob.getJobTrigger().getDescription(); descLabel = new Label(desc); scheduledPanel.add(descLabel); } else { descLabel = new Label(Messages.getString("generatedFilesAreNotScheduledToBeDeleted")); scheduledPanel.add(descLabel); } descLabel.getElement().getStyle().setPaddingTop(10, Unit.PX); descLabel.getElement().getStyle().setPaddingBottom(10, Unit.PX); Button editScheduleButton = new Button(Messages.getString("edit")); if (fakeJob) { editScheduleButton.setText(Messages.getString("scheduleDeletion")); } Button deleteScheduleButton = new Button(Messages.getString("cancelSchedule")); deleteScheduleButton.setStylePrimaryName("pentaho-button"); deleteScheduleButton.addStyleName("last"); deleteScheduleButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { deleteContentCleaner(jsJob); } }); editScheduleButton.setStylePrimaryName("pentaho-button"); editScheduleButton.addStyleName("first"); editScheduleButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { IDialogCallback callback = new IDialogCallback() { public void okPressed() { deleteContentCleaner(jsJob); } public void cancelPressed() { } }; HorizontalPanel scheduleLabelPanel = new HorizontalPanel(); scheduleLabelPanel .add(new Label(Messages.getString("deleteGeneratedFilesOlderThan"), false)); scheduleLabelPanel.add(scheduleTextBox); scheduleLabelPanel .add(new Label(Messages.getString("daysUsingTheFollowingRules"), false)); ScheduleRecurrenceDialog editSchedule = new ScheduleRecurrenceDialog(null, jsJob, callback, false, false, AbstractWizardDialog.ScheduleDialogType.SCHEDULER); editSchedule.setShowSuccessDialog(false); editSchedule.addCustomPanel(scheduleLabelPanel, DockPanel.NORTH); editSchedule.center(); } }); HorizontalPanel scheduleButtonPanel = new HorizontalPanel(); scheduleButtonPanel.add(editScheduleButton); if (!fakeJob) { scheduleButtonPanel.add(deleteScheduleButton); } scheduledPanel.add(scheduleButtonPanel); add(scheduledPanel, DockPanel.NORTH); VerticalPanel fillPanel = new VerticalPanel(); add(fillPanel, DockPanel.NORTH); fillPanel.getElement().getParentElement().getStyle().setHeight(100, Unit.PCT); } }); } catch (RequestException re) { //ignored } }
From source file:org.pentaho.mantle.client.admin.ContentCleanerPanel.java
License:Open Source License
/** * @param age// w w w . ja v a 2 s .com * in milliseconds */ public void deleteContentNow(long age) { showLoadingIndicator(); String date = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(new Date()); String json = "{\"jobName\": \"Content Cleaner\", \"actionClass\": \"org.pentaho.platform.admin.GeneratedContentCleaner\"," + " \"jobParameters\":[ { \"name\": \"age\", \"stringValue\": \"" + age + "\", \"type\": \"string\" }], \"simpleJobTrigger\": { \"endTime\": null, \"repeatCount\": \"0\", " + "\"repeatInterval\": \"0\", \"startTime\": \"" + date + "\", \"uiPassParam\": \"RUN_ONCE\"} }"; RequestBuilder scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.POST, GWT.getHostPageBaseURL() + "api/scheduler/job"); scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); scheduleFileRequestBuilder.setHeader("Content-Type", "application/json"); //$NON-NLS-1$//$NON-NLS-2$ try { scheduleFileRequestBuilder.sendRequest(json, new RequestCallback() { public void onError(Request request, Throwable exception) { } public void onResponseReceived(Request request, Response response) { String jobId = response.getText(); final RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "api/scheduler/jobinfo?jobId=" + URL.encodeQueryString(jobId)); requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); requestBuilder.setHeader("Content-Type", "application/json"); //$NON-NLS-1$//$NON-NLS-2$ requestBuilder.setHeader("accept", "application/json"); //$NON-NLS-1$//$NON-NLS-2$ // create a timer to check if the job has finished Timer t = new Timer() { public void run() { try { requestBuilder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { // if we're receiving a correct job info, then the job is still executing. // once the job is finished, it is removed from scheduler and we should receive a 404 code. if (response.getStatusCode() != Response.SC_OK) { hideLoadingIndicator(); cancel(); } } @Override public void onError(Request request, Throwable throwable) { hideLoadingIndicator(); cancel(); } }); } catch (RequestException e) { hideLoadingIndicator(); cancel(); } } }; t.scheduleRepeating(1000); } }); } catch (RequestException re) { hideLoadingIndicator(); } }
From source file:org.pentaho.mantle.client.admin.EmailAdminPanelController.java
License:Open Source License
private void getEmailConfig() { String serviceUrl = GWT.getHostPageBaseURL() + "api/emailconfig/getEmailConfig?cb=" + System.currentTimeMillis(); RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, serviceUrl); executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); executableTypesRequestBuilder.setHeader("accept", "application/json"); try {/*from w ww. j a v a2 s. co m*/ executableTypesRequestBuilder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { } public void onResponseReceived(Request request, Response response) { emailConfig = JsEmailConfiguration.parseJsonString(response.getText()); authenticationCheckBox.setValue(Boolean.parseBoolean(emailConfig.isAuthenticate() + "")); authenticationPanel.setVisible(Boolean.parseBoolean(emailConfig.isAuthenticate() + "")); smtpHostTextBox.setValue(emailConfig.getSmtpHost()); portTextBox.setValue(emailConfig.getSmtpPort() + ""); useStartTLSCheckBox.setValue(Boolean.parseBoolean(emailConfig.isUseStartTls() + "")); useSSLCheckBox.setValue(Boolean.parseBoolean(emailConfig.isUseSsl() + "")); fromAddressTextBox.setValue(emailConfig.getDefaultFrom()); fromNameTextBox.setValue(emailConfig.getFromName()); userNameTextBox.setValue(emailConfig.getUserId()); // If password is non-empty.. disable the text-box String password = emailConfig.getPassword(); passwordTextBox.setValue(password); String protocol = emailConfig.getSmtpProtocol(); protocolsListBox.setSelectedIndex(-1); if (!StringUtils.isEmpty(protocol)) { for (int i = 0; i < protocolsListBox.getItemCount(); ++i) { if (protocol.equalsIgnoreCase(protocolsListBox.getItemText(i))) { protocolsListBox.setSelectedIndex(i); break; } } } } }); } catch (RequestException e) { //ignored } }
From source file:org.pentaho.mantle.client.admin.UserDialog.java
License:Open Source License
private void performSave() throws RequestException { String url = GWT.getHostPageBaseURL() + "api/repo/files/reservedCharacters"; RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url); requestBuilder.sendRequest("", new RequestCallback() { @Override// w ww . ja v a2s . co m public void onResponseReceived(Request request, Response response) { String userName = nameTextBox.getText(); String password = passwordTextBox.getText(); String reservedCharacters = response.getText(); if (isValidName(userName, reservedCharacters)) { controller.saveUser(userName, password); hide(); } else { showErrorMessage(userName, reservedCharacters); } } @Override public void onError(Request request, Throwable exception) { hide(); } }); }