Search in sources :

Example 1 with RSConnectAppName

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

the class AppNameTextbox method validateAppName.

public void validateAppName() {
    if (!host_.supportsTitle()) {
        String app = appTitle_.getText();
        RegExp validReg = RegExp.compile("^[A-Za-z0-9_-]{4,63}$");
        validTitle_ = validReg.test(app);
        setAppNameValid(validTitle_);
        if (validTitle_)
            name_ = app;
        else
            error_.setText("The title must contain 3 - 64 alphanumeric " + "characters.");
        return;
    }
    // if we don't have enough characters, bail out early 
    final String title = appTitle_.getText().trim();
    if (title.length() < 3) {
        validTitle_ = false;
        // if we also don't have focus in the box, show an error
        if (DomUtils.getActiveElement() != appTitle_.getElement()) {
            setAppNameValid(false);
            error_.setText("The title must contain at least 3 characters.");
        }
        return;
    }
    host_.generateAppName(title, new CommandWithArg<RSConnectAppName>() {

        @Override
        public void execute(RSConnectAppName arg) {
            name_ = arg.name();
            validTitle_ = arg.valid();
            error_.setText(arg.error());
            setAppNameValid(arg.valid());
        }
    });
}
Also used : RegExp(com.google.gwt.regexp.shared.RegExp) RSConnectAppName(org.rstudio.studio.client.rsconnect.model.RSConnectAppName)

Aggregations

RegExp (com.google.gwt.regexp.shared.RegExp)1 RSConnectAppName (org.rstudio.studio.client.rsconnect.model.RSConnectAppName)1