1 19 20 package org.netbeans.modules.java.j2seproject.ui.customizer; 21 22 import java.io.File ; 23 import javax.swing.JFileChooser ; 24 import javax.swing.filechooser.FileFilter ; 25 import org.openide.filesystems.FileUtil; 26 import org.openide.util.HelpCtx; 27 import org.openide.util.NbBundle; 28 29 35 public class CustomizerApplication extends javax.swing.JPanel implements HelpCtx.Provider { 36 37 private File lastImageFolder; 38 39 40 public CustomizerApplication(J2SEProjectProperties props) { 41 initComponents(); 42 titleTextField.setDocument(props.APPLICATION_TITLE_DOC); 43 vendorTextField.setDocument(props.APPLICATION_VENDOR_DOC); 44 descTextArea.setDocument(props.APPLICATION_DESC_DOC); 45 homepageTextField.setDocument(props.APPLICATION_HOMEPAGE_DOC); 46 splashTextField.setDocument(props.APPLICATION_SPLASH_DOC); 47 } 48 49 54 private void initComponents() { 56 java.awt.GridBagConstraints gridBagConstraints; 57 58 panelDescLabel = new javax.swing.JLabel (); 59 titleLabel = new javax.swing.JLabel (); 60 vendorLabel = new javax.swing.JLabel (); 61 descLabel = new javax.swing.JLabel (); 62 homepageLabel = new javax.swing.JLabel (); 63 splashLabel = new javax.swing.JLabel (); 64 titleTextField = new javax.swing.JTextField (); 65 vendorTextField = new javax.swing.JTextField (); 66 homepageTextField = new javax.swing.JTextField (); 67 splashTextField = new javax.swing.JTextField (); 68 browseButton = new javax.swing.JButton (); 69 jScrollPane1 = new javax.swing.JScrollPane (); 70 descTextArea = new javax.swing.JTextArea (); 71 72 setLayout(new java.awt.GridBagLayout ()); 73 74 panelDescLabel.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.panelDescLabel.text")); gridBagConstraints = new java.awt.GridBagConstraints (); 76 gridBagConstraints.gridx = 0; 77 gridBagConstraints.gridy = 0; 78 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 79 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 80 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 81 gridBagConstraints.insets = new java.awt.Insets (0, 0, 10, 0); 82 add(panelDescLabel, gridBagConstraints); 83 84 titleLabel.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.titleLabel.text")); gridBagConstraints = new java.awt.GridBagConstraints (); 86 gridBagConstraints.gridx = 0; 87 gridBagConstraints.gridy = 1; 88 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 89 gridBagConstraints.insets = new java.awt.Insets (9, 0, 0, 0); 90 add(titleLabel, gridBagConstraints); 91 92 vendorLabel.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.vendorLabel.text")); gridBagConstraints = new java.awt.GridBagConstraints (); 94 gridBagConstraints.gridx = 0; 95 gridBagConstraints.gridy = 2; 96 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 97 gridBagConstraints.insets = new java.awt.Insets (7, 0, 0, 0); 98 add(vendorLabel, gridBagConstraints); 99 100 descLabel.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.descLabel.text")); gridBagConstraints = new java.awt.GridBagConstraints (); 102 gridBagConstraints.gridx = 0; 103 gridBagConstraints.gridy = 3; 104 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 105 gridBagConstraints.insets = new java.awt.Insets (7, 0, 0, 0); 106 add(descLabel, gridBagConstraints); 107 108 homepageLabel.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.homepageLabel.text")); gridBagConstraints = new java.awt.GridBagConstraints (); 110 gridBagConstraints.gridx = 0; 111 gridBagConstraints.gridy = 4; 112 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 113 gridBagConstraints.insets = new java.awt.Insets (8, 0, 0, 0); 114 add(homepageLabel, gridBagConstraints); 115 116 splashLabel.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.splashLabel.text")); gridBagConstraints = new java.awt.GridBagConstraints (); 118 gridBagConstraints.gridx = 0; 119 gridBagConstraints.gridy = 5; 120 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 121 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 122 gridBagConstraints.weighty = 1.0; 123 gridBagConstraints.insets = new java.awt.Insets (8, 0, 0, 0); 124 add(splashLabel, gridBagConstraints); 125 126 titleTextField.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.titleTextField.text")); gridBagConstraints = new java.awt.GridBagConstraints (); 128 gridBagConstraints.gridx = 1; 129 gridBagConstraints.gridy = 1; 130 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 131 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 132 gridBagConstraints.weightx = 1.0; 133 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 134 add(titleTextField, gridBagConstraints); 135 136 vendorTextField.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.vendorTextField.text")); gridBagConstraints = new java.awt.GridBagConstraints (); 138 gridBagConstraints.gridx = 1; 139 gridBagConstraints.gridy = 2; 140 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 141 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 142 gridBagConstraints.weightx = 1.0; 143 gridBagConstraints.insets = new java.awt.Insets (5, 6, 0, 0); 144 add(vendorTextField, gridBagConstraints); 145 146 homepageTextField.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.homepageTextField.text")); gridBagConstraints = new java.awt.GridBagConstraints (); 148 gridBagConstraints.gridx = 1; 149 gridBagConstraints.gridy = 4; 150 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 151 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 152 gridBagConstraints.weightx = 1.0; 153 gridBagConstraints.insets = new java.awt.Insets (5, 6, 0, 0); 154 add(homepageTextField, gridBagConstraints); 155 156 splashTextField.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.splashTextField.text")); gridBagConstraints = new java.awt.GridBagConstraints (); 158 gridBagConstraints.gridx = 1; 159 gridBagConstraints.gridy = 5; 160 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 161 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 162 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 163 gridBagConstraints.weightx = 1.0; 164 gridBagConstraints.weighty = 1.0; 165 gridBagConstraints.insets = new java.awt.Insets (5, 6, 0, 0); 166 add(splashTextField, gridBagConstraints); 167 168 browseButton.setText(org.openide.util.NbBundle.getMessage(CustomizerApplication.class, "CustomizerApplication.browseButton.text")); browseButton.addActionListener(new java.awt.event.ActionListener () { 170 public void actionPerformed(java.awt.event.ActionEvent evt) { 171 browseButtonActionPerformed(evt); 172 } 173 }); 174 gridBagConstraints = new java.awt.GridBagConstraints (); 175 gridBagConstraints.gridx = 2; 176 gridBagConstraints.gridy = 5; 177 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 178 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 179 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 180 gridBagConstraints.weighty = 1.0; 181 gridBagConstraints.insets = new java.awt.Insets (3, 6, 0, 0); 182 add(browseButton, gridBagConstraints); 183 184 descTextArea.setColumns(20); 185 descTextArea.setRows(4); 186 jScrollPane1.setViewportView(descTextArea); 187 188 gridBagConstraints = new java.awt.GridBagConstraints (); 189 gridBagConstraints.gridx = 1; 190 gridBagConstraints.gridy = 3; 191 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 192 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 193 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 194 add(jScrollPane1, gridBagConstraints); 195 } 197 private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser (); 199 FileUtil.preventFileChooserSymlinkTraversal(chooser, null); 200 chooser.setFileSelectionMode (JFileChooser.FILES_AND_DIRECTORIES); 201 chooser.setMultiSelectionEnabled(false); 202 chooser.setFileFilter(new SplashFileFilter()); 203 if (lastImageFolder != null) { 204 chooser.setSelectedFile(lastImageFolder); 205 } else { 206 } 208 chooser.setDialogTitle(NbBundle.getMessage(CustomizerApplication.class, "LBL_Select_Splash_Image")); 209 if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { 210 File file = FileUtil.normalizeFile(chooser.getSelectedFile()); 211 splashTextField.setText(file.getAbsolutePath()); 212 lastImageFolder = file.getParentFile(); 213 } 214 } 216 private static class SplashFileFilter extends FileFilter { 217 218 public boolean accept(File f) { 220 if (f.isDirectory()) { 221 return true; 222 } 223 String name = f.getName(); 224 int index = name.lastIndexOf('.'); 225 if (index > 0 && index < name.length() - 1) { 226 String ext = name.substring(index+1).toLowerCase(); 227 if ("gif".equals(ext) || "png".equals(ext) || "jpg".equals(ext)) { 228 return true; 229 } 230 } 231 return false; 232 } 233 234 public String getDescription() { 235 return "Splash image files"; 236 } 237 238 } 239 240 private javax.swing.JButton browseButton; 242 private javax.swing.JLabel descLabel; 243 private javax.swing.JTextArea descTextArea; 244 private javax.swing.JLabel homepageLabel; 245 private javax.swing.JTextField homepageTextField; 246 private javax.swing.JScrollPane jScrollPane1; 247 private javax.swing.JLabel panelDescLabel; 248 private javax.swing.JLabel splashLabel; 249 private javax.swing.JTextField splashTextField; 250 private javax.swing.JLabel titleLabel; 251 private javax.swing.JTextField titleTextField; 252 private javax.swing.JLabel vendorLabel; 253 private javax.swing.JTextField vendorTextField; 254 256 public HelpCtx getHelpCtx() { 257 return new HelpCtx(CustomizerApplication.class); 258 } 259 260 } 261 | Popular Tags |