Remove the assumption of package location under workspace and prompt user to specify...
authorjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 22 May 2006 04:59:10 +0000 (04:59 +0000)
committerjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 22 May 2006 04:59:10 +0000 (04:59 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@226 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/PackageEditor/src/org/tianocore/packaging/DbFileContents.java
Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageAction.java
Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageLibraryClass.java
Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageMsaFile.java
Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePkgHeader.java
Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagingMain.java

index 44b8d27..4f5fb37 100644 (file)
@@ -288,7 +288,7 @@ public class DbFileContents {
         p.addNewPackageName().setStringValue(name);\r
         p.addNewGuid().setStringValue(guid);\r
         p.addNewVersion().setStringValue(version);\r
-        p.addNewPath().setStringValue(installDir);\r
+        p.addNewPath().setStringValue(installDir + "/");\r
 \r
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");\r
         Date date = new Date();\r
index 71d2915..03e1607 100644 (file)
@@ -24,6 +24,7 @@ import java.awt.GridLayout;
 import java.io.File;\r
 \r
 import javax.swing.JButton;\r
+import javax.swing.filechooser.FileFilter;\r
 \r
 /**\r
  GUI for create spd file\r
@@ -137,6 +138,8 @@ public class PackageAction extends JFrame {
       @return javax.swing.JButton      \r
      **/\r
     private JButton getJButton() {\r
+        final FileFilter filter = new PkgFileFilter("spd");\r
+        \r
         if (jButton == null) {\r
             jButton = new JButton();\r
             jButton.setText("Save");\r
@@ -145,8 +148,9 @@ public class PackageAction extends JFrame {
                     //\r
                     // save sfc contents to file\r
                     //\r
-                    JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE"));\r
+                    JFileChooser chooser = new JFileChooser(PackagingMain.dirForNewSpd);\r
                     chooser.setMultiSelectionEnabled(false);\r
+                    chooser.setFileFilter(filter);\r
 \r
                     int retval = chooser.showSaveDialog(frame);\r
                     if (retval == JFileChooser.APPROVE_OPTION) {\r
index efd6a76..bf8c70b 100644 (file)
@@ -416,7 +416,7 @@ public class PackageLibraryClass extends JFrame implements ActionListener {
             if (jRadioButtonSelect.isSelected()) {\r
                 strLibClass = jComboBoxSelect.getSelectedItem().toString();\r
             }\r
-            listItem.addElement(jTextField.getText() + this.Separator + strLibClass);\r
+            listItem.addElement(jTextField.getText().replace('\\', '/') + this.Separator + strLibClass);\r
         }\r
         //\r
         // remove selected line\r
@@ -517,25 +517,40 @@ public class PackageLibraryClass extends JFrame implements ActionListener {
                     // Select files from current workspace\r
                     //\r
                     JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE"));\r
+                    File theFile = null;\r
+                    String headerDest = null;\r
                     \r
                     chooser.setMultiSelectionEnabled(false);\r
                     chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);\r
                     int retval = chooser.showOpenDialog(frame);\r
                     if (retval == JFileChooser.APPROVE_OPTION) {\r
 \r
-                        File theFile = chooser.getSelectedFile();\r
+                        theFile = chooser.getSelectedFile();\r
                         String file = theFile.getPath();\r
                         if (!file.startsWith(System.getenv("WORKSPACE"))) {\r
                             JOptionPane.showMessageDialog(frame, "You can only select files in current workspace!");\r
                             return;\r
                         }\r
+                        \r
+                        \r
+                    }\r
+                    else {\r
+                        return;\r
+                    }\r
+                    \r
+                    if (!theFile.getPath().startsWith(PackagingMain.dirForNewSpd)) {\r
                         //\r
-                        // record relative path of selected file. Assume top level package directory lies directly in workspace\r
+                        //ToDo: copy elsewhere header file to new pkg dir, prompt user to chooser a location\r
                         //\r
-                        int fileIndex = file.indexOf(System.getProperty("file.separator"), System.getenv("WORKSPACE").length() + 1);\r
-                        jTextField.setText(file.substring(fileIndex + 1));\r
-                        \r
+                        JOptionPane.showMessageDialog(frame, "You must copy header file into current package directory!");\r
+                        return;\r
                     }\r
+                    \r
+                    headerDest = theFile.getPath();\r
+                    int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), PackagingMain.dirForNewSpd.length());\r
+                    \r
+                    jTextField.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));\r
+                        \r
                 }\r
             });\r
         }\r
index b57a1b2..824c372 100644 (file)
@@ -32,6 +32,7 @@ import javax.swing.JList;
 import javax.swing.JScrollPane;\r
 import javax.swing.JButton;\r
 import javax.swing.JFrame;\r
+import javax.swing.filechooser.FileFilter;\r
 \r
 /**\r
  GUI for create MsaFile elements of spd file\r
@@ -318,6 +319,8 @@ public class PackageMsaFile extends JFrame implements ActionListener {
      @return javax.swing.JButton       \r
      **/\r
     private JButton getJButton() {\r
+        final FileFilter filter = new PkgFileFilter("msa");\r
+        \r
         if (jButton == null) {\r
             jButton = new JButton();\r
             jButton.setBounds(new java.awt.Rectangle(377,46,89,20));\r
@@ -326,23 +329,39 @@ public class PackageMsaFile extends JFrame implements ActionListener {
             jButton.addMouseListener(new java.awt.event.MouseAdapter() {\r
                 public void mouseClicked(java.awt.event.MouseEvent e) {\r
                     JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE"));\r
+                    File theFile = null;\r
+                    String msaDest = null;\r
                     \r
                     chooser.setMultiSelectionEnabled(false);\r
                     chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);\r
-                    chooser.setFileFilter(new PkgFileFilter("msa"));\r
+                    chooser.setFileFilter(filter);\r
                     int retval = chooser.showOpenDialog(frame);\r
                     if (retval == JFileChooser.APPROVE_OPTION) {\r
 \r
-                        File theFile = chooser.getSelectedFile();\r
+                        theFile = chooser.getSelectedFile();\r
                         String file = theFile.getPath();\r
                         if (!file.startsWith(System.getenv("WORKSPACE"))) {\r
                             JOptionPane.showMessageDialog(frame, "You can only select files in current workspace!");\r
                             return;\r
                         }\r
-                        int fileIndex = file.indexOf(System.getProperty("file.separator"), System.getenv("WORKSPACE").length() + 1);\r
-                        jTextField.setText(file.substring(fileIndex + 1));\r
                         \r
                     }\r
+                    else {\r
+                        return;\r
+                    }\r
+                    \r
+                    if (!theFile.getPath().startsWith(PackagingMain.dirForNewSpd)) {\r
+                        //\r
+                        //ToDo: copy elsewhere msa to new pkg dir, prompt user to chooser a location\r
+                        //\r
+                        JOptionPane.showMessageDialog(frame, "You must copy msa file into current package directory!");\r
+                        return;\r
+                    }\r
+                    \r
+                    msaDest = theFile.getPath();\r
+                    int fileIndex = msaDest.indexOf(System.getProperty("file.separator"), PackagingMain.dirForNewSpd.length());\r
+                    \r
+                    jTextField.setText(msaDest.substring(fileIndex + 1).replace('\\', '/'));\r
                 }\r
             });\r
         }\r
index 982dbe2..8d0eb7d 100644 (file)
@@ -373,7 +373,7 @@ public class PackagePkgHeader extends JFrame implements ActionListener {
                 strLibClass = jComboBoxSelect.getSelectedItem().toString();\r
             }\r
 \r
-            listItem.addElement(jTextField.getText() + Separator + strLibClass);\r
+            listItem.addElement(jTextField.getText().replace('\\', '/') + Separator + strLibClass);\r
         }\r
 \r
         if (arg0.getSource() == jButtonRemove) {\r
index bca1108..7d4654a 100644 (file)
@@ -37,6 +37,8 @@ public class PackagingMain extends JFrame {
 \r
     static JFrame frame;\r
 \r
+    static String dirForNewSpd = null;\r
+\r
     private JPanel jContentPane = null;\r
 \r
     private JButton jButton = null;\r
@@ -227,6 +229,25 @@ public class PackagingMain extends JFrame {
             jButton5.setText("Create Package Description File");\r
             jButton5.addMouseListener(new java.awt.event.MouseAdapter() {\r
                 public void mouseClicked(java.awt.event.MouseEvent e) {\r
+                    JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE"));\r
+                    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);\r
+                    chooser.setMultiSelectionEnabled(false);\r
+                    chooser.setDialogTitle("Please specify where to save the new spd file");\r
+\r
+                    int retval = chooser.showSaveDialog(frame);\r
+                    if (retval == JFileChooser.APPROVE_OPTION) {\r
+                        try {\r
+                            File theFile = chooser.getSelectedFile();\r
+                            PackagingMain.dirForNewSpd = theFile.getPath();\r
+\r
+                        } catch (Exception ee) {\r
+                            System.out.println(ee.toString());\r
+                        }\r
+//                        pThis.dispose();\r
+                    }\r
+                    else {\r
+                        return;\r
+                    }\r
                     SpdFileContents sfc = new SpdFileContents();\r
                     ModalFrameUtil.showAsModal(new PackageAction(sfc), pThis);\r
                 }\r