1 43 44 package org.jfree.ui.about; 45 46 import java.awt.BorderLayout ; 47 import java.util.ArrayList ; 48 import java.util.List ; 49 import javax.swing.JPanel ; 50 import javax.swing.JScrollPane ; 51 import javax.swing.JTable ; 52 53 60 public class LibraryPanel extends JPanel { 61 62 63 private JTable table; 64 65 66 private LibraryTableModel model; 67 68 73 public LibraryPanel(final List libraries) { 74 75 setLayout(new BorderLayout ()); 76 this.model = new LibraryTableModel(libraries); 77 this.table = new JTable (this.model); 78 add(new JScrollPane (this.table)); 79 80 } 81 82 public LibraryPanel(final ProjectInfo projectInfo) { 83 this(getLibraries(projectInfo)); 84 } 85 86 private static List getLibraries (final ProjectInfo info) { 87 if (info == null) { 88 return new ArrayList (); 89 } 90 final ArrayList libs = new ArrayList (); 91 collectLibraries(info, libs); 92 return libs; 93 } 94 95 private static void collectLibraries (final ProjectInfo info, 96 final List list) { 97 org.jfree.base.Library[] libs = info.getLibraries(); 98 for (int i = 0; i < libs.length; i++) { 99 final org.jfree.base.Library lib = libs[i]; 100 if (list.contains(lib) == false) { 101 list.add(lib); 103 if (lib instanceof ProjectInfo) { 104 collectLibraries((ProjectInfo) lib, list); 105 } 106 } 107 } 108 109 libs = info.getOptionalLibraries(); 110 for (int i = 0; i < libs.length; i++) { 111 final org.jfree.base.Library lib = libs[i]; 112 if (list.contains(lib) == false) { 113 list.add(lib); 115 if (lib instanceof ProjectInfo) { 116 collectLibraries((ProjectInfo) lib, list); 117 } 118 } 119 } 120 } 121 122 public LibraryTableModel getModel() { 123 return model; 124 } 125 126 protected JTable getTable() { 127 return table; 128 } 129 } 130 | Popular Tags |