1 19 20 package org.netbeans.modules.apisupport.project.ui.customizer; 21 22 import java.awt.Dialog ; 23 import java.awt.Dimension ; 24 import java.awt.event.KeyEvent ; 25 import java.awt.event.MouseAdapter ; 26 import java.awt.event.MouseEvent ; 27 import java.beans.PropertyChangeEvent ; 28 import java.beans.PropertyChangeListener ; 29 import javax.swing.AbstractAction ; 30 import javax.swing.Action ; 31 import javax.swing.JButton ; 32 import javax.swing.JCheckBox ; 33 import javax.swing.KeyStroke ; 34 import javax.swing.ListSelectionModel ; 35 import javax.swing.event.DocumentEvent ; 36 import javax.swing.event.ListSelectionListener ; 37 import org.netbeans.modules.apisupport.project.ui.UIUtil; 38 import org.netbeans.spi.project.ui.support.ProjectCustomizer; 39 import org.openide.DialogDescriptor; 40 import org.openide.DialogDisplayer; 41 import org.openide.util.HelpCtx; 42 import org.openide.util.NbBundle; 43 44 49 final class CustomizerVersioning extends NbPropertyPanel.Single { 50 51 private static final int CHECKBOX_WIDTH = new JCheckBox ().getWidth(); 52 53 private boolean lastAppImplChecked; 54 55 private Dimension lastSize; 56 private ProjectCustomizer.Category cat; 57 BasicCustomizer.SubCategoryProvider provider; 58 59 60 61 CustomizerVersioning(SingleModuleProperties props, ProjectCustomizer.Category cat, BasicCustomizer.SubCategoryProvider prov) { 62 super(props, CustomizerVersioning.class); 63 this.cat = cat; 64 initComponents(); 65 initAccesibility(); 66 initPublicPackageTable(); 67 refresh(); 68 attachListeners(); 69 checkValidity(); 70 provider = prov; 71 } 72 73 public void addNotify() { 74 super.addNotify(); 75 if (provider != null) { 76 showSubCategory(provider); 77 provider = null; 79 } 80 } 81 82 void refresh() { 83 UIUtil.setText(majorRelVerValue, getProperties().getMajorReleaseVersion()); 84 UIUtil.setText(tokensValue, getProperties().getProvidedTokens()); 85 String specVersion = getProperties().getSpecificationVersion(); 86 if (null == specVersion || "".equals(specVersion)) { appendImpl.setSelected(true); 88 UIUtil.setText(specificationVerValue, getProperty(SingleModuleProperties.SPEC_VERSION_BASE)); 89 } else { 90 UIUtil.setText(specificationVerValue, specVersion); 91 } 92 UIUtil.setText(implVerValue, getProperties().getImplementationVersion()); 93 friendsList.setModel(getProperties().getFriendListModel()); 94 UIUtil.setText(cnbValue, getProperties().getCodeNameBase()); 95 regularMod.setSelected(true); 96 autoloadMod.setSelected(getBooleanProperty(SingleModuleProperties.IS_AUTOLOAD)); 97 eagerMod.setSelected(getBooleanProperty(SingleModuleProperties.IS_EAGER)); 98 removeFriendButton.setEnabled(false); 99 updateAppendImpl(); 100 } 101 102 private void attachListeners() { 103 implVerValue.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() { 104 public void insertUpdate(DocumentEvent e) { 105 updateAppendImpl(); 106 } 107 }); 108 friendsList.addListSelectionListener(new ListSelectionListener () { 109 public void valueChanged(javax.swing.event.ListSelectionEvent e) { 110 if (!e.getValueIsAdjusting()) { 111 removeFriendButton.setEnabled(friendsList.getSelectedIndex() != -1); 112 } 113 } 114 }); 115 majorRelVerValue.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() { 116 public void insertUpdate(DocumentEvent e) { 117 checkValidity(); 118 } 119 }); 120 implVerValue.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() { 121 public void insertUpdate(DocumentEvent e) { 122 updateAppendImpl(); 123 checkValidity(); 124 } 125 }); 126 } 127 128 boolean isCustomizerValid() { 129 return checkMajorReleaseVersion(); 130 } 131 132 private boolean checkMajorReleaseVersion() { 133 boolean valid; 134 String mrv = majorRelVerValue.getText().trim(); 135 try { 136 valid = (mrv.length() == 0 || Integer.parseInt(mrv) >= 0); 137 } catch (NumberFormatException nfe) { 138 valid = false; 139 } 140 return valid; 141 } 142 143 protected void checkValidity() { 144 exportOnlyToFriend.setSelected(getFriendModel().getSize() > 0); 145 if (!checkMajorReleaseVersion()) { 147 cat.setErrorMessage(getMessage("MSG_MajorReleaseVersionIsInvalid")); cat.setValid(true); 149 } else if (exportOnlyToFriend.isSelected() && getPublicPackagesModel().getSelectedPackages().length < 1) { 150 cat.setErrorMessage(getMessage("MSG_PublicPackageMustBeSelected")); 151 cat.setValid(false); 152 } else if (implVerValue.getText().matches(".*[^0-9].*")) { cat.setErrorMessage(getMessage("MSG_integer_impl_version_recommended")); 154 cat.setValid(true); 155 } else { 156 cat.setErrorMessage(null); 157 cat.setValid(true); 158 } 159 } 160 161 private void initPublicPackageTable() { 162 publicPkgsTable.setModel(getProperties().getPublicPackagesModel()); 163 publicPkgsTable.getColumnModel().getColumn(0).setMaxWidth(CHECKBOX_WIDTH + 20); 164 publicPkgsTable.setRowHeight(publicPkgsTable.getFontMetrics(publicPkgsTable.getFont()).getHeight() + 165 (2 * publicPkgsTable.getRowMargin())); 166 publicPkgsTable.setTableHeader(null); 167 publicPkgsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 168 publicPkgsSP.getViewport().setBackground(publicPkgsTable.getBackground()); 169 final Action switchAction = new AbstractAction () { 170 public void actionPerformed(java.awt.event.ActionEvent e) { 171 int row = publicPkgsTable.getSelectedRow(); 172 if (row == -1) { 173 return; 175 } 176 Boolean b = (Boolean ) publicPkgsTable. 177 getValueAt(row, 0); 178 publicPkgsTable.setValueAt(Boolean.valueOf(!b.booleanValue()), 179 row, 0); 180 checkForm(); 181 } 182 }; 183 publicPkgsTable.addMouseListener(new MouseAdapter () { 184 public void mouseClicked(MouseEvent e) { 185 switchAction.actionPerformed(null); 186 } 187 }); 188 publicPkgsTable.getInputMap().put( 189 KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "startEditing"); publicPkgsTable.getActionMap().put("startEditing", switchAction); } 192 193 private void updateAppendImpl() { 194 boolean isImplVerFiled = !"".equals(implVerValue.getText().trim()); boolean shouldEnable = isImplVerFiled || getProperties().dependingOnImplDependency(); 196 if (shouldEnable && !appendImpl.isEnabled()) { 197 appendImpl.setEnabled(true); 198 appendImpl.setSelected(lastAppImplChecked); 199 } else if (!shouldEnable && appendImpl.isEnabled()) { 200 appendImpl.setEnabled(false); 201 lastAppImplChecked = appendImpl.isSelected(); 202 appendImpl.setSelected(false); 203 } 204 } 205 206 public void store() { 207 getProperties().setMajorReleaseVersion(majorRelVerValue.getText().trim()); 208 String specVer = specificationVerValue.getText().trim(); 209 if (appendImpl.isSelected()) { 210 getProperties().setSpecificationVersion(""); setProperty(SingleModuleProperties.SPEC_VERSION_BASE, specVer); 212 } else { 213 getProperties().setSpecificationVersion(specVer); 214 setProperty(SingleModuleProperties.SPEC_VERSION_BASE, ""); } 216 getProperties().setImplementationVersion(implVerValue.getText().trim()); 217 getProperties().setProvidedTokens(tokensValue.getText().trim()); 218 setBooleanProperty(SingleModuleProperties.IS_AUTOLOAD, autoloadMod.isSelected()); 219 setBooleanProperty(SingleModuleProperties.IS_EAGER, eagerMod.isSelected()); 220 } 221 222 public void propertyChange(PropertyChangeEvent evt) { 223 String pName = evt.getPropertyName(); 224 if (SingleModuleProperties.DEPENDENCIES_PROPERTY == pName) { 225 updateAppendImpl(); 226 } else if (ModuleProperties.PROPERTIES_REFRESHED == pName) { 227 refresh(); 228 checkForm(); 229 } 230 } 231 232 private CustomizerComponentFactory.FriendListModel getFriendModel() { 233 return (CustomizerComponentFactory.FriendListModel) friendsList.getModel(); 234 } 235 236 private CustomizerComponentFactory.PublicPackagesTableModel getPublicPackagesModel() { 237 return (CustomizerComponentFactory.PublicPackagesTableModel) publicPkgsTable.getModel(); 238 } 239 240 245 private void initComponents() { 247 java.awt.GridBagConstraints gridBagConstraints; 248 249 moduleTypeGroup = new javax.swing.ButtonGroup (); 250 cnb = new javax.swing.JLabel (); 251 cnbValue = new javax.swing.JTextField (); 252 majorRelVer = new javax.swing.JLabel (); 253 majorRelVerValue = new javax.swing.JTextField (); 254 specificationVer = new javax.swing.JLabel (); 255 specificationVerValue = new javax.swing.JTextField (); 256 implVer = new javax.swing.JLabel (); 257 implVerValue = new javax.swing.JTextField (); 258 tokens = new javax.swing.JLabel (); 259 tokensValue = new javax.swing.JTextField (); 260 appendImpl = new javax.swing.JCheckBox (); 261 publicPkgs = new javax.swing.JLabel (); 262 publicPkgsSP = new javax.swing.JScrollPane (); 263 publicPkgsTable = new javax.swing.JTable (); 264 bottomPanel = new javax.swing.JPanel (); 265 buttonPanel = new javax.swing.JPanel (); 266 addFriendButton = new javax.swing.JButton (); 267 removeFriendButton = new javax.swing.JButton (); 268 filler1 = new javax.swing.JLabel (); 269 friendsSP = new javax.swing.JScrollPane (); 270 friendsList = new javax.swing.JList (); 271 exportOnlyToFriend = new javax.swing.JCheckBox (); 272 typePanel = new javax.swing.JPanel (); 273 regularMod = new javax.swing.JRadioButton (); 274 autoloadMod = new javax.swing.JRadioButton (); 275 eagerMod = new javax.swing.JRadioButton (); 276 typeTxt = new javax.swing.JLabel (); 277 278 setLayout(new java.awt.GridBagLayout ()); 279 280 cnb.setLabelFor(cnbValue); 281 org.openide.awt.Mnemonics.setLocalizedText(cnb, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_CNB")); 282 gridBagConstraints = new java.awt.GridBagConstraints (); 283 gridBagConstraints.gridx = 0; 284 gridBagConstraints.gridy = 0; 285 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 286 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 287 add(cnb, gridBagConstraints); 288 289 cnbValue.setEditable(false); 290 gridBagConstraints = new java.awt.GridBagConstraints (); 291 gridBagConstraints.gridx = 1; 292 gridBagConstraints.gridy = 0; 293 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 294 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 295 gridBagConstraints.weightx = 1.0; 296 add(cnbValue, gridBagConstraints); 297 298 majorRelVer.setLabelFor(majorRelVerValue); 299 org.openide.awt.Mnemonics.setLocalizedText(majorRelVer, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_MajorReleaseVersion")); 300 gridBagConstraints = new java.awt.GridBagConstraints (); 301 gridBagConstraints.gridx = 0; 302 gridBagConstraints.gridy = 1; 303 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 304 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 305 add(majorRelVer, gridBagConstraints); 306 307 gridBagConstraints = new java.awt.GridBagConstraints (); 308 gridBagConstraints.gridx = 1; 309 gridBagConstraints.gridy = 1; 310 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 311 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 312 gridBagConstraints.weightx = 1.0; 313 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 314 add(majorRelVerValue, gridBagConstraints); 315 316 specificationVer.setLabelFor(specificationVerValue); 317 org.openide.awt.Mnemonics.setLocalizedText(specificationVer, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_SpecificationVersion")); 318 gridBagConstraints = new java.awt.GridBagConstraints (); 319 gridBagConstraints.gridx = 0; 320 gridBagConstraints.gridy = 2; 321 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 322 gridBagConstraints.insets = new java.awt.Insets (24, 0, 0, 12); 323 add(specificationVer, gridBagConstraints); 324 325 gridBagConstraints = new java.awt.GridBagConstraints (); 326 gridBagConstraints.gridx = 1; 327 gridBagConstraints.gridy = 2; 328 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 329 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 330 gridBagConstraints.weightx = 1.0; 331 gridBagConstraints.insets = new java.awt.Insets (24, 0, 0, 0); 332 add(specificationVerValue, gridBagConstraints); 333 334 implVer.setLabelFor(implVerValue); 335 org.openide.awt.Mnemonics.setLocalizedText(implVer, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_ImplementationVersion")); 336 gridBagConstraints = new java.awt.GridBagConstraints (); 337 gridBagConstraints.gridx = 0; 338 gridBagConstraints.gridy = 4; 339 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 340 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 341 add(implVer, gridBagConstraints); 342 343 gridBagConstraints = new java.awt.GridBagConstraints (); 344 gridBagConstraints.gridx = 1; 345 gridBagConstraints.gridy = 4; 346 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 347 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 348 gridBagConstraints.weightx = 1.0; 349 add(implVerValue, gridBagConstraints); 350 351 tokens.setLabelFor(tokensValue); 352 org.openide.awt.Mnemonics.setLocalizedText(tokens, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_ProvidedTokens")); 353 gridBagConstraints = new java.awt.GridBagConstraints (); 354 gridBagConstraints.gridx = 0; 355 gridBagConstraints.gridy = 12; 356 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 357 gridBagConstraints.insets = new java.awt.Insets (18, 0, 0, 12); 358 add(tokens, gridBagConstraints); 359 360 gridBagConstraints = new java.awt.GridBagConstraints (); 361 gridBagConstraints.gridx = 1; 362 gridBagConstraints.gridy = 12; 363 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 364 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 365 gridBagConstraints.weightx = 1.0; 366 gridBagConstraints.insets = new java.awt.Insets (18, 0, 0, 0); 367 add(tokensValue, gridBagConstraints); 368 369 org.openide.awt.Mnemonics.setLocalizedText(appendImpl, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_AppendImplementation")); 370 appendImpl.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 371 appendImpl.setMargin(new java.awt.Insets (0, 0, 0, 0)); 372 gridBagConstraints = new java.awt.GridBagConstraints (); 373 gridBagConstraints.gridx = 0; 374 gridBagConstraints.gridy = 3; 375 gridBagConstraints.gridwidth = 2; 376 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 377 gridBagConstraints.insets = new java.awt.Insets (6, 0, 6, 0); 378 add(appendImpl, gridBagConstraints); 379 380 publicPkgs.setLabelFor(publicPkgsTable); 381 org.openide.awt.Mnemonics.setLocalizedText(publicPkgs, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_PublicPackages")); 382 gridBagConstraints = new java.awt.GridBagConstraints (); 383 gridBagConstraints.gridx = 0; 384 gridBagConstraints.gridy = 8; 385 gridBagConstraints.gridwidth = 2; 386 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 387 gridBagConstraints.insets = new java.awt.Insets (18, 0, 2, 12); 388 add(publicPkgs, gridBagConstraints); 389 390 publicPkgsTable.setShowHorizontalLines(false); 391 publicPkgsSP.setViewportView(publicPkgsTable); 392 393 gridBagConstraints = new java.awt.GridBagConstraints (); 394 gridBagConstraints.gridx = 0; 395 gridBagConstraints.gridy = 9; 396 gridBagConstraints.gridwidth = 2; 397 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 398 gridBagConstraints.weighty = 0.8; 399 add(publicPkgsSP, gridBagConstraints); 400 401 bottomPanel.setLayout(new java.awt.GridBagLayout ()); 402 403 buttonPanel.setLayout(new java.awt.GridBagLayout ()); 404 405 org.openide.awt.Mnemonics.setLocalizedText(addFriendButton, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_AddButton")); 406 addFriendButton.addActionListener(new java.awt.event.ActionListener () { 407 public void actionPerformed(java.awt.event.ActionEvent evt) { 408 addFriend(evt); 409 } 410 }); 411 412 gridBagConstraints = new java.awt.GridBagConstraints (); 413 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 414 buttonPanel.add(addFriendButton, gridBagConstraints); 415 416 org.openide.awt.Mnemonics.setLocalizedText(removeFriendButton, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_RemoveButton")); 417 removeFriendButton.addActionListener(new java.awt.event.ActionListener () { 418 public void actionPerformed(java.awt.event.ActionEvent evt) { 419 removeFriend(evt); 420 } 421 }); 422 423 gridBagConstraints = new java.awt.GridBagConstraints (); 424 gridBagConstraints.gridx = 0; 425 gridBagConstraints.gridy = 1; 426 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 427 gridBagConstraints.insets = new java.awt.Insets (2, 0, 0, 0); 428 buttonPanel.add(removeFriendButton, gridBagConstraints); 429 430 gridBagConstraints = new java.awt.GridBagConstraints (); 431 gridBagConstraints.gridx = 0; 432 gridBagConstraints.gridy = 2; 433 gridBagConstraints.weighty = 1.0; 434 buttonPanel.add(filler1, gridBagConstraints); 435 436 gridBagConstraints = new java.awt.GridBagConstraints (); 437 gridBagConstraints.gridx = 1; 438 gridBagConstraints.gridy = 0; 439 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 440 bottomPanel.add(buttonPanel, gridBagConstraints); 441 442 friendsSP.setViewportView(friendsList); 443 444 gridBagConstraints = new java.awt.GridBagConstraints (); 445 gridBagConstraints.gridx = 0; 446 gridBagConstraints.gridy = 0; 447 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 448 gridBagConstraints.weightx = 1.0; 449 gridBagConstraints.weighty = 1.0; 450 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 451 bottomPanel.add(friendsSP, gridBagConstraints); 452 453 gridBagConstraints = new java.awt.GridBagConstraints (); 454 gridBagConstraints.gridx = 0; 455 gridBagConstraints.gridy = 11; 456 gridBagConstraints.gridwidth = 2; 457 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 458 gridBagConstraints.weighty = 0.2; 459 gridBagConstraints.insets = new java.awt.Insets (2, 0, 0, 0); 460 add(bottomPanel, gridBagConstraints); 461 462 org.openide.awt.Mnemonics.setLocalizedText(exportOnlyToFriend, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_ExportOnlyToFriends")); 463 exportOnlyToFriend.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 464 exportOnlyToFriend.setEnabled(false); 465 exportOnlyToFriend.setMargin(new java.awt.Insets (0, 0, 0, 0)); 466 gridBagConstraints = new java.awt.GridBagConstraints (); 467 gridBagConstraints.gridx = 0; 468 gridBagConstraints.gridy = 10; 469 gridBagConstraints.gridwidth = 2; 470 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 471 gridBagConstraints.insets = new java.awt.Insets (18, 0, 0, 12); 472 add(exportOnlyToFriend, gridBagConstraints); 473 474 typePanel.setLayout(new java.awt.GridBagLayout ()); 475 476 moduleTypeGroup.add(regularMod); 477 regularMod.setSelected(true); 478 org.openide.awt.Mnemonics.setLocalizedText(regularMod, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_RegularModule")); 479 regularMod.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 480 regularMod.setMargin(new java.awt.Insets (0, 0, 0, 0)); 481 gridBagConstraints = new java.awt.GridBagConstraints (); 482 gridBagConstraints.gridx = 1; 483 gridBagConstraints.gridy = 0; 484 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 485 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 486 typePanel.add(regularMod, gridBagConstraints); 487 488 moduleTypeGroup.add(autoloadMod); 489 org.openide.awt.Mnemonics.setLocalizedText(autoloadMod, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_AutoloadModule")); 490 autoloadMod.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 491 autoloadMod.setMargin(new java.awt.Insets (0, 0, 0, 0)); 492 gridBagConstraints = new java.awt.GridBagConstraints (); 493 gridBagConstraints.gridx = 2; 494 gridBagConstraints.gridy = 0; 495 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 496 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 497 typePanel.add(autoloadMod, gridBagConstraints); 498 499 moduleTypeGroup.add(eagerMod); 500 org.openide.awt.Mnemonics.setLocalizedText(eagerMod, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_EagerModule")); 501 eagerMod.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 502 eagerMod.setMargin(new java.awt.Insets (0, 0, 0, 0)); 503 gridBagConstraints = new java.awt.GridBagConstraints (); 504 gridBagConstraints.gridx = 3; 505 gridBagConstraints.gridy = 0; 506 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 507 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 508 gridBagConstraints.weightx = 1.0; 509 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 510 typePanel.add(eagerMod, gridBagConstraints); 511 512 org.openide.awt.Mnemonics.setLocalizedText(typeTxt, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_ModuleType")); 513 gridBagConstraints = new java.awt.GridBagConstraints (); 514 gridBagConstraints.gridx = 0; 515 gridBagConstraints.gridy = 0; 516 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 517 typePanel.add(typeTxt, gridBagConstraints); 518 519 gridBagConstraints = new java.awt.GridBagConstraints (); 520 gridBagConstraints.gridx = 0; 521 gridBagConstraints.gridy = 5; 522 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 523 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 524 gridBagConstraints.insets = new java.awt.Insets (18, 0, 0, 0); 525 add(typePanel, gridBagConstraints); 526 527 } 529 private void removeFriend(java.awt.event.ActionEvent evt) { getFriendModel().removeFriend((String ) friendsList.getSelectedValue()); 531 if (getFriendModel().getSize() > 0) { 532 friendsList.setSelectedIndex(0); 533 } 534 friendsList.requestFocus(); 535 checkForm(); 536 } 538 private void addFriend(java.awt.event.ActionEvent evt) { AddFriendPanel addFriend = new AddFriendPanel(getProperties()); 540 DialogDescriptor descriptor = new DialogDescriptor(addFriend, getMessage("CTL_AddNewFriend_Title")); 541 descriptor.setHelpCtx(new HelpCtx(AddFriendPanel.class)); 542 final JButton okButton = new JButton (getMessage("CTL_OK")); 543 JButton cancel = new JButton (getMessage("CTL_Cancel")); 544 okButton.setEnabled(false); 545 Object [] options = new Object [] { okButton , cancel }; 546 descriptor.setOptions(options); 547 descriptor.setClosingOptions(options); 548 final Dialog d = DialogDisplayer.getDefault().createDialog(descriptor); 549 addFriend.addPropertyChangeListener(new PropertyChangeListener () { 550 public void propertyChange(PropertyChangeEvent pce) { 551 if (pce.getPropertyName() == AddFriendPanel.VALID_PROPERTY) { 552 okButton.setEnabled(((Boolean ) pce.getNewValue()).booleanValue()); 553 } 554 } 555 }); 556 d.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CTL_AddNewFriend_Title")); 557 okButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CTL_OK")); 558 cancel.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CTL_Cancel")); 559 if (lastSize != null) { 560 d.setSize(lastSize); 561 } else { 562 d.pack(); 563 } 564 d.setLocationRelativeTo(null); 565 d.setVisible(true); 566 lastSize = d.getSize(); 567 if (descriptor.getValue().equals(okButton)) { 568 String newFriendCNB = addFriend.getFriendCNB(); 569 getFriendModel().addFriend(newFriendCNB); 570 friendsList.setSelectedValue(newFriendCNB, true); 571 } 572 d.dispose(); 573 friendsList.requestFocus(); 574 checkForm(); 575 } 577 private String getMessage(String key) { 578 return NbBundle.getMessage(CustomizerVersioning.class, key); 579 } 580 581 public void showSubCategory(BasicCustomizer.SubCategoryProvider prov) { 582 if (CustomizerProviderImpl.CATEGORY_VERSIONING.equals(prov.getCategory()) && 583 CustomizerProviderImpl.SUBCATEGORY_VERSIONING_PUBLIC_PACKAGES.equals(prov.getSubcategory())) { 584 publicPkgsTable.requestFocus(); 585 591 } 592 } 593 594 private javax.swing.JButton addFriendButton; 596 private javax.swing.JCheckBox appendImpl; 597 private javax.swing.JRadioButton autoloadMod; 598 private javax.swing.JPanel bottomPanel; 599 private javax.swing.JPanel buttonPanel; 600 private javax.swing.JLabel cnb; 601 private javax.swing.JTextField cnbValue; 602 private javax.swing.JRadioButton eagerMod; 603 private javax.swing.JCheckBox exportOnlyToFriend; 604 private javax.swing.JLabel filler1; 605 private javax.swing.JList friendsList; 606 private javax.swing.JScrollPane friendsSP; 607 private javax.swing.JLabel implVer; 608 private javax.swing.JTextField implVerValue; 609 private javax.swing.JLabel majorRelVer; 610 private javax.swing.JTextField majorRelVerValue; 611 private javax.swing.ButtonGroup moduleTypeGroup; 612 private javax.swing.JLabel publicPkgs; 613 private javax.swing.JScrollPane publicPkgsSP; 614 private javax.swing.JTable publicPkgsTable; 615 private javax.swing.JRadioButton regularMod; 616 private javax.swing.JButton removeFriendButton; 617 private javax.swing.JLabel specificationVer; 618 private javax.swing.JTextField specificationVerValue; 619 private javax.swing.JLabel tokens; 620 private javax.swing.JTextField tokensValue; 621 private javax.swing.JPanel typePanel; 622 private javax.swing.JLabel typeTxt; 623 625 private void initAccesibility() { 626 addFriendButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_AddFriendButton")); 627 removeFriendButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_RemoveFriendButton")); 628 cnbValue.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CnbValue")); 629 majorRelVerValue.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_MajorRelVerValue")); 630 specificationVerValue.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_SpecificationVerValuea")); 631 appendImpl.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_AppendImpl")); 632 implVerValue.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_ImplVerValue")); 633 regularMod.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_RegularMod")); 634 autoloadMod.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_AutoloadMod")); 635 eagerMod.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_EagerMod")); 636 publicPkgsTable.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_PublicPkgsTable")); 637 tokensValue.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_TokensValue")); 638 } 639 640 } 641 | Popular Tags |