List of usage examples for com.google.gwt.core.client JsArrayString length
public final native int length() ;
From source file:org.rstudio.studio.client.workbench.views.console.shell.assist.CompletionRequester.java
License:Open Source License
private void addFunctionArgumentCompletions(String token, ArrayList<QualifiedName> completions) { AceEditor editor = (AceEditor) editor_; if (editor != null) { Position cursorPosition = editor.getSession().getSelection().getCursor(); CodeModel codeModel = editor.getSession().getMode().getRCodeModel(); // Try to see if we can find a function name TokenCursor cursor = codeModel.getTokenCursor(); // NOTE: This can fail if the document is empty if (!cursor.moveToPosition(cursorPosition)) return; String tokenLower = token.toLowerCase(); if (cursor.currentValue() == "(" || cursor.findOpeningBracket("(", false)) { if (cursor.moveToPreviousToken()) { // Check to see if this really is the name of a function JsArray<ScopeFunction> functionsInScope = codeModel.getAllFunctionScopes(); String tokenName = cursor.currentValue(); for (int i = 0; i < functionsInScope.length(); i++) { ScopeFunction rFunction = functionsInScope.get(i); String fnName = rFunction.getFunctionName(); if (tokenName == fnName) { JsArrayString args = rFunction.getFunctionArgs(); for (int j = 0; j < args.length(); j++) { String arg = args.get(j); if (arg.toLowerCase().startsWith(tokenLower)) completions.add(new QualifiedName(args.get(j) + " = ", fnName, false, RCompletionType.CONTEXT)); }/*www . j av a 2 s. co m*/ } } } } } }
From source file:org.rstudio.studio.client.workbench.views.console.shell.Shell.java
License:Open Source License
private void setHistory(JsArrayString history) { ArrayList<String> historyList = new ArrayList<String>(history.length()); for (int i = 0; i < history.length(); i++) historyList.add(history.get(i)); historyManager_.setHistory(historyList); browseHistoryManager_.resetPosition(); }
From source file:org.rstudio.studio.client.workbench.views.environment.dataimport.ImportFileSettingsDialog.java
License:Open Source License
private void populateOutput(DataPreviewResult result) { JsArray<JsObject> output = result.getOutput(); JsArrayString names = result.getOutputNames(); int rows = output.length(); int cols = names.length(); Grid grid = new Grid(rows + 1, cols); grid.setCellPadding(0);/*ww w.j ava 2 s . c o m*/ grid.setCellSpacing(0); grid.getRowFormatter().addStyleName(0, styles_.header()); for (int col = 0; col < cols; col++) grid.setText(0, col, names.get(col)); for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { String val = output.get(row).getString(names.get(col), true); if (val == null) val = "NA"; grid.setText(row + 1, col, val); } } outputPanel_.setWidget(grid); }
From source file:org.rstudio.studio.client.workbench.views.environment.EnvironmentPane.java
License:Open Source License
@Override public void setExpandedObjects(JsArrayString objects) { objects_.setExpandedObjects(objects); expandedObjects_.clear();/* w w w . j a v a2 s .c om*/ for (int idx = 0; idx < objects.length(); idx++) { expandedObjects_.add(objects.get(idx)); } }
From source file:org.rstudio.studio.client.workbench.views.help.search.HelpSearch.java
License:Open Source License
private void fireShowHelpEvent(String topic) { server_.search(topic, new SimpleRequestCallback<JsArrayString>() { public void onResponseReceived(JsArrayString url) { if (url != null && url.length() > 0) eventBus_.fireEvent(new ShowHelpEvent(url.get(0))); }//w w w .ja v a 2 s .c o m }); }
From source file:org.rstudio.studio.client.workbench.views.help.search.HelpSearchOracle.java
License:Open Source License
@Override public void requestSuggestions(final Request request, final Callback callback) { String query = request.getQuery(); server_.suggestTopics(query, new ServerRequestCallback<JsArrayString>() { @Override/* w ww . j av a2 s . com*/ public void onError(ServerError error) { } @Override public void onResponseReceived(JsArrayString suggestions) { int maxCount = Math.min(suggestions.length(), request.getLimit()); ArrayList<SearchSuggestion> results = new ArrayList<SearchSuggestion>(); for (int i = 0; i < maxCount; i++) results.add(new SearchSuggestion(suggestions.get(i))); callback.onSuggestionsReady(request, new Response(results)); } }); ; }
From source file:org.rstudio.studio.client.workbench.views.history.History.java
License:Open Source License
private ArrayList<HistoryEntry> toRecentCommandsList(JsArrayString jsCommands) { ArrayList<HistoryEntry> commands = new ArrayList<HistoryEntry>(); for (int i = 0; i < jsCommands.length(); i++) commands.add(HistoryEntry.create(i, jsCommands.get(i))); return commands; }
From source file:org.rstudio.studio.client.workbench.views.packages.ui.InstallPackageDialog.java
License:Open Source License
@Override protected Widget createMainWidget() { // vertical panel VerticalPanel mainPanel = new VerticalPanel(); mainPanel.setSpacing(2);/*from ww w . j a v a 2 s . c om*/ mainPanel.setStylePrimaryName(RESOURCES.styles().mainWidget()); // source type reposCaption_ = new CaptionWithHelp("Install from:", "Configuring Repositories", "configuring_repositories"); reposCaption_.setIncludeVersionInfo(false); reposCaption_.setWidth("100%"); mainPanel.add(reposCaption_); packageSourceListBox_ = new ListBox(); packageSourceListBox_.setStylePrimaryName(RESOURCES.styles().packageSourceListBox()); packageSourceListBox_.addStyleName(RESOURCES.styles().extraBottomPad()); JsArrayString repos = installContext_.selectedRepositoryNames(); if (repos.length() == 1) { packageSourceListBox_.addItem("Repository (" + repos.get(0) + ")"); } else { StringBuilder reposItem = new StringBuilder(); reposItem.append("Repository ("); for (int i = 0; i < repos.length(); i++) { if (i != 0) reposItem.append(", "); reposItem.append(repos.get(i)); } reposItem.append(")"); packageSourceListBox_.addItem(reposItem.toString()); } packageSourceListBox_.addItem("Package Archive File (" + installContext_.packageArchiveExtension() + ")"); mainPanel.add(packageSourceListBox_); // source panel container sourcePanel_ = new SimplePanel(); sourcePanel_.setStylePrimaryName(RESOURCES.styles().packageSourcePanel()); // repos source panel reposSourcePanel_ = new FlowPanel(); Label packagesLabel = new Label("Packages (separate multiple with space or comma):"); packagesLabel.setStylePrimaryName(RESOURCES.styles().packagesLabel()); reposSourcePanel_.add(packagesLabel); packagesTextBox_ = new MultipleItemSuggestTextBox(); packagesSuggestBox_ = new SuggestBox(new PackageOracle(), packagesTextBox_); packagesSuggestBox_.setWidth("100%"); packagesSuggestBox_.setLimit(20); packagesSuggestBox_.addStyleName(RESOURCES.styles().extraBottomPad()); reposSourcePanel_.add(packagesSuggestBox_); sourcePanel_.setWidget(reposSourcePanel_); mainPanel.add(sourcePanel_); // archive source panel packageArchiveFile_ = new TextBoxWithButton("Package archive:", "Browse...", browseForArchiveClickHandler_); // create check box here because manageUIState accesses it installDependenciesCheckBox_ = new CheckBox(); if (defaultInstallOptions_.getInstallFromRepository()) packageSourceListBox_.setSelectedIndex(0); else packageSourceListBox_.setSelectedIndex(1); manageUIState(); packageSourceListBox_.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { manageUIState(); if (!installFromRepository()) packageArchiveFile_.click(); } }); mainPanel.add(new Label("Install to Library:")); // library list box libraryListBox_ = new ListBox(); libraryListBox_.setWidth("100%"); libraryListBox_.addStyleName(RESOURCES.styles().extraBottomPad()); JsArrayString libPaths = installContext_.getWriteableLibraryPaths(); int selectedIndex = 0; for (int i = 0; i < libPaths.length(); i++) { String libPath = libPaths.get(i); if (!installContext_.isDevModeOn()) { if (defaultInstallOptions_.getLibraryPath().equals(libPath)) selectedIndex = i; } if (libPath.equals(installContext_.getDefaultLibraryPath())) libPath = libPath + " [Default]"; libraryListBox_.addItem(libPath); } libraryListBox_.setSelectedIndex(selectedIndex); mainPanel.add(libraryListBox_); // install dependencies check box installDependenciesCheckBox_.addStyleName(RESOURCES.styles().installDependenciesCheckBox()); installDependenciesCheckBox_.setText("Install dependencies"); installDependenciesCheckBox_.setValue(defaultInstallOptions_.getInstallDependencies()); mainPanel.add(installDependenciesCheckBox_); mainPanel.add(new HTML("<br/>")); return mainPanel; }
From source file:org.rstudio.studio.client.workbench.views.plots.ui.manipulator.ManipulatorControlPicker.java
License:Open Source License
public ManipulatorControlPicker(String variable, String value, Manipulator.Picker picker, final ManipulatorChangedHandler changedHandler) { super(variable, picker, changedHandler); // get manipulator styles ManipulatorStyles styles = ManipulatorResources.INSTANCE.manipulatorStyles(); // main control HorizontalPanel panel = new HorizontalPanel(); panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); // caption//www . j av a 2 s . com Label captionLabel = new Label(); captionLabel.setStyleName(styles.captionLabel()); captionLabel.setText(getLabel() + ":"); panel.add(captionLabel); // picker listBox_ = new ListBox(); listBox_.setVisibleItemCount(1); JsArrayString choices = picker.getChoices(); int selectedIndex = 0; for (int i = 0; i < choices.length(); i++) { String choice = choices.get(i); listBox_.addItem(choice); if (choice.equals(value)) selectedIndex = i; } listBox_.setSelectedIndex(selectedIndex); listBox_.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { ManipulatorControlPicker.this .onValueChanged(new JSONString(listBox_.getItemText(listBox_.getSelectedIndex()))); } }); panel.add(listBox_); initWidget(panel); addControlStyle(styles.picker()); }
From source file:org.rstudio.studio.client.workbench.views.plots.ui.manipulator.ManipulatorPopupPanel.java
License:Open Source License
public void update(Manipulator manipulator) { mainPanel_.clear();// w w w . ja va 2s. c om if (manipulator != null && manipulator.getVariables() != null) { // iterate over the variables JsArrayString variables = manipulator.getVariables(); for (int i = 0; i < variables.length(); i++) { String variable = variables.get(i); try { ManipulatorControl addedControl = null; Manipulator.Control control = manipulator.getControl(variable); switch (control.getType()) { case Manipulator.Control.SLIDER: Manipulator.Slider slider = control.cast(); addedControl = addSliderControl(variable, manipulator.getDoubleValue(variable), slider); break; case Manipulator.Control.PICKER: Manipulator.Picker picker = control.cast(); addedControl = addPickerControl(variable, manipulator.getStringValue(variable), picker); break; case Manipulator.Control.CHECKBOX: Manipulator.CheckBox checkBox = control.cast(); addedControl = addCheckBoxControl(variable, manipulator.getBooleanValue(variable), checkBox); break; case Manipulator.Control.BUTTON: Manipulator.Button button = control.cast(); addedControl = addButtonControl(variable, button); break; } // save reference to first control (for setting focus) if (i == 0) firstControl_ = addedControl; } catch (Throwable e) { Debug.log("WARNING: exception occurred during addition of " + "variable " + variable + ", " + e.getMessage()); } } } }