Search in sources :

Example 1 with RSConnectAccount

use of org.rstudio.studio.client.rsconnect.model.RSConnectAccount in project rstudio by rstudio.

the class RSConnectDeploy method initialize.

@Inject
public void initialize(RSConnectServerOperations server, RSAccountConnector connector, GlobalDisplay display, UIPrefs prefs) {
    server_ = server;
    connector_ = connector;
    display_ = display;
    prefs_ = prefs;
    accountList_ = new RSConnectAccountList(server_, display_, false, !asStatic_);
    appName_ = new AppNameTextbox(this);
    // when the account list finishes populating, select the account from the
    // previous deployment if we have one
    accountList_.setOnRefreshCompleted(new Operation() {

        @Override
        public void execute() {
            if (fromPrevious_ != null) {
                // when re-deploying, select the account used the last time 
                // around
                accountList_.selectAccount(fromPrevious_.getAccount());
            } else {
                // when doing a first-time publish, select the account the user
                // prefers (currently this just tracks the last account used)
                RSConnectAccount preferred = prefs_.preferredPublishAccount().getGlobalValue();
                if (preferred != null) {
                    accountList_.selectAccount(preferred);
                }
                // validate the app name now that we have an account selected
                appName_.validateAppName();
            }
        }
    });
    // when the user selects a different account, show the appropriate UI
    addAccountChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent arg0) {
            if (fromPrevious_ != null) {
                boolean existing = accountList_.getSelectedAccount().equals(fromPrevious_.getAccount());
                appInfoPanel_.setVisible(existing);
                newAppPanel_.setVisible(!existing);
                // validate name if necessary
                if (existing && onDeployEnabled_ != null)
                    onDeployEnabled_.execute();
                else if (!existing)
                    appName_.validateAppName();
            } else {
                // re-validate app name as different accounts have different 
                // name restrictions
                appName_.validateAppName();
            }
        }
    });
}
Also used : RSConnectAccount(org.rstudio.studio.client.rsconnect.model.RSConnectAccount) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) Operation(org.rstudio.core.client.widget.Operation) Inject(com.google.inject.Inject)

Example 2 with RSConnectAccount

use of org.rstudio.studio.client.rsconnect.model.RSConnectAccount in project rstudio by rstudio.

the class PublishingPreferencesPane method onDisconnect.

private void onDisconnect() {
    final RSConnectAccount account = accountList_.getSelectedAccount();
    if (account == null) {
        display_.showErrorMessage("Error Disconnecting Account", "Please select an account to disconnect.");
        return;
    }
    display_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Confirm Remove Account", "Are you sure you want to disconnect the '" + account.getName() + "' account on '" + account.getServer() + "'" + "? This won't delete the account on the server.", false, new Operation() {

        @Override
        public void execute() {
            onConfirmDisconnect(account);
        }
    }, null, null, "Disconnect Account", "Cancel", false);
}
Also used : RSConnectAccount(org.rstudio.studio.client.rsconnect.model.RSConnectAccount) Operation(org.rstudio.core.client.widget.Operation)

Aggregations

Operation (org.rstudio.core.client.widget.Operation)2 RSConnectAccount (org.rstudio.studio.client.rsconnect.model.RSConnectAccount)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 Inject (com.google.inject.Inject)1 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)1