1 2 24 package org.enhydra.tool.archive.wizard; 25 26 import org.enhydra.tool.archive.ArchiveException; 28 import org.enhydra.tool.archive.Descriptor; 29 import org.enhydra.tool.archive.JarPlan; 30 import org.enhydra.tool.archive.EarPlan; 31 32 import java.awt.*; 34 import java.beans.Beans ; 35 import java.io.File ; 36 import java.util.ArrayList ; 37 import javax.swing.*; 38 39 public class MetaPanel extends ArchivePanel { 41 private BorderLayout layoutMain = null; 42 private OneColumnFileSelector selectorPanel = null; 43 44 public MetaPanel() { 45 try { 46 jbInit(); 47 pmInit(); 48 } catch (Exception ex) { 49 ex.printStackTrace(); 50 } 51 } 52 53 public void readPlan(JarPlan plan) throws ArchiveException { 54 selectorPanel.setSelections(plan.getLibFiles()); 55 Descriptor[] dd = new Descriptor[0]; 56 String [] paths = new String [0]; 57 ArrayList list = new ArrayList (); 58 59 if (plan instanceof EarPlan) { 60 EarPlan ep = (EarPlan) plan; 61 dd = ep.getDescriptors(); 62 for (int i = 0 ; i < dd.length ; i++) { 63 list.add(dd[i].getPath()); 64 } 65 list.trimToSize(); 66 paths = new String [list.size()]; 67 paths = (String []) list.toArray(paths); 68 selectorPanel.setSelections(paths); 69 } 70 } 71 72 public void writePlan(JarPlan plan) throws ArchiveException { 73 if (plan instanceof EarPlan) { 74 EarPlan ep = (EarPlan) plan; 75 Descriptor[] dd = new Descriptor[0]; 76 String [] paths = new String [0]; 77 paths = selectorPanel.getSelections(); 78 dd = new Descriptor[paths.length]; 79 for (int i = 0 ; i < dd.length ; i++) { 80 dd[i] = new Descriptor(paths[i]); 81 } 82 ep.setDescriptors(dd); 83 } 84 } 85 86 public void validatePlan() throws ArchiveException { 87 } 89 90 public String getPageTitle() { 91 return "Deployment Descriptors"; 92 } 93 94 public String getInstructions() { 95 StringBuffer buf = new StringBuffer (); 96 97 buf.append("Select the deployment descriptors "); 98 buf.append("to include in this archive."); 99 return buf.toString(); 100 } 101 102 protected void setWizard(ArchiveWizard wizard) { 104 super.setWizard(wizard); 105 selectorPanel.setWizard(wizard); 106 } 107 108 private void pmInit() { 109 String [] exts = { 110 "xml", "mf" 111 }; 112 113 selectorPanel.setExtensions(exts); 114 selectorPanel.setTitle("meta-inf"); 115 } 116 117 private void jbInit() throws Exception { 118 layoutMain = 119 (BorderLayout) Beans.instantiate(getClass().getClassLoader(), 120 BorderLayout.class.getName()); 121 selectorPanel = 122 (OneColumnFileSelector) Beans.instantiate(getClass().getClassLoader(), 123 OneColumnFileSelector.class.getName()); 124 this.setLayout(layoutMain); 125 this.add(selectorPanel, BorderLayout.CENTER); 126 } 127 128 } 129 | Popular Tags |