From: hche10x Date: Thu, 17 Aug 2006 02:04:40 +0000 (+0000) Subject: 1. Merge ModuleDefinitions to MsaHeader X-Git-Tag: edk2-stable201903~24573 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=739c6b04fd86cb47de673b1038bea336a7f3499c 1. Merge ModuleDefinitions to MsaHeader 2. Make InMemoryDB consistent for all operations 3. Extend Copyright to 2 lines text area in msa header git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1300 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/Tools/Source/FrameworkWizard/FrameworkWizard.msa b/Tools/Source/FrameworkWizard/FrameworkWizard.msa index e11f7bb1ae..1d764e8b36 100644 --- a/Tools/Source/FrameworkWizard/FrameworkWizard.msa +++ b/Tools/Source/FrameworkWizard/FrameworkWizard.msa @@ -50,6 +50,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. src/org/tianocore/frameworkwizard/common/DataValidation.java src/org/tianocore/frameworkwizard/common/EnumerationData.java src/org/tianocore/frameworkwizard/common/FileOperation.java + src/org/tianocore/frameworkwizard/common/GlobalData.java src/org/tianocore/frameworkwizard/common/IDefaultTableModel.java src/org/tianocore/frameworkwizard/common/IFileFilter.java src/org/tianocore/frameworkwizard/common/Log.java diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java index 3d8c267484..68aef5eb35 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java @@ -723,7 +723,7 @@ public class Clone extends IDialog { // trg = getModulePath(); newId.setPath(trg); - vFiles = wt.getAllModuleFilesPath(src); + vFiles = wt.getAllFilesPathOfModule(src); // // First copy all files to new directory @@ -787,7 +787,7 @@ public class Clone extends IDialog { // trg = this.getPackagePath(); newId.setPath(trg); - vFiles = wt.getAllPakcageFilesPath(src); + vFiles = wt.getAllFilesPathOfPakcage(src); // // First copy all files to new directory diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java index 6041472c5f..e8857b543c 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java @@ -44,21 +44,16 @@ import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import org.apache.xmlbeans.XmlException; -import org.tianocore.ModuleSurfaceAreaDocument; import org.tianocore.PackageSurfaceAreaDocument; -import org.tianocore.PlatformSurfaceAreaDocument; import org.tianocore.frameworkwizard.common.DataType; +import org.tianocore.frameworkwizard.common.GlobalData; import org.tianocore.frameworkwizard.common.IFileFilter; import org.tianocore.frameworkwizard.common.Log; -import org.tianocore.frameworkwizard.common.OpenFile; import org.tianocore.frameworkwizard.common.SaveFile; import org.tianocore.frameworkwizard.common.Tools; import org.tianocore.frameworkwizard.common.Identifications.Identification; -import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleList; import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType; -import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageList; import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType; -import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformList; import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType; import org.tianocore.frameworkwizard.common.ui.IDefaultMutableTreeNode; import org.tianocore.frameworkwizard.common.ui.IDesktopManager; @@ -71,7 +66,6 @@ import org.tianocore.frameworkwizard.far.updateui.UpdateStepOne; import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; import org.tianocore.frameworkwizard.module.ui.ModuleBootModes; import org.tianocore.frameworkwizard.module.ui.ModuleDataHubs; -import org.tianocore.frameworkwizard.module.ui.ModuleDefinitions; import org.tianocore.frameworkwizard.module.ui.ModuleEvents; import org.tianocore.frameworkwizard.module.ui.ModuleExterns; import org.tianocore.frameworkwizard.module.ui.ModuleGuids; @@ -119,20 +113,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele private static final long serialVersionUID = -7103240960573031772L; /// - /// Used to save information of all files + /// Used to record current operation target /// - private Vector vModuleList = new Vector(); - - private Vector vPackageList = new Vector(); - - private Vector vPlatformList = new Vector(); - - private OpeningModuleList openingModuleList = new OpeningModuleList(); - - private OpeningPackageList openingPackageList = new OpeningPackageList(); - - private OpeningPlatformList openingPlatformList = new OpeningPlatformList(); - private int currentOpeningModuleIndex = -1; private int currentOpeningPackageIndex = -1; @@ -1699,11 +1681,18 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele System.exit(0); } + // + // Init Global Data + // + GlobalData.init(); + + // + // Init the frame + // this.setSize(DataType.MAIN_FRAME_PREFERRED_SIZE_WIDTH, DataType.MAIN_FRAME_PREFERRED_SIZE_HEIGHT); this.setResizable(true); this.setJMenuBar(getjJMenuBar()); this.addComponentListener(this); - this.getCompontentsFromFrameworkDatabase(); this.setContentPane(getJContentPane()); this.setTitle(DataType.PROJECT_NAME + " " + DataType.PROJECT_VERSION + " " + "- [" + Workspace.getCurrentWorkspace() + "]"); @@ -1828,34 +1817,34 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // First add package // - if (this.vPackageList.size() > 0) { - for (int index = 0; index < this.vPackageList.size(); index++) { + if (GlobalData.vPackageList.size() > 0) { + for (int index = 0; index < GlobalData.vPackageList.size(); index++) { IDefaultMutableTreeNode dmtnModulePackage = null; IDefaultMutableTreeNode dmtnModulePackageLibrary = null; IDefaultMutableTreeNode dmtnModulePackageModule = null; - dmtnModulePackage = new IDefaultMutableTreeNode(this.vPackageList.elementAt(index).getName(), + dmtnModulePackage = new IDefaultMutableTreeNode(GlobalData.vPackageList.elementAt(index).getName(), IDefaultMutableTreeNode.MODULE_PACKAGE, false, - this.vPackageList.elementAt(index)); + GlobalData.vPackageList.elementAt(index)); dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library", IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, - false, this.vPackageList.elementAt(index)); + false, GlobalData.vPackageList.elementAt(index)); dmtnModulePackageModule = new IDefaultMutableTreeNode("Module", IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE, - false, this.vPackageList.elementAt(index)); + false, GlobalData.vPackageList.elementAt(index)); // // And then add each module in its package // - Vector vModule = wt.getAllModules(this.vPackageList.elementAt(index)); + Vector vModule = wt.getAllModules(GlobalData.vPackageList.elementAt(index)); 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))); + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ))); } else { dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), - IDefaultMutableTreeNode.MODULE, - false, vModule.get(indexJ))); + IDefaultMutableTreeNode.MODULE, false, + vModule.get(indexJ))); } } if (dmtnModulePackageModule.getChildCount() > 0) { @@ -1873,11 +1862,12 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // Make Package Description // dmtnPackageDescription = new IDefaultMutableTreeNode("PackageDescription", IDefaultMutableTreeNode.PACKAGE, -1); - if (this.vPackageList.size() > 0) { - for (int index = 0; index < this.vPackageList.size(); index++) { - dmtnPackageDescription.add(new IDefaultMutableTreeNode(this.vPackageList.elementAt(index).getName(), + 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, - this.vPackageList.elementAt(index))); + GlobalData.vPackageList.elementAt(index))); } } @@ -1886,11 +1876,12 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // dmtnPlatformDescription = new IDefaultMutableTreeNode("PlatformDescription", IDefaultMutableTreeNode.PLATFORM, -1); - if (this.vPlatformList.size() > 0) { - for (int index = 0; index < this.vPlatformList.size(); index++) { - dmtnPlatformDescription.add(new IDefaultMutableTreeNode(this.vPlatformList.elementAt(index).getName(), - IDefaultMutableTreeNode.PLATFORM, - false, this.vPlatformList.elementAt(index))); + 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))); } } @@ -2023,7 +2014,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Add new MsaHeader node to the tree // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(mid.getName(), IDefaultMutableTreeNode.MSA_HEADER, + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(mid.getName(), IDefaultMutableTreeNode.MODULE, true, mid); // // First find the module belongs to which package @@ -2083,90 +2074,6 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } } - /** - Open Module - - @param path input file path - - **/ - private void openModule(String path, ModuleIdentification moduleId) { - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; - try { - msa = OpenFile.openMsaFile(path); - } catch (IOException e) { - Log.wrn("Open Module Surface Area " + path, e.getMessage()); - Log.err("Open Module Surface Area " + path, e.getMessage()); - return; - } catch (XmlException e) { - Log.wrn("Open Module Surface Area " + path, e.getMessage()); - Log.err("Open Module Surface Area " + path, e.getMessage()); - return; - } catch (Exception e) { - Log.wrn("Open Module Surface Area " + path, "Invalid file type"); - Log.err("Open Module Surface Area " + path, "Invalid file type"); - return; - } - Identification id = new Identification(msa.getMsaHeader().getModuleName(), msa.getMsaHeader().getGuidValue(), - msa.getMsaHeader().getVersion(), path); - // - // Generate module id - // - PackageIdentification pid = wt.getPackageIdByModuleId(id); - if (pid != null) { - // - // To judge if the module existed in vModuleList - // If not, add it to vModuleList - // - boolean isFind = false; - for (int index = 0; index < vModuleList.size(); index++) { - if (vModuleList.elementAt(index).equals(id)) { - isFind = true; - break; - } - } - if (!isFind) { - ModuleIdentification mid = new ModuleIdentification(id, pid, moduleId.isLibrary()); - vModuleList.addElement(mid); - addModuleToTree(mid); - } - } else { - // - // The module is not in existing packages - // - Log.err("The module hasn't been added to any package of current workspace!"); - return; - } - - // - // Make the node selected - // - iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, - IDefaultMutableTreeNode.MODULE))); - // - // Update opening Module list information - // - if (!openingModuleList.existsModule(id)) { - // - // Insert sub node of module - // - insertModuleTreeNode(id); - iTree.getSelectNode().setOpening(true); - - // - // Update opening module list - // - openingModuleList.insertToOpeningModuleList(id, msa); - openingModuleList.setTreePathById(id, iTree.getSelectionPath()); - } - // - // Select msa header node and show it in editor panel - // - iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, - IDefaultMutableTreeNode.MSA_HEADER))); - showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, openingModuleList.getOpeningModuleById(id)); - this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id); - } - /** Open Module @@ -2174,46 +2081,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void openModule(String path) { - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; - try { - msa = OpenFile.openMsaFile(path); - } catch (IOException e) { - Log.wrn("Open Module Surface Area " + path, e.getMessage()); - Log.err("Open Module Surface Area " + path, e.getMessage()); - return; - } catch (XmlException e) { - Log.wrn("Open Module Surface Area " + path, e.getMessage()); - Log.err("Open Module Surface Area " + path, e.getMessage()); - return; - } catch (Exception e) { - Log.wrn("Open Module Surface Area " + path, "Invalid file type"); - Log.err("Open Module Surface Area " + path, "Invalid file type"); - return; - } - Identification id = new Identification(msa.getMsaHeader().getModuleName(), msa.getMsaHeader().getGuidValue(), - msa.getMsaHeader().getVersion(), path); - // - // Generate module id - // - PackageIdentification pid = wt.getPackageIdByModuleId(id); - if (pid != null) { - // - // To judge if the module existed in vModuleList - // If not, add it to vModuleList - // - boolean isFind = false; - for (int index = 0; index < vModuleList.size(); index++) { - if (vModuleList.elementAt(index).equals(id)) { - isFind = true; - break; - } - } - if (!isFind) { - ModuleIdentification mid = new ModuleIdentification(id, pid); - vModuleList.addElement(mid); - addModuleToTree(mid); - } - } else { + ModuleIdentification id = GlobalData.openingModuleList.getIdByPath(path); + if (id == null) { // // The module is not in existing packages // @@ -2229,7 +2098,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Update opening Module list information // - if (!openingModuleList.existsModule(id)) { + if (!GlobalData.openingModuleList.getModuleOpen(id)) { // // Insert sub node of module // @@ -2239,16 +2108,16 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Update opening module list // - openingModuleList.insertToOpeningModuleList(id, msa); - openingModuleList.setTreePathById(id, iTree.getSelectionPath()); + GlobalData.openingModuleList.setModuleOpen(id, true); + GlobalData.openingModuleList.setTreePathById(id, iTree.getSelectionPath()); } // // Select msa header node and show it in editor panel // iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, IDefaultMutableTreeNode.MSA_HEADER))); - showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, openingModuleList.getOpeningModuleById(id)); - this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id); + showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, GlobalData.openingModuleList.getOpeningModuleById(id)); + this.currentOpeningModuleIndex = GlobalData.openingModuleList.findIndexOfListById(id); } /** @@ -2258,38 +2127,10 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void openPackage(String path) { - PackageSurfaceAreaDocument.PackageSurfaceArea spd = null; - try { - spd = OpenFile.openSpdFile(path); - } catch (IOException e) { - Log.wrn("Open Package Surface Area " + path, e.getMessage()); - Log.err("Open Package Surface Area " + path, e.getMessage()); - return; - } catch (XmlException e) { - Log.wrn("Open Package Surface Area " + path, e.getMessage()); - Log.err("Open Package Surface Area " + path, e.getMessage()); - return; - } catch (Exception e) { - Log.wrn("Open Package Surface Area " + path, "Invalid file type"); - Log.err("Open Package Surface Area " + path, "Invalid file type"); - return; - } - Identification id = new Identification(spd.getSpdHeader().getPackageName(), spd.getSpdHeader().getGuidValue(), - spd.getSpdHeader().getVersion(), path); - // - // To judge if the package existed in vPackageList - // If not, add it to vPackageList - // - boolean isFind = false; - for (int index = 0; index < vPackageList.size(); index++) { - if (vPackageList.elementAt(index).equals(id)) { - isFind = true; - break; - } - } - if (!isFind) { + PackageIdentification id = GlobalData.openingPackageList.getIdByPath(path); + if (id == null) { // - // The module is not in existing packages + // The package is not in current workspace // Log.wrn("Open Package", "The package hasn't been added to current workspace!"); return; @@ -2303,7 +2144,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Update opening package list information // - if (!openingPackageList.existsPackage(id)) { + if (!GlobalData.openingPackageList.getPackageOpen(id)) { // // Insert sub node of module // @@ -2313,16 +2154,16 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Update opening module list // - openingPackageList.insertToOpeningPackageList(id, spd); - openingPackageList.setTreePathById(id, iTree.getSelectionPath()); + GlobalData.openingPackageList.setPackageOpen(id, true); + GlobalData.openingPackageList.setTreePathById(id, iTree.getSelectionPath()); } // // Show spd header in editor panel // iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPackageDescription, id, IDefaultMutableTreeNode.SPD_HEADER))); - showPackageElement(IDefaultMutableTreeNode.SPD_HEADER, openingPackageList.getOpeningPackageById(id)); - this.currentOpeningPackageIndex = openingPackageList.findIndexOfListById(id); + showPackageElement(IDefaultMutableTreeNode.SPD_HEADER, GlobalData.openingPackageList.getOpeningPackageById(id)); + this.currentOpeningPackageIndex = GlobalData.openingPackageList.findIndexOfListById(id); } /** @@ -2332,39 +2173,10 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void openPlatform(String path) { - PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd = null; - try { - fpd = OpenFile.openFpdFile(path); - } catch (IOException e) { - Log.wrn("Open Platform Surface Area " + path, e.getMessage()); - Log.err("Open Platform Surface Area " + path, e.getMessage()); - return; - } catch (XmlException e) { - Log.wrn("Open Platform Surface Area " + path, e.getMessage()); - Log.err("Open Platform Surface Area " + path, e.getMessage()); - return; - } catch (Exception e) { - Log.wrn("Open Platform Surface Area " + path, "Invalid file type"); - Log.err("Open Platform Surface Area " + path, "Invalid file type"); - return; - } - Identification id = new Identification(fpd.getPlatformHeader().getPlatformName(), fpd.getPlatformHeader() - .getGuidValue(), - fpd.getPlatformHeader().getVersion(), path); - // - // To judge if the platform existed in vPlatformList - // If not, add it to vPlatformList - // - boolean isFind = false; - for (int index = 0; index < vPlatformList.size(); index++) { - if (vPlatformList.elementAt(index).equals(id)) { - isFind = true; - break; - } - } - if (!isFind) { + PlatformIdentification id = GlobalData.openingPlatformList.getIdByPath(path); + if (id == null) { // - // The module is not in existing packages + // The platform is not in current workspace // Log.wrn("Open Platform", "The platform hasn't been added to current workspace!"); return; @@ -2378,7 +2190,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Update opening package list information // - if (!openingPlatformList.existsPlatform(id)) { + if (!GlobalData.openingPlatformList.getPlatformOpen(id)) { // // Insert sub node of module // @@ -2388,16 +2200,17 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Update opening module list // - openingPlatformList.insertToOpeningPlatformList(id, fpd); - openingPlatformList.setTreePathById(id, iTree.getSelectionPath()); + GlobalData.openingPlatformList.setPlatformOpen(id, true); + GlobalData.openingPlatformList.setTreePathById(id, iTree.getSelectionPath()); } // // Show fpd header in editor panel // iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPlatformDescription, id, IDefaultMutableTreeNode.FPD_PLATFORMHEADER))); - showPlatformElement(IDefaultMutableTreeNode.FPD_PLATFORMHEADER, openingPlatformList.getOpeningPlatformById(id)); - this.currentOpeningPlatformIndex = openingPlatformList.findIndexOfListById(id); + showPlatformElement(IDefaultMutableTreeNode.FPD_PLATFORMHEADER, + GlobalData.openingPlatformList.getOpeningPlatformById(id)); + this.currentOpeningPlatformIndex = GlobalData.openingPlatformList.findIndexOfListById(id); } /** @@ -2405,7 +2218,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void saveModule(int index) { - OpeningModuleType omt = openingModuleList.getOpeningModuleByIndex(index); + OpeningModuleType omt = GlobalData.openingModuleList.getOpeningModuleByIndex(index); if (omt.isNew()) { if (getNewFilePath(DataType.MODULE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { return; @@ -2413,8 +2226,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } try { SaveFile.saveMsaFile(omt.getId().getPath(), omt.getXmlMsa()); - openingModuleList.setNew(omt.getId(), false); - openingModuleList.setModuleSaved(omt.getId(), true); + GlobalData.openingModuleList.setNew(omt.getId(), false); + GlobalData.openingModuleList.setModuleSaved(omt.getId(), true); } catch (Exception e) { Log.wrn("Save Module", e.getMessage()); Log.err("Save Module", e.getMessage()); @@ -2426,7 +2239,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void savePackage(int index) { - OpeningPackageType opt = openingPackageList.getOpeningPackageByIndex(index); + OpeningPackageType opt = GlobalData.openingPackageList.getOpeningPackageByIndex(index); if (opt.isNew()) { if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { return; @@ -2434,8 +2247,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } try { SaveFile.saveSpdFile(opt.getId().getPath(), opt.getXmlSpd()); - openingPackageList.setNew(opt.getId(), false); - openingPackageList.setPackageSaved(opt.getId(), true); + GlobalData.openingPackageList.setNew(opt.getId(), false); + GlobalData.openingPackageList.setPackageSaved(opt.getId(), true); } catch (Exception e) { Log.wrn("Save Package", e.getMessage()); Log.err("Save Package", e.getMessage()); @@ -2447,7 +2260,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void savePlatform(int index) { - OpeningPlatformType opt = openingPlatformList.getOpeningPlatformByIndex(index); + OpeningPlatformType opt = GlobalData.openingPlatformList.getOpeningPlatformByIndex(index); if (opt.isNew()) { if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { return; @@ -2455,8 +2268,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } try { SaveFile.saveFpdFile(opt.getId().getPath(), opt.getXmlFpd()); - openingPlatformList.setNew(opt.getId(), false); - openingPlatformList.setPlatformSaved(opt.getId(), true); + GlobalData.openingPlatformList.setNew(opt.getId(), false); + GlobalData.openingPlatformList.setPlatformSaved(opt.getId(), true); } catch (Exception e) { Log.wrn("Save Package", e.getMessage()); Log.err("Save Package", e.getMessage()); @@ -2506,19 +2319,11 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } } - private void getCompontentsFromFrameworkDatabase() { - this.vModuleList = wt.getAllModules(); - this.vPackageList = wt.getAllPackages(); - this.vPlatformList = wt.getAllPlatforms(); - } - private void insertModuleTreeNode(Identification id) { iTree.addNode(new IDefaultMutableTreeNode("Module Header", IDefaultMutableTreeNode.MSA_HEADER, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Module Definitions", IDefaultMutableTreeNode.MSA_MODULEDEFINITIONS, - true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id)); iTree.addNode(new IDefaultMutableTreeNode("Library Class Definitions", IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id)); iTree.addNode(new IDefaultMutableTreeNode("Package Dependencies", IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES, true, id)); iTree.addNode(new IDefaultMutableTreeNode("Protocols", IDefaultMutableTreeNode.MSA_PROTOCOLS, true, id)); @@ -2537,8 +2342,6 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele private void insertPackageTreeNode(Identification id) { iTree.addNode(new IDefaultMutableTreeNode("Package Header", IDefaultMutableTreeNode.SPD_HEADER, true, id)); - iTree.addNode(new IDefaultMutableTreeNode("Package Definitions", - IDefaultMutableTreeNode.SPD_PACKAGEDEFINITIONS, true, id)); iTree.addNode(new IDefaultMutableTreeNode("Library Class Declarations", IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS, true, id)); iTree.addNode(new IDefaultMutableTreeNode("Msa Files", IDefaultMutableTreeNode.SPD_MSAFILES, false, id)); @@ -2580,7 +2383,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele id = iTree.getSelectNode().getId(); intCategory = iTree.getSelectCategory(); isOpen = iTree.getSelectNode().isOpening(); - + if (!isOpen) { // // If the node is not opened yet @@ -2608,27 +2411,38 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return; } } - + // // Show editor panel // if (intCategory >= IDefaultMutableTreeNode.MSA_HEADER && intCategory < IDefaultMutableTreeNode.SPD_HEADER) { - showModuleElement(intCategory, openingModuleList.getOpeningModuleById(id)); - this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id); + showModuleElement(intCategory, + GlobalData.openingModuleList.getOpeningModuleById(new ModuleIdentification(id))); + this.currentOpeningModuleIndex = GlobalData.openingModuleList + .findIndexOfListById(new ModuleIdentification( + id)); } if (intCategory >= IDefaultMutableTreeNode.SPD_HEADER && intCategory < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { - showPackageElement(intCategory, openingPackageList.getOpeningPackageById(id)); - this.currentOpeningPackageIndex = openingPackageList.findIndexOfListById(id); + showPackageElement(intCategory, + GlobalData.openingPackageList.getOpeningPackageById(new PackageIdentification(id))); + this.currentOpeningPackageIndex = GlobalData.openingPackageList + .findIndexOfListById(new PackageIdentification( + id)); } if (intCategory >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { - showPlatformElement(intCategory, openingPlatformList.getOpeningPlatformById(id)); - this.currentOpeningPlatformIndex = openingPlatformList.findIndexOfListById(id); + showPlatformElement( + intCategory, + GlobalData.openingPlatformList + .getOpeningPlatformById(new PlatformIdentification(id))); + this.currentOpeningPlatformIndex = GlobalData.openingPlatformList + .findIndexOfListById(new PlatformIdentification( + id)); } } catch (RuntimeException e) { - Log.log("double click category: " + intCategory); - Log.log("double click id path: " + id); - Log.log("double click exception: " + e.getMessage()); + Log.err("double click category: " + intCategory); + Log.err("double click id path: " + id); + Log.err("double click exception: " + e.getMessage()); } } @@ -2734,10 +2548,6 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele MsaHeader frmMsaHeader = new MsaHeader(msa); getJDesktopPaneModule().add(frmMsaHeader, 1); break; - case IDefaultMutableTreeNode.MSA_MODULEDEFINITIONS: - ModuleDefinitions frmMd = new ModuleDefinitions(msa); - getJDesktopPaneModule().add(frmMd, 1); - break; case IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS: ModuleLibraryClassDefinitions frmMlcd = new ModuleLibraryClassDefinitions(msa); getJDesktopPaneModule().add(frmMlcd, 1); @@ -2833,26 +2643,47 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele smb.dispose(); return; } else if (result == DataType.RETURN_TYPE_OK) { - PackageSurfaceAreaDocument.PackageSurfaceArea psa = null; - if (this.openingPackageList.existsPackage(smb.getMid().getPackageId())) { - psa = openingPackageList.getPackageSurfaceAreaFromId(smb.getMid().getPackageId()); - } - try { - wt.addModuleToPackage(smb.getMid(), psa); - } catch (IOException e) { - Log.wrn("Upddate MsaFiles of Package", e.getMessage()); - Log.err("Upddate MsaFiles of Package", e.getMessage()); - return; - } catch (XmlException e) { - Log.wrn("Upddate MsaFiles of Package", e.getMessage()); - Log.err("Upddate MsaFiles of Package", e.getMessage()); - return; - } catch (Exception e) { - Log.wrn("Upddate MsaFiles of Package", e.getMessage()); - Log.err("Upddate MsaFiles of Package", e.getMessage()); - return; + ModuleIdentification mid = smb.getMid(); + if (mid != null) { + // + // Update package of workspace first + // + PackageSurfaceAreaDocument.PackageSurfaceArea psa = null; + if (GlobalData.openingPackageList.existsPackage(mid.getPackageId())) { + psa = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(mid.getPackageId()); + } + try { + wt.addModuleToPackage(mid, psa); + } catch (IOException e) { + Log.wrn("Upddate MsaFiles of Package", e.getMessage()); + Log.err("Upddate MsaFiles of Package", e.getMessage()); + return; + } catch (XmlException e) { + Log.wrn("Upddate MsaFiles of Package", e.getMessage()); + Log.err("Upddate MsaFiles of Package", e.getMessage()); + return; + } catch (Exception e) { + Log.wrn("Upddate MsaFiles of Package", e.getMessage()); + Log.err("Upddate MsaFiles of Package", e.getMessage()); + return; + } + + // + // Update Global Data + // + GlobalData.openingModuleList.insertToOpeningModuleList(mid, smb.getMsa()); + GlobalData.vModuleList.addElement(mid); + + // + // Create new node on the tree + // + addModuleToTree(mid); + + // + // Open the node + // + this.openModule(mid.getPath()); } - this.openModule(smb.getMid().getPath(), smb.getMid()); } } else if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { // @@ -2866,30 +2697,37 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele smb.dispose(); return; } else if (result == DataType.RETURN_TYPE_OK) { - try { - wt.addPackageToDatabase(smb.getPid()); - } catch (Exception e) { - Log.err("addPackageToDatabase", e.getMessage()); - } - vPackageList.addElement(smb.getPid()); + PackageIdentification pid = smb.getPid(); + if (pid != null) { + try { + wt.addPackageToDatabase(smb.getPid()); + } catch (Exception e) { + Log.err("addPackageToDatabase", e.getMessage()); + } - // - // Add to Module Description node - // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(), - IDefaultMutableTreeNode.MODULE_PACKAGE, - false, vPackageList.lastElement()); + // + // Update Global Data + // + GlobalData.openingPackageList.insertToOpeningPackageList(pid, smb.getSpd()); + GlobalData.vPackageList.addElement(pid); - iTree.addNode(dmtnModuleDescription, node); + // + // Add to Module Description node + // + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(pid.getName(), + IDefaultMutableTreeNode.MODULE_PACKAGE, + false, pid); - // - // Add new SpdHeader node to the tree - // - node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(), - IDefaultMutableTreeNode.SPD_HEADER, true, vPackageList.lastElement()); - iTree.addNode(dmtnPackageDescription, node); + iTree.addNode(dmtnModuleDescription, node); + + // + // Add new SpdHeader node to the tree + // + node = new IDefaultMutableTreeNode(pid.getName(), IDefaultMutableTreeNode.PACKAGE, true, pid); + iTree.addNode(dmtnPackageDescription, node); - this.openPackage(smb.getPid().getPath()); + this.openPackage(pid.getPath()); + } } } else if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { // @@ -2903,20 +2741,28 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele smb.dispose(); return; } else if (result == DataType.RETURN_TYPE_OK) { - try { - wt.addPlatformToDatabase(smb.getFid()); - } catch (Exception e) { - Log.err("addPlatformToDatabase", e.getMessage()); + PlatformIdentification fid = smb.getFid(); + if (fid != null) { + try { + wt.addPlatformToDatabase(fid); + } catch (Exception e) { + Log.err("addPlatformToDatabase", e.getMessage()); + } + + // + // Update global data + // + GlobalData.openingPlatformList.insertToOpeningPlatformList(fid, smb.getFpd()); + GlobalData.vPlatformList.addElement(fid); + // + // Add new SpdHeader node to the tree + // + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(fid.getName(), + IDefaultMutableTreeNode.PLATFORM, true, + fid); + iTree.addNode(dmtnPlatformDescription, node); + this.openPlatform(fid.getPath()); } - vPlatformList.addElement(smb.getFid()); - // - // Add new SpdHeader node to the tree - // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPlatformList.lastElement().getName(), - IDefaultMutableTreeNode.FPD_PLATFORMHEADER, - true, vPlatformList.lastElement()); - iTree.addNode(dmtnPlatformDescription, node); - this.openPlatform(smb.getFid().getPath()); } } } @@ -2962,7 +2808,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // case 0: if (this.currentOpeningModuleIndex > -1) { - if (!openingModuleList.getModuleSaved(currentOpeningModuleIndex)) { + if (!GlobalData.openingModuleList.getModuleSaved(currentOpeningModuleIndex)) { int result = showSaveDialog(); if (result == JOptionPane.YES_OPTION) { this.saveAll(); @@ -2974,8 +2820,10 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return; } } - iTree.removeNodeChildrenByPath(openingModuleList.getTreePathByIndex(currentOpeningModuleIndex)); - this.openingModuleList.removeFromOpeningModuleListByIndex(this.currentOpeningModuleIndex); + iTree + .removeNodeChildrenByPath(GlobalData.openingModuleList + .getTreePathByIndex(currentOpeningModuleIndex)); + GlobalData.openingModuleList.setModuleOpen(this.currentOpeningModuleIndex, false); this.cleanDesktopPaneModule(); this.currentOpeningModuleIndex = -1; } @@ -2985,7 +2833,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // case 1: if (this.currentOpeningPackageIndex > -1) { - if (!openingPackageList.getPackageSaved(currentOpeningPackageIndex)) { + if (!GlobalData.openingPackageList.getPackageSaved(currentOpeningPackageIndex)) { int result = showSaveDialog(); if (result == JOptionPane.YES_OPTION) { this.saveAll(); @@ -2997,8 +2845,10 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return; } } - iTree.removeNodeChildrenByPath(openingPackageList.getTreePathByIndex(currentOpeningPackageIndex)); - this.openingPackageList.removeFromOpeningPackageListByIndex(this.currentOpeningPackageIndex); + iTree + .removeNodeChildrenByPath(GlobalData.openingPackageList + .getTreePathByIndex(currentOpeningPackageIndex)); + GlobalData.openingPackageList.setPackageOpen(this.currentOpeningPackageIndex, false); this.cleanDesktopPanePackage(); this.currentOpeningPackageIndex = -1; } @@ -3008,7 +2858,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // case 2: if (this.currentOpeningPlatformIndex > -1) { - if (!openingPlatformList.getPlatformSaved(currentOpeningPlatformIndex)) { + if (!GlobalData.openingPlatformList.getPlatformSaved(currentOpeningPlatformIndex)) { int result = showSaveDialog(); if (result == JOptionPane.YES_OPTION) { this.saveAll(); @@ -3020,8 +2870,10 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return; } } - iTree.removeNodeChildrenByPath(openingPlatformList.getTreePathByIndex(currentOpeningPlatformIndex)); - this.openingPlatformList.removeFromOpeningPlatformListByIndex(this.currentOpeningPlatformIndex); + iTree + .removeNodeChildrenByPath(GlobalData.openingPlatformList + .getTreePathByIndex(currentOpeningPlatformIndex)); + GlobalData.openingPlatformList.setPlatformOpen(this.currentOpeningPlatformIndex, false); this.cleanDesktopPanePlatform(); this.currentOpeningPlatformIndex = -1; } @@ -3035,7 +2887,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void closeAll() { int result = -1; - if (!openingModuleList.isSaved() || !openingPackageList.isSaved() || !openingPlatformList.isSaved()) { + if (!GlobalData.openingModuleList.isSaved() || !GlobalData.openingPackageList.isSaved() + || !GlobalData.openingPlatformList.isSaved()) { result = showSaveDialog(); } if (result == JOptionPane.YES_OPTION) { @@ -3050,10 +2903,9 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele return; } this.cleanDesktopPane(); - this.getCompontentsFromFrameworkDatabase(); - openingModuleList.removeAllFromOpeningModuleList(); - openingPackageList.removeAllFromOpeningPackageList(); - openingPlatformList.removeAllFromOpeningPlatformList(); + GlobalData.openingModuleList.closeAll(); + GlobalData.openingPackageList.closeAll(); + GlobalData.openingPlatformList.closeAll(); this.makeEmptyTree(); } @@ -3089,8 +2941,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Save all modules // - for (int index = 0; index < openingModuleList.size(); index++) { - if (!openingModuleList.getModuleSaved(index)) { + for (int index = 0; index < GlobalData.openingModuleList.size(); index++) { + if (!GlobalData.openingModuleList.getModuleSaved(index)) { saveModule(index); } } @@ -3098,8 +2950,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Save all packages // - for (int index = 0; index < openingPackageList.size(); index++) { - if (!openingPackageList.getPackageSaved(index)) { + for (int index = 0; index < GlobalData.openingPackageList.size(); index++) { + if (!GlobalData.openingPackageList.getPackageSaved(index)) { savePackage(index); } } @@ -3107,8 +2959,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Save all platforms // - for (int index = 0; index < openingPlatformList.size(); index++) { - if (!openingPlatformList.getPlatformSaved(index)) { + for (int index = 0; index < GlobalData.openingPlatformList.size(); index++) { + if (!GlobalData.openingPlatformList.getPlatformSaved(index)) { savePlatform(index); } } @@ -3120,7 +2972,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele **/ private void exit() { int result = -1; - if (!openingModuleList.isSaved() || !openingPackageList.isSaved() || !openingPlatformList.isSaved()) { + if (!GlobalData.openingModuleList.isSaved() || !GlobalData.openingPackageList.isSaved() + || !GlobalData.openingPlatformList.isSaved()) { result = showSaveDialog(); } if (result == JOptionPane.YES_OPTION) { @@ -3275,29 +3128,30 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele } if (result == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) { Tools.showInformationMessage("Module Surface Area Clone Finished"); - vModuleList.addElement(c.getMid()); + GlobalData.vModuleList.addElement(c.getMid()); addModuleToTree(c.getMid()); } if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { Tools.showInformationMessage("Package Surface Area Clone Finished"); - vPackageList.addElement(c.getPid()); + GlobalData.vPackageList.addElement(c.getPid()); // // Add new SpdHeader node to the tree // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(), + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(GlobalData.vPackageList.lastElement().getName(), IDefaultMutableTreeNode.SPD_HEADER, true, - vPackageList.lastElement()); + GlobalData.vPackageList.lastElement()); iTree.addNode(dmtnPackageDescription, node); } if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { Tools.showInformationMessage("Platform Surface Area Clone Finished"); - vPlatformList.addElement(c.getFid()); + GlobalData.vPlatformList.addElement(c.getFid()); // // Add new SpdHeader node to the tree // - IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPlatformList.lastElement().getName(), + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode( + GlobalData.vPlatformList.lastElement().getName(), IDefaultMutableTreeNode.FPD_PLATFORMHEADER, - true, vPlatformList.lastElement()); + true, GlobalData.vPlatformList.lastElement()); iTree.addNode(dmtnPlatformDescription, node); //this.openPlatform(c.getFid().getPath()); } @@ -3326,18 +3180,22 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele // // Enable close/close all if some files are opened // - jMenuItemFileClose.setEnabled(openingModuleList.isOpend() || openingPackageList.isOpend() - || openingPlatformList.isOpend()); - jMenuItemFileCloseAll.setEnabled(openingModuleList.isOpend() || openingPackageList.isOpend() - || openingPlatformList.isOpend()); + jMenuItemFileClose.setEnabled(GlobalData.openingModuleList.isOpen() + || GlobalData.openingPackageList.isOpen() + || GlobalData.openingPlatformList.isOpen()); + jMenuItemFileCloseAll.setEnabled(GlobalData.openingModuleList.isOpen() + || GlobalData.openingPackageList.isOpen() + || GlobalData.openingPlatformList.isOpen()); // // Enable save/save all if some files are changed // - jMenuItemFileSave.setEnabled(!openingModuleList.isSaved() || !openingPackageList.isSaved() - || !openingPlatformList.isSaved()); - jMenuItemFileSaveAll.setEnabled(!openingModuleList.isSaved() || !openingPackageList.isSaved() - || !openingPlatformList.isSaved()); + jMenuItemFileSave.setEnabled(!GlobalData.openingModuleList.isSaved() + || !GlobalData.openingPackageList.isSaved() + || !GlobalData.openingPlatformList.isSaved()); + jMenuItemFileSaveAll.setEnabled(!GlobalData.openingModuleList.isSaved() + || !GlobalData.openingPackageList.isSaved() + || !GlobalData.openingPlatformList.isSaved()); } if (arg0.getSource() == jMenuTools) { diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/SelectModuleBelong.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/SelectModuleBelong.java index 3e08196938..f5ba066b2f 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/SelectModuleBelong.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/SelectModuleBelong.java @@ -28,9 +28,9 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; -import org.tianocore.ModuleSurfaceAreaDocument; import org.tianocore.MsaHeaderDocument; import org.tianocore.SpdHeaderDocument; +import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea; import org.tianocore.PlatformHeaderDocument.PlatformHeader; import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea; @@ -109,6 +109,12 @@ public class SelectModuleBelong extends IDialog { private PackageIdentification pid = null; private PlatformIdentification fid = null; + + private ModuleSurfaceArea msa = null; + + private PackageSurfaceArea spd = null; + + private PlatformSurfaceArea fpd = null; private int mode = -1; @@ -572,7 +578,7 @@ public class SelectModuleBelong extends IDialog { **/ private void saveModule() { - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; + msa = null; String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText()); // @@ -581,7 +587,7 @@ public class SelectModuleBelong extends IDialog { try { MsaHeaderDocument.MsaHeader msaHeader = null; - msa = ModuleSurfaceAreaDocument.ModuleSurfaceArea.Factory.newInstance(); + msa = ModuleSurfaceArea.Factory.newInstance(); msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance(); msaHeader.setModuleName(this.jTextFieldName.getText()); @@ -618,7 +624,7 @@ public class SelectModuleBelong extends IDialog { **/ private void savePackage() { - PackageSurfaceArea spd = null; + spd = null; String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText()); // @@ -664,7 +670,7 @@ public class SelectModuleBelong extends IDialog { **/ private void savePlatform() { - PlatformSurfaceArea fpd = null; + fpd = null; String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText()); // @@ -709,27 +715,27 @@ public class SelectModuleBelong extends IDialog { return mid; } - public void setMid(ModuleIdentification mid) { - this.mid = mid; - } - public PlatformIdentification getFid() { return fid; } - public void setFid(PlatformIdentification fid) { - this.fid = fid; - } - public PackageIdentification getPid() { return pid; } - public void setPid(PackageIdentification pid) { - this.pid = pid; - } - private void upLocation(Component c, int size) { c.setLocation(c.getLocation().x, c.getLocation().y - size); } + + public PlatformSurfaceArea getFpd() { + return fpd; + } + + public ModuleSurfaceArea getMsa() { + return msa; + } + + public PackageSurfaceArea getSpd() { + return spd; + } } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java index 5525b0a867..30454ec1a3 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java @@ -237,4 +237,11 @@ public class DataType { // Hex String Header // public static final String HEX_STRING_HEADER = "0x"; + + // + // The String of Boolean + // + public static final String TRUE = "True"; + + public static final String FALSE = "False"; } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java index b347fa861c..e2981d0a2e 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java @@ -293,8 +293,8 @@ public class EnumerationData { private void initBoolean() { vBoolean.removeAllElements(); - vBoolean.addElement("False"); - vBoolean.addElement("True"); + vBoolean.addElement(DataType.FALSE); + vBoolean.addElement(DataType.TRUE); } private void initModuleType() { diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/GlobalData.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/GlobalData.java new file mode 100644 index 0000000000..2d4fbe4699 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/GlobalData.java @@ -0,0 +1,193 @@ +/** @file + The file is used to provide initializing global data. + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + **/ +package org.tianocore.frameworkwizard.common; + +import java.io.IOException; +import java.util.Vector; + +import org.apache.xmlbeans.XmlException; +import org.tianocore.FrameworkDatabaseDocument.FrameworkDatabase; +import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; +import org.tianocore.MsaFilesDocument.MsaFiles; +import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea; +import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea; +import org.tianocore.frameworkwizard.common.Identifications.Identification; +import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleList; +import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageList; +import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformList; +import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; +import org.tianocore.frameworkwizard.packaging.PackageIdentification; +import org.tianocore.frameworkwizard.platform.PlatformIdentification; +import org.tianocore.frameworkwizard.workspace.Workspace; + +public class GlobalData { + + public static FrameworkDatabase fdb = null; + + public static OpeningModuleList openingModuleList = new OpeningModuleList(); + + public static OpeningPackageList openingPackageList = new OpeningPackageList(); + + public static OpeningPlatformList openingPlatformList = new OpeningPlatformList(); + + public static Vector vModuleList = new Vector(); + + public static Vector vPackageList = new Vector(); + + public static Vector vPlatformList = new Vector(); + + public static void init() { + initDatabase(); + initPackage(); + initPlatform(); + initModule(); + } + + public static void initDatabase() { + String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); + strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); + try { + fdb = OpenFile.openFrameworkDb(strFrameworkDbFilePath); + } catch (XmlException e) { + Log.err("Open Framework Database " + strFrameworkDbFilePath, e.getMessage()); + return; + } catch (Exception e) { + Log.err("Open Framework Database " + strFrameworkDbFilePath, "Invalid file type"); + return; + } + } + + public static void initModule() { + vModuleList = new Vector(); + openingModuleList = new OpeningModuleList(); + + ModuleSurfaceArea msa = null; + Vector modulePaths = new Vector(); + Identification id = null; + ModuleIdentification mid = null; + String packagePath = null; + String modulePath = null; + + // + // For each package, get all modules list + // + if (vPackageList.size() > 0) { + for (int indexI = 0; indexI < vPackageList.size(); indexI++) { + packagePath = vPackageList.elementAt(indexI).getPath(); + modulePaths = getAllModulesOfPackage(packagePath); + + for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) { + try { + modulePath = modulePaths.get(indexJ); + msa = OpenFile.openMsaFile(modulePath); + + } catch (IOException e) { + Log.err("Open Module Surface Area " + modulePath, e.getMessage()); + } catch (XmlException e) { + Log.err("Open Module Surface Area " + modulePath, e.getMessage()); + } catch (Exception e) { + Log.err("Open Module Surface Area " + modulePath, "Invalid file type"); + } + id = Tools.getId(modulePath, msa); + mid = new ModuleIdentification(id, vPackageList.elementAt(indexI)); + vModuleList.addElement(mid); + openingModuleList.insertToOpeningModuleList(mid, msa); + } + } + Sort.sortModules(vModuleList, DataType.SORT_TYPE_ASCENDING); + } + } + + public static void initPackage() { + vPackageList = new Vector(); + openingPackageList = new OpeningPackageList(); + if (fdb != null) { + for (int index = 0; index < fdb.getPackageList().getFilenameList().size(); index++) { + String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + + fdb.getPackageList().getFilenameArray(index).getStringValue(); + path = Tools.convertPathToCurrentOsType(path); + PackageSurfaceArea spd = null; + PackageIdentification id = null; + try { + spd = OpenFile.openSpdFile(path); + } catch (IOException e) { + Log.err("Open Package Surface Area " + path, e.getMessage()); + } catch (XmlException e) { + Log.err("Open Package Surface Area " + path, e.getMessage()); + } catch (Exception e) { + Log.err("Open Package Surface Area " + path, "Invalid file type"); + } + id = Tools.getId(path, spd); + vPackageList.addElement(id); + openingPackageList.insertToOpeningPackageList(id, spd); + } + Sort.sortPackages(vPackageList, DataType.SORT_TYPE_ASCENDING); + } + } + + public static void initPlatform() { + vPlatformList = new Vector(); + openingPlatformList = new OpeningPlatformList(); + + if (fdb != null) { + for (int index = 0; index < fdb.getPlatformList().getFilenameList().size(); index++) { + String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + + fdb.getPlatformList().getFilenameArray(index).getStringValue(); + path = Tools.convertPathToCurrentOsType(path); + PlatformSurfaceArea fpd = null; + PlatformIdentification id = null; + try { + fpd = OpenFile.openFpdFile(path); + } catch (IOException e) { + Log.err("Open Platform Surface Area " + path, e.getMessage()); + } catch (XmlException e) { + Log.err("Open Platform Surface Area " + path, e.getMessage()); + } catch (Exception e) { + Log.err("Open Platform Surface Area " + path, "Invalid file type"); + } + id = Tools.getId(path, fpd); + vPlatformList.addElement(new PlatformIdentification(id)); + openingPlatformList.insertToOpeningPlatformList(id, fpd); + } + Sort.sortPlatforms(vPlatformList, DataType.SORT_TYPE_ASCENDING); + } + } + + /** + Get all modules' paths from one package + + @return a Vector with all modules' path + + **/ + private static Vector getAllModulesOfPackage(String path) { + Vector modulePath = new Vector(); + try { + MsaFiles files = OpenFile.openSpdFile(path).getMsaFiles(); + if (files != null) { + for (int index = 0; index < files.getFilenameList().size(); index++) { + String msaPath = files.getFilenameList().get(index); + msaPath = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + msaPath; + msaPath = Tools.convertPathToCurrentOsType(msaPath); + modulePath.addElement(msaPath); + } + } + } catch (IOException e) { + Log.err("Get all mdoules of a package " + path, e.getMessage()); + } catch (XmlException e) { + Log.err("Get all mdoules of a package " + path, e.getMessage()); + } catch (Exception e) { + Log.err("Get all mdoules of a package " + path, e.getMessage()); + } + return modulePath; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/Identification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/Identification.java index bc296474e6..03717b560b 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/Identification.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/Identification.java @@ -49,7 +49,6 @@ public class Identification { if (obj instanceof Identification) { Identification id = (Identification) obj; if (path.equals(id.path)) { - //if ( name.equals(id.name) && guid.equals(id.guid) && version.equals(id.version)) { return true; } return false; 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 c75ee8d835..14890286ca 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 @@ -22,36 +22,22 @@ public class OpeningFileType { // // Define class members // - - private Identification id = null; - private boolean isSaved = true; private boolean isNew = false; + private boolean isOpen = false; + private TreePath treePath = null; public OpeningFileType() { } - public OpeningFileType(Identification identification) { - this.id = identification; - } - - public OpeningFileType(Identification identification, TreePath treePathValue) { - this.id = identification; + public OpeningFileType(TreePath treePathValue) { this.treePath = treePathValue; } - public Identification getId() { - return id; - } - - public void setId(Identification id) { - this.id = id; - } - public boolean isNew() { return isNew; } @@ -75,4 +61,12 @@ public class OpeningFileType { public void setTreePath(TreePath treePath) { this.treePath = treePath; } + + public boolean isOpen() { + return isOpen; + } + + public void setOpen(boolean isOpen) { + this.isOpen = isOpen; + } } 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 6796b17bc9..eab8d2a824 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 @@ -19,6 +19,7 @@ import java.util.Vector; import javax.swing.tree.TreePath; import org.tianocore.ModuleSurfaceAreaDocument; +import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; public class OpeningModuleList { private Vector vOpeningModuleList = new Vector(); @@ -34,7 +35,7 @@ public class OpeningModuleList { vOpeningModuleList = openingModuleList; } - public void insertToOpeningModuleList(Identification id, ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa) { + public void insertToOpeningModuleList(ModuleIdentification id, ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa) { vOpeningModuleList.addElement(new OpeningModuleType(id, xmlMsa)); } @@ -45,7 +46,7 @@ public class OpeningModuleList { return null; } - public OpeningModuleType getOpeningModuleById(Identification id) { + public OpeningModuleType getOpeningModuleById(ModuleIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningModuleList.elementAt(index); @@ -53,7 +54,7 @@ public class OpeningModuleList { return null; } - public int findIndexOfListById(Identification id) { + public int findIndexOfListById(ModuleIdentification id) { for (int index = 0; index < vOpeningModuleList.size(); index++) { if (vOpeningModuleList.elementAt(index).getId().equals(id)) { return index; @@ -68,7 +69,7 @@ public class OpeningModuleList { } } - public void removeFromOpeningModuleListById(Identification id) { + public void removeFromOpeningModuleListById(ModuleIdentification id) { int index = findIndexOfListById(id); if (index > -1) { vOpeningModuleList.removeElementAt(findIndexOfListById(id)); @@ -79,7 +80,7 @@ public class OpeningModuleList { vOpeningModuleList.removeAllElements(); } - public ModuleSurfaceAreaDocument.ModuleSurfaceArea getModuleSurfaceAreaFromId(Identification id) { + public ModuleSurfaceAreaDocument.ModuleSurfaceArea getModuleSurfaceAreaFromId(ModuleIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningModuleList.elementAt(index).getXmlMsa(); @@ -87,7 +88,7 @@ public class OpeningModuleList { return null; } - public boolean existsModule(Identification id) { + public boolean existsModule(ModuleIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return true; @@ -95,7 +96,7 @@ public class OpeningModuleList { return false; } - public void setModuleSaved(Identification id, boolean isSaved) { + public void setModuleSaved(ModuleIdentification id, boolean isSaved) { setModuleSaved(findIndexOfListById(id), isSaved); } @@ -105,7 +106,7 @@ public class OpeningModuleList { } } - public boolean getModuleSaved(Identification id) { + public boolean getModuleSaved(ModuleIdentification id) { return getModuleSaved(findIndexOfListById(id)); } @@ -116,14 +117,35 @@ public class OpeningModuleList { return true; } - public void setTreePathById(Identification id, TreePath treePath) { + 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) { int index = findIndexOfListById(id); if (index > -1) { vOpeningModuleList.elementAt(index).setTreePath(treePath); } } - public TreePath getTreePathById(Identification id) { + public TreePath getTreePathById(ModuleIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningModuleList.elementAt(index).getTreePath(); @@ -138,13 +160,28 @@ public class OpeningModuleList { return null; } - public void setNew(Identification id, boolean isNew) { + public ModuleIdentification getIdByPath(String path) { + ModuleIdentification id = new ModuleIdentification(null, null, null, path); + int index = findIndexOfListById(id); + if (index > -1) { + return vOpeningModuleList.elementAt(index).getId(); + } + 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); + } + } + public int size() { return vOpeningModuleList.size(); } @@ -158,9 +195,11 @@ public class OpeningModuleList { return true; } - public boolean isOpend() { - if (this.size() > 0 ) { - return true; + public boolean isOpen() { + for (int index = 0; index < this.size(); index++) { + if (this.getModuleOpen(index)) { + return true; + } } return false; } 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 d44c86178d..2ead77a84f 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 @@ -18,6 +18,7 @@ package org.tianocore.frameworkwizard.common.Identifications; import javax.swing.tree.TreePath; import org.tianocore.ModuleSurfaceAreaDocument; +import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; public class OpeningModuleType extends OpeningFileType{ // @@ -25,17 +26,21 @@ public class OpeningModuleType extends OpeningFileType{ // private ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa = null; + private ModuleIdentification id = null; + public OpeningModuleType() { } - public OpeningModuleType(Identification identification, ModuleSurfaceAreaDocument.ModuleSurfaceArea msa) { - super(identification); + public OpeningModuleType(ModuleIdentification identification, ModuleSurfaceAreaDocument.ModuleSurfaceArea msa) { + this.id = identification; this.xmlMsa = msa; } - public OpeningModuleType(Identification identification, ModuleSurfaceAreaDocument.ModuleSurfaceArea msa, TreePath treePath) { - super(identification, treePath); + public OpeningModuleType(ModuleIdentification identification, ModuleSurfaceAreaDocument.ModuleSurfaceArea msa, TreePath treePath) { + super(treePath); + + this.id = identification; this.xmlMsa = msa; } @@ -46,4 +51,12 @@ public class OpeningModuleType extends OpeningFileType{ public void setXmlMsa(ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa) { this.xmlMsa = xmlMsa; } + + public ModuleIdentification getId() { + return id; + } + + public void setId(ModuleIdentification id) { + this.id = id; + } } 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 0b4f9a5144..b53a5bd89c 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 @@ -19,6 +19,7 @@ import java.util.Vector; import javax.swing.tree.TreePath; import org.tianocore.PackageSurfaceAreaDocument; +import org.tianocore.frameworkwizard.packaging.PackageIdentification; public class OpeningPackageList { private Vector vOpeningPackageList = new Vector(); @@ -35,7 +36,7 @@ public class OpeningPackageList { vOpeningPackageList = openingPackageList; } - public void insertToOpeningPackageList(Identification id, PackageSurfaceAreaDocument.PackageSurfaceArea xmlMsa) { + public void insertToOpeningPackageList(PackageIdentification id, PackageSurfaceAreaDocument.PackageSurfaceArea xmlMsa) { vOpeningPackageList.addElement(new OpeningPackageType(id, xmlMsa)); } @@ -46,7 +47,7 @@ public class OpeningPackageList { return null; } - public OpeningPackageType getOpeningPackageById(Identification id) { + public OpeningPackageType getOpeningPackageById(PackageIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningPackageList.elementAt(index); @@ -54,7 +55,7 @@ public class OpeningPackageList { return null; } - public int findIndexOfListById(Identification id) { + public int findIndexOfListById(PackageIdentification id) { for (int index = 0; index < vOpeningPackageList.size(); index++) { if (vOpeningPackageList.elementAt(index).getId().equals(id)) { return index; @@ -69,7 +70,7 @@ public class OpeningPackageList { } } - public void removeFromOpeningPackageListById(Identification id) { + public void removeFromOpeningPackageListById(PackageIdentification id) { int index = findIndexOfListById(id); if (index > -1) { vOpeningPackageList.removeElementAt(findIndexOfListById(id)); @@ -80,7 +81,7 @@ public class OpeningPackageList { vOpeningPackageList.removeAllElements(); } - public PackageSurfaceAreaDocument.PackageSurfaceArea getPackageSurfaceAreaFromId(Identification id) { + public PackageSurfaceAreaDocument.PackageSurfaceArea getPackageSurfaceAreaFromId(PackageIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningPackageList.elementAt(index).getXmlSpd(); @@ -88,7 +89,7 @@ public class OpeningPackageList { return null; } - public boolean existsPackage(Identification id) { + public boolean existsPackage(PackageIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return true; @@ -96,7 +97,7 @@ public class OpeningPackageList { return false; } - public void setPackageSaved(Identification id, boolean isSaved) { + public void setPackageSaved(PackageIdentification id, boolean isSaved) { setPackageSaved(findIndexOfListById(id), isSaved); } @@ -106,7 +107,7 @@ public class OpeningPackageList { } } - public boolean getPackageSaved(Identification id) { + public boolean getPackageSaved(PackageIdentification id) { return getPackageSaved(findIndexOfListById(id)); } @@ -117,14 +118,35 @@ public class OpeningPackageList { return true; } - public void setTreePathById(Identification id, TreePath treePath) { + public void setPackageOpen(PackageIdentification id, boolean isOpem) { + setPackageOpen(findIndexOfListById(id), isOpem); + } + + public void setPackageOpen(int index, boolean isOpem) { + if (index > -1) { + vOpeningPackageList.elementAt(index).setOpen(isOpem); + } + } + + public boolean getPackageOpen(PackageIdentification id) { + return getPackageOpen(findIndexOfListById(id)); + } + + public boolean getPackageOpen(int index) { + if (index > -1) { + return vOpeningPackageList.elementAt(index).isOpen(); + } + return true; + } + + public void setTreePathById(PackageIdentification id, TreePath treePath) { int index = findIndexOfListById(id); if (index > -1) { vOpeningPackageList.elementAt(index).setTreePath(treePath); } } - public TreePath getTreePathById(Identification id) { + public TreePath getTreePathById(PackageIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningPackageList.elementAt(index).getTreePath(); @@ -139,13 +161,28 @@ public class OpeningPackageList { return null; } - public void setNew(Identification id, boolean isNew) { + public PackageIdentification getIdByPath(String path) { + PackageIdentification id = new PackageIdentification(null, null, null, path); + int index = findIndexOfListById(id); + if (index > -1) { + return vOpeningPackageList.elementAt(index).getId(); + } + return null; + } + + public void setNew(PackageIdentification id, boolean isNew) { int index = findIndexOfListById(id); if (index > -1) { vOpeningPackageList.elementAt(index).setNew(isNew); } } + public void closeAll() { + for (int index = 0; index < this.size(); index++) { + this.setPackageOpen(index, false); + } + } + public int size() { return vOpeningPackageList.size(); } @@ -159,9 +196,11 @@ public class OpeningPackageList { return true; } - public boolean isOpend() { - if (this.size() > 0 ) { - return true; + public boolean isOpen() { + for (int index = 0; index < this.size(); index++) { + if (this.getPackageOpen(index)) { + return true; + } } return false; } 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 73df9f2626..51ca083f46 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 @@ -17,6 +17,7 @@ package org.tianocore.frameworkwizard.common.Identifications; import javax.swing.tree.TreePath; import org.tianocore.PackageSurfaceAreaDocument; +import org.tianocore.frameworkwizard.packaging.PackageIdentification; public class OpeningPackageType extends OpeningFileType { // @@ -24,17 +25,21 @@ public class OpeningPackageType extends OpeningFileType { // private PackageSurfaceAreaDocument.PackageSurfaceArea xmlSpd = null; + private PackageIdentification id = null; + public OpeningPackageType() { } - public OpeningPackageType(Identification identification, PackageSurfaceAreaDocument.PackageSurfaceArea spd) { - super(identification); + public OpeningPackageType(PackageIdentification identification, PackageSurfaceAreaDocument.PackageSurfaceArea spd) { + this.id = identification; this.xmlSpd = spd; } - public OpeningPackageType(Identification identification, PackageSurfaceAreaDocument.PackageSurfaceArea spd, TreePath treePath) { - super(identification, treePath); + public OpeningPackageType(PackageIdentification identification, PackageSurfaceAreaDocument.PackageSurfaceArea spd, TreePath treePath) { + super(treePath); + + this.id = identification; this.xmlSpd = spd; } @@ -45,4 +50,12 @@ public class OpeningPackageType extends OpeningFileType { public void setXmlSpd(PackageSurfaceAreaDocument.PackageSurfaceArea xmlSpd) { this.xmlSpd = xmlSpd; } + + public PackageIdentification getId() { + return id; + } + + public void setId(PackageIdentification id) { + this.id = id; + } } 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 3389d7081a..343d8ee6fc 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 @@ -19,6 +19,7 @@ import java.util.Vector; import javax.swing.tree.TreePath; import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.frameworkwizard.platform.PlatformIdentification; public class OpeningPlatformList { @@ -36,7 +37,7 @@ public class OpeningPlatformList { vOpeningPlatformList = openingPlatformList; } - public void insertToOpeningPlatformList(Identification id, PlatformSurfaceAreaDocument.PlatformSurfaceArea xmlFpd) { + public void insertToOpeningPlatformList(PlatformIdentification id, PlatformSurfaceAreaDocument.PlatformSurfaceArea xmlFpd) { vOpeningPlatformList.addElement(new OpeningPlatformType(id, xmlFpd)); } @@ -47,7 +48,7 @@ public class OpeningPlatformList { return null; } - public OpeningPlatformType getOpeningPlatformById(Identification id) { + public OpeningPlatformType getOpeningPlatformById(PlatformIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningPlatformList.elementAt(index); @@ -55,7 +56,7 @@ public class OpeningPlatformList { return null; } - public int findIndexOfListById(Identification id) { + public int findIndexOfListById(PlatformIdentification id) { for (int index = 0; index < vOpeningPlatformList.size(); index++) { if (vOpeningPlatformList.elementAt(index).getId().equals(id)) { return index; @@ -70,7 +71,7 @@ public class OpeningPlatformList { } } - public void removeFromOpeningPlatformListById(Identification id) { + public void removeFromOpeningPlatformListById(PlatformIdentification id) { int index = findIndexOfListById(id); if (index > -1) { vOpeningPlatformList.removeElementAt(findIndexOfListById(id)); @@ -81,7 +82,7 @@ public class OpeningPlatformList { vOpeningPlatformList.removeAllElements(); } - public PlatformSurfaceAreaDocument.PlatformSurfaceArea getPlatformSurfaceAreaFromId(Identification id) { + public PlatformSurfaceAreaDocument.PlatformSurfaceArea getPlatformSurfaceAreaFromId(PlatformIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningPlatformList.elementAt(index).getXmlFpd(); @@ -89,7 +90,7 @@ public class OpeningPlatformList { return null; } - public boolean existsPlatform(Identification id) { + public boolean existsPlatform(PlatformIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return true; @@ -98,7 +99,7 @@ public class OpeningPlatformList { } - public void setPlatformSaved(Identification id, boolean isSaved) { + public void setPlatformSaved(PlatformIdentification id, boolean isSaved) { setPlatformSaved(findIndexOfListById(id), isSaved); } @@ -108,7 +109,7 @@ public class OpeningPlatformList { } } - public boolean getPlatformSaved(Identification id) { + public boolean getPlatformSaved(PlatformIdentification id) { return getPlatformSaved(findIndexOfListById(id)); } @@ -119,14 +120,35 @@ public class OpeningPlatformList { return true; } - public void setTreePathById(Identification id, TreePath treePath) { + public void setPlatformOpen(PlatformIdentification id, boolean isOpen) { + setPlatformOpen(findIndexOfListById(id), isOpen); + } + + public void setPlatformOpen(int index, boolean isOpen) { + if (index > -1) { + vOpeningPlatformList.elementAt(index).setOpen(isOpen); + } + } + + public boolean getPlatformOpen(PlatformIdentification id) { + return getPlatformOpen(findIndexOfListById(id)); + } + + public boolean getPlatformOpen(int index) { + if (index > -1) { + return vOpeningPlatformList.elementAt(index).isOpen(); + } + return true; + } + + public void setTreePathById(PlatformIdentification id, TreePath treePath) { int index = findIndexOfListById(id); if (index > -1) { vOpeningPlatformList.elementAt(index).setTreePath(treePath); } } - public TreePath getTreePathById(Identification id) { + public TreePath getTreePathById(PlatformIdentification id) { int index = findIndexOfListById(id); if (index > -1) { return vOpeningPlatformList.elementAt(index).getTreePath(); @@ -141,13 +163,28 @@ public class OpeningPlatformList { return null; } - public void setNew(Identification id, boolean isNew) { + public PlatformIdentification getIdByPath(String path) { + PlatformIdentification id = new PlatformIdentification(null, null, null, path); + int index = findIndexOfListById(id); + if (index > -1) { + return vOpeningPlatformList.elementAt(index).getId(); + } + return null; + } + + public void setNew(PlatformIdentification id, boolean isNew) { int index = findIndexOfListById(id); if (index > -1) { vOpeningPlatformList.elementAt(index).setNew(isNew); } } + public void closeAll() { + for (int index = 0; index < this.size(); index++) { + this.setPlatformOpen(index, false); + } + } + public int size() { return vOpeningPlatformList.size(); } @@ -161,9 +198,11 @@ public class OpeningPlatformList { return true; } - public boolean isOpend() { - if (this.size() > 0 ) { - return true; + public boolean isOpen() { + for (int index = 0; index < this.size(); index++) { + if (this.getPlatformOpen(index)) { + return true; + } } return false; } 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 cc6a3f9c77..c81f4eef05 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 @@ -17,6 +17,7 @@ package org.tianocore.frameworkwizard.common.Identifications; import javax.swing.tree.TreePath; import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.frameworkwizard.platform.PlatformIdentification; public class OpeningPlatformType extends OpeningFileType { // @@ -24,17 +25,20 @@ public class OpeningPlatformType extends OpeningFileType { // private PlatformSurfaceAreaDocument.PlatformSurfaceArea xmlFpd = null; + private PlatformIdentification id = null; + public OpeningPlatformType() { } - public OpeningPlatformType(Identification identification, PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) { - super(identification); + public OpeningPlatformType(PlatformIdentification identification, PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) { + this.id = identification; this.xmlFpd = fpd; } - public OpeningPlatformType(Identification identification, PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd, TreePath treePath) { - super(identification, treePath); + public OpeningPlatformType(PlatformIdentification identification, PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd, TreePath treePath) { + super(treePath); + this.id = identification; this.xmlFpd = fpd; } @@ -45,4 +49,12 @@ public class OpeningPlatformType extends OpeningFileType { public void setXmlFpd(PlatformSurfaceAreaDocument.PlatformSurfaceArea xmlFpd) { this.xmlFpd = xmlFpd; } + + public PlatformIdentification getId() { + return id; + } + + public void setId(PlatformIdentification id) { + this.id = id; + } } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java index d5d16b8d65..a5345019ea 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java @@ -27,6 +27,16 @@ import javax.swing.JComboBox; import javax.swing.JList; import javax.swing.JOptionPane; +import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; +import org.tianocore.MsaHeaderDocument.MsaHeader; +import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea; +import org.tianocore.PlatformHeaderDocument.PlatformHeader; +import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea; +import org.tianocore.SpdHeaderDocument.SpdHeader; +import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; +import org.tianocore.frameworkwizard.packaging.PackageIdentification; +import org.tianocore.frameworkwizard.platform.PlatformIdentification; + /** The class is used to provides some useful interfaces @@ -457,4 +467,31 @@ public class Tools { // return hexString.trim(); } + + public static ModuleIdentification getId(String path, ModuleSurfaceArea msa) { + MsaHeader head = msa.getMsaHeader(); + String name = head.getModuleName(); + String guid = head.getGuidValue(); + String version = head.getVersion(); + ModuleIdentification id = new ModuleIdentification(name, guid, version, path); + return id; + } + + public static PackageIdentification getId(String path, PackageSurfaceArea spd) { + SpdHeader head = spd.getSpdHeader(); + String name = head.getPackageName(); + String guid = head.getGuidValue(); + String version = head.getVersion(); + PackageIdentification id = new PackageIdentification(name, guid, version, path); + return id; + } + + public static PlatformIdentification getId(String path, PlatformSurfaceArea fpd) { + PlatformHeader head = fpd.getPlatformHeader(); + String name = head.getPlatformName(); + String guid = head.getGuidValue(); + String version = head.getVersion(); + PlatformIdentification id = new PlatformIdentification(name, guid, version, path); + return id; + } } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ArchCheckBox.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ArchCheckBox.java index 0e051d421b..76c29da157 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ArchCheckBox.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ArchCheckBox.java @@ -17,15 +17,15 @@ package org.tianocore.frameworkwizard.common.ui; import java.util.Vector; -import javax.swing.JPanel; import javax.swing.JCheckBox; +import javax.swing.JPanel; import org.tianocore.frameworkwizard.common.DataType; public class ArchCheckBox extends JPanel { /// - /// + /// Define class members /// private static final long serialVersionUID = 4792669775676953990L; @@ -40,7 +40,7 @@ public class ArchCheckBox extends JPanel { private JCheckBox jCheckBoxArm = null; private JCheckBox jCheckBoxPpc = null; - + /** * This method initializes jCheckBoxIa32 * @@ -131,16 +131,6 @@ public class ArchCheckBox extends JPanel { return jCheckBoxPpc; } - /** - - @param args - - **/ - public static void main(String[] args) { - // TODO Auto-generated method stub - - } - /** * This is the default constructor */ diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/PackageQuery.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/PackageQuery.java index a3ebfed8de..f76af054ba 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/PackageQuery.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/PackageQuery.java @@ -26,6 +26,7 @@ import org.tianocore.PackageDependenciesDocument; import org.tianocore.PackageSurfaceAreaDocument; import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.frameworkwizard.common.OpenFile; +import org.tianocore.frameworkwizard.common.Tools; import org.tianocore.frameworkwizard.packaging.PackageIdentification; import org.tianocore.frameworkwizard.workspace.WorkspaceTools; @@ -35,8 +36,7 @@ public class PackageQuery implements PackageQueryInterface { PackageIdentification packageId = null; try { String path = spdFile.getPath(); - WorkspaceTools wt = new WorkspaceTools(); - packageId = new PackageIdentification(wt.getId(path, OpenFile.openSpdFile(path))); + packageId = Tools.getId(path, OpenFile.openSpdFile(path)); } catch (Exception e) { e.printStackTrace(); } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/ModuleIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/ModuleIdentification.java index 02189d92ef..d7a9c48fe4 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/ModuleIdentification.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/ModuleIdentification.java @@ -45,6 +45,10 @@ public class ModuleIdentification extends Identification { this.isLibrary = library; } + public ModuleIdentification(Identification id) { + super(id.getName(), id.getGuid(), id.getVersion(), id.getPath()); + } + public ModuleIdentification(Identification id, boolean library) { super(id.getName(), id.getGuid(), id.getVersion(), id.getPath()); this.isLibrary = library; diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDefinitions.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDefinitions.java deleted file mode 100644 index a427b2f770..0000000000 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDefinitions.java +++ /dev/null @@ -1,362 +0,0 @@ -/** @file - - The file is used to create, update Module Definitions of MSA file - - Copyright (c) 2006, Intel Corporation - All rights reserved. This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - **/ -package org.tianocore.frameworkwizard.module.ui; - -import java.awt.event.ComponentEvent; -import java.awt.event.FocusEvent; - -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JComboBox; - -import org.tianocore.ModuleDefinitionsDocument; -import org.tianocore.ModuleSurfaceAreaDocument; -import org.tianocore.ModuleDefinitionsDocument.ModuleDefinitions.ClonedFrom; -import org.tianocore.frameworkwizard.common.DataValidation; -import org.tianocore.frameworkwizard.common.EnumerationData; -import org.tianocore.frameworkwizard.common.Log; -import org.tianocore.frameworkwizard.common.Tools; -import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType; -import org.tianocore.frameworkwizard.common.ui.IInternalFrame; -import org.tianocore.frameworkwizard.common.ui.StarLabel; -import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList; - -public class ModuleDefinitions extends IInternalFrame { - - /// - /// Define class Serial Version UID - /// - private static final long serialVersionUID = 5860378543553036323L; - - private JScrollPane jScrollPane = null; - - private JPanel jContentPane = null; - - private JLabel jLabelArch = null; - - private ICheckBoxList iCheckBoxListArch = null; - - private JLabel jLabelBinaryModule = null; - - private JComboBox jComboBoxBinaryModule = null; - - private JLabel jLabelOutputFileBasename = null; - - private JTextField jTextFieldOutputFileBasename = null; - - private JScrollPane jScrollPaneArch = null; - - private StarLabel jStarLabel1 = null; - - private StarLabel jStarLabel2 = null; - - private StarLabel jStarLabel3 = null; - - private OpeningModuleType omt = null; - - private ClonedFrom cf = null; - - private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; - - private ModuleDefinitionsDocument.ModuleDefinitions md = null; - - /** - * This method initializes jScrollPane - * - * @return javax.swing.JScrollPane - */ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setViewportView(getJContentPane()); - } - return jScrollPane; - } - - /** - * This method initializes jPanel - * - * @return javax.swing.JPanel - */ - private JPanel getJContentPane() { - if (jContentPane == null) { - jLabelOutputFileBasename = new JLabel(); - jLabelOutputFileBasename.setBounds(new java.awt.Rectangle(15, 10, 140, 20)); - jLabelOutputFileBasename.setText("Output File Basename"); - jLabelBinaryModule = new JLabel(); - jLabelBinaryModule.setBounds(new java.awt.Rectangle(15, 35, 140, 20)); - jLabelBinaryModule.setText("Binary Module"); - jLabelArch = new JLabel(); - jLabelArch.setBounds(new java.awt.Rectangle(15, 60, 140, 20)); - jLabelArch.setText("Supported Architectures"); - jStarLabel1 = new StarLabel(); - jStarLabel1.setLocation(new java.awt.Point(0, 10)); - jStarLabel2 = new StarLabel(); - jStarLabel2.setLocation(new java.awt.Point(0, 35)); - jStarLabel3 = new StarLabel(); - jStarLabel3.setLocation(new java.awt.Point(0, 60)); - - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.setPreferredSize(new java.awt.Dimension(490, 150)); - - jContentPane.add(jLabelArch, null); - jContentPane.add(getJScrollPaneArch(), null); - jContentPane.add(jLabelBinaryModule, null); - jContentPane.add(getJComboBoxBinaryModule(), null); - jContentPane.add(jLabelOutputFileBasename, null); - jContentPane.add(getJTextFieldOutputFileBasename(), null); - jContentPane.add(jStarLabel1, null); - jContentPane.add(jStarLabel2, null); - jContentPane.add(jStarLabel3, null); - } - return jContentPane; - } - - /** - This method initializes iCheckBoxListArch - - @return ICheckBoxList - **/ - private ICheckBoxList getICheckBoxListSupportedArchitectures() { - if (iCheckBoxListArch == null) { - iCheckBoxListArch = new ICheckBoxList(); - iCheckBoxListArch.addFocusListener(this); - iCheckBoxListArch.setToolTipText("Deselecting a checkbox will restrict this module
" - + "for use with the selected architectures,
" - + "based on the list of items that are checked.
" - + "If all boxes are checked,
" - + "then the module will support all
" - + "current AND FUTURE architectures"); - } - return iCheckBoxListArch; - } - - /** - * This method initializes jComboBoxBinaryModule - * - * @return javax.swing.JComboBox - */ - private JComboBox getJComboBoxBinaryModule() { - if (jComboBoxBinaryModule == null) { - jComboBoxBinaryModule = new JComboBox(); - jComboBoxBinaryModule.setBounds(new java.awt.Rectangle(160, 35, 320, 20)); - jComboBoxBinaryModule.setPreferredSize(new java.awt.Dimension(320, 20)); - jComboBoxBinaryModule.addFocusListener(this); - jComboBoxBinaryModule.setToolTipText("Modules are either source modules
" - + "which can be compiled or binary
" - + "modules which are linked.
" - + "A module cannot contain both.
" - + "The GUID numbers should be identical
" - + "for a binary and source MSA,
" - + "but the BINARY MSA should have
" - + "a higher version number."); - } - return jComboBoxBinaryModule; - } - - /** - * This method initializes jTextFieldOutputFileBasename - * - * @return javax.swing.JTextField - */ - private JTextField getJTextFieldOutputFileBasename() { - if (jTextFieldOutputFileBasename == null) { - jTextFieldOutputFileBasename = new JTextField(); - jTextFieldOutputFileBasename.setBounds(new java.awt.Rectangle(160, 10, 320, 20)); - jTextFieldOutputFileBasename.setPreferredSize(new java.awt.Dimension(320, 20)); - jTextFieldOutputFileBasename.addFocusListener(this); - jTextFieldOutputFileBasename.setToolTipText("Enter a single word for generated output file names"); - } - return jTextFieldOutputFileBasename; - } - - /** - This method initializes jScrollPaneArch - - @return javax.swing.JScrollPane - - **/ - private JScrollPane getJScrollPaneArch() { - if (jScrollPaneArch == null) { - jScrollPaneArch = new JScrollPane(); - jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 60, 320, 80)); - jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 60)); - jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures()); - } - return jScrollPaneArch; - } - - /** - - @param args - - **/ - public static void main(String[] args) { - // TODO Auto-generated method stub - - } - - /** - * This is the default constructor - */ - public ModuleDefinitions() { - super(); - init(); - this.setVisible(true); - } - - /** - This is the override edit constructor - - @param inMsa - - **/ - public ModuleDefinitions(OpeningModuleType inOmt) { - super(); - this.omt = inOmt; - this.msa = omt.getXmlMsa(); - if (msa.getModuleDefinitions() != null) { - this.cf = msa.getModuleDefinitions().getClonedFrom(); - } - init(msa.getModuleDefinitions()); - this.setVisible(true); - } - - /** - * This method initializes this - * - * @return void - */ - private void init() { - this.setContentPane(getJScrollPane()); - this.setTitle("Module Definitions"); - initFrame(); - this.setPreferredSize(new java.awt.Dimension(490, 520)); - } - - /** - This method initializes this - Fill values to all fields if these values are not empty - - @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader - - **/ - private void init(ModuleDefinitionsDocument.ModuleDefinitions inMd) { - init(); - if (inMd != null) { - this.md = inMd; - if (md.getSupportedArchitectures() != null) { - this.iCheckBoxListArch.initCheckedItem(true, Tools.convertListToVector(md.getSupportedArchitectures())); - } - if (md.getBinaryModule()) { - this.jComboBoxBinaryModule.setSelectedIndex(1); - } else { - this.jComboBoxBinaryModule.setSelectedIndex(0); - } - if (md.getOutputFileBasename() != null) { - this.jTextFieldOutputFileBasename.setText(md.getOutputFileBasename()); - } - } - } - - /** - This method initializes Module type and Compontent type - - **/ - private void initFrame() { - EnumerationData ed = new EnumerationData(); - this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures()); - Tools.generateComboBoxByVector(jComboBoxBinaryModule, ed.getVBoolean()); - } - - private boolean check() { - if (isEmpty(this.jTextFieldOutputFileBasename.getText())) { - Log.wrn("Update Definitions", "Output File Basename couldn't be empty!"); - return false; - } - if (!DataValidation.isOutputFileBasename(this.jTextFieldOutputFileBasename.getText())) { - Log.wrn("Update Definitions", "Incorrect data type for Output File Basename"); - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent) - * - * Override componentResized to resize all components when frame's size is changed - */ - public void componentResized(ComponentEvent arg0) { - int intCurrentWidth = this.getJContentPane().getWidth(); - int intPreferredWidth = this.getJContentPane().getPreferredSize().width; - - resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth); - resizeComponentWidth(this.jComboBoxBinaryModule, intCurrentWidth, intPreferredWidth); - resizeComponentWidth(this.jTextFieldOutputFileBasename, intCurrentWidth, intPreferredWidth); - } - - /** - Save all components of Module Definitions - if exists Module Definitions, set the value directly - if not exists Module Definitions, new an instance first - - **/ - public void save() { - check(); - try { - if (this.md == null) { - md = ModuleDefinitionsDocument.ModuleDefinitions.Factory.newInstance(); - } - - if (!isEmpty(this.jTextFieldOutputFileBasename.getText())) { - md.setOutputFileBasename(this.jTextFieldOutputFileBasename.getText()); - } - - if (this.jComboBoxBinaryModule.getSelectedIndex() == 0) { - md.setBinaryModule(false); - } else { - md.setBinaryModule(true); - } - - // - // Set ClonedFrom field - // - if (this.cf != null) { - md.setClonedFrom(this.cf); - } - - // - // Save Arch list - // - md.setSupportedArchitectures(this.iCheckBoxListArch.getAllCheckedItemsString()); - - msa.setModuleDefinitions(md); - - this.omt.setSaved(false); - - } catch (Exception e) { - Log.err("Save Module Definitions", e.getMessage()); - } - } - - public void focusLost(FocusEvent arg0) { - this.save(); - if (arg0.getSource() == this.jTextFieldOutputFileBasename) { - } - } -} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java index 4f6cc955ff..b20ac3d5f1 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java @@ -18,8 +18,10 @@ package org.tianocore.frameworkwizard.module.ui; import java.awt.event.ActionEvent; import java.awt.event.ComponentEvent; import java.awt.event.FocusEvent; +import java.util.Vector; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; @@ -104,6 +106,26 @@ public class MsaHeader extends IInternalFrame { private JComboBox jComboBoxModuleType = null; + private JLabel jLabelArch = null; + + private JLabel jLabelBinaryModule = null; + + private JComboBox jComboBoxBinaryModule = null; + + private JLabel jLabelOutputFileBasename = null; + + private JTextField jTextFieldOutputFileBasename = null; + + private JScrollPane jScrollPaneCopyright = null; + + private JTextArea jTextAreaCopyright = null; + + private JLabel jLabelURL = null; + + private JTextField jTextFieldURL = null; + + private JScrollPane jScrollPane = null; + private StarLabel jStarLabel1 = null; private StarLabel jStarLabel2 = null; @@ -122,22 +144,133 @@ public class MsaHeader extends IInternalFrame { private StarLabel jStarLabel12 = null; - private MsaHeaderDocument.MsaHeader msaHeader = null; + private StarLabel jStarLabel13 = null; - private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; + private StarLabel jStarLabel14 = null; - private JTextField jTextFieldCopyright = null; + private StarLabel jStarLabel15 = null; - private JLabel jLabelURL = null; + private JCheckBox jCheckBoxIa32 = null; - private JTextField jTextFieldURL = null; + private JCheckBox jCheckBoxX64 = null; - private JScrollPane jScrollPane = null; + private JCheckBox jCheckBoxIpf = null; + + private JCheckBox jCheckBoxEbc = null; + + private JCheckBox jCheckBoxArm = null; + + private JCheckBox jCheckBoxPpc = null; + + // + // Not used for UI + // + private MsaHeaderDocument.MsaHeader msaHeader = null; + + private ModuleDefinitionsDocument.ModuleDefinitions md = null; + + private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; private OpeningModuleType omt = null; private EnumerationData ed = new EnumerationData(); + /** + * This method initializes jCheckBoxIa32 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBoxIa32() { + if (jCheckBoxIa32 == null) { + jCheckBoxIa32 = new JCheckBox(); + jCheckBoxIa32.setBounds(new java.awt.Rectangle(160, 505, 55, 20)); + jCheckBoxIa32.setText("IA32"); + jCheckBoxIa32.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT); + jCheckBoxIa32.addFocusListener(this); + } + return jCheckBoxIa32; + } + + /** + * This method initializes jCheckBoxX64 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBoxX64() { + if (jCheckBoxX64 == null) { + jCheckBoxX64 = new JCheckBox(); + jCheckBoxX64.setBounds(new java.awt.Rectangle(215, 505, 53, 20)); + jCheckBoxX64.setText("X64"); + jCheckBoxX64.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT); + jCheckBoxX64.addFocusListener(this); + } + return jCheckBoxX64; + } + + /** + * This method initializes jCheckBoxIpf + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBoxIpf() { + if (jCheckBoxIpf == null) { + jCheckBoxIpf = new JCheckBox(); + jCheckBoxIpf.setBounds(new java.awt.Rectangle(270, 505, 52, 20)); + jCheckBoxIpf.setText("IPF"); + jCheckBoxIpf.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT); + jCheckBoxIpf.addFocusListener(this); + } + return jCheckBoxIpf; + } + + /** + * This method initializes jCheckBoxEbc + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBoxEbc() { + if (jCheckBoxEbc == null) { + jCheckBoxEbc = new JCheckBox(); + jCheckBoxEbc.setBounds(new java.awt.Rectangle(325, 505, 53, 20)); + jCheckBoxEbc.setText("EBC"); + jCheckBoxEbc.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT); + jCheckBoxEbc.addFocusListener(this); + } + return jCheckBoxEbc; + } + + /** + * This method initializes jCheckBoxArm + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBoxArm() { + if (jCheckBoxArm == null) { + jCheckBoxArm = new JCheckBox(); + jCheckBoxArm.setBounds(new java.awt.Rectangle(380, 505, 54, 20)); + jCheckBoxArm.setText("ARM"); + jCheckBoxArm.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT); + jCheckBoxArm.addFocusListener(this); + } + return jCheckBoxArm; + } + + /** + * This method initializes jCheckBoxPpc + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBoxPpc() { + if (jCheckBoxPpc == null) { + jCheckBoxPpc = new JCheckBox(); + jCheckBoxPpc.setBounds(new java.awt.Rectangle(435, 505, 53, 20)); + jCheckBoxPpc.setText("PPC"); + jCheckBoxPpc.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT); + jCheckBoxPpc.addFocusListener(this); + } + return jCheckBoxPpc; + } + /** This method initializes jTextFieldBaseName @@ -260,7 +393,7 @@ public class MsaHeader extends IInternalFrame { jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320, 20)); jTextFieldSpecification.setText("FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"); jTextFieldSpecification.setSize(new java.awt.Dimension(320, 20)); - jTextFieldSpecification.setLocation(new java.awt.Point(160, 435)); + jTextFieldSpecification.setLocation(new java.awt.Point(160, 530)); jTextFieldSpecification.setEditable(false); jTextFieldSpecification.addFocusListener(this); } @@ -314,7 +447,7 @@ public class MsaHeader extends IInternalFrame { jScrollPaneLicense = new JScrollPane(); jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jScrollPaneLicense.setSize(new java.awt.Dimension(320, 120)); - jScrollPaneLicense.setLocation(new java.awt.Point(160, 285)); + jScrollPaneLicense.setLocation(new java.awt.Point(160, 305)); jScrollPaneLicense.setViewportView(getJTextAreaLicense()); jScrollPaneLicense.setPreferredSize(new java.awt.Dimension(320, 120)); } @@ -374,33 +507,16 @@ public class MsaHeader extends IInternalFrame { } /** - This method initializes jTextFieldCopyright + This method initializes jTextFieldURL - @return javax.swing.JTextField jTextFieldCopyright + @return javax.swing.JTextField **/ - private JTextField getJTextFieldCopyright() { - if (jTextFieldCopyright == null) { - jTextFieldCopyright = new JTextField(); - jTextFieldCopyright.setPreferredSize(new java.awt.Dimension(320, 20)); - jTextFieldCopyright.setLocation(new java.awt.Point(160, 260)); - jTextFieldCopyright.setSize(new java.awt.Dimension(320, 20)); - jTextFieldCopyright.addFocusListener(this); - jTextFieldCopyright.setToolTipText("One or more copyright lines"); - } - return jTextFieldCopyright; - } - - /** - * This method initializes jTextFieldURL - * - * @return javax.swing.JTextField - */ private JTextField getJTextFieldURL() { if (jTextFieldURL == null) { jTextFieldURL = new JTextField(); jTextFieldURL.setPreferredSize(new java.awt.Dimension(320, 20)); - jTextFieldURL.setLocation(new java.awt.Point(160, 410)); + jTextFieldURL.setLocation(new java.awt.Point(160, 430)); jTextFieldURL.setSize(new java.awt.Dimension(320, 20)); jTextFieldURL.addFocusListener(this); jTextFieldURL.setToolTipText("A URL for the latest version of the license"); @@ -409,10 +525,11 @@ public class MsaHeader extends IInternalFrame { } /** - * This method initializes jScrollPane - * - * @return javax.swing.JScrollPane - */ + This method initializes jScrollPane + + @return javax.swing.JScrollPane + + **/ private JScrollPane getJScrollPane() { if (jScrollPane == null) { jScrollPane = new JScrollPane(); @@ -421,8 +538,80 @@ public class MsaHeader extends IInternalFrame { return jScrollPane; } - public static void main(String[] args) { + /** + This method initializes jScrollPaneCopyright + + @return javax.swing.JScrollPane + + **/ + private JScrollPane getJScrollPaneCopyright() { + if (jScrollPaneCopyright == null) { + jScrollPaneCopyright = new JScrollPane(); + jScrollPaneCopyright.setBounds(new java.awt.Rectangle(160, 260, 320, 40)); + jScrollPaneCopyright.setPreferredSize(new java.awt.Dimension(320, 40)); + jScrollPaneCopyright.setViewportView(getJTextAreaCopyright()); + jScrollPaneCopyright.setSize(new java.awt.Dimension(320, 40)); + } + return jScrollPaneCopyright; + } + /** + This method initializes jTextAreaCopyright + + @return javax.swing.JTextArea + + **/ + private JTextArea getJTextAreaCopyright() { + if (jTextAreaCopyright == null) { + jTextAreaCopyright = new JTextArea(); + jTextAreaCopyright.setLineWrap(true); + jTextAreaCopyright.addFocusListener(this); + jTextAreaCopyright.setWrapStyleWord(true); + jTextAreaCopyright.setSelectionStart(0); + jTextAreaCopyright.setSelectionEnd(0); + jTextAreaCopyright.setBounds(new java.awt.Rectangle(0, 0, 320, 40)); + jTextAreaCopyright.setToolTipText("One or more copyright lines"); + } + return jTextAreaCopyright; + } + + /** + * This method initializes jComboBoxBinaryModule + * + * @return javax.swing.JComboBox + */ + private JComboBox getJComboBoxBinaryModule() { + if (jComboBoxBinaryModule == null) { + jComboBoxBinaryModule = new JComboBox(); + jComboBoxBinaryModule.setBounds(new java.awt.Rectangle(160, 480, 320, 20)); + jComboBoxBinaryModule.setPreferredSize(new java.awt.Dimension(320, 20)); + jComboBoxBinaryModule.addFocusListener(this); + jComboBoxBinaryModule.setToolTipText("Modules are either source modules
" + + "which can be compiled or binary
" + + "modules which are linked.
" + + "A module cannot contain both.
" + + "The GUID numbers should be identical
" + + "for a binary and source MSA,
" + + "but the BINARY MSA should have
" + + "a higher version number."); + } + return jComboBoxBinaryModule; + } + + /** + * This method initializes jTextFieldOutputFileBasename + * + * @return javax.swing.JTextField + */ + private JTextField getJTextFieldOutputFileBasename() { + if (jTextFieldOutputFileBasename == null) { + jTextFieldOutputFileBasename = new JTextField(); + jTextFieldOutputFileBasename.setBounds(new java.awt.Rectangle(160, 455, 320, 20)); + jTextFieldOutputFileBasename.setPreferredSize(new java.awt.Dimension(320, 20)); + jTextFieldOutputFileBasename.addFocusListener(this); + jTextFieldOutputFileBasename.setToolTipText("Enter a single word for generated output file names"); + } + return jTextFieldOutputFileBasename; } /** @@ -458,6 +647,7 @@ public class MsaHeader extends IInternalFrame { msa.setModuleDefinitions(md); } init(msa.getMsaHeader()); + init(msa.getModuleDefinitions()); this.setVisible(true); this.setViewMode(false); } @@ -469,14 +659,12 @@ public class MsaHeader extends IInternalFrame { **/ public void setViewMode(boolean isView) { - //this.jButtonOk.setVisible(false); - //this.jButtonCancel.setVisible(false); if (isView) { this.jTextFieldBaseName.setEnabled(!isView); this.jTextFieldGuid.setEnabled(!isView); this.jTextFieldVersion.setEnabled(!isView); this.jTextAreaLicense.setEnabled(!isView); - this.jTextFieldCopyright.setEnabled(!isView); + this.jTextAreaCopyright.setEnabled(!isView); this.jTextAreaDescription.setEnabled(!isView); this.jTextFieldSpecification.setEnabled(!isView); this.jTextFieldAbstract.setEnabled(!isView); @@ -493,7 +681,7 @@ public class MsaHeader extends IInternalFrame { **/ private void init() { this.setSize(500, 515); - this.setPreferredSize(new java.awt.Dimension(490, 520)); + this.setPreferredSize(new java.awt.Dimension(490, 615)); this.setContentPane(getJScrollPane()); this.setTitle("Module Surface Area Header"); initFrame(); @@ -531,7 +719,7 @@ public class MsaHeader extends IInternalFrame { jTextAreaDescription.setSelectionEnd(0); } if (this.msaHeader.getCopyright() != null) { - this.jTextFieldCopyright.setText(this.msaHeader.getCopyright()); + this.jTextAreaCopyright.setText(this.msaHeader.getCopyright()); } if (this.msaHeader.getLicense() != null) { this.jTextAreaLicense.setText(this.msaHeader.getLicense().getStringValue()); @@ -547,6 +735,31 @@ public class MsaHeader extends IInternalFrame { } } + /** + This method initializes this + Fill values to all fields if these values are not empty + + @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader + + **/ + private void init(ModuleDefinitionsDocument.ModuleDefinitions inMd) { + init(); + if (inMd != null) { + this.md = inMd; + if (md.getSupportedArchitectures() != null) { + this.setSelectedItems(Tools.convertListToVector(md.getSupportedArchitectures())); + } + if (md.getBinaryModule()) { + this.jComboBoxBinaryModule.setSelectedIndex(1); + } else { + this.jComboBoxBinaryModule.setSelectedIndex(0); + } + if (md.getOutputFileBasename() != null) { + this.jTextFieldOutputFileBasename.setText(md.getOutputFileBasename()); + } + } + } + /** This method initializes jContentPane @@ -558,7 +771,7 @@ public class MsaHeader extends IInternalFrame { jLabelURL = new JLabel(); jLabelURL.setText("License URL"); - jLabelURL.setLocation(new java.awt.Point(15, 410)); + jLabelURL.setLocation(new java.awt.Point(15, 430)); jLabelURL.setSize(new java.awt.Dimension(140, 20)); jLabelBaseName = new JLabel(); jLabelBaseName.setText("Module Name"); @@ -588,16 +801,26 @@ public class MsaHeader extends IInternalFrame { jLabelCopyright.setSize(new java.awt.Dimension(140, 20)); jLabelLicense = new JLabel(); jLabelLicense.setText("License"); - jLabelLicense.setLocation(new java.awt.Point(15, 285)); + jLabelLicense.setLocation(new java.awt.Point(15, 305)); jLabelLicense.setSize(new java.awt.Dimension(140, 20)); + jLabelOutputFileBasename = new JLabel(); + jLabelOutputFileBasename.setBounds(new java.awt.Rectangle(15, 455, 140, 20)); + jLabelOutputFileBasename.setText("Output File Basename"); + jLabelBinaryModule = new JLabel(); + jLabelBinaryModule.setBounds(new java.awt.Rectangle(15, 480, 140, 20)); + jLabelBinaryModule.setText("Binary Module"); + jLabelArch = new JLabel(); + jLabelArch.setBounds(new java.awt.Rectangle(15, 505, 140, 20)); + jLabelArch.setText("Supported Architectures"); jLabelSpecification = new JLabel(); jLabelSpecification.setText("Specification"); - jLabelSpecification.setLocation(new java.awt.Point(14, 435)); + jLabelSpecification.setLocation(new java.awt.Point(14, 530)); jLabelSpecification.setSize(new java.awt.Dimension(140, 20)); jContentPane = new JPanel(); jContentPane.setLayout(null); - jContentPane.setPreferredSize(new java.awt.Dimension(490, 470)); + jContentPane.setPreferredSize(new java.awt.Dimension(490, 565)); + jContentPane.addFocusListener(this); jContentPane.add(jLabelBaseName, null); jContentPane.add(getJTextFieldBaseName(), null); @@ -621,7 +844,12 @@ public class MsaHeader extends IInternalFrame { jContentPane.add(getJComboBoxModuleType(), null); jContentPane.add(jLabelURL, null); jContentPane.add(getJTextFieldURL(), null); - jContentPane.add(getJTextFieldCopyright(), null); + jContentPane.add(jLabelOutputFileBasename, null); + jContentPane.add(getJTextFieldOutputFileBasename(), null); + jContentPane.add(jLabelBinaryModule, null); + jContentPane.add(getJComboBoxBinaryModule(), null); + jContentPane.add(jLabelArch, null); + jStarLabel1 = new StarLabel(); jStarLabel1.setLocation(new java.awt.Point(0, 10)); jStarLabel2 = new StarLabel(); @@ -635,11 +863,17 @@ public class MsaHeader extends IInternalFrame { jStarLabel7 = new StarLabel(); jStarLabel7.setLocation(new java.awt.Point(0, 260)); jStarLabel8 = new StarLabel(); - jStarLabel8.setLocation(new java.awt.Point(0, 285)); + jStarLabel8.setLocation(new java.awt.Point(0, 305)); jStarLabel10 = new StarLabel(); jStarLabel10.setLocation(new java.awt.Point(0, 110)); jStarLabel12 = new StarLabel(); - jStarLabel12.setLocation(new java.awt.Point(0, 435)); + jStarLabel12.setLocation(new java.awt.Point(0, 455)); + jStarLabel13 = new StarLabel(); + jStarLabel13.setLocation(new java.awt.Point(0, 480)); + jStarLabel14 = new StarLabel(); + jStarLabel14.setLocation(new java.awt.Point(0, 505)); + jStarLabel15 = new StarLabel(); + jStarLabel15.setLocation(new java.awt.Point(0, 530)); jContentPane.add(jStarLabel1, null); jContentPane.add(jStarLabel2, null); @@ -650,6 +884,17 @@ public class MsaHeader extends IInternalFrame { jContentPane.add(jStarLabel8, null); jContentPane.add(jStarLabel10, null); jContentPane.add(jStarLabel12, null); + jContentPane.add(jStarLabel13, null); + jContentPane.add(jStarLabel14, null); + jContentPane.add(jStarLabel15, null); + jContentPane.add(getJScrollPaneCopyright(), null); + + jContentPane.add(getJCheckBoxIa32(), null); + jContentPane.add(getJCheckBoxX64(), null); + jContentPane.add(getJCheckBoxIpf(), null); + jContentPane.add(getJCheckBoxEbc(), null); + jContentPane.add(getJCheckBoxArm(), null); + jContentPane.add(getJCheckBoxPpc(), null); } return jContentPane; } @@ -759,7 +1004,7 @@ public class MsaHeader extends IInternalFrame { // // Check Copyright // - if (isEmpty(this.jTextFieldCopyright.getText())) { + if (isEmpty(this.jTextAreaCopyright.getText())) { Log.wrn("Update Msa Header", "Copyright couldn't be empty"); //this.jTextFieldCopyright.requestFocus(); return false; @@ -799,28 +1044,9 @@ public class MsaHeader extends IInternalFrame { **/ public void save() { try { - // this.msaHeader.setModuleName(this.jTextFieldBaseName.getText()); - // this.msaHeader.setModuleType(ModuleTypeDef.Enum.forString(this.jComboBoxModuleType.getSelectedItem() - // .toString())); - // this.msaHeader.setGuidValue(this.jTextFieldGuid.getText()); - // this.msaHeader.setVersion(this.jTextFieldVersion.getText()); - // this.msaHeader.setAbstract(this.jTextFieldAbstract.getText()); - // this.msaHeader.setDescription(this.jTextAreaDescription.getText()); - // this.msaHeader.setCopyright(this.jTextFieldCopyright.getText()); - // if (this.msaHeader.getLicense() != null) { - // this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText()); - // } else { - // License mLicense = License.Factory.newInstance(); - // mLicense.setStringValue(this.jTextAreaLicense.getText()); - // this.msaHeader.setLicense(mLicense); - // } - // if (!isEmpty(this.jTextFieldURL.getText())) { - // this.msaHeader.getLicense().setURL(this.jTextFieldURL.getText()); - // } - // this.msaHeader.setSpecification(this.jTextFieldSpecification.getText()); - msaHeader.setSpecification(this.jTextFieldSpecification.getText()); msa.setMsaHeader(msaHeader); + msa.setModuleDefinitions(md); this.omt.setSaved(false); } catch (Exception e) { Log.wrn("Save Module", e.getMessage()); @@ -835,6 +1061,8 @@ public class MsaHeader extends IInternalFrame { private void initFrame() { EnumerationData ed = new EnumerationData(); Tools.generateComboBoxByVector(jComboBoxModuleType, ed.getVModuleType()); + Tools.generateComboBoxByVector(jComboBoxBinaryModule, ed.getVBoolean()); + this.setSelectedItems(ed.getVSupportedArchitectures()); } /** @@ -871,11 +1099,14 @@ public class MsaHeader extends IInternalFrame { resizeComponentWidth(this.jTextFieldVersion, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jScrollPaneLicense, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jTextFieldURL, intCurrentWidth, intPreferredWidth); - resizeComponentWidth(this.jTextFieldCopyright, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jScrollPaneCopyright, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jScrollPaneDescription, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jTextFieldSpecification, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jTextFieldAbstract, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jComboBoxModuleType, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jComboBoxBinaryModule, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jTextFieldOutputFileBasename, intCurrentWidth, intPreferredWidth); + relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON); } @@ -999,14 +1230,14 @@ public class MsaHeader extends IInternalFrame { // // Check Copyright // - if (arg0.getSource() == this.jTextFieldCopyright) { - if (isEmpty(this.jTextFieldCopyright.getText())) { + if (arg0.getSource() == this.jTextAreaCopyright) { + if (isEmpty(this.jTextAreaCopyright.getText())) { Log.wrn("Update Msa Header", "Copyright couldn't be empty"); //this.jTextFieldCopyright.requestFocus(); return; } - if (!this.jTextFieldCopyright.getText().equals(msaHeader.getCopyright())) { - this.msaHeader.setCopyright(this.jTextFieldCopyright.getText()); + if (!this.jTextAreaCopyright.getText().equals(msaHeader.getCopyright())) { + this.msaHeader.setCopyright(this.jTextAreaCopyright.getText()); } else { return; } @@ -1053,6 +1284,143 @@ public class MsaHeader extends IInternalFrame { } } + // + // Check Output File Basename + // + if (arg0.getSource() == this.jTextFieldOutputFileBasename) { + if (isEmpty(this.jTextFieldOutputFileBasename.getText())) { + Log.wrn("Update Msa Header", "Output File Basename couldn't be empty"); + // jTextFieldOutputFileBasename.removeFocusListener(this); + // jTextFieldOutputFileBasename.requestFocus(); + // jTextFieldOutputFileBasename.addFocusListener(this); + return; + } + if (!this.jTextFieldOutputFileBasename.getText().equals(md.getOutputFileBasename())) { + this.md.setOutputFileBasename(this.jTextFieldOutputFileBasename.getText()); + } else { + return; + } + } + + // + // Check Binary Module Type + // + if (arg0.getSource() == this.jComboBoxBinaryModule) { + if (jComboBoxBinaryModule.getSelectedItem().toString().equals(DataType.TRUE)) { + if (md.getBinaryModule()) { + return; + } else { + md.setBinaryModule(true); + } + } else if (jComboBoxBinaryModule.getSelectedItem().toString().equals(DataType.FALSE)) { + if (md.getBinaryModule()) { + md.setBinaryModule(false); + } else { + return; + } + } + } + + // + // Check Supported Arch + // + if (arg0.getSource() == this.jCheckBoxArm || arg0.getSource() == this.jCheckBoxEbc + || arg0.getSource() == this.jCheckBoxIa32 || arg0.getSource() == this.jCheckBoxIpf + || arg0.getSource() == this.jCheckBoxPpc || arg0.getSource() == this.jCheckBoxX64) { + if (!this.getSelectedItemsString().equals(md.getSupportedArchitectures().toString())) { + md.setSupportedArchitectures(this.getSelectedItemsVector()); + } else { + return; + } + } + this.save(); } + + private Vector getSelectedItemsVector() { + Vector v = new Vector(); + if (this.jCheckBoxIa32.isSelected()) { + v.addElement(jCheckBoxIa32.getText()); + } + if (this.jCheckBoxX64.isSelected()) { + v.addElement(jCheckBoxX64.getText()); + } + if (this.jCheckBoxIpf.isSelected()) { + v.addElement(jCheckBoxIpf.getText()); + } + if (this.jCheckBoxEbc.isSelected()) { + v.addElement(jCheckBoxEbc.getText()); + } + if (this.jCheckBoxArm.isSelected()) { + v.addElement(jCheckBoxArm.getText()); + } + if (this.jCheckBoxPpc.isSelected()) { + v.addElement(jCheckBoxPpc.getText()); + } + return v; + } + + private String getSelectedItemsString() { + String s = ""; + if (this.jCheckBoxIa32.isSelected()) { + s = s + jCheckBoxIa32.getText() + " "; + } + if (this.jCheckBoxX64.isSelected()) { + s = s + jCheckBoxX64.getText() + " "; + } + if (this.jCheckBoxIpf.isSelected()) { + s = s + jCheckBoxIpf.getText() + " "; + } + if (this.jCheckBoxEbc.isSelected()) { + s = s + jCheckBoxEbc.getText() + " "; + } + if (this.jCheckBoxArm.isSelected()) { + s = s + jCheckBoxArm.getText() + " "; + } + if (this.jCheckBoxPpc.isSelected()) { + s = s + jCheckBoxPpc.getText() + " "; + } + return s.trim(); + } + + private void setAllItemsSelected(boolean isSelected) { + this.jCheckBoxIa32.setSelected(isSelected); + this.jCheckBoxX64.setSelected(isSelected); + this.jCheckBoxIpf.setSelected(isSelected); + this.jCheckBoxEbc.setSelected(isSelected); + this.jCheckBoxArm.setSelected(isSelected); + this.jCheckBoxPpc.setSelected(isSelected); + } + + private void setSelectedItems(Vector v) { + setAllItemsSelected(false); + if (v != null) { + for (int index = 0; index < v.size(); index++) { + if (v.get(index).equals(this.jCheckBoxIa32.getText())) { + this.jCheckBoxIa32.setSelected(true); + continue; + } + if (v.get(index).equals(this.jCheckBoxIpf.getText())) { + this.jCheckBoxIpf.setSelected(true); + continue; + } + if (v.get(index).equals(this.jCheckBoxX64.getText())) { + this.jCheckBoxX64.setSelected(true); + continue; + } + if (v.get(index).equals(this.jCheckBoxEbc.getText())) { + this.jCheckBoxEbc.setSelected(true); + continue; + } + if (v.get(index).equals(this.jCheckBoxArm.getText())) { + this.jCheckBoxArm.setSelected(true); + continue; + } + if (v.get(index).equals(this.jCheckBoxPpc.getText())) { + this.jCheckBoxPpc.setSelected(true); + continue; + } + } + } + } } 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 3c575ed3cd..9c8368b0d7 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java @@ -22,17 +22,13 @@ import java.util.Vector; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlException; import org.tianocore.DbPathAndFilename; -import org.tianocore.FrameworkDatabaseDocument.FrameworkDatabase; import org.tianocore.IndustryStdIncludesDocument.IndustryStdIncludes; import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.MsaFilesDocument.MsaFiles; -import org.tianocore.MsaHeaderDocument.MsaHeader; import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea; -import org.tianocore.PlatformHeaderDocument.PlatformHeader; -import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea; import org.tianocore.SourceFilesDocument.SourceFiles; -import org.tianocore.SpdHeaderDocument.SpdHeader; import org.tianocore.frameworkwizard.common.DataType; +import org.tianocore.frameworkwizard.common.GlobalData; import org.tianocore.frameworkwizard.common.Log; import org.tianocore.frameworkwizard.common.OpenFile; import org.tianocore.frameworkwizard.common.SaveFile; @@ -48,75 +44,44 @@ import org.tianocore.frameworkwizard.packaging.PackageIdentification; import org.tianocore.frameworkwizard.platform.PlatformIdentification; public class WorkspaceTools { - // - // Define class members - // - private FrameworkDatabase fdb = null; - - private Vector vModuleList = new Vector(); - - private Vector vPackageList = new Vector(); - - private Vector vPlatformList = new Vector(); - - /** - - Open Framework Database file - - */ - private FrameworkDatabase openFrameworkDb() { - String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); - strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); - try { - fdb = OpenFile.openFrameworkDb(strFrameworkDbFilePath); - } catch (XmlException e) { - Log.err("Open Framework Database " + strFrameworkDbFilePath, e.getMessage()); - return null; - } catch (Exception e) { - Log.err("Open Framework Database " + strFrameworkDbFilePath, "Invalid file type"); - return null; - } - return fdb; - } public void addFarToDb(List packageList, List platformList, FarHeader far) { - FrameworkDatabase fdb = openFrameworkDb(); + //FrameworkDatabase fdb = openFrameworkDb(); for (int i = 0; i < packageList.size(); i++) { DbPathAndFilename item = DbPathAndFilename.Factory.newInstance(); item.setFarGuid(far.getGuidValue()); item.setStringValue(packageList.get(i)); - fdb.getPackageList().getFilenameList().add(item); + GlobalData.fdb.getPackageList().getFilenameList().add(item); } for (int i = 0; i < platformList.size(); i++) { DbPathAndFilename item = DbPathAndFilename.Factory.newInstance(); item.setFarGuid(far.getGuidValue()); item.setStringValue(platformList.get(i)); - fdb.getPlatformList().getFilenameList().add(item); + GlobalData.fdb.getPlatformList().getFilenameList().add(item); } DbPathAndFilename farItem = DbPathAndFilename.Factory.newInstance(); farItem.setFarGuid(far.getGuidValue()); farItem.setStringValue(far.getFarName()); - fdb.getFarList().getFilenameList().add(farItem); + GlobalData.fdb.getFarList().getFilenameList().add(farItem); String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); try { - SaveFile.saveDbFile(strFrameworkDbFilePath, fdb); + SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb); } catch (Exception e) { Log.err("Save Database File", e.getMessage()); } } public void removeFarFromDb(FarIdentification far) { - FrameworkDatabase fdb = openFrameworkDb(); // // Remove Packages // - XmlCursor cursor = fdb.getPackageList().newCursor(); + XmlCursor cursor = GlobalData.fdb.getPackageList().newCursor(); cursor.toFirstChild(); do { DbPathAndFilename item = (DbPathAndFilename) cursor.getObject(); @@ -130,7 +95,7 @@ public class WorkspaceTools { // // Remove Platforms // - cursor = fdb.getPlatformList().newCursor(); + cursor = GlobalData.fdb.getPlatformList().newCursor(); cursor.toFirstChild(); do { DbPathAndFilename item = (DbPathAndFilename) cursor.getObject(); @@ -142,7 +107,7 @@ public class WorkspaceTools { // // Remove Far // - cursor = fdb.getFarList().newCursor(); + cursor = GlobalData.fdb.getFarList().newCursor(); cursor.toFirstChild(); do { DbPathAndFilename item = (DbPathAndFilename) cursor.getObject(); @@ -155,21 +120,19 @@ public class WorkspaceTools { String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); try { - SaveFile.saveDbFile(strFrameworkDbFilePath, fdb); + SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb); } catch (Exception e) { Log.err("Save Database File", e.getMessage()); } } public String getPackageFarGuid(Identification packageId) { - openFrameworkDb(); - - for (int index = 0; index < fdb.getPackageList().getFilenameList().size(); index++) { - DbPathAndFilename item = fdb.getPackageList().getFilenameArray(index); + for (int index = 0; index < GlobalData.fdb.getPackageList().getFilenameList().size(); index++) { + DbPathAndFilename item = GlobalData.fdb.getPackageList().getFilenameArray(index); String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue(); File tempFile = new File(path); if (tempFile.getPath().equalsIgnoreCase(packageId.getPath())) { - return fdb.getPackageList().getFilenameArray(index).getFarGuid(); + return GlobalData.fdb.getPackageList().getFilenameArray(index).getFarGuid(); } } @@ -177,14 +140,12 @@ public class WorkspaceTools { } public String getPlatformFarGuid(Identification platformId) { - openFrameworkDb(); - - for (int index = 0; index < fdb.getPlatformList().getFilenameList().size(); index++) { - DbPathAndFilename item = fdb.getPlatformList().getFilenameArray(index); + for (int index = 0; index < GlobalData.fdb.getPlatformList().getFilenameList().size(); index++) { + DbPathAndFilename item = GlobalData.fdb.getPlatformList().getFilenameArray(index); String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue(); File tempFile = new File(path); if (tempFile.getPath().equalsIgnoreCase(platformId.getPath())) { - return fdb.getPlatformList().getFilenameArray(index).getFarGuid(); + return GlobalData.fdb.getPlatformList().getFilenameArray(index).getFarGuid(); } } @@ -208,23 +169,17 @@ public class WorkspaceTools { **/ public Vector getAllModulesOfPackage(String path) { Vector modulePath = new Vector(); - try { - MsaFiles files = OpenFile.openSpdFile(path).getMsaFiles(); - if (files != null) { - for (int index = 0; index < files.getFilenameList().size(); index++) { - String msaPath = files.getFilenameList().get(index); - msaPath = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + msaPath; - msaPath = Tools.convertPathToCurrentOsType(msaPath); - modulePath.addElement(msaPath); - } + PackageIdentification id = new PackageIdentification(null, null, null, path); + MsaFiles files = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(id).getMsaFiles(); + if (files != null) { + for (int index = 0; index < files.getFilenameList().size(); index++) { + String msaPath = files.getFilenameList().get(index); + msaPath = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + msaPath; + msaPath = Tools.convertPathToCurrentOsType(msaPath); + modulePath.addElement(msaPath); } - } catch (IOException e) { - Log.err("Get all mdoules of a package " + path, e.getMessage()); - } catch (XmlException e) { - Log.err("Get all mdoules of a package " + path, e.getMessage()); - } catch (Exception e) { - Log.err("Get all mdoules of a package " + path, e.getMessage()); } + return modulePath; } @@ -236,22 +191,16 @@ public class WorkspaceTools { **/ public Vector getAllIndustryStdIncludesOfPackage(String path) { Vector includePath = new Vector(); - try { - IndustryStdIncludes files = OpenFile.openSpdFile(path).getIndustryStdIncludes(); - if (files != null) { - for (int index = 0; index < files.getIndustryStdHeaderList().size(); index++) { - String temp = files.getIndustryStdHeaderList().get(index).getIncludeHeader(); - temp = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + temp; - temp = Tools.convertPathToCurrentOsType(temp); - includePath.addElement(temp); - } + PackageIdentification id = new PackageIdentification(null, null, null, path); + IndustryStdIncludes files = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(id) + .getIndustryStdIncludes(); + if (files != null) { + for (int index = 0; index < files.getIndustryStdHeaderList().size(); index++) { + String temp = files.getIndustryStdHeaderList().get(index).getIncludeHeader(); + temp = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + temp; + temp = Tools.convertPathToCurrentOsType(temp); + includePath.addElement(temp); } - } catch (IOException e) { - Log.err("Get all Industry Std Includes of a package " + path, e.getMessage()); - } catch (XmlException e) { - Log.err("Get all Industry Std Includes of a package " + path, e.getMessage()); - } catch (Exception e) { - Log.err("Get all Industry Std Includes of a package " + path, e.getMessage()); } return includePath; } @@ -263,35 +212,14 @@ public class WorkspaceTools { */ public Vector getAllPackages() { - Identification id = null; - vPackageList.removeAllElements(); - - openFrameworkDb(); - - for (int index = 0; index < fdb.getPackageList().getFilenameList().size(); index++) { - String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR - + fdb.getPackageList().getFilenameArray(index).getStringValue(); - path = Tools.convertPathToCurrentOsType(path); - try { - id = getId(path, OpenFile.openSpdFile(path)); - vPackageList.addElement(new PackageIdentification(id)); - } catch (IOException e) { - Log.err("Open Package Surface Area " + path, e.getMessage()); - } catch (XmlException e) { - Log.err("Open Package Surface Area " + path, e.getMessage()); - } catch (Exception e) { - Log.err("Open Package Surface Area " + path, "Invalid file type"); - } - } - Sort.sortPackages(vPackageList, DataType.SORT_TYPE_ASCENDING); - return vPackageList; + return GlobalData.vPackageList; } public Vector getAllFars() { - openFrameworkDb(); + Vector v = new Vector(); - for (int index = 0; index < fdb.getFarList().getFilenameList().size(); index++) { - DbPathAndFilename item = fdb.getFarList().getFilenameList().get(index); + for (int index = 0; index < GlobalData.fdb.getFarList().getFilenameList().size(); index++) { + DbPathAndFilename item = GlobalData.fdb.getFarList().getFilenameList().get(index); FarIdentification far = new FarIdentification(item.getFarGuid(), item.getMd5Sum(), item.getStringValue()); v.addElement(far); } @@ -300,18 +228,18 @@ public class WorkspaceTools { public Vector getPackagesByFar(FarIdentification far) { Identification id = null; - openFrameworkDb(); + Vector v = new Vector(); - for (int index = 0; index < fdb.getPackageList().getFilenameList().size(); index++) { - DbPathAndFilename item = fdb.getPackageList().getFilenameArray(index); + for (int index = 0; index < GlobalData.fdb.getPackageList().getFilenameList().size(); index++) { + DbPathAndFilename item = GlobalData.fdb.getPackageList().getFilenameArray(index); String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue(); path = Tools.convertPathToCurrentOsType(path); if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) { try { - id = getId(path, OpenFile.openSpdFile(path)); + id = Tools.getId(path, OpenFile.openSpdFile(path)); v.addElement(new PackageIdentification(id)); } catch (IOException e) { Log.err("Open Package Surface Area " + path, e.getMessage()); @@ -327,17 +255,17 @@ public class WorkspaceTools { public Vector getPlatformsByFar(FarIdentification far) { Identification id = null; - openFrameworkDb(); + Vector v = new Vector(); - for (int index = 0; index < fdb.getPlatformList().getFilenameList().size(); index++) { - DbPathAndFilename item = fdb.getPlatformList().getFilenameArray(index); + for (int index = 0; index < GlobalData.fdb.getPlatformList().getFilenameList().size(); index++) { + DbPathAndFilename item = GlobalData.fdb.getPlatformList().getFilenameArray(index); String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue(); path = Tools.convertPathToCurrentOsType(path); if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) { try { - id = getId(path, OpenFile.openFpdFile(path)); + id = Tools.getId(path, OpenFile.openFpdFile(path)); v.addElement(new PlatformIdentification(id)); } catch (IOException e) { Log.err("Open Platform Surface Area " + path, e.getMessage()); @@ -361,25 +289,16 @@ public class WorkspaceTools { public Vector getAllModules(PackageIdentification pid) { Vector v = new Vector(); Vector modulePaths = this.getAllModulesOfPackage(pid.getPath()); - Identification id = null; String modulePath = null; for (int index = 0; index < modulePaths.size(); index++) { - try { - modulePath = modulePaths.get(index); - id = getId(modulePath, OpenFile.openMsaFile(modulePath)); - } catch (IOException e) { - Log.err("Open Module Surface Area " + modulePath, e.getMessage()); - } catch (XmlException e) { - Log.err("Open Module Surface Area " + modulePath, e.getMessage()); - } catch (Exception e) { - Log.err("Open Module Surface Area " + modulePath, "Invalid file type " + e.getMessage()); - } - v.addElement(new ModuleIdentification(id, pid)); + modulePath = modulePaths.get(index); + ModuleIdentification id = GlobalData.openingModuleList.getIdByPath(modulePath); + + v.addElement(id); } Sort.sortModules(v, DataType.SORT_TYPE_ASCENDING); return v; - } /** @@ -389,39 +308,7 @@ public class WorkspaceTools { */ public Vector getAllModules() { - vModuleList.removeAllElements(); - // - // First get all packages - // - getAllPackages(); - Vector modulePaths = new Vector(); - Identification id = null; - String packagePath = null; - String modulePath = null; - - // - // For each package, get all modules list - // - for (int indexI = 0; indexI < vPackageList.size(); indexI++) { - packagePath = vPackageList.elementAt(indexI).getPath(); - modulePaths = this.getAllModulesOfPackage(packagePath); - - for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) { - try { - modulePath = modulePaths.get(indexJ); - id = getId(modulePath, OpenFile.openMsaFile(modulePath)); - vModuleList.addElement(new ModuleIdentification(id, vPackageList.elementAt(indexI))); - } catch (IOException e) { - Log.err("Open Module Surface Area " + modulePath, e.getMessage()); - } catch (XmlException e) { - Log.err("Open Module Surface Area " + modulePath, e.getMessage()); - } catch (Exception e) { - Log.err("Open Module Surface Area " + modulePath, "Invalid file type"); - } - } - } - Sort.sortModules(vModuleList, DataType.SORT_TYPE_ASCENDING); - return vModuleList; + return GlobalData.vModuleList; } /** @@ -431,28 +318,7 @@ public class WorkspaceTools { */ public Vector getAllPlatforms() { - Identification id = null; - vPlatformList.removeAllElements(); - - openFrameworkDb(); - - for (int index = 0; index < fdb.getPlatformList().getFilenameList().size(); index++) { - String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR - + fdb.getPlatformList().getFilenameArray(index).getStringValue(); - path = Tools.convertPathToCurrentOsType(path); - try { - id = getId(path, OpenFile.openFpdFile(path)); - vPlatformList.addElement(new PlatformIdentification(id)); - } catch (IOException e) { - Log.err("Open Platform Surface Area " + path, e.getMessage()); - } catch (XmlException e) { - Log.err("Open Platform Surface Area " + path, e.getMessage()); - } catch (Exception e) { - Log.err("Open Platform Surface Area " + path, "Invalid file type"); - } - } - Sort.sortPlatforms(vPlatformList, DataType.SORT_TYPE_ASCENDING); - return vPlatformList; + return GlobalData.vPlatformList; } /** @@ -552,53 +418,28 @@ public class WorkspaceTools { } public Vector getAllLibraryClassDefinitionsFromWorkspace() { - // - // First get all packages - // - this.getAllPackages(); - Vector vector = new Vector(); - for (int index = 0; index < this.vPackageList.size(); index++) { - try { - Vector v = getAllLibraryClassDefinitionsFromPackage(OpenFile - .openSpdFile(vPackageList - .get(index) - .getPath())); - if (v != null && v.size() > 0) { - vector.addAll(v); - } - } catch (IOException e) { - Log.err("getAllLibraryClassDefinitionsFromWorkspace ", e.getMessage()); - } catch (XmlException e) { - Log.err("getAllLibraryClassDefinitionsFromWorkspace ", e.getMessage()); - } catch (Exception e) { - Log.err("getAllLibraryClassDefinitionsFromWorkspace ", e.getMessage()); + for (int index = 0; index < GlobalData.vPackageList.size(); index++) { + Vector v = getAllLibraryClassDefinitionsFromPackage(GlobalData.openingPackageList + .getPackageSurfaceAreaFromId(GlobalData.vPackageList + .get(index))); + if (v != null && v.size() > 0) { + vector.addAll(v); } + } Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); return vector; } public Vector getAllProtocolDeclarationsFromWorkspace() { - // - // First get all packages - // - this.getAllPackages(); - Vector vector = new Vector(); - for (int index = 0; index < this.vPackageList.size(); index++) { - try { - Vector v = getAllProtocolDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index) - .getPath())); - if (v != null && v.size() > 0) { - vector.addAll(v); - } - } catch (IOException e) { - Log.err("getAllProtocolDeclarationsFromPackage", e.getMessage()); - } catch (XmlException e) { - Log.err("getAllProtocolDeclarationsFromPackage", e.getMessage()); - } catch (Exception e) { - Log.err("getAllProtocolDeclarationsFromPackage", e.getMessage()); + for (int index = 0; index < GlobalData.vPackageList.size(); index++) { + Vector v = getAllProtocolDeclarationsFromPackage(GlobalData.openingPackageList + .getPackageSurfaceAreaFromId(GlobalData.vPackageList + .get(index))); + if (v != null && v.size() > 0) { + vector.addAll(v); } } Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); @@ -606,25 +447,13 @@ public class WorkspaceTools { } public Vector getAllPpiDeclarationsFromWorkspace() { - // - // First get all packages - // - this.getAllPackages(); - Vector vector = new Vector(); - for (int index = 0; index < this.vPackageList.size(); index++) { - try { - Vector v = getAllPpiDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index) - .getPath())); - if (v != null && v.size() > 0) { - vector.addAll(v); - } - } catch (IOException e) { - Log.err("getAllPpiDeclarationsFromWorkspace", e.getMessage()); - } catch (XmlException e) { - Log.err("getAllPpiDeclarationsFromWorkspace", e.getMessage()); - } catch (Exception e) { - Log.err("getAllPpiDeclarationsFromWorkspace", e.getMessage()); + for (int index = 0; index < GlobalData.vPackageList.size(); index++) { + Vector v = getAllPpiDeclarationsFromPackage(GlobalData.openingPackageList + .getPackageSurfaceAreaFromId(GlobalData.vPackageList + .get(index))); + if (v != null && v.size() > 0) { + vector.addAll(v); } } Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); @@ -632,51 +461,30 @@ public class WorkspaceTools { } public Vector getAllGuidDeclarationsFromWorkspace() { - // - // First get all packages - // - this.getAllPackages(); - Vector vector = new Vector(); - for (int index = 0; index < this.vPackageList.size(); index++) { - try { - Vector v = getAllGuidDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index) - .getPath())); - if (v != null && v.size() > 0) { - vector.addAll(v); - } - } catch (IOException e) { - Log.err("getAllGuidDeclarationsFromWorkspace", e.getMessage()); - } catch (XmlException e) { - Log.err("getAllGuidDeclarationsFromWorkspace", e.getMessage()); - } catch (Exception e) { - Log.err("getAllGuidDeclarationsFromWorkspace", e.getMessage()); + for (int index = 0; index < GlobalData.vPackageList.size(); index++) { + Vector v = getAllGuidDeclarationsFromPackage(GlobalData.openingPackageList + .getPackageSurfaceAreaFromId(GlobalData.vPackageList + .get(index))); + if (v != null && v.size() > 0) { + vector.addAll(v); } + } Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); return vector; } public PcdVector getAllPcdDeclarationsFromWorkspace() { - // - // First get all packages - // - this.getAllPackages(); - PcdVector vector = new PcdVector(); - for (int index = 0; index < this.vPackageList.size(); index++) { - try { - PcdVector v = getAllPcdDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index).getPath())); - if (v != null && v.size() > 0) { - vector.addAll(v); - } - } catch (IOException e) { - Log.err("getAllPcdDeclarationsFromWorkspace", e.getMessage()); - } catch (XmlException e) { - Log.err("getAllPcdDeclarationsFromWorkspace", e.getMessage()); - } catch (Exception e) { - Log.err("getAllPcdDeclarationsFromWorkspace", e.getMessage()); + for (int index = 0; index < GlobalData.openingPackageList.size(); index++) { + PcdVector v = getAllPcdDeclarationsFromPackage(GlobalData.openingPackageList + .getPackageSurfaceAreaFromId(GlobalData.vPackageList + .get(index))); + if (v != null && v.size() > 0) { + vector.addAll(v); } + } Sort.sortPcds(vector, DataType.SORT_TYPE_ASCENDING); return vector; @@ -690,7 +498,6 @@ public class WorkspaceTools { **/ public PackageIdentification getPackageIdByModuleId(Identification id) { - getAllPackages(); Vector modulePaths = new Vector(); Identification mid = null; String packagePath = null; @@ -699,59 +506,25 @@ public class WorkspaceTools { // // For each package, get all modules list // - for (int indexI = 0; indexI < vPackageList.size(); indexI++) { - packagePath = vPackageList.elementAt(indexI).getPath(); + for (int indexI = 0; indexI < GlobalData.vPackageList.size(); indexI++) { + packagePath = GlobalData.vPackageList.elementAt(indexI).getPath(); modulePaths = this.getAllModulesOfPackage(packagePath); for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) { modulePath = modulePaths.get(indexJ); - try { - mid = getId(modulePath, OpenFile.openMsaFile(modulePath)); - // - // Check id - // - if (mid.equals(id)) { - return vPackageList.elementAt(indexI); - } - } catch (IOException e) { - Log.err("getPackageIdByModuleId " + id.getPath(), e.getMessage()); - } catch (XmlException e) { - Log.err("getPackageIdByModuleId " + id.getPath(), e.getMessage()); - } catch (Exception e) { - Log.err("getPackageIdByModuleId " + id.getPath(), e.getMessage()); + mid = GlobalData.openingModuleList.getIdByPath(modulePath); + // + // Check id + // + if (mid.equals(id)) { + return GlobalData.vPackageList.elementAt(indexI); } + } } return null; } - public Identification getId(String path, ModuleSurfaceArea msa) { - MsaHeader head = msa.getMsaHeader(); - String name = head.getModuleName(); - String guid = head.getGuidValue(); - String version = head.getVersion(); - Identification id = new Identification(name, guid, version, path); - return id; - } - - public Identification getId(String path, PackageSurfaceArea spd) { - SpdHeader head = spd.getSpdHeader(); - String name = head.getPackageName(); - String guid = head.getGuidValue(); - String version = head.getVersion(); - Identification id = new Identification(name, guid, version, path); - return id; - } - - public Identification getId(String path, PlatformSurfaceArea fpd) { - PlatformHeader head = fpd.getPlatformHeader(); - String name = head.getPlatformName(); - String guid = head.getGuidValue(); - String version = head.getVersion(); - Identification id = new Identification(name, guid, version, path); - return id; - } - /** Add module information to package surface area @@ -790,14 +563,15 @@ public class WorkspaceTools { public void addPackageToDatabase(PackageIdentification id) throws Exception { String path = id.getPath(); path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace()); - this.openFrameworkDb(); + DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance(); filename.setStringValue(path); - fdb.getPackageList().addNewFilename(); - fdb.getPackageList().setFilenameArray(fdb.getPackageList().sizeOfFilenameArray() - 1, filename); + GlobalData.fdb.getPackageList().addNewFilename(); + GlobalData.fdb.getPackageList().setFilenameArray(GlobalData.fdb.getPackageList().sizeOfFilenameArray() - 1, + filename); String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); - SaveFile.saveDbFile(strFrameworkDbFilePath, fdb); + SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb); } /** @@ -810,14 +584,15 @@ public class WorkspaceTools { public void addPlatformToDatabase(PlatformIdentification id) throws Exception { String path = id.getPath(); path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace()); - this.openFrameworkDb(); + DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance(); filename.setStringValue(path); - fdb.getPlatformList().addNewFilename(); - fdb.getPlatformList().setFilenameArray(fdb.getPlatformList().sizeOfFilenameArray() - 1, filename); + GlobalData.fdb.getPlatformList().addNewFilename(); + GlobalData.fdb.getPlatformList().setFilenameArray(GlobalData.fdb.getPlatformList().sizeOfFilenameArray() - 1, + filename); String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); - SaveFile.saveDbFile(strFrameworkDbFilePath, fdb); + SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb); } /** @@ -830,11 +605,13 @@ public class WorkspaceTools { @throws Exception **/ - public Vector getAllModuleFilesPath(String path) throws IOException, XmlException, Exception { + public Vector getAllFilesPathOfModule(String path) { Vector v = new Vector(); path = Tools.convertPathToCurrentOsType(path); v.addElement(path); - ModuleSurfaceArea msa = OpenFile.openMsaFile(path); + ModuleSurfaceArea msa = GlobalData.openingModuleList + .getModuleSurfaceAreaFromId(GlobalData.openingModuleList + .getIdByPath(path)); if (msa != null) { // // Get all files' path of a module @@ -862,7 +639,7 @@ public class WorkspaceTools { @throws Exception **/ - public Vector getAllPakcageFilesPath(String path) throws IOException, XmlException, Exception { + public Vector getAllFilesPathOfPakcage(String path) { Vector v = new Vector(); path = Tools.convertPathToCurrentOsType(path); // @@ -885,7 +662,7 @@ public class WorkspaceTools { f1 = new Vector(); f1 = getAllModulesOfPackage(path); for (int indexI = 0; indexI < f1.size(); indexI++) { - Vector f2 = getAllModuleFilesPath(f1.get(indexI)); + Vector f2 = getAllFilesPathOfModule(f1.get(indexI)); for (int indexJ = 0; indexJ < f2.size(); indexJ++) { v.addElement(f2.get(indexJ)); }