1 19 20 package org.netbeans.modules.ruby.rubyproject.ui.customizer; 21 22 import java.io.File ; 23 import javax.swing.event.ListDataEvent ; 24 import javax.swing.event.ListDataListener ; 25 import org.openide.filesystems.FileObject; 26 import org.openide.filesystems.FileUtil; 27 import org.openide.util.HelpCtx; 28 import org.openide.util.NbBundle; 29 import org.netbeans.modules.ruby.rubyproject.RubyProject; 30 31 35 public class CustomizerSources extends javax.swing.JPanel implements HelpCtx.Provider { 36 37 public CustomizerSources( RubyProjectProperties uiProperties ) { 38 initComponents(); 39 jScrollPane1.getViewport().setBackground( sourceRoots.getBackground() ); 40 jScrollPane2.getViewport().setBackground( testRoots.getBackground() ); 41 42 sourceRoots.setModel( uiProperties.SOURCE_ROOTS_MODEL ); 43 testRoots.setModel( uiProperties.TEST_ROOTS_MODEL ); 44 sourceRoots.getTableHeader().setReorderingAllowed(false); 45 testRoots.getTableHeader().setReorderingAllowed(false); 46 47 FileObject projectFolder = uiProperties.getProject().getProjectDirectory(); 48 File pf = FileUtil.toFile( projectFolder ); 49 this.projectLocation.setText( pf == null ? "" : pf.getPath() ); 51 52 RubySourceRootsUi.EditMediator emSR = RubySourceRootsUi.registerEditMediator( 53 (RubyProject)uiProperties.getProject(), 54 ((RubyProject)uiProperties.getProject()).getSourceRoots(), 55 sourceRoots, 56 addSourceRoot, 57 removeSourceRoot, 58 upSourceRoot, 59 downSourceRoot); 60 61 RubySourceRootsUi.EditMediator emTSR = RubySourceRootsUi.registerEditMediator( 62 (RubyProject)uiProperties.getProject(), 63 ((RubyProject)uiProperties.getProject()).getTestSourceRoots(), 64 testRoots, 65 addTestRoot, 66 removeTestRoot, 67 upTestRoot, 68 downTestRoot); 69 70 emSR.setRelatedEditMediator( emTSR ); 71 emTSR.setRelatedEditMediator( emSR ); 72 } 73 74 public HelpCtx getHelpCtx() { 75 return new HelpCtx (CustomizerSources.class); 76 } 77 78 83 private void initComponents() { 85 java.awt.GridBagConstraints gridBagConstraints; 86 87 jLabel1 = new javax.swing.JLabel (); 88 projectLocation = new javax.swing.JTextField (); 89 sourceRootsPanel = new javax.swing.JPanel (); 90 jLabel2 = new javax.swing.JLabel (); 91 jScrollPane1 = new javax.swing.JScrollPane (); 92 sourceRoots = new javax.swing.JTable (); 93 addSourceRoot = new javax.swing.JButton (); 94 removeSourceRoot = new javax.swing.JButton (); 95 upSourceRoot = new javax.swing.JButton (); 96 downSourceRoot = new javax.swing.JButton (); 97 testRootsPanel = new javax.swing.JPanel (); 98 jLabel3 = new javax.swing.JLabel (); 99 jScrollPane2 = new javax.swing.JScrollPane (); 100 testRoots = new javax.swing.JTable (); 101 addTestRoot = new javax.swing.JButton (); 102 removeTestRoot = new javax.swing.JButton (); 103 upTestRoot = new javax.swing.JButton (); 104 downTestRoot = new javax.swing.JButton (); 105 jPanel1 = new javax.swing.JPanel (); 106 jPanel2 = new javax.swing.JPanel (); 107 108 setLayout(new java.awt.GridBagLayout ()); 109 110 jLabel1.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_ProjectFolder").charAt(0)); 111 jLabel1.setLabelFor(projectLocation); 112 java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle"); jLabel1.setText(bundle.getString("CTL_ProjectFolder")); gridBagConstraints = new java.awt.GridBagConstraints (); 115 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 116 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 117 add(jLabel1, gridBagConstraints); 118 119 projectLocation.setEditable(false); 120 gridBagConstraints = new java.awt.GridBagConstraints (); 121 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 122 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 123 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 124 gridBagConstraints.weightx = 1.0; 125 add(projectLocation, gridBagConstraints); 126 projectLocation.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_projectLocation")); 128 sourceRootsPanel.setLayout(new java.awt.GridBagLayout ()); 129 130 jLabel2.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_SourceRoots").charAt(0)); 131 jLabel2.setLabelFor(sourceRoots); 132 jLabel2.setText(bundle.getString("CTL_SourceRoots")); gridBagConstraints = new java.awt.GridBagConstraints (); 134 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 135 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 136 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 137 gridBagConstraints.insets = new java.awt.Insets (0, 0, 6, 0); 138 sourceRootsPanel.add(jLabel2, gridBagConstraints); 139 140 sourceRoots.setModel(new javax.swing.table.DefaultTableModel ( 141 new Object [][] { 142 {null, null}, 143 {null, null}, 144 {null, null}, 145 {null, null} 146 }, 147 new String [] { 148 "Package Folder", "Label" 149 } 150 ) { 151 Class [] types = new Class [] { 152 java.lang.Object .class, java.lang.String .class 153 }; 154 boolean[] canEdit = new boolean [] { 155 false, false 156 }; 157 158 public Class getColumnClass(int columnIndex) { 159 return types [columnIndex]; 160 } 161 162 public boolean isCellEditable(int rowIndex, int columnIndex) { 163 return canEdit [columnIndex]; 164 } 165 }); 166 jScrollPane1.setViewportView(sourceRoots); 167 sourceRoots.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_sourceRoots")); 169 gridBagConstraints = new java.awt.GridBagConstraints (); 170 gridBagConstraints.gridx = 0; 171 gridBagConstraints.gridy = 1; 172 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 173 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 174 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 175 gridBagConstraints.weightx = 1.0; 176 gridBagConstraints.weighty = 1.0; 177 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 178 sourceRootsPanel.add(jScrollPane1, gridBagConstraints); 179 180 addSourceRoot.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_AddSourceRoot").charAt(0)); 181 addSourceRoot.setText(bundle.getString("CTL_AddSourceRoot")); gridBagConstraints = new java.awt.GridBagConstraints (); 183 gridBagConstraints.gridx = 1; 184 gridBagConstraints.gridy = 1; 185 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 186 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 187 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 188 sourceRootsPanel.add(addSourceRoot, gridBagConstraints); 189 addSourceRoot.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_addSourceRoot")); 191 removeSourceRoot.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_RemoveSourceRoot").charAt(0)); 192 removeSourceRoot.setText(bundle.getString("CTL_RemoveSourceRoot")); gridBagConstraints = new java.awt.GridBagConstraints (); 194 gridBagConstraints.gridx = 1; 195 gridBagConstraints.gridy = 2; 196 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 197 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 198 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 199 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 200 sourceRootsPanel.add(removeSourceRoot, gridBagConstraints); 201 removeSourceRoot.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_removeSourceRoot")); 203 upSourceRoot.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_UpSourceRoot").charAt(0)); 204 upSourceRoot.setText(bundle.getString("CTL_UpSourceRoot")); gridBagConstraints = new java.awt.GridBagConstraints (); 206 gridBagConstraints.gridx = 1; 207 gridBagConstraints.gridy = 3; 208 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 209 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 210 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 211 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 212 sourceRootsPanel.add(upSourceRoot, gridBagConstraints); 213 upSourceRoot.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_upSourceRoot")); 215 downSourceRoot.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_DownSourceRoot").charAt(0)); 216 downSourceRoot.setText(bundle.getString("CTL_DownSourceRoot")); gridBagConstraints = new java.awt.GridBagConstraints (); 218 gridBagConstraints.gridx = 1; 219 gridBagConstraints.gridy = 4; 220 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 221 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 222 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 223 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 224 sourceRootsPanel.add(downSourceRoot, gridBagConstraints); 225 downSourceRoot.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_downSourceRoot")); 227 gridBagConstraints = new java.awt.GridBagConstraints (); 228 gridBagConstraints.gridx = 0; 229 gridBagConstraints.gridy = 1; 230 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 231 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 232 gridBagConstraints.weightx = 1.0; 233 gridBagConstraints.weighty = 0.45; 234 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 235 add(sourceRootsPanel, gridBagConstraints); 236 237 testRootsPanel.setLayout(new java.awt.GridBagLayout ()); 238 239 jLabel3.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_TestRoots").charAt(0)); 240 jLabel3.setLabelFor(testRoots); 241 jLabel3.setText(bundle.getString("CTL_TestRoots")); gridBagConstraints = new java.awt.GridBagConstraints (); 243 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 244 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 245 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 246 gridBagConstraints.weightx = 1.0; 247 gridBagConstraints.insets = new java.awt.Insets (0, 0, 6, 0); 248 testRootsPanel.add(jLabel3, gridBagConstraints); 249 250 testRoots.setModel(new javax.swing.table.DefaultTableModel ( 251 new Object [][] { 252 {null, null}, 253 {null, null}, 254 {null, null}, 255 {null, null} 256 }, 257 new String [] { 258 "Package Folder", "Label" 259 } 260 ) { 261 Class [] types = new Class [] { 262 java.lang.Object .class, java.lang.String .class 263 }; 264 boolean[] canEdit = new boolean [] { 265 false, false 266 }; 267 268 public Class getColumnClass(int columnIndex) { 269 return types [columnIndex]; 270 } 271 272 public boolean isCellEditable(int rowIndex, int columnIndex) { 273 return canEdit [columnIndex]; 274 } 275 }); 276 jScrollPane2.setViewportView(testRoots); 277 testRoots.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_testRoots")); 279 gridBagConstraints = new java.awt.GridBagConstraints (); 280 gridBagConstraints.gridx = 0; 281 gridBagConstraints.gridy = 1; 282 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 283 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 284 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 285 gridBagConstraints.weightx = 1.0; 286 gridBagConstraints.weighty = 1.0; 287 testRootsPanel.add(jScrollPane2, gridBagConstraints); 288 289 addTestRoot.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_AddTestRoot").charAt(0)); 290 addTestRoot.setText(bundle.getString("CTL_AddTestRoot")); gridBagConstraints = new java.awt.GridBagConstraints (); 292 gridBagConstraints.gridx = 1; 293 gridBagConstraints.gridy = 1; 294 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 295 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 296 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 297 gridBagConstraints.insets = new java.awt.Insets (0, 12, 6, 0); 298 testRootsPanel.add(addTestRoot, gridBagConstraints); 299 addTestRoot.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_addTestRoot")); 301 removeTestRoot.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_RemoveTestRoot").charAt(0)); 302 removeTestRoot.setText(bundle.getString("CTL_RemoveTestRoot")); gridBagConstraints = new java.awt.GridBagConstraints (); 304 gridBagConstraints.gridx = 1; 305 gridBagConstraints.gridy = 2; 306 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 307 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 308 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 309 gridBagConstraints.insets = new java.awt.Insets (0, 12, 12, 0); 310 testRootsPanel.add(removeTestRoot, gridBagConstraints); 311 removeTestRoot.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_removeTestRoot")); 313 upTestRoot.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_UpTestRoot").charAt(0)); 314 upTestRoot.setText(bundle.getString("CTL_UpTestRoot")); gridBagConstraints = new java.awt.GridBagConstraints (); 316 gridBagConstraints.gridx = 1; 317 gridBagConstraints.gridy = 3; 318 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 319 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 320 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 321 gridBagConstraints.insets = new java.awt.Insets (0, 12, 6, 0); 322 testRootsPanel.add(upTestRoot, gridBagConstraints); 323 upTestRoot.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_upTestRoot")); 325 downTestRoot.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle").getString("MNE_DownTestRoot").charAt(0)); 326 downTestRoot.setText(bundle.getString("CTL_DownTestRoot")); gridBagConstraints = new java.awt.GridBagConstraints (); 328 gridBagConstraints.gridx = 1; 329 gridBagConstraints.gridy = 4; 330 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 331 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 332 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 333 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 334 testRootsPanel.add(downTestRoot, gridBagConstraints); 335 downTestRoot.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizerSources_downTestRoot")); 337 gridBagConstraints = new java.awt.GridBagConstraints (); 338 gridBagConstraints.gridx = 0; 339 gridBagConstraints.gridy = 2; 340 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 341 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 342 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 343 gridBagConstraints.weightx = 1.0; 344 gridBagConstraints.weighty = 0.45; 345 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 346 add(testRootsPanel, gridBagConstraints); 347 348 jPanel1.setLayout(new java.awt.GridBagLayout ()); 349 gridBagConstraints = new java.awt.GridBagConstraints (); 350 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 351 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 352 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 353 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 354 gridBagConstraints.weightx = 1.0; 355 jPanel1.add(jPanel2, gridBagConstraints); 356 357 gridBagConstraints = new java.awt.GridBagConstraints (); 358 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 359 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 360 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 361 gridBagConstraints.weightx = 1.0; 362 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 363 add(jPanel1, gridBagConstraints); 364 } 366 367 private javax.swing.JButton addSourceRoot; 369 private javax.swing.JButton addTestRoot; 370 private javax.swing.JButton downSourceRoot; 371 private javax.swing.JButton downTestRoot; 372 private javax.swing.JLabel jLabel1; 373 private javax.swing.JLabel jLabel2; 374 private javax.swing.JLabel jLabel3; 375 private javax.swing.JPanel jPanel1; 376 private javax.swing.JPanel jPanel2; 377 private javax.swing.JScrollPane jScrollPane1; 378 private javax.swing.JScrollPane jScrollPane2; 379 private javax.swing.JTextField projectLocation; 380 private javax.swing.JButton removeSourceRoot; 381 private javax.swing.JButton removeTestRoot; 382 private javax.swing.JTable sourceRoots; 383 private javax.swing.JPanel sourceRootsPanel; 384 private javax.swing.JTable testRoots; 385 private javax.swing.JPanel testRootsPanel; 386 private javax.swing.JButton upSourceRoot; 387 private javax.swing.JButton upTestRoot; 388 390 } 391 | Popular Tags |