コード例 #1
0
ファイル: ui.go プロジェクト: weldpua2008/deployer
func UiApplianceName(ui *gui.DialogUi, defaultName string, driver deployer.EnvDriver) (string, error) {
	var name string
	var err error

	for {
		ui.SetSize(8, len(defaultName)+10)
		ui.SetTitle("Virtual machine name")
		ui.HelpButton(true)
		ui.SetHelpLabel("Back")
		name, err = ui.Inputbox(defaultName)
		if err != nil {
			return "", err
		}
		if name != "" {
			name = strings.Replace(name, ".", "-", -1)
			if driver != nil {
				if driver.DomainExists(name) {
					ui.Output(gui.Warning, "domain "+name+" already exists.", "Press <OK> to return to menu.")
					continue
				}
			}
			break
		}
	}
	return name, nil
}