1 19 20 package org.netbeans.modules.j2ee.ejbcore.ejb.wizard.dd; 21 22 import java.awt.Component ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import java.io.File ; 26 import javax.swing.DefaultListCellRenderer ; 27 import javax.swing.JList ; 28 import javax.swing.JPanel ; 29 import org.netbeans.api.project.Project; 30 import org.netbeans.api.project.ProjectUtils; 31 import org.netbeans.modules.j2ee.api.ejbjar.EjbJar; 32 import org.openide.filesystems.FileObject; 33 import org.openide.filesystems.FileUtil; 34 import org.openide.util.NbBundle; 35 36 40 public final class EjbJarXmlVisualPanel1 extends JPanel { 41 42 44 private Project project; 45 46 public EjbJarXmlVisualPanel1() { 47 initComponents(); 48 locationCombo.setRenderer(new FileObjectListCellRenderer()); 49 } 50 51 void setProject(Project project) { 52 this.project = project; 53 EjbJar[] apiEjbJars = EjbJar.getEjbJars(project); 54 fileNameText.setText("ejb-jar.xml"); projectText.setText(ProjectUtils.getInformation(project).getDisplayName()); 57 for (int i = 0; i < apiEjbJars.length; i++) { 58 if (apiEjbJars[i].getDeploymentDescriptor() == null) { 59 locationCombo.addItem(apiEjbJars[i].getMetaInf()); 60 } 61 } 62 refreshLocation(); 63 locationCombo.addActionListener(new ActionListener () { 64 public void actionPerformed(ActionEvent actionEvent) { 65 refreshLocation(); 66 } 67 }); 68 } 69 70 FileObject getSelectedLocation() { 71 return (FileObject) locationCombo.getSelectedItem(); 72 } 73 74 @Override 75 public String getName() { 76 return NbBundle.getMessage(EjbJarXmlVisualPanel1.class, "LBL_SelectLocation"); 77 } 78 79 private void refreshLocation() { 80 FileObject fileObject = (FileObject) locationCombo.getSelectedItem(); 81 if (fileObject != null) { 82 createdFileText.setText(FileUtil.getFileDisplayName(fileObject) + File.separator + "ejb-jar.xml"); 83 } 84 firePropertyChange("", null, null); 85 } 86 87 private class FileObjectListCellRenderer extends DefaultListCellRenderer { 88 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 89 if (value instanceof FileObject) { 90 FileObject fileObject = (FileObject) value; 91 setText(FileUtil.getFileDisplayName(fileObject)); 92 } 93 return this; 94 } 95 } 96 97 102 private void initComponents() { 104 jLabel1 = new javax.swing.JLabel (); 105 jLabel2 = new javax.swing.JLabel (); 106 jLabel3 = new javax.swing.JLabel (); 107 jLabel4 = new javax.swing.JLabel (); 108 createdFileText = new javax.swing.JTextField (); 109 projectText = new javax.swing.JTextField (); 110 fileNameText = new javax.swing.JTextField (); 111 locationCombo = new javax.swing.JComboBox (); 112 113 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(EjbJarXmlVisualPanel1.class, "LBL_Name")); 114 115 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(EjbJarXmlVisualPanel1.class, "LBL_Project")); 116 117 org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(EjbJarXmlVisualPanel1.class, "LBL_Location")); 118 119 org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(EjbJarXmlVisualPanel1.class, "LBL_CreatedFile")); 120 121 createdFileText.setEditable(false); 122 123 projectText.setEditable(false); 124 125 fileNameText.setEditable(false); 126 127 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 128 this.setLayout(layout); 129 layout.setHorizontalGroup( 130 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 131 .add(layout.createSequentialGroup() 132 .addContainerGap() 133 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 134 .add(jLabel4) 135 .add(jLabel2) 136 .add(jLabel1) 137 .add(jLabel3)) 138 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 139 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 140 .add(projectText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE) 141 .add(createdFileText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE) 142 .add(fileNameText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE) 143 .add(locationCombo, 0, 287, Short.MAX_VALUE)) 144 .addContainerGap()) 145 ); 146 layout.setVerticalGroup( 147 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 148 .add(layout.createSequentialGroup() 149 .addContainerGap() 150 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 151 .add(jLabel1) 152 .add(fileNameText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 153 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 154 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 155 .add(jLabel2) 156 .add(projectText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 157 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 158 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 159 .add(jLabel3) 160 .add(locationCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 161 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 162 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 163 .add(jLabel4) 164 .add(createdFileText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 165 .addContainerGap(189, Short.MAX_VALUE)) 166 ); 167 } 169 170 private javax.swing.JTextField createdFileText; 172 private javax.swing.JTextField fileNameText; 173 private javax.swing.JLabel jLabel1; 174 private javax.swing.JLabel jLabel2; 175 private javax.swing.JLabel jLabel3; 176 private javax.swing.JLabel jLabel4; 177 private javax.swing.JComboBox locationCombo; 178 private javax.swing.JTextField projectText; 179 181 } 182 183 | Popular Tags |