1 2 24 25 package org.enhydra.tool.archive.wizard; 26 27 import org.enhydra.tool.archive.ArchiveException; 29 import org.enhydra.tool.archive.ClassFilter; 30 import org.enhydra.tool.archive.JarPlan; 31 import org.enhydra.tool.archive.WarPlan; 32 import org.enhydra.tool.common.PathHandle; 33 34 import java.awt.*; 36 import java.beans.Beans ; 37 import java.io.File ; 38 import java.lang.ref.WeakReference ; 39 import javax.swing.*; 40 41 public class ClassesPanel extends ArchivePanel { 43 private BorderLayout layoutMain = null; 44 private TwoColumnFileSelector selectorPanel = null; 45 46 public ClassesPanel() { 47 try { 48 jbInit(); 49 pmInit(); 50 } catch (Exception ex) { 51 ex.printStackTrace(); 52 } 53 } 54 55 public void validatePlan() throws ArchiveException { 56 selectorPanel.validatePlan(); 57 } 58 59 public void readPlan(JarPlan plan) throws ArchiveException { 60 selectorPanel.setRoot(plan.getClassRoot()); 61 selectorPanel.setSelections(plan.getClassFileArray()); 62 } 63 64 public void writePlan(JarPlan plan) throws ArchiveException { 65 validatePlan(); 66 plan.setClassRoot(selectorPanel.getRoot()); 67 plan.setClassFiles(selectorPanel.getSelections()); 68 } 69 70 public String getPageTitle() { 71 return "Classes"; 72 } 73 74 public String getInstructions() { 75 StringBuffer buf = new StringBuffer (); 76 77 buf.append("Select files to include in classes"); 78 return buf.toString(); 79 } 80 81 protected void preparePanel() { 82 if (selectorPanel.getRootFile() == null) { 83 StringBuffer buf = new StringBuffer (); 84 PathHandle path = null; 85 86 buf.append(getWorkingRoot()); 87 buf.append(File.separator); 88 buf.append("classes"); 89 path = PathHandle.createPathHandle(buf.toString()); 90 if (path.isDirectory()) { 91 selectorPanel.setDefaultSelect(true); 92 } else { 93 selectorPanel.setDefaultSelect(false); 94 path = PathHandle.createPathHandle(getWorkingRoot()); 95 } 96 if (path.isDirectory()) { 97 selectorPanel.setRoot(path.getPath()); 98 } 99 } 100 } 101 102 private void pmInit() { 103 selectorPanel.setFilter(new ClassFilter()); 104 } 105 106 private void jbInit() throws Exception { 107 layoutMain = 108 (BorderLayout) Beans.instantiate(getClass().getClassLoader(), 109 BorderLayout.class.getName()); 110 selectorPanel = 111 (TwoColumnFileSelector) Beans.instantiate(getClass().getClassLoader(), 112 TwoColumnFileSelector.class.getName()); 113 this.setLayout(layoutMain); 114 this.add(selectorPanel, BorderLayout.CENTER); 115 } 116 117 } 118 | Popular Tags |