From 2003a22e9463226869633edb92584cd8a1bc0462 Mon Sep 17 00:00:00 2001 From: hche10x Date: Fri, 21 Jul 2006 02:56:30 +0000 Subject: [PATCH] 1. Enhance Source Files selection in msa: a. Can select multiple files one time b. Totally same file can be added once 2. Separate sort functions from Tools.java to Sort.java 3. Fix a bug of new function: to create directory first if the file's directory doesn't exist 4. Adjust some file's coding style git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1058 6f19259b-4bc3-4df7-8a09-765794883524 --- .../org/tianocore/frameworkwizard/About.java | 30 +-- .../common/EnumerationData.java | 4 +- .../Identifications/Identification.java | 108 ++++---- .../frameworkwizard/common/SaveFile.java | 24 +- .../frameworkwizard/common/Sort.java | 239 ++++++++++++++++++ .../frameworkwizard/common/Tools.java | 193 -------------- .../Identifications/PcdCoded/PcdVector.java | 6 +- .../SourceFilesIdentification.java | 17 +- .../SourceFiles/SourceFilesVector.java | 4 +- .../module/ui/ModuleSourceFiles.java | 6 +- .../frameworkwizard/module/ui/MsaHeader.java | 71 ++++-- .../module/ui/dialog/SourceFilesDlg.java | 38 ++- .../workspace/WorkspaceTools.java | 29 ++- 13 files changed, 444 insertions(+), 325 deletions(-) create mode 100644 Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Sort.java diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/About.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/About.java index 8a2c682ca0..fe97d8ac68 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/About.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/About.java @@ -63,7 +63,7 @@ public class About extends IDialog { private JButton getJButtonOK() { if (jButtonOK == null) { jButtonOK = new JButton(); - jButtonOK.setBounds(new java.awt.Rectangle(115,200,90,20)); + jButtonOK.setBounds(new java.awt.Rectangle(115, 200, 90, 20)); jButtonOK.setText("OK"); jButtonOK.addActionListener(this); } @@ -83,15 +83,15 @@ public class About extends IDialog { super(); init(); } - + /** - This is the default constructor - - **/ - public About(IFrame parentFrame, boolean modal) { - super(parentFrame, modal); - init(); - } + This is the default constructor + + **/ + public About(IFrame parentFrame, boolean modal) { + super(parentFrame, modal); + init(); + } /** This method initializes this @@ -114,25 +114,25 @@ public class About extends IDialog { private JPanel getJContentPane() { if (jContentPane == null) { jLabelImage = new JLabel(); - jLabelImage.setBounds(new java.awt.Rectangle(63,20,193,58)); + jLabelImage.setBounds(new java.awt.Rectangle(63, 20, 193, 58)); jLabelImage.setIcon(new ImageIcon(getClass().getResource("/resources/images/logo.gif"))); - + jLabel2 = new JLabel(); - jLabel2.setBounds(new java.awt.Rectangle(25,160,270,20)); + jLabel2.setBounds(new java.awt.Rectangle(25, 160, 270, 20)); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("All rights reserved"); jLabel1 = new JLabel(); - jLabel1.setBounds(new java.awt.Rectangle(25,130,270,20)); + jLabel1.setBounds(new java.awt.Rectangle(25, 130, 270, 20)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText("Copyright (c) 2006, Intel Corporation"); jLabel = new JLabel(); jLabel.setToolTipText(""); - jLabel.setBounds(new java.awt.Rectangle(25,90,270,20)); + jLabel.setBounds(new java.awt.Rectangle(25, 90, 270, 20)); jLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel.setText(DataType.PROJECT_NAME + " " + DataType.PROJECT_VERSION); jContentPane = new JPanel(); jContentPane.setLayout(null); - jContentPane.setSize(new java.awt.Dimension(320,235)); + jContentPane.setSize(new java.awt.Dimension(320, 235)); jContentPane.add(jLabel, null); jContentPane.add(jLabel1, null); jContentPane.add(jLabel2, null); diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java index a03dfac775..bf050e0f64 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java @@ -307,7 +307,7 @@ public class EnumerationData { vModuleType.addElement("UEFI_DRIVER"); vModuleType.addElement("UEFI_APPLICATION"); vModuleType.addElement("USER_DEFINED"); - Tools.sortVectorString(vModuleType, DataType.SORT_TYPE_ASCENDING); + Sort.sortVectorString(vModuleType, DataType.SORT_TYPE_ASCENDING); } // private void initComponentType() { @@ -363,7 +363,7 @@ public class EnumerationData { vFrameworkModuleTypes.addElement("UEFI_DRIVER"); vFrameworkModuleTypes.addElement("UEFI_APPLICATION"); vFrameworkModuleTypes.addElement("USER_DEFINED"); - Tools.sortVectorString(vFrameworkModuleTypes, DataType.SORT_TYPE_ASCENDING); + Sort.sortVectorString(vFrameworkModuleTypes, DataType.SORT_TYPE_ASCENDING); } private void initLibClassDef() { diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/Identification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/Identification.java index 4affb03afe..bc296474e6 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/Identification.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/Identification.java @@ -17,69 +17,65 @@ package org.tianocore.frameworkwizard.common.Identifications; public class Identification { - /// - /// Define class members - /// + /// + /// Define class members + /// private String name; - + private String guid; - + private String version; - + private String path; - + public Identification(String name, String guid, String version) { this.name = name; this.guid = guid; this.version = version; } - + public Identification() { - + } - + public Identification(String name, String guid, String version, String path) { - this.name = name; + this.name = name; this.guid = guid; this.version = version; this.path = path; } - + public boolean equals(Object obj) { - if (obj instanceof Identification) { - Identification id = (Identification)obj; - if (path.equals(id.path)) { - //if ( name.equals(id.name) && guid.equals(id.guid) && version.equals(id.version)) { - return true; - } - return false; - } - else { - return super.equals(obj); - } - } - + if (obj instanceof Identification) { + Identification id = (Identification) obj; + if (path.equals(id.path)) { + //if ( name.equals(id.name) && guid.equals(id.guid) && version.equals(id.version)) { + return true; + } + return false; + } else { + return super.equals(obj); + } + } + public boolean equalsWithGuid(Object obj) { - if (obj instanceof Identification) { - Identification id = (Identification)obj; - if ( guid.equalsIgnoreCase(id.guid)) { - if (version == null || id.version == null) { - return true; - } - else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){ - return true; - } - else if (version.equalsIgnoreCase(id.version)) { - return true; - } - } - return false; - } - else { - return super.equals(obj); - } - } - + if (obj instanceof Identification) { + Identification id = (Identification) obj; + if (guid.equalsIgnoreCase(id.guid)) { + if (version == null || id.version == null) { + return true; + } else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")) { + return true; + } else if (version.equalsIgnoreCase(id.version)) { + return true; + } + } + return false; + } else { + return super.equals(obj); + } + } + public void setName(String name) { this.name = name; } @@ -91,10 +87,10 @@ public class Identification { public void setVersion(String version) { this.version = version; } - - public void setPath(String path) { - this.path = path; - } + + public void setPath(String path) { + this.path = path; + } public String getGuid() { return guid; @@ -108,11 +104,11 @@ public class Identification { return version; } - public String getPath() { - return path; - } - - public int hashCode(){ - return guid.toLowerCase().hashCode(); - } + public String getPath() { + return path; + } + + public int hashCode() { + return guid.toLowerCase().hashCode(); + } } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java index 5d5ab9fd2b..e28252239f 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java @@ -36,8 +36,13 @@ public class SaveFile { **/ public static void main(String[] args) { - // TODO Auto-generated method stub - + + } + + private static void createDirectory(String path) throws Exception { + File f = new File(path); + path = f.getParent(); + FileOperation.newFolder(path); } /** @@ -45,6 +50,11 @@ public class SaveFile { **/ public static void saveMsaFile(String path, ModuleSurfaceArea msa) throws Exception { + // + // Create the file's directory first + // + createDirectory(path); + // // Remove all empty top level elements // @@ -225,6 +235,11 @@ public class SaveFile { **/ public static void saveSpdFile(String path, PackageSurfaceArea spd) throws Exception { + // + // Create the file's directory first + // + createDirectory(path); + PackageSurfaceAreaDocument spdDoc = PackageSurfaceAreaDocument.Factory.newInstance(); File f = new File(path); @@ -254,6 +269,11 @@ public class SaveFile { **/ public static void saveFpdFile(String path, PlatformSurfaceArea fpd) throws Exception { + // + // Create the file's directory first + // + createDirectory(path); + PlatformSurfaceAreaDocument fpdDoc = PlatformSurfaceAreaDocument.Factory.newInstance(); File f = new File(path); diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Sort.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Sort.java new file mode 100644 index 0000000000..88fe64e4d9 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Sort.java @@ -0,0 +1,239 @@ +/** @file + + The file is used to provide all kinds of sorting method + + 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.util.Vector; + +import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; +import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdIdentification; +import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdVector; +import org.tianocore.frameworkwizard.packaging.PackageIdentification; +import org.tianocore.frameworkwizard.platform.PlatformIdentification; + +public class Sort { + + /** + Sort all elements in the vector as the specific sort type + + @param v The vector need to be sorted + @param mode Sort type DataType.Sort_Type_Ascendin and DataType.Sort_Type_Descending + + **/ + public static void sortVectorString(Vector v, int mode) { + if (v != null) { + for (int indexI = 0; indexI < v.size(); indexI++) { + for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { + if ((v.get(indexJ).compareTo(v.get(indexI)) < 0 && mode == DataType.SORT_TYPE_ASCENDING) + || (v.get(indexI).compareTo(v.get(indexJ)) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { + String temp = v.get(indexI); + v.setElementAt(v.get(indexJ), indexI); + v.setElementAt(temp, indexJ); + } + } + } + } + } + + /** + Sort all elements of vector and return sorted sequence + + @param v The vector need to be sorted + @param mode Sort type DataType.Sort_Type_Ascendin and DataType.Sort_Type_Descending + @return Vector The sorted sequence + + **/ + public static Vector getVectorSortSequence(Vector v, int mode) { + Vector vSequence = new Vector(); + // + // Init sequence + // + if (v != null) { + for (int index = 0; index < v.size(); index++) { + vSequence.addElement(index); + } + } + + // + // sort and get new sequence + // + for (int indexI = 0; indexI < v.size(); indexI++) { + for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { + if ((v.get(indexJ).compareTo(v.get(indexI)) < 0 && mode == DataType.SORT_TYPE_ASCENDING) + || (v.get(indexI).compareTo(v.get(indexJ)) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { + // + // Swap strings + // + String tempStr = v.get(indexI); + v.setElementAt(v.get(indexJ), indexI); + v.setElementAt(tempStr, indexJ); + + // + // Swap sequences + // + int tempInt = vSequence.get(indexI); + vSequence.setElementAt(vSequence.get(indexJ), indexI); + vSequence.setElementAt(tempInt, indexJ); + } + } + } + + return vSequence; + } + + /** + Sort all elements of vector as input sequence + + @param v The vector need to be sorted + @param vSequence The sort sequence should be followed + + **/ + public static void sortVectorString(Vector v, Vector vSequence) { + if (v != null && vSequence != null && v.size() == vSequence.size()) { + Vector tempV = new Vector(); + for (int index = 0; index < v.size(); index++) { + tempV.addElement(v.get(index)); + } + for (int index = 0; index < v.size(); index++) { + v.setElementAt(tempV.get(vSequence.get(index)), index); + } + } + } + + /** + Sort all modules + + @param v + @param mode + + **/ + public static void sortModules(Vector v, int mode) { + if (v != null) { + // + // sort by name + // + for (int indexI = 0; indexI < v.size(); indexI++) { + for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { + if ((v.get(indexJ).getName().compareTo(v.get(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING) + || (v.get(indexI).getName().compareTo(v.get(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { + ModuleIdentification temp = v.get(indexI); + v.setElementAt(v.get(indexJ), indexI); + v.setElementAt(temp, indexJ); + } + } + } + } + } + + /** + Sort all packages + + @param v + @param mode + + **/ + public static void sortPackages(Vector v, int mode) { + if (v != null) { + // + // sort by name + // + for (int indexI = 0; indexI < v.size(); indexI++) { + for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { + if ((v.get(indexJ).getName().compareTo(v.get(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING) + || (v.get(indexI).getName().compareTo(v.get(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { + PackageIdentification temp = v.get(indexI); + v.setElementAt(v.get(indexJ), indexI); + v.setElementAt(temp, indexJ); + } + } + } + } + } + + /** + Sort all platforms + + @param v + @param mode + + **/ + public static void sortPlatforms(Vector v, int mode) { + if (v != null) { + // + // sort by name + // + for (int indexI = 0; indexI < v.size(); indexI++) { + for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { + if ((v.get(indexJ).getName().compareTo(v.get(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING) + || (v.get(indexI).getName().compareTo(v.get(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { + PlatformIdentification temp = v.get(indexI); + v.setElementAt(v.get(indexJ), indexI); + v.setElementAt(temp, indexJ); + } + } + } + } + } + + /** + Sort all pcd entries + + @param v + @param mode + + **/ + public static void sortPcds(PcdVector v, int mode) { + if (v != null) { + // + // sort by name + // + for (int indexI = 0; indexI < v.size(); indexI++) { + for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { + if ((v.getPcd(indexJ).getName().compareTo(v.getPcd(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING) + || (v.getPcd(indexI).getName().compareTo(v.getPcd(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { + PcdIdentification temp = v.getPcd(indexI); + v.setPcd(v.getPcd(indexJ), indexI); + v.setPcd(temp, indexJ); + } + } + } + } + } + + /** + Sort all objects of a vector based on the object's "toString" + + @param v + @param mode + + **/ + public static void sortObjectVector(Vector v, int mode) { + if (v != null) { + // + // sort by name + // + for (int indexI = 0; indexI < v.size(); indexI++) { + for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { + if ((v.get(indexJ).toString().compareTo(v.get(indexI).toString()) < 0 && mode == DataType.SORT_TYPE_ASCENDING) + || (v.get(indexI).toString().compareTo(v.get(indexJ).toString()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { + Object temp = v.get(indexI); + v.setElementAt(v.get(indexJ), indexI); + v.setElementAt(temp, indexJ); + } + } + } + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java index 0bfca453cd..26604d0d39 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java @@ -27,12 +27,6 @@ import javax.swing.JComboBox; import javax.swing.JList; import javax.swing.JOptionPane; -import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; -import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdIdentification; -import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdVector; -import org.tianocore.frameworkwizard.packaging.PackageIdentification; -import org.tianocore.frameworkwizard.platform.PlatformIdentification; - /** The class is used to provides some useful interfaces @@ -342,191 +336,4 @@ public class Tools { } return arg0; } - - /** - Sort all elements in the vector as the specific sort type - - @param v The vector need to be sorted - @param mode Sort type DataType.Sort_Type_Ascendin and DataType.Sort_Type_Descending - - **/ - public static void sortVectorString(Vector v, int mode) { - if (v != null) { - for (int indexI = 0; indexI < v.size(); indexI++) { - for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { - if ((v.get(indexJ).compareTo(v.get(indexI)) < 0 && mode == DataType.SORT_TYPE_ASCENDING) - || (v.get(indexI).compareTo(v.get(indexJ)) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { - String temp = v.get(indexI); - v.setElementAt(v.get(indexJ), indexI); - v.setElementAt(temp, indexJ); - } - } - } - } - } - - /** - Sort all elements of vector and return sorted sequence - - @param v The vector need to be sorted - @param mode Sort type DataType.Sort_Type_Ascendin and DataType.Sort_Type_Descending - @return Vector The sorted sequence - - **/ - public static Vector getVectorSortSequence(Vector v, int mode) { - Vector vSequence = new Vector(); - // - // Init sequence - // - if (v != null) { - for (int index = 0; index < v.size(); index++) { - vSequence.addElement(index); - } - } - - // - // sort and get new sequence - // - for (int indexI = 0; indexI < v.size(); indexI++) { - for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { - if ((v.get(indexJ).compareTo(v.get(indexI)) < 0 && mode == DataType.SORT_TYPE_ASCENDING) - || (v.get(indexI).compareTo(v.get(indexJ)) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { - // - // Swap strings - // - String tempStr = v.get(indexI); - v.setElementAt(v.get(indexJ), indexI); - v.setElementAt(tempStr, indexJ); - - // - // Swap sequences - // - int tempInt = vSequence.get(indexI); - vSequence.setElementAt(vSequence.get(indexJ), indexI); - vSequence.setElementAt(tempInt, indexJ); - } - } - } - - return vSequence; - } - - /** - Sort all elements of vector as input sequence - - @param v The vector need to be sorted - @param vSequence The sort sequence should be followed - - **/ - public static void sortVectorString(Vector v, Vector vSequence) { - if (v != null && vSequence != null && v.size() == vSequence.size()) { - Vector tempV = new Vector(); - for (int index = 0; index < v.size(); index++) { - tempV.addElement(v.get(index)); - } - for (int index = 0; index < v.size(); index++) { - v.setElementAt(tempV.get(vSequence.get(index)), index); - } - } - } - - /** - Sort all modules - - @param v - @param mode - - **/ - public static void sortModules(Vector v, int mode) { - if (v != null) { - // - // sort by name - // - for (int indexI = 0; indexI < v.size(); indexI++) { - for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { - if ((v.get(indexJ).getName().compareTo(v.get(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING) - || (v.get(indexI).getName().compareTo(v.get(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { - ModuleIdentification temp = v.get(indexI); - v.setElementAt(v.get(indexJ), indexI); - v.setElementAt(temp, indexJ); - } - } - } - } - } - - /** - Sort all packages - - @param v - @param mode - - **/ - public static void sortPackages(Vector v, int mode) { - if (v != null) { - // - // sort by name - // - for (int indexI = 0; indexI < v.size(); indexI++) { - for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { - if ((v.get(indexJ).getName().compareTo(v.get(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING) - || (v.get(indexI).getName().compareTo(v.get(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { - PackageIdentification temp = v.get(indexI); - v.setElementAt(v.get(indexJ), indexI); - v.setElementAt(temp, indexJ); - } - } - } - } - } - - /** - Sort all platforms - - @param v - @param mode - - **/ - public static void sortPlatforms(Vector v, int mode) { - if (v != null) { - // - // sort by name - // - for (int indexI = 0; indexI < v.size(); indexI++) { - for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { - if ((v.get(indexJ).getName().compareTo(v.get(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING) - || (v.get(indexI).getName().compareTo(v.get(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { - PlatformIdentification temp = v.get(indexI); - v.setElementAt(v.get(indexJ), indexI); - v.setElementAt(temp, indexJ); - } - } - } - } - } - - /** - Sort all pcd entries - - @param v - @param mode - - **/ - public static void sortPcds(PcdVector v, int mode) { - if (v != null) { - // - // sort by name - // - for (int indexI = 0; indexI < v.size(); indexI++) { - for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) { - if ((v.getPcd(indexJ).getName().compareTo(v.getPcd(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING) - || (v.getPcd(indexI).getName().compareTo(v.getPcd(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) { - PcdIdentification temp = v.getPcd(indexI); - v.setPcd(v.getPcd(indexJ), indexI); - v.setPcd(temp, indexJ); - } - } - } - } - } } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PcdCoded/PcdVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PcdCoded/PcdVector.java index 5834744bdc..dd2832e778 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PcdCoded/PcdVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/PcdCoded/PcdVector.java @@ -17,9 +17,9 @@ package org.tianocore.frameworkwizard.module.Identifications.PcdCoded; import java.util.Vector; public class PcdVector { - + private Vector vPcd = new Vector(); - + public int findPcd(PcdIdentification sfi) { for (int index = 0; index < vPcd.size(); index++) { if (vPcd.elementAt(index).equals(sfi)) { @@ -86,7 +86,7 @@ public class PcdVector { public int size() { return this.vPcd.size(); } - + public void addAll(PcdVector v) { if (v != null) { for (int index = 0; index < v.size(); index++) { diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesIdentification.java index 31e9aec835..02a9d7faf4 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesIdentification.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesIdentification.java @@ -21,17 +21,17 @@ public class SourceFilesIdentification { private String filename = null; private String tagName = null; - + private String toolCode = null; - + private String toolChainFamily = null; - + private Vector supArchList = null; private String featureFlag = null; - public SourceFilesIdentification(String strFilename, String strTagName, String strToolCode, String strToolChainFamily, - String strFeatureFlag, Vector arch) { + public SourceFilesIdentification(String strFilename, String strTagName, String strToolCode, + String strToolChainFamily, String strFeatureFlag, Vector arch) { this.filename = (strFilename == null ? "" : strFilename); this.tagName = (strTagName == null ? "" : strTagName); this.toolCode = (strToolCode == null ? "" : strToolCode); @@ -87,9 +87,12 @@ public class SourceFilesIdentification { public void setToolCode(String toolCode) { this.toolCode = toolCode; } - + public boolean equals(SourceFilesIdentification sfid) { - if (this.filename.equals(sfid.filename)) { + if (this.filename.equals(sfid.filename) && this.tagName.equals(sfid.tagName) + && this.toolCode.equals(sfid.toolCode) && this.toolChainFamily.equals(sfid.toolChainFamily) + && this.featureFlag.equals(sfid.featureFlag) + && this.supArchList.toString().equals(sfid.supArchList.toString())) { return true; } return false; diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesVector.java index 3e6e98dac3..c08ae21166 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesVector.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/SourceFiles/SourceFilesVector.java @@ -47,7 +47,9 @@ public class SourceFilesVector { } public void addSourceFiles(SourceFilesIdentification sfi) { - vSourceFiles.addElement(sfi); + if (findSourceFiles(sfi) == -1) { + vSourceFiles.addElement(sfi); + } } public void setSourceFiles(SourceFilesIdentification sfi, int index) { diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java index 7dd7d32e3a..eab29befa3 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java @@ -348,9 +348,11 @@ public class ModuleSourceFiles extends IInternalFrame { int result = sfd.showDialog(); if (result == DataType.RETURN_TYPE_OK) { if (index == -1) { - this.vSourceFiles.addSourceFiles(sfd.getSfid()); + for (int indexI = 0; indexI < sfd.getSfid().length; indexI++) { + this.vSourceFiles.addSourceFiles(sfd.getSfid()[indexI]); + } } else { - this.vSourceFiles.setSourceFiles(sfd.getSfid(), index); + this.vSourceFiles.setSourceFiles(sfd.getSfid()[0], index); } this.showTable(); this.save(); diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java index c529bc0207..295cde4676 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java @@ -135,7 +135,7 @@ public class MsaHeader extends IInternalFrame { private JScrollPane jScrollPane = null; private OpeningModuleType omt = null; - + private EnumerationData ed = new EnumerationData(); /** @@ -221,6 +221,9 @@ public class MsaHeader extends IInternalFrame { jTextAreaLicense.setText(""); jTextAreaLicense.setLineWrap(true); jTextAreaLicense.addFocusListener(this); + jTextAreaLicense.setWrapStyleWord(true); + jTextAreaLicense.setSelectionStart(0); + jTextAreaLicense.setSelectionEnd(0); jTextAreaLicense.setToolTipText("The License for this file"); } return jTextAreaLicense; @@ -238,6 +241,7 @@ public class MsaHeader extends IInternalFrame { jTextAreaDescription.setLineWrap(true); jTextAreaDescription.addFocusListener(this); jTextAreaDescription.setToolTipText("A verbose description of the module"); + jTextAreaDescription.setWrapStyleWord(true); jTextAreaDescription.setSelectionStart(0); jTextAreaDescription.setSelectionEnd(0); } @@ -441,12 +445,13 @@ public class MsaHeader extends IInternalFrame { super(); this.omt = inMsa; this.msa = omt.getXmlMsa(); - + // // Set module definitions default value // if (msa.getModuleDefinitions() == null) { - ModuleDefinitionsDocument.ModuleDefinitions md = ModuleDefinitionsDocument.ModuleDefinitions.Factory.newInstance(); + ModuleDefinitionsDocument.ModuleDefinitions md = ModuleDefinitionsDocument.ModuleDefinitions.Factory + .newInstance(); md.setOutputFileBasename(msa.getMsaHeader().getModuleName()); md.setBinaryModule(false); md.setSupportedArchitectures(ed.getVSupportedArchitectures()); @@ -815,7 +820,6 @@ public class MsaHeader extends IInternalFrame { // this.msaHeader.setSpecification(this.jTextFieldSpecification.getText()); msaHeader.setSpecification(this.jTextFieldSpecification.getText()); - msaHeader.setModuleType(ModuleTypeDef.Enum.forString(jComboBoxModuleType.getSelectedItem().toString())); msa.setMsaHeader(msaHeader); this.omt.setSaved(false); } catch (Exception e) { @@ -879,7 +883,7 @@ public class MsaHeader extends IInternalFrame { if (this.msaHeader == null) { msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance(); } - + // // Check BaseName // @@ -894,14 +898,22 @@ public class MsaHeader extends IInternalFrame { //this.jTextFieldBaseName.requestFocus(); return; } - this.msaHeader.setModuleName(this.jTextFieldBaseName.getText()); + if (!this.jTextFieldBaseName.getText().equals(msaHeader.getModuleName())) { + this.msaHeader.setModuleName(this.jTextFieldBaseName.getText()); + } else { + return; + } } // // Check Module Type // if (arg0.getSource() == this.jComboBoxModuleType) { - //msaHeader.setModuleType(ModuleTypeDef.Enum.forString(jComboBoxModuleType.getSelectedItem().toString())); + if (!jComboBoxModuleType.getSelectedItem().toString().equals(msaHeader.getModuleType().toString())) { + msaHeader.setModuleType(ModuleTypeDef.Enum.forString(jComboBoxModuleType.getSelectedItem().toString())); + } else { + return; + } } // @@ -918,14 +930,17 @@ public class MsaHeader extends IInternalFrame { //this.jTextFieldGuid.requestFocus(); return; } - this.msaHeader.setGuidValue(jTextFieldGuid.getText()); + if (!this.jTextFieldGuid.getText().equals(msaHeader.getGuidValue())) { + this.msaHeader.setGuidValue(this.jTextFieldGuid.getText()); + } else { + return; + } } // // Check Version // if (arg0.getSource() == this.jTextFieldVersion) { - if (isEmpty(this.jTextFieldVersion.getText())) { Log.err("Version couldn't be empty"); //this.jTextFieldVersion.requestFocus(); @@ -936,7 +951,11 @@ public class MsaHeader extends IInternalFrame { //this.jTextFieldVersion.requestFocus(); return; } - this.msaHeader.setVersion(this.jTextFieldVersion.getText()); + if (!this.jTextFieldVersion.getText().equals(msaHeader.getVersion())) { + this.msaHeader.setVersion(this.jTextFieldVersion.getText()); + } else { + return; + } } // @@ -953,7 +972,11 @@ public class MsaHeader extends IInternalFrame { //this.jTextFieldAbstract.requestFocus(); return; } - this.msaHeader.setAbstract(this.jTextFieldAbstract.getText()); + if (!this.jTextFieldAbstract.getText().equals(msaHeader.getAbstract())) { + this.msaHeader.setAbstract(this.jTextFieldAbstract.getText()); + } else { + return; + } } // @@ -965,7 +988,11 @@ public class MsaHeader extends IInternalFrame { //this.jTextAreaDescription.requestFocus(); return; } - this.msaHeader.setDescription(this.jTextAreaDescription.getText()); + if (!this.jTextAreaDescription.getText().equals(msaHeader.getDescription())) { + this.msaHeader.setDescription(this.jTextAreaDescription.getText()); + } else { + return; + } } // @@ -977,7 +1004,11 @@ public class MsaHeader extends IInternalFrame { //this.jTextFieldCopyright.requestFocus(); return; } - this.msaHeader.setCopyright(this.jTextFieldCopyright.getText()); + if (!this.jTextFieldCopyright.getText().equals(msaHeader.getCopyright())) { + this.msaHeader.setCopyright(this.jTextFieldCopyright.getText()); + } else { + return; + } } // @@ -990,7 +1021,11 @@ public class MsaHeader extends IInternalFrame { return; } if (this.msaHeader.getLicense() != null) { - this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText()); + if (!this.jTextAreaLicense.getText().equals(msaHeader.getLicense().getStringValue())) { + this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText()); + } else { + return; + } } else { License mLicense = License.Factory.newInstance(); mLicense.setStringValue(this.jTextAreaLicense.getText()); @@ -1008,11 +1043,15 @@ public class MsaHeader extends IInternalFrame { mLicense.setURL(this.jTextFieldURL.getText()); this.msaHeader.setLicense(mLicense); } else { - this.msaHeader.getLicense().setURL(this.jTextFieldURL.getText()); + if (!this.jTextFieldURL.getText().equals(msaHeader.getLicense().getURL())) { + this.msaHeader.getLicense().setURL(this.jTextFieldURL.getText()); + } else { + return; + } } } } - + this.save(); } } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/SourceFilesDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/SourceFilesDlg.java index 53ac9a591c..d11c979e25 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/SourceFilesDlg.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/SourceFilesDlg.java @@ -91,7 +91,7 @@ public class SourceFilesDlg extends IDialog { // // Not used by UI // - private SourceFilesIdentification sfid = null; + private SourceFilesIdentification sfid[] = null; private String msaFileName = ""; @@ -268,16 +268,16 @@ public class SourceFilesDlg extends IDialog { **/ private void init(SourceFilesIdentification inSourceFilesIdentifications, String fileName) { init(); - this.sfid = inSourceFilesIdentifications; + //this.sfid = inSourceFilesIdentifications; this.msaFileName = fileName; - if (this.sfid != null) { - this.jTextFieldFileName.setText(sfid.getFilename()); - this.jTextFieldTagName.setText(sfid.getTagName()); - this.jTextFieldToolCode.setText(sfid.getToolCode()); - this.jTextFieldToolChainFamily.setText(sfid.getToolChainFamily()); - jTextFieldFeatureFlag.setText(sfid.getFeatureFlag()); - this.jArchCheckBox.setSelectedItems(sfid.getSupArchList()); + if (inSourceFilesIdentifications != null) { + this.jTextFieldFileName.setText(inSourceFilesIdentifications.getFilename()); + this.jTextFieldTagName.setText(inSourceFilesIdentifications.getTagName()); + this.jTextFieldToolCode.setText(inSourceFilesIdentifications.getToolCode()); + this.jTextFieldToolChainFamily.setText(inSourceFilesIdentifications.getToolChainFamily()); + jTextFieldFeatureFlag.setText(inSourceFilesIdentifications.getFeatureFlag()); + this.jArchCheckBox.setSelectedItems(inSourceFilesIdentifications.getSupArchList()); } } @@ -376,14 +376,18 @@ public class SourceFilesDlg extends IDialog { } } - private SourceFilesIdentification getCurrentSourceFiles() { + private SourceFilesIdentification[] getCurrentSourceFiles() { String name = this.jTextFieldFileName.getText(); + String s[] = name.split(";"); String tagName = this.jTextFieldTagName.getText(); String toolCode = this.jTextFieldToolCode.getText(); String tcf = this.jTextFieldToolChainFamily.getText(); String featureFlag = this.jTextFieldFeatureFlag.getText(); Vector arch = this.jArchCheckBox.getSelectedItemsVector(); - sfid = new SourceFilesIdentification(name, tagName, toolCode, tcf, featureFlag, arch); + sfid = new SourceFilesIdentification[s.length]; + for (int index = 0; index < s.length; index++) { + sfid[index] = new SourceFilesIdentification(s[index], tagName, toolCode, tcf, featureFlag, arch); + } return sfid; } @@ -457,17 +461,23 @@ public class SourceFilesDlg extends IDialog { private void selectFile() { JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(Tools.getFilePathOnly(msaFileName))); + fc.setMultiSelectionEnabled(true); int result = fc.showOpenDialog(new JPanel()); if (result == JFileChooser.APPROVE_OPTION) { - this.jTextFieldFileName.setText(fc.getSelectedFile().getName()); + File f[] = fc.getSelectedFiles(); + String s = ""; + for (int index = 0; index < f.length; index++) { + s = s + f[index].getName() + ";"; + } + this.jTextFieldFileName.setText(s); } } - public SourceFilesIdentification getSfid() { + public SourceFilesIdentification[] getSfid() { return sfid; } - public void setSfid(SourceFilesIdentification sfid) { + public void setSfid(SourceFilesIdentification[] sfid) { this.sfid = sfid; } } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java index 19ed62005d..16cfaad87a 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java @@ -35,6 +35,7 @@ import org.tianocore.SpdHeaderDocument.SpdHeader; import org.tianocore.frameworkwizard.common.DataType; import org.tianocore.frameworkwizard.common.Log; import org.tianocore.frameworkwizard.common.SaveFile; +import org.tianocore.frameworkwizard.common.Sort; import org.tianocore.frameworkwizard.common.Tools; import org.tianocore.frameworkwizard.common.Identifications.Identification; import org.tianocore.frameworkwizard.common.Identifications.OpenFile; @@ -285,7 +286,7 @@ public class WorkspaceTools { } } - Tools.sortPackages(vPackageList, DataType.SORT_TYPE_ASCENDING); + Sort.sortPackages(vPackageList, DataType.SORT_TYPE_ASCENDING); return vPackageList; } @@ -385,7 +386,7 @@ public class WorkspaceTools { } v.addElement(new ModuleIdentification(id, pid)); } - Tools.sortModules(v, DataType.SORT_TYPE_ASCENDING); + Sort.sortModules(v, DataType.SORT_TYPE_ASCENDING); return v; } @@ -428,7 +429,7 @@ public class WorkspaceTools { } } } - Tools.sortModules(vModuleList, DataType.SORT_TYPE_ASCENDING); + Sort.sortModules(vModuleList, DataType.SORT_TYPE_ASCENDING); return vModuleList; } @@ -459,7 +460,7 @@ public class WorkspaceTools { Log.err("Open Platform Surface Area " + path, "Invalid file type"); } } - Tools.sortPlatforms(vPlatformList, DataType.SORT_TYPE_ASCENDING); + Sort.sortPlatforms(vPlatformList, DataType.SORT_TYPE_ASCENDING); return vPlatformList; } @@ -477,7 +478,7 @@ public class WorkspaceTools { } } } - Tools.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); + Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); return vector; } @@ -495,7 +496,7 @@ public class WorkspaceTools { } } } - Tools.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); + Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); return vector; } @@ -513,7 +514,7 @@ public class WorkspaceTools { } } } - Tools.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); + Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); return vector; } @@ -531,7 +532,7 @@ public class WorkspaceTools { } } } - Tools.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); + Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); return vector; } @@ -555,7 +556,7 @@ public class WorkspaceTools { } } } - Tools.sortPcds(vector, DataType.SORT_TYPE_ASCENDING); + Sort.sortPcds(vector, DataType.SORT_TYPE_ASCENDING); return vector; } @@ -583,7 +584,7 @@ public class WorkspaceTools { // TODO Auto-generated catch block } } - Tools.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); + Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); return vector; } @@ -609,7 +610,7 @@ public class WorkspaceTools { // TODO Auto-generated catch block } } - Tools.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); + Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); return vector; } @@ -635,7 +636,7 @@ public class WorkspaceTools { // TODO Auto-generated catch block } } - Tools.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); + Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); return vector; } @@ -661,7 +662,7 @@ public class WorkspaceTools { // TODO Auto-generated catch block } } - Tools.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); + Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING); return vector; } @@ -686,7 +687,7 @@ public class WorkspaceTools { // TODO Auto-generated catch block } } - Tools.sortPcds(vector, DataType.SORT_TYPE_ASCENDING); + Sort.sortPcds(vector, DataType.SORT_TYPE_ASCENDING); return vector; } -- 2.39.2