~ubuntu-branches/debian/sid/nunit/sid

« back to all changes in this revision

Viewing changes to src/GuiComponents/UiKit/AddConfigurationDialog.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-09-16 13:43:36 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140916134336-kjxz48tty6lx2ja5
Tags: 2.6.3+dfsg-1
* [c7bd1b5] Imported Upstream version 2.6.3+dfsg
* [bcb4bf8] Move nunit-console-runner to GAC-installed libnunit2.6, 
  don't treat it as a private lib. This lib is signed, and treated 
  as a GAC lib by consumers such as MonoDevelop.
* [7f08e99] Bump version to 2.6.3 as required
* [84535eb] Refreshed patches
* [8479f61] Split package up into per-assembly packages. This makes 
  ABI tracking easier in the future, as we can meaningfully have GAC 
  policy for cases where ABI isn't truly bumped, and no policy for 
  cases where it is. For example, if nunit.framework bumps ABI but 
  nunit.core does not, previously we would need to rebuild everything 
  using NUnit, but under the new split packaging, that rebuild would 
  not be needed for apps only using nunit.core.
* [17a7dc7] Add missing nunit.mocks.dll to nunit.pc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ****************************************************************
2
 
// Copyright 2011, Charlie Poole
3
 
// This is free software licensed under the NUnit license. You may
4
 
// obtain a copy of the license at http://nunit.org
5
 
// ****************************************************************
6
 
 
7
 
using System;
8
 
using System.Drawing;
9
 
using System.Collections;
10
 
using System.ComponentModel;
11
 
using System.Windows.Forms;
12
 
using NUnit.Util;
13
 
 
14
 
namespace NUnit.UiKit
15
 
{
16
 
        /// <summary>
17
 
    /// Displays a dialog for creation of a new configuration.
18
 
    /// The dialog collects and validates the name and the
19
 
    /// name of a configuration to be copied and then adds the
20
 
    /// new configuration to the project.
21
 
    /// 
22
 
    /// A DialogResult of DialogResult.OK indicates that the
23
 
    /// configuration was added successfully.
24
 
    /// </summary>
25
 
    public class AddConfigurationDialog : NUnitFormBase
26
 
        {
27
 
                #region Instance variables
28
 
 
29
 
                private NUnitProject project;
30
 
                private string configurationName;
31
 
                private string copyConfigurationName;
32
 
 
33
 
                private System.Windows.Forms.Button okButton;
34
 
                private System.Windows.Forms.Button cancelButton;
35
 
                private System.Windows.Forms.TextBox configurationNameTextBox;
36
 
                private System.Windows.Forms.Label label1;
37
 
                private System.Windows.Forms.Label label2;
38
 
                private System.Windows.Forms.ComboBox configurationComboBox;
39
 
 
40
 
                /// <summary>
41
 
                /// Required designer variable.
42
 
                /// </summary>
43
 
                private System.ComponentModel.Container components = null;
44
 
 
45
 
                #endregion
46
 
 
47
 
                #region Construction and Disposal
48
 
 
49
 
                public AddConfigurationDialog( NUnitProject project )
50
 
                { 
51
 
                        InitializeComponent();
52
 
                        this.project = project;
53
 
                }
54
 
 
55
 
                /// <summary>
56
 
                /// Clean up any resources being used.
57
 
                /// </summary>
58
 
                protected override void Dispose( bool disposing )
59
 
                {
60
 
                        if( disposing )
61
 
                        {
62
 
                                if(components != null)
63
 
                                {
64
 
                                        components.Dispose();
65
 
                                }
66
 
                        }
67
 
                        base.Dispose( disposing );
68
 
                }
69
 
 
70
 
                #endregion
71
 
 
72
 
                #region Windows Form Designer generated code
73
 
                /// <summary>
74
 
                /// Required method for Designer support - do not modify
75
 
                /// the contents of this method with the code editor.
76
 
                /// </summary>
77
 
                private void InitializeComponent()
78
 
                {
79
 
                        this.configurationNameTextBox = new System.Windows.Forms.TextBox();
80
 
                        this.okButton = new System.Windows.Forms.Button();
81
 
                        this.cancelButton = new System.Windows.Forms.Button();
82
 
                        this.configurationComboBox = new System.Windows.Forms.ComboBox();
83
 
                        this.label1 = new System.Windows.Forms.Label();
84
 
                        this.label2 = new System.Windows.Forms.Label();
85
 
                        this.SuspendLayout();
86
 
                        // 
87
 
                        // configurationNameTextBox
88
 
                        // 
89
 
                        this.configurationNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
90
 
                                | System.Windows.Forms.AnchorStyles.Right)));
91
 
                        this.configurationNameTextBox.Location = new System.Drawing.Point(16, 24);
92
 
                        this.configurationNameTextBox.Name = "configurationNameTextBox";
93
 
                        this.configurationNameTextBox.Size = new System.Drawing.Size(254, 22);
94
 
                        this.configurationNameTextBox.TabIndex = 0;
95
 
                        this.configurationNameTextBox.Text = "";
96
 
                        // 
97
 
                        // okButton
98
 
                        // 
99
 
                        this.okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
100
 
                        this.okButton.Location = new System.Drawing.Point(50, 120);
101
 
                        this.okButton.Name = "okButton";
102
 
                        this.okButton.Size = new System.Drawing.Size(76, 23);
103
 
                        this.okButton.TabIndex = 1;
104
 
                        this.okButton.Text = "OK";
105
 
                        this.okButton.Click += new System.EventHandler(this.okButton_Click);
106
 
                        // 
107
 
                        // cancelButton
108
 
                        // 
109
 
                        this.cancelButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
110
 
                        this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
111
 
                        this.cancelButton.Location = new System.Drawing.Point(155, 120);
112
 
                        this.cancelButton.Name = "cancelButton";
113
 
                        this.cancelButton.TabIndex = 2;
114
 
                        this.cancelButton.Text = "Cancel";
115
 
                        // 
116
 
                        // configurationComboBox
117
 
                        // 
118
 
                        this.configurationComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
119
 
                                | System.Windows.Forms.AnchorStyles.Right)));
120
 
                        this.configurationComboBox.ItemHeight = 16;
121
 
                        this.configurationComboBox.Location = new System.Drawing.Point(16, 80);
122
 
                        this.configurationComboBox.Name = "configurationComboBox";
123
 
                        this.configurationComboBox.Size = new System.Drawing.Size(256, 24);
124
 
                        this.configurationComboBox.TabIndex = 3;
125
 
                        // 
126
 
                        // label1
127
 
                        // 
128
 
                        this.label1.Location = new System.Drawing.Point(16, 8);
129
 
                        this.label1.Name = "label1";
130
 
                        this.label1.Size = new System.Drawing.Size(248, 16);
131
 
                        this.label1.TabIndex = 4;
132
 
                        this.label1.Text = "Configuration Name:";
133
 
                        // 
134
 
                        // label2
135
 
                        // 
136
 
                        this.label2.Location = new System.Drawing.Point(16, 63);
137
 
                        this.label2.Name = "label2";
138
 
                        this.label2.Size = new System.Drawing.Size(240, 17);
139
 
                        this.label2.TabIndex = 5;
140
 
                        this.label2.Text = "Copy Settings From:";
141
 
                        // 
142
 
                        // AddConfigurationDialog
143
 
                        // 
144
 
                        this.AcceptButton = this.okButton;
145
 
                        this.CancelButton = this.cancelButton;
146
 
                        this.ClientSize = new System.Drawing.Size(280, 149);
147
 
                        this.Controls.Add(this.label2);
148
 
                        this.Controls.Add(this.label1);
149
 
                        this.Controls.Add(this.configurationComboBox);
150
 
                        this.Controls.Add(this.cancelButton);
151
 
                        this.Controls.Add(this.okButton);
152
 
                        this.Controls.Add(this.configurationNameTextBox);
153
 
                        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
154
 
                        this.Name = "AddConfigurationDialog";
155
 
                        this.ShowInTaskbar = false;
156
 
                        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
157
 
                        this.Text = "New Configuration";
158
 
                        this.Load += new System.EventHandler(this.ConfigurationNameDialog_Load);
159
 
                        this.ResumeLayout(false);
160
 
 
161
 
                }
162
 
                #endregion
163
 
 
164
 
                #region Properties
165
 
 
166
 
                public string ConfigurationName
167
 
                {
168
 
                        get { return configurationName; }
169
 
                }
170
 
 
171
 
                public string CopyConfigurationName
172
 
                {
173
 
                        get { return copyConfigurationName; }
174
 
                }
175
 
 
176
 
                #endregion
177
 
 
178
 
                #region Methods
179
 
 
180
 
                private void ConfigurationNameDialog_Load(object sender, System.EventArgs e)
181
 
                {
182
 
                        configurationComboBox.Items.Add( "<none>" );
183
 
                        configurationComboBox.SelectedIndex = 0;
184
 
 
185
 
                        foreach( ProjectConfig config in project.Configs )
186
 
                        {
187
 
                                int index = configurationComboBox.Items.Add( config.Name );
188
 
                                if ( config.Name == project.ActiveConfigName )
189
 
                                        configurationComboBox.SelectedIndex = index;
190
 
                        }
191
 
                }
192
 
 
193
 
                private void okButton_Click(object sender, System.EventArgs e)
194
 
                {
195
 
                        configurationName = configurationNameTextBox.Text;
196
 
 
197
 
                        if ( configurationName == string.Empty )
198
 
                        {
199
 
                MessageDisplay.Error("No configuration name provided");
200
 
                                return;
201
 
                        }
202
 
 
203
 
                        if ( project.Configs.Contains( configurationName ) )
204
 
                        {
205
 
                MessageDisplay.Error("A configuration with that name already exists");
206
 
                                return;
207
 
                        }
208
 
 
209
 
                        // ToDo: Move more of this to project
210
 
                        ProjectConfig newConfig = new ProjectConfig( configurationName );
211
 
                                
212
 
                        copyConfigurationName = null;
213
 
                        if ( configurationComboBox.SelectedIndex > 0 )
214
 
                        {               
215
 
                                copyConfigurationName = (string)configurationComboBox.SelectedItem;
216
 
                                ProjectConfig copyConfig = project.Configs[copyConfigurationName];
217
 
                                if ( copyConfig != null )
218
 
                                        foreach( string assembly in copyConfig.Assemblies )
219
 
                                                newConfig.Assemblies.Add( assembly );
220
 
                        }
221
 
 
222
 
                        project.Configs.Add( newConfig );
223
 
                        DialogResult = DialogResult.OK;
224
 
 
225
 
                        Close();
226
 
                }
227
 
 
228
 
                #endregion
229
 
        }
230
 
}
 
1
// ****************************************************************
 
2
// Copyright 2011, Charlie Poole
 
3
// This is free software licensed under the NUnit license. You may
 
4
// obtain a copy of the license at http://nunit.org
 
5
// ****************************************************************
 
6
 
 
7
using System;
 
8
using System.Drawing;
 
9
using System.Collections;
 
10
using System.ComponentModel;
 
11
using System.Windows.Forms;
 
12
using NUnit.Util;
 
13
 
 
14
namespace NUnit.UiKit
 
15
{
 
16
        /// <summary>
 
17
    /// Displays a dialog for creation of a new configuration.
 
18
    /// The dialog collects and validates the name and the
 
19
    /// name of a configuration to be copied and then adds the
 
20
    /// new configuration to the project.
 
21
    /// 
 
22
    /// A DialogResult of DialogResult.OK indicates that the
 
23
    /// configuration was added successfully.
 
24
    /// </summary>
 
25
    public class AddConfigurationDialog : NUnitFormBase
 
26
        {
 
27
                #region Instance variables
 
28
 
 
29
                private NUnitProject project;
 
30
                private string configurationName;
 
31
                private string copyConfigurationName;
 
32
 
 
33
                private System.Windows.Forms.Button okButton;
 
34
                private System.Windows.Forms.Button cancelButton;
 
35
                private System.Windows.Forms.TextBox configurationNameTextBox;
 
36
                private System.Windows.Forms.Label label1;
 
37
                private System.Windows.Forms.Label label2;
 
38
                private System.Windows.Forms.ComboBox configurationComboBox;
 
39
 
 
40
                /// <summary>
 
41
                /// Required designer variable.
 
42
                /// </summary>
 
43
                private System.ComponentModel.Container components = null;
 
44
 
 
45
                #endregion
 
46
 
 
47
                #region Construction and Disposal
 
48
 
 
49
                public AddConfigurationDialog( NUnitProject project )
 
50
                { 
 
51
                        InitializeComponent();
 
52
                        this.project = project;
 
53
                }
 
54
 
 
55
                /// <summary>
 
56
                /// Clean up any resources being used.
 
57
                /// </summary>
 
58
                protected override void Dispose( bool disposing )
 
59
                {
 
60
                        if( disposing )
 
61
                        {
 
62
                                if(components != null)
 
63
                                {
 
64
                                        components.Dispose();
 
65
                                }
 
66
                        }
 
67
                        base.Dispose( disposing );
 
68
                }
 
69
 
 
70
                #endregion
 
71
 
 
72
                #region Windows Form Designer generated code
 
73
                /// <summary>
 
74
                /// Required method for Designer support - do not modify
 
75
                /// the contents of this method with the code editor.
 
76
                /// </summary>
 
77
                private void InitializeComponent()
 
78
                {
 
79
                        this.configurationNameTextBox = new System.Windows.Forms.TextBox();
 
80
                        this.okButton = new System.Windows.Forms.Button();
 
81
                        this.cancelButton = new System.Windows.Forms.Button();
 
82
                        this.configurationComboBox = new System.Windows.Forms.ComboBox();
 
83
                        this.label1 = new System.Windows.Forms.Label();
 
84
                        this.label2 = new System.Windows.Forms.Label();
 
85
                        this.SuspendLayout();
 
86
                        // 
 
87
                        // configurationNameTextBox
 
88
                        // 
 
89
                        this.configurationNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
 
90
                                | System.Windows.Forms.AnchorStyles.Right)));
 
91
                        this.configurationNameTextBox.Location = new System.Drawing.Point(16, 24);
 
92
                        this.configurationNameTextBox.Name = "configurationNameTextBox";
 
93
                        this.configurationNameTextBox.Size = new System.Drawing.Size(254, 22);
 
94
                        this.configurationNameTextBox.TabIndex = 0;
 
95
                        this.configurationNameTextBox.Text = "";
 
96
                        // 
 
97
                        // okButton
 
98
                        // 
 
99
                        this.okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
 
100
                        this.okButton.Location = new System.Drawing.Point(50, 120);
 
101
                        this.okButton.Name = "okButton";
 
102
                        this.okButton.Size = new System.Drawing.Size(76, 23);
 
103
                        this.okButton.TabIndex = 1;
 
104
                        this.okButton.Text = "OK";
 
105
                        this.okButton.Click += new System.EventHandler(this.okButton_Click);
 
106
                        // 
 
107
                        // cancelButton
 
108
                        // 
 
109
                        this.cancelButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
 
110
                        this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
 
111
                        this.cancelButton.Location = new System.Drawing.Point(155, 120);
 
112
                        this.cancelButton.Name = "cancelButton";
 
113
                        this.cancelButton.TabIndex = 2;
 
114
                        this.cancelButton.Text = "Cancel";
 
115
                        // 
 
116
                        // configurationComboBox
 
117
                        // 
 
118
                        this.configurationComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
 
119
                                | System.Windows.Forms.AnchorStyles.Right)));
 
120
                        this.configurationComboBox.ItemHeight = 16;
 
121
                        this.configurationComboBox.Location = new System.Drawing.Point(16, 80);
 
122
                        this.configurationComboBox.Name = "configurationComboBox";
 
123
                        this.configurationComboBox.Size = new System.Drawing.Size(256, 24);
 
124
                        this.configurationComboBox.TabIndex = 3;
 
125
                        // 
 
126
                        // label1
 
127
                        // 
 
128
                        this.label1.Location = new System.Drawing.Point(16, 8);
 
129
                        this.label1.Name = "label1";
 
130
                        this.label1.Size = new System.Drawing.Size(248, 16);
 
131
                        this.label1.TabIndex = 4;
 
132
                        this.label1.Text = "Configuration Name:";
 
133
                        // 
 
134
                        // label2
 
135
                        // 
 
136
                        this.label2.Location = new System.Drawing.Point(16, 63);
 
137
                        this.label2.Name = "label2";
 
138
                        this.label2.Size = new System.Drawing.Size(240, 17);
 
139
                        this.label2.TabIndex = 5;
 
140
                        this.label2.Text = "Copy Settings From:";
 
141
                        // 
 
142
                        // AddConfigurationDialog
 
143
                        // 
 
144
                        this.AcceptButton = this.okButton;
 
145
                        this.CancelButton = this.cancelButton;
 
146
                        this.ClientSize = new System.Drawing.Size(280, 149);
 
147
                        this.Controls.Add(this.label2);
 
148
                        this.Controls.Add(this.label1);
 
149
                        this.Controls.Add(this.configurationComboBox);
 
150
                        this.Controls.Add(this.cancelButton);
 
151
                        this.Controls.Add(this.okButton);
 
152
                        this.Controls.Add(this.configurationNameTextBox);
 
153
                        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
 
154
                        this.Name = "AddConfigurationDialog";
 
155
                        this.ShowInTaskbar = false;
 
156
                        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
 
157
                        this.Text = "New Configuration";
 
158
                        this.Load += new System.EventHandler(this.ConfigurationNameDialog_Load);
 
159
                        this.ResumeLayout(false);
 
160
 
 
161
                }
 
162
                #endregion
 
163
 
 
164
                #region Properties
 
165
 
 
166
                public string ConfigurationName
 
167
                {
 
168
                        get { return configurationName; }
 
169
                }
 
170
 
 
171
                public string CopyConfigurationName
 
172
                {
 
173
                        get { return copyConfigurationName; }
 
174
                }
 
175
 
 
176
                #endregion
 
177
 
 
178
                #region Methods
 
179
 
 
180
                private void ConfigurationNameDialog_Load(object sender, System.EventArgs e)
 
181
                {
 
182
                        configurationComboBox.Items.Add( "<none>" );
 
183
                        configurationComboBox.SelectedIndex = 0;
 
184
 
 
185
                        foreach( ProjectConfig config in project.Configs )
 
186
                        {
 
187
                                int index = configurationComboBox.Items.Add( config.Name );
 
188
                                if ( config.Name == project.ActiveConfigName )
 
189
                                        configurationComboBox.SelectedIndex = index;
 
190
                        }
 
191
                }
 
192
 
 
193
                private void okButton_Click(object sender, System.EventArgs e)
 
194
                {
 
195
                        configurationName = configurationNameTextBox.Text;
 
196
 
 
197
                        if ( configurationName == string.Empty )
 
198
                        {
 
199
                MessageDisplay.Error("No configuration name provided");
 
200
                                return;
 
201
                        }
 
202
 
 
203
                        if ( project.Configs.Contains( configurationName ) )
 
204
                        {
 
205
                MessageDisplay.Error("A configuration with that name already exists");
 
206
                                return;
 
207
                        }
 
208
 
 
209
                        // ToDo: Move more of this to project
 
210
                        ProjectConfig newConfig = new ProjectConfig( configurationName );
 
211
                                
 
212
                        copyConfigurationName = null;
 
213
                        if ( configurationComboBox.SelectedIndex > 0 )
 
214
                        {               
 
215
                                copyConfigurationName = (string)configurationComboBox.SelectedItem;
 
216
                                ProjectConfig copyConfig = project.Configs[copyConfigurationName];
 
217
                                if ( copyConfig != null )
 
218
                                        foreach( string assembly in copyConfig.Assemblies )
 
219
                                                newConfig.Assemblies.Add( assembly );
 
220
                        }
 
221
 
 
222
                        project.Configs.Add( newConfig );
 
223
                        DialogResult = DialogResult.OK;
 
224
 
 
225
                        Close();
 
226
                }
 
227
 
 
228
                #endregion
 
229
        }
 
230
}