Example usage for com.google.gwt.core.client JsArrayString get

List of usage examples for com.google.gwt.core.client JsArrayString get

Introduction

In this page you can find the example usage for com.google.gwt.core.client JsArrayString get.

Prototype

public final native String get(int index) ;

Source Link

Document

Gets the value at a given index.

Usage

From source file:org.kie.workbench.common.widgets.client.widget.KieMultipleSelectElementView.java

License:Apache License

@Override
public List<String> getValue() {
    final List<String> value = new ArrayList<>();
    final JsArrayString jsValue = getValue(select);

    if (jsValue != null) {
        for (int i = 0; i < jsValue.length(); i++) {
            value.add(jsValue.get(i));
        }//  ww w .  j av a 2  s .  c  o m
    }

    return value;
}

From source file:org.kjots.json.object.gwt.client.impl.GwtJsonObjectImpl.java

License:Apache License

/**
 * Retrieve the names of the properties of the JSON object.
 *
 * @return The name of the properties of the JSON object.
 *///from ww w  .j a  v  a  2  s  . com
@Override
public final Set<String> getPropertyNames() {
    Set<String> propertyNames = new HashSet<String>();

    JsArrayString jsPropertyNames = this.getJsPropertyNames();
    for (int i = 0; i < jsPropertyNames.length(); i++) {
        propertyNames.add(jsPropertyNames.get(i));
    }

    return propertyNames;
}

From source file:org.mindinformatics.gwt.domeo.plugins.annotation.textmining.ui.viewer.TextminingResultsViewer.java

License:Apache License

public TextminingResultsViewer(IDomeo domeo, final ITextminingRequestCompleted completionCallback,
        JsAnnotationSet jsonSet) {/*from w ww  . j  a v  a2  s . c  o m*/
    _domeo = domeo;
    _completionCallback = completionCallback;
    _jsonSet = jsonSet;

    initWidget(binder.createAndBindUi(this));

    header.add(new HTML(
            "<span style='font-weight: bold;'>" + jsonSet.getLabel() + "</span>, " + jsonSet.getDescription()));

    JsArray<JavaScriptObject> jsonAnnotations = jsonSet.getAnnotation();
    for (int j = 0; j < jsonAnnotations.length(); j++) {
        // Detect annotation type
        HashSet<String> typesSet = new HashSet<String>();
        if (hasMultipleTypes(jsonAnnotations.get(j))) {
            JsArrayString types = getObjectTypes(jsonAnnotations.get(j));
            for (int k = 0; k < types.length(); k++) {
                typesSet.add(types.get(k));
            }
        } else {
            typesSet.add(getObjectType(jsonAnnotations.get(j)));
        }

        if (typesSet.contains(MQualifierAnnotation.TYPE)) {
            JsArray<JsoLinkedDataResource> tags = getSemanticTags(jsonAnnotations.get(j));
            for (int k = 0; k < tags.length(); k++) {
                JsonGenericResource gr = tags.get(k).getSource();
                MGenericResource r = ResourcesFactory.createGenericResource(gr.getUrl(), gr.getLabel());
                MLinkedResource ldr = ResourcesFactory.createTrustedResource(tags.get(k).getUrl(),
                        tags.get(k).getLabel(), r);
                ldr.setUrl(tags.get(k).getUrl());
                ldr.setLabel(tags.get(k).getLabel());
                ldr.setDescription(tags.get(k).getDescription());

                if (!terms.containsKey(ldr.getUrl()))
                    terms.put(ldr.getUrl(), ldr);

                if (!ontologies.containsKey(r)) {
                    HashMap<MLinkedResource, Integer> hSet = new HashMap<MLinkedResource, Integer>();
                    hSet.put(ldr, new Integer(1));
                    ontologies.put(r, hSet);
                } else {
                    if (ontologies.get(r).containsKey(ldr)) {
                        Integer current = ontologies.get(r).get(ldr);
                        ontologies.get(r).remove(ldr);
                        ontologies.get(r).put(ldr, ++current);
                    } else {
                        ontologies.get(r).put(ldr, new Integer(1));
                    }
                }
            }
        }
    }

    Set<MGenericResource> ts1 = ontologies.keySet();
    StringBuffer sb1 = new StringBuffer();

    for (MGenericResource t : ts1) {
        termsPanel.add(new HTML("<a href='" + t.getUrl() + "' target='_blank'>" + t.getLabel()
                + " <span class='source'></a> (" + ontologies.get(t).size() + " terms)<br/>"));
        //sb1.append("<a href='" + t.getUrl() + "' target='_blank'>" + t.getLabel() + " <span class='source'></a> (" +  ontologies.get(t).size() + ")<br/>");
        //sb1.append("<ul class='tags'>");
        FlowPanel p = new FlowPanel();
        for (MLinkedResource tt : ontologies.get(t).keySet()) {
            //sb1.append("<li><a href='" + tt.getUrl() + "' target='_blank'>" + tt.getLabel() + "</a></li>");
            TextminingResultCheckBox box = new TextminingResultCheckBox(_domeo, tt, ontologies.get(t).get(tt));
            box.setStyleName("tagss");
            boxes.add(box);
            p.add(box);
        }
        termsPanel.add(p);

        //sb1.append("</ul>");
        //sb1.append("<br/><br/>");

    }
    termsPanel.add(new HTML(sb1.toString()));

    /*
    Set<MGenericResource> ts1 = ontologies.keySet();
    StringBuffer sb1 = new StringBuffer();   
    for(MGenericResource t: ts1) {
       sb1.append("<a href='" + t.getUrl() + "' target='_blank'>" + t.getLabel() + " <span class='source'></a> (" +  ontologies.get(t).size() + ")<br/>");
       sb1.append("<ul class='tags'>");
       for(MLinkedResource tt: ontologies.get(t)) {
    sb1.append("<li><a href='" + tt.getUrl() + "' target='_blank'>" + tt.getLabel() + "</a></li>");
    termsPanel.add(new TextminingResultCheckBox(_domeo, tt));
       }
       sb1.append("</ul>");
       sb1.append("<br/><br/>");
               
               
    }
    termsPanel.add(new HTML(sb1.toString()));   
    */

    summary.add(new HTML("<span>Total of " + terms.size() + " terms and " + jsonSet.getAnnotation().length()
            + " annotations</span>"));

    Button process = new Button("Process");
    process.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            HashSet<String> uris = new HashSet<String>();
            for (TextminingResultCheckBox box : boxes) {
                String sel = box.getSelection();
                if (sel != null)
                    uris.add(sel);
            }
            completionCallback.returnTextminingResults(_jsonSet, uris);
            _containerPanel.hide();
        }

    });
    buttonsPanel.add(process);

    Button processAll = new Button("Process All");
    processAll.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            completionCallback.returnTextminingResults(_jsonSet, true);
            _containerPanel.hide();
        }
    });
    buttonsPanel.add(processAll);

    /*
    Collection<MLinkedResource> ts = terms.values();
    StringBuffer sb2 = new StringBuffer();
    sb2.append(" <ul class='tags'>");
    for(MLinkedResource t: ts) {
       sb2.append("<li><a href='" + t.getUrl() + "' target='_blank'>" + 
    t.getLabel() + " <span class='source'>- " +  
    t.getSource().getLabel() + "</span></a></li>");
    }
    sb2.append("</ul>");
    termsPanel.add(new HTML(sb2.toString()));
    */
}

From source file:org.mindinformatics.gwt.domeo.plugins.persistence.annotopia.src.AnnotopiaConverter.java

License:Apache License

/**
 * This is reading the annotation sets and the annotations and caching all the agents.
 * @param wrapper      The Annotation Set wrapper
 * @param agents      Agent ID is the key while the Agent object is the value
 * @param entityAgents  Entity (ann or set) ID is the key while the Agent ID is the value
 * @param targets       Target ID is the key while the Target object is the value
 * @param targetSources Annotation ID is the key and the Target object is the value
 *//*from   w w w  . j av  a2  s.  com*/
private void cacheAgents(JsAnnotopiaAnnotationSetGraph wrapper, HashMap<String, JsAnnotopiaAgent> agents,
        HashMap<String, String> entityAgents, HashMap<String, JsResource> targets,
        HashMap<String, String> targetSources, boolean parseAnnotations) {
    JsArray<JavaScriptObject> graphs = wrapper.getGraphs();
    if (graphs.length() == 1) {
        JavaScriptObject jsItem = graphs.get(0);

        // Extract types
        HashSet<String> typesSet = new HashSet<String>();
        if (hasMultipleTypes(jsItem)) {
            JsArrayString types = getObjectTypes(jsItem);
            for (int k = 0; k < types.length(); k++) {
                typesSet.add(types.get(k));
            }
        } else {
            typesSet.add(getObjectType(jsItem));
        }

        try {
            // ----------------------------------------
            //  Caching Annotation Sets Agents
            // ----------------------------------------
            JsAnnotopiaAnnotationSetSummary jsSet = (JsAnnotopiaAnnotationSetSummary) jsItem;

            _domeo.getLogger().debug(this, "Caching createdBy");
            // Annotation Set: createdBy
            _domeo.getLogger().debug(this, "Caching createdBy " + jsSet.isCreatedByString());
            if (jsSet.getCreatedBy() != null && jsSet.isCreatedByString()) {
                entityAgents.put("createdBy:" + jsSet.getId(), jsSet.getCreatedByAsString());
                _domeo.getLogger().debug(this, "Caching createdBy [" + "createdBy:" + jsSet.getId() + ":"
                        + jsSet.getCreatedByAsString() + "]");
            } else if (jsSet.getCreatedBy() != null && jsSet.isCreatedByObject()) {
                agents.put(jsSet.getCreatedByAsObject().getId(), jsSet.getCreatedByAsObject());
                _domeo.getLogger().debug(this, "Caching createdBy [" + "createdBy:" + jsSet.getId() + ":"
                        + jsSet.getCreatedByAsObject().getId() + "]");
            }

            _domeo.getLogger().debug(this, "Caching createdWith");
            // Annotation Set: createdWith
            if (jsSet.getCreatedWith() != null && jsSet.isCreatedWithString()) {
                entityAgents.put("createdWith:" + jsSet.getId(), jsSet.getCreatedWithAsString());
                _domeo.getLogger().debug(this, "Caching createdWith [" + "createdWith:" + jsSet.getId() + ":"
                        + jsSet.getCreatedWithAsString() + "]");
            } else if (jsSet.getCreatedWith() != null && jsSet.isCreatedWithObject()) {
                agents.put(jsSet.getCreatedWithAsObject().getId(), jsSet.getCreatedWithAsObject());
            }

            _domeo.getLogger().debug(this, "Caching lastSavedBy");
            // Annotation Set: lastSavedBy
            if (jsSet.getLastSavedBy() != null && jsSet.isLastSavedByString()) {
                entityAgents.put("lastSavedBy:" + jsSet.getId(), jsSet.getLastSavedByAsString());
            } else if (jsSet.getLastSavedBy() != null && jsSet.isLastSavedByObject()) {
                agents.put(jsSet.getLastSavedByAsObject().getId(), jsSet.getLastSavedByAsObject());
            }

            // ----------------------------------------
            //  Caching Annotation Agents
            // ----------------------------------------
            if (parseAnnotations) {
                _domeo.getLogger().debug(this, "Caching annotation agents");
                int max = jsSet.isAnnotationsArray() ? jsSet.getAnnotations().length()
                        : (jsSet.hasAnnotation() ? 1 : 0);
                _domeo.getLogger().debug(this, "Detected annotations: " + max);
                for (int i = 0; i < max; i++) {
                    JavaScriptObject a = null;
                    if (max == 1)
                        a = jsSet.getAnnotation();
                    else
                        a = jsSet.getAnnotations().get(i);
                    if (getObjectType(a).equals(IOpenAnnotation.ANNOTATION)) {
                        // Unmarshall annotatedBy
                        JsAnnotationProvenance annotationProvenance = (JsAnnotationProvenance) a;
                        if (annotationProvenance.getAnnotatedBy() != null
                                && annotationProvenance.isAnnotatedByString()) {
                            entityAgents.put("createdBy:" + annotationProvenance.getId(),
                                    annotationProvenance.getAnnotatedByAsString());
                            _domeo.getLogger().debug(this, "PUT: " + annotationProvenance.getId() + "-"
                                    + annotationProvenance.getAnnotatedByAsString());
                        } else if (annotationProvenance.getAnnotatedBy() != null
                                && annotationProvenance.isAnnotatedByObject()) {
                            agents.put(annotationProvenance.getAnnotatedByAsObject().getId(),
                                    annotationProvenance.getAnnotatedByAsObject());
                            _domeo.getLogger().debug(this,
                                    "PUT: " + annotationProvenance.getAnnotatedByAsObject().getId() + "-"
                                            + annotationProvenance.getAnnotatedByAsObject().getName());
                        }
                        if (annotationProvenance.getCreatedWith() != null
                                && annotationProvenance.isCreatedWithString()) {
                            entityAgents.put("createdWith:" + annotationProvenance.getId(),
                                    annotationProvenance.getCreatedWithAsString());
                        } else if (annotationProvenance.getCreatedWith() != null
                                && annotationProvenance.isCreatedWithObject()) {
                            agents.put(annotationProvenance.getCreatedWithAsObject().getId(),
                                    annotationProvenance.getCreatedWithAsObject());
                        }
                        if (annotationProvenance.getLastSavedBy() != null
                                && annotationProvenance.isLastSavedByString()) {
                            entityAgents.put("lastSavedBy:" + annotationProvenance.getId(),
                                    annotationProvenance.getLastSavedByAsString());
                        } else if (annotationProvenance.getLastSavedBy() != null
                                && annotationProvenance.isLastSavedByObject()) {
                            agents.put(annotationProvenance.getLastSavedByAsObject().getId(),
                                    annotationProvenance.getLastSavedByAsObject());
                        }

                        JsOpenAnnotation annotation = (JsOpenAnnotation) a;

                        // Unmarshall targets
                        boolean multipleTargets = annotation.hasMultipleTargets();
                        if (multipleTargets) {
                            JsArray<JavaScriptObject> jsTargets = annotation.getTargets();
                            for (int t = 0; t < jsTargets.length(); t++) {
                                JavaScriptObject jsTarget = jsTargets.get(t);
                                if (getObjectType(jsTarget).contains(IOpenAnnotation.SPECIFIC_RESOURCE)) {
                                    JsSpecificResource jsSpecificResource = (JsSpecificResource) jsTarget;
                                    if (jsSpecificResource.getHasSource() != null
                                            && jsSpecificResource.isHasSourceString()) {
                                        targetSources.put(jsSpecificResource.getId(),
                                                jsSpecificResource.getHasSourceAsString());
                                    } else if (jsSpecificResource.getHasSource() != null
                                            && jsSpecificResource.isHasSourceObject()) {
                                        targets.put(jsSpecificResource.getHasSourceAsObject().getId(),
                                                jsSpecificResource.getHasSourceAsObject());
                                    }
                                }
                            }
                        } else {
                            JavaScriptObject jsTarget = annotation.getTarget();
                            if (getObjectType(jsTarget).contains(IOpenAnnotation.SPECIFIC_RESOURCE)) {
                                JsSpecificResource jsSpecificResource = (JsSpecificResource) jsTarget;
                                if (jsSpecificResource.getHasSource() != null
                                        && jsSpecificResource.isHasSourceString()) {
                                    targetSources.put(jsSpecificResource.getId(),
                                            jsSpecificResource.getHasSourceAsString());
                                } else if (jsSpecificResource.getHasSource() != null
                                        && jsSpecificResource.isHasSourceObject()) {
                                    targets.put(jsSpecificResource.getHasSourceAsObject().getId(),
                                            jsSpecificResource.getHasSourceAsObject());
                                }
                            }
                        }
                    } else {
                        _domeo.getLogger().warn(this,
                                "Item not qualified as annotation... skipped" + jsSet.getId());
                    }
                }
            }

            /*
            Set<String> agentsKeys = agents.keySet();
            for(String agentsKey: agentsKeys) {
               _domeo.getLogger().debug(this, "AGENT: " + agentsKey + "-" + agents.get(agentsKey).getName());
            }
            Set<String> agentEntityKeys = entityAgents.keySet();
            for(String agentEntityKey: agentEntityKeys) {
               _domeo.getLogger().debug(this, "AGENTENTITY: " + agentEntityKey + "-" + entityAgents.get(agentEntityKey));
            }
            */
        } catch (Exception e) {
            _domeo.getLogger().exception(this, "unmarshallAnnotationSet(): " + e.getMessage());
        }
    } else {
        _domeo.getLogger().exception(this, "Graph issue, unrecognized agents format");
    }
}

From source file:org.mindinformatics.gwt.domeo.plugins.persistence.annotopia.src.AnnotopiaConverter.java

License:Apache License

/**
 * Unmarshalls the annotation sets list summaries ignoring
 * the sets details./*w  ww.j ava2 s  .co m*/
 * @return Annotation Sets list summary
 */
public List<MAnnotopiaAnnotationSet> unmarshallAnnotationSetsList(JsAnnotopiaSetsResultWrapper wrapper) {
    List<MAnnotopiaAnnotationSet> sets = new ArrayList<MAnnotopiaAnnotationSet>();

    JsArray<JsAnnotopiaAnnotationSetGraph> jsSets = wrapper.getResult().getSets();
    for (int i = 0; i < jsSets.length(); i++) {
        // Cache for lazy binding
        HashMap<String, JsAnnotopiaAgent> agents = new HashMap<String, JsAnnotopiaAgent>();
        HashMap<String, String> entityAgents = new HashMap<String, String>();
        HashMap<String, JsResource> targets = new HashMap<String, JsResource>();
        HashMap<String, String> targetSources = new HashMap<String, String>();
        // Caching of both sets and annotations
        cacheAgents(jsSets.get(i), agents, entityAgents, targets, targetSources, false);

        JsArray<JavaScriptObject> graphs = jsSets.get(i).getGraphs();
        if (graphs.length() == 1) {
            JavaScriptObject jsItem = graphs.get(0);

            // Extract types
            HashSet<String> typesSet = new HashSet<String>();
            if (hasMultipleTypes(jsItem)) {
                JsArrayString types = getObjectTypes(jsItem);
                for (int k = 0; k < types.length(); k++) {
                    typesSet.add(types.get(k));
                }
            } else {
                typesSet.add(getObjectType(jsItem));
            }

            try {
                MAnnotopiaAnnotationSet set = unmarshallAnnotationSet(jsItem, typesSet, agents, entityAgents);
                if (set != null)
                    sets.add(set);
            } catch (Exception e) {
                _domeo.getLogger().exception(this, e.getMessage());
            }
        } else {
            _domeo.getLogger().exception(this, "Unrecognized format");
        }
    }
    return sets;
}

From source file:org.mindinformatics.gwt.domeo.plugins.persistence.annotopia.src.AnnotopiaConverter.java

License:Apache License

public MAnnotationSet unmarshallAnnotationSet(JsAnnotopiaAnnotationSetGraph wrapper, boolean persist) {

    // Cache for lazy binding
    HashMap<String, JsAnnotopiaAgent> agents = new HashMap<String, JsAnnotopiaAgent>();
    HashMap<String, String> entityAgents = new HashMap<String, String>();
    HashMap<String, JsResource> targets = new HashMap<String, JsResource>();
    HashMap<String, String> targetSources = new HashMap<String, String>();

    // Caching of both sets and annotations
    cacheAgents(wrapper, agents, entityAgents, targets, targetSources, true);

    _domeo.getLogger().debug(this, "Unmarshalling set");
    JsArray<JavaScriptObject> graphs = wrapper.getGraphs();
    _domeo.getLogger().debug(this, "Graphs: " + graphs.length());
    if (graphs.length() == 1) {
        JavaScriptObject jsItem = graphs.get(0);

        // Extract types
        HashSet<String> typesSet = new HashSet<String>();
        if (hasMultipleTypes(jsItem)) {
            JsArrayString types = getObjectTypes(jsItem);
            for (int k = 0; k < types.length(); k++) {
                typesSet.add(types.get(k));
            }/*from  www .ja  v a2s . co m*/
        } else {
            typesSet.add(getObjectType(jsItem));
        }

        try {
            MAnnotopiaAnnotationSet set = unmarshallAnnotationSet(jsItem, typesSet, agents, entityAgents);

            if (set != null) {
                _domeo.getLogger().debug(this, "Unmarshalling createdWith " + set.getCreatedWith());
                // Translation to the old internal formats
                MAgentSoftware createdWith = new MAgentSoftware();
                createdWith.setUri(set.getCreatedWith().getId());
                createdWith.setName(set.getCreatedWith().getName());

                _domeo.getLogger().debug(this, "Unmarshalling createdBy " + set.getCreatedBy());
                MAgentPerson createdBy = new MAgentPerson();
                createdBy.setUri(set.getCreatedBy().getId());
                createdBy.setName(set.getCreatedBy().getName());

                // Annotation Set
                // Note: currently the lastSavedOn is forcing createdOn
                MAnnotationSet aSet = AnnotationFactory.createAnnotationSet(set.getId(), set.getId(),
                        set.getLastSavedOn(), set.getVersionNumber(), set.getPreviousVersion(),
                        _domeo.getPersistenceManager().getCurrentResource(), set.getLabel(),
                        set.getDescription());
                aSet.setCreatedWith(createdWith);
                aSet.setCreatedBy(createdBy);
                aSet.setCreatedOn(set.getCreatedOn());

                _domeo.getLogger().debug(this, "Unmarshalling annotations");
                unmarshallAnnotations(aSet, set, jsItem, agents, entityAgents, targets, targetSources, persist);

                return aSet;
            }
        } catch (Exception e) {
            _domeo.getLogger().exception(this, "unmarshallAnnotationSet(): " + e.getMessage());
        }
    } else {
        _domeo.getLogger().exception(this, "Unrecognized format");
    }
    return null;
}

From source file:org.nightcode.gwt.selectio.client.jso.SelectionJso.java

License:Apache License

@Override
public final List<String> getSearchQueries() {
    JsArrayString queries = getQueries();
    List<String> searchQueries = new ArrayList<String>();
    for (int i = queries.length() - 1; i >= 0; i--) {
        searchQueries.add(queries.get(i));
    }//w w w  . j  av  a 2 s .c  o  m
    return searchQueries;
}

From source file:org.obiba.opal.web.gwt.app.client.administration.configuration.edit.GeneralConfModalView.java

License:Open Source License

@Override
public void setSelectedLanguages(JsArrayString languages) {
    int length = languages.length();
    for (int i = 0; i < length; i++) {
        locales.setSelectedValue(languages.get(i));
    }// w  w w  .j ava 2  s . c  o m
}

From source file:org.obiba.opal.web.gwt.app.client.js.JsArrays.java

License:Open Source License

public static Iterable<String> toIterable(JsArrayString values) {
    final JsArrayString array = values != null ? values : (JsArrayString) JsArrayString.createArray();
    return new Iterable<String>() {

        @Override// ww w. j  a v a2  s .  c  o  m
        public Iterator<String> iterator() {
            return new Iterator<String>() {

                private int next = 0;

                @Override
                public boolean hasNext() {
                    return next < array.length();
                }

                @Override
                public String next() {
                    return array.get(next++);
                }

                @Override
                public void remove() {

                }
            };
        }

    };
}

From source file:org.obiba.opal.web.gwt.app.client.magma.datasource.presenter.CsvDatasourceFormPresenter.java

License:Open Source License

private void getAvailableCharsets() {
    ResourceRequestBuilderFactory.<JsArrayString>newBuilder().forResource("/files/charsets/available").get()
            .withCallback(new ResourceCallback<JsArrayString>() {
                @Override//from  w  ww  .j  av  a  2s .  c  o  m
                public void onResource(Response response, JsArrayString datasources) {
                    for (int i = 0; i < datasources.length(); i++) {
                        availableCharsets.add(datasources.get(i));
                    }
                }
            }).send();
}