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.rstudio.studio.client.shiny.ui.ShinyAppsDeploy.java

License:Open Source License

public void setFileList(JsArrayString files) {
    for (int i = 0; i < files.length(); i++) {
        Label fileLabel = new Label(files.get(i));
        fileListPanel_.add(fileLabel);/*from w  ww .j a  v a2 s .  c  o  m*/
    }
}

From source file:org.rstudio.studio.client.shiny.ui.ShinyAppsDeployDialog.java

License:Open Source License

private void onConnectAccountFinished() {
    server_.getShinyAppsAccountList(new ServerRequestCallback<JsArrayString>() {
        @Override// www  . j  ava  2  s . co m
        public void onResponseReceived(JsArrayString accounts) {
            if (accounts.length() == 0) {
                // The user didn't successfully connect an account--just close 
                // ourselves
                closeDialog();
            } else {
                // We have an account, show it and re-display ourselves
                contents_.setAccountList(accounts);
                contents_.setDefaultAccount(accounts.get(0));
                updateApplicationList();
                showModal();
            }
        }

        @Override
        public void onError(ServerError error) {
            display_.showErrorMessage("Error retrieving ShinyApps accounts", error.getMessage());
            closeDialog();
        }
    });
}

From source file:org.rstudio.studio.client.workbench.events.ListChangedEvent.java

License:Open Source License

public ListChangedEvent(JsObject eventData) {
    name_ = eventData.getString("name");

    JsArrayString list = eventData.getObject("list");
    list_ = new ArrayList<String>();
    for (int i = 0; i < list.length(); i++)
        list_.add(list.get(i));
}

From source file:org.rstudio.studio.client.workbench.model.WorkbenchLists.java

License:Open Source License

private ArrayList<String> convertList(JsArrayString jsList) {
    ArrayList<String> list = new ArrayList<String>();
    for (int i = 0; i < jsList.length(); i++)
        list.add(jsList.get(i));
    return list;/*w ww  .j av  a 2s  .c  o m*/
}

From source file:org.rstudio.studio.client.workbench.MRUList.java

License:Open Source License

public MRUList(Commands commands, Session session, String clientStateGroup, AppCommand[] mruCmds,
        AppCommand clearCommand, boolean includeExt, OperationWithInput<String> operation) {
    commands_ = commands;//  w w w  .  java2s .c o m
    session_ = session;
    mruCmds_ = mruCmds;
    includeExt_ = includeExt;
    operation_ = operation;

    for (int i = 0; i < mruCmds_.length; i++)
        bindCommand(i);

    clearCommand.addHandler(new CommandHandler() {
        public void onCommand(AppCommand command) {
            clear();
        }
    });

    new JSObjectStateValue(clientStateGroup, "entries", ClientState.PERSISTENT,
            session.getSessionInfo().getClientState(), false) {
        @Override
        protected void onInit(JsObject value) {
            if (value != null) {
                JsArrayString array = value.cast();
                for (int i = 0; i < array.length(); i++) {
                    mruEntries_.add(array.get(i));
                }
            }
            updateCommands(false);
            dirty_ = false;
        }

        @Override
        protected JsObject getValue() {
            JsArrayString value = JsArrayString.createArray().cast();
            for (String entry : mruEntries_)
                value.push(entry);
            return value.cast();
        }

        @Override
        protected boolean hasChanged() {
            if (dirty_) {
                dirty_ = false;
                return true;
            }
            return false;
        }
    };
}

From source file:org.rstudio.studio.client.workbench.prefs.views.PaneLayoutPreferencesPane.java

License:Open Source License

@Inject
public PaneLayoutPreferencesPane(PreferencesDialogResources res, UIPrefs uiPrefs) {
    res_ = res;/*  www  .j  a  va  2  s.co  m*/
    uiPrefs_ = uiPrefs;

    add(new Label("Choose the layout of the panes in RStudio by selecting from the controls in each quadrant.",
            true));

    String[] allPanes = PaneConfig.getAllPanes();

    leftTop_ = new ListBox();
    leftBottom_ = new ListBox();
    rightTop_ = new ListBox();
    rightBottom_ = new ListBox();
    allPanes_ = new ListBox[] { leftTop_, leftBottom_, rightTop_, rightBottom_ };
    for (ListBox lb : allPanes_) {
        for (String value : allPanes)
            lb.addItem(value);
    }

    PaneConfig value = uiPrefs.paneConfig().getGlobalValue();
    if (value == null || !value.validateAndAutoCorrect())
        uiPrefs.paneConfig().setGlobalValue(PaneConfig.createDefault(), false);

    JsArrayString origPanes = uiPrefs.paneConfig().getGlobalValue().getPanes();
    for (int i = 0; i < 4; i++) {
        boolean success = selectByValue(allPanes_[i], origPanes.get(i));
        if (!success) {
            Debug.log("Bad config! Falling back to a reasonable default");
            leftTop_.setSelectedIndex(0);
            leftBottom_.setSelectedIndex(1);
            rightTop_.setSelectedIndex(2);
            rightBottom_.setSelectedIndex(3);
            break;
        }
    }

    new ExclusiveSelectionMaintainer(allPanes_);

    for (ListBox lb : allPanes_)
        lb.addChangeHandler(new ChangeHandler() {
            public void onChange(ChangeEvent event) {
                dirty_ = true;
            }
        });

    Grid grid = new Grid(2, 2);
    grid.addStyleName(res.styles().paneLayoutTable());
    grid.setCellSpacing(8);
    grid.setCellPadding(6);
    grid.setWidget(0, 0, leftTopPanel_ = createPane(leftTop_));
    grid.setWidget(1, 0, leftBottomPanel_ = createPane(leftBottom_));
    grid.setWidget(0, 1, rightTopPanel_ = createPane(rightTop_));
    grid.setWidget(1, 1, rightBottomPanel_ = createPane(rightBottom_));
    for (int row = 0; row < 2; row++)
        for (int col = 0; col < 2; col++)
            grid.getCellFormatter().setStyleName(row, col, res.styles().paneLayoutTable());
    add(grid);

    allPanePanels_ = new VerticalPanel[] { leftTopPanel_, leftBottomPanel_, rightTopPanel_, rightBottomPanel_ };

    tabSet1ModuleList_ = new ModuleList();
    tabSet1ModuleList_.setValue(toArrayList(uiPrefs.paneConfig().getGlobalValue().getTabSet1()));
    tabSet2ModuleList_ = new ModuleList();
    tabSet2ModuleList_.setValue(toArrayList(uiPrefs.paneConfig().getGlobalValue().getTabSet2()));

    ValueChangeHandler<ArrayList<Boolean>> vch = new ValueChangeHandler<ArrayList<Boolean>>() {
        public void onValueChange(ValueChangeEvent<ArrayList<Boolean>> e) {
            dirty_ = true;

            ModuleList source = (ModuleList) e.getSource();
            ModuleList other = (source == tabSet1ModuleList_) ? tabSet2ModuleList_ : tabSet1ModuleList_;

            if (!PaneConfig.isValidConfig(source.getValue())) {
                ArrayList<Boolean> indices = source.getSelectedIndices();
                ArrayList<Boolean> otherIndices = other.getSelectedIndices();
                for (int i = 0; i < indices.size(); i++) {
                    indices.set(i, !otherIndices.get(i));
                }
                source.setSelectedIndices(indices);
            } else {
                ArrayList<Boolean> indices = source.getSelectedIndices();
                ArrayList<Boolean> otherIndices = new ArrayList<Boolean>();
                for (Boolean b : indices)
                    otherIndices.add(!b);
                other.setSelectedIndices(otherIndices);

                updateTabSetLabels();
            }
        }
    };
    tabSet1ModuleList_.addValueChangeHandler(vch);
    tabSet2ModuleList_.addValueChangeHandler(vch);

    updateTabSetPositions();
    updateTabSetLabels();
}

From source file:org.rstudio.studio.client.workbench.prefs.views.PaneLayoutPreferencesPane.java

License:Open Source License

private ArrayList<String> toArrayList(JsArrayString strings) {
    ArrayList<String> results = new ArrayList<String>();
    for (int i = 0; i < strings.length(); i++)
        results.add(strings.get(i));
    return results;
}

From source file:org.rstudio.studio.client.workbench.ui.PaneConfig.java

License:Open Source License

public static void replaceObsoleteTabs(JsArrayString tabs) {
    for (int idx = 0; idx < tabs.length(); idx++) {
        if (indexOfReplacedTab(tabs.get(idx)) >= 0) {
            tabs.set(idx, getReplacementTabs()[idx]);
        }/* w w  w.  j a  v  a2 s.  co m*/
    }
}

From source file:org.rstudio.studio.client.workbench.ui.PaneConfig.java

License:Open Source License

private boolean sameElements(JsArrayString a, String[] b) {
    if (a.length() != b.length)
        return false;

    ArrayList<String> a1 = new ArrayList<String>();
    for (int i = 0; i < a.length(); i++)
        a1.add(a.get(i));
    Collections.sort(a1);//from w w  w  .  jav a  2  s .  com

    Arrays.sort(b);

    for (int i = 0; i < b.length; i++)
        if (!a1.get(i).equals(b[i]))
            return false;

    return true;
}

From source file:org.rstudio.studio.client.workbench.ui.PaneConfig.java

License:Open Source License

private JsArrayString concat(JsArrayString a, JsArrayString b) {
    JsArrayString ab = createArray().cast();
    for (int i = 0; i < a.length(); i++)
        ab.push(a.get(i));
    for (int i = 0; i < b.length(); i++)
        ab.push(b.get(i));// ww  w  .j av  a  2 s  .  co m
    return ab;
}