Java 类com.google.gwt.core.client.JsArrayString 实例源码

项目:Charba    文件:JsEnumValueArrayList.java   
/**
 * Internal constructor used to load a JSArray already in another object.
 * @param values all values of an enumeration
 * @param array JS array instance
 */
JsEnumValueArrayList(E[] values, JsArrayStringImpl array) {
    // sets all enumeration values
    this.definedValues = values;
    // if null, creates a new JS array
    if (array == null){
        this.array = (JsArrayStringImpl)JsArrayString.createArray().cast();
    } else {
        // uses an existing array
        this.array = array;
    }
}
项目:Charba    文件:Labels.java   
/**
 * Returns a multi line label at a specific index. An array of strings is returned. 
 * @param index index of label
 * @return an array of strings
 */
public final String[] getStrings(int index){
    // checks range
    if (checkRange(index)){
        // gets multi line array
        JsArrayString multiValues = getObject(index);
        // if consistent
        if (multiValues != null){
            // creates an string array
            String[] result = new String[multiValues.length()];
            // scans all values
            for (int i=0; i<multiValues.length(); i++){
                // adds to java array
                result[i] = multiValues.get(i);
            }
            // returns array
            return result;
        } else {
            // returns an empty array
            return new String[0];
        }
    }
    // returns an empty array
    return new String[0];
}
项目:document-management-system    文件:RichTextToolbar.java   
/** Native JavaScript that returns the selected text and position of the start **/
public static native JsArrayString getSelection(Element elem) /*-{
       var txt = "";
       var pos = 0;
       var range;
       var parentElement;
       var container;

       if (elem.contentWindow.getSelection) {
           txt = elem.contentWindow.getSelection();
           pos = elem.contentWindow.getSelection().getRangeAt(0).startOffset;
       } else if (elem.contentWindow.document.getSelection) {
           txt = elem.contentWindow.document.getSelection();
           pos = elem.contentWindow.document.getSelection().getRangeAt(0).startOffset;
       } else if (elem.contentWindow.document.selection) {
           range = elem.contentWindow.document.selection.createRange();
           txt = range.text;
           parentElement = range.parentElement();
           container = range.duplicate();
           container.moveToElementText(parentElement);
           container.setEndPoint('EndToEnd', range);
           pos = container.text.length - range.text.length;
       }
       return ["" + txt, "" + pos];
   }-*/;
项目:gerrit    文件:Hashtags.java   
private void addHashtag(String hashtags) {
  ChangeApi.hashtags(project.get(), changeId.get())
      .post(
          PostInput.create(hashtags, null),
          new GerritCallback<JsArrayString>() {
            @Override
            public void onSuccess(JsArrayString result) {
              Gerrit.display(
                  PageLinks.toChange(project, psId.getParentKey(), String.valueOf(psId.get())));
            }

            @Override
            public void onFailure(Throwable err) {
              UIObject.setVisible(error, true);
              error.setInnerText(
                  err instanceof StatusCodeException
                      ? ((StatusCodeException) err).getEncodedResponse()
                      : err.getMessage());
              hashtagTextBox.setEnabled(true);
            }
          });
}
项目:gerrit    文件:PathSuggestOracle.java   
@Override
protected void onRequestSuggestions(Request req, Callback cb) {
  RestApi api = ChangeApi.revision(project.get(), changeId.get(), revision.name()).view("files");
  if (req.getQuery() != null) {
    api.addParameter("q", req.getQuery() == null ? "" : req.getQuery());
  }
  api.background()
      .get(
          new AsyncCallback<JsArrayString>() {
            @Override
            public void onSuccess(JsArrayString result) {
              List<Suggestion> r = new ArrayList<>();
              for (String path : Natives.asList(result)) {
                r.add(new PathSuggestion(path));
              }
              cb.onSuggestionsReady(req, new Response(r));
            }

            @Override
            public void onFailure(Throwable caught) {
              List<Suggestion> none = Collections.emptyList();
              cb.onSuggestionsReady(req, new Response(none));
            }
          });
}
项目:gerrit    文件:IncludedInBox.java   
@Override
protected void onLoad() {
  if (!loaded) {
    ChangeApi.includedIn(
        project.get(),
        changeId.get(),
        new AsyncCallback<IncludedInInfo>() {
          @Override
          public void onSuccess(IncludedInInfo r) {
            branches.setInnerSafeHtml(formatList(r.branches()));
            tags.setInnerSafeHtml(formatList(r.tags()));
            for (String n : r.externalNames()) {
              JsArrayString external = r.external(n);
              if (external.length() > 0) {
                appendRow(n, external);
              }
            }
            loaded = true;
          }

          @Override
          public void onFailure(Throwable caught) {}
        });
  }
}
项目:gerrit    文件:ReplyAction.java   
ReplyAction(
    ChangeInfo info,
    String revision,
    boolean hasDraftComments,
    ChangeScreen.Style style,
    CommentLinkProcessor clp,
    Widget replyButton,
    Widget quickApproveButton) {
  this.psId = new PatchSet.Id(info.legacyId(), info.revisions().get(revision)._number());
  this.project = info.projectNameKey();
  this.revision = revision;
  this.hasDraftComments = hasDraftComments;
  this.style = style;
  this.clp = clp;
  this.replyButton = replyButton;
  this.quickApproveButton = quickApproveButton;

  boolean current = revision.equals(info.currentRevision());
  allLabels = info.allLabels();
  permittedLabels =
      current && info.hasPermittedLabels()
          ? info.permittedLabels()
          : NativeMap.<JsArrayString>create();
}
项目:gerrit    文件:ModeInjector.java   
private void ensureDependenciesAreLoaded(String mode) {
  JsArrayString deps = getDependencies(mode);
  for (int i = 0; i < deps.length(); i++) {
    String d = deps.get(i);
    if (loading.contains(d) || isModeLoaded(d)) {
      continue;
    }

    if (!canLoad(d)) {
      Logger.getLogger("net.codemirror")
          .log(Level.SEVERE, "CodeMirror mode " + d + " needs " + d);
      continue;
    }

    loading.add(d);
    beginLoading(d);
  }
}
项目:gerrit    文件:PluginName.java   
private static String getUrl(JavaScriptException e) {
  String baseUrl = baseUrl();
  JsArrayString stack = getStack(e);
  for (int i = stack.length() - 1; i >= 0; i--) {
    String frame = stack.get(i);
    int at = frame.indexOf(baseUrl);
    if (at >= 0) {
      int end = frame.indexOf(':', at + baseUrl.length());
      if (end < 0) {
        end = frame.length();
      }
      return frame.substring(at, end);
    }
  }
  return UNKNOWN;
}
项目:gerrit    文件:UnifiedChunkManager.java   
private void markEdit(DisplaySide side, int startLine, JsArrayString lines, JsArray<Span> edits) {
  if (lines == null || edits == null) {
    return;
  }

  EditIterator iter = new EditIterator(lines, startLine);
  Configuration bg =
      Configuration.create().set("className", getIntralineBgFromSide(side)).set("readOnly", true);

  Configuration diff =
      Configuration.create().set("className", getDiffColorFromSide(side)).set("readOnly", true);

  Pos last = Pos.create(0, 0);
  for (Span span : Natives.asList(edits)) {
    Pos from = iter.advance(span.skip());
    Pos to = iter.advance(span.mark());
    if (from.line() == last.line()) {
      getMarkers().add(cm.markText(last, from, bg));
    } else {
      getMarkers().add(cm.markText(Pos.create(from.line(), 0), from, bg));
    }
    getMarkers().add(cm.markText(from, to, diff));
    last = to;
    colorLines(cm, LineClassWhere.BACKGROUND, getDiffColorFromSide(side), from.line(), to.line());
  }
}
项目:Charba    文件:JsStringArrayList.java   
/**
 * Internal constructor used to load a JSArray already in another object.
 * @param array JS array instance
 */
JsStringArrayList(JsArrayStringImpl array) {
    // if null, creates a new JS array
    if (array == null){
        this.array = (JsArrayStringImpl)JsArrayString.createArray().cast();
    } else {
        // uses an existing array
        this.array = array;
    }
}
项目:Charba    文件:Labels.java   
/**
 * Adds a multi line label
 * @param values array ofstring which represents a multi line label
 */
public final void add(String... values){
    // checks if is a valid array
    if (values != null && values.length > 0){
        // creates new JS array
        JsArrayString multiValues = JsArrayString.createArray().cast();
        // scans values
        for(String value: values){
            // adds to JS array string
            multiValues.push(value);
        }
        // pushes array to JS array
        push(multiValues);
    }
}
项目:sig-seguimiento-vehiculos    文件:Projections.java   
private static List<String> getProj4jsProjections() {
    List<String> projections = new ArrayList<String>(); 

    JsArrayString projDefs = getProjDefs();

    for (int i = 0; i < projDefs.length(); i++) {
        projections.add(projDefs.get(i).trim());
    }

    return projections;
}
项目:appinventor-extensions    文件:AssetManager.java   
public static JsArrayString getExtensionsToLoad() {
  JsArrayString result = JsArrayString.createArray().cast();
  if (INSTANCE != null) {
    for (String s : INSTANCE.extensions) {
      result.push(s);
    }
  }
  return result;
}
项目:document-management-system    文件:RichTextToolbar.java   
/** Method called to toggle the style in HTML-Mode **/
private void changeHtmlStyle(String startTag, String stopTag) {
    JsArrayString tx = getSelection(styleText.getElement());
    String txbuffer = styleText.getText();
    Integer startpos = Integer.parseInt(tx.get(1));
    String selectedText = tx.get(0);
    styleText.setText(txbuffer.substring(0, startpos) + startTag + selectedText + stopTag + txbuffer.substring(startpos + selectedText.length()));
}
项目:Wiab.pro    文件:GwtStatisticsEvent.java   
private final native JsArrayString getExtraParameterNames0() /*-{
  if (!this.extraParameters) {
    var a = new Array();
    for (name in this) {
      if (name != "moduleName" && name != "subSystem" && name != "evtGroup" && name != "millis") {
        a.push(name);
      }
    }
    this.extraParameters = a;
  }
  return this.extraParameters
}-*/;
项目:Wiab.pro    文件:JsRegExp.java   
@Override
public List<String> getMatches(String test) {
  JsArrayString matches = matches(regExp, test);
  if (matches != null && matches.length() > 0) {
    List<String> result = new ArrayList<String>(matches.length());
    for (int i = 0; i < matches.length(); ++i) {
      result.add(matches.get(i));
    }
    return result;
  }
  return new ArrayList<String>();
}
项目:gwt-oauth2    文件:Auth.java   
private final String[] getScopes() {
  JsArrayString jsa = getScopesNative();
  String[] arr = new String[jsa.length()];
  for (int i = 0; i < jsa.length(); i++) {
    arr[i] = jsa.get(i);
  }
  return arr;
}
项目:WebGL4J    文件:WebGL20.java   
public static Uint32Array glGetUniformIndices(int program, List<String> uniformNames)
{
    JsArrayString arrayString = JsArrayString.createArray(uniformNames.size()).cast();

    for (String uniformName : uniformNames)
        arrayString.push(uniformName);

    return glGetUniformIndices(program, arrayString);
}
项目:WebGL4J    文件:WebGL20.java   
public static Uint32Array glGetUniformIndices(int program, String... uniformNames)
{
    JsArrayString arrayString = JsArrayString.createArray(uniformNames.length).cast();

    for (String uniformName : uniformNames)
        arrayString.push(uniformName);

    return glGetUniformIndices(program, arrayString);
}
项目:WebGL4J    文件:WebGL20.java   
public static void glTransformFeedbackVaryings(int program, List<String> varyings, int bufferMode)
{
    JsArrayString varyingsArray = JsArrayString.createArray(varyings.size()).cast();

    for (String varying : varyings)
        varyingsArray.push(varying);

    glTransformFeedbackVaryings(program, varyingsArray, bufferMode);
}
项目:gwt-chronoscope    文件:GwtJsonArrayOverlay.java   
public T get(int i) {
  T wrapper = null;
  if (parameterType == JsonArrayNumber.class) {
    wrapper = (T) new GwtJsonArrayNumber((JsArrayNumber) jso.get(i));
  } else if(parameterType == JsonArrayString.class) {
    wrapper = (T) new GwtJsonArrayString((JsArrayString) jso.get(i));
  }
  return wrapper;
}
项目:gwt-oauth    文件:Auth.java   
private final String[] getScopes() {
  JsArrayString jsa = getScopesNative();
  String[] arr = new String[jsa.length()];
  for (int i = 0; i < jsa.length(); i++) {
    arr[i] = jsa.get(i);
  }
  return arr;
}
项目:gwt-backbone    文件:JsObject.java   
public final int[] indexes() {
    checkNull();
    JsArrayString a = keysImpl();
    int[] ret = new int[a.length()];
    for (int i = 0; i < a.length(); i++) {
        try {
            ret[i] = Integer.valueOf(a.get(i));
        } catch (Exception e) {
            ret[i] = i;
        }
    }
    return ret;
}
项目:gwt-backbone    文件:JsObject.java   
private native JsArrayString keysImpl() /*-{
    var key, keys=[];
    // Chrome in DevMode sets '__gwt_ObjectId' to JS objects
    // GWT sets '$H' when calling getHashCode (see com/google/gwt/core/client/impl/Impl.java)
    for(key in this) {
        if (this.hasOwnProperty(key) && key != '__gwt_ObjectId' && key != '$H')
            keys.push(String(key));
    }
    return keys;
}-*/;
项目:gwt-jui    文件:JsArrayUtil.java   
public static JsArrayString fromStrings(Collection<String> collection) {
    JsArrayString array = JsArrayString.createArray().cast();
    for(String item : collection) {
        array.push(item);
    }
    return array;
}
项目:gwt-jui    文件:JsArrayUtil.java   
public static List<String> toList(JsArrayString array) {
    List<String> list = new ArrayList<>();
    if(array != null) {
        for (int i = 0; i < array.length(); i++) {
            list.add(array.get(i));
        }
    }
    return list;
}
项目:gerrit    文件:FileTable.java   
void markReviewed(JsArrayString reviewed) {
  if (table != null) {
    table.markReviewed(reviewed);
  } else {
    this.reviewed = reviewed;
  }
}
项目:che    文件:OrionOccurrencesRegistrant.java   
public void registerOccurrencesHandler(
    final JsArrayString contentTypes, final OrionOccurrencesHandler handler) {
  editorModule
      .getInitializerPromise()
      .then(
          new Operation<Void>() {
            @Override
            public void apply(Void arg) throws OperationException {
              registerOccurrencesHandler(
                  codeEditWidgetProvider.get().getServiceRegistry(), contentTypes, handler);
            }
          });
}
项目:che    文件:OrionHighlightingConfigurationOverlay.java   
public final void setContentTypes(String... theContentTypes) {
  JsArrayString arr = JavaScriptObject.createArray().cast();
  for (String value : theContentTypes) {
    arr.push(value);
  }
  setContentTypes(arr);
}
项目:gerrit    文件:Extras.java   
public final void setAnnotations(JsArray<BlameInfo> blameInfos) {
  if (blameInfos.length() > 0) {
    setBlameInfo(blameInfos);
    JsArrayString gutters = ((JsArrayString) JsArrayString.createArray());
    gutters.push(ANNOTATION_GUTTER_ID);
    cm.setOption("gutters", gutters);
    annotated = true;
    DateTimeFormat format = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_SHORT);
    JsArray<LintLine> annotations = JsArray.createArray().cast();
    for (BlameInfo blameInfo : Natives.asList(blameInfos)) {
      for (RangeInfo range : Natives.asList(blameInfo.ranges())) {
        Date commitTime = new Date(blameInfo.time() * 1000L);
        String shortId = blameInfo.id().substring(0, 8);
        String shortBlame =
            C.shortBlameMsg(shortId, format.format(commitTime), blameInfo.author());
        String detailedBlame =
            C.detailedBlameMsg(
                blameInfo.id(),
                blameInfo.author(),
                FormatUtil.mediumFormat(commitTime),
                blameInfo.commitMsg());

        annotations.push(
            LintLine.create(shortBlame, detailedBlame, shortId, Pos.create(range.start() - 1)));
      }
    }
    cm.setOption("lint", getAnnotation(annotations));
  }
}
项目:gerrit    文件:Hashtags.java   
private static JsArrayString toJsArrayString(String commaSeparated) {
  if (commaSeparated == null || commaSeparated.equals("")) {
    return null;
  }
  JsArrayString array = JsArrayString.createArray().cast();
  for (String hashtag : commaSeparated.split(",")) {
    array.push(hashtag.trim());
  }
  return array;
}
项目:che    文件:OrionContentTypeOverlay.java   
public final void setExtension(String... fileExtensions) {
  JsArrayString arr = JavaScriptObject.createArray().cast();
  for (String value : fileExtensions) {
    arr.push(value);
  }
  setExtension(arr);
}
项目:gwt-worker    文件:WorkerNavigatorJsoImpl.java   
@Override
public final List<String> getLanguages() {
    JsArrayString langs = getLanguages0();
    if(langs == null || langs.length() == 0) {
        return Collections.emptyList();
    }

    List<String> ls = new ArrayList<>();
    for(int i = 0; i < langs.length(); i++) {
        String l = langs.get(i);
        ls.add(l);
    }

    return ls;
}
项目:gerrit    文件:IncludedInBox.java   
private void appendRow(String title, JsArrayString l) {
  TableRowElement row = table.insertRow(-1);
  TableCellElement th = Document.get().createTHElement();
  th.setInnerText(title);
  row.appendChild(th);
  row.insertCell(-1).setInnerSafeHtml(formatList(l));
}
项目:google-apis-explorer    文件:ApiResponse.java   
/**
 * Inspects the headers object of the given JS object and constructs a
 * {@link Map} of its keys and values.
 */
private static Map<String, HeaderValue> createHeadersMap(DynamicJso data) {
  DynamicJso headers = data.get("headers");
  JsArrayString keys = headers.keys();
  Map<String, HeaderValue> headersMap = Maps.newHashMapWithExpectedSize(keys.length());

  for (int i = 0; i < keys.length(); i++) {
    String key = keys.get(i);
    String value = "";
    switch (headers.typeofKey(key)) {
      case STRING:
        value = headers.getString(key);
        break;

      case BOOLEAN:
        value = String.valueOf(headers.getBoolean(key));
        break;

      case NUMBER:
        value = String.valueOf(headers.getInteger(key));
        break;

      case INTEGER:
        value = String.valueOf(headers.getDouble(key));
        break;
    }
    headersMap.put(key.toLowerCase(), new HeaderValue(key, value));

  }
  return headersMap;
}
项目:che    文件:StringUtils.java   
@Override
public List<String> split(String string, String separator) {
  JsArrayString jsArrayString = nativeSplit(string, separator);

  List<String> result = new ArrayList<>();
  for (int i = 0; i < jsArrayString.length(); i++) {
    result.add(jsArrayString.get(i));
  }
  return result;
}
项目:che    文件:WorkerGlobalScope.java   
public final void importScripts(String[] urls) {
  JsArrayString jsUrls = JsArrayString.createArray().cast();
  for (int i = 0, l = urls.length; i < l; ++i) {
    jsUrls.set(i, urls[i]);
  }
  importScripts(jsUrls);
}