1 2 package org.enhydra.tool.archive.wizard; 3 4 import org.enhydra.tool.archive.ArchiveException; 6 import org.enhydra.tool.archive.JarPlan; 7 import org.enhydra.tool.archive.WarPlan; 8 import org.enhydra.tool.common.PathHandle; 9 import java.awt.*; 11 import java.beans.Beans ; 12 import java.io.File ; 13 import javax.swing.*; 14 15 16 public class ContentPanel extends ArchivePanel { 18 private BorderLayout layoutMain = null; 19 private TwoColumnFileSelector selectorPanel = null; 20 21 public ContentPanel() { 22 try { 23 jbInit(); 24 } catch (Exception ex) { 25 ex.printStackTrace(); 26 } 27 } 28 29 public void validatePlan() throws ArchiveException { 30 selectorPanel.validatePlan(); 31 } 32 33 public void readPlan(JarPlan plan) throws ArchiveException { 34 WarPlan wp = (WarPlan) plan; 35 selectorPanel.setRoot(wp.getContentRoot()); 36 selectorPanel.setSelections(wp.getContentFileArray()); 37 } 38 39 public void writePlan(JarPlan plan) throws ArchiveException { 40 WarPlan wp = (WarPlan) plan; 41 validatePlan(); 42 wp.setContentRoot(selectorPanel.getRoot()); 43 wp.setContentFiles(selectorPanel.getSelections()); 44 } 45 46 public String getPageTitle() { 47 return "Content"; 48 } 49 50 protected void preparePanel() { 51 if (selectorPanel.getRootFile() == null) { 52 StringBuffer buf = new StringBuffer (); 53 PathHandle path = null; 54 buf.append(getWorkingRoot()); 55 buf.append(File.separator); 56 buf.append("output/content"); 57 path = PathHandle.createPathHandle(buf.toString()); 58 if (path.isDirectory()) { 59 selectorPanel.setDefaultSelect(true); 60 selectorPanel.setRoot(path.getPath()); 61 } 62 } 63 } 64 65 public String getInstructions() { 66 StringBuffer buf = new StringBuffer (); 67 buf.append("Select files to include in content"); 68 return buf.toString(); 69 } 70 71 72 73 private void jbInit() throws Exception { 74 layoutMain = 75 (BorderLayout) Beans.instantiate(getClass().getClassLoader(), 76 BorderLayout.class.getName()); 77 selectorPanel = 78 (TwoColumnFileSelector) Beans.instantiate(getClass().getClassLoader(), 79 TwoColumnFileSelector.class.getName()); 80 81 this.setLayout(layoutMain); 82 this.add(selectorPanel, BorderLayout.CENTER); 83 } 84 85 86 87 } 88 | Popular Tags |