Fix the no library instance in UI display when some exception occurs.
authorjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 20 Nov 2006 05:21:41 +0000 (05:21 +0000)
committerjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 20 Nov 2006 05:21:41 +0000 (05:21 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1982 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java

index 2f3dec9..579f561 100644 (file)
@@ -196,18 +196,24 @@ public class FpdModuleSA extends JDialog implements ActionListener {
     }\r
     \r
     public void initLibraries(String key) {\r
+        libClassTableModel.setRowCount(0);\r
+        libInstanceTableModel.setRowCount(0);\r
+        selectedInstancesTableModel.setRowCount(0);\r
+        Vector<String> errorMsg = new Vector<String>();\r
         try {\r
             //\r
             // display library classes that need to be resolved. also potential instances for them.\r
             //\r
-            resolveLibraryInstances(moduleKey);\r
+            resolveLibraryInstances(moduleKey, errorMsg);\r
         } catch (Exception e) {\r
-            JOptionPane.showMessageDialog(frame, e.getCause() + " " + e.getMessage());\r
+            String exceptionMsg = e.getCause() + " " + e.getMessage();\r
+            errorMsg.add(exceptionMsg);\r
+            JOptionPane.showMessageDialog(frame, exceptionMsg);\r
         }\r
         //\r
         // display lib instances already selected for key\r
         //\r
-        selectedInstancesTableModel.setRowCount(0);\r
+        \r
         int instanceCount = ffc.getLibraryInstancesCount(key);\r
         if (instanceCount != 0) {\r
             String[][] saa = new String[instanceCount][5];\r
@@ -226,15 +232,25 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                     // re-evaluate lib instance usage when adding a already-selected lib instance.\r
                     //\r
                     try {\r
-                        resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);\r
+                        resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4], errorMsg);\r
                     } catch (Exception e) {\r
-                        JOptionPane.showMessageDialog(frame, e.getCause() + " " + e.getMessage());\r
+                        String exceptionMsg = e.getCause() + " " + e.getMessage();\r
+                        if (!errorMsg.contains(exceptionMsg)) {\r
+                            JOptionPane.showMessageDialog(frame, e.getCause() + " " + e.getMessage());\r
+                        }\r
                     }\r
                     selectedInstancesTableModel.addRow(saa[i]);\r
                 }\r
             }\r
         }\r
 \r
+        if (errorMsg.size() > 0) {\r
+            String errors = "";\r
+            for (int i = 0; i < errorMsg.size(); ++i) {\r
+                errors += " " + errorMsg.get(i) + "\n";\r
+            }\r
+            JOptionPane.showMessageDialog(frame, errors);\r
+        }\r
         showClassToResolved();\r
     }\r
     \r
@@ -326,7 +342,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
         }\r
     }\r
     \r
-    private void resolveLibraryInstances(String key) throws MultipleInstanceException, NoInstanceException{\r
+    private void resolveLibraryInstances(String key, Vector<String> errorMsg) throws MultipleInstanceException, NoInstanceException{\r
         ModuleIdentification mi = WorkspaceProfile.getModuleId(key);\r
         PackageIdentification[] depPkgList = null;\r
         \r
@@ -401,7 +417,12 @@ public class FpdModuleSA extends JDialog implements ActionListener {
             }\r
             ArrayList<String> instances = getInstancesForClass(cls, depPkgList);\r
             if (instances.size() == 0) {\r
-                throw new NoInstanceException (cls.className);\r
+//                throw new NoInstanceException (cls.className);\r
+                String exceptionMsg = new NoInstanceException (cls.className).getMessage();\r
+                if (!errorMsg.contains(exceptionMsg)) {\r
+                    errorMsg.add(exceptionMsg);    \r
+                }\r
+                \r
             }\r
             classInstanceMap.put(cls, instances);\r
 \r
@@ -540,7 +561,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
     }\r
     \r
     private void showClassToResolved(){\r
-        libClassTableModel.setRowCount(0);\r
+        \r
         if (classConsumed == null || classConsumed.size() == 0) {\r
             return;\r
         }\r
@@ -556,7 +577,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                 libClassTableModel.addRow(s);\r
             }\r
         }\r
-        libInstanceTableModel.setRowCount(0);\r
+        \r
     }\r
     \r
     private void addLibInstance (ModuleIdentification libMi) throws Exception{\r
@@ -1175,12 +1196,22 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                                   libInstanceTableModel.getValueAt(row, 2), libInstanceTableModel.getValueAt(row, 3),\r
                                   libInstanceTableModel.getValueAt(row, 4)};\r
                     selectedInstancesTableModel.addRow(s);\r
+                    \r
+                    Vector<String> errorMsg = new Vector<String>();\r
                     try {\r
-                        resolveLibraryInstances(instanceValue);\r
+                        resolveLibraryInstances(instanceValue, errorMsg);\r
                     }\r
                     catch (Exception exp) {\r
                         JOptionPane.showMessageDialog(frame, exp.getMessage());\r
                     }\r
+                    \r
+                    if (errorMsg.size() > 0) {\r
+                        String errors = "";\r
+                        for (int i = 0; i < errorMsg.size(); ++i) {\r
+                            errors += " " + errorMsg.get(i) + "\n";\r
+                        }\r
+                        JOptionPane.showMessageDialog(frame, errors);\r
+                    }\r
                     showClassToResolved();\r
                 }\r
             });\r