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
This commit is contained in:
hche10x 2006-08-17 02:04:40 +00:00
parent 4033708d7a
commit 739c6b04fd
22 changed files with 1273 additions and 1246 deletions

View File

@ -50,6 +50,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Filename>src/org/tianocore/frameworkwizard/common/DataValidation.java</Filename> <Filename>src/org/tianocore/frameworkwizard/common/DataValidation.java</Filename>
<Filename>src/org/tianocore/frameworkwizard/common/EnumerationData.java</Filename> <Filename>src/org/tianocore/frameworkwizard/common/EnumerationData.java</Filename>
<Filename>src/org/tianocore/frameworkwizard/common/FileOperation.java</Filename> <Filename>src/org/tianocore/frameworkwizard/common/FileOperation.java</Filename>
<Filename>src/org/tianocore/frameworkwizard/common/GlobalData.java</Filename>
<Filename>src/org/tianocore/frameworkwizard/common/IDefaultTableModel.java</Filename> <Filename>src/org/tianocore/frameworkwizard/common/IDefaultTableModel.java</Filename>
<Filename>src/org/tianocore/frameworkwizard/common/IFileFilter.java</Filename> <Filename>src/org/tianocore/frameworkwizard/common/IFileFilter.java</Filename>
<Filename>src/org/tianocore/frameworkwizard/common/Log.java</Filename> <Filename>src/org/tianocore/frameworkwizard/common/Log.java</Filename>

View File

@ -723,7 +723,7 @@ public class Clone extends IDialog {
// //
trg = getModulePath(); trg = getModulePath();
newId.setPath(trg); newId.setPath(trg);
vFiles = wt.getAllModuleFilesPath(src); vFiles = wt.getAllFilesPathOfModule(src);
// //
// First copy all files to new directory // First copy all files to new directory
@ -787,7 +787,7 @@ public class Clone extends IDialog {
// //
trg = this.getPackagePath(); trg = this.getPackagePath();
newId.setPath(trg); newId.setPath(trg);
vFiles = wt.getAllPakcageFilesPath(src); vFiles = wt.getAllFilesPathOfPakcage(src);
// //
// First copy all files to new directory // First copy all files to new directory

View File

@ -44,21 +44,16 @@ import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener; import javax.swing.event.TreeSelectionListener;
import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlException;
import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.PackageSurfaceAreaDocument; import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.DataType; import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.GlobalData;
import org.tianocore.frameworkwizard.common.IFileFilter; import org.tianocore.frameworkwizard.common.IFileFilter;
import org.tianocore.frameworkwizard.common.Log; import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpenFile;
import org.tianocore.frameworkwizard.common.SaveFile; import org.tianocore.frameworkwizard.common.SaveFile;
import org.tianocore.frameworkwizard.common.Tools; import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.Identification; 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.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageList;
import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType; 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.Identifications.OpeningPlatformType;
import org.tianocore.frameworkwizard.common.ui.IDefaultMutableTreeNode; import org.tianocore.frameworkwizard.common.ui.IDefaultMutableTreeNode;
import org.tianocore.frameworkwizard.common.ui.IDesktopManager; 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.Identifications.ModuleIdentification;
import org.tianocore.frameworkwizard.module.ui.ModuleBootModes; import org.tianocore.frameworkwizard.module.ui.ModuleBootModes;
import org.tianocore.frameworkwizard.module.ui.ModuleDataHubs; 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.ModuleEvents;
import org.tianocore.frameworkwizard.module.ui.ModuleExterns; import org.tianocore.frameworkwizard.module.ui.ModuleExterns;
import org.tianocore.frameworkwizard.module.ui.ModuleGuids; 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; private static final long serialVersionUID = -7103240960573031772L;
/// ///
/// Used to save information of all files /// Used to record current operation target
/// ///
private Vector<ModuleIdentification> vModuleList = new Vector<ModuleIdentification>();
private Vector<PackageIdentification> vPackageList = new Vector<PackageIdentification>();
private Vector<PlatformIdentification> vPlatformList = new Vector<PlatformIdentification>();
private OpeningModuleList openingModuleList = new OpeningModuleList();
private OpeningPackageList openingPackageList = new OpeningPackageList();
private OpeningPlatformList openingPlatformList = new OpeningPlatformList();
private int currentOpeningModuleIndex = -1; private int currentOpeningModuleIndex = -1;
private int currentOpeningPackageIndex = -1; private int currentOpeningPackageIndex = -1;
@ -1699,11 +1681,18 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
System.exit(0); 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.setSize(DataType.MAIN_FRAME_PREFERRED_SIZE_WIDTH, DataType.MAIN_FRAME_PREFERRED_SIZE_HEIGHT);
this.setResizable(true); this.setResizable(true);
this.setJMenuBar(getjJMenuBar()); this.setJMenuBar(getjJMenuBar());
this.addComponentListener(this); this.addComponentListener(this);
this.getCompontentsFromFrameworkDatabase();
this.setContentPane(getJContentPane()); this.setContentPane(getJContentPane());
this.setTitle(DataType.PROJECT_NAME + " " + DataType.PROJECT_VERSION + " " + "- [" this.setTitle(DataType.PROJECT_NAME + " " + DataType.PROJECT_VERSION + " " + "- ["
+ Workspace.getCurrentWorkspace() + "]"); + Workspace.getCurrentWorkspace() + "]");
@ -1828,34 +1817,34 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
// First add package // First add package
// //
if (this.vPackageList.size() > 0) { if (GlobalData.vPackageList.size() > 0) {
for (int index = 0; index < this.vPackageList.size(); index++) { for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
IDefaultMutableTreeNode dmtnModulePackage = null; IDefaultMutableTreeNode dmtnModulePackage = null;
IDefaultMutableTreeNode dmtnModulePackageLibrary = null; IDefaultMutableTreeNode dmtnModulePackageLibrary = null;
IDefaultMutableTreeNode dmtnModulePackageModule = null; IDefaultMutableTreeNode dmtnModulePackageModule = null;
dmtnModulePackage = new IDefaultMutableTreeNode(this.vPackageList.elementAt(index).getName(), dmtnModulePackage = new IDefaultMutableTreeNode(GlobalData.vPackageList.elementAt(index).getName(),
IDefaultMutableTreeNode.MODULE_PACKAGE, false, IDefaultMutableTreeNode.MODULE_PACKAGE, false,
this.vPackageList.elementAt(index)); GlobalData.vPackageList.elementAt(index));
dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library", dmtnModulePackageLibrary = new IDefaultMutableTreeNode("Library",
IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY, IDefaultMutableTreeNode.MODULE_PACKAGE_LIBRARY,
false, this.vPackageList.elementAt(index)); false, GlobalData.vPackageList.elementAt(index));
dmtnModulePackageModule = new IDefaultMutableTreeNode("Module", dmtnModulePackageModule = new IDefaultMutableTreeNode("Module",
IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE, IDefaultMutableTreeNode.MODULE_PACKAGE_MODULE,
false, this.vPackageList.elementAt(index)); false, GlobalData.vPackageList.elementAt(index));
// //
// And then add each module in its package // And then add each module in its package
// //
Vector<ModuleIdentification> vModule = wt.getAllModules(this.vPackageList.elementAt(index)); Vector<ModuleIdentification> vModule = wt.getAllModules(GlobalData.vPackageList.elementAt(index));
for (int indexJ = 0; indexJ < vModule.size(); indexJ++) { for (int indexJ = 0; indexJ < vModule.size(); indexJ++) {
if (vModule.get(indexJ).isLibrary()) { if (vModule.get(indexJ).isLibrary()) {
dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), dmtnModulePackageLibrary.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(),
IDefaultMutableTreeNode.MODULE, IDefaultMutableTreeNode.MODULE, false,
false, vModule.get(indexJ))); vModule.get(indexJ)));
} else { } else {
dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(), dmtnModulePackageModule.add(new IDefaultMutableTreeNode(vModule.get(indexJ).getName(),
IDefaultMutableTreeNode.MODULE, IDefaultMutableTreeNode.MODULE, false,
false, vModule.get(indexJ))); vModule.get(indexJ)));
} }
} }
if (dmtnModulePackageModule.getChildCount() > 0) { if (dmtnModulePackageModule.getChildCount() > 0) {
@ -1873,11 +1862,12 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// Make Package Description // Make Package Description
// //
dmtnPackageDescription = new IDefaultMutableTreeNode("PackageDescription", IDefaultMutableTreeNode.PACKAGE, -1); dmtnPackageDescription = new IDefaultMutableTreeNode("PackageDescription", IDefaultMutableTreeNode.PACKAGE, -1);
if (this.vPackageList.size() > 0) { if (GlobalData.vPackageList.size() > 0) {
for (int index = 0; index < this.vPackageList.size(); index++) { for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
dmtnPackageDescription.add(new IDefaultMutableTreeNode(this.vPackageList.elementAt(index).getName(), dmtnPackageDescription.add(new IDefaultMutableTreeNode(GlobalData.vPackageList.elementAt(index)
.getName(),
IDefaultMutableTreeNode.PACKAGE, false, 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, dmtnPlatformDescription = new IDefaultMutableTreeNode("PlatformDescription", IDefaultMutableTreeNode.PLATFORM,
-1); -1);
if (this.vPlatformList.size() > 0) { if (GlobalData.vPlatformList.size() > 0) {
for (int index = 0; index < this.vPlatformList.size(); index++) { for (int index = 0; index < GlobalData.vPlatformList.size(); index++) {
dmtnPlatformDescription.add(new IDefaultMutableTreeNode(this.vPlatformList.elementAt(index).getName(), dmtnPlatformDescription.add(new IDefaultMutableTreeNode(GlobalData.vPlatformList.elementAt(index)
IDefaultMutableTreeNode.PLATFORM, .getName(),
false, this.vPlatformList.elementAt(index))); 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 // 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); true, mid);
// //
// First find the module belongs to which package // 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 Open Module
@ -2174,46 +2081,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
**/ **/
private void openModule(String path) { private void openModule(String path) {
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; ModuleIdentification id = GlobalData.openingModuleList.getIdByPath(path);
try { if (id == null) {
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 {
// //
// The module is not in existing packages // The module is not in existing packages
// //
@ -2229,7 +2098,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
// Update opening Module list information // Update opening Module list information
// //
if (!openingModuleList.existsModule(id)) { if (!GlobalData.openingModuleList.getModuleOpen(id)) {
// //
// Insert sub node of module // Insert sub node of module
// //
@ -2239,16 +2108,16 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
// Update opening module list // Update opening module list
// //
openingModuleList.insertToOpeningModuleList(id, msa); GlobalData.openingModuleList.setModuleOpen(id, true);
openingModuleList.setTreePathById(id, iTree.getSelectionPath()); GlobalData.openingModuleList.setTreePathById(id, iTree.getSelectionPath());
} }
// //
// Select msa header node and show it in editor panel // Select msa header node and show it in editor panel
// //
iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id,
IDefaultMutableTreeNode.MSA_HEADER))); IDefaultMutableTreeNode.MSA_HEADER)));
showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, openingModuleList.getOpeningModuleById(id)); showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, GlobalData.openingModuleList.getOpeningModuleById(id));
this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id); this.currentOpeningModuleIndex = GlobalData.openingModuleList.findIndexOfListById(id);
} }
/** /**
@ -2258,38 +2127,10 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
**/ **/
private void openPackage(String path) { private void openPackage(String path) {
PackageSurfaceAreaDocument.PackageSurfaceArea spd = null; PackageIdentification id = GlobalData.openingPackageList.getIdByPath(path);
try { if (id == null) {
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) {
// //
// 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!"); Log.wrn("Open Package", "The package hasn't been added to current workspace!");
return; return;
@ -2303,7 +2144,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
// Update opening package list information // Update opening package list information
// //
if (!openingPackageList.existsPackage(id)) { if (!GlobalData.openingPackageList.getPackageOpen(id)) {
// //
// Insert sub node of module // Insert sub node of module
// //
@ -2313,16 +2154,16 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
// Update opening module list // Update opening module list
// //
openingPackageList.insertToOpeningPackageList(id, spd); GlobalData.openingPackageList.setPackageOpen(id, true);
openingPackageList.setTreePathById(id, iTree.getSelectionPath()); GlobalData.openingPackageList.setTreePathById(id, iTree.getSelectionPath());
} }
// //
// Show spd header in editor panel // Show spd header in editor panel
// //
iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPackageDescription, id, iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPackageDescription, id,
IDefaultMutableTreeNode.SPD_HEADER))); IDefaultMutableTreeNode.SPD_HEADER)));
showPackageElement(IDefaultMutableTreeNode.SPD_HEADER, openingPackageList.getOpeningPackageById(id)); showPackageElement(IDefaultMutableTreeNode.SPD_HEADER, GlobalData.openingPackageList.getOpeningPackageById(id));
this.currentOpeningPackageIndex = openingPackageList.findIndexOfListById(id); this.currentOpeningPackageIndex = GlobalData.openingPackageList.findIndexOfListById(id);
} }
/** /**
@ -2332,39 +2173,10 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
**/ **/
private void openPlatform(String path) { private void openPlatform(String path) {
PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd = null; PlatformIdentification id = GlobalData.openingPlatformList.getIdByPath(path);
try { if (id == null) {
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) {
// //
// 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!"); Log.wrn("Open Platform", "The platform hasn't been added to current workspace!");
return; return;
@ -2378,7 +2190,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
// Update opening package list information // Update opening package list information
// //
if (!openingPlatformList.existsPlatform(id)) { if (!GlobalData.openingPlatformList.getPlatformOpen(id)) {
// //
// Insert sub node of module // Insert sub node of module
// //
@ -2388,16 +2200,17 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
// Update opening module list // Update opening module list
// //
openingPlatformList.insertToOpeningPlatformList(id, fpd); GlobalData.openingPlatformList.setPlatformOpen(id, true);
openingPlatformList.setTreePathById(id, iTree.getSelectionPath()); GlobalData.openingPlatformList.setTreePathById(id, iTree.getSelectionPath());
} }
// //
// Show fpd header in editor panel // Show fpd header in editor panel
// //
iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPlatformDescription, id, iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPlatformDescription, id,
IDefaultMutableTreeNode.FPD_PLATFORMHEADER))); IDefaultMutableTreeNode.FPD_PLATFORMHEADER)));
showPlatformElement(IDefaultMutableTreeNode.FPD_PLATFORMHEADER, openingPlatformList.getOpeningPlatformById(id)); showPlatformElement(IDefaultMutableTreeNode.FPD_PLATFORMHEADER,
this.currentOpeningPlatformIndex = openingPlatformList.findIndexOfListById(id); 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) { private void saveModule(int index) {
OpeningModuleType omt = openingModuleList.getOpeningModuleByIndex(index); OpeningModuleType omt = GlobalData.openingModuleList.getOpeningModuleByIndex(index);
if (omt.isNew()) { if (omt.isNew()) {
if (getNewFilePath(DataType.MODULE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { if (getNewFilePath(DataType.MODULE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) {
return; return;
@ -2413,8 +2226,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
} }
try { try {
SaveFile.saveMsaFile(omt.getId().getPath(), omt.getXmlMsa()); SaveFile.saveMsaFile(omt.getId().getPath(), omt.getXmlMsa());
openingModuleList.setNew(omt.getId(), false); GlobalData.openingModuleList.setNew(omt.getId(), false);
openingModuleList.setModuleSaved(omt.getId(), true); GlobalData.openingModuleList.setModuleSaved(omt.getId(), true);
} catch (Exception e) { } catch (Exception e) {
Log.wrn("Save Module", e.getMessage()); Log.wrn("Save Module", e.getMessage());
Log.err("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) { private void savePackage(int index) {
OpeningPackageType opt = openingPackageList.getOpeningPackageByIndex(index); OpeningPackageType opt = GlobalData.openingPackageList.getOpeningPackageByIndex(index);
if (opt.isNew()) { if (opt.isNew()) {
if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) {
return; return;
@ -2434,8 +2247,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
} }
try { try {
SaveFile.saveSpdFile(opt.getId().getPath(), opt.getXmlSpd()); SaveFile.saveSpdFile(opt.getId().getPath(), opt.getXmlSpd());
openingPackageList.setNew(opt.getId(), false); GlobalData.openingPackageList.setNew(opt.getId(), false);
openingPackageList.setPackageSaved(opt.getId(), true); GlobalData.openingPackageList.setPackageSaved(opt.getId(), true);
} catch (Exception e) { } catch (Exception e) {
Log.wrn("Save Package", e.getMessage()); Log.wrn("Save Package", e.getMessage());
Log.err("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) { private void savePlatform(int index) {
OpeningPlatformType opt = openingPlatformList.getOpeningPlatformByIndex(index); OpeningPlatformType opt = GlobalData.openingPlatformList.getOpeningPlatformByIndex(index);
if (opt.isNew()) { if (opt.isNew()) {
if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) {
return; return;
@ -2455,8 +2268,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
} }
try { try {
SaveFile.saveFpdFile(opt.getId().getPath(), opt.getXmlFpd()); SaveFile.saveFpdFile(opt.getId().getPath(), opt.getXmlFpd());
openingPlatformList.setNew(opt.getId(), false); GlobalData.openingPlatformList.setNew(opt.getId(), false);
openingPlatformList.setPlatformSaved(opt.getId(), true); GlobalData.openingPlatformList.setPlatformSaved(opt.getId(), true);
} catch (Exception e) { } catch (Exception e) {
Log.wrn("Save Package", e.getMessage()); Log.wrn("Save Package", e.getMessage());
Log.err("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) { private void insertModuleTreeNode(Identification id) {
iTree.addNode(new IDefaultMutableTreeNode("Module Header", IDefaultMutableTreeNode.MSA_HEADER, true, id)); iTree.addNode(new IDefaultMutableTreeNode("Module Header", IDefaultMutableTreeNode.MSA_HEADER, true, id));
iTree.addNode(new IDefaultMutableTreeNode("Module Definitions", IDefaultMutableTreeNode.MSA_MODULEDEFINITIONS, iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id));
true, id));
iTree.addNode(new IDefaultMutableTreeNode("Library Class Definitions", iTree.addNode(new IDefaultMutableTreeNode("Library Class Definitions",
IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS, true, id)); IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS, true, id));
iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id));
iTree.addNode(new IDefaultMutableTreeNode("Package Dependencies", iTree.addNode(new IDefaultMutableTreeNode("Package Dependencies",
IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES, true, id)); IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES, true, id));
iTree.addNode(new IDefaultMutableTreeNode("Protocols", IDefaultMutableTreeNode.MSA_PROTOCOLS, 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) { private void insertPackageTreeNode(Identification id) {
iTree.addNode(new IDefaultMutableTreeNode("Package Header", IDefaultMutableTreeNode.SPD_HEADER, true, 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", iTree.addNode(new IDefaultMutableTreeNode("Library Class Declarations",
IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS, true, id)); IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS, true, id));
iTree.addNode(new IDefaultMutableTreeNode("Msa Files", IDefaultMutableTreeNode.SPD_MSAFILES, false, id)); iTree.addNode(new IDefaultMutableTreeNode("Msa Files", IDefaultMutableTreeNode.SPD_MSAFILES, false, id));
@ -2613,22 +2416,33 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// Show editor panel // Show editor panel
// //
if (intCategory >= IDefaultMutableTreeNode.MSA_HEADER && intCategory < IDefaultMutableTreeNode.SPD_HEADER) { if (intCategory >= IDefaultMutableTreeNode.MSA_HEADER && intCategory < IDefaultMutableTreeNode.SPD_HEADER) {
showModuleElement(intCategory, openingModuleList.getOpeningModuleById(id)); showModuleElement(intCategory,
this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id); GlobalData.openingModuleList.getOpeningModuleById(new ModuleIdentification(id)));
this.currentOpeningModuleIndex = GlobalData.openingModuleList
.findIndexOfListById(new ModuleIdentification(
id));
} }
if (intCategory >= IDefaultMutableTreeNode.SPD_HEADER if (intCategory >= IDefaultMutableTreeNode.SPD_HEADER
&& intCategory < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { && intCategory < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) {
showPackageElement(intCategory, openingPackageList.getOpeningPackageById(id)); showPackageElement(intCategory,
this.currentOpeningPackageIndex = openingPackageList.findIndexOfListById(id); GlobalData.openingPackageList.getOpeningPackageById(new PackageIdentification(id)));
this.currentOpeningPackageIndex = GlobalData.openingPackageList
.findIndexOfListById(new PackageIdentification(
id));
} }
if (intCategory >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { if (intCategory >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) {
showPlatformElement(intCategory, openingPlatformList.getOpeningPlatformById(id)); showPlatformElement(
this.currentOpeningPlatformIndex = openingPlatformList.findIndexOfListById(id); intCategory,
GlobalData.openingPlatformList
.getOpeningPlatformById(new PlatformIdentification(id)));
this.currentOpeningPlatformIndex = GlobalData.openingPlatformList
.findIndexOfListById(new PlatformIdentification(
id));
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.log("double click category: " + intCategory); Log.err("double click category: " + intCategory);
Log.log("double click id path: " + id); Log.err("double click id path: " + id);
Log.log("double click exception: " + e.getMessage()); Log.err("double click exception: " + e.getMessage());
} }
} }
@ -2734,10 +2548,6 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
MsaHeader frmMsaHeader = new MsaHeader(msa); MsaHeader frmMsaHeader = new MsaHeader(msa);
getJDesktopPaneModule().add(frmMsaHeader, 1); getJDesktopPaneModule().add(frmMsaHeader, 1);
break; break;
case IDefaultMutableTreeNode.MSA_MODULEDEFINITIONS:
ModuleDefinitions frmMd = new ModuleDefinitions(msa);
getJDesktopPaneModule().add(frmMd, 1);
break;
case IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS: case IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS:
ModuleLibraryClassDefinitions frmMlcd = new ModuleLibraryClassDefinitions(msa); ModuleLibraryClassDefinitions frmMlcd = new ModuleLibraryClassDefinitions(msa);
getJDesktopPaneModule().add(frmMlcd, 1); getJDesktopPaneModule().add(frmMlcd, 1);
@ -2833,26 +2643,47 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
smb.dispose(); smb.dispose();
return; return;
} else if (result == DataType.RETURN_TYPE_OK) { } else if (result == DataType.RETURN_TYPE_OK) {
PackageSurfaceAreaDocument.PackageSurfaceArea psa = null; ModuleIdentification mid = smb.getMid();
if (this.openingPackageList.existsPackage(smb.getMid().getPackageId())) { if (mid != null) {
psa = openingPackageList.getPackageSurfaceAreaFromId(smb.getMid().getPackageId()); //
// 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());
} }
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;
}
this.openModule(smb.getMid().getPath(), smb.getMid());
} }
} else if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { } else if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
// //
@ -2866,30 +2697,37 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
smb.dispose(); smb.dispose();
return; return;
} else if (result == DataType.RETURN_TYPE_OK) { } else if (result == DataType.RETURN_TYPE_OK) {
try { PackageIdentification pid = smb.getPid();
wt.addPackageToDatabase(smb.getPid()); if (pid != null) {
} catch (Exception e) { try {
Log.err("addPackageToDatabase", e.getMessage()); wt.addPackageToDatabase(smb.getPid());
} catch (Exception e) {
Log.err("addPackageToDatabase", e.getMessage());
}
//
// Update Global Data
//
GlobalData.openingPackageList.insertToOpeningPackageList(pid, smb.getSpd());
GlobalData.vPackageList.addElement(pid);
//
// Add to Module Description node
//
IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(pid.getName(),
IDefaultMutableTreeNode.MODULE_PACKAGE,
false, pid);
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(pid.getPath());
} }
vPackageList.addElement(smb.getPid());
//
// Add to Module Description node
//
IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(),
IDefaultMutableTreeNode.MODULE_PACKAGE,
false, vPackageList.lastElement());
iTree.addNode(dmtnModuleDescription, node);
//
// Add new SpdHeader node to the tree
//
node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(),
IDefaultMutableTreeNode.SPD_HEADER, true, vPackageList.lastElement());
iTree.addNode(dmtnPackageDescription, node);
this.openPackage(smb.getPid().getPath());
} }
} else if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { } else if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
// //
@ -2903,20 +2741,28 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
smb.dispose(); smb.dispose();
return; return;
} else if (result == DataType.RETURN_TYPE_OK) { } else if (result == DataType.RETURN_TYPE_OK) {
try { PlatformIdentification fid = smb.getFid();
wt.addPlatformToDatabase(smb.getFid()); if (fid != null) {
} catch (Exception e) { try {
Log.err("addPlatformToDatabase", e.getMessage()); 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: case 0:
if (this.currentOpeningModuleIndex > -1) { if (this.currentOpeningModuleIndex > -1) {
if (!openingModuleList.getModuleSaved(currentOpeningModuleIndex)) { if (!GlobalData.openingModuleList.getModuleSaved(currentOpeningModuleIndex)) {
int result = showSaveDialog(); int result = showSaveDialog();
if (result == JOptionPane.YES_OPTION) { if (result == JOptionPane.YES_OPTION) {
this.saveAll(); this.saveAll();
@ -2974,8 +2820,10 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
return; return;
} }
} }
iTree.removeNodeChildrenByPath(openingModuleList.getTreePathByIndex(currentOpeningModuleIndex)); iTree
this.openingModuleList.removeFromOpeningModuleListByIndex(this.currentOpeningModuleIndex); .removeNodeChildrenByPath(GlobalData.openingModuleList
.getTreePathByIndex(currentOpeningModuleIndex));
GlobalData.openingModuleList.setModuleOpen(this.currentOpeningModuleIndex, false);
this.cleanDesktopPaneModule(); this.cleanDesktopPaneModule();
this.currentOpeningModuleIndex = -1; this.currentOpeningModuleIndex = -1;
} }
@ -2985,7 +2833,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
case 1: case 1:
if (this.currentOpeningPackageIndex > -1) { if (this.currentOpeningPackageIndex > -1) {
if (!openingPackageList.getPackageSaved(currentOpeningPackageIndex)) { if (!GlobalData.openingPackageList.getPackageSaved(currentOpeningPackageIndex)) {
int result = showSaveDialog(); int result = showSaveDialog();
if (result == JOptionPane.YES_OPTION) { if (result == JOptionPane.YES_OPTION) {
this.saveAll(); this.saveAll();
@ -2997,8 +2845,10 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
return; return;
} }
} }
iTree.removeNodeChildrenByPath(openingPackageList.getTreePathByIndex(currentOpeningPackageIndex)); iTree
this.openingPackageList.removeFromOpeningPackageListByIndex(this.currentOpeningPackageIndex); .removeNodeChildrenByPath(GlobalData.openingPackageList
.getTreePathByIndex(currentOpeningPackageIndex));
GlobalData.openingPackageList.setPackageOpen(this.currentOpeningPackageIndex, false);
this.cleanDesktopPanePackage(); this.cleanDesktopPanePackage();
this.currentOpeningPackageIndex = -1; this.currentOpeningPackageIndex = -1;
} }
@ -3008,7 +2858,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
case 2: case 2:
if (this.currentOpeningPlatformIndex > -1) { if (this.currentOpeningPlatformIndex > -1) {
if (!openingPlatformList.getPlatformSaved(currentOpeningPlatformIndex)) { if (!GlobalData.openingPlatformList.getPlatformSaved(currentOpeningPlatformIndex)) {
int result = showSaveDialog(); int result = showSaveDialog();
if (result == JOptionPane.YES_OPTION) { if (result == JOptionPane.YES_OPTION) {
this.saveAll(); this.saveAll();
@ -3020,8 +2870,10 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
return; return;
} }
} }
iTree.removeNodeChildrenByPath(openingPlatformList.getTreePathByIndex(currentOpeningPlatformIndex)); iTree
this.openingPlatformList.removeFromOpeningPlatformListByIndex(this.currentOpeningPlatformIndex); .removeNodeChildrenByPath(GlobalData.openingPlatformList
.getTreePathByIndex(currentOpeningPlatformIndex));
GlobalData.openingPlatformList.setPlatformOpen(this.currentOpeningPlatformIndex, false);
this.cleanDesktopPanePlatform(); this.cleanDesktopPanePlatform();
this.currentOpeningPlatformIndex = -1; this.currentOpeningPlatformIndex = -1;
} }
@ -3035,7 +2887,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
**/ **/
private void closeAll() { private void closeAll() {
int result = -1; int result = -1;
if (!openingModuleList.isSaved() || !openingPackageList.isSaved() || !openingPlatformList.isSaved()) { if (!GlobalData.openingModuleList.isSaved() || !GlobalData.openingPackageList.isSaved()
|| !GlobalData.openingPlatformList.isSaved()) {
result = showSaveDialog(); result = showSaveDialog();
} }
if (result == JOptionPane.YES_OPTION) { if (result == JOptionPane.YES_OPTION) {
@ -3050,10 +2903,9 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
return; return;
} }
this.cleanDesktopPane(); this.cleanDesktopPane();
this.getCompontentsFromFrameworkDatabase(); GlobalData.openingModuleList.closeAll();
openingModuleList.removeAllFromOpeningModuleList(); GlobalData.openingPackageList.closeAll();
openingPackageList.removeAllFromOpeningPackageList(); GlobalData.openingPlatformList.closeAll();
openingPlatformList.removeAllFromOpeningPlatformList();
this.makeEmptyTree(); this.makeEmptyTree();
} }
@ -3089,8 +2941,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
// Save all modules // Save all modules
// //
for (int index = 0; index < openingModuleList.size(); index++) { for (int index = 0; index < GlobalData.openingModuleList.size(); index++) {
if (!openingModuleList.getModuleSaved(index)) { if (!GlobalData.openingModuleList.getModuleSaved(index)) {
saveModule(index); saveModule(index);
} }
} }
@ -3098,8 +2950,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
// Save all packages // Save all packages
// //
for (int index = 0; index < openingPackageList.size(); index++) { for (int index = 0; index < GlobalData.openingPackageList.size(); index++) {
if (!openingPackageList.getPackageSaved(index)) { if (!GlobalData.openingPackageList.getPackageSaved(index)) {
savePackage(index); savePackage(index);
} }
} }
@ -3107,8 +2959,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
// //
// Save all platforms // Save all platforms
// //
for (int index = 0; index < openingPlatformList.size(); index++) { for (int index = 0; index < GlobalData.openingPlatformList.size(); index++) {
if (!openingPlatformList.getPlatformSaved(index)) { if (!GlobalData.openingPlatformList.getPlatformSaved(index)) {
savePlatform(index); savePlatform(index);
} }
} }
@ -3120,7 +2972,8 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
**/ **/
private void exit() { private void exit() {
int result = -1; int result = -1;
if (!openingModuleList.isSaved() || !openingPackageList.isSaved() || !openingPlatformList.isSaved()) { if (!GlobalData.openingModuleList.isSaved() || !GlobalData.openingPackageList.isSaved()
|| !GlobalData.openingPlatformList.isSaved()) {
result = showSaveDialog(); result = showSaveDialog();
} }
if (result == JOptionPane.YES_OPTION) { 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) { if (result == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
Tools.showInformationMessage("Module Surface Area Clone Finished"); Tools.showInformationMessage("Module Surface Area Clone Finished");
vModuleList.addElement(c.getMid()); GlobalData.vModuleList.addElement(c.getMid());
addModuleToTree(c.getMid()); addModuleToTree(c.getMid());
} }
if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
Tools.showInformationMessage("Package Surface Area Clone Finished"); Tools.showInformationMessage("Package Surface Area Clone Finished");
vPackageList.addElement(c.getPid()); GlobalData.vPackageList.addElement(c.getPid());
// //
// Add new SpdHeader node to the tree // 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, IDefaultMutableTreeNode.SPD_HEADER, true,
vPackageList.lastElement()); GlobalData.vPackageList.lastElement());
iTree.addNode(dmtnPackageDescription, node); iTree.addNode(dmtnPackageDescription, node);
} }
if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
Tools.showInformationMessage("Platform Surface Area Clone Finished"); Tools.showInformationMessage("Platform Surface Area Clone Finished");
vPlatformList.addElement(c.getFid()); GlobalData.vPlatformList.addElement(c.getFid());
// //
// Add new SpdHeader node to the tree // 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, IDefaultMutableTreeNode.FPD_PLATFORMHEADER,
true, vPlatformList.lastElement()); true, GlobalData.vPlatformList.lastElement());
iTree.addNode(dmtnPlatformDescription, node); iTree.addNode(dmtnPlatformDescription, node);
//this.openPlatform(c.getFid().getPath()); //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 // Enable close/close all if some files are opened
// //
jMenuItemFileClose.setEnabled(openingModuleList.isOpend() || openingPackageList.isOpend() jMenuItemFileClose.setEnabled(GlobalData.openingModuleList.isOpen()
|| openingPlatformList.isOpend()); || GlobalData.openingPackageList.isOpen()
jMenuItemFileCloseAll.setEnabled(openingModuleList.isOpend() || openingPackageList.isOpend() || GlobalData.openingPlatformList.isOpen());
|| openingPlatformList.isOpend()); jMenuItemFileCloseAll.setEnabled(GlobalData.openingModuleList.isOpen()
|| GlobalData.openingPackageList.isOpen()
|| GlobalData.openingPlatformList.isOpen());
// //
// Enable save/save all if some files are changed // Enable save/save all if some files are changed
// //
jMenuItemFileSave.setEnabled(!openingModuleList.isSaved() || !openingPackageList.isSaved() jMenuItemFileSave.setEnabled(!GlobalData.openingModuleList.isSaved()
|| !openingPlatformList.isSaved()); || !GlobalData.openingPackageList.isSaved()
jMenuItemFileSaveAll.setEnabled(!openingModuleList.isSaved() || !openingPackageList.isSaved() || !GlobalData.openingPlatformList.isSaved());
|| !openingPlatformList.isSaved()); jMenuItemFileSaveAll.setEnabled(!GlobalData.openingModuleList.isSaved()
|| !GlobalData.openingPackageList.isSaved()
|| !GlobalData.openingPlatformList.isSaved());
} }
if (arg0.getSource() == jMenuTools) { if (arg0.getSource() == jMenuTools) {

View File

@ -28,9 +28,9 @@ import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.MsaHeaderDocument; import org.tianocore.MsaHeaderDocument;
import org.tianocore.SpdHeaderDocument; import org.tianocore.SpdHeaderDocument;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea; import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
import org.tianocore.PlatformHeaderDocument.PlatformHeader; import org.tianocore.PlatformHeaderDocument.PlatformHeader;
import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea; import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
@ -110,6 +110,12 @@ public class SelectModuleBelong extends IDialog {
private PlatformIdentification fid = null; private PlatformIdentification fid = null;
private ModuleSurfaceArea msa = null;
private PackageSurfaceArea spd = null;
private PlatformSurfaceArea fpd = null;
private int mode = -1; private int mode = -1;
private JLabel jLabelIsLibrary = null; private JLabel jLabelIsLibrary = null;
@ -572,7 +578,7 @@ public class SelectModuleBelong extends IDialog {
**/ **/
private void saveModule() { private void saveModule() {
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; msa = null;
String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText()); String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
// //
@ -581,7 +587,7 @@ public class SelectModuleBelong extends IDialog {
try { try {
MsaHeaderDocument.MsaHeader msaHeader = null; MsaHeaderDocument.MsaHeader msaHeader = null;
msa = ModuleSurfaceAreaDocument.ModuleSurfaceArea.Factory.newInstance(); msa = ModuleSurfaceArea.Factory.newInstance();
msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance(); msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance();
msaHeader.setModuleName(this.jTextFieldName.getText()); msaHeader.setModuleName(this.jTextFieldName.getText());
@ -618,7 +624,7 @@ public class SelectModuleBelong extends IDialog {
**/ **/
private void savePackage() { private void savePackage() {
PackageSurfaceArea spd = null; spd = null;
String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText()); String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
// //
@ -664,7 +670,7 @@ public class SelectModuleBelong extends IDialog {
**/ **/
private void savePlatform() { private void savePlatform() {
PlatformSurfaceArea fpd = null; fpd = null;
String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText()); String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
// //
@ -709,27 +715,27 @@ public class SelectModuleBelong extends IDialog {
return mid; return mid;
} }
public void setMid(ModuleIdentification mid) {
this.mid = mid;
}
public PlatformIdentification getFid() { public PlatformIdentification getFid() {
return fid; return fid;
} }
public void setFid(PlatformIdentification fid) {
this.fid = fid;
}
public PackageIdentification getPid() { public PackageIdentification getPid() {
return pid; return pid;
} }
public void setPid(PackageIdentification pid) {
this.pid = pid;
}
private void upLocation(Component c, int size) { private void upLocation(Component c, int size) {
c.setLocation(c.getLocation().x, c.getLocation().y - 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;
}
} }

View File

@ -237,4 +237,11 @@ public class DataType {
// Hex String Header // Hex String Header
// //
public static final String HEX_STRING_HEADER = "0x"; public static final String HEX_STRING_HEADER = "0x";
//
// The String of Boolean
//
public static final String TRUE = "True";
public static final String FALSE = "False";
} }

View File

@ -293,8 +293,8 @@ public class EnumerationData {
private void initBoolean() { private void initBoolean() {
vBoolean.removeAllElements(); vBoolean.removeAllElements();
vBoolean.addElement("False"); vBoolean.addElement(DataType.FALSE);
vBoolean.addElement("True"); vBoolean.addElement(DataType.TRUE);
} }
private void initModuleType() { private void initModuleType() {

View File

@ -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<ModuleIdentification> vModuleList = new Vector<ModuleIdentification>();
public static Vector<PackageIdentification> vPackageList = new Vector<PackageIdentification>();
public static Vector<PlatformIdentification> vPlatformList = new Vector<PlatformIdentification>();
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<ModuleIdentification>();
openingModuleList = new OpeningModuleList();
ModuleSurfaceArea msa = null;
Vector<String> modulePaths = new Vector<String>();
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<PackageIdentification>();
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<PlatformIdentification>();
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<String> getAllModulesOfPackage(String path) {
Vector<String> modulePath = new Vector<String>();
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;
}
}

View File

@ -49,7 +49,6 @@ public class Identification {
if (obj instanceof Identification) { if (obj instanceof Identification) {
Identification id = (Identification) obj; Identification id = (Identification) obj;
if (path.equals(id.path)) { if (path.equals(id.path)) {
//if ( name.equals(id.name) && guid.equals(id.guid) && version.equals(id.version)) {
return true; return true;
} }
return false; return false;

View File

@ -22,36 +22,22 @@ public class OpeningFileType {
// //
// Define class members // Define class members
// //
private Identification id = null;
private boolean isSaved = true; private boolean isSaved = true;
private boolean isNew = false; private boolean isNew = false;
private boolean isOpen = false;
private TreePath treePath = null; private TreePath treePath = null;
public OpeningFileType() { public OpeningFileType() {
} }
public OpeningFileType(Identification identification) { public OpeningFileType(TreePath treePathValue) {
this.id = identification;
}
public OpeningFileType(Identification identification, TreePath treePathValue) {
this.id = identification;
this.treePath = treePathValue; this.treePath = treePathValue;
} }
public Identification getId() {
return id;
}
public void setId(Identification id) {
this.id = id;
}
public boolean isNew() { public boolean isNew() {
return isNew; return isNew;
} }
@ -75,4 +61,12 @@ public class OpeningFileType {
public void setTreePath(TreePath treePath) { public void setTreePath(TreePath treePath) {
this.treePath = treePath; this.treePath = treePath;
} }
public boolean isOpen() {
return isOpen;
}
public void setOpen(boolean isOpen) {
this.isOpen = isOpen;
}
} }

View File

@ -19,6 +19,7 @@ import java.util.Vector;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import org.tianocore.ModuleSurfaceAreaDocument; import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
public class OpeningModuleList { public class OpeningModuleList {
private Vector<OpeningModuleType> vOpeningModuleList = new Vector<OpeningModuleType>(); private Vector<OpeningModuleType> vOpeningModuleList = new Vector<OpeningModuleType>();
@ -34,7 +35,7 @@ public class OpeningModuleList {
vOpeningModuleList = 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)); vOpeningModuleList.addElement(new OpeningModuleType(id, xmlMsa));
} }
@ -45,7 +46,7 @@ public class OpeningModuleList {
return null; return null;
} }
public OpeningModuleType getOpeningModuleById(Identification id) { public OpeningModuleType getOpeningModuleById(ModuleIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return vOpeningModuleList.elementAt(index); return vOpeningModuleList.elementAt(index);
@ -53,7 +54,7 @@ public class OpeningModuleList {
return null; return null;
} }
public int findIndexOfListById(Identification id) { public int findIndexOfListById(ModuleIdentification id) {
for (int index = 0; index < vOpeningModuleList.size(); index++) { for (int index = 0; index < vOpeningModuleList.size(); index++) {
if (vOpeningModuleList.elementAt(index).getId().equals(id)) { if (vOpeningModuleList.elementAt(index).getId().equals(id)) {
return index; return index;
@ -68,7 +69,7 @@ public class OpeningModuleList {
} }
} }
public void removeFromOpeningModuleListById(Identification id) { public void removeFromOpeningModuleListById(ModuleIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
vOpeningModuleList.removeElementAt(findIndexOfListById(id)); vOpeningModuleList.removeElementAt(findIndexOfListById(id));
@ -79,7 +80,7 @@ public class OpeningModuleList {
vOpeningModuleList.removeAllElements(); vOpeningModuleList.removeAllElements();
} }
public ModuleSurfaceAreaDocument.ModuleSurfaceArea getModuleSurfaceAreaFromId(Identification id) { public ModuleSurfaceAreaDocument.ModuleSurfaceArea getModuleSurfaceAreaFromId(ModuleIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return vOpeningModuleList.elementAt(index).getXmlMsa(); return vOpeningModuleList.elementAt(index).getXmlMsa();
@ -87,7 +88,7 @@ public class OpeningModuleList {
return null; return null;
} }
public boolean existsModule(Identification id) { public boolean existsModule(ModuleIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return true; return true;
@ -95,7 +96,7 @@ public class OpeningModuleList {
return false; return false;
} }
public void setModuleSaved(Identification id, boolean isSaved) { public void setModuleSaved(ModuleIdentification id, boolean isSaved) {
setModuleSaved(findIndexOfListById(id), 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)); return getModuleSaved(findIndexOfListById(id));
} }
@ -116,14 +117,35 @@ public class OpeningModuleList {
return true; 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); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
vOpeningModuleList.elementAt(index).setTreePath(treePath); vOpeningModuleList.elementAt(index).setTreePath(treePath);
} }
} }
public TreePath getTreePathById(Identification id) { public TreePath getTreePathById(ModuleIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return vOpeningModuleList.elementAt(index).getTreePath(); return vOpeningModuleList.elementAt(index).getTreePath();
@ -138,13 +160,28 @@ public class OpeningModuleList {
return null; 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); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
vOpeningModuleList.elementAt(index).setNew(isNew); vOpeningModuleList.elementAt(index).setNew(isNew);
} }
} }
public void closeAll() {
for (int index = 0; index < this.size(); index++) {
this.setModuleOpen(index, false);
}
}
public int size() { public int size() {
return vOpeningModuleList.size(); return vOpeningModuleList.size();
} }
@ -158,9 +195,11 @@ public class OpeningModuleList {
return true; return true;
} }
public boolean isOpend() { public boolean isOpen() {
if (this.size() > 0 ) { for (int index = 0; index < this.size(); index++) {
return true; if (this.getModuleOpen(index)) {
return true;
}
} }
return false; return false;
} }

View File

@ -18,6 +18,7 @@ package org.tianocore.frameworkwizard.common.Identifications;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import org.tianocore.ModuleSurfaceAreaDocument; import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
public class OpeningModuleType extends OpeningFileType{ public class OpeningModuleType extends OpeningFileType{
// //
@ -25,17 +26,21 @@ public class OpeningModuleType extends OpeningFileType{
// //
private ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa = null; private ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa = null;
private ModuleIdentification id = null;
public OpeningModuleType() { public OpeningModuleType() {
} }
public OpeningModuleType(Identification identification, ModuleSurfaceAreaDocument.ModuleSurfaceArea msa) { public OpeningModuleType(ModuleIdentification identification, ModuleSurfaceAreaDocument.ModuleSurfaceArea msa) {
super(identification); this.id = identification;
this.xmlMsa = msa; this.xmlMsa = msa;
} }
public OpeningModuleType(Identification identification, ModuleSurfaceAreaDocument.ModuleSurfaceArea msa, TreePath treePath) { public OpeningModuleType(ModuleIdentification identification, ModuleSurfaceAreaDocument.ModuleSurfaceArea msa, TreePath treePath) {
super(identification, treePath); super(treePath);
this.id = identification;
this.xmlMsa = msa; this.xmlMsa = msa;
} }
@ -46,4 +51,12 @@ public class OpeningModuleType extends OpeningFileType{
public void setXmlMsa(ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa) { public void setXmlMsa(ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa) {
this.xmlMsa = xmlMsa; this.xmlMsa = xmlMsa;
} }
public ModuleIdentification getId() {
return id;
}
public void setId(ModuleIdentification id) {
this.id = id;
}
} }

View File

@ -19,6 +19,7 @@ import java.util.Vector;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import org.tianocore.PackageSurfaceAreaDocument; import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
public class OpeningPackageList { public class OpeningPackageList {
private Vector<OpeningPackageType> vOpeningPackageList = new Vector<OpeningPackageType>(); private Vector<OpeningPackageType> vOpeningPackageList = new Vector<OpeningPackageType>();
@ -35,7 +36,7 @@ public class OpeningPackageList {
vOpeningPackageList = 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)); vOpeningPackageList.addElement(new OpeningPackageType(id, xmlMsa));
} }
@ -46,7 +47,7 @@ public class OpeningPackageList {
return null; return null;
} }
public OpeningPackageType getOpeningPackageById(Identification id) { public OpeningPackageType getOpeningPackageById(PackageIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return vOpeningPackageList.elementAt(index); return vOpeningPackageList.elementAt(index);
@ -54,7 +55,7 @@ public class OpeningPackageList {
return null; return null;
} }
public int findIndexOfListById(Identification id) { public int findIndexOfListById(PackageIdentification id) {
for (int index = 0; index < vOpeningPackageList.size(); index++) { for (int index = 0; index < vOpeningPackageList.size(); index++) {
if (vOpeningPackageList.elementAt(index).getId().equals(id)) { if (vOpeningPackageList.elementAt(index).getId().equals(id)) {
return index; return index;
@ -69,7 +70,7 @@ public class OpeningPackageList {
} }
} }
public void removeFromOpeningPackageListById(Identification id) { public void removeFromOpeningPackageListById(PackageIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
vOpeningPackageList.removeElementAt(findIndexOfListById(id)); vOpeningPackageList.removeElementAt(findIndexOfListById(id));
@ -80,7 +81,7 @@ public class OpeningPackageList {
vOpeningPackageList.removeAllElements(); vOpeningPackageList.removeAllElements();
} }
public PackageSurfaceAreaDocument.PackageSurfaceArea getPackageSurfaceAreaFromId(Identification id) { public PackageSurfaceAreaDocument.PackageSurfaceArea getPackageSurfaceAreaFromId(PackageIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return vOpeningPackageList.elementAt(index).getXmlSpd(); return vOpeningPackageList.elementAt(index).getXmlSpd();
@ -88,7 +89,7 @@ public class OpeningPackageList {
return null; return null;
} }
public boolean existsPackage(Identification id) { public boolean existsPackage(PackageIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return true; return true;
@ -96,7 +97,7 @@ public class OpeningPackageList {
return false; return false;
} }
public void setPackageSaved(Identification id, boolean isSaved) { public void setPackageSaved(PackageIdentification id, boolean isSaved) {
setPackageSaved(findIndexOfListById(id), 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)); return getPackageSaved(findIndexOfListById(id));
} }
@ -117,14 +118,35 @@ public class OpeningPackageList {
return true; 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); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
vOpeningPackageList.elementAt(index).setTreePath(treePath); vOpeningPackageList.elementAt(index).setTreePath(treePath);
} }
} }
public TreePath getTreePathById(Identification id) { public TreePath getTreePathById(PackageIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return vOpeningPackageList.elementAt(index).getTreePath(); return vOpeningPackageList.elementAt(index).getTreePath();
@ -139,13 +161,28 @@ public class OpeningPackageList {
return null; 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); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
vOpeningPackageList.elementAt(index).setNew(isNew); vOpeningPackageList.elementAt(index).setNew(isNew);
} }
} }
public void closeAll() {
for (int index = 0; index < this.size(); index++) {
this.setPackageOpen(index, false);
}
}
public int size() { public int size() {
return vOpeningPackageList.size(); return vOpeningPackageList.size();
} }
@ -159,9 +196,11 @@ public class OpeningPackageList {
return true; return true;
} }
public boolean isOpend() { public boolean isOpen() {
if (this.size() > 0 ) { for (int index = 0; index < this.size(); index++) {
return true; if (this.getPackageOpen(index)) {
return true;
}
} }
return false; return false;
} }

View File

@ -17,6 +17,7 @@ package org.tianocore.frameworkwizard.common.Identifications;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import org.tianocore.PackageSurfaceAreaDocument; import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
public class OpeningPackageType extends OpeningFileType { public class OpeningPackageType extends OpeningFileType {
// //
@ -24,17 +25,21 @@ public class OpeningPackageType extends OpeningFileType {
// //
private PackageSurfaceAreaDocument.PackageSurfaceArea xmlSpd = null; private PackageSurfaceAreaDocument.PackageSurfaceArea xmlSpd = null;
private PackageIdentification id = null;
public OpeningPackageType() { public OpeningPackageType() {
} }
public OpeningPackageType(Identification identification, PackageSurfaceAreaDocument.PackageSurfaceArea spd) { public OpeningPackageType(PackageIdentification identification, PackageSurfaceAreaDocument.PackageSurfaceArea spd) {
super(identification); this.id = identification;
this.xmlSpd = spd; this.xmlSpd = spd;
} }
public OpeningPackageType(Identification identification, PackageSurfaceAreaDocument.PackageSurfaceArea spd, TreePath treePath) { public OpeningPackageType(PackageIdentification identification, PackageSurfaceAreaDocument.PackageSurfaceArea spd, TreePath treePath) {
super(identification, treePath); super(treePath);
this.id = identification;
this.xmlSpd = spd; this.xmlSpd = spd;
} }
@ -45,4 +50,12 @@ public class OpeningPackageType extends OpeningFileType {
public void setXmlSpd(PackageSurfaceAreaDocument.PackageSurfaceArea xmlSpd) { public void setXmlSpd(PackageSurfaceAreaDocument.PackageSurfaceArea xmlSpd) {
this.xmlSpd = xmlSpd; this.xmlSpd = xmlSpd;
} }
public PackageIdentification getId() {
return id;
}
public void setId(PackageIdentification id) {
this.id = id;
}
} }

View File

@ -19,6 +19,7 @@ import java.util.Vector;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import org.tianocore.PlatformSurfaceAreaDocument; import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.frameworkwizard.platform.PlatformIdentification;
public class OpeningPlatformList { public class OpeningPlatformList {
@ -36,7 +37,7 @@ public class OpeningPlatformList {
vOpeningPlatformList = 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)); vOpeningPlatformList.addElement(new OpeningPlatformType(id, xmlFpd));
} }
@ -47,7 +48,7 @@ public class OpeningPlatformList {
return null; return null;
} }
public OpeningPlatformType getOpeningPlatformById(Identification id) { public OpeningPlatformType getOpeningPlatformById(PlatformIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return vOpeningPlatformList.elementAt(index); return vOpeningPlatformList.elementAt(index);
@ -55,7 +56,7 @@ public class OpeningPlatformList {
return null; return null;
} }
public int findIndexOfListById(Identification id) { public int findIndexOfListById(PlatformIdentification id) {
for (int index = 0; index < vOpeningPlatformList.size(); index++) { for (int index = 0; index < vOpeningPlatformList.size(); index++) {
if (vOpeningPlatformList.elementAt(index).getId().equals(id)) { if (vOpeningPlatformList.elementAt(index).getId().equals(id)) {
return index; return index;
@ -70,7 +71,7 @@ public class OpeningPlatformList {
} }
} }
public void removeFromOpeningPlatformListById(Identification id) { public void removeFromOpeningPlatformListById(PlatformIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
vOpeningPlatformList.removeElementAt(findIndexOfListById(id)); vOpeningPlatformList.removeElementAt(findIndexOfListById(id));
@ -81,7 +82,7 @@ public class OpeningPlatformList {
vOpeningPlatformList.removeAllElements(); vOpeningPlatformList.removeAllElements();
} }
public PlatformSurfaceAreaDocument.PlatformSurfaceArea getPlatformSurfaceAreaFromId(Identification id) { public PlatformSurfaceAreaDocument.PlatformSurfaceArea getPlatformSurfaceAreaFromId(PlatformIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return vOpeningPlatformList.elementAt(index).getXmlFpd(); return vOpeningPlatformList.elementAt(index).getXmlFpd();
@ -89,7 +90,7 @@ public class OpeningPlatformList {
return null; return null;
} }
public boolean existsPlatform(Identification id) { public boolean existsPlatform(PlatformIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return true; 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); 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)); return getPlatformSaved(findIndexOfListById(id));
} }
@ -119,14 +120,35 @@ public class OpeningPlatformList {
return true; 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); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
vOpeningPlatformList.elementAt(index).setTreePath(treePath); vOpeningPlatformList.elementAt(index).setTreePath(treePath);
} }
} }
public TreePath getTreePathById(Identification id) { public TreePath getTreePathById(PlatformIdentification id) {
int index = findIndexOfListById(id); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
return vOpeningPlatformList.elementAt(index).getTreePath(); return vOpeningPlatformList.elementAt(index).getTreePath();
@ -141,13 +163,28 @@ public class OpeningPlatformList {
return null; 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); int index = findIndexOfListById(id);
if (index > -1) { if (index > -1) {
vOpeningPlatformList.elementAt(index).setNew(isNew); vOpeningPlatformList.elementAt(index).setNew(isNew);
} }
} }
public void closeAll() {
for (int index = 0; index < this.size(); index++) {
this.setPlatformOpen(index, false);
}
}
public int size() { public int size() {
return vOpeningPlatformList.size(); return vOpeningPlatformList.size();
} }
@ -161,9 +198,11 @@ public class OpeningPlatformList {
return true; return true;
} }
public boolean isOpend() { public boolean isOpen() {
if (this.size() > 0 ) { for (int index = 0; index < this.size(); index++) {
return true; if (this.getPlatformOpen(index)) {
return true;
}
} }
return false; return false;
} }

View File

@ -17,6 +17,7 @@ package org.tianocore.frameworkwizard.common.Identifications;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import org.tianocore.PlatformSurfaceAreaDocument; import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.frameworkwizard.platform.PlatformIdentification;
public class OpeningPlatformType extends OpeningFileType { public class OpeningPlatformType extends OpeningFileType {
// //
@ -24,17 +25,20 @@ public class OpeningPlatformType extends OpeningFileType {
// //
private PlatformSurfaceAreaDocument.PlatformSurfaceArea xmlFpd = null; private PlatformSurfaceAreaDocument.PlatformSurfaceArea xmlFpd = null;
private PlatformIdentification id = null;
public OpeningPlatformType() { public OpeningPlatformType() {
} }
public OpeningPlatformType(Identification identification, PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) { public OpeningPlatformType(PlatformIdentification identification, PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {
super(identification); this.id = identification;
this.xmlFpd = fpd; this.xmlFpd = fpd;
} }
public OpeningPlatformType(Identification identification, PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd, TreePath treePath) { public OpeningPlatformType(PlatformIdentification identification, PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd, TreePath treePath) {
super(identification, treePath); super(treePath);
this.id = identification;
this.xmlFpd = fpd; this.xmlFpd = fpd;
} }
@ -45,4 +49,12 @@ public class OpeningPlatformType extends OpeningFileType {
public void setXmlFpd(PlatformSurfaceAreaDocument.PlatformSurfaceArea xmlFpd) { public void setXmlFpd(PlatformSurfaceAreaDocument.PlatformSurfaceArea xmlFpd) {
this.xmlFpd = xmlFpd; this.xmlFpd = xmlFpd;
} }
public PlatformIdentification getId() {
return id;
}
public void setId(PlatformIdentification id) {
this.id = id;
}
} }

View File

@ -27,6 +27,16 @@ import javax.swing.JComboBox;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JOptionPane; 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 The class is used to provides some useful interfaces
@ -457,4 +467,31 @@ public class Tools {
// //
return hexString.trim(); 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;
}
} }

View File

@ -17,15 +17,15 @@ package org.tianocore.frameworkwizard.common.ui;
import java.util.Vector; import java.util.Vector;
import javax.swing.JPanel;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JPanel;
import org.tianocore.frameworkwizard.common.DataType; import org.tianocore.frameworkwizard.common.DataType;
public class ArchCheckBox extends JPanel { public class ArchCheckBox extends JPanel {
/// ///
/// /// Define class members
/// ///
private static final long serialVersionUID = 4792669775676953990L; private static final long serialVersionUID = 4792669775676953990L;
@ -131,16 +131,6 @@ public class ArchCheckBox extends JPanel {
return jCheckBoxPpc; return jCheckBoxPpc;
} }
/**
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/** /**
* This is the default constructor * This is the default constructor
*/ */

View File

@ -26,6 +26,7 @@ import org.tianocore.PackageDependenciesDocument;
import org.tianocore.PackageSurfaceAreaDocument; import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.OpenFile; import org.tianocore.frameworkwizard.common.OpenFile;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.packaging.PackageIdentification; import org.tianocore.frameworkwizard.packaging.PackageIdentification;
import org.tianocore.frameworkwizard.workspace.WorkspaceTools; import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
@ -35,8 +36,7 @@ public class PackageQuery implements PackageQueryInterface {
PackageIdentification packageId = null; PackageIdentification packageId = null;
try { try {
String path = spdFile.getPath(); String path = spdFile.getPath();
WorkspaceTools wt = new WorkspaceTools(); packageId = Tools.getId(path, OpenFile.openSpdFile(path));
packageId = new PackageIdentification(wt.getId(path, OpenFile.openSpdFile(path)));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -45,6 +45,10 @@ public class ModuleIdentification extends Identification {
this.isLibrary = library; this.isLibrary = library;
} }
public ModuleIdentification(Identification id) {
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
}
public ModuleIdentification(Identification id, boolean library) { public ModuleIdentification(Identification id, boolean library) {
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath()); super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
this.isLibrary = library; this.isLibrary = library;

View File

@ -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("<html>Deselecting a checkbox will restrict this module<br>"
+ "for use with the selected architectures, <br>"
+ "based on the list of items that are checked. <br>"
+ "If all boxes are checked, <br>"
+ "then the module will support all <br>"
+ "current AND FUTURE architectures</html>");
}
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("<html>Modules are either source modules <br>"
+ "which can be compiled or binary <br>"
+ "modules which are linked. <br>"
+ "A module cannot contain both. <br>"
+ "The GUID numbers should be identical <br>"
+ "for a binary and source MSA, <br>"
+ "but the BINARY MSA should have <br>"
+ "a higher version number.</html>");
}
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) {
}
}
}

View File

@ -18,8 +18,10 @@ package org.tianocore.frameworkwizard.module.ui;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent; import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.util.Vector;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -104,6 +106,26 @@ public class MsaHeader extends IInternalFrame {
private JComboBox jComboBoxModuleType = null; 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 jStarLabel1 = null;
private StarLabel jStarLabel2 = null; private StarLabel jStarLabel2 = null;
@ -122,22 +144,133 @@ public class MsaHeader extends IInternalFrame {
private StarLabel jStarLabel12 = null; private StarLabel jStarLabel12 = null;
private StarLabel jStarLabel13 = null;
private StarLabel jStarLabel14 = null;
private StarLabel jStarLabel15 = null;
private JCheckBox jCheckBoxIa32 = null;
private JCheckBox jCheckBoxX64 = 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 MsaHeaderDocument.MsaHeader msaHeader = null;
private ModuleDefinitionsDocument.ModuleDefinitions md = null;
private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;
private JTextField jTextFieldCopyright = null;
private JLabel jLabelURL = null;
private JTextField jTextFieldURL = null;
private JScrollPane jScrollPane = null;
private OpeningModuleType omt = null; private OpeningModuleType omt = null;
private EnumerationData ed = new EnumerationData(); 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 This method initializes jTextFieldBaseName
@ -260,7 +393,7 @@ public class MsaHeader extends IInternalFrame {
jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320, 20)); jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320, 20));
jTextFieldSpecification.setText("FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"); jTextFieldSpecification.setText("FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052");
jTextFieldSpecification.setSize(new java.awt.Dimension(320, 20)); 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.setEditable(false);
jTextFieldSpecification.addFocusListener(this); jTextFieldSpecification.addFocusListener(this);
} }
@ -314,7 +447,7 @@ public class MsaHeader extends IInternalFrame {
jScrollPaneLicense = new JScrollPane(); jScrollPaneLicense = new JScrollPane();
jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneLicense.setSize(new java.awt.Dimension(320, 120)); 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.setViewportView(getJTextAreaLicense());
jScrollPaneLicense.setPreferredSize(new java.awt.Dimension(320, 120)); 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() { private JTextField getJTextFieldURL() {
if (jTextFieldURL == null) { if (jTextFieldURL == null) {
jTextFieldURL = new JTextField(); jTextFieldURL = new JTextField();
jTextFieldURL.setPreferredSize(new java.awt.Dimension(320, 20)); 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.setSize(new java.awt.Dimension(320, 20));
jTextFieldURL.addFocusListener(this); jTextFieldURL.addFocusListener(this);
jTextFieldURL.setToolTipText("A URL for the latest version of the license"); jTextFieldURL.setToolTipText("A URL for the latest version of the license");
@ -409,10 +525,11 @@ public class MsaHeader extends IInternalFrame {
} }
/** /**
* This method initializes jScrollPane This method initializes jScrollPane
*
* @return javax.swing.JScrollPane @return javax.swing.JScrollPane
*/
**/
private JScrollPane getJScrollPane() { private JScrollPane getJScrollPane() {
if (jScrollPane == null) { if (jScrollPane == null) {
jScrollPane = new JScrollPane(); jScrollPane = new JScrollPane();
@ -421,8 +538,80 @@ public class MsaHeader extends IInternalFrame {
return jScrollPane; 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("<html>Modules are either source modules <br>"
+ "which can be compiled or binary <br>"
+ "modules which are linked. <br>"
+ "A module cannot contain both. <br>"
+ "The GUID numbers should be identical <br>"
+ "for a binary and source MSA, <br>"
+ "but the BINARY MSA should have <br>"
+ "a higher version number.</html>");
}
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); msa.setModuleDefinitions(md);
} }
init(msa.getMsaHeader()); init(msa.getMsaHeader());
init(msa.getModuleDefinitions());
this.setVisible(true); this.setVisible(true);
this.setViewMode(false); this.setViewMode(false);
} }
@ -469,14 +659,12 @@ public class MsaHeader extends IInternalFrame {
**/ **/
public void setViewMode(boolean isView) { public void setViewMode(boolean isView) {
//this.jButtonOk.setVisible(false);
//this.jButtonCancel.setVisible(false);
if (isView) { if (isView) {
this.jTextFieldBaseName.setEnabled(!isView); this.jTextFieldBaseName.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView); this.jTextFieldGuid.setEnabled(!isView);
this.jTextFieldVersion.setEnabled(!isView); this.jTextFieldVersion.setEnabled(!isView);
this.jTextAreaLicense.setEnabled(!isView); this.jTextAreaLicense.setEnabled(!isView);
this.jTextFieldCopyright.setEnabled(!isView); this.jTextAreaCopyright.setEnabled(!isView);
this.jTextAreaDescription.setEnabled(!isView); this.jTextAreaDescription.setEnabled(!isView);
this.jTextFieldSpecification.setEnabled(!isView); this.jTextFieldSpecification.setEnabled(!isView);
this.jTextFieldAbstract.setEnabled(!isView); this.jTextFieldAbstract.setEnabled(!isView);
@ -493,7 +681,7 @@ public class MsaHeader extends IInternalFrame {
**/ **/
private void init() { private void init() {
this.setSize(500, 515); this.setSize(500, 515);
this.setPreferredSize(new java.awt.Dimension(490, 520)); this.setPreferredSize(new java.awt.Dimension(490, 615));
this.setContentPane(getJScrollPane()); this.setContentPane(getJScrollPane());
this.setTitle("Module Surface Area Header"); this.setTitle("Module Surface Area Header");
initFrame(); initFrame();
@ -531,7 +719,7 @@ public class MsaHeader extends IInternalFrame {
jTextAreaDescription.setSelectionEnd(0); jTextAreaDescription.setSelectionEnd(0);
} }
if (this.msaHeader.getCopyright() != null) { if (this.msaHeader.getCopyright() != null) {
this.jTextFieldCopyright.setText(this.msaHeader.getCopyright()); this.jTextAreaCopyright.setText(this.msaHeader.getCopyright());
} }
if (this.msaHeader.getLicense() != null) { if (this.msaHeader.getLicense() != null) {
this.jTextAreaLicense.setText(this.msaHeader.getLicense().getStringValue()); 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 This method initializes jContentPane
@ -558,7 +771,7 @@ public class MsaHeader extends IInternalFrame {
jLabelURL = new JLabel(); jLabelURL = new JLabel();
jLabelURL.setText("License URL"); 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)); jLabelURL.setSize(new java.awt.Dimension(140, 20));
jLabelBaseName = new JLabel(); jLabelBaseName = new JLabel();
jLabelBaseName.setText("Module Name"); jLabelBaseName.setText("Module Name");
@ -588,16 +801,26 @@ public class MsaHeader extends IInternalFrame {
jLabelCopyright.setSize(new java.awt.Dimension(140, 20)); jLabelCopyright.setSize(new java.awt.Dimension(140, 20));
jLabelLicense = new JLabel(); jLabelLicense = new JLabel();
jLabelLicense.setText("License"); 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)); 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 = new JLabel();
jLabelSpecification.setText("Specification"); 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)); jLabelSpecification.setSize(new java.awt.Dimension(140, 20));
jContentPane = new JPanel(); jContentPane = new JPanel();
jContentPane.setLayout(null); 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(jLabelBaseName, null);
jContentPane.add(getJTextFieldBaseName(), null); jContentPane.add(getJTextFieldBaseName(), null);
@ -621,7 +844,12 @@ public class MsaHeader extends IInternalFrame {
jContentPane.add(getJComboBoxModuleType(), null); jContentPane.add(getJComboBoxModuleType(), null);
jContentPane.add(jLabelURL, null); jContentPane.add(jLabelURL, null);
jContentPane.add(getJTextFieldURL(), 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 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10)); jStarLabel1.setLocation(new java.awt.Point(0, 10));
jStarLabel2 = new StarLabel(); jStarLabel2 = new StarLabel();
@ -635,11 +863,17 @@ public class MsaHeader extends IInternalFrame {
jStarLabel7 = new StarLabel(); jStarLabel7 = new StarLabel();
jStarLabel7.setLocation(new java.awt.Point(0, 260)); jStarLabel7.setLocation(new java.awt.Point(0, 260));
jStarLabel8 = new StarLabel(); jStarLabel8 = new StarLabel();
jStarLabel8.setLocation(new java.awt.Point(0, 285)); jStarLabel8.setLocation(new java.awt.Point(0, 305));
jStarLabel10 = new StarLabel(); jStarLabel10 = new StarLabel();
jStarLabel10.setLocation(new java.awt.Point(0, 110)); jStarLabel10.setLocation(new java.awt.Point(0, 110));
jStarLabel12 = new StarLabel(); 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(jStarLabel1, null);
jContentPane.add(jStarLabel2, null); jContentPane.add(jStarLabel2, null);
@ -650,6 +884,17 @@ public class MsaHeader extends IInternalFrame {
jContentPane.add(jStarLabel8, null); jContentPane.add(jStarLabel8, null);
jContentPane.add(jStarLabel10, null); jContentPane.add(jStarLabel10, null);
jContentPane.add(jStarLabel12, 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; return jContentPane;
} }
@ -759,7 +1004,7 @@ public class MsaHeader extends IInternalFrame {
// //
// Check Copyright // Check Copyright
// //
if (isEmpty(this.jTextFieldCopyright.getText())) { if (isEmpty(this.jTextAreaCopyright.getText())) {
Log.wrn("Update Msa Header", "Copyright couldn't be empty"); Log.wrn("Update Msa Header", "Copyright couldn't be empty");
//this.jTextFieldCopyright.requestFocus(); //this.jTextFieldCopyright.requestFocus();
return false; return false;
@ -799,28 +1044,9 @@ public class MsaHeader extends IInternalFrame {
**/ **/
public void save() { public void save() {
try { 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()); msaHeader.setSpecification(this.jTextFieldSpecification.getText());
msa.setMsaHeader(msaHeader); msa.setMsaHeader(msaHeader);
msa.setModuleDefinitions(md);
this.omt.setSaved(false); this.omt.setSaved(false);
} catch (Exception e) { } catch (Exception e) {
Log.wrn("Save Module", e.getMessage()); Log.wrn("Save Module", e.getMessage());
@ -835,6 +1061,8 @@ public class MsaHeader extends IInternalFrame {
private void initFrame() { private void initFrame() {
EnumerationData ed = new EnumerationData(); EnumerationData ed = new EnumerationData();
Tools.generateComboBoxByVector(jComboBoxModuleType, ed.getVModuleType()); 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.jTextFieldVersion, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jScrollPaneLicense, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jScrollPaneLicense, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldURL, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jTextFieldURL, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldCopyright, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jScrollPaneCopyright, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jScrollPaneDescription, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jScrollPaneDescription, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldSpecification, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jTextFieldSpecification, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldAbstract, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jTextFieldAbstract, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jComboBoxModuleType, intCurrentWidth, intPreferredWidth); resizeComponentWidth(this.jComboBoxModuleType, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jComboBoxBinaryModule, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldOutputFileBasename, intCurrentWidth, intPreferredWidth);
relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth, relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,
DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON); DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
} }
@ -999,14 +1230,14 @@ public class MsaHeader extends IInternalFrame {
// //
// Check Copyright // Check Copyright
// //
if (arg0.getSource() == this.jTextFieldCopyright) { if (arg0.getSource() == this.jTextAreaCopyright) {
if (isEmpty(this.jTextFieldCopyright.getText())) { if (isEmpty(this.jTextAreaCopyright.getText())) {
Log.wrn("Update Msa Header", "Copyright couldn't be empty"); Log.wrn("Update Msa Header", "Copyright couldn't be empty");
//this.jTextFieldCopyright.requestFocus(); //this.jTextFieldCopyright.requestFocus();
return; return;
} }
if (!this.jTextFieldCopyright.getText().equals(msaHeader.getCopyright())) { if (!this.jTextAreaCopyright.getText().equals(msaHeader.getCopyright())) {
this.msaHeader.setCopyright(this.jTextFieldCopyright.getText()); this.msaHeader.setCopyright(this.jTextAreaCopyright.getText());
} else { } else {
return; 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(); this.save();
} }
private Vector<String> getSelectedItemsVector() {
Vector<String> v = new Vector<String>();
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<String> 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;
}
}
}
}
} }

View File

@ -22,17 +22,13 @@ import java.util.Vector;
import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlException;
import org.tianocore.DbPathAndFilename; import org.tianocore.DbPathAndFilename;
import org.tianocore.FrameworkDatabaseDocument.FrameworkDatabase;
import org.tianocore.IndustryStdIncludesDocument.IndustryStdIncludes; import org.tianocore.IndustryStdIncludesDocument.IndustryStdIncludes;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.MsaFilesDocument.MsaFiles; import org.tianocore.MsaFilesDocument.MsaFiles;
import org.tianocore.MsaHeaderDocument.MsaHeader;
import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea; import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
import org.tianocore.PlatformHeaderDocument.PlatformHeader;
import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
import org.tianocore.SourceFilesDocument.SourceFiles; import org.tianocore.SourceFilesDocument.SourceFiles;
import org.tianocore.SpdHeaderDocument.SpdHeader;
import org.tianocore.frameworkwizard.common.DataType; import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.GlobalData;
import org.tianocore.frameworkwizard.common.Log; import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpenFile; import org.tianocore.frameworkwizard.common.OpenFile;
import org.tianocore.frameworkwizard.common.SaveFile; import org.tianocore.frameworkwizard.common.SaveFile;
@ -48,75 +44,44 @@ import org.tianocore.frameworkwizard.packaging.PackageIdentification;
import org.tianocore.frameworkwizard.platform.PlatformIdentification; import org.tianocore.frameworkwizard.platform.PlatformIdentification;
public class WorkspaceTools { public class WorkspaceTools {
//
// Define class members
//
private FrameworkDatabase fdb = null;
private Vector<ModuleIdentification> vModuleList = new Vector<ModuleIdentification>();
private Vector<PackageIdentification> vPackageList = new Vector<PackageIdentification>();
private Vector<PlatformIdentification> vPlatformList = new Vector<PlatformIdentification>();
/**
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<String> packageList, List<String> platformList, FarHeader far) { public void addFarToDb(List<String> packageList, List<String> platformList, FarHeader far) {
FrameworkDatabase fdb = openFrameworkDb(); //FrameworkDatabase fdb = openFrameworkDb();
for (int i = 0; i < packageList.size(); i++) { for (int i = 0; i < packageList.size(); i++) {
DbPathAndFilename item = DbPathAndFilename.Factory.newInstance(); DbPathAndFilename item = DbPathAndFilename.Factory.newInstance();
item.setFarGuid(far.getGuidValue()); item.setFarGuid(far.getGuidValue());
item.setStringValue(packageList.get(i)); item.setStringValue(packageList.get(i));
fdb.getPackageList().getFilenameList().add(item); GlobalData.fdb.getPackageList().getFilenameList().add(item);
} }
for (int i = 0; i < platformList.size(); i++) { for (int i = 0; i < platformList.size(); i++) {
DbPathAndFilename item = DbPathAndFilename.Factory.newInstance(); DbPathAndFilename item = DbPathAndFilename.Factory.newInstance();
item.setFarGuid(far.getGuidValue()); item.setFarGuid(far.getGuidValue());
item.setStringValue(platformList.get(i)); item.setStringValue(platformList.get(i));
fdb.getPlatformList().getFilenameList().add(item); GlobalData.fdb.getPlatformList().getFilenameList().add(item);
} }
DbPathAndFilename farItem = DbPathAndFilename.Factory.newInstance(); DbPathAndFilename farItem = DbPathAndFilename.Factory.newInstance();
farItem.setFarGuid(far.getGuidValue()); farItem.setFarGuid(far.getGuidValue());
farItem.setStringValue(far.getFarName()); farItem.setStringValue(far.getFarName());
fdb.getFarList().getFilenameList().add(farItem); GlobalData.fdb.getFarList().getFilenameList().add(farItem);
String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();
strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);
try { try {
SaveFile.saveDbFile(strFrameworkDbFilePath, fdb); SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb);
} catch (Exception e) { } catch (Exception e) {
Log.err("Save Database File", e.getMessage()); Log.err("Save Database File", e.getMessage());
} }
} }
public void removeFarFromDb(FarIdentification far) { public void removeFarFromDb(FarIdentification far) {
FrameworkDatabase fdb = openFrameworkDb();
// //
// Remove Packages // Remove Packages
// //
XmlCursor cursor = fdb.getPackageList().newCursor(); XmlCursor cursor = GlobalData.fdb.getPackageList().newCursor();
cursor.toFirstChild(); cursor.toFirstChild();
do { do {
DbPathAndFilename item = (DbPathAndFilename) cursor.getObject(); DbPathAndFilename item = (DbPathAndFilename) cursor.getObject();
@ -130,7 +95,7 @@ public class WorkspaceTools {
// //
// Remove Platforms // Remove Platforms
// //
cursor = fdb.getPlatformList().newCursor(); cursor = GlobalData.fdb.getPlatformList().newCursor();
cursor.toFirstChild(); cursor.toFirstChild();
do { do {
DbPathAndFilename item = (DbPathAndFilename) cursor.getObject(); DbPathAndFilename item = (DbPathAndFilename) cursor.getObject();
@ -142,7 +107,7 @@ public class WorkspaceTools {
// //
// Remove Far // Remove Far
// //
cursor = fdb.getFarList().newCursor(); cursor = GlobalData.fdb.getFarList().newCursor();
cursor.toFirstChild(); cursor.toFirstChild();
do { do {
DbPathAndFilename item = (DbPathAndFilename) cursor.getObject(); DbPathAndFilename item = (DbPathAndFilename) cursor.getObject();
@ -155,21 +120,19 @@ public class WorkspaceTools {
String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();
strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);
try { try {
SaveFile.saveDbFile(strFrameworkDbFilePath, fdb); SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb);
} catch (Exception e) { } catch (Exception e) {
Log.err("Save Database File", e.getMessage()); Log.err("Save Database File", e.getMessage());
} }
} }
public String getPackageFarGuid(Identification packageId) { public String getPackageFarGuid(Identification packageId) {
openFrameworkDb(); for (int index = 0; index < GlobalData.fdb.getPackageList().getFilenameList().size(); index++) {
DbPathAndFilename item = GlobalData.fdb.getPackageList().getFilenameArray(index);
for (int index = 0; index < fdb.getPackageList().getFilenameList().size(); index++) {
DbPathAndFilename item = fdb.getPackageList().getFilenameArray(index);
String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue(); String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue();
File tempFile = new File(path); File tempFile = new File(path);
if (tempFile.getPath().equalsIgnoreCase(packageId.getPath())) { 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) { public String getPlatformFarGuid(Identification platformId) {
openFrameworkDb(); for (int index = 0; index < GlobalData.fdb.getPlatformList().getFilenameList().size(); index++) {
DbPathAndFilename item = GlobalData.fdb.getPlatformList().getFilenameArray(index);
for (int index = 0; index < fdb.getPlatformList().getFilenameList().size(); index++) {
DbPathAndFilename item = fdb.getPlatformList().getFilenameArray(index);
String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue(); String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue();
File tempFile = new File(path); File tempFile = new File(path);
if (tempFile.getPath().equalsIgnoreCase(platformId.getPath())) { 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<String> getAllModulesOfPackage(String path) { public Vector<String> getAllModulesOfPackage(String path) {
Vector<String> modulePath = new Vector<String>(); Vector<String> modulePath = new Vector<String>();
try { PackageIdentification id = new PackageIdentification(null, null, null, path);
MsaFiles files = OpenFile.openSpdFile(path).getMsaFiles(); MsaFiles files = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(id).getMsaFiles();
if (files != null) { if (files != null) {
for (int index = 0; index < files.getFilenameList().size(); index++) { for (int index = 0; index < files.getFilenameList().size(); index++) {
String msaPath = files.getFilenameList().get(index); String msaPath = files.getFilenameList().get(index);
msaPath = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + msaPath; msaPath = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + msaPath;
msaPath = Tools.convertPathToCurrentOsType(msaPath); msaPath = Tools.convertPathToCurrentOsType(msaPath);
modulePath.addElement(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; return modulePath;
} }
@ -236,22 +191,16 @@ public class WorkspaceTools {
**/ **/
public Vector<String> getAllIndustryStdIncludesOfPackage(String path) { public Vector<String> getAllIndustryStdIncludesOfPackage(String path) {
Vector<String> includePath = new Vector<String>(); Vector<String> includePath = new Vector<String>();
try { PackageIdentification id = new PackageIdentification(null, null, null, path);
IndustryStdIncludes files = OpenFile.openSpdFile(path).getIndustryStdIncludes(); IndustryStdIncludes files = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(id)
if (files != null) { .getIndustryStdIncludes();
for (int index = 0; index < files.getIndustryStdHeaderList().size(); index++) { if (files != null) {
String temp = files.getIndustryStdHeaderList().get(index).getIncludeHeader(); for (int index = 0; index < files.getIndustryStdHeaderList().size(); index++) {
temp = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + temp; String temp = files.getIndustryStdHeaderList().get(index).getIncludeHeader();
temp = Tools.convertPathToCurrentOsType(temp); temp = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + temp;
includePath.addElement(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; return includePath;
} }
@ -263,35 +212,14 @@ public class WorkspaceTools {
*/ */
public Vector<PackageIdentification> getAllPackages() { public Vector<PackageIdentification> getAllPackages() {
Identification id = null; return GlobalData.vPackageList;
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;
} }
public Vector<FarIdentification> getAllFars() { public Vector<FarIdentification> getAllFars() {
openFrameworkDb();
Vector<FarIdentification> v = new Vector<FarIdentification>(); Vector<FarIdentification> v = new Vector<FarIdentification>();
for (int index = 0; index < fdb.getFarList().getFilenameList().size(); index++) { for (int index = 0; index < GlobalData.fdb.getFarList().getFilenameList().size(); index++) {
DbPathAndFilename item = fdb.getFarList().getFilenameList().get(index); DbPathAndFilename item = GlobalData.fdb.getFarList().getFilenameList().get(index);
FarIdentification far = new FarIdentification(item.getFarGuid(), item.getMd5Sum(), item.getStringValue()); FarIdentification far = new FarIdentification(item.getFarGuid(), item.getMd5Sum(), item.getStringValue());
v.addElement(far); v.addElement(far);
} }
@ -300,18 +228,18 @@ public class WorkspaceTools {
public Vector<PackageIdentification> getPackagesByFar(FarIdentification far) { public Vector<PackageIdentification> getPackagesByFar(FarIdentification far) {
Identification id = null; Identification id = null;
openFrameworkDb();
Vector<PackageIdentification> v = new Vector<PackageIdentification>(); Vector<PackageIdentification> v = new Vector<PackageIdentification>();
for (int index = 0; index < fdb.getPackageList().getFilenameList().size(); index++) { for (int index = 0; index < GlobalData.fdb.getPackageList().getFilenameList().size(); index++) {
DbPathAndFilename item = fdb.getPackageList().getFilenameArray(index); DbPathAndFilename item = GlobalData.fdb.getPackageList().getFilenameArray(index);
String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue(); String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue();
path = Tools.convertPathToCurrentOsType(path); path = Tools.convertPathToCurrentOsType(path);
if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) { if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {
try { try {
id = getId(path, OpenFile.openSpdFile(path)); id = Tools.getId(path, OpenFile.openSpdFile(path));
v.addElement(new PackageIdentification(id)); v.addElement(new PackageIdentification(id));
} catch (IOException e) { } catch (IOException e) {
Log.err("Open Package Surface Area " + path, e.getMessage()); Log.err("Open Package Surface Area " + path, e.getMessage());
@ -327,17 +255,17 @@ public class WorkspaceTools {
public Vector<PlatformIdentification> getPlatformsByFar(FarIdentification far) { public Vector<PlatformIdentification> getPlatformsByFar(FarIdentification far) {
Identification id = null; Identification id = null;
openFrameworkDb();
Vector<PlatformIdentification> v = new Vector<PlatformIdentification>(); Vector<PlatformIdentification> v = new Vector<PlatformIdentification>();
for (int index = 0; index < fdb.getPlatformList().getFilenameList().size(); index++) { for (int index = 0; index < GlobalData.fdb.getPlatformList().getFilenameList().size(); index++) {
DbPathAndFilename item = fdb.getPlatformList().getFilenameArray(index); DbPathAndFilename item = GlobalData.fdb.getPlatformList().getFilenameArray(index);
String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue(); String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue();
path = Tools.convertPathToCurrentOsType(path); path = Tools.convertPathToCurrentOsType(path);
if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) { if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {
try { try {
id = getId(path, OpenFile.openFpdFile(path)); id = Tools.getId(path, OpenFile.openFpdFile(path));
v.addElement(new PlatformIdentification(id)); v.addElement(new PlatformIdentification(id));
} catch (IOException e) { } catch (IOException e) {
Log.err("Open Platform Surface Area " + path, e.getMessage()); Log.err("Open Platform Surface Area " + path, e.getMessage());
@ -361,25 +289,16 @@ public class WorkspaceTools {
public Vector<ModuleIdentification> getAllModules(PackageIdentification pid) { public Vector<ModuleIdentification> getAllModules(PackageIdentification pid) {
Vector<ModuleIdentification> v = new Vector<ModuleIdentification>(); Vector<ModuleIdentification> v = new Vector<ModuleIdentification>();
Vector<String> modulePaths = this.getAllModulesOfPackage(pid.getPath()); Vector<String> modulePaths = this.getAllModulesOfPackage(pid.getPath());
Identification id = null;
String modulePath = null; String modulePath = null;
for (int index = 0; index < modulePaths.size(); index++) { for (int index = 0; index < modulePaths.size(); index++) {
try { modulePath = modulePaths.get(index);
modulePath = modulePaths.get(index); ModuleIdentification id = GlobalData.openingModuleList.getIdByPath(modulePath);
id = getId(modulePath, OpenFile.openMsaFile(modulePath));
} catch (IOException e) { v.addElement(id);
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));
} }
Sort.sortModules(v, DataType.SORT_TYPE_ASCENDING); Sort.sortModules(v, DataType.SORT_TYPE_ASCENDING);
return v; return v;
} }
/** /**
@ -389,39 +308,7 @@ public class WorkspaceTools {
*/ */
public Vector<ModuleIdentification> getAllModules() { public Vector<ModuleIdentification> getAllModules() {
vModuleList.removeAllElements(); return GlobalData.vModuleList;
//
// First get all packages
//
getAllPackages();
Vector<String> modulePaths = new Vector<String>();
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;
} }
/** /**
@ -431,28 +318,7 @@ public class WorkspaceTools {
*/ */
public Vector<PlatformIdentification> getAllPlatforms() { public Vector<PlatformIdentification> getAllPlatforms() {
Identification id = null; return GlobalData.vPlatformList;
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;
} }
/** /**
@ -552,53 +418,28 @@ public class WorkspaceTools {
} }
public Vector<String> getAllLibraryClassDefinitionsFromWorkspace() { public Vector<String> getAllLibraryClassDefinitionsFromWorkspace() {
//
// First get all packages
//
this.getAllPackages();
Vector<String> vector = new Vector<String>(); Vector<String> vector = new Vector<String>();
for (int index = 0; index < this.vPackageList.size(); index++) { for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
try { Vector<String> v = getAllLibraryClassDefinitionsFromPackage(GlobalData.openingPackageList
Vector<String> v = getAllLibraryClassDefinitionsFromPackage(OpenFile .getPackageSurfaceAreaFromId(GlobalData.vPackageList
.openSpdFile(vPackageList .get(index)));
.get(index) if (v != null && v.size() > 0) {
.getPath())); vector.addAll(v);
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());
} }
} }
Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
return vector; return vector;
} }
public Vector<String> getAllProtocolDeclarationsFromWorkspace() { public Vector<String> getAllProtocolDeclarationsFromWorkspace() {
//
// First get all packages
//
this.getAllPackages();
Vector<String> vector = new Vector<String>(); Vector<String> vector = new Vector<String>();
for (int index = 0; index < this.vPackageList.size(); index++) { for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
try { Vector<String> v = getAllProtocolDeclarationsFromPackage(GlobalData.openingPackageList
Vector<String> v = getAllProtocolDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index) .getPackageSurfaceAreaFromId(GlobalData.vPackageList
.getPath())); .get(index)));
if (v != null && v.size() > 0) { if (v != null && v.size() > 0) {
vector.addAll(v); 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());
} }
} }
Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
@ -606,25 +447,13 @@ public class WorkspaceTools {
} }
public Vector<String> getAllPpiDeclarationsFromWorkspace() { public Vector<String> getAllPpiDeclarationsFromWorkspace() {
//
// First get all packages
//
this.getAllPackages();
Vector<String> vector = new Vector<String>(); Vector<String> vector = new Vector<String>();
for (int index = 0; index < this.vPackageList.size(); index++) { for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
try { Vector<String> v = getAllPpiDeclarationsFromPackage(GlobalData.openingPackageList
Vector<String> v = getAllPpiDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index) .getPackageSurfaceAreaFromId(GlobalData.vPackageList
.getPath())); .get(index)));
if (v != null && v.size() > 0) { if (v != null && v.size() > 0) {
vector.addAll(v); 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());
} }
} }
Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
@ -632,51 +461,30 @@ public class WorkspaceTools {
} }
public Vector<String> getAllGuidDeclarationsFromWorkspace() { public Vector<String> getAllGuidDeclarationsFromWorkspace() {
//
// First get all packages
//
this.getAllPackages();
Vector<String> vector = new Vector<String>(); Vector<String> vector = new Vector<String>();
for (int index = 0; index < this.vPackageList.size(); index++) { for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
try { Vector<String> v = getAllGuidDeclarationsFromPackage(GlobalData.openingPackageList
Vector<String> v = getAllGuidDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index) .getPackageSurfaceAreaFromId(GlobalData.vPackageList
.getPath())); .get(index)));
if (v != null && v.size() > 0) { if (v != null && v.size() > 0) {
vector.addAll(v); 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());
} }
} }
Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
return vector; return vector;
} }
public PcdVector getAllPcdDeclarationsFromWorkspace() { public PcdVector getAllPcdDeclarationsFromWorkspace() {
//
// First get all packages
//
this.getAllPackages();
PcdVector vector = new PcdVector(); PcdVector vector = new PcdVector();
for (int index = 0; index < this.vPackageList.size(); index++) { for (int index = 0; index < GlobalData.openingPackageList.size(); index++) {
try { PcdVector v = getAllPcdDeclarationsFromPackage(GlobalData.openingPackageList
PcdVector v = getAllPcdDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index).getPath())); .getPackageSurfaceAreaFromId(GlobalData.vPackageList
if (v != null && v.size() > 0) { .get(index)));
vector.addAll(v); 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());
} }
} }
Sort.sortPcds(vector, DataType.SORT_TYPE_ASCENDING); Sort.sortPcds(vector, DataType.SORT_TYPE_ASCENDING);
return vector; return vector;
@ -690,7 +498,6 @@ public class WorkspaceTools {
**/ **/
public PackageIdentification getPackageIdByModuleId(Identification id) { public PackageIdentification getPackageIdByModuleId(Identification id) {
getAllPackages();
Vector<String> modulePaths = new Vector<String>(); Vector<String> modulePaths = new Vector<String>();
Identification mid = null; Identification mid = null;
String packagePath = null; String packagePath = null;
@ -699,59 +506,25 @@ public class WorkspaceTools {
// //
// For each package, get all modules list // For each package, get all modules list
// //
for (int indexI = 0; indexI < vPackageList.size(); indexI++) { for (int indexI = 0; indexI < GlobalData.vPackageList.size(); indexI++) {
packagePath = vPackageList.elementAt(indexI).getPath(); packagePath = GlobalData.vPackageList.elementAt(indexI).getPath();
modulePaths = this.getAllModulesOfPackage(packagePath); modulePaths = this.getAllModulesOfPackage(packagePath);
for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) { for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) {
modulePath = modulePaths.get(indexJ); modulePath = modulePaths.get(indexJ);
try { mid = GlobalData.openingModuleList.getIdByPath(modulePath);
mid = getId(modulePath, OpenFile.openMsaFile(modulePath)); //
// // Check id
// Check id //
// if (mid.equals(id)) {
if (mid.equals(id)) { return GlobalData.vPackageList.elementAt(indexI);
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());
} }
} }
} }
return null; 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 Add module information to package surface area
@ -790,14 +563,15 @@ public class WorkspaceTools {
public void addPackageToDatabase(PackageIdentification id) throws Exception { public void addPackageToDatabase(PackageIdentification id) throws Exception {
String path = id.getPath(); String path = id.getPath();
path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace()); path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace());
this.openFrameworkDb();
DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance(); DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance();
filename.setStringValue(path); filename.setStringValue(path);
fdb.getPackageList().addNewFilename(); GlobalData.fdb.getPackageList().addNewFilename();
fdb.getPackageList().setFilenameArray(fdb.getPackageList().sizeOfFilenameArray() - 1, filename); GlobalData.fdb.getPackageList().setFilenameArray(GlobalData.fdb.getPackageList().sizeOfFilenameArray() - 1,
filename);
String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();
strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); 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 { public void addPlatformToDatabase(PlatformIdentification id) throws Exception {
String path = id.getPath(); String path = id.getPath();
path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace()); path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace());
this.openFrameworkDb();
DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance(); DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance();
filename.setStringValue(path); filename.setStringValue(path);
fdb.getPlatformList().addNewFilename(); GlobalData.fdb.getPlatformList().addNewFilename();
fdb.getPlatformList().setFilenameArray(fdb.getPlatformList().sizeOfFilenameArray() - 1, filename); GlobalData.fdb.getPlatformList().setFilenameArray(GlobalData.fdb.getPlatformList().sizeOfFilenameArray() - 1,
filename);
String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();
strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);
SaveFile.saveDbFile(strFrameworkDbFilePath, fdb); SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb);
} }
/** /**
@ -830,11 +605,13 @@ public class WorkspaceTools {
@throws Exception @throws Exception
**/ **/
public Vector<String> getAllModuleFilesPath(String path) throws IOException, XmlException, Exception { public Vector<String> getAllFilesPathOfModule(String path) {
Vector<String> v = new Vector<String>(); Vector<String> v = new Vector<String>();
path = Tools.convertPathToCurrentOsType(path); path = Tools.convertPathToCurrentOsType(path);
v.addElement(path); v.addElement(path);
ModuleSurfaceArea msa = OpenFile.openMsaFile(path); ModuleSurfaceArea msa = GlobalData.openingModuleList
.getModuleSurfaceAreaFromId(GlobalData.openingModuleList
.getIdByPath(path));
if (msa != null) { if (msa != null) {
// //
// Get all files' path of a module // Get all files' path of a module
@ -862,7 +639,7 @@ public class WorkspaceTools {
@throws Exception @throws Exception
**/ **/
public Vector<String> getAllPakcageFilesPath(String path) throws IOException, XmlException, Exception { public Vector<String> getAllFilesPathOfPakcage(String path) {
Vector<String> v = new Vector<String>(); Vector<String> v = new Vector<String>();
path = Tools.convertPathToCurrentOsType(path); path = Tools.convertPathToCurrentOsType(path);
// //
@ -885,7 +662,7 @@ public class WorkspaceTools {
f1 = new Vector<String>(); f1 = new Vector<String>();
f1 = getAllModulesOfPackage(path); f1 = getAllModulesOfPackage(path);
for (int indexI = 0; indexI < f1.size(); indexI++) { for (int indexI = 0; indexI < f1.size(); indexI++) {
Vector<String> f2 = getAllModuleFilesPath(f1.get(indexI)); Vector<String> f2 = getAllFilesPathOfModule(f1.get(indexI));
for (int indexJ = 0; indexJ < f2.size(); indexJ++) { for (int indexJ = 0; indexJ < f2.size(); indexJ++) {
v.addElement(f2.get(indexJ)); v.addElement(f2.get(indexJ));
} }