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

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

Introduction

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

Prototype

public final native int length() ;

Source Link

Document

Gets the length of the array.

Usage

From source file:org.cruxframework.crux.core.client.utils.JsUtils.java

License:Apache License

public static FastList<String> toFastList(JsArrayString jSArray) {
    FastList<String> result = new FastList<String>();
    for (int i = 0; i < jSArray.length(); i++) {
        result.add(jSArray.get(i));//w  w  w . j a  va2 s . c  o  m
    }
    return result;
}

From source file:org.dataconservancy.dcs.access.client.model.DcpTree.java

License:Apache License

private void add_kid(JsEntity kid, JsArrayString parents) {
    for (int i = 0; i < parents.length(); i++) {
        String parent_id = parents.get(i);

        add_kid(kid, parent_id);/*ww  w.jav a 2  s.  co m*/
    }
}

From source file:org.dataconservancy.dcs.access.client.model.DcpTree.java

License:Apache License

private void add_kids(HashMap<String, JsFile> map, JsArrayString kids, String parent_id) {
    for (int i = 0; i < kids.length(); i++) {
        String kid_id = kids.get(i);
        JsEntity kid = map.get(kid_id);//w  w w .j av a 2 s . co m

        if (kid != null) {
            add_kid(kid, parent_id);
        }
    }
}

From source file:org.dataconservancy.dcs.access.client.presenter.EntityProvPresenter.java

License:Apache License

@Override
public void bind() {

    userService.checkSession(null, new AsyncCallback<UserSession>() {

        @Override/*from   w w  w .j  a v  a2  s .  c  om*/
        public void onSuccess(UserSession result) {
            final String entityUrl = display.getEntityId();
            //                  "http://seadva-test.d2i.indiana.edu:5667/sead-wf/entity/192410";
            //"http%3A%2F%2Fseadva-test.d2i.indiana.edu%3A5667%2Fsead-wf%2Fentity%2F189712";
            //                  "agent:f8477e5d-922f-41fb-9496-ba39ff218264";
            //                  "agent:7dd76828-d615-4c76-9f95-427a1dcdf5f4";
            //                  "agent:e4b2ea67-e775-498d-af9e-fcb1a0235f01";
            //                  "agent:4f1e3f38-6fc4-47f8-8e15-4358f80b0986v";
            //             "agent:fb9c6de1-322b-467b-8a88-f6475c6fa0f1";
            String queryUrl = SeadApp.roUrl + "resource/entityGraph/"
                    + entityUrl.replace(":", "%3A").replace("/", "%2F");
            //            queryUrl = "http://seadva-test.d2i.indiana.edu/ro/resource/agentGraph/agent:fb9c6de1-322b-467b-8a88-f6475c6fa0f1";

            JsonpRequestBuilder rb = new JsonpRequestBuilder();
            rb.setTimeout(100000);
            rb.requestObject(queryUrl, new AsyncCallback<JsProvGraph>() {

                @Override
                public void onFailure(Throwable caught) {
                    new ErrorPopupPanel("Error:" + caught.getMessage()).show();
                }

                @Override
                public void onSuccess(JsProvGraph entityGraph) {

                    //Get all activities related to this entity
                    //Get all entities related to this entity
                    //Get all activities related to these entities as well
                    JsProvDocument document = entityGraph.getDocument();

                    JsProvEntity entity = document.getEntity(
                            //"http://seadva-test.d2i.indiana.edu:5667/sead-wf/entity/189712"
                            entityUrl);

                    //  Window.alert(entityId);

                    UtilPopulate populate = new UtilPopulate();
                    populate.populateEntities(entity.getEntityId(), document);
                    JsArrayString entitiesStr = populate.getEArrayString();

                    TreeMap<Date, HTML> htmlMap = new TreeMap<Date, HTML>(Collections.reverseOrder());
                    //  JsArray<JsProvEntity> entities = document.getSafeEntities();
                    String relations = "";
                    for (int j = 0; j < entitiesStr.length(); j++) {
                        String entityLink = "";
                        JsArray<JsGenerated> generatedBys = document
                                .getGeneratedBysByEntity(entitiesStr.get(j));
                        //  Window.alert(generatedBys.length()+" generatedBys");
                        JsArray<JsAssociatedWith> activities = document.getSafeActivities();
                        //  Window.alert(activities.length()+" activities");

                        for (int i = 0; i < generatedBys.length(); i++) {

                            JsGenerated gen = generatedBys.get(i);
                            String activityId = gen.getActivityId();

                            JsAssociatedWith activity = null;
                            //  Window.alert("activityId = " +activityId);

                            for (int k = 0; k < activities.length(); k++) {
                                if (activities.get(k) == null || activities.get(k).getActivityId() == null)
                                    continue;
                                if (activities.get(k).getActivityId().equalsIgnoreCase(activityId)) {
                                    activity = activities.get(k);
                                    break;
                                }
                            }

                            if (activity == null) {
                                Window.alert("Continuing 3");
                                continue;
                            }

                            if (gen.getTimeString() == null || gen.getTimeString().length() < 2) {
                                Window.alert("Continuing 4");
                                continue;
                            }

                            String timeString = gen.getTimeString().substring(0,
                                    gen.getTimeString().length() - 2);

                            String activityString = activity.getEventType();

                            if (activityString.contains("Curation-Workflow"))
                                activityString = "Submission-Workflow";
                            entity = document.getEntityById(entitiesStr.get(j));

                            entityLink = "<a href=\"" + GWT.getModuleName().replace("sead_access",
                                    //                                "Sead_access.html?gwt.codesvr=127.0.0.1:9997"
                                    "") + "#" + SeadState.CURATIONOBJECT.toToken(entity.getEntityUrl())
                                    + "\"><font color=\"steelblue\">" + entity.getEntityTitle() + "</font></a>";

                            HTML html = new HTML(
                                    "<font color=\"gray\">" + timeString + "</font>" + "&nbsp;&nbsp;"
                                            + activityString + "&nbsp; was performed on &nbsp;" + entityLink,
                                    true);

                            html.setStyleName("ActivityEntry");

                            DateTimeFormat format = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
                            htmlMap.put(format.parse(timeString), html);
                        }
                        if (j > 0)
                            relations += ", ";
                        relations += entityLink + "&nbsp;&nbsp;";
                    }

                    //sort the htmlArray by Date

                    if (htmlMap.values().size() == 0 || htmlMap.size() == 0) {
                        HTML html = new HTML(
                                "<font color=\"gray\"><center>" + "No Activity Yet" + "</center></font>", true);
                        html.setStyleName("ActivityEntry");
                        display.getActivityContainer().add(html);
                    } else
                        for (HTML html : htmlMap.values())
                            display.getActivityContainer().add(html);

                    HTML html = new HTML("<font color=\"gray\">" + "Relations" + "</font>", true);
                    html.setStyleName("ActivityEntry");
                    display.getActivityContainer().add(html);
                    html = new HTML(relations + "&nbsp;&nbsp; represent lineage stages of a single RO.", true);
                    display.getActivityContainer().add(html);

                }

            });
        }

        @Override
        public void onFailure(Throwable caught) {
            new ErrorPopupPanel("Error:" + caught.getMessage()).show();
        }
    });
}

From source file:org.dataconservancy.dcs.access.client.Util.java

License:Apache License

public static Widget entityLinks(JsArrayString ids) {
    if (ids.length() == 0) {
        return new Label();
    }//ww  w  .  j av  a 2  s. com

    MenuBar top = new MenuBar();
    // TODO work around bug with menubar width
    top.setWidth("15ex");
    top.setAnimationEnabled(true);

    MenuBar refs = new MenuBar(true);

    top.addItem("Entities (" + ids.length() + ")", refs);

    for (int i = 0; i < ids.length(); i++) {
        final String id = ids.get(i);

        refs.addItem(id, new Command() {
            public void execute() {
                History.newItem(SeadState.ENTITY.toToken(id));
            }
        });
    }

    return top;
}

From source file:org.dataconservancy.dcs.access.client.Util.java

License:Apache License

public static Widget metadataLinks(JsArrayString ids) {
    if (ids.length() == 0) {
        return new Label();
    }/*from  w  w  w.j  a va 2s.c  o m*/

    MenuBar top = new MenuBar();
    top.setWidth("15ex");
    top.setAnimationEnabled(true);

    final MenuBar refs = new MenuBar(true);

    top.addItem("View Metadata (" + ids.length() + ")", refs);

    for (int i = 0; i < ids.length(); i++) {
        final String id = ids.get(i);
        JsonpRequestBuilder rb = new JsonpRequestBuilder();

        String query = Search.createLiteralQuery("id", id);
        String searchUrl = Search.searchURL(query, 0, true, Constants.MAX_SEARCH_RESULTS);
        rb.requestObject(searchUrl, new AsyncCallback<JsSearchResult>() {

            public void onFailure(Throwable caught) {
                reportInternalError("Viewing entity", caught);
            }

            public void onSuccess(final JsSearchResult result) {
                final JsMatch m = result.matches().get(0);
                if (m.getEntityType().equalsIgnoreCase("file")) {

                    final JsArray<JsFormat> formats = ((JsFile) m.getEntity()).getFormats();
                    if (formats.length() > 0) {

                        refs.addItem(formats.get(0).getFormat(), new Command() {
                            public void execute() {
                                String fileSource = ((JsFile) m.getEntity()).getPrimaryDataLocation()
                                        .getLocation();
                                if (!(fileSource.startsWith("http://") || fileSource.startsWith("https://")))
                                    fileSource = ((JsFile) m.getEntity()).getSource();
                                MetadataPopupPanel statusPopupPanel = new MetadataPopupPanel(fileSource,
                                        formats.get(0).getFormat());
                                statusPopupPanel.show();
                            }
                        });
                    }
                }
            }
        });

    }

    return top;
}

From source file:org.dataconservancy.dcs.access.server.model.JsModel.java

License:Apache License

protected static String toString(JsArrayString array) {
    if (array == null || array.length() == 0) {
        return "";
    }//from   ww w .  j  a va  2 s.c o m

    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < array.length(); i++) {
        sb.append(array.get(i));

        if (i < array.length() - 1) {
            sb.append(", ");
        }
    }

    return sb.toString();
}

From source file:org.dataconservancy.dcs.access.ui.client.Util.java

License:Apache License

public static Widget entityLinks(JsArrayString ids) {
    if (ids.length() == 0) {
        return new Label();
    }//from   www . ja  v  a  2s . co m

    MenuBar top = new MenuBar();
    // TODO work around bug with menubar width
    top.setWidth("15ex");
    top.setAnimationEnabled(true);

    MenuBar refs = new MenuBar(true);

    top.addItem("Entities (" + ids.length() + ")", refs);

    for (int i = 0; i < ids.length(); i++) {
        final String id = ids.get(i);

        refs.addItem(id, new Command() {
            public void execute() {
                History.newItem(State.ENTITY.toToken(id));
            }
        });
    }

    return top;
}

From source file:org.daxplore.presenter.client.json.shared.JsonTools.java

License:Open Source License

/**
 * Convert a {@link JsArrayString} to a String array.
 * /*from  w w  w  .  j ava2s  . c o m*/
 * @param jsArray
 *            the js array
 * @return the string[]
 */
public static String[] jsArrayAsArray(JsArrayString jsArray) {
    String[] javaArray = new String[jsArray.length()];
    for (int i = 0; i < jsArray.length(); i++) {
        javaArray[i] = jsArray.get(i);
    }
    return javaArray;
}

From source file:org.daxplore.presenter.client.json.shared.JsonTools.java

License:Open Source License

/**
 * Convert a {@link JsArrayString} to a List<String>.
 * /* w w w. j  a  va 2s.  c  o m*/
 * @param jsArray
 *            the js array
 * @return the list
 */
public static List<String> jsArrayAsList(JsArrayString jsArray) {
    List<String> list = new LinkedList<String>();
    for (int i = 0; i < jsArray.length(); i++) {
        list.add(jsArray.get(i));
    }
    return list;
}