From 09ef924264d49f8cd322bd5b8d3109d2ad5ab202 Mon Sep 17 00:00:00 2001 From: hche10x Date: Thu, 7 Sep 2006 09:14:34 +0000 Subject: [PATCH] 1. Fix EDKT193 "Provide a Module tree when platform/package are open" 2. Fix bugs in Clone git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1497 6f19259b-4bc3-4df7-8a09-765794883524 --- .../org/tianocore/frameworkwizard/Clone.java | 27 +- .../frameworkwizard/FrameworkWizardUI.java | 333 ++++++++++++------ .../Identifications/OpeningFileType.java | 25 +- .../Identifications/OpeningModuleList.java | 78 ++-- .../Identifications/OpeningModuleType.java | 9 - .../Identifications/OpeningPackageList.java | 7 +- .../Identifications/OpeningPackageType.java | 9 - .../Identifications/OpeningPlatformList.java | 7 +- .../Identifications/OpeningPlatformType.java | 8 - .../common/ui/IDefaultMutableTreeNode.java | 178 +++------- .../frameworkwizard/common/ui/ITree.java | 105 +++--- .../workspace/WorkspaceTools.java | 36 +- 12 files changed, 448 insertions(+), 374 deletions(-) diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java index 8a6f90534f..97f16ce40c 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java @@ -36,6 +36,7 @@ import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea; import org.tianocore.frameworkwizard.common.DataType; import org.tianocore.frameworkwizard.common.DataValidation; import org.tianocore.frameworkwizard.common.FileOperation; +import org.tianocore.frameworkwizard.common.GlobalData; import org.tianocore.frameworkwizard.common.IFileFilter; import org.tianocore.frameworkwizard.common.Log; import org.tianocore.frameworkwizard.common.OpenFile; @@ -752,7 +753,7 @@ public class Clone extends IDialog { // Update Section // updateModuleClonedId(msa, oldId); - + // // Save to file // @@ -774,6 +775,12 @@ public class Clone extends IDialog { // Update the db file // wt.addModuleToPackage(mid, psa); + + // + // Update GlobalData + // + GlobalData.vModuleList.addElement(mid); + GlobalData.openingModuleList.insertToOpeningModuleList(mid, msa); this.returnType = DataType.RETURN_TYPE_MODULE_SURFACE_AREA; } @@ -831,7 +838,13 @@ public class Clone extends IDialog { // Update the db file // wt.addPackageToDatabase(pid); - + + // + // Update GlobalData + // + GlobalData.vPackageList.addElement(pid); + GlobalData.openingPackageList.insertToOpeningPackageList(pid, spd); + this.returnType = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA; } @@ -868,6 +881,12 @@ public class Clone extends IDialog { // Update the db file // wt.addPlatformToDatabase(fid); + + // + // Update GlobalData + // + GlobalData.vPlatformList.addElement(fid); + GlobalData.openingPlatformList.insertToOpeningPlatformList(fid, fpd); this.returnType = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA; } @@ -1016,7 +1035,7 @@ public class Clone extends IDialog { c.setPackageGuid(id.getGuid()); c.setPackageVersion(id.getVersion()); c.setId(count.add(new BigInteger("1"))); - String guid = wt.getModuleFarGuid(oldId); + String guid = wt.getPackageFarGuid(oldId); if (guid != null && !guid.equals("")) { c.setFarGuid(guid); } @@ -1072,7 +1091,7 @@ public class Clone extends IDialog { c.setPlatformGuid(id.getGuid()); c.setPlatformVersion(id.getVersion()); c.setId(count.add(new BigInteger("1"))); - String guid = wt.getModuleFarGuid(oldId); + String guid = wt.getPlatformFarGuid(oldId); if (guid != null && !guid.equals("")) { c.setFarGuid(guid); } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java index 59bb752fa9..b159fe4d62 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java @@ -23,6 +23,8 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.WindowEvent; import java.io.IOException; +import java.util.Iterator; +import java.util.Set; import java.util.Vector; import javax.swing.JButton; @@ -43,6 +45,7 @@ import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.TreePath; import org.apache.xmlbeans.XmlException; import org.tianocore.PackageSurfaceAreaDocument; @@ -1934,12 +1937,13 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // // Make root // - dmtnRoot = new IDefaultMutableTreeNode("WORKSPACE", IDefaultMutableTreeNode.WORKSPACE, -1); + dmtnRoot = new IDefaultMutableTreeNode("WORKSPACE", IDefaultMutableTreeNode.WORKSPACE, false, null, null); // // Make Module Description // - dmtnModuleDescription = new IDefaultMutableTreeNode("Modules", IDefaultMutableTreeNode.MODULE, -1); + dmtnModuleDescription = new IDefaultMutableTreeNode("Modules", IDefaultMutableTreeNode.MODULE_DESCRIPTION, + false, null, dmtnRoot); // // First add package @@ -1952,13 +1956,16 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe dmtnModulePackage = new IDefaultMutableTreeNode(GlobalData.vPackageList.elementAt(index).getName(), IDefaultMutableTreeNode.MODULE_PACKAGE, false, - GlobalData.vPackageList.elementAt(index)); + GlobalData.vPackageList.elementAt(index), + this.dmtnModuleDescription); dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library", IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, - false, GlobalData.vPackageList.elementAt(index)); + false, GlobalData.vPackageList.elementAt(index), + this.dmtnModuleDescription); dmtnModulePackageModule = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE, - false, GlobalData.vPackageList.elementAt(index)); + false, GlobalData.vPackageList.elementAt(index), + this.dmtnModuleDescription); // // And then add each module in its package // @@ -1967,11 +1974,13 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe if (vModule.get(indexJ).isLibrary()) { dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), IDefaultMutableTreeNode.MODULE, false, - vModule.get(indexJ))); + vModule.get(indexJ), + this.dmtnModuleDescription)); } else { dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), IDefaultMutableTreeNode.MODULE, false, - vModule.get(indexJ))); + vModule.get(indexJ), + this.dmtnModuleDescription)); } } if (dmtnModulePackageModule.getChildCount() > 0) { @@ -1988,26 +1997,31 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // // Make Package Description // - dmtnPackageDescription = new IDefaultMutableTreeNode("Packages", IDefaultMutableTreeNode.PACKAGE, -1); + dmtnPackageDescription = new IDefaultMutableTreeNode("Packages", IDefaultMutableTreeNode.PACKAGE_DESCRIPTION, + false, null, this.dmtnRoot); if (GlobalData.vPackageList.size() > 0) { for (int index = 0; index < GlobalData.vPackageList.size(); index++) { dmtnPackageDescription.add(new IDefaultMutableTreeNode(GlobalData.vPackageList.elementAt(index) .getName(), IDefaultMutableTreeNode.PACKAGE, false, - GlobalData.vPackageList.elementAt(index))); + GlobalData.vPackageList.elementAt(index), + this.dmtnPackageDescription)); } } // // Make Platform Description // - dmtnPlatformDescription = new IDefaultMutableTreeNode("Platforms", IDefaultMutableTreeNode.PLATFORM, -1); + dmtnPlatformDescription = new IDefaultMutableTreeNode("Platforms", + IDefaultMutableTreeNode.PLATFORM_DESCRIPTION, false, + null, this.dmtnRoot); if (GlobalData.vPlatformList.size() > 0) { for (int index = 0; index < GlobalData.vPlatformList.size(); index++) { dmtnPlatformDescription.add(new IDefaultMutableTreeNode(GlobalData.vPlatformList.elementAt(index) .getName(), IDefaultMutableTreeNode.PLATFORM, false, - GlobalData.vPlatformList.elementAt(index))); + GlobalData.vPlatformList.elementAt(index), + this.dmtnPlatformDescription)); } } @@ -2040,10 +2054,6 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe * */ public void mouseClicked(MouseEvent arg0) { - if (arg0.getButton() == MouseEvent.BUTTON1) { - } - if (arg0.getButton() == MouseEvent.BUTTON3) { - } // // When double click // @@ -2141,8 +2151,8 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // // Add new MsaHeader node to the tree // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(mid.getName(), IDefaultMutableTreeNode.MODULE, true, - mid); + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(mid.getName(), IDefaultMutableTreeNode.MODULE, + false, mid, this.dmtnModuleDescription); // // First find the module belongs to which package // @@ -2176,7 +2186,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // if (!hasModule) { parentModuleNode = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE, - false, mid.getPackageId()); + false, mid.getPackageId(), this.dmtnModuleDescription); iTree.addNode(packageNode, parentModuleNode); } @@ -2193,7 +2203,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe if (!hasLibrary) { parentLibraryNode = new IDefaultMutableTreeNode("Library", IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, false, - mid.getPackageId()); + mid.getPackageId(), this.dmtnModuleDescription); iTree.addNode(packageNode, parentLibraryNode); } @@ -2207,7 +2217,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe @param path input file path **/ - private void openModule(String path) { + private void openModule(String path, IDefaultMutableTreeNode belongNode) { ModuleIdentification id = GlobalData.openingModuleList.getIdByPath(path); if (id == null) { // @@ -2220,29 +2230,33 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // // Make the node selected // - iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, - IDefaultMutableTreeNode.MODULE))); + iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(belongNode, id, IDefaultMutableTreeNode.MODULE))); + // // Update opening Module list information // - if (!GlobalData.openingModuleList.getModuleOpen(id)) { + if (!iTree.getSelectNode().isOpening()) { // // Insert sub node of module // - insertModuleTreeNode(id); + insertModuleTreeNode(id, belongNode); iTree.getSelectNode().setOpening(true); // // Update opening module list // GlobalData.openingModuleList.setModuleOpen(id, true); - GlobalData.openingModuleList.setTreePathById(id, iTree.getSelectionPath()); + Set temp = GlobalData.openingModuleList.getTreePathById(id); + temp.add(iTree.getSelectionPath()); + GlobalData.openingModuleList.setTreePathById(id, temp); } // // Select msa header node and show it in editor panel // - iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, - IDefaultMutableTreeNode.MSA_HEADER))); + iTree + .setSelectionPath(iTree + .getPathOfNode(iTree + .getNodeById(belongNode, id, IDefaultMutableTreeNode.MSA_HEADER))); showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, GlobalData.openingModuleList.getOpeningModuleById(id)); this.currentOpeningModuleIndex = GlobalData.openingModuleList.findIndexOfListById(id); } @@ -2282,7 +2296,9 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // Update opening module list // GlobalData.openingPackageList.setPackageOpen(id, true); - GlobalData.openingPackageList.setTreePathById(id, iTree.getSelectionPath()); + Set temp = GlobalData.openingPackageList.getTreePathById(id); + temp.add(iTree.getSelectionPath()); + GlobalData.openingPackageList.setTreePathById(id, temp); } // // Show spd header in editor panel @@ -2328,7 +2344,9 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // Update opening module list // GlobalData.openingPlatformList.setPlatformOpen(id, true); - GlobalData.openingPlatformList.setTreePathById(id, iTree.getSelectionPath()); + Set temp = GlobalData.openingPlatformList.getTreePathById(id); + temp.add(iTree.getSelectionPath()); + GlobalData.openingPlatformList.setTreePathById(id, temp); } // // Show fpd header in editor panel @@ -2433,56 +2451,136 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe } } - private void insertModuleTreeNode(Identification id) { - iTree.addNode(new IDefaultMutableTreeNode("Module Header", IDefaultMutableTreeNode.MSA_HEADER, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id)); + private void insertModuleTreeNode(Identification id, IDefaultMutableTreeNode belongNode) { + iTree.addNode(new IDefaultMutableTreeNode("Module Header", IDefaultMutableTreeNode.MSA_HEADER, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id, + belongNode)); iTree.addNode(new IDefaultMutableTreeNode("Library Class Definitions", - IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Package Dependencies", - IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Protocols", IDefaultMutableTreeNode.MSA_PROTOCOLS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Events", IDefaultMutableTreeNode.MSA_EVENTS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Hobs", IDefaultMutableTreeNode.MSA_HOBS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Ppis", IDefaultMutableTreeNode.MSA_PPIS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Variables", IDefaultMutableTreeNode.MSA_VARIABLES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Boot Modes", IDefaultMutableTreeNode.MSA_BOOTMODES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("System Tables", IDefaultMutableTreeNode.MSA_SYSTEMTABLES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Data Hubs", IDefaultMutableTreeNode.MSA_DATAHUBS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Hii Packages", IDefaultMutableTreeNode.MSA_HIIPACKAGES, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Guids", IDefaultMutableTreeNode.MSA_GUIDS, true, id)); + IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS, true, id, + belongNode)); iTree - .addNode(new IDefaultMutableTreeNode("External Defintions", IDefaultMutableTreeNode.MSA_EXTERNS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Pcd Coded", IDefaultMutableTreeNode.MSA_PCDS, true, id)); + .addNode(new IDefaultMutableTreeNode("Package Dependencies", + IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES, true, id, belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Protocols", IDefaultMutableTreeNode.MSA_PROTOCOLS, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Events", IDefaultMutableTreeNode.MSA_EVENTS, true, id, belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Hobs", IDefaultMutableTreeNode.MSA_HOBS, true, id, belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Ppis", IDefaultMutableTreeNode.MSA_PPIS, true, id, belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Variables", IDefaultMutableTreeNode.MSA_VARIABLES, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Boot Modes", IDefaultMutableTreeNode.MSA_BOOTMODES, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("System Tables", IDefaultMutableTreeNode.MSA_SYSTEMTABLES, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Data Hubs", IDefaultMutableTreeNode.MSA_DATAHUBS, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Hii Packages", IDefaultMutableTreeNode.MSA_HIIPACKAGES, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Guids", IDefaultMutableTreeNode.MSA_GUIDS, true, id, belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("External Defintions", IDefaultMutableTreeNode.MSA_EXTERNS, true, id, + belongNode)); + iTree.addNode(new IDefaultMutableTreeNode("Pcd Coded", IDefaultMutableTreeNode.MSA_PCDS, true, id, belongNode)); } private void insertPackageTreeNode(Identification id) { - iTree.addNode(new IDefaultMutableTreeNode("Package Header", IDefaultMutableTreeNode.SPD_HEADER, true, id)); + IDefaultMutableTreeNode idmtTemp = this.dmtnPackageDescription; + iTree.addNode(new IDefaultMutableTreeNode("Package Header", IDefaultMutableTreeNode.SPD_HEADER, true, id, + idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Library Class Declarations", - IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Msa Files", IDefaultMutableTreeNode.SPD_MSAFILES, false, id)); + IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS, true, id, + idmtTemp)); + iTree.addNode(new IDefaultMutableTreeNode("Msa Files", IDefaultMutableTreeNode.SPD_MSAFILES, false, id, + idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Package Includes", IDefaultMutableTreeNode.SPD_PACKAGEHEADERS, true, - id)); + id, idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Guid Declarations", IDefaultMutableTreeNode.SPD_GUIDDECLARATIONS, - true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Protocol Declarations", - IDefaultMutableTreeNode.SPD_PROTOCOLDECLARATIONS, true, id)); + true, id, idmtTemp)); + iTree + .addNode(new IDefaultMutableTreeNode("Protocol Declarations", + IDefaultMutableTreeNode.SPD_PROTOCOLDECLARATIONS, true, id, idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Ppi Declarations", IDefaultMutableTreeNode.SPD_PPIDECLARATIONS, - true, id)); + true, id, idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Pcd Declarations", IDefaultMutableTreeNode.SPD_PCDDECLARATIONS, - true, id)); + true, id, idmtTemp)); + // + // Add modules in this package + // + IDefaultMutableTreeNode dmtnModulePackageLibrary = null; + IDefaultMutableTreeNode dmtnModulePackageModule = null; + + dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library", + IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, false, + id, idmtTemp); + dmtnModulePackageModule = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE, + false, id, idmtTemp); + + Vector vModule = wt.getAllModules(new PackageIdentification(id)); + for (int indexJ = 0; indexJ < vModule.size(); indexJ++) { + if (vModule.get(indexJ).isLibrary()) { + dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ), idmtTemp)); + } else { + dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ), idmtTemp)); + } + } + if (dmtnModulePackageModule.getChildCount() > 0) { + iTree.addNode(dmtnModulePackageModule); + } + if (dmtnModulePackageLibrary.getChildCount() > 0) { + iTree.addNode(dmtnModulePackageLibrary); + } } private void insertPlatformTreeNode(Identification id) { + IDefaultMutableTreeNode idmtTemp = this.dmtnPlatformDescription; iTree.addNode(new IDefaultMutableTreeNode("Platform Header", IDefaultMutableTreeNode.FPD_PLATFORMHEADER, true, - id)); + id, idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Platform Definitions", - IDefaultMutableTreeNode.FPD_PLATFORMDEFINITIONS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Flash Information", IDefaultMutableTreeNode.FPD_FLASH, true, id)); + IDefaultMutableTreeNode.FPD_PLATFORMDEFINITIONS, true, id, idmtTemp)); + iTree.addNode(new IDefaultMutableTreeNode("Flash Information", IDefaultMutableTreeNode.FPD_FLASH, true, id, + idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Framework Modules", IDefaultMutableTreeNode.FPD_FRAMEWORKMODULES, - true, id)); + true, id, idmtTemp)); iTree.addNode(new IDefaultMutableTreeNode("Dynamic PCD Build Declarations", - IDefaultMutableTreeNode.FPD_PCDDYNAMICBUILDDECLARATIONS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Build Options", IDefaultMutableTreeNode.FPD_BUILDOPTIONS, true, id)); + IDefaultMutableTreeNode.FPD_PCDDYNAMICBUILDDECLARATIONS, true, id, + idmtTemp)); + iTree.addNode(new IDefaultMutableTreeNode("Build Options", IDefaultMutableTreeNode.FPD_BUILDOPTIONS, true, id, + idmtTemp)); + + // + // Add modules in this platform + // + IDefaultMutableTreeNode dmtnModulePackageLibrary = null; + IDefaultMutableTreeNode dmtnModulePackageModule = null; + + dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library", + IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, false, + id, idmtTemp); + dmtnModulePackageModule = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE, + false, id, idmtTemp); + + Vector vModule = wt.getAllModules(new PlatformIdentification(id)); + for (int indexJ = 0; indexJ < vModule.size(); indexJ++) { + if (vModule.get(indexJ).isLibrary()) { + dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ), idmtTemp)); + } else { + dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ), idmtTemp)); + } + } + if (dmtnModulePackageModule.getChildCount() > 0) { + iTree.addNode(dmtnModulePackageModule); + } + if (dmtnModulePackageLibrary.getChildCount() > 0) { + iTree.addNode(dmtnModulePackageLibrary); + } } /** @@ -2493,10 +2591,12 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe Identification id = null; int intCategory = -1; String path = null; + IDefaultMutableTreeNode belongNode = null; try { id = iTree.getSelectNode().getId(); intCategory = iTree.getSelectCategory(); + belongNode = iTree.getSelectNode().getBelongNode(); // // If id is null, return directly @@ -2510,14 +2610,8 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // Insert top level elements first // if (intCategory == IDefaultMutableTreeNode.MODULE) { - - if (intCategory == IDefaultMutableTreeNode.MODULE) { - path = iTree.getSelectNode().getId().getPath(); - } - if (intCategory == IDefaultMutableTreeNode.PACKAGE) { - path = iTree.getSelectNode().getId().getPath(); - } - openModule(path); + path = iTree.getSelectNode().getId().getPath(); + openModule(path, belongNode); return; } if (intCategory == IDefaultMutableTreeNode.PACKAGE) { @@ -2558,8 +2652,9 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe .findIndexOfListById(new PlatformIdentification( id)); } - } catch (RuntimeException e) { + } catch (Exception e) { Log.err("double click category: " + intCategory); + Log.err("double click belong node: " + belongNode.toString()); Log.err("double click id path: " + id); Log.err("double click exception: " + e.getMessage()); } @@ -2801,7 +2896,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // // Open the node // - this.openModule(mid.getPath()); + this.openModule(mid.getPath(), this.dmtnModuleDescription); } } } else if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { @@ -2835,14 +2930,15 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(pid.getName(), IDefaultMutableTreeNode.MODULE_PACKAGE, - false, pid); + false, pid, this.dmtnModuleDescription); iTree.addNode(dmtnModuleDescription, node); // // Add new SpdHeader node to the tree // - node = new IDefaultMutableTreeNode(pid.getName(), IDefaultMutableTreeNode.PACKAGE, true, pid); + node = new IDefaultMutableTreeNode(pid.getName(), IDefaultMutableTreeNode.PACKAGE, true, pid, + this.dmtnPackageDescription); iTree.addNode(dmtnPackageDescription, node); this.openPackage(pid.getPath()); @@ -2878,7 +2974,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe // IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(fid.getName(), IDefaultMutableTreeNode.PLATFORM, true, - fid); + fid, this.dmtnPlatformDescription); iTree.addNode(dmtnPlatformDescription, node); this.openPlatform(fid.getPath()); } @@ -2907,7 +3003,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe String path = fc.getSelectedFile().getPath(); String match = path.substring(path.length() - 4); if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.MODULE_SURFACE_AREA_EXT)) { - openModule(path); + openModule(path, this.dmtnModuleDescription); } else if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.PACKAGE_SURFACE_AREA_EXT)) { openPackage(path); } else if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.PLATFORM_SURFACE_AREA_EXT)) { @@ -2921,6 +3017,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe **/ private void close() { + TreePath item = null; switch (this.jTabbedPaneEditor.getSelectedIndex()) { // // Current is module @@ -2939,9 +3036,19 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe return; } } - iTree - .removeNodeChildrenByPath(GlobalData.openingModuleList - .getTreePathByIndex(currentOpeningModuleIndex)); + + // + // Remove all tree paths for the module + // + Set openingTreePaths = GlobalData.openingModuleList + .getTreePathByIndex(currentOpeningModuleIndex); + Iterator openingTreePathsIter = openingTreePaths.iterator(); + while (openingTreePathsIter.hasNext()) { + item = openingTreePathsIter.next(); + iTree.getNodeByPath(item).setOpening(false); + iTree.removeNodeChildrenByPath(item); + } + GlobalData.openingModuleList.setModuleOpen(this.currentOpeningModuleIndex, false); this.cleanDesktopPaneModule(); this.currentOpeningModuleIndex = -1; @@ -2964,9 +3071,19 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe return; } } - iTree - .removeNodeChildrenByPath(GlobalData.openingPackageList - .getTreePathByIndex(currentOpeningPackageIndex)); + + // + // Remove all tree paths for the module + // + Set openingTreePaths = GlobalData.openingPackageList + .getTreePathByIndex(currentOpeningPackageIndex); + Iterator openingTreePathsIter = openingTreePaths.iterator(); + while (openingTreePathsIter.hasNext()) { + item = openingTreePathsIter.next(); + iTree.getNodeByPath(item).setOpening(false); + iTree.removeNodeChildrenByPath(item); + } + GlobalData.openingPackageList.setPackageOpen(this.currentOpeningPackageIndex, false); this.cleanDesktopPanePackage(); this.currentOpeningPackageIndex = -1; @@ -2989,9 +3106,19 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe return; } } - iTree - .removeNodeChildrenByPath(GlobalData.openingPlatformList - .getTreePathByIndex(currentOpeningPlatformIndex)); + + // + // Remove all tree paths for the module + // + Set openingTreePaths = GlobalData.openingPlatformList + .getTreePathByIndex(currentOpeningPlatformIndex); + Iterator openingTreePathsIter = openingTreePaths.iterator(); + while (openingTreePathsIter.hasNext()) { + item = openingTreePathsIter.next(); + iTree.getNodeByPath(item).setOpening(false); + iTree.removeNodeChildrenByPath(item); + } + GlobalData.openingPlatformList.setPlatformOpen(this.currentOpeningPlatformIndex, false); this.cleanDesktopPanePlatform(); this.currentOpeningPlatformIndex = -1; @@ -3292,23 +3419,20 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe } int category = iTree.getSelectCategory(); Identification id = iTree.getSelectNode().getId(); - if (category == IDefaultMutableTreeNode.MODULE || category == IDefaultMutableTreeNode.PACKAGE - || category == IDefaultMutableTreeNode.PLATFORM) { - Log.wrn("Clone", "Please select a target to clone!"); - return; - } if (category == IDefaultMutableTreeNode.WORKSPACE) { mode = DataType.RETURN_TYPE_WORKSPACE; id = null; } - if (category >= IDefaultMutableTreeNode.MSA_HEADER && category < IDefaultMutableTreeNode.SPD_HEADER) { + if ((category == IDefaultMutableTreeNode.MODULE) + || (category >= IDefaultMutableTreeNode.MSA_HEADER && category < IDefaultMutableTreeNode.SPD_HEADER)) { mode = DataType.RETURN_TYPE_MODULE_SURFACE_AREA; } - if (category >= IDefaultMutableTreeNode.SPD_HEADER && category < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { + if ((category == IDefaultMutableTreeNode.PACKAGE) + || (category >= IDefaultMutableTreeNode.SPD_HEADER && category < IDefaultMutableTreeNode.FPD_PLATFORMHEADER)) { mode = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA; } - if (category >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { + if ((category == IDefaultMutableTreeNode.PLATFORM) || (category >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER)) { mode = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA; } @@ -3323,32 +3447,30 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe } if (result == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) { Tools.showInformationMessage("Module Clone Completed!"); - GlobalData.vModuleList.addElement(c.getMid()); addModuleToTree(c.getMid()); } if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { Tools.showInformationMessage("Package Clone Completed!"); - GlobalData.vPackageList.addElement(c.getPid()); // // Add new SpdHeader node to the tree // IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(GlobalData.vPackageList.lastElement().getName(), - IDefaultMutableTreeNode.SPD_HEADER, true, - GlobalData.vPackageList.lastElement()); - iTree.addNode(dmtnPackageDescription, node); + IDefaultMutableTreeNode.PACKAGE, false, + GlobalData.vPackageList.lastElement(), + this.dmtnPackageDescription); + iTree.addNode(this.dmtnPackageDescription, node); } if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { Tools.showInformationMessage("Platform Surface Area Clone Finished"); - GlobalData.vPlatformList.addElement(c.getFid()); // // Add new SpdHeader node to the tree // IDefaultMutableTreeNode node = new IDefaultMutableTreeNode( GlobalData.vPlatformList.lastElement().getName(), - IDefaultMutableTreeNode.FPD_PLATFORMHEADER, - true, GlobalData.vPlatformList.lastElement()); - iTree.addNode(dmtnPlatformDescription, node); - //this.openPlatform(c.getFid().getPath()); + IDefaultMutableTreeNode.PLATFORM, + false, GlobalData.vPlatformList.lastElement(), + this.dmtnPlatformDescription); + iTree.addNode(this.dmtnPlatformDescription, node); } if (result == DataType.RETURN_TYPE_OK) { @@ -3401,8 +3523,9 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe jMenuItemToolsClone.setEnabled(false); } else { int category = iTree.getSelectCategory(); - if (category == IDefaultMutableTreeNode.MODULE || category == IDefaultMutableTreeNode.PACKAGE - || category == IDefaultMutableTreeNode.PLATFORM + if (category == IDefaultMutableTreeNode.MODULE_DESCRIPTION + || category == IDefaultMutableTreeNode.PACKAGE_DESCRIPTION + || category == IDefaultMutableTreeNode.PLATFORM_DESCRIPTION || category == IDefaultMutableTreeNode.MODULE_PACKAGE || category == IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY || category == IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE) { diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningFileType.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningFileType.java index 14890286ca..9811c19868 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningFileType.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningFileType.java @@ -15,6 +15,9 @@ package org.tianocore.frameworkwizard.common.Identifications; +import java.util.LinkedHashSet; +import java.util.Set; + import javax.swing.tree.TreePath; @@ -28,15 +31,11 @@ public class OpeningFileType { private boolean isOpen = false; - private TreePath treePath = null; + private Set treePath = new LinkedHashSet(); public OpeningFileType() { } - - public OpeningFileType(TreePath treePathValue) { - this.treePath = treePathValue; - } public boolean isNew() { return isNew; @@ -54,14 +53,6 @@ public class OpeningFileType { this.isSaved = isSaved; } - public TreePath getTreePath() { - return treePath; - } - - public void setTreePath(TreePath treePath) { - this.treePath = treePath; - } - public boolean isOpen() { return isOpen; } @@ -69,4 +60,12 @@ public class OpeningFileType { public void setOpen(boolean isOpen) { this.isOpen = isOpen; } + + public Set getTreePath() { + return treePath; + } + + public void setTreePath(Set treePath) { + this.treePath = treePath; + } } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningModuleList.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningModuleList.java index eab8d2a824..df52b8a34d 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningModuleList.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningModuleList.java @@ -14,6 +14,7 @@ **/ package org.tianocore.frameworkwizard.common.Identifications; +import java.util.Set; import java.util.Vector; import javax.swing.tree.TreePath; @@ -27,6 +28,7 @@ public class OpeningModuleList { public OpeningModuleList() { } + public Vector getVOpeningModuleList() { return vOpeningModuleList; } @@ -34,18 +36,18 @@ public class OpeningModuleList { public void setVOpeningModuleList(Vector openingModuleList) { vOpeningModuleList = openingModuleList; } - + public void insertToOpeningModuleList(ModuleIdentification id, ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa) { vOpeningModuleList.addElement(new OpeningModuleType(id, xmlMsa)); } - + public OpeningModuleType getOpeningModuleByIndex(int index) { if (index > -1 && index < vOpeningModuleList.size()) { return vOpeningModuleList.elementAt(index); } return null; } - + public OpeningModuleType getOpeningModuleById(ModuleIdentification id) { int index = findIndexOfListById(id); if (index > -1) { @@ -53,7 +55,7 @@ public class OpeningModuleList { } return null; } - + public int findIndexOfListById(ModuleIdentification id) { for (int index = 0; index < vOpeningModuleList.size(); index++) { if (vOpeningModuleList.elementAt(index).getId().equals(id)) { @@ -62,24 +64,24 @@ public class OpeningModuleList { } return -1; } - + public void removeFromOpeningModuleListByIndex(int index) { if (index > -1 && index < vOpeningModuleList.size()) { vOpeningModuleList.removeElementAt(index); } } - + public void removeFromOpeningModuleListById(ModuleIdentification id) { int index = findIndexOfListById(id); if (index > -1) { vOpeningModuleList.removeElementAt(findIndexOfListById(id)); } } - + public void removeAllFromOpeningModuleList() { vOpeningModuleList.removeAllElements(); } - + public ModuleSurfaceAreaDocument.ModuleSurfaceArea getModuleSurfaceAreaFromId(ModuleIdentification id) { int index = findIndexOfListById(id); if (index > -1) { @@ -87,7 +89,7 @@ public class OpeningModuleList { } return null; } - + public boolean existsModule(ModuleIdentification id) { int index = findIndexOfListById(id); if (index > -1) { @@ -95,71 +97,71 @@ public class OpeningModuleList { } return false; } - + public void setModuleSaved(ModuleIdentification id, boolean isSaved) { setModuleSaved(findIndexOfListById(id), isSaved); } - + public void setModuleSaved(int index, boolean isSaved) { if (index > -1) { vOpeningModuleList.elementAt(index).setSaved(isSaved); } } - + public boolean getModuleSaved(ModuleIdentification id) { return getModuleSaved(findIndexOfListById(id)); } - + public boolean getModuleSaved(int index) { if (index > -1) { return vOpeningModuleList.elementAt(index).isSaved(); } return true; } - + public void setModuleOpen(ModuleIdentification id, boolean isOpen) { setModuleOpen(findIndexOfListById(id), isOpen); } - + public void setModuleOpen(int index, boolean isOpen) { if (index > -1) { vOpeningModuleList.elementAt(index).setOpen(isOpen); } } - + public boolean getModuleOpen(ModuleIdentification id) { return getModuleOpen(findIndexOfListById(id)); } - + public boolean getModuleOpen(int index) { if (index > -1) { return vOpeningModuleList.elementAt(index).isOpen(); } return true; } - - public void setTreePathById(ModuleIdentification id, TreePath treePath) { + + public void setTreePathById(ModuleIdentification id, Set treePath) { int index = findIndexOfListById(id); if (index > -1) { vOpeningModuleList.elementAt(index).setTreePath(treePath); } } - - public TreePath getTreePathById(ModuleIdentification id) { + + public Set getTreePathById(ModuleIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningModuleList.elementAt(index).getTreePath(); } return null; } - - public TreePath getTreePathByIndex(int index) { + + public Set getTreePathByIndex(int index) { if (index > -1) { return vOpeningModuleList.elementAt(index).getTreePath(); } return null; } - + public ModuleIdentification getIdByPath(String path) { ModuleIdentification id = new ModuleIdentification(null, null, null, path); int index = findIndexOfListById(id); @@ -168,24 +170,40 @@ public class OpeningModuleList { } return null; } - + + public ModuleIdentification getIdByGuidVersion(String guid, String version) { + for (int index = 0; index < vOpeningModuleList.size(); index++) { + ModuleIdentification id = vOpeningModuleList.elementAt(index).getId(); + if (version != null) { + if (id.getGuid().equals(guid) && id.getVersion().equals(version)) { + return id; + } + } else { + if (id.getGuid().equals(guid)) { + return id; + } + } + } + return null; + } + public void setNew(ModuleIdentification id, boolean isNew) { int index = findIndexOfListById(id); if (index > -1) { vOpeningModuleList.elementAt(index).setNew(isNew); } } - + public void closeAll() { for (int index = 0; index < this.size(); index++) { - this.setModuleOpen(index, false); + this.setModuleOpen(index, false); } } - + public int size() { return vOpeningModuleList.size(); } - + public boolean isSaved() { for (int index = 0; index < this.size(); index++) { if (!this.getModuleSaved(index)) { @@ -194,7 +212,7 @@ public class OpeningModuleList { } return true; } - + public boolean isOpen() { for (int index = 0; index < this.size(); index++) { if (this.getModuleOpen(index)) { diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningModuleType.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningModuleType.java index 2ead77a84f..427549ade7 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningModuleType.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningModuleType.java @@ -15,8 +15,6 @@ package org.tianocore.frameworkwizard.common.Identifications; -import javax.swing.tree.TreePath; - import org.tianocore.ModuleSurfaceAreaDocument; import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; @@ -36,13 +34,6 @@ public class OpeningModuleType extends OpeningFileType{ this.id = identification; this.xmlMsa = msa; } - - public OpeningModuleType(ModuleIdentification identification, ModuleSurfaceAreaDocument.ModuleSurfaceArea msa, TreePath treePath) { - super(treePath); - - this.id = identification; - this.xmlMsa = msa; - } public ModuleSurfaceAreaDocument.ModuleSurfaceArea getXmlMsa() { return xmlMsa; diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPackageList.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPackageList.java index b53a5bd89c..dc71bbc194 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPackageList.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPackageList.java @@ -14,6 +14,7 @@ **/ package org.tianocore.frameworkwizard.common.Identifications; +import java.util.Set; import java.util.Vector; import javax.swing.tree.TreePath; @@ -139,14 +140,14 @@ public class OpeningPackageList { return true; } - public void setTreePathById(PackageIdentification id, TreePath treePath) { + public void setTreePathById(PackageIdentification id, Set treePath) { int index = findIndexOfListById(id); if (index > -1) { vOpeningPackageList.elementAt(index).setTreePath(treePath); } } - public TreePath getTreePathById(PackageIdentification id) { + public Set getTreePathById(PackageIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningPackageList.elementAt(index).getTreePath(); @@ -154,7 +155,7 @@ public class OpeningPackageList { return null; } - public TreePath getTreePathByIndex(int index) { + public Set getTreePathByIndex(int index) { if (index > -1) { return vOpeningPackageList.elementAt(index).getTreePath(); } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPackageType.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPackageType.java index 51ca083f46..66d749e266 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPackageType.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPackageType.java @@ -14,8 +14,6 @@ **/ package org.tianocore.frameworkwizard.common.Identifications; -import javax.swing.tree.TreePath; - import org.tianocore.PackageSurfaceAreaDocument; import org.tianocore.frameworkwizard.packaging.PackageIdentification; @@ -35,13 +33,6 @@ public class OpeningPackageType extends OpeningFileType { this.id = identification; this.xmlSpd = spd; } - - public OpeningPackageType(PackageIdentification identification, PackageSurfaceAreaDocument.PackageSurfaceArea spd, TreePath treePath) { - super(treePath); - - this.id = identification; - this.xmlSpd = spd; - } public PackageSurfaceAreaDocument.PackageSurfaceArea getXmlSpd() { return xmlSpd; diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPlatformList.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPlatformList.java index 343d8ee6fc..40275e9eb3 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPlatformList.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPlatformList.java @@ -14,6 +14,7 @@ **/ package org.tianocore.frameworkwizard.common.Identifications; +import java.util.Set; import java.util.Vector; import javax.swing.tree.TreePath; @@ -141,14 +142,14 @@ public class OpeningPlatformList { return true; } - public void setTreePathById(PlatformIdentification id, TreePath treePath) { + public void setTreePathById(PlatformIdentification id, Set treePath) { int index = findIndexOfListById(id); if (index > -1) { vOpeningPlatformList.elementAt(index).setTreePath(treePath); } } - public TreePath getTreePathById(PlatformIdentification id) { + public Set getTreePathById(PlatformIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningPlatformList.elementAt(index).getTreePath(); @@ -156,7 +157,7 @@ public class OpeningPlatformList { return null; } - public TreePath getTreePathByIndex(int index) { + public Set getTreePathByIndex(int index) { if (index > -1) { return vOpeningPlatformList.elementAt(index).getTreePath(); } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPlatformType.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPlatformType.java index c81f4eef05..34c847eb0e 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPlatformType.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPlatformType.java @@ -14,8 +14,6 @@ **/ package org.tianocore.frameworkwizard.common.Identifications; -import javax.swing.tree.TreePath; - import org.tianocore.PlatformSurfaceAreaDocument; import org.tianocore.frameworkwizard.platform.PlatformIdentification; @@ -36,12 +34,6 @@ public class OpeningPlatformType extends OpeningFileType { this.xmlFpd = fpd; } - public OpeningPlatformType(PlatformIdentification identification, PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd, TreePath treePath) { - super(treePath); - this.id = identification; - this.xmlFpd = fpd; - } - public PlatformSurfaceAreaDocument.PlatformSurfaceArea getXmlFpd() { return xmlFpd; } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDefaultMutableTreeNode.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDefaultMutableTreeNode.java index 4f7b953c81..4708191ac9 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDefaultMutableTreeNode.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDefaultMutableTreeNode.java @@ -39,9 +39,9 @@ public class IDefaultMutableTreeNode extends DefaultMutableTreeNode { public static final int MSA_HEADER = 100; public static final int MSA_LIBRARYCLASSDEFINITIONS = 101; - + public static final int MSA_PACKAGEDEPENDENCIES = 102; - + public static final int MSA_SOURCEFILES = 103; public static final int MSA_PROTOCOLS = 104; @@ -60,8 +60,6 @@ public class IDefaultMutableTreeNode extends DefaultMutableTreeNode { public static final int MSA_DATAHUBS = 111; - //public static final int MSA_FORMSETS = 112; - public static final int MSA_HIIPACKAGES = 112; public static final int MSA_GUIDS = 113; @@ -69,58 +67,64 @@ public class IDefaultMutableTreeNode extends DefaultMutableTreeNode { public static final int MSA_EXTERNS = 114; public static final int MSA_PCDS = 115; - + public static final int MSA_BUILDOPTIONS = 117; - + public static final int MSA_USEREXTENSIONS = 118; - + public static final int MSA_MODULEDEFINITIONS = 119; - + public static final int SPD_HEADER = 200; - + public static final int SPD_LIBRARYCLASSDECLARATIONS = 201; - + public static final int SPD_MSAFILES = 202; - + public static final int SPD_PACKAGEHEADERS = 203; - + public static final int SPD_GUIDDECLARATIONS = 204; - + public static final int SPD_PROTOCOLDECLARATIONS = 205; - + public static final int SPD_PPIDECLARATIONS = 206; - + public static final int SPD_PCDDECLARATIONS = 207; - + public static final int SPD_PACKAGEDEFINITIONS = 208; - + public static final int SPD_INDUSTRYSTDINCLUDES = 209; - + public static final int FPD_PLATFORMHEADER = 300; - + public static final int FPD_FLASH = 301; - + public static final int FPD_FRAMEWORKMODULES = 302; - + public static final int FPD_PCDDYNAMICBUILDDECLARATIONS = 303; - + public static final int FPD_BUILDOPTIONS = 304; - + public static final int FPD_PLATFORMDEFINITIONS = 305; - + public static final int WORKSPACE = 0; - - public static final int MODULE = 1; - public static final int PACKAGE = 2; + public static final int MODULE_DESCRIPTION = 1; - public static final int PLATFORM = 3; - - public static final int MODULE_PACKAGE = 4; - - public static final int MODULE_PACKAGE_LIBRARY = 5; - - public static final int MODULE_PACKAGE_MODULE = 6; + public static final int PACKAGE_DESCRIPTION = 2; + + public static final int PLATFORM_DESCRIPTION = 3; + + public static final int MODULE = 4; + + public static final int PACKAGE = 5; + + public static final int PLATFORM = 6; + + public static final int MODULE_PACKAGE = 7; + + public static final int MODULE_PACKAGE_LIBRARY = 8; + + public static final int MODULE_PACKAGE_MODULE = 9; // //Static final definitions for operation @@ -146,26 +150,13 @@ public class IDefaultMutableTreeNode extends DefaultMutableTreeNode { // private int category = 0; - private int operation = 0; - - private int location = 0; - private String nodeName = ""; private boolean isOpening = false; private Identification id = null; - - /** - Main class, reserved for test - - @param args - - **/ - public static void main(String[] args) { - // TODO Auto-generated method stub - - } + + private IDefaultMutableTreeNode belongNode = null; /** This is the default constructor @@ -186,46 +177,13 @@ public class IDefaultMutableTreeNode extends DefaultMutableTreeNode { **/ public IDefaultMutableTreeNode(String strNodeName, int intCategory, boolean bolIsOpening, - Identification identification) { + Identification identification, IDefaultMutableTreeNode idmtBelongNode) { super(strNodeName); this.nodeName = strNodeName; this.category = intCategory; this.isOpening = bolIsOpening; this.id = identification; - } - - /** - This is the overrided constructor - Init clase members with input data - - @param strNodeName The name of node - @param intCategory The category of node - @param intOperation The operation of node - - **/ - public IDefaultMutableTreeNode(String strNodeName, int intCategory, int intOperation) { - super(strNodeName); - this.nodeName = strNodeName; - this.category = intCategory; - this.operation = intOperation; - } - - /** - This is the overrided constructor - Init clase members with input data - - @param strNodeName The name of node - @param intCategory The category of node - @param intOperation The operation of node - @param intLocation The location of node - - **/ - public IDefaultMutableTreeNode(String strNodeName, int intCategory, int intOperation, int intLocation) { - super(strNodeName); - this.nodeName = strNodeName; - this.category = intCategory; - this.operation = intOperation; - this.location = intLocation; + this.belongNode = idmtBelongNode; } /** @@ -268,46 +226,6 @@ public class IDefaultMutableTreeNode extends DefaultMutableTreeNode { this.nodeName = nodeName; } - /** - Get operation of node - - @return The operation of node - - **/ - public int getOperation() { - return operation; - } - - /** - Set operation of node - - @param operation The input data of node operation - - **/ - public void setOperation(int operation) { - this.operation = operation; - } - - /** - Get location of node - - @return The location of node - - **/ - public int getLocation() { - return location; - } - - /** - Set location of node - - @param location The input data of node location - - **/ - public void setLocation(int location) { - this.location = location; - } - /** Get identification of node @@ -347,4 +265,16 @@ public class IDefaultMutableTreeNode extends DefaultMutableTreeNode { public void setOpening(boolean isOpening) { this.isOpening = isOpening; } + + public String toString() { + return this.nodeName; + } + + public IDefaultMutableTreeNode getBelongNode() { + return belongNode; + } + + public void setBelongNode(IDefaultMutableTreeNode belongNode) { + this.belongNode = belongNode; + } } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ITree.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ITree.java index 5b7ea5900c..252c34ff72 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ITree.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ITree.java @@ -26,8 +26,6 @@ import org.tianocore.frameworkwizard.common.Identifications.Identification; /** The class is used to override JTree to provides customized interfaces It extends JTree - - **/ public class ITree extends JTree { @@ -35,7 +33,7 @@ public class ITree extends JTree { /// Define class Serial Version UID /// private static final long serialVersionUID = -7907086164518295327L; - + // // Define class members // @@ -58,7 +56,7 @@ public class ITree extends JTree { **/ public ITree(IDefaultMutableTreeNode iDmtRoot) { super(iDmtRoot); - treeModel = (DefaultTreeModel)this.getModel(); + treeModel = (DefaultTreeModel) this.getModel(); } /** @@ -75,44 +73,6 @@ public class ITree extends JTree { return intCategory; } - /** - Get operation of selected node - - @return The operation of selected node - - **/ - public int getSelectOperation() { - int intOperation = 0; - TreePath path = this.getSelectionPath(); - IDefaultMutableTreeNode node = (IDefaultMutableTreeNode) path.getLastPathComponent(); - intOperation = node.getOperation(); - return intOperation; - } - - /** - Get selectLoaction of selected node - - @return The selectLoaction of selected node - - **/ - public int getSelectLoaction() { - int intLocation = 0; - TreePath path = this.getSelectionPath(); - IDefaultMutableTreeNode node = (IDefaultMutableTreeNode) path.getLastPathComponent(); - intLocation = node.getLocation(); - return intLocation; - } - - /** - Main class, reserved for test - - @param args - - **/ - public static void main(String[] args) { - // TODO Auto-generated method stub - } - /** Add input node as child node for current selected node @@ -151,17 +111,17 @@ public class ITree extends JTree { treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount()); this.scrollPathToVisible(new TreePath(newNode.getPath())); } - + /** - Add input node as child node for current selected node - - @param newNode The node need be added - - **/ - public void addNode(IDefaultMutableTreeNode parentNode, IDefaultMutableTreeNode newNode) { - treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount()); - this.scrollPathToVisible(new TreePath(newNode.getPath())); - } + Add input node as child node for current selected node + + @param newNode The node need be added + + **/ + public void addNode(IDefaultMutableTreeNode parentNode, IDefaultMutableTreeNode newNode) { + treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount()); + this.scrollPathToVisible(new TreePath(newNode.getPath())); + } /** Remove the selected node @@ -173,13 +133,13 @@ public class ITree extends JTree { TreePath treePath = this.getSelectionPath(); removeNodeByPath(treePath); } - + /** - Remove the node by tree path - - @param strRemovedNode - - **/ + Remove the node by tree path + + @param strRemovedNode + + **/ public void removeNodeByPath(TreePath treePath) { if (treePath != null) { DefaultMutableTreeNode selectionNode = (DefaultMutableTreeNode) treePath.getLastPathComponent(); @@ -191,14 +151,29 @@ public class ITree extends JTree { } /** - Remove all child nodes under current node + Return a node by input tree path + + @param treePath + @return **/ + public IDefaultMutableTreeNode getNodeByPath(TreePath treePath) { + if (treePath != null) { + IDefaultMutableTreeNode selectionNode = (IDefaultMutableTreeNode) treePath.getLastPathComponent(); + return selectionNode; + } + return null; + } + + /** + Remove all child nodes under current node + + **/ public void removeNodeChildrenByPath(TreePath treePath) { if (treePath != null) { DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) treePath.getLastPathComponent(); for (int index = currentNode.getChildCount() - 1; index > -1; index--) { - treeModel.removeNodeFromParent((DefaultMutableTreeNode)currentNode.getChildAt(index)); + treeModel.removeNodeFromParent((DefaultMutableTreeNode) currentNode.getChildAt(index)); } } } @@ -212,7 +187,7 @@ public class ITree extends JTree { rootNode.removeAllChildren(); treeModel.reload(); } - + public IDefaultMutableTreeNode getSelectNode() { TreePath treepath = this.getSelectionPath(); IDefaultMutableTreeNode selectionNode = null; @@ -221,7 +196,7 @@ public class ITree extends JTree { } return selectionNode; } - + public IDefaultMutableTreeNode getNodeById(IDefaultMutableTreeNode node, Identification id) { for (int index = 0; index < node.getChildCount(); index++) { IDefaultMutableTreeNode iNode = (IDefaultMutableTreeNode) node.getChildAt(index); @@ -231,7 +206,7 @@ public class ITree extends JTree { } return null; } - + public IDefaultMutableTreeNode getNodeById(IDefaultMutableTreeNode node, Identification id, int category) { for (int index = 0; index < node.getChildCount(); index++) { IDefaultMutableTreeNode iNode = (IDefaultMutableTreeNode) node.getChildAt(index); @@ -245,11 +220,11 @@ public class ITree extends JTree { } return null; } - + public TreePath getPathOfNode(IDefaultMutableTreeNode node) { if (node != null) { TreePath treePath = new TreePath(treeModel.getPathToRoot(node)); - return treePath; + return treePath; } return null; } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java index 10b8aee17f..e022eb1d3a 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java @@ -26,6 +26,7 @@ import org.tianocore.IndustryStdIncludesDocument.IndustryStdIncludes; import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.MsaFilesDocument.MsaFiles; import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea; +import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea; import org.tianocore.SourceFilesDocument.SourceFiles; import org.tianocore.frameworkwizard.common.DataType; import org.tianocore.frameworkwizard.common.GlobalData; @@ -295,7 +296,40 @@ public class WorkspaceTools { modulePath = modulePaths.get(index); ModuleIdentification id = GlobalData.openingModuleList.getIdByPath(modulePath); if (id != null) { - v.addElement(id); + v.addElement(id); + } + } + Sort.sortModules(v, DataType.SORT_TYPE_ASCENDING); + return v; + } + + /** + Get all module basic information from a platform + + @param id Package id + @return A vector includes all modules' basic information + + **/ + public Vector getAllModules(PlatformIdentification fid) { + Vector v = new Vector(); + PlatformSurfaceArea fpd = GlobalData.openingPlatformList.getOpeningPlatformById(fid).getXmlFpd(); + if (fpd.getFrameworkModules() != null) { + for (int index = 0; index < fpd.getFrameworkModules().getModuleSAList().size(); index++) { + String guid = fpd.getFrameworkModules().getModuleSAList().get(index).getModuleGuid(); + String version = fpd.getFrameworkModules().getModuleSAList().get(index).getModuleVersion(); + ModuleIdentification id = GlobalData.openingModuleList.getIdByGuidVersion(guid, version); + if (id != null) { + boolean isFind = false; + for (int indexOfModules = 0; indexOfModules < v.size(); indexOfModules++) { + if (v.elementAt(indexOfModules).equals(id)) { + isFind = true; + break; + } + } + if (!isFind) { + v.addElement(id); + } + } } } Sort.sortModules(v, DataType.SORT_TYPE_ASCENDING); -- 2.39.2