List of usage examples for com.google.gwt.core.client JsArrayString push
public final native void push(String value) ;
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleParamsDialog.java
License:Open Source License
@Override protected boolean onFinish() { scheduleParams = getScheduleParams(false); if (editJob != null) { String lineageId = editJob.getJobParamValue("lineage-id"); // JsArrayString jobIdValue = (JsArrayString) JavaScriptObject.createArray().cast(); // jobIdValue.push( editJob.getJobId() ); JsArrayString lineageIdValue = (JsArrayString) JavaScriptObject.createArray().cast(); lineageIdValue.push(lineageId); JsSchedulingParameter p = (JsSchedulingParameter) JavaScriptObject.createObject().cast(); p.setName("lineage-id"); p.setType("string"); p.setStringValue(lineageIdValue); scheduleParams.set(scheduleParams.size(), new JSONObject(p)); }/*from w w w .j ava2s .co m*/ if (isEmailConfValid) { showScheduleEmailDialog(scheduleParams); } else { hide(); JSONObject scheduleRequest = (JSONObject) JSONParser.parseStrict(jobSchedule.toString()); scheduleRequest.put("jobParameters", scheduleParams); //$NON-NLS-1$ RequestBuilder scheduleFileRequestBuilder = ScheduleHelper.buildRequestForJob(editJob, scheduleRequest); try { scheduleFileRequestBuilder.sendRequest(scheduleRequest.toString(), new RequestCallback() { @Override public void onError(Request request, Throwable exception) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ exception.toString(), false, false, true); dialogBox.center(); setDone(false); } @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == 200) { setDone(true); ScheduleParamsDialog.this.hide(); if (callback != null) { callback.okPressed(); } if (afterResponseCallback != null) { afterResponseCallback.onResponse(jobSchedule.get("runInBackground")); } } else { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("serverErrorColon") + " " + response.getStatusCode(), //$NON-NLS-1$ false, false, true); dialogBox.center(); setDone(false); } } }); } catch (RequestException e) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), e.toString(), //$NON-NLS-1$ false, false, true); dialogBox.center(); setDone(false); } setDone(true); } return false; }
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleRecurrenceDialog.java
License:Open Source License
private void handleWizardPanels(final JSONObject schedule, final JsJobTrigger trigger) { if (hasParams) { showScheduleParamsDialog(trigger, schedule); } else if (isEmailConfValid) { showScheduleEmailDialog(schedule); } else {//from w w w. ja va2 s .c o m // submit JSONObject scheduleRequest = (JSONObject) JSONParser.parseStrict(schedule.toString()); if (editJob != null) { JSONArray scheduleParams = new JSONArray(); for (int i = 0; i < editJob.getJobParams().length(); i++) { JsJobParam param = editJob.getJobParams().get(i); JsArrayString paramValue = (JsArrayString) JavaScriptObject.createArray().cast(); paramValue.push(param.getValue()); JsSchedulingParameter p = (JsSchedulingParameter) JavaScriptObject.createObject().cast(); p.setName(param.getName()); p.setType("string"); //$NON-NLS-1$ p.setStringValue(paramValue); scheduleParams.set(i, new JSONObject(p)); } scheduleRequest.put("jobParameters", scheduleParams); //$NON-NLS-1$ String actionClass = editJob.getJobParamValue("ActionAdapterQuartzJob-ActionClass"); //$NON-NLS-1$ if (!StringUtils.isEmpty(actionClass)) { scheduleRequest.put("actionClass", new JSONString(actionClass)); //$NON-NLS-1$ } } RequestBuilder scheduleFileRequestBuilder = ScheduleHelper.buildRequestForJob(editJob, scheduleRequest); try { scheduleFileRequestBuilder.sendRequest(scheduleRequest.toString(), new RequestCallback() { @Override public void onError(Request request, Throwable exception) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ exception.toString(), false, false, true); dialogBox.center(); setDone(false); } @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == 200) { setDone(true); ScheduleRecurrenceDialog.this.hide(); if (callback != null) { callback.okPressed(); } } else { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ Messages.getString("serverErrorColon") + " " + response.getStatusCode(), false, false, true); dialogBox.center(); setDone(false); } } }); } catch (RequestException e) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), e.toString(), //$NON-NLS-1$ false, false, true); dialogBox.center(); setDone(false); } setDone(true); } }
From source file:org.pentaho.mantle.client.ui.PerspectiveManager.java
License:Open Source License
private JsArrayString getPerspectives() { JsArrayString stringArray = getJsArrayString(); for (IPluginPerspective perspective : perspectives) { stringArray.push(perspective.getId()); }/*from w w w . j a v a 2s . c o m*/ return stringArray; }
From source file:org.rest.client.storage.indexeddb.IDBDatabase.java
License:Apache License
/** * Immediately returns an {@link IDBTransaction} object, and starts a * transaction in a separate thread. The method returns a transaction object * ({@link IDBTransaction}) containing the objectStore() method, which you * can use to access your object store. <br/> * Example in javascript:// w w w .j ava 2 s. c o m * * <pre> * var transaction = db.transaction(['my-store-name', 'my-store-name2'], IDBTransaction.READ_ONLY_TRANSACTION); * </pre> * * You cannot pass an empty array into the storeNames parameter, such as in * the following: <br/> * var transaction = db.transaction([], * IDBTransaction.READ_ONLY_TRANSACTION); <br/> * Use something like: example in javascript: * * <pre> * var transaction = db.transaction(db.objectStoreNames, * IDBTransaction.READ_ONLY_TRANSACTION); * </pre> * * <br/> * * Warning: Accessing all obejct stores under the * {@link IDBTransaction#READ_WRITE_TRANSACTION} mode means that you can run * only that transaction. You cannot have writing transactions with * overlapping scopes. * * @param storeNames * The names of object stores and indexes that are in the scope * of the new transaction. Specify only the object stores that * you need to access. Include into transaction multiple object * stores. * @param mode * The types of access that can be performed in the transaction. * Transactions are opened in one of three modes: * {@link IDBTransaction#READ_ONLY_TRANSACTION}, * {@link IDBTransaction#READ_WRITE_TRANSACTION}, and * {@link IDBTransaction#VERSION_CHANGE}. If you don't provide * the parameter, the default access mode is READ_ONLY. To avoid * slowing things down, don't open a * {@link IDBTransaction#READ_WRITE_TRANSACTION} transaction, * unless you actually need to write into the database. * @return */ public final IDBTransaction transaction(String[] storeNames, String mode) throws IDBDatabaseException { try { JsArrayString store = JsArrayString.createArray().cast(); for (String name : storeNames) { store.push(name); } return this.transactionImpl(store, mode); } catch (JavaScriptException e) { throw new IDBDatabaseException(e); } }
From source file:org.rest.client.storage.indexeddb.IDBDatabase.java
License:Apache License
/** * Immediately returns an {@link IDBTransaction} object, and starts a * transaction in a separate thread. The method returns a transaction object * ({@link IDBTransaction}) containing the objectStore() method, which you * can use to access your object store. <br/> * Example in javascript://from ww w. j av a 2s. c o m * * <pre> * var transaction = db.transaction(['my-store-name'], IDBTransaction.READ_ONLY_TRANSACTION); * or * var transaction = db.transaction('my-store-name', IDBTransaction.READ_ONLY_TRANSACTION); * </pre> * * @param storeName * The names of object stores and indexes that are in the scope * of the new transaction. Specify only the object stores that * you need to access. Include into transaction single object * store * @param mode * The types of access that can be performed in the transaction. * Transactions are opened in one of three modes: * {@link IDBTransaction#READ_ONLY_TRANSACTION}, * {@link IDBTransaction#READ_WRITE_TRANSACTION}, and * {@link IDBTransaction#VERSION_CHANGE}. If you don't provide * the parameter, the default access mode is * {@link IDBTransaction#READ_ONLY_TRANSACTION}. To avoid slowing * things down, don't open a * {@link IDBTransaction#READ_WRITE_TRANSACTION} transaction, * unless you actually need to write into the database. * @return current {@link IDBTransaction} * @throws IDBDatabaseException */ public final IDBTransaction transaction(String storeName, String mode) throws IDBDatabaseException { try { JsArrayString store = JsArrayString.createArray().cast(); store.push(storeName); return this.transactionImpl(store, mode); } catch (JavaScriptException e) { throw new IDBDatabaseException(e); } }
From source file:org.rstudio.core.client.js.JsUtil.java
License:Open Source License
public static JsArrayString toJsArrayString(Iterable<String> strings) { JsArrayString result = JsArrayString.createArray().cast(); for (String s : strings) result.push(s); return result; }
From source file:org.rstudio.core.client.js.JsUtil.java
License:Open Source License
public static JsArrayString toJsArrayString(String[] strings) { JsArrayString result = JsArrayString.createArray().cast(); for (String s : strings) result.push(s); return result; }
From source file:org.rstudio.core.client.JsArrayUtil.java
License:Open Source License
public static JsArrayString toJsArrayString(List<String> in) { JsArrayString out = JavaScriptObject.createArray().cast(); for (int i = 0; i < in.size(); i++) { out.push(in.get(i)); }//from w ww .ja va 2 s .co m return out; }
From source file:org.rstudio.studio.client.application.IgnoredUpdates.java
License:Open Source License
public final void addIgnoredUpdate(String update) { JsArrayString newUpdateList = create().getIgnoredUpdates(); JsArrayString existingUpdateList = getIgnoredUpdates(); for (int i = 0; i < existingUpdateList.length(); i++) { // We want to discard any updates we're ignoring that are older than // the one we're ignoring now--i.e. if we're currently ignoring // { 0.98.407, 0.99.440 }, and we were just asked to ignore // 0.98.411, the new set should be { 0.98.411, 0.99.440 }. Do this by // only keeping updates in the list that are newer than the update // we're about to add. if (compareVersions(update, existingUpdateList.get(i)) < 0) { newUpdateList.push(existingUpdateList.get(i)); }//from w w w .ja va2s . c om } newUpdateList.push(update); setIgnoredUpdates(newUpdateList); }
From source file:org.rstudio.studio.client.common.r.roxygen.RoxygenHelper.java
License:Open Source License
private void amendExistingRoxygenBlock(int row, String objectName, JsArrayString argNames, JsArrayString argTypes, String tagName, Pattern pattern) { // Get the range encompassing this Roxygen block. Range range = getRoxygenBlockRange(row); // Extract that block (as an array of strings) JsArrayString block = extractRoxygenBlock(editor_.getWidget().getEditor(), range); // If the block contains roxygen parameters that require // non-local information (e.g. @inheritParams), then // bail.//from www . j av a2 s .c o m for (int i = 0; i < block.length(); i++) { if (RE_ROXYGEN_NONLOCAL.test(block.get(i))) { view_.showWarningBar( "Cannot automatically update roxygen blocks " + "that are not self-contained."); return; } } String roxygenDelim = RE_ROXYGEN.match(block.get(0), 0).getGroup(1); // The replacement block (we build by munging parts of // the old block JsArrayString replacement = JsArray.createArray().cast(); // Scan through the block to get the names of // pre-existing parameters. JsArrayString params = listParametersInRoxygenBlock(block, pattern); // Figure out what parameters need to be removed, and remove them. // Any parameter not mentioned in the current function's argument list // should be stripped out. JsArrayString paramsToRemove = setdiff(params, argNames); int blockLength = block.length(); for (int i = 0; i < blockLength; i++) { // If we encounter a param we don't want to extract, then // move over it. Match match = pattern.match(block.get(i), 0); if (match != null && contains(paramsToRemove, match.getGroup(1))) { i++; while (i < blockLength && !RE_ROXYGEN_WITH_TAG.test(block.get(i))) i++; i--; continue; } replacement.push(block.get(i)); } // Now, add example roxygen for any parameters that are // present in the function prototype, but not present // within the roxygen block. int insertionPosition = findParamsInsertionPosition(replacement, pattern); JsArrayInteger indices = setdiffIndices(argNames, params); // NOTE: modifies replacement insertNewTags(replacement, argNames, argTypes, indices, roxygenDelim, tagName, insertionPosition); // Ensure space between final param and next tag ensureSpaceBetweenFirstParamAndPreviousEntry(replacement, roxygenDelim, pattern); ensureSpaceBetweenFinalParamAndNextTag(replacement, roxygenDelim, pattern); // Apply the replacement. editor_.getSession().replace(range, replacement.join("\n") + "\n"); }