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.EjbPlan; 31 32 import java.awt.*; 34 import java.io.File ; 35 import javax.swing.*; 36 import java.lang.ref.WeakReference ; 37 import java.beans.*; 38 39 public class EjbFilePanel extends ArchivePanel { 41 private FilePanel filePanel = null; 42 private JCheckBox checkCreateClient = null; 43 private GridBagLayout layoutMain = null; 44 45 public EjbFilePanel() { 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 EjbPlan) { 57 EjbPlan ep = (EjbPlan) plan; 58 Descriptor[] row = plan.getDescriptors(); 59 filePanel.getDDTableModel().clear(); 60 for (int i = 0 ; i < row.length ; i++ ) { 61 filePanel.getDDTableModel().addDescriptor(row[i]); 62 } 63 filePanel.getDDTable().setRowSelectionInterval(0, 0); 64 checkCreateClient.setSelected(ep.isCreateClient()); 65 } else { 66 throw new ArchiveException("Unable to read plan: expecting type EjbPlan"); 67 } 68 } 69 70 public void writePlan(JarPlan plan) throws ArchiveException { 71 validatePlan(); 72 plan.setArchivePath(filePanel.getArchivePath()); 73 if (plan instanceof EjbPlan) { 74 EjbPlan ep = (EjbPlan) plan; 75 int count = filePanel.getDDTableModel().getRowCount(); 76 77 ep.setDescriptors(filePanel.getDDTableModel().getDescriptors()); 78 ep.setCreateClient(checkCreateClient.isSelected()); 79 } 80 } 81 82 public void validatePlan() throws ArchiveException { 83 filePanel.validatePlan(); 84 } 85 86 public String getPageTitle() { 87 return "Enterprise JavaBean Archive"; 88 } 89 90 public String getInstructions() { 91 StringBuffer buf = new StringBuffer (); 92 93 buf.append("Enter details for the enterprise JavaBean archive."); 94 return buf.toString(); 95 } 96 97 protected void preparePanel() { 98 String [] defaultDD = new String [1]; 99 StringBuffer buf = new StringBuffer (); 100 101 buf.append(getWorkingRoot()); 102 buf.append(File.separator); 103 buf.append("src"); 104 buf.append(File.separator); 105 buf.append("meta-inf"); 106 buf.append(File.separator); 107 buf.append("ejb-jar.xml"); 108 defaultDD[0] = buf.toString(); 109 filePanel.setDefaultDD(defaultDD); 110 filePanel.preparePanel(); 111 } 112 113 private void pmInit() { 114 filePanel.setExtension("jar"); 115 } 116 117 protected void setWizard(ArchiveWizard wizard) { 119 super.setWizard(wizard); 120 filePanel.setWizard(wizard); 121 } 122 123 private void jbInit() throws Exception { 124 filePanel = (FilePanel) Beans.instantiate(getClass().getClassLoader(), 125 FilePanel.class.getName()); 126 checkCreateClient = 127 (JCheckBox) Beans.instantiate(getClass().getClassLoader(), 128 JCheckBox.class.getName()); 129 layoutMain = 130 (GridBagLayout) Beans.instantiate(getClass().getClassLoader(), 131 GridBagLayout.class.getName()); 132 checkCreateClient.setText("Create client jar"); 133 this.setLayout(layoutMain); 134 this.add(filePanel, 135 new GridBagConstraints(0, 0, 1, 1, 0.1, 0.1, 136 GridBagConstraints.CENTER, 137 GridBagConstraints.BOTH, 138 new Insets(0, 0, 0, 0), 0, 0)); 139 this.add(checkCreateClient, 140 new GridBagConstraints(0, 1, 1, 1, 0.1, 0.0, 141 GridBagConstraints.WEST, 142 GridBagConstraints.HORIZONTAL, 143 new Insets(0, 10, 5, 5), 0, 0)); 144 } 145 146 } 147 | Popular Tags |