1 2 24 package org.enhydra.tool.archive.wizard; 25 26 import org.enhydra.tool.ToolBoxInfo; 30 import org.enhydra.tool.archive.WarPlan; 31 import org.enhydra.tool.archive.ArchiveException; 32 import org.enhydra.tool.archive.ArchiveTool; 33 import org.enhydra.tool.common.PathHandle; 34 import org.enhydra.tool.common.SwingUtil; 35 36 import javax.swing.*; 40 import javax.swing.border.*; 41 import java.awt.*; 42 import java.awt.event.ActionEvent ; 43 import java.awt.event.ActionListener ; 44 import java.io.File ; 45 import java.util.ArrayList ; 46 import java.util.ResourceBundle ; 47 import java.util.jar.Manifest ; 48 import java.util.jar.JarInputStream ; 49 50 public class WarType extends ArchiveType { 52 public final static String EXT = "war"; 53 54 protected String getClassIncludeRoot() { 56 return "WEB-INF/CLASSES/"; 57 } 58 59 protected final String getSelectionName() { 60 return "Web Application"; 61 } 62 63 protected final String getExtension() { 64 return EXT; 65 } 66 67 protected final String getType() { 68 return getExtension(); 69 } 70 71 protected final String getDescription() { 72 StringBuffer buf = new StringBuffer (); 73 74 buf.append("Create a web application archive for "); 75 buf.append("deploying serlvet classes, libraries, "); 76 buf.append("Java Server Pages and static content."); 77 return buf.toString(); 78 } 79 80 protected void initPanels() throws ArchiveException { 81 WarFilePanel filePanel = new WarFilePanel(); 82 ContentPanel contentPanel = new ContentPanel(); 83 ClassesPanel classesPanel = new ClassesPanel(); 84 LibraryPanel libPanel = new LibraryPanel(); 85 ArchivePanel[] newPanels = new ArchivePanel[4]; 86 87 newPanels[0] = filePanel; 88 newPanels[1] = contentPanel; 89 newPanels[2] = classesPanel; 90 newPanels[3] = libPanel; 91 setWizardPanels(newPanels); 92 } 93 94 protected void initPlan() throws ArchiveException { 95 WarPlan warPlan = null; 96 PathHandle path = null; 97 98 setPlan(new WarPlan()); 99 getWarPlan().setArchivePath(getDefaultArchivePath()); 100 path = PathHandle.createPathHandle(getWarPlan().getArchivePath()); 101 if (path.isFile()) { 102 readArchive(getWarPlan().getArchivePath()); 103 } 104 } 105 106 protected boolean readArchive(Manifest manifest, String [] entries) { 107 boolean read = super.readArchive(manifest, entries); 108 PathHandle root = null; 109 110 if (read) { 111 String value = null; 112 113 try { 114 value = manifest.getMainAttributes().getValue(CONTENT_ROOT); 115 root = PathHandle.createPathHandle(value); 116 if (root.isDirectory()) { 117 PathHandle cursor = null; 118 String [] content = new String [0]; 119 ArrayList list = new ArrayList (); 120 121 getWarPlan().setContentRoot(root.getPath()); 122 for (int i = 0; i < entries.length; i++) { 123 if (entries[i].toUpperCase().startsWith("WEB-INF")) { 124 125 } else if (entries[i].toUpperCase().startsWith("META-INF")) { 127 128 } else { 130 cursor = 131 PathHandle.createPathHandle(root.getPath() 132 + File.separator 133 + entries[i]); 134 if (cursor.isFile()) { 135 list.add(cursor.getPath()); 136 } 137 } 138 } 139 list.trimToSize(); 140 content = new String [list.size()]; 141 content = (String []) list.toArray(content); 142 list.clear(); 143 getWarPlan().setContentFiles(content); 144 } 145 } catch (ArchiveException e) { 146 e.printStackTrace(System.err); 147 } 148 } 149 return read; 150 } 151 152 private WarPlan getWarPlan() throws ArchiveException { 153 return (WarPlan) getPlan(); 154 } 155 156 } 157 | Popular Tags |