1 2 24 25 package org.enhydra.tool.archive.wizard; 26 27 import org.enhydra.tool.archive.ArchiveException; 29 import org.enhydra.tool.archive.Descriptor; 30 import org.enhydra.tool.archive.JarPlan; 31 import org.enhydra.tool.archive.WarPlan; 32 33 import java.awt.*; 35 import java.beans.Beans ; 36 import java.io.File ; 37 import java.lang.ref.WeakReference ; 38 import javax.swing.*; 39 40 public class WarFilePanel extends ArchivePanel { 42 private BorderLayout layoutMain = null; 43 private FilePanel filePanel = null; 44 45 public WarFilePanel() { 46 try { 47 jbInit(); 48 pmInit(); 49 } catch (Exception ex) { 50 ex.printStackTrace(); 51 } 52 } 53 54 public void readPlan(JarPlan plan) throws ArchiveException { 55 filePanel.setArchivePath(plan.getArchivePath()); 56 if (plan instanceof WarPlan) { 57 WarPlan wp = (WarPlan) plan; 58 Descriptor[] rows = plan.getDescriptors(); 59 60 filePanel.getDDTableModel().clear(); 61 for (int i = 0 ; i < rows.length ; i++ ) { 62 filePanel.getDDTableModel().addDescriptor(rows[i]); 63 } 64 filePanel.getDDTable().setRowSelectionInterval(0, 0); 65 } else { 66 throw new ArchiveException("Unable to read plan: expecting type WarPlan"); 67 } 68 } 69 70 public void writePlan(JarPlan plan) throws ArchiveException { 71 validatePlan(); 72 plan.setArchivePath(filePanel.getArchivePath()); 73 plan.setDescriptors(filePanel.getDDTableModel().getDescriptors()); 74 } 75 76 public void validatePlan() throws ArchiveException { 77 filePanel.validatePlan(); 78 } 79 80 public String getPageTitle() { 81 return "Web Archive"; 82 } 83 84 public String getInstructions() { 85 StringBuffer buf = new StringBuffer (); 86 87 buf.append("Enter details for the web archive file."); 88 return buf.toString(); 89 } 90 91 protected void setWizard(ArchiveWizard wizard) { 93 super.setWizard(wizard); 94 filePanel.setWizard(wizard); 95 } 96 97 protected void preparePanel() { 98 String [] defaultDD = new String [1]; 99 StringBuffer buf = new StringBuffer (); 100 buf.append("src"); 101 buf.append(File.separator); 102 buf.append("WEB-INF"); 103 buf.append(File.separator); 104 buf.append("web.xml"); 105 defaultDD[0] = buf.toString(); 106 filePanel.setDefaultDD(defaultDD); 107 filePanel.preparePanel(); 108 } 109 110 private void pmInit() { 111 filePanel.setExtension("war"); 112 } 113 114 private void jbInit() throws Exception { 115 layoutMain = 116 (BorderLayout) Beans.instantiate(getClass().getClassLoader(), 117 BorderLayout.class.getName()); 118 filePanel = (FilePanel) Beans.instantiate(getClass().getClassLoader(), 119 FilePanel.class.getName()); 120 this.setLayout(layoutMain); 121 this.add(filePanel, BorderLayout.CENTER); 122 } 123 124 } 125 | Popular Tags |