Subversion Repositories DevTools

Rev

Rev 2145 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2145 Rev 2151
Line 1... Line 1...
1
 
1
 
2
using System;
2
using System;
3
using System.Text;
3
using System.Text;
4
using System.Globalization;
4
using System.Globalization;
5
using System.Collections;
5
using System.Collections;
6
using System.Windows.Forms;
6
using System.Windows.Forms;
7
using ReqPro40;
7
using ReqPro40;
8
 
8
 
9
namespace EA_ReqPro
9
namespace EA_ReqPro
10
{
10
{
11
	/// <summary>
11
	/// <summary>
12
	/// Summary description for EA_Utils.
12
	/// Summary description for EA_Utils.
13
	/// </summary>
13
	/// </summary>
14
	public class EA_Utilities
14
	public class EA_Utilities
15
	{
15
	{
16
      EA.Repository EA_Repository = null;
-
 
17
 
16
 
18
		public EA_Utilities(EA.Repository theRepository)
17
		public EA_Utilities()
19
		{
18
		{
20
         EA_Repository = theRepository;
-
 
21
		}
19
		}
22
 
20
 
23
      /// <summary>
21
      /// <summary>
24
      /// This function is designed to parse EA models/packages in a predefined way, whilst allowing
22
      /// This function is designed to parse EA models/packages in a predefined way, whilst allowing
25
      /// a user to specify what processing is to be done upon or with each element found.
23
      /// a user to specify what processing is to be done upon or with each element found.
Line 46... Line 44...
46
         }
44
         }
47
 
45
 
48
      }
46
      }
49
 
47
 
50
 
48
 
51
      public string ReadTag(EA.Element theElement, string tagName)
49
      public string ReadTag(EA.Element theElement, string tagName)
52
      {
50
      {
53
         string result;
51
         string result;
54
 
52
 
55
         EA.TaggedValue tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
53
         EA.TaggedValue tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
56
         if (null != tag)
54
         if (null != tag)
57
         {
55
         {
58
            result = tag.Value;
56
            result = tag.Value;
59
         }
57
         }
60
         else
58
         else
61
         {
59
         {
62
            result = "";
60
            result = "";
63
         }
61
         }
64
         return result;
62
         return result;
65
      }
63
      }
66
 
64
 
67
 
65
 
68
      public bool WriteTag(EA.Element theElement, string tagName, string value)
66
      public bool WriteTag(EA.Element theElement, string tagName, string value)
69
      {
67
      {
70
         bool result;
68
         bool result;
71
         EA.TaggedValue tag;
69
         EA.TaggedValue tag;
72
            
70
            
73
         tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
71
         tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
74
         if (null != tag)
72
         if (null != tag)
75
         {
73
         {
76
            tag.Value = value;
74
            tag.Value = value;
77
         }
75
         }
78
         else
76
         else
79
         {
77
         {
80
            tag = (EA.TaggedValue)theElement.TaggedValues.AddNew(tagName, value);
78
            tag = (EA.TaggedValue)theElement.TaggedValues.AddNew(tagName, value);
81
         }
79
         }
82
 
80
 
83
         if (tag != null)
81
         if (tag != null)
84
         {
82
         {
85
            result = tag.Update();
83
            result = tag.Update();
86
         }
84
         }
87
         else
85
         else
88
         {
86
         {
89
            result = false;
87
            result = false;
90
         }
88
         }
91
         return result;
89
         return result;
92
      }
90
      }
93
 
91
 
94
 
92
 
95
      public EA.Package get_selected_package()
93
      public EA.Package get_selected_package()
96
      {
94
      {
97
         object o;
95
         object o;
98
         EA.ObjectType type;
96
         EA.ObjectType type;
99
 
97
 
100
         type = EA_Repository.GetTreeSelectedItem(out o);
98
         type = Main.EA_Repository.GetTreeSelectedItem(out o);
101
         if (type == EA.ObjectType.otElement)
99
         if (type == EA.ObjectType.otElement)
102
         {
100
         {
103
            return EA_Repository.GetPackageByID( ((EA.Element)o).PackageID );
101
            return Main.EA_Repository.GetPackageByID( ((EA.Element)o).PackageID );
104
         }
102
         }
105
         else if (type == EA.ObjectType.otPackage)
103
         else if (type == EA.ObjectType.otPackage)
106
         {
104
         {
107
            return (EA.Package)o;
105
            return (EA.Package)o;
108
         }
106
         }
109
         return null;
107
         return null;
110
      }
108
      }
111
 
109
 
112
      /// <summary>
110
      /// <summary>
Line 123... Line 121...
123
         newobj.TreePos = treePos;
121
         newobj.TreePos = treePos;
124
         newobj.Update();
122
         newobj.Update();
125
         return newobj;
123
         return newobj;
126
      }
124
      }
127
 
125
 
128
      public void DumpEAElement(EA.Repository repository)
126
      public void DumpEAElement()
129
      {
127
      {
130
         EA.Element ea_ele = (EA.Element)repository.GetTreeSelectedObject();
128
         EA.Element ea_ele = (EA.Element)Main.EA_Repository.GetTreeSelectedObject();
131
 
129
 
132
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Element : " + ea_ele.Name, ea_ele.ElementID);
130
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Element : " + ea_ele.Name, ea_ele.ElementID);
133
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,               "Author : " + ea_ele.Author, -1);
131
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,               "Author : " + ea_ele.Author, -1);
134
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,          "ClassfierID : " + ea_ele.ClassfierID.ToString(), -1);
132
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,          "ClassfierID : " + ea_ele.ClassfierID.ToString(), -1);
135
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,       "ClassifierName : " + ea_ele.ClassifierName, -1);
133
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,       "ClassifierName : " + ea_ele.ClassifierName, -1);
136
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,       "ClassifierType : " + ea_ele.ClassifierType, -1);
134
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,       "ClassifierType : " + ea_ele.ClassifierType, -1);
137
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "Complexity : " + ea_ele.Complexity, -1);
135
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "Complexity : " + ea_ele.Complexity, -1);
138
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "Difficulty : " + ea_ele.Difficulty, -1);
136
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "Difficulty : " + ea_ele.Difficulty, -1);
139
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,          "ElementGUID : " + ea_ele.ElementGUID, -1);
137
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,          "ElementGUID : " + ea_ele.ElementGUID, -1);
140
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,            "ElementID : " + ea_ele.ElementID.ToString(), ea_ele.ElementID);
138
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,            "ElementID : " + ea_ele.ElementID.ToString(), ea_ele.ElementID);
141
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "EventFlags : " + ea_ele.EventFlags, -1);
139
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "EventFlags : " + ea_ele.EventFlags, -1);
142
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,      "ExtensionPoints : " + ea_ele.ExtensionPoints, -1);
140
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,      "ExtensionPoints : " + ea_ele.ExtensionPoints, -1);
143
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "Genfile : " + ea_ele.Genfile, -1);
141
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "Genfile : " + ea_ele.Genfile, -1);
144
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,             "Genlinks : " + ea_ele.Genlinks, -1);
142
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,             "Genlinks : " + ea_ele.Genlinks, -1);
145
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "Gentype : " + ea_ele.Gentype, -1);
143
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "Gentype : " + ea_ele.Gentype, -1);
146
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,         "GetLastError : " + ea_ele.GetLastError(), -1);
144
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,         "GetLastError : " + ea_ele.GetLastError(), -1);
147
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,    "GetLinkedDocument : " + ea_ele.GetLinkedDocument(), -1);
145
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,    "GetLinkedDocument : " + ea_ele.GetLinkedDocument(), -1);
148
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,    "GetStereotypeList : " + ea_ele.GetStereotypeList(), -1);
146
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,    "GetStereotypeList : " + ea_ele.GetStereotypeList(), -1);
149
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,             "MetaType : " + ea_ele.MetaType, -1);
147
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,             "MetaType : " + ea_ele.MetaType, -1);
150
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,         "Multiplicity : " + ea_ele.Multiplicity, -1);
148
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,         "Multiplicity : " + ea_ele.Multiplicity, -1);
151
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,                "Notes : " + ea_ele.Notes, -1);
149
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,                "Notes : " + ea_ele.Notes, -1);
152
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,            "PackageID : " + ea_ele.PackageID.ToString(), ea_ele.PackageID);
150
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,            "PackageID : " + ea_ele.PackageID.ToString(), ea_ele.PackageID);
153
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,             "ParentID : " + ea_ele.ParentID.ToString(), ea_ele.ParentID);
151
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,             "ParentID : " + ea_ele.ParentID.ToString(), ea_ele.ParentID);
154
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,          "Persistence : " + ea_ele.Persistence, -1);
152
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,          "Persistence : " + ea_ele.Persistence, -1);
155
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,                "Phase : " + ea_ele.Phase, -1);
153
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,                "Phase : " + ea_ele.Phase, -1);
156
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,             "Priority : " + ea_ele.Priority, -1);
154
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,             "Priority : " + ea_ele.Priority, -1);
157
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,         "PropertyType : " + ea_ele.PropertyType.ToString(), -1);
155
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,         "PropertyType : " + ea_ele.PropertyType.ToString(), -1);
158
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,             "RunState : " + ea_ele.RunState, -1);
156
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,             "RunState : " + ea_ele.RunState, -1);
159
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,               "Status : " + ea_ele.Status, -1);
157
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,               "Status : " + ea_ele.Status, -1);
160
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "Stereotype : " + ea_ele.Stereotype, -1);
158
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "Stereotype : " + ea_ele.Stereotype, -1);
161
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,         "StereotypeEx : " + ea_ele.StereotypeEx, -1);
159
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,         "StereotypeEx : " + ea_ele.StereotypeEx, -1);
162
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "StyleEx : " + ea_ele.StyleEx, -1);
160
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "StyleEx : " + ea_ele.StyleEx, -1);
163
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "Subtype : " + ea_ele.Subtype.ToString(), -1);
161
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "Subtype : " + ea_ele.Subtype.ToString(), -1);
164
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "Tablespace : " + ea_ele.Tablespace, -1);
162
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "Tablespace : " + ea_ele.Tablespace, -1);
165
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,                  "Tag : " + ea_ele.Tag, -1);
163
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,                  "Tag : " + ea_ele.Tag, -1);
166
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "TreePos : " + ea_ele.TreePos.ToString(), -1);
164
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "TreePos : " + ea_ele.TreePos.ToString(), -1);
167
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,                 "Type : " + ea_ele.Type, -1);
165
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,                 "Type : " + ea_ele.Type, -1);
168
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "Version : " + ea_ele.Version, -1);
166
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,              "Version : " + ea_ele.Version, -1);
169
         repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "Visibility : " + ea_ele.Visibility, -1);
167
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,           "Visibility : " + ea_ele.Visibility, -1);
170
      }
168
      }
171
 
169
 
172
  
170
  
173
	}
171
	}
174
 
172
 
175
 
173
 
Line 191... Line 189...
191
      {
189
      {
192
      }
190
      }
193
   }
191
   }
194
 
192
 
195
 
193
 
196
   
194
   
197
   /// <summary>
195
   /// <summary>
198
   /// This class is one derived from the EA_UtilitiesRecursionWorker base class so that
196
   /// This class is one derived from the EA_UtilitiesRecursionWorker base class so that
199
   /// an instance of it can be used as a parameter in the EA_Utilities.findAndProcessPackageElements
197
   /// an instance of it can be used as a parameter in the EA_Utilities.findAndProcessPackageElements
200
   /// method which recursively parses a given package. Thus, clients can parse EA model structure but
198
   /// method which recursively parses a given package. Thus, clients can parse EA model structure but
201
   /// specify their own functionality to be carried out on packages and elements found in the
199
   /// specify their own functionality to be carried out on packages and elements found in the
202
   /// parsing.
200
   /// parsing.
203
   /// This particular derived class is designed to collect a list of element names from the
201
   /// This particular derived class is designed to collect a list of element names from the
204
   /// package, from elements that have a type that is acceptable.
202
   /// package, from elements that have a type that is acceptable.
205
   /// </summary>
203
   /// </summary>
206
   public class ElementAccumulator : EA_UtilitiesRecursionWorker
204
   public class ElementAccumulator : EA_UtilitiesRecursionWorker
207
   {
205
   {
208
      public ArrayList Elements = null;
206
      public ArrayList Elements = null;
209
      public ArrayList ElementIDs = null;
207
      public ArrayList ElementIDs = null;
210
      private ArrayList validElementTypes = null;
208
      private ArrayList validElementTypes = null;
211
 
209
 
212
      public ElementAccumulator(ArrayList elementTypeList): base()
210
      public ElementAccumulator(ArrayList elementTypeList): base()
213
      {
211
      {
214
         validElementTypes = elementTypeList;
212
         validElementTypes = elementTypeList;
215
         Elements = new ArrayList();
213
         Elements = new ArrayList();
216
         ElementIDs = new ArrayList();
214
         ElementIDs = new ArrayList();
217
      }
215
      }
218
 
216
 
219
      public override void processElement( EA.Element theElement )
217
      public override void processElement( EA.Element theElement )
220
      {
218
      {
221
         if (validElementTypes.Contains( theElement.Type ))
219
         if (validElementTypes.Contains( theElement.Type ))
222
         {
220
         {
223
            Elements.Add( theElement );
221
            Elements.Add( theElement );
224
            ElementIDs.Add( theElement.ElementID );
222
            ElementIDs.Add( theElement.ElementID );
225
         }
223
         }
226
      }
224
      }
227
   }
225
   }
228
 
226
 
229
}
227
}