Search in sources :

Example 81 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project gerrit by GerritCodeReview.

the class Extras method clearAnnotations.

public final void clearAnnotations() {
    JsArrayString gutters = ((JsArrayString) JsArrayString.createArray());
    cm.setOption("gutters", gutters);
    annotated = false;
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 82 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project gerrit by GerritCodeReview.

the class Extras method setAnnotations.

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));
    }
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) RangeInfo(com.google.gerrit.client.RangeInfo) JsArrayString(com.google.gwt.core.client.JsArrayString) Date(java.util.Date) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat) BlameInfo(com.google.gerrit.client.blame.BlameInfo)

Example 83 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project gerrit by GerritCodeReview.

the class ModeInjector method ensureDependenciesAreLoaded.

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);
    }
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 84 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project gerrit by GerritCodeReview.

the class ChangeInfo method getMissingLabelIndex.

/**
   * @return the index of the missing label or -1 if no label is missing, or if more than one label
   *     is missing.
   */
public final int getMissingLabelIndex() {
    int i = -1;
    int ret = -1;
    List<LabelInfo> labels = Natives.asList(allLabels().values());
    for (LabelInfo label : labels) {
        i++;
        if (!permittedLabels().containsKey(label.name())) {
            continue;
        }
        JsArrayString values = permittedValues(label.name());
        if (values.length() == 0) {
            continue;
        }
        switch(label.status()) {
            case // Label is required for submit.
            NEED:
                if (ret != -1) {
                    // approve, return -1
                    return -1;
                }
                ret = i;
                continue;
            // Label already applied.
            case OK:
            case // Label is not required.
            MAY:
                continue;
            // Submit cannot happen, do not quick approve.
            case REJECT:
            case IMPOSSIBLE:
                return -1;
        }
    }
    return ret;
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 85 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project opennms by OpenNMS.

the class JSNodeMarker method getCategoriesAsString.

public String getCategoriesAsString() {
    final StringBuilder catBuilder = new StringBuilder();
    final JsArrayString categories = getCategories();
    if (categories.length() > 0) {
        if (categories.length() == 1) {
            catBuilder.append("Category: ");
        } else {
            catBuilder.append("Categories: ");
        }
        for (int i = 0; i < categories.length(); i++) {
            catBuilder.append(categories.get(i));
            if (i != (categories.length() - 1)) {
                catBuilder.append(", ");
            }
        }
    }
    return catBuilder.toString();
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString)

Aggregations

JsArrayString (com.google.gwt.core.client.JsArrayString)86 ArrayList (java.util.ArrayList)15 JSONString (com.google.gwt.json.client.JSONString)5 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)5 ServerError (org.rstudio.studio.client.server.ServerError)4 JsArrayInteger (com.google.gwt.core.client.JsArrayInteger)3 Command (com.google.gwt.user.client.Command)3 List (java.util.List)3 KeySequence (org.rstudio.core.client.command.KeyboardShortcut.KeySequence)3 JsObject (org.rstudio.core.client.js.JsObject)3 RmdTemplateFormatOption (org.rstudio.studio.client.rmarkdown.model.RmdTemplateFormatOption)3 JsArrayBoolean (com.google.gwt.core.client.JsArrayBoolean)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 Label (com.google.gwt.user.client.ui.Label)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 Handler (org.rstudio.core.client.command.Handler)2 EnsureHeightHandler (org.rstudio.core.client.events.EnsureHeightHandler)2 EnsureVisibleHandler (org.rstudio.core.client.events.EnsureVisibleHandler)2 ChangeFontSizeHandler (org.rstudio.studio.client.application.events.ChangeFontSizeHandler)2 RmdFrontMatterOutputOptions (org.rstudio.studio.client.rmarkdown.model.RmdFrontMatterOutputOptions)2