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:next.celebs.JsoUtils.java

License:Apache License

public static ArrayList<String> toListString(JsArrayString jsArr) {
    int len = jsArr.length();
    ArrayList<String> list = new ArrayList<String>(len);
    for (int i = 0; i < len; i++) {
        list.add(jsArr.get(i));
    }/*w ww . j  a v a 2 s  .c o  m*/
    return list;
}

From source file:nl.strohalm.cyclos.mobile.client.model.PaymentPreview.java

License:Open Source License

private final JsArray<Fee> ensureFees() {
    JsArrayString keys = getFeeKeys();
    List<Fee> fees = new ArrayList<Fee>();
    if (keys != null && keys.length() > 0) {
        for (int i = 0; i < keys.length(); i++) {
            String key = keys.get(i);
            Fee fee = (Fee) JavaScriptObject.createObject().cast();
            fee.setName(key);/* ww w. j a va 2s. c  o m*/
            fee.setFormattedAmount(AmountHelper.getFormattedAmount(getFeeAmount(key), getUnitsPattern()));
            fees.add(fee);
        }
    }
    return JsonHelper.createGenericArray(fees);
}

From source file:nl.strohalm.cyclos.mobile.client.payments.PaymentPreviewPage.java

License:Open Source License

/**
 * Renders the form with the data/*from w  ww . jav a 2  s .  com*/
 */
private void renderPreviewData() {

    TransferType transferType = preview.getTransferType();
    JsArray<Fee> fees = preview.getFees();
    JsArrayString customFieldKeys = preview.getCustomFieldKeys();
    String to = preview.getTo() != null ? preview.getTo().getName() : transferType.getTo().getName();
    String description = getParameters().getString(ParameterKey.DESCRIPTION);
    boolean requireAuth = preview.isWouldRequireAuth();

    String feesData = "";
    if (fees != null && fees.length() > 0) {
        for (int i = 0; i < fees.length(); i++) {
            Fee fee = fees.get(i);
            feesData += fee.getName() + "<br>" + messages.amount() + ": " + fee.getFormattedAmount() + "<br>";
        }
    }

    Map<String, String> formData = new LinkedHashMap<String, String>();
    formData.put(messages.transactionType(), transferType.getName());
    formData.put(messages.to(), to);
    formData.put(messages.amount(), preview.getFormattedFinalAmount());
    formData.put(messages.description(), description);

    if (customFieldKeys != null && customFieldKeys.length() > 0) {
        for (int i = 0; i < customFieldKeys.length(); i++) {
            String displayName = customFieldKeys.get(i);
            formData.put(displayName, preview.getCustomFieldValue(displayName));
        }
    }

    formData.put(messages.appliedFees(), feesData);

    form.setData(formData);

    if (requirePassword) {
        LabelField supplyPassword = new LabelField(messages.supplyTransactionPassword());
        supplyPassword.addStyleName("transaction-password-label-field");
        passwordField = new PasswordField(messages.typeYourTransactionPasswordHere());
        password.add(supplyPassword);
        password.add(passwordField);
    }

    if (requireAuth) {
        title.setText(messages.youAreAboutToPerformTheFollowingPaymentWithAuth());
    }
    container.setVisible(true);
}

From source file:nz.co.doltech.gwtjui.core.client.js.JsArrayUtil.java

License:Apache License

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));
        }/* w w  w. j a va  2 s . com*/
    }
    return list;
}

From source file:opus.gwt.management.console.client.dashboard.DashboardPanel.java

License:Apache License

public void handleProjectInformation(String projectName) {
    applicationsFlowPanel.clear();//from  w w w .j  a  v  a 2 s. co m

    final Project project = clientFactory.getProjects().get(projectName);
    HashMap<String, Application> applicationsMap = clientFactory.getApplications();
    JsArrayString applicationsArray = project.getApps();

    if (active) {
        activeButton.setText("Deactivate project");
    } else {
        activeButton.setText("Activate project");
    }

    for (int i = 0; i < applicationsArray.length() - 1; i++) {

        final Application app = applicationsMap.get(applicationsArray.get(i));
        final FlowPanel application = new FlowPanel();
        final FocusPanel applicationLabel = new FocusPanel();

        final Label appName = new Label(app.getName());
        final Label httpLabel = new Label("HTTP");
        final Label httpsLabel = new Label("HTTPS");
        final Label settingsLabel = new Label("Settings");

        Image appIcon = new Image();

        if (app.getIconURL().split("//").length < 2) {
            appIcon = new Image(JSVarHandler.getCommunityBaseURL() + app.getIconURL());
        } else {
            appIcon = new Image(app.getIconURL());
        }

        appIcon.setSize("64px", "64px");

        application.add(appIcon);
        application.add(appName);
        application.add(httpLabel);
        application.add(httpsLabel);
        application.add(settingsLabel);
        application.setStyleName(manager.appIcon());

        applicationLabel.add(application);

        applicationLabel.addMouseOverHandler(new MouseOverHandler() {
            public void onMouseOver(MouseOverEvent event) {
                if (active) {
                    applicationLabel.setStyleName(manager.appIconActive());
                    appName.addStyleName(manager.text());
                    httpLabel.addStyleName(manager.link());
                    httpsLabel.addStyleName(manager.link());
                    settingsLabel.addStyleName(manager.link());
                }
            }
        });
        applicationLabel.addMouseOutHandler(new MouseOutHandler() {
            public void onMouseOut(MouseOutEvent event) {
                applicationLabel.setStyleName(manager.appIcon());
                appName.removeStyleName(manager.text());
                httpLabel.removeStyleName(manager.link());
                httpsLabel.removeStyleName(manager.link());
                settingsLabel.removeStyleName(manager.link());
            }
        });

        httpLabel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                if (active) {
                    Window.Location.assign(project.getURLS().get(0) + app.getAppName());
                }
            }
        });

        httpsLabel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                if (active) {
                    Window.Location.assign(project.getURLS().get(1) + app.getAppName());
                }
            }
        });

        settingsLabel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                if (active) {
                    eventBus.fireEvent(new PanelTransitionEvent(PanelTransitionEvent.TransitionTypes.SETTINGS,
                            app.getAppName()));
                }
            }
        });

        applicationsFlowPanel.add(applicationLabel);
    }

}

From source file:opus.gwt.management.console.client.dashboard.IconPanel.java

License:Apache License

public void addProjectIcon(Project project) {
    FlowPanel projectPanel = new FlowPanel();

    JsArrayString appStrings = project.getApps();
    String description = "";

    for (int i = 0; i < appStrings.length(); i++) {
        if (i == appStrings.length() - 1)
            description += appStrings.get(i);
        else/*from   ww w.  jav  a  2 s.  c  o m*/
            description += appStrings.get(i) + ", ";
    }

    final String projectName = project.getName();
    final String appNames = description;

    Image projectImg = new Image(res.projectdefaulticon2().getUrl());
    projectImg.setPixelSize(64, 64);

    projectPanel.add(projectImg);
    projectPanel.add(new Label(projectName));

    final FocusPanel testLabel = new FocusPanel();
    testLabel.add(projectPanel);
    testLabel.setStyleName(style.projectIcon());
    testLabel.addMouseOverHandler(new MouseOverHandler() {
        public void onMouseOver(MouseOverEvent event) {
            testLabel.setStyleName(style.projectIconActive());
            int[] pos = getDescPosition(testLabel);
            desc.show();
            desc.setPopupPosition(pos[0], pos[1]);
            desc.setTitle("Applications");
            desc.setText(appNames);
        }
    });
    testLabel.addMouseOutHandler(new MouseOutHandler() {
        public void onMouseOut(MouseOutEvent event) {
            testLabel.setStyleName(style.projectIcon());
            desc.hide();
        }
    });

    testLabel.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            testLabel.setStyleName(style.projectIcon());
            eventBus.fireEvent(
                    new PanelTransitionEvent(PanelTransitionEvent.TransitionTypes.DASHBOARD, projectName));
        }
    });

    projectIconsFlowPanel.add(testLabel);
    iconMap.put(project.getName(), projectIconsFlowPanel.getWidgetIndex(testLabel));
}

From source file:org.atmosphere.gwt.client.impl.IFrameCometTransport.java

License:Apache License

@SuppressWarnings("unused")
private void onMessages(JsArrayString arguments) {
    collect();//  w ww  .j  a  v  a 2  s .c om
    int length = arguments.length();
    List<Serializable> messages = new ArrayList<Serializable>(length);
    for (int i = 0; i < length; i++) {
        String message = arguments.get(i);
        switch (message.charAt(0)) {
        case ']':
            messages.add(message.substring(1));
            break;
        case '[':
        case 'R':
        case 'r':
        case 'f':
            try {
                messages.add(parse(message));
            } catch (SerializationException e) {
                listener.onError(e, true);
            }
            break;
        default:
            listener.onError(new AtmosphereClientException("Invalid message received: " + message), true);
        }
    }

    listener.onMessage(messages);
}

From source file:org.atmosphere.gwt.client.impl.StreamingProtocolTransport.java

License:Apache License

protected void onReceiving(int statusCode, String responseText, boolean connected) {
    if (statusCode != Response.SC_OK) {
        if (!connected) {
            expectingDisconnection = true;
            listener.onError(new StatusCodeException(statusCode, responseText), connected);
        }/*from   w  w w  . j  a  v  a2  s .  c om*/
    } else {
        int index = responseText.lastIndexOf(SEPARATOR);
        if (index > read) {
            List<Serializable> messages = new ArrayList<Serializable>();
            JsArrayString data = AtmosphereClient.split(responseText.substring(read, index), SEPARATOR);
            int length = data.length();
            for (int i = 0; i < length; i++) {
                if (aborted) {
                    return;
                }
                parse(data.get(i), messages);
            }
            read = index + 1;
            if (!messages.isEmpty()) {
                listener.onMessage(messages);
            }
        }

        if (!connected) {
            if (expectingDisconnection) {
                listener.onDisconnected();
            } else {
                listener.onError(new AtmosphereClientException("Unexpected disconnection"), false);
            }
        }
    }
}

From source file:org.cloudcoder.app.client.model.ChangeFromAceOnChangeEvent.java

License:Open Source License

protected static IContainsEvent convertFromLines(String aceChangeType, int sr, int sc, int er, int ec,
        JsArrayString lines, int userId, int problemId) {
    ChangeType type = fromAceChangeType(aceChangeType);
    String[] lineArr = new String[lines.length()];
    for (int i = 0; i < lineArr.length; i++) {
        lineArr[i] = lines.get(i);
    }/*from ww  w. j a  v a2  s.c om*/
    return new Change(type, sr, sc, er, ec, System.currentTimeMillis(), userId, problemId, lineArr);
}

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

License:Apache License

public static String[] toArray(JsArrayString jSArray) {
    String[] result = new String[jSArray.length()];
    for (int i = 0; i < jSArray.length(); i++) {
        result[i] = jSArray.get(i);
    }/*  w w  w.  j  a  v  a2 s  .c  o m*/
    return result;
}