List of usage examples for com.google.gwt.core.client JsArray setLength
public final native void setLength(int newLength) ;
From source file:com.emitrom.ti4j.mobile.client.ui.Gradient.java
License:Apache License
/** * Set the colors of this gradient using an array of colors with equal amount * offsets and colors.// www . j a v a2 s .c om * @param colors The array of color strings * @param offsets The offsets */ public final void setColors(String[] colors, double[] offsets) { if (colors.length != offsets.length) { return; //Misfit between colors and offsets array length } @SuppressWarnings("unchecked") JsArray<JavaScriptObject> c = (JsArray<JavaScriptObject>) JavaScriptObject.createArray(); c.setLength(colors.length); for (int i = 0; i < colors.length; ++i) { JavaScriptObject newColor = createColorOffset(colors[i], offsets[i]); c.set(i, newColor); } setColors(c); }
From source file:com.smartgwt.client.util.JSOHelper.java
License:Open Source License
public static <O extends JavaScriptObject> JsArray<O> convertToJsArray(O[] array) { if (array == null) return null; else {/* w ww. j a v a2 s . com*/ final JsArray<O> ret = (JsArray<O>) JavaScriptObject.createArray(); ret.setLength(array.length); for (int i = 0; i < array.length; ++i) { ret.set(i, array[i]); } return ret; } }
From source file:org.rstudio.studio.client.common.dependencies.DependencyManager.java
License:Open Source License
private void withDependencies(String progressCaption, final String userAction, final CommandWith2Args<String, Command> userPrompt, Dependency[] dependencies, final boolean silentEmbeddedUpdate, final Command command) { // convert dependencies to JsArray JsArray<Dependency> deps = JsArray.createArray().cast(); deps.setLength(dependencies.length); for (int i = 0; i < deps.length(); i++) deps.set(i, dependencies[i]);/*from w ww. j a va 2s . c om*/ // create progress indicator final ProgressIndicator progress = new GlobalProgressDelayer(globalDisplay_, 250, progressCaption + "...") .getIndicator(); // query for unsatisfied dependencies server_.unsatisfiedDependencies(deps, silentEmbeddedUpdate, new ServerRequestCallback<JsArray<Dependency>>() { @Override public void onResponseReceived(final JsArray<Dependency> unsatisfiedDeps) { progress.onCompleted(); // if we've satisfied all dependencies then execute the command if (unsatisfiedDeps.length() == 0) { command.execute(); return; } // check to see if we can satisfy the version requirement for all // dependencies String unsatisfiedVersions = ""; for (int i = 0; i < unsatisfiedDeps.length(); i++) { if (!unsatisfiedDeps.get(i).getVersionSatisfied()) { unsatisfiedVersions += unsatisfiedDeps.get(i).getName() + " " + unsatisfiedDeps.get(i).getVersion(); String version = unsatisfiedDeps.get(i).getAvailableVersion(); if (version.isEmpty()) unsatisfiedVersions += " is not available\n"; else unsatisfiedVersions += " is required but " + version + " is available\n"; } } if (!unsatisfiedVersions.isEmpty()) { // error if we can't satisfy requirements globalDisplay_.showErrorMessage(userAction, "Required package versions could not be found:\n\n" + unsatisfiedVersions + "\n" + "Check that getOption(\"repos\") refers to a CRAN " + "repository that contains the needed package versions."); } else { // otherwise ask the user if they want to install the // unsatisifed dependencies Command installCommand = new Command() { @Override public void execute() { // the incoming JsArray from the server may not serialize // as expected when this code is executed from a satellite // (see RemoteServer.sendRequestViaMainWorkbench), so we // clone it before passing to the dependency installer JsArray<Dependency> newArray = JsArray.createArray().cast(); newArray.setLength(unsatisfiedDeps.length()); for (int i = 0; i < unsatisfiedDeps.length(); i++) { newArray.set(i, unsatisfiedDeps.get(i)); } installDependencies(newArray, silentEmbeddedUpdate, command); } }; if (userPrompt != null) { userPrompt.execute(describeDepPkgs(unsatisfiedDeps), installCommand); } else { confirmPackageInstallation(userAction, unsatisfiedDeps, installCommand); } } } @Override public void onError(ServerError error) { progress.onError(error.getUserMessage()); } }); }
From source file:org.rstudio.studio.client.vcs.VCSApplicationParams.java
License:Open Source License
public final static VCSApplicationParams create(boolean showHistory, FileSystemItem historyFileFilter, ArrayList<StatusAndPath> selected) { JsArray<StatusAndPathInfo> jsSelected = JavaScriptObject.createArray().cast(); jsSelected.setLength(selected.size()); for (int i = 0; i < selected.size(); i++) jsSelected.set(i, selected.get(i).toInfo()); return createNative(showHistory, historyFileFilter, jsSelected); }
From source file:org.rstudio.studio.client.workbench.views.output.lint.LintMarkers.java
License:Open Source License
public JsArray<AceAnnotation> asAceAnnotations() { JsArray<AceAnnotation> annotations = JsArray.createArray().cast(); annotations.setLength(annotations_.size()); for (int i = 0; i < annotations_.size(); i++) annotations.set(i, annotations_.get(i).asAceAnnotation()); return annotations; }
From source file:org.rstudio.studio.client.workbench.views.source.editors.text.AceEditorWidget.java
License:Open Source License
public JsArray<AceAnnotation> getAnnotations() { JsArray<AceAnnotation> annotations = JsArray.createArray().cast(); annotations.setLength(annotations_.size()); for (int i = 0; i < annotations_.size(); i++) annotations.set(i, annotations_.get(i).asAceAnnotation()); return annotations; }