List of usage examples for com.google.gwt.core.client JsArrayString length
public final native int length() ;
From source file:org.rstudio.studio.client.shiny.ui.ShinyAppsDeploy.java
License:Open Source License
public void setAccountList(JsArrayString accounts) { accountList.clear();//from w w w . j a va 2s .c om for (int i = 0; i < accounts.length(); i++) accountList.addItem(accounts.get(i)); }
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 w w . j a va 2s . co m } }
From source file:org.rstudio.studio.client.shiny.ui.ShinyAppsDeployDialog.java
License:Open Source License
public ShinyAppsDeployDialog(ShinyAppsServerOperations server, final GlobalDisplay display, EventBus events, final String sourceDir, String sourceFile, final String lastAccount, String lastAppName, boolean isSatellite) { super(server, display, new ShinyAppsDeploy()); setText("Publish to ShinyApps"); setWidth("350px"); deployButton_ = new ThemedButton("Publish"); addCancelButton();/*from w ww . j a v a2s . com*/ addOkButton(deployButton_); sourceDir_ = sourceDir; sourceFile_ = sourceFile; events_ = events; lastAppName_ = lastAppName; isSatellite_ = isSatellite; defaultAccount_ = lastAccount; launchCheck_ = new CheckBox("Launch browser"); launchCheck_.setValue(true); launchCheck_.setStyleName(contents_.getStyle().launchCheck()); addLeftWidget(launchCheck_); contents_.setSourceDir(sourceDir); deployButton_.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { onDeploy(); } }); // don't enable the deploy button until we're done getting the file list deployButton_.setEnabled(false); indicator_ = addProgressIndicator(false); // Get the files to be deployed server_.getDeploymentFiles(sourceDir, new ServerRequestCallback<ShinyAppsDeploymentFiles>() { @Override public void onResponseReceived(ShinyAppsDeploymentFiles files) { if (files.getDirSize() > files.getMaxSize()) { hide(); display_.showErrorMessage("Directory Too Large", "The directory to be deployed (" + sourceDir + ") " + "exceeds the maximum deployment size, which is " + StringUtil.formatFileSize(files.getMaxSize()) + "." + " Consider creating a new directory containing " + "only the content you wish to deploy."); } else { contents_.setFileList(files.getDirList()); deployButton_.setEnabled(true); } } @Override public void onError(ServerError error) { // we'll just show an empty list in the failure case } }); // Get the deployments of this directory from any account (should be fast, // since this information is stored locally in the directory). server_.getShinyAppsDeployments(sourceDir, new ServerRequestCallback<JsArray<ShinyAppsDeploymentRecord>>() { @Override public void onResponseReceived(JsArray<ShinyAppsDeploymentRecord> records) { processDeploymentRecords(records); if (records.length() == 1 && defaultAccount_ == null) { defaultAccount_ = records.get(0).getAccount(); contents_.setDefaultAccount(defaultAccount_); } } @Override public void onError(ServerError error) { // If an error occurs we won't have any local deployment records, // but the user can still create new deployments. } }); server_.getShinyAppsAccountList(new ServerRequestCallback<JsArrayString>() { @Override public void onResponseReceived(JsArrayString accounts) { if (accounts.length() == 0) { // The user has no accounts connected--hide ourselves and // ask the user to connect an account before we continue. hide(); ShinyAppsConnectAccountDialog dialog = new ShinyAppsConnectAccountDialog(server_, display_); dialog.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { onConnectAccountFinished(); } }); dialog.showModal(); } else { contents_.setAccountList(accounts); if (defaultAccount_ != null) contents_.setDefaultAccount(defaultAccount_); updateApplicationList(); } } @Override public void onError(ServerError error) { display_.showErrorMessage("Error retrieving ShinyApps accounts", error.getMessage()); closeDialog(); } }); // Update the list of applications when the account is changed contents_.addAccountChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { updateApplicationList(); } }); // Update app info when the application is changed contents_.addAppChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { updateApplicationInfo(); } }); contents_.setOnDeployDisabled(new Command() { @Override public void execute() { deployButton_.setEnabled(false); } }); contents_.setOnDeployEnabled(new Command() { @Override public void execute() { deployButton_.setEnabled(true); } }); }
From source file:org.rstudio.studio.client.shiny.ui.ShinyAppsDeployDialog.java
License:Open Source License
private void onConnectAccountFinished() { server_.getShinyAppsAccountList(new ServerRequestCallback<JsArrayString>() { @Override//from www. ja va 2s .c om 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));/* ww w .j a v a2 s . co m*/ }
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));//w w w . java 2 s .co m return list; }
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;//from ww w .j a va 2s . co 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
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));//from www . j ava 2 s . c o m 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]); }//from w w w. j av a2s.co m } }
From source file:org.rstudio.studio.client.workbench.ui.PaneConfig.java
License:Open Source License
public final boolean validateAndAutoCorrect() { JsArrayString panes = getPanes();//from www .j a va 2s . co m if (panes == null) return false; if (!sameElements(panes, new String[] { "Source", "Console", "TabSet1", "TabSet2" })) return false; JsArrayString ts1 = getTabSet1(); JsArrayString ts2 = getTabSet2(); if (ts1.length() == 0 || ts2.length() == 0) return false; // Replace any obsoleted tabs in the config replaceObsoleteTabs(ts1); replaceObsoleteTabs(ts2); // If any of these tabs are missing, then they can be added Set<String> addableTabs = makeSet(getAddableTabs()); // If any of these tabs are missing, then the whole config is invalid Set<String> baseTabs = makeSet(getAllTabs()); baseTabs.removeAll(addableTabs); for (String tab : JsUtil.asIterable(concat(ts1, ts2))) { if (!baseTabs.remove(tab) && !addableTabs.remove(tab)) return false; // unknown tab } // If any baseTabs are still present, they weren't part of the tabsets if (baseTabs.size() > 0) return false; // Were any addable tabs missing? Add them the appropriate tabset // (Iterate over original array instead of addableTabs set so that order // is well-defined) for (String tab : getAddableTabs()) if (addableTabs.contains(tab)) if (tab.equals("Viewer")) ts2.push(tab); else ts1.push(tab); // These tabs can be hidden sometimes; they can't stand alone in a tabset Set<String> hideableTabs = makeSet(getHideableTabs()); if (isSubset(hideableTabs, JsUtil.asIterable(ts1)) || isSubset(hideableTabs, JsUtil.asIterable(ts2))) { return false; } return true; }