Subversion Repositories DevTools

Rev

Rev 2112 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2094 ghuddy 1
using System;
2
using System.Drawing;
3
using System.Collections;
4
using System.ComponentModel;
5
using System.Windows.Forms;
6
 
7
namespace EA_DocGen
8
{
9
	/// <summary>
10
	/// Summary description for EA_DocGenOptionsForm.
11
	/// </summary>
12
	public class EA_DocGenOptionsForm : System.Windows.Forms.Form
13
	{
14
      private System.Windows.Forms.Button buttonCancel;
15
      private System.Windows.Forms.Button buttonOK;
16
      private System.Windows.Forms.GroupBox groupBoxElementTypes;
17
      private System.Windows.Forms.Button button_ET_All;
18
      private System.Windows.Forms.Button button_ET_None;
19
      private System.Windows.Forms.CheckedListBox checkedListBox_ETs;
20
      private System.Windows.Forms.Button buttonDefault;
2116 ghuddy 21
      private System.Windows.Forms.TreeView treeView_BooleanOptions;
22
      private System.Windows.Forms.GroupBox groupBox1;
2094 ghuddy 23
		/// <summary>
24
		/// Required designer variable.
25
		/// </summary>
26
		private System.ComponentModel.Container components = null;
27
 
28
		public EA_DocGenOptionsForm()
29
		{
30
			//
31
			// Required for Windows Form Designer support
32
			//
33
			InitializeComponent();
34
 
35
			//
36
			// TODO: Add any constructor code after InitializeComponent call
37
			//
38
		}
39
 
40
		/// <summary>
41
		/// Clean up any resources being used.
42
		/// </summary>
43
		protected override void Dispose( bool disposing )
44
		{
45
			if( disposing )
46
			{
47
				if(components != null)
48
				{
49
					components.Dispose();
50
				}
51
			}
52
			base.Dispose( disposing );
53
		}
54
 
55
		#region Windows Form Designer generated code
56
		/// <summary>
57
		/// Required method for Designer support - do not modify
58
		/// the contents of this method with the code editor.
59
		/// </summary>
60
		private void InitializeComponent()
61
		{
62
         this.buttonCancel = new System.Windows.Forms.Button();
63
         this.buttonOK = new System.Windows.Forms.Button();
64
         this.checkedListBox_ETs = new System.Windows.Forms.CheckedListBox();
65
         this.groupBoxElementTypes = new System.Windows.Forms.GroupBox();
66
         this.buttonDefault = new System.Windows.Forms.Button();
67
         this.button_ET_None = new System.Windows.Forms.Button();
68
         this.button_ET_All = new System.Windows.Forms.Button();
2116 ghuddy 69
         this.treeView_BooleanOptions = new System.Windows.Forms.TreeView();
70
         this.groupBox1 = new System.Windows.Forms.GroupBox();
2094 ghuddy 71
         this.groupBoxElementTypes.SuspendLayout();
2116 ghuddy 72
         this.groupBox1.SuspendLayout();
2094 ghuddy 73
         this.SuspendLayout();
2104 ghuddy 74
         // 
2094 ghuddy 75
         // buttonCancel
2104 ghuddy 76
         // 
2094 ghuddy 77
         this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
2116 ghuddy 78
         this.buttonCancel.Location = new System.Drawing.Point(680, 520);
2094 ghuddy 79
         this.buttonCancel.Name = "buttonCancel";
80
         this.buttonCancel.Size = new System.Drawing.Size(96, 24);
81
         this.buttonCancel.TabIndex = 0;
82
         this.buttonCancel.Text = "Cancel";
2104 ghuddy 83
         // 
2094 ghuddy 84
         // buttonOK
2104 ghuddy 85
         // 
2094 ghuddy 86
         this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
2116 ghuddy 87
         this.buttonOK.Location = new System.Drawing.Point(568, 520);
2094 ghuddy 88
         this.buttonOK.Name = "buttonOK";
89
         this.buttonOK.Size = new System.Drawing.Size(96, 24);
90
         this.buttonOK.TabIndex = 1;
91
         this.buttonOK.Text = "OK";
2104 ghuddy 92
         // 
2094 ghuddy 93
         // checkedListBox_ETs
2104 ghuddy 94
         // 
95
         this.checkedListBox_ETs.Location = new System.Drawing.Point(32, 48);
2094 ghuddy 96
         this.checkedListBox_ETs.Name = "checkedListBox_ETs";
2116 ghuddy 97
         this.checkedListBox_ETs.Size = new System.Drawing.Size(280, 395);
2094 ghuddy 98
         this.checkedListBox_ETs.TabIndex = 3;
2104 ghuddy 99
         // 
2094 ghuddy 100
         // groupBoxElementTypes
2104 ghuddy 101
         // 
2094 ghuddy 102
         this.groupBoxElementTypes.Controls.Add(this.buttonDefault);
103
         this.groupBoxElementTypes.Controls.Add(this.button_ET_None);
104
         this.groupBoxElementTypes.Controls.Add(this.button_ET_All);
2104 ghuddy 105
         this.groupBoxElementTypes.Location = new System.Drawing.Point(16, 16);
2094 ghuddy 106
         this.groupBoxElementTypes.Name = "groupBoxElementTypes";
2116 ghuddy 107
         this.groupBoxElementTypes.Size = new System.Drawing.Size(312, 488);
2094 ghuddy 108
         this.groupBoxElementTypes.TabIndex = 4;
109
         this.groupBoxElementTypes.TabStop = false;
110
         this.groupBoxElementTypes.Text = "Element Types to be serialised to document";
2104 ghuddy 111
         // 
2094 ghuddy 112
         // buttonDefault
2104 ghuddy 113
         // 
2116 ghuddy 114
         this.buttonDefault.Location = new System.Drawing.Point(208, 440);
2094 ghuddy 115
         this.buttonDefault.Name = "buttonDefault";
116
         this.buttonDefault.Size = new System.Drawing.Size(88, 23);
117
         this.buttonDefault.TabIndex = 2;
118
         this.buttonDefault.Text = "Defaults";
119
         this.buttonDefault.Click += new System.EventHandler(this.buttonDefault_Click);
2104 ghuddy 120
         // 
2094 ghuddy 121
         // button_ET_None
2104 ghuddy 122
         // 
2116 ghuddy 123
         this.button_ET_None.Location = new System.Drawing.Point(112, 440);
2094 ghuddy 124
         this.button_ET_None.Name = "button_ET_None";
125
         this.button_ET_None.Size = new System.Drawing.Size(88, 23);
126
         this.button_ET_None.TabIndex = 1;
127
         this.button_ET_None.Text = "DeSelect All";
128
         this.button_ET_None.Click += new System.EventHandler(this.button_ET_None_Click);
2104 ghuddy 129
         // 
2094 ghuddy 130
         // button_ET_All
2104 ghuddy 131
         // 
2116 ghuddy 132
         this.button_ET_All.Location = new System.Drawing.Point(16, 440);
2094 ghuddy 133
         this.button_ET_All.Name = "button_ET_All";
134
         this.button_ET_All.Size = new System.Drawing.Size(88, 24);
135
         this.button_ET_All.TabIndex = 0;
136
         this.button_ET_All.Text = "Select All";
137
         this.button_ET_All.Click += new System.EventHandler(this.button_ET_All_Click);
2104 ghuddy 138
         // 
2116 ghuddy 139
         // treeView_BooleanOptions
2104 ghuddy 140
         // 
2116 ghuddy 141
         this.treeView_BooleanOptions.CheckBoxes = true;
142
         this.treeView_BooleanOptions.ImageIndex = -1;
143
         this.treeView_BooleanOptions.Location = new System.Drawing.Point(16, 32);
144
         this.treeView_BooleanOptions.Name = "treeView_BooleanOptions";
145
         this.treeView_BooleanOptions.SelectedImageIndex = -1;
146
         this.treeView_BooleanOptions.Size = new System.Drawing.Size(400, 440);
147
         this.treeView_BooleanOptions.TabIndex = 16;
2104 ghuddy 148
         // 
2116 ghuddy 149
         // groupBox1
2104 ghuddy 150
         // 
2116 ghuddy 151
         this.groupBox1.Controls.Add(this.treeView_BooleanOptions);
152
         this.groupBox1.Location = new System.Drawing.Point(344, 16);
153
         this.groupBox1.Name = "groupBox1";
154
         this.groupBox1.Size = new System.Drawing.Size(432, 488);
155
         this.groupBox1.TabIndex = 17;
156
         this.groupBox1.TabStop = false;
157
         this.groupBox1.Text = "Discrete Options";
2104 ghuddy 158
         // 
2094 ghuddy 159
         // EA_DocGenOptionsForm
2104 ghuddy 160
         // 
2094 ghuddy 161
         this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
2116 ghuddy 162
         this.ClientSize = new System.Drawing.Size(792, 560);
163
         this.Controls.Add(this.groupBox1);
2094 ghuddy 164
         this.Controls.Add(this.checkedListBox_ETs);
165
         this.Controls.Add(this.buttonOK);
166
         this.Controls.Add(this.buttonCancel);
167
         this.Controls.Add(this.groupBoxElementTypes);
168
         this.Name = "EA_DocGenOptionsForm";
169
         this.Text = "EA_DocGenOptionsForm";
170
         this.groupBoxElementTypes.ResumeLayout(false);
2116 ghuddy 171
         this.groupBox1.ResumeLayout(false);
2094 ghuddy 172
         this.ResumeLayout(false);
173
 
174
      }
175
		#endregion
176
 
177
 
2106 ghuddy 178
      public void populate()
2094 ghuddy 179
      {
180
         EA.ObjectType objType;
181
         object obj;
182
 
2106 ghuddy 183
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
2094 ghuddy 184
         if (objType == EA.ObjectType.otElement)
185
         {
186
            EA.Element ele = (EA.Element)obj;
187
            if (0 == ele.Name.CompareTo(EA_Constants.EA_DocGenBaseName))
188
            {
189
               CheckState defState;
2106 ghuddy 190
               if (EA_DocGenOptions.opt_ElementTypes.Count > 0)
2094 ghuddy 191
                  defState = CheckState.Unchecked;
192
               else
193
                  defState = CheckState.Checked;
194
 
2098 ghuddy 195
               // Items marked with a ? are things that do not appear in the New Element dialogs drop down list yet they
196
               // are mentioned in the on-line help files. Not sure why this is so. Perhpas such element types are created
197
               // by other means that the New Element dialog?
198
               checkedListBox_ETs.Items.Add("Action",                     defState);
199
               checkedListBox_ETs.Items.Add("Activity",                   defState);
200
               checkedListBox_ETs.Items.Add("ActivityPartition",          defState);
201
               checkedListBox_ETs.Items.Add("ActivityRegion",             defState);    // ?
202
               checkedListBox_ETs.Items.Add("Actor",                      defState);
203
               checkedListBox_ETs.Items.Add("Artifact",                   defState);
204
               checkedListBox_ETs.Items.Add("Association",                defState);    // ?
205
               checkedListBox_ETs.Items.Add("Boundary",                   defState);    // ?
206
               checkedListBox_ETs.Items.Add("CentralBufferNode",          defState);
207
               checkedListBox_ETs.Items.Add("Change",                     defState);
208
               checkedListBox_ETs.Items.Add("Class",                      defState);
209
               checkedListBox_ETs.Items.Add("Collaboration",              defState);
210
               checkedListBox_ETs.Items.Add("Comment",                    defState);
211
               checkedListBox_ETs.Items.Add("Component",                  defState);
212
               checkedListBox_ETs.Items.Add("Constraint",                 defState);    // ?
213
               checkedListBox_ETs.Items.Add("DataStore",                  defState);
214
               checkedListBox_ETs.Items.Add("Decision",                   defState);    // ?
215
               checkedListBox_ETs.Items.Add("DeploymentSpecification",    defState);
2112 ghuddy 216
               checkedListBox_ETs.Items.Add("Device",                     defState);    // ?
2098 ghuddy 217
               checkedListBox_ETs.Items.Add("DiagramFrame",               defState);
218
               checkedListBox_ETs.Items.Add("EmbeddedElement",            defState);    // ?
219
               checkedListBox_ETs.Items.Add("Entity",                     defState);
220
               checkedListBox_ETs.Items.Add("EntryPoint",                 defState);    // ?
221
               checkedListBox_ETs.Items.Add("Enumeration",                defState);
222
               checkedListBox_ETs.Items.Add("Event",                      defState);    // ?
223
               checkedListBox_ETs.Items.Add("ExcecutionEnvironment",      defState);
224
               checkedListBox_ETs.Items.Add("ExceptionHandler",           defState);
225
               checkedListBox_ETs.Items.Add("ExitPoint",                  defState);    // ?
226
               checkedListBox_ETs.Items.Add("ExpansionNode",              defState);    // ?
227
               checkedListBox_ETs.Items.Add("ExpansionRegion",            defState);
228
               checkedListBox_ETs.Items.Add("GUIElement",                 defState);
229
               checkedListBox_ETs.Items.Add("InformationItem",            defState);
230
               checkedListBox_ETs.Items.Add("Interaction",                defState);
231
               checkedListBox_ETs.Items.Add("InteractionFragment",        defState);
232
               checkedListBox_ETs.Items.Add("InteractionOccurrence",      defState);    // ?
233
               checkedListBox_ETs.Items.Add("InteractionState",           defState);    // ?
234
               checkedListBox_ETs.Items.Add("Interface",                  defState);
235
               checkedListBox_ETs.Items.Add("InterruptibleActivityRegion",defState);
236
               checkedListBox_ETs.Items.Add("Issue",                      defState);
237
               checkedListBox_ETs.Items.Add("MergeNode",                  defState);
238
               checkedListBox_ETs.Items.Add("Node",                       defState);
239
               checkedListBox_ETs.Items.Add("Note",                       defState);    // ?
240
               checkedListBox_ETs.Items.Add("Object",                     defState);
241
               checkedListBox_ETs.Items.Add("Package",                    defState);    // ?
242
               checkedListBox_ETs.Items.Add("Parameter",                  defState);    // ?
243
               checkedListBox_ETs.Items.Add("Part",                       defState);    // ?
244
               checkedListBox_ETs.Items.Add("Port",                       defState);    // ?
245
               checkedListBox_ETs.Items.Add("ProvidedInterface",          defState);    // ?
246
               checkedListBox_ETs.Items.Add("Region",                     defState);
247
               checkedListBox_ETs.Items.Add("Report",                     defState);    // ?
248
               checkedListBox_ETs.Items.Add("RequiredInterface",          defState);    // ?
249
               checkedListBox_ETs.Items.Add("Requirement",                defState);
250
               checkedListBox_ETs.Items.Add("Screen",                     defState);
251
               checkedListBox_ETs.Items.Add("Sequence",                   defState);    // ?
252
               checkedListBox_ETs.Items.Add("Signal",                     defState);
253
               checkedListBox_ETs.Items.Add("State",                      defState);
254
               checkedListBox_ETs.Items.Add("StateMachine",               defState);
255
               checkedListBox_ETs.Items.Add("StateNode",                  defState);
256
               checkedListBox_ETs.Items.Add("Synchronization",            defState);    // ?
257
               checkedListBox_ETs.Items.Add("Text",                       defState);    // ?
258
               checkedListBox_ETs.Items.Add("TimeLine",                   defState);
259
               checkedListBox_ETs.Items.Add("Trigger",                    defState);
260
               checkedListBox_ETs.Items.Add("UMLDiagram",                 defState);    // ?
261
               checkedListBox_ETs.Items.Add("UseCase",                    defState);
2094 ghuddy 262
 
2106 ghuddy 263
               if (EA_DocGenOptions.opt_ElementTypes.Count > 0)
2094 ghuddy 264
               {
2106 ghuddy 265
                  foreach(string s in EA_DocGenOptions.opt_ElementTypes)
2094 ghuddy 266
                  {
267
                     int i = checkedListBox_ETs.FindStringExact(s);
268
                     if (i != -1)
269
                     {
270
                        checkedListBox_ETs.SetItemChecked(i,true);
271
                     }
272
                  }
273
               }
274
 
2116 ghuddy 275
               // Use the EA_DocGenOptions class to populate a tree view of discrete boolean options
276
               int i_1 = -1;
277
               TreeNodeCollection tnc = treeView_BooleanOptions.Nodes;
278
               EA_DocGenOptions.boolean_options_e e;
279
               int level;
280
               string dn;
281
               bool v;
282
               if (EA_DocGenOptions.getFirstBooleanOption(out e, out level, out dn, out v))
283
               {
284
                  do
285
                  {
286
                     if (level > 1 && i_1 != -1)
287
                     {
288
                        int i_2 = tnc[i_1].Nodes.Add( new TreeNode(dn) );
289
                        tnc[i_1].Nodes[i_2].Checked = v;
290
                        tnc[i_1].Nodes[i_2].Tag = e;
291
                     }
292
                     else
293
                     {
294
                        i_1 = tnc.Add( new TreeNode(dn) );
295
                        tnc[i_1].Checked = v;
296
                        tnc[i_1].Tag = e;
297
                     }
2094 ghuddy 298
 
2116 ghuddy 299
                  } while (EA_DocGenOptions.getNextBooleanOption(out e, out level, out dn, out v));
300
               }
301
 
2094 ghuddy 302
            }
303
         }
304
      }
305
 
306
 
2106 ghuddy 307
      public void read()
2094 ghuddy 308
      {
309
         // If every item is checked then we give back an empty opt_ElementTypes list because
310
         // that indicates that the user wants everything.
2106 ghuddy 311
         EA_DocGenOptions.opt_ElementTypes.Clear();
2094 ghuddy 312
         if (checkedListBox_ETs.CheckedItems.Count != checkedListBox_ETs.Items.Count)
313
         {
314
            foreach(string s in checkedListBox_ETs.CheckedItems)
315
            {
2106 ghuddy 316
               EA_DocGenOptions.opt_ElementTypes.Add(s);
2094 ghuddy 317
            }
318
         }
319
 
2116 ghuddy 320
         // Take the discrete boolean options and feed them back to the EA_DocGenOptions class
321
         TreeNodeCollection tnc = treeView_BooleanOptions.Nodes;
322
         foreach(TreeNode tn in tnc)
323
         {
324
            EA_DocGenOptions.optionValue( (EA_DocGenOptions.boolean_options_e)tn.Tag, tn.Checked );
325
            foreach(TreeNode tnsub in tn.Nodes)
326
            {
327
               EA_DocGenOptions.optionValue( (EA_DocGenOptions.boolean_options_e)tnsub.Tag, tnsub.Checked );
328
            }
329
         }
2094 ghuddy 330
 
331
      }
332
 
333
      private void button_ET_All_Click(object sender, System.EventArgs e)
334
      {
335
         int i;
336
         for (i=0; i < checkedListBox_ETs.Items.Count; i++)
337
         {
338
            checkedListBox_ETs.SetItemChecked(i, true);
339
         }
340
      }
341
 
342
      private void button_ET_None_Click(object sender, System.EventArgs e)
343
      {
344
         int i;
345
         for (i=0; i < checkedListBox_ETs.Items.Count; i++)
346
         {
347
            checkedListBox_ETs.SetItemChecked(i, false);
348
         }
349
      }
350
 
351
      private void findAndCheckItem(string s)
352
      {
353
         int i = checkedListBox_ETs.FindStringExact(s);
354
         if (i != -1)
355
            checkedListBox_ETs.SetItemChecked(i,true);
356
      }
357
 
358
      private void checkDefaultItems()
359
      {
360
         findAndCheckItem("Class");
361
         findAndCheckItem("Component");
362
         findAndCheckItem("Interface");
363
         findAndCheckItem("Requirement");
364
      }
365
 
366
      private void buttonDefault_Click(object sender, System.EventArgs e)
367
      {
368
         int i = 0;
369
 
370
         for (i=0; i < checkedListBox_ETs.Items.Count; i++)
371
         {
372
            checkedListBox_ETs.SetItemChecked(i, false);
373
         }
374
         checkDefaultItems();
375
      }
376
 
377
 
378
	}
379
}