List of usage examples for com.google.gwt.core.client JsArrayString get
public final native String get(int index) ;
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);/*from w ww . j ava 2 s . co 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();//from ww w .j a v a 2 s . c o m 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))); }/* ww w. ja v a 2 s. co 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//from w ww . ja v a2s . c o m 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 w ww .j a v a2 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//from w w w .j a va 2 s. c om 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 ww .ja v a2s .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()); } } } }
From source file:org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserContextWidget.java
License:Open Source License
public CodeBrowserContextWidget(final CodeBrowserEditingTargetWidget.Styles styles) { HorizontalPanel panel = new HorizontalPanel(); captionLabel_ = new Label(); captionLabel_.addStyleName(styles.captionLabel()); panel.add(captionLabel_);// w w w . ja va2 s . com ClickHandler clickHandler = new ClickHandler() { public void onClick(ClickEvent event) { if (dropDownImage_.isVisible()) { CodeBrowserPopupMenu menu = new CodeBrowserPopupMenu(); JsArrayString methods = functionDef_.getMethods(); for (int i = 0; i < methods.length(); i++) { final String method = methods.get(i); MenuItem mi = new MenuItem(method, new Command() { @Override public void execute() { SelectionEvent.fire(CodeBrowserContextWidget.this, method); } }); mi.getElement().getStyle().setPaddingRight(20, Unit.PX); menu.addItem(mi); } menu.showRelativeTo(nameLabel_); menu.getElement().getStyle().setPaddingTop(3, Unit.PX); } } }; nameLabel_ = new Label(); nameLabel_.addStyleName(styles.menuElement()); nameLabel_.addStyleName(styles.functionName()); nameLabel_.addClickHandler(clickHandler); panel.add(nameLabel_); namespaceLabel_ = new Label(); namespaceLabel_.addStyleName(styles.menuElement()); namespaceLabel_.addStyleName(styles.functionNamespace()); namespaceLabel_.addClickHandler(clickHandler); panel.add(namespaceLabel_); dropDownImage_ = new Image(ThemeResources.INSTANCE.mediumDropDownArrow()); dropDownImage_.addStyleName(styles.menuElement()); dropDownImage_.addStyleName(styles.dropDownImage()); dropDownImage_.addClickHandler(clickHandler); panel.add(dropDownImage_); dropDownImage_.setVisible(false); initWidget(panel); }