1 19 20 package org.netbeans.modules.j2ee.earproject.ui.customizer; 21 22 import java.io.File ; 23 import java.util.ArrayList ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 import javax.swing.DefaultListModel ; 27 import javax.swing.JPanel ; 28 import org.netbeans.api.java.platform.JavaPlatform; 29 import org.netbeans.api.java.platform.JavaPlatformManager; 30 import org.netbeans.api.java.platform.PlatformsCustomizer; 31 import org.netbeans.api.java.platform.Specification; 32 import org.openide.filesystems.FileObject; 33 import org.openide.filesystems.FileUtil; 34 import org.openide.util.HelpCtx; 35 import org.openide.util.NbBundle; 36 37 42 public class CustomizerGeneral extends JPanel implements ArchiveCustomizerPanel, HelpCtx.Provider { 43 44 private EarProjectProperties projProperties; 45 private VisualPropertySupport vps; 46 47 48 private boolean initialized; 49 50 51 public CustomizerGeneral(EarProjectProperties projProperties) { 52 initComponents(); 53 this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerGeneral.class, "ACS_CustomizeGeneral_A11YDesc")); jButton1.setVisible(false); 55 jComboBoxTarget.setVisible(false); 56 jLabelTarget.setVisible(false); 57 this.projProperties = projProperties; 58 vps = new VisualPropertySupport(projProperties); 59 } 60 61 public void initValues() { 62 if (initialized) { 63 return; 64 } 65 FileObject projectFolder = projProperties.getProject().getProjectDirectory(); 66 File pf = FileUtil.toFile(projectFolder); 67 jTextFieldProjectFolder.setText(pf == null ? "" : pf.getPath()); 69 71 initPlatforms(vps); 73 74 DefaultListModel lm = new DefaultListModel (); 76 for( Iterator it = projProperties.getSortedSubprojectsList().iterator(); it.hasNext(); ) { 77 lm.addElement( it.next() ); 78 } 79 initialized = true; 80 } 82 83 private void initPlatforms(VisualPropertySupport vps) { 84 JavaPlatform[] platforms = JavaPlatformManager.getDefault().getInstalledPlatforms(); 86 List <String > platformNames = new ArrayList <String >(); 87 for( int i = 0; i < platforms.length; i++ ) { 88 Specification spec = platforms[i].getSpecification(); 89 if ("j2se".equalsIgnoreCase (spec.getName())) { platformNames.add(platforms[i].getDisplayName()); 91 } 92 } 93 vps.register(jComboBoxTarget, platformNames.toArray( 94 new String [platformNames.size()]), EarProjectProperties.JAVA_PLATFORM); 95 } 96 97 98 103 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 105 106 jLabelProjectName = new javax.swing.JLabel (); 107 jTextFieldProjectFolder = new javax.swing.JTextField (); 108 jLabelTarget = new javax.swing.JLabel (); 109 jComboBoxTarget = new javax.swing.JComboBox (); 110 jButton1 = new javax.swing.JButton (); 111 jPanel1 = new javax.swing.JPanel (); 112 113 setLayout(new java.awt.GridBagLayout ()); 114 115 jLabelProjectName.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_ProjectFolder_LabelMnemonic").charAt(0)); 116 jLabelProjectName.setLabelFor(jTextFieldProjectFolder); 117 jLabelProjectName.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_ProjectFolder_JLabel")); 118 jLabelProjectName.setVerticalAlignment(javax.swing.SwingConstants.TOP); 119 jLabelProjectName.setAlignmentY(0.0F); 120 jLabelProjectName.setVerticalTextPosition(javax.swing.SwingConstants.TOP); 121 gridBagConstraints = new java.awt.GridBagConstraints (); 122 gridBagConstraints.gridx = 0; 123 gridBagConstraints.gridy = 0; 124 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 125 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 12); 126 add(jLabelProjectName, gridBagConstraints); 127 128 jTextFieldProjectFolder.setEditable(false); 129 gridBagConstraints = new java.awt.GridBagConstraints (); 130 gridBagConstraints.gridx = 1; 131 gridBagConstraints.gridy = 0; 132 gridBagConstraints.gridwidth = 2; 133 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 134 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 135 gridBagConstraints.insets = new java.awt.Insets (12, 0, 12, 12); 136 add(jTextFieldProjectFolder, gridBagConstraints); 137 jTextFieldProjectFolder.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACS_CustomizeGeneral_ProjectFolder_A11YDesc")); 138 139 jLabelTarget.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_Platform_LabelMnemonic").charAt(0)); 140 jLabelTarget.setLabelFor(jComboBoxTarget); 141 jLabelTarget.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_Platform_JLabel")); 142 gridBagConstraints = new java.awt.GridBagConstraints (); 143 gridBagConstraints.gridx = 0; 144 gridBagConstraints.gridy = 1; 145 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 146 gridBagConstraints.insets = new java.awt.Insets (0, 12, 12, 12); 147 add(jLabelTarget, gridBagConstraints); 148 149 gridBagConstraints = new java.awt.GridBagConstraints (); 150 gridBagConstraints.gridx = 1; 151 gridBagConstraints.gridy = 1; 152 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 153 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 154 gridBagConstraints.weightx = 1.0; 155 gridBagConstraints.insets = new java.awt.Insets (0, 0, 12, 0); 156 add(jComboBoxTarget, gridBagConstraints); 157 jComboBoxTarget.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACS_CustomizeGeneral_Platform_A11YDesc")); 158 159 jButton1.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_PlatformEdit_LabelMnemonic").charAt(0)); 160 jButton1.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_Platform_JButton")); 161 jButton1.addActionListener(new java.awt.event.ActionListener () { 162 public void actionPerformed(java.awt.event.ActionEvent evt) { 163 createNewPlatform(evt); 164 } 165 }); 166 167 gridBagConstraints = new java.awt.GridBagConstraints (); 168 gridBagConstraints.gridx = 2; 169 gridBagConstraints.gridy = 1; 170 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 171 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST; 172 gridBagConstraints.insets = new java.awt.Insets (0, 6, 12, 12); 173 add(jButton1, gridBagConstraints); 174 jButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACS_CustomizeGeneral_PlatformEdit_A11YDesc")); 175 176 gridBagConstraints = new java.awt.GridBagConstraints (); 177 gridBagConstraints.gridx = 0; 178 gridBagConstraints.gridy = 2; 179 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 180 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 181 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 182 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 183 gridBagConstraints.weightx = 1.0; 184 gridBagConstraints.weighty = 1.0; 185 add(jPanel1, gridBagConstraints); 186 187 } 189 private void createNewPlatform(java.awt.event.ActionEvent evt) { PlatformsCustomizer.showCustomizer(null); 191 initPlatforms (vps); 192 } 194 private javax.swing.JButton jButton1; 196 private javax.swing.JComboBox jComboBoxTarget; 197 private javax.swing.JLabel jLabelProjectName; 198 private javax.swing.JLabel jLabelTarget; 199 private javax.swing.JPanel jPanel1; 200 private javax.swing.JTextField jTextFieldProjectFolder; 201 203 206 public HelpCtx getHelpCtx() { 207 return new HelpCtx(this.getClass()); 208 } 209 210 } 211 | Popular Tags |