Example #1
0
        protected override void CreateChildControls()
        {
            this.txtArtifactName = new ValidatingTextBox {
                Required = true
            };
            this.txtBranchName = new ValidatingTextBox()
            {
                DefaultText = "Default"
            };
            this.chkArtifactNameLocked = new CheckBox {
                Text = "Allow selection at build time"
            };
            this.chkBranchNameLocked = new CheckBox {
                Text = "Allow selection at build time"
            };

            this.ddlBuildConfigurationId = new SelectBuildConfigurationPicker()
            {
                ID = "ddlBuildConfigurationId"
            };
            this.ddlBuildConfigurationId.ExternalInit =
                () =>
            {
                int?configurerId = this.TryGetConfigurerId();
                this.ddlBuildConfigurationId.FillItems(TeamCityConfigurer.GetConfigurer(configurerId: configurerId));
            };

            this.ddlBuildNumber = new SelectList();
            this.ddlBuildNumber.Items.Add(new SelectListItem("Select at build import time", ""));
            this.ddlBuildNumber.Items.Add(new SelectListItem("Always use last successful build", "lastSuccessful"));
            this.ddlBuildNumber.Items.Add(new SelectListItem("Always use last finished build", "lastFinished"));
            this.ddlBuildNumber.Items.Add(new SelectListItem("Always use last pinned build", "lastPinned"));

            this.Controls.Add(
                new SlimFormField("Build configuration:", this.ddlBuildConfigurationId),
                new SlimFormField("TeamCity build number:", this.ddlBuildNumber),
                new SlimFormField("Artifact name:", new Div(this.txtArtifactName), new Div(this.chkArtifactNameLocked))
            {
                HelpText = "The name of artifact, for example: \"ideaIC-118.SNAPSHOT.win.zip\"."
            },
                new SlimFormField("Branch name:", new Div(this.txtBranchName), new Div(this.chkBranchNameLocked))
            {
                HelpText = "The branch used to get the artifact, typically used in conjunction with predefined constant build numbers."
            }
                );
        }
        private void CreateSelectArtifactControls()
        {
            var ctlSelectBuildConfigurationPicker = new SelectBuildConfigurationPicker
            {
                Width = 350
            };
            ctlSelectBuildConfigurationPicker.PreRender += (s, e) => ctlSelectBuildConfigurationPicker.FillItems(null);

            var txtArtifactName = new ValidatingTextBox
            {
                Required = true,
                Width = 350
            };

            this.wizardSteps.TeamCityBuild.Controls.Add(
                new FormFieldGroup(
                    "Build Configuration",
                    "This is the build configuration where an artifact will be retrieved from. The last successful build will be used for the wizard, but you can change this later.",
                    false,
                    new StandardFormField("Build Configuration:", ctlSelectBuildConfigurationPicker)
                ),
                new FormFieldGroup(
                    "Artifact Name",
                    "The name of artifact, for example: <br />\"ideaIC-118.SNAPSHOT.win.zip\". The wizard assumes this artifact is a zip file, but you can change this later.",
                    false,
                    new StandardFormField("Artifact Name:", txtArtifactName)
                )
            );
            this.WizardStepChange += (s, e) =>
            {
                if (e.CurrentStep != this.wizardSteps.TeamCityBuild) return;
                this.BuildConfigurationId = ctlSelectBuildConfigurationPicker.SelectedValue;
                this.BuildConfigurationName = ctlSelectBuildConfigurationPicker.Items.Cast<ListItem>()
                    .Where(li => li.Selected)
                    .Select(li => li.Text)
                    .FirstOrDefault();
                this.ArtifactName = txtArtifactName.Text;
            };
        }