private void init() { this.artifacts.Clear(); this.rootNode = new TreeNode("ルート"); this.treeView1.Nodes.Clear(); this.treeNodeMap.Clear(); if (this.tabControl1.TabPages.Count > 1) { this.tabControl1.TabPages.Clear(); } if (ProjectSetting.getVO() != null) { initProject(); // 使用するIndexDBファイルの存在チェック if (!System.IO.File.Exists(ProjectSetting.getVO().projectPath + "\\" + ProjectSetting.getVO().dbName)) { // 読み込みが終わるまでモーダルでスプラッシュ画面を開く SplashForm splashForm = new SplashForm(); splashForm.Show(); splashForm.CloseOnLoadComplete(ProjectSetting.getVO().projectPath, ProjectSetting.getVO().dbName); } } AttachEA(); }
private void AttachEA() { EA.App eaapp = null; if (ProjectSetting.getVO() == null) { toolStripStatusLabel1.Text = "[ファイル]メニューの[開く]を選択しプロジェクトをオープンしてください"; return; } try { eaapp = (EA.App)Microsoft.VisualBasic.Interaction.GetObject(null, "EA.App"); if (eaapp != null) { EA.Repository repo = eaapp.Repository; // eaapp.Visible = true; ProjectSetting.getVO().eaRepo = repo; string connStr = repo.ConnectionString; if (connStr.Length > 50) { connStr = connStr.Substring(0, 50); } toolStripStatusLabel1.Text = "EAへのアタッチ成功 EA接続先=" + connStr; } else { toolStripStatusLabel1.Text = "EAにアタッチできなかったため、EAへの反映機能は使えません"; } } catch (Exception ex) { toolStripStatusLabel1.Text = "EAが起動していなかったため、EAへの反映機能は使えません : " + ex.Message; return; } }
/// <summary> /// 要素ファイルのフルパスを取得する /// </summary> /// <param name="guid">対象要素のGUID</param> /// <returns>要素ファイルのフルパス</returns> private static string getElementFilePath(string guid) { string outputDir = ProjectSetting.getVO().projectPath + @"\elements"; string elementFile = outputDir + @"\" + guid.Substring(1, 1) + @"\" + guid.Substring(2, 1) + @"\" + guid.Substring(1, 36) + ".xml"; return(elementFile); }
private void init() { this.artifacts.Clear(); this.rootNode = new TreeNode("ルート"); this.treeView1.Nodes.Clear(); this.treeNodeMap.Clear(); if (this.tabControl1.TabPages.Count > 1) { this.tabControl1.TabPages.Clear(); } // プロジェクトファイル(.bdprj)が読み込み済みの場合 if (ProjectSetting.getVO() != null) { initProject(); // 使用するIndexDBファイルの存在チェック //if ( !System.IO.File.Exists(ProjectSetting.getVO().projectPath + "\\" + ProjectSetting.getVO().dbName) ) { // // 読み込みが終わるまでモーダルでスプラッシュ画面を開く // SplashForm splashForm = new SplashForm(); // splashForm.Show(); // splashForm.CloseOnLoadComplete(ProjectSetting.getVO().projectPath, ProjectSetting.getVO().dbName); //} // 展開IndexDBが未作成の場合にここで作成する処理を、一旦、削除する。 // TODO: IndexDBと要素毎に展開される成果物ファイルの存在が無いと、データ更新処理などで色々とできないことが出てくるため、 // ProjectSettingなどでこのフラグを管理して、画面の動作モードを一元的に管理できるようにする。 // 既に "EAと接続済みか否か" の情報を持っていたりするので、その延長で。 } AttachEA(); }
/// <summary> /// detail の method XML (/detail/#method_${guid}_${LR}.xml) を読み、得られたVOを返却する /// /// </summary> /// <returns>MethodVO</returns> public MethodVO readMethodDiffDetail(string methodGuid, string leftRight) { string target_dir = ProjectSetting.getVO().projectPath; string fileName = target_dir + "/detail/" + "#method_" + methodGuid.Substring(1, 36) + "_" + leftRight + ".xml"; // 指定されたfileNameでファイルが存在しなかったらnullを返す if (!System.IO.File.Exists(fileName)) { return(null); } // XMLテキストをロードする XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); // methodノードに移動する XmlNode mthNode = xmlDoc.SelectSingleNode("method"); if (mthNode != null) { return(ElementsXmlReader.readMethod(mthNode)); } else { return(new MethodVO()); } }
/// <summary> /// detail の attribute XML (/detail/#attribute_${guid}_${LR}.xml) を読み、得られたVOを返却する /// /// </summary> /// <returns>AttributeVO</returns> public AttributeVO readAttributeDiffDetail(string attributeGuid, string leftRight) { string target_dir = ProjectSetting.getVO().projectPath; string fileName = target_dir + "/detail/" + "#attribute_" + attributeGuid.Substring(1, 36) + "_" + leftRight + ".xml"; // 指定されたfileNameでファイルが存在しなかったらnullを返す if (!System.IO.File.Exists(fileName)) { return(null); } // XMLテキストをロードする XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); // attributeノードに移動する XmlNode attrNode = xmlDoc.SelectSingleNode("attribute"); if (attrNode != null) { return(ElementsXmlReader.readAttribute(attrNode)); } else { return(new AttributeVO()); } }
private void initProject() { string artifactsFileName = ProjectSetting.getVO().artifactsFile; string artifactDir = ProjectSetting.getVO().projectPath + "\\" + ProjectSetting.getVO().artifactsPath; // artifactList.Items.Clear(); this.artifacts = ArtifactsXmlReader.readArtifactList(artifactDir, artifactsFileName); string atfnodename; for (int i = 0; i < artifacts.Count; i++) { ArtifactVO atf = artifacts[i]; TreeNode packageNode = addPackageNodes(atf.pathName); if (atf.changed == ' ') { atfnodename = atf.name; } else { atfnodename = atf.name + " [" + atf.changed + "]"; } TreeNode atfNode = new TreeNode(atfnodename, 2, 1); atfNode.Tag = atf; atfNode.ContextMenuStrip = contextMenuStrip1; packageNode.Nodes.Add(atfNode); treeNodeMap.Add(atf.guid, atfNode); } this.treeView1.Nodes.Add(rootNode); }
private void AttachEA() { EA.App eaapp = null; try { eaapp = (EA.App)Microsoft.VisualBasic.Interaction.GetObject(null, "EA.App"); } catch (Exception e) { toolStripStatusLabel1.Text = "EAが起動していなかったため、EAへの反映機能は使えません : " + e.Message; // MessageBox.Show( e.Message ); return; } finally { } if (ProjectSetting.getVO() != null) { if (eaapp != null) { EA.Repository repo = eaapp.Repository; // eaapp.Visible = true; ProjectSetting.getVO().eaRepo = repo; toolStripStatusLabel1.Text = "EAへのアタッチ成功 EA接続先=" + repo.ConnectionString; } else { toolStripStatusLabel1.Text = "EAにアタッチできなかったため、EAへの反映機能は使えません"; } } }
/// <summary> /// EAから取得したパッケージ情報でartifactXMLを更新し、取得結果を新しいArtifactVOに入れて返却する /// </summary> /// <returns></returns> public ArtifactVO makeArtifactXml() { // if (eaPackageObj.IsControlled == false) { // } ArtifactVO atf = new ArtifactVO(); atf.artifactId = ""; atf.changed = ' '; atf.createDate = rootPackObj.Element.Created.ToString(); atf.guid = rootPackObj.PackageGUID; atf.name = rootPackObj.Name; atf.notes = rootPackObj.Notes; atf.pathName = makePackagePathFromEAPackage(rootPackObj); atf.projectName = "ASW"; atf.stereoType = rootPackObj.StereotypeEx; atf.updateDate = rootPackObj.Element.Modified.ToString(); atf.package = ObjectEAConverter.getPackageFromEAObject(rootPackObj); atf.packageId = rootPackObj.PackageID; string artifactDir = ProjectSetting.getVO().projectPath + ProjectSetting.getVO().artifactsPath; ArtifactXmlWriter.outputArtifactXml(artifactDir, atf); // writer.outputArtifactXml(@"C:\WORK", atf); return(atf); }
private void addElementLabels(ElementVO elem) { int rowIndex = 0; string artifactsDir = ProjectSetting.getVO().projectPath + "\\" + ProjectSetting.getVO().artifactsPath; ArtifactXmlReader reader = new ArtifactXmlReader(artifactsDir); tableLayoutPanel1.RowCount = elem.attributes.Count + elem.methods.Count + elem.taggedValues.Count; foreach (AttributeVO attr in elem.attributes) { addAttributeBox(rowIndex, reader, attr); rowIndex++; } foreach (MethodVO mth in elem.methods) { addMethodBox(rowIndex, reader, mth); rowIndex++; } foreach (TaggedValueVO tgv in elem.taggedValues) { addTaggedValueBox(rowIndex, reader, tgv); rowIndex++; } }
public static bool outputElementXmlFile(ElementVO elem) { string outputDir = ProjectSetting.getVO().projectPath; bool retFlg = false; StreamWriter swe = null; try { // 要素XMLを出力するフォルダ (projectDir + /elements/ 配下) が存在するかを調べ、なければ作る string edir = outputDir + @"\elements\" + elem.guid.Substring(1, 1) + @"\" + elem.guid.Substring(2, 1); checkAndMakeElementDir(edir); //BOM無しのUTF8でテキストファイルを作成する swe = new StreamWriter(outputDir + @"\elements\" + elem.guid.Substring(1, 1) + @"\" + elem.guid.Substring(2, 1) + @"\" + elem.guid.Substring(1, 36) + ".xml"); swe.WriteLine(@"<?xml version=""1.0"" encoding=""UTF-8""?> "); // このStreamに対象の要素をXML出力する writeElementXml(elem, 0, swe); retFlg = true; } catch (Exception exp) { Console.WriteLine(exp.Message); } finally { if (swe != null) { swe.Close(); } } return(retFlg); }
/// <summary> /// detail の taggedValue XML (/detail/#taggedValue_${guid}_${LR}.xml) を読み、得られたVOを返却する /// /// </summary> /// <returns>MethodVO</returns> public TaggedValueVO readTaggedValueDiffDetail(string tagGuid, string leftRight) { string target_dir = ProjectSetting.getVO().projectPath; string fileName = target_dir + "/detail/" + "#taggedValue_" + tagGuid.Substring(1, 36) + "_" + leftRight + ".xml"; // 指定されたfileNameでファイルが存在しなかったらnullを返す if (!System.IO.File.Exists(fileName)) { return(null); } // XMLテキストをロードする XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); // taggedValues ノードに移動する XmlNode tvNode = xmlDoc.SelectSingleNode("tv"); if (tvNode != null) { return(ElementsXmlReader.readTaggedValue(tvNode)); } else { return(new TaggedValueVO()); } }
/// <summary> /// コンテキストメニュー:EAに反映 のクリックイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ReflectToEAToolStripMenuItemClick(object sender, EventArgs e) { EA.Repository repo = ProjectSetting.getVO().eaRepo; if (repo != null) { Control source = contextMenuStrip1.SourceControl; if (source != null) { if (source.Tag is AttributeVO) { AttributeVO att = (AttributeVO)source.Tag; confirmUpdateAttribute(repo, att); } else if (source.Tag is MethodVO) { MethodVO mth = (MethodVO)source.Tag; confirmUpdateMethod(repo, mth); } } } else { MessageBox.Show("EAにアタッチしていないため、反映できません"); } }
/// <summary> /// 一時保存ボタンのイベントハンドラ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void BtnCommitClick(object sender, EventArgs e) { string outputDir = ProjectSetting.getVO().projectPath; StreamWriter swe = null; try { //BOM無しのUTF8でテキストファイルを作成する swe = new StreamWriter(outputDir + @"\elements\" + myElement.guid.Substring(1, 36) + "_changed.xml"); swe.WriteLine(@"<?xml version=""1.0"" encoding=""UTF-8""?> "); ElementXmlWriter.writeElementXml(myElement, 0, swe); btnCommit.Enabled = false; } catch (Exception exp) { MessageBox.Show(exp.Message); } finally { if (swe != null) { swe.Close(); } } savedElement = myElement; //メッセージボックスを表示する MessageBox.Show("クラスの変更内容をローカルファイルに記録しました", "確認", MessageBoxButtons.OK, MessageBoxIcon.Information); // this.Close(); }
public void exportBehaviorText() { // 出力フォルダはプロジェクトファイルの配置パスとする string outputDir = ProjectSetting.getVO().projectPath; // 全成果物リストの読み込み string artifactDir = ProjectSetting.getVO().projectPath + "\\" + ProjectSetting.getVO().artifactsPath; ArtifactsVO allArtifacts = ArtifactsXmlReader.readAllArtifacts(artifactDir); // 成果物パッケージXMLファイル読み込み ArtifactXmlReader atfReader = new ArtifactXmlReader(artifactDir, true); for (int i = 0; i < allArtifacts.artifactList.Count; i++) { ArtifactVO atf = allArtifacts.artifactList[i]; // 成果物VOのPathNameより出力が必要と判断された場合 if (artifactPathNameIsValid(atf.pathName)) { // ルールに従い、GUIDから成果物ファイルの名称を取得 string artifactFileName = "atf_" + atf.guid.Substring(1, 36) + ".xml"; // 成果物ファイル名と出力フォルダを渡し、ふるまいテキストを出力させる outputIndexedBehaviorText(atfReader, artifactFileName, outputDir); Console.WriteLine("{0}:テキスト出力中 {1}", i + 1, artifactFileName); } } }
/// <summary> /// 成果物リストの読み込みとAsciidoc出力 /// </summary> /// <param name="elementMode"></param> /// <param name="repositoryVO"></param> private static void readArtifactsAndWriteAsciidocs(string projectFilePath, bool elementMode, string elementGuid) { // .bdprjファイルの読み込み ProjectSetting.load(projectFilePath); // Asciidocの出力モードによる分岐 if (elementMode) { // 要素1つ分のAsciidoc出力 } else { // 全成果物リストの読み込み string artifactDir = ProjectSetting.getVO().projectPath + "\\" + ProjectSetting.getVO().artifactsPath; ArtifactsVO allArtifacts = readAllArtifacts(artifactDir); // indexDb作成処理 // (Asciidoc出力処理の中でElementSearcherやConnectorSearcherを利用するため、 // indexDb未作成だとここでエラーになってしまっていた) makeIndexDbIfNotExist(allArtifacts); // 全成果物分のAsciidoc出力 outputAllArtifactAsciidoc(allArtifacts); // asciidocFilePath をセットした結果を AllArtifacts.xml ファイルに記録 AllArtifactsXmlWriter.outputAllArtifactsFile(artifactDir, allArtifacts); } }
public LoggerElementAccess(string projectPath, string dbName) { this.projectPath = projectPath; this.dbName = dbName; string dbFileName = ProjectSetting.getVO().projectPath + "\\" + ProjectSetting.getVO().dbName; this.conn = new SQLiteConnection("Data Source=" + dbFileName); }
public ArtifactXmlReader(string project_dir) { // 内部DBからの接続情報検索オブジェクトを生成 if (this.connSearcher == null && ProjectSetting.getVO() != null) { this.connSearcher = new ConnectorSearcher(); } this.projectPath = project_dir; }
public ConnectorXmlReader(string project_dir) { // string target_dir = ConfigurationManager.AppSettings["artifact_dir"]; // string target_file = "AllConnectorList.xml"; string fileName = project_dir + "\\" + ProjectSetting.getVO().allConnectorFile; // XMLテキストをロードする this.xmlDoc = new XmlDocument(); this.xmlDoc.Load(fileName); }
/// <summary> /// /// </summary> /// <param name="package"></param> /// <param name="sw"></param> /// <param name="packagePath"></param> private void writePackage(PackageVO package, StreamWriter sw, string packagePath) { string pathName = ""; if (packagePath != "") { pathName = packagePath + "/" + package.name; } else { pathName = package.name; } // 要素別AsciiDocファイルの出力先を指定 string elementsDir = ProjectSetting.getVO().projectPath + "\\elements"; // 直下に出力すべき要素が1つも存在しないパッケージは出力の対象外とする(ドキュメント内での項番も不要) if (countPrintableElement(package) > 0) { sw.WriteLine("## パッケージ: " + pathName); sw.WriteLine("// GUID: " + package.guid); sw.WriteLine(""); // このパッケージ直下にダイアグラムを持っていたら if (package.diagrams != null && package.diagrams.Count > 0) { foreach (DiagramVO diag in package.diagrams) { // writeDiagramData(diag, sw); writeDiagramPlantUml(diag, sw); } } foreach (ElementVO elem in package.elements) { if (elem.eaType == "Class" || elem.eaType == "Interface" || elem.eaType == "Enumeration" || elem.eaType == "UseCase" || elem.eaType == "Actor") { //ElementAsciidocWriter.writeElement(elem, sw); string relPath = ElementAsciidocWriter.doWrite(elementsDir, elem); writeElementInclude(sw, relPath); } } sw.WriteLine("<<<"); sw.WriteLine(""); } if (package.childPackageList != null && package.childPackageList.Count > 0) { foreach (PackageVO pkg in package.childPackageList) { writePackage(pkg, sw, pathName); } } }
void ContextMenuStrip1Opening(object sender, System.ComponentModel.CancelEventArgs e) { EA.Repository repo = ProjectSetting.getVO().eaRepo; if (repo != null) { contextMenuStrip1.Enabled = true; } else { contextMenuStrip1.Enabled = false; } }
/// <summary> /// メソッドのコンテキストメニューのオープン時イベントハンドラ(利用可否制御) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void MethodContextMenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e) { EA.Repository repo = ProjectSetting.getVO().eaRepo; if (repo != null) { focusEAMethodToolStripMenuItem.Enabled = true; } else { focusEAMethodToolStripMenuItem.Enabled = false; } }
/// <summary> /// 変更差分確認ボタンのクリックイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ButtonViewDiffClick(object sender, EventArgs e) { EA.Repository repo = ProjectSetting.getVO().eaRepo; EA.Element eaElemObj = (EA.Element)repo.GetElementByGuid(myElement.guid); ElementVO eaElement = ObjectEAConverter.getElementFromEAObject(eaElemObj); // 差分フォームを開く DiffElementForm diffForm = new DiffElementForm(eaElement, ref myElement); diffForm.ShowDialog(this); diffForm.Dispose(); }
public ArtifactAsciidocWriter(string asciidocDir) { string dbFilePath = ProjectSetting.getVO().projectPath + "\\" + ProjectSetting.getVO().dbName; this.elementSearcher = new ElementSearcher(dbFilePath); this.connSearcher = new ConnectorSearcher(dbFilePath); this.asciidocDir = asciidocDir; // Asciidoc出力フォルダの存在チェック&無ければ作成 makeAsciidocDirIfNotExist(asciidocDir); }
/// <summary> /// Index用データベース(SQLite)に、接続と要素(属性・操作)の情報を登録する /// </summary> public void doMakeIndex() { try { IndexDbWriter dbWriter = new IndexDbWriter(ProjectSetting.getVO().projectPath, ProjectSetting.getVO().dbName); dbWriter.writeAllConnector(this.allConnectors); dbWriter.writeAllElements(this.allArtifacts); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// GUIDを指定してEA上の属性オブジェクトを取得する /// </summary> /// <param name="attributeGuid">検索対象属性のGUID</param> /// <returns>合致するGUIDでヒットした属性オブジェクト。ヒットしなかったらnull</returns> private static EA.Attribute getAttributeByGuid(string attributeGuid) { EA.Repository repo = ProjectSetting.getVO().eaRepo; EA.Attribute attrObj = (EA.Attribute)repo.GetAttributeByGuid(attributeGuid); if (attrObj != null) { return(attrObj); } else { return(null); } }
/// <summary> /// クラスのコンテキストメニュー-「EAでこのクラスを選択」のクリックイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void FocusEAClassToolStripMenuItemClick(object sender, EventArgs e) { EA.Repository repo = ProjectSetting.getVO().eaRepo; if (repo != null) { EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid); if (elem != null) { repo.ShowInProjectView(elem); } } }
/// <summary> /// GUIDによりEAからメソッドオブジェクトを取得 /// </summary> /// <param name="methodGuid"></param> /// <returns></returns> private EA.Method getMethodByGuid(string methodGuid) { EA.Repository repo = ProjectSetting.getVO().eaRepo; EA.Method mthObj = (EA.Method)repo.GetMethodByGuid(methodGuid); if (mthObj != null) { return(mthObj); } else { return(null); } }
/// <summary> /// IndexDB情報の作成 /// </summary> private static void makeIndexDbIfNotExist(ArtifactsVO allArtifacts) { string indexDbFilePath = ProjectSetting.getVO().projectPath + "\\" + ProjectSetting.getVO().dbName; // IndexDBファイルが存在してないなら if (!File.Exists(indexDbFilePath)) { // Index情報未作成と見なして、IndexDB情報の作成処理を呼び出す IndexMaker indexMaker = new IndexMaker(allArtifacts, ProjectSetting.getVO().projectPath); indexMaker.doMakeIndex(); indexMaker.doMakeElementFiles(); } }
private void exportMethodCallingGraph(List <MethodVO> methods) { StreamWriter grphsw = null; string dbFileName = ProjectSetting.getVO().projectPath + "\\" + ProjectSetting.getVO().dbName; SQLiteConnection conn = new SQLiteConnection("Data Source=" + dbFileName); try { grphsw = new StreamWriter(outputDir + "\\" + "graphdata_l.dat", false, System.Text.Encoding.GetEncoding("utf-8")); conn.Open(); BehaviorParser parser = new BehaviorParser(); foreach (MethodVO mth in methods) { List <MethodCallingInfo> callingInfos = searchForMethodLinks(mth, conn, parser); foreach (MethodCallingInfo ci in callingInfos) { // Methodノードとのリレーション(:Call) の追加 grphsw.Write("MATCH (src:Method{id:" + ci.methodId + "}), "); grphsw.Write("(dst:Method{id:" + ci.destMethodId + "}) "); grphsw.WriteLine("CREATE (src)-[:Call{ row:" + ci.row + " }]->(dst)"); grphsw.WriteLine(";"); } } } catch (Exception ex) { Console.WriteLine("Message=" + ex.Message); Console.WriteLine(ex.StackTrace); Console.WriteLine("-------改行の入力で終了します"); Console.ReadLine(); } finally { if (grphsw != null) { grphsw.Close(); } if (conn != null) { conn.Close(); } } }