1 19 20 package org.netbeans.core.ui; 21 22 import java.awt.Color ; 23 import java.awt.Dimension ; 24 import java.awt.Font ; 25 import java.awt.Graphics ; 26 import java.awt.Toolkit ; 27 import java.awt.datatransfer.Clipboard ; 28 import java.awt.event.FocusEvent ; 29 import java.io.File ; 30 import java.text.MessageFormat ; 31 import java.util.Enumeration ; 32 import java.util.HashSet ; 33 import java.util.Locale ; 34 import java.util.Set ; 35 import java.util.StringTokenizer ; 36 import javax.swing.Action ; 37 import javax.swing.ImageIcon ; 38 import javax.swing.JLabel ; 39 import javax.swing.JPanel ; 40 import javax.swing.UIManager ; 41 import org.netbeans.core.actions.CopyProductInfoAction; 42 import org.openide.filesystems.FileUtil; 43 import org.openide.util.Enumerations; 44 import org.openide.util.Lookup; 45 import org.openide.util.NbBundle; 46 import org.openide.util.Utilities; 47 import org.openide.util.datatransfer.ExClipboard; 48 49 public class ProductInformationPanel extends JPanel { 50 51 private static final int FONT_SIZE_PLUS = 5; 52 53 private static final Color COLOR = Color.black; 54 55 56 private static Clipboard clipboard; 57 58 private static Action copyAction; 59 60 public ProductInformationPanel() { 61 initComponents(); 62 63 initAccessibility(); 64 65 updateLabelFont(productInformationLabel, Font.BOLD, FONT_SIZE_PLUS, COLOR); 66 updateLabelFont(productVersionLabel, Font.BOLD, COLOR); 67 updateLabelFont(operatingSystemLabel, Font.BOLD, COLOR); 68 updateLabelFont(javaLabel, Font.BOLD, COLOR); 69 updateLabelFont(vmLabel, Font.BOLD, COLOR); 70 updateLabelFont(vendorLabel, Font.BOLD, COLOR); 71 updateLabelFont(javaHomeLabel, Font.BOLD, COLOR); 72 updateLabelFont(systemLocaleLabel, Font.BOLD, COLOR); 73 updateLabelFont(homeDirLabel, Font.BOLD, COLOR); 74 updateLabelFont(currentDirLabel, Font.BOLD, COLOR); 75 updateLabelFont(ideInstallLabel, Font.BOLD, COLOR); 76 updateLabelFont(userDirLabel, Font.BOLD, COLOR); 77 updateLabelFont(productVersionValueLabel, COLOR); 78 updateLabelFont(operatingSystemValueLabel, COLOR); 79 updateLabelFont(javaValueLabel, COLOR); 80 updateLabelFont(vmValueLabel, COLOR); 81 updateLabelFont(vendorValueLabel, COLOR); 82 updateLabelFont(javaHomeValueLabel, COLOR); 83 updateLabelFont(systemLocaleValueLabel, COLOR); 84 updateLabelFont(homeDirValueLabel, COLOR); 85 updateLabelFont(currentDirValueLabel, COLOR); 86 updateLabelFont(ideInstallValueField, COLOR); 87 updateLabelFont(userDirValueLabel, COLOR); 88 89 if (ideInstallValueField.getText().length() == 0) { 90 ideInstallLabel.setVisible(false); 92 ideInstallValueField.setVisible(false); 93 } 95 } 96 97 private void initComponents() { 99 java.awt.GridBagConstraints gridBagConstraints; 100 101 ideImageLabel = new javax.swing.JLabel (); 102 productVersionLabel = new javax.swing.JLabel (); 103 operatingSystemLabel = new javax.swing.JLabel (); 104 javaLabel = new javax.swing.JLabel (); 105 vmLabel = new javax.swing.JLabel (); 106 vendorLabel = new javax.swing.JLabel (); 107 javaHomeLabel = new javax.swing.JLabel (); 108 systemLocaleLabel = new javax.swing.JLabel (); 109 homeDirLabel = new javax.swing.JLabel (); 110 currentDirLabel = new javax.swing.JLabel (); 111 ideInstallLabel = new javax.swing.JLabel (); 112 userDirLabel = new javax.swing.JLabel (); 113 jPanel1 = new javax.swing.JPanel (); 114 productInformationLabel = new FocusableLabel(); 115 ideInstallValueField = new javax.swing.JTextArea (); 116 copyButton = new javax.swing.JButton (); 117 productVersionValueLabel = new javax.swing.JTextArea (); 118 operatingSystemValueLabel = new javax.swing.JTextArea (); 119 javaValueLabel = new javax.swing.JTextArea (); 120 vmValueLabel = new javax.swing.JTextArea (); 121 vendorValueLabel = new javax.swing.JTextArea (); 122 javaHomeValueLabel = new javax.swing.JTextArea (); 123 systemLocaleValueLabel = new javax.swing.JTextArea (); 124 homeDirValueLabel = new javax.swing.JTextArea (); 125 currentDirValueLabel = new javax.swing.JTextArea (); 126 userDirValueLabel = new javax.swing.JTextArea (); 127 128 setLayout(new java.awt.GridBagLayout ()); 129 130 ideImageLabel.setIcon(getIcon()); 131 ideImageLabel.setLabelFor(productInformationLabel); 132 gridBagConstraints = new java.awt.GridBagConstraints (); 133 gridBagConstraints.gridx = 0; 134 gridBagConstraints.gridy = 0; 135 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 136 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 137 add(ideImageLabel, gridBagConstraints); 138 139 productVersionLabel.setLabelFor(productVersionValueLabel); 140 productVersionLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_ProductVersion")); gridBagConstraints = new java.awt.GridBagConstraints (); 142 gridBagConstraints.gridx = 1; 143 gridBagConstraints.gridy = 1; 144 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 145 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 146 add(productVersionLabel, gridBagConstraints); 147 148 operatingSystemLabel.setLabelFor(operatingSystemValueLabel); 149 operatingSystemLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_OperationgSystem")); gridBagConstraints = new java.awt.GridBagConstraints (); 151 gridBagConstraints.gridx = 1; 152 gridBagConstraints.gridy = 2; 153 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 154 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 0); 155 add(operatingSystemLabel, gridBagConstraints); 156 157 javaLabel.setLabelFor(javaValueLabel); 158 javaLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_Java")); gridBagConstraints = new java.awt.GridBagConstraints (); 160 gridBagConstraints.gridx = 1; 161 gridBagConstraints.gridy = 3; 162 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 163 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 0); 164 add(javaLabel, gridBagConstraints); 165 166 vmLabel.setLabelFor(vmValueLabel); 167 vmLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_VM")); gridBagConstraints = new java.awt.GridBagConstraints (); 169 gridBagConstraints.gridx = 1; 170 gridBagConstraints.gridy = 4; 171 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 172 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 0); 173 add(vmLabel, gridBagConstraints); 174 175 vendorLabel.setLabelFor(vendorValueLabel); 176 vendorLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_Vendor")); gridBagConstraints = new java.awt.GridBagConstraints (); 178 gridBagConstraints.gridx = 1; 179 gridBagConstraints.gridy = 5; 180 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 181 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 0); 182 add(vendorLabel, gridBagConstraints); 183 184 javaHomeLabel.setLabelFor(javaHomeValueLabel); 185 javaHomeLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_JavaHome")); gridBagConstraints = new java.awt.GridBagConstraints (); 187 gridBagConstraints.gridx = 1; 188 gridBagConstraints.gridy = 6; 189 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 190 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 0); 191 add(javaHomeLabel, gridBagConstraints); 192 193 systemLocaleLabel.setLabelFor(systemLocaleValueLabel); 194 systemLocaleLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_SystemLocale")); gridBagConstraints = new java.awt.GridBagConstraints (); 196 gridBagConstraints.gridx = 1; 197 gridBagConstraints.gridy = 7; 198 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 199 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 0); 200 add(systemLocaleLabel, gridBagConstraints); 201 202 homeDirLabel.setLabelFor(homeDirValueLabel); 203 homeDirLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_HomeDir")); gridBagConstraints = new java.awt.GridBagConstraints (); 205 gridBagConstraints.gridx = 1; 206 gridBagConstraints.gridy = 8; 207 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 208 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 0); 209 add(homeDirLabel, gridBagConstraints); 210 211 currentDirLabel.setLabelFor(currentDirValueLabel); 212 currentDirLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_CurrentDir")); gridBagConstraints = new java.awt.GridBagConstraints (); 214 gridBagConstraints.gridx = 1; 215 gridBagConstraints.gridy = 9; 216 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 217 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 0); 218 add(currentDirLabel, gridBagConstraints); 219 220 ideInstallLabel.setLabelFor(ideInstallValueField); 221 ideInstallLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_IDEInstall")); gridBagConstraints = new java.awt.GridBagConstraints (); 223 gridBagConstraints.gridx = 1; 224 gridBagConstraints.gridy = 11; 225 gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE; 226 gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; 227 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 228 gridBagConstraints.insets = new java.awt.Insets (6, 12, 5, 0); 229 add(ideInstallLabel, gridBagConstraints); 230 231 userDirLabel.setLabelFor(userDirValueLabel); 232 userDirLabel.setText(org.openide.util.NbBundle.getMessage(ProductInformationPanel.class, "LBL_UserDir")); gridBagConstraints = new java.awt.GridBagConstraints (); 234 gridBagConstraints.gridx = 1; 235 gridBagConstraints.gridy = 10; 236 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 237 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 0); 238 add(userDirLabel, gridBagConstraints); 239 gridBagConstraints = new java.awt.GridBagConstraints (); 240 gridBagConstraints.gridx = 1; 241 gridBagConstraints.gridy = 15; 242 gridBagConstraints.gridwidth = 2; 243 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 244 gridBagConstraints.weightx = 1.0; 245 gridBagConstraints.weighty = 1.0; 246 add(jPanel1, gridBagConstraints); 247 248 productInformationLabel.setText(getProductInformationTitle ()); 249 gridBagConstraints = new java.awt.GridBagConstraints (); 250 gridBagConstraints.gridwidth = 2; 251 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 252 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 253 add(productInformationLabel, gridBagConstraints); 254 255 ideInstallValueField.setEditable(false); 256 ideInstallValueField.setText(getIDEInstallValue ()); 257 ideInstallValueField.setOpaque(false); 258 gridBagConstraints = new java.awt.GridBagConstraints (); 259 gridBagConstraints.gridx = 2; 260 gridBagConstraints.gridy = 11; 261 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 262 gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE; 263 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 264 gridBagConstraints.insets = new java.awt.Insets (6, 12, 5, 11); 265 add(ideInstallValueField, gridBagConstraints); 266 267 copyButton.setAction(CopyProductInfoAction.findObject(CopyProductInfoAction.class, true)); 268 gridBagConstraints = new java.awt.GridBagConstraints (); 269 gridBagConstraints.gridx = 3; 270 gridBagConstraints.gridy = 0; 271 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 12); 272 add(copyButton, gridBagConstraints); 273 274 productVersionValueLabel.setEditable(false); 275 productVersionValueLabel.setText(getProductVersionValue()); 276 productVersionValueLabel.setOpaque(false); 277 gridBagConstraints = new java.awt.GridBagConstraints (); 278 gridBagConstraints.gridx = 2; 279 gridBagConstraints.gridy = 1; 280 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 281 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 282 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 11); 283 add(productVersionValueLabel, gridBagConstraints); 284 285 operatingSystemValueLabel.setEditable(false); 286 operatingSystemValueLabel.setText(getOperatingSystemValue()); 287 operatingSystemValueLabel.setOpaque(false); 288 gridBagConstraints = new java.awt.GridBagConstraints (); 289 gridBagConstraints.gridx = 2; 290 gridBagConstraints.gridy = 2; 291 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 292 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 293 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 11); 294 add(operatingSystemValueLabel, gridBagConstraints); 295 296 javaValueLabel.setEditable(false); 297 javaValueLabel.setText(getJavaValue()); 298 javaValueLabel.setOpaque(false); 299 gridBagConstraints = new java.awt.GridBagConstraints (); 300 gridBagConstraints.gridx = 2; 301 gridBagConstraints.gridy = 3; 302 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 303 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 304 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 11); 305 add(javaValueLabel, gridBagConstraints); 306 307 vmValueLabel.setEditable(false); 308 vmValueLabel.setText(getVMValue()); 309 vmValueLabel.setOpaque(false); 310 gridBagConstraints = new java.awt.GridBagConstraints (); 311 gridBagConstraints.gridx = 2; 312 gridBagConstraints.gridy = 4; 313 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 314 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 315 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 11); 316 add(vmValueLabel, gridBagConstraints); 317 318 vendorValueLabel.setEditable(false); 319 vendorValueLabel.setText(getVendorValue()); 320 vendorValueLabel.setOpaque(false); 321 gridBagConstraints = new java.awt.GridBagConstraints (); 322 gridBagConstraints.gridx = 2; 323 gridBagConstraints.gridy = 5; 324 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 325 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 326 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 11); 327 add(vendorValueLabel, gridBagConstraints); 328 329 javaHomeValueLabel.setEditable(false); 330 javaHomeValueLabel.setText(getJavaHomeValue()); 331 javaHomeValueLabel.setOpaque(false); 332 gridBagConstraints = new java.awt.GridBagConstraints (); 333 gridBagConstraints.gridx = 2; 334 gridBagConstraints.gridy = 6; 335 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 336 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 337 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 11); 338 add(javaHomeValueLabel, gridBagConstraints); 339 340 systemLocaleValueLabel.setEditable(false); 341 systemLocaleValueLabel.setText(getSystemLocaleValue()); 342 systemLocaleValueLabel.setOpaque(false); 343 gridBagConstraints = new java.awt.GridBagConstraints (); 344 gridBagConstraints.gridx = 2; 345 gridBagConstraints.gridy = 7; 346 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 347 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 348 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 11); 349 add(systemLocaleValueLabel, gridBagConstraints); 350 351 homeDirValueLabel.setEditable(false); 352 homeDirValueLabel.setText(getHomeDirValue()); 353 homeDirValueLabel.setOpaque(false); 354 gridBagConstraints = new java.awt.GridBagConstraints (); 355 gridBagConstraints.gridx = 2; 356 gridBagConstraints.gridy = 8; 357 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 358 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 359 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 11); 360 add(homeDirValueLabel, gridBagConstraints); 361 362 currentDirValueLabel.setEditable(false); 363 currentDirValueLabel.setText(getCurrentDirValue()); 364 currentDirValueLabel.setOpaque(false); 365 gridBagConstraints = new java.awt.GridBagConstraints (); 366 gridBagConstraints.gridx = 2; 367 gridBagConstraints.gridy = 9; 368 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 369 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 370 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 11); 371 add(currentDirValueLabel, gridBagConstraints); 372 373 userDirValueLabel.setEditable(false); 374 userDirValueLabel.setText(getUserDirValue()); 375 userDirValueLabel.setOpaque(false); 376 gridBagConstraints = new java.awt.GridBagConstraints (); 377 gridBagConstraints.gridx = 2; 378 gridBagConstraints.gridy = 10; 379 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 380 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 381 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 11); 382 add(userDirValueLabel, gridBagConstraints); 383 } 385 private javax.swing.JButton copyButton; 387 private javax.swing.JLabel currentDirLabel; 388 private javax.swing.JTextArea currentDirValueLabel; 389 private javax.swing.JLabel homeDirLabel; 390 private javax.swing.JTextArea homeDirValueLabel; 391 private javax.swing.JLabel ideImageLabel; 392 private javax.swing.JLabel ideInstallLabel; 393 private javax.swing.JTextArea ideInstallValueField; 394 private javax.swing.JPanel jPanel1; 395 private javax.swing.JLabel javaHomeLabel; 396 private javax.swing.JTextArea javaHomeValueLabel; 397 private javax.swing.JLabel javaLabel; 398 private javax.swing.JTextArea javaValueLabel; 399 private javax.swing.JLabel operatingSystemLabel; 400 private javax.swing.JTextArea operatingSystemValueLabel; 401 private javax.swing.JLabel productInformationLabel; 402 private javax.swing.JLabel productVersionLabel; 403 private javax.swing.JTextArea productVersionValueLabel; 404 private javax.swing.JLabel systemLocaleLabel; 405 private javax.swing.JTextArea systemLocaleValueLabel; 406 private javax.swing.JLabel userDirLabel; 407 private javax.swing.JTextArea userDirValueLabel; 408 private javax.swing.JLabel vendorLabel; 409 private javax.swing.JTextArea vendorValueLabel; 410 private javax.swing.JLabel vmLabel; 411 private javax.swing.JTextArea vmValueLabel; 412 414 private void updateLabelFont (javax.swing.JComponent label, Color color) { 415 updateLabelFont(label, 0, 0, color); 416 } 417 418 private void updateLabelFont (javax.swing.JComponent label, int style, Color color) { 419 updateLabelFont(label, style, 0, color); 420 } 421 422 private void updateLabelFont (javax.swing.JComponent label, int style, int plusSize, Color color) { 423 Font font = label.getFont(); 424 if(style != 0) { 425 if (Utilities.isMac()) { 427 font = new Font (label.getFont().getName(), Font.BOLD, label.getFont().getSize()); 428 } else { 429 font = label.getFont().deriveFont(Font.BOLD); 430 } 431 label.setFont(font); 432 } 433 if(plusSize != 0f) { 434 font = new Font (font.getName(), font.getStyle(), font.getSize() + plusSize); 436 label.setFont(font); 437 } 438 if(color != null) { 439 label.setForeground(color); 440 } 441 } 442 443 private ImageIcon getIcon () { 444 return new ImageIcon (Utilities.loadImage("org/netbeans/core/startup/frame48.gif", true)); 445 } 446 447 private String getProductInformationTitle () { 448 return NbBundle.getMessage(ProductInformationPanel.class, "LBL_ProductInformation"); 449 } 450 451 public static String getProductVersionValue () { 452 return MessageFormat.format( 453 NbBundle.getBundle("org.netbeans.core.startup.Bundle").getString("currentVersion"), 454 new Object [] {System.getProperty("netbeans.buildnumber")}); 455 } 456 457 public static String getOperatingSystemValue () { 458 return NbBundle.getMessage(ProductInformationPanel.class, "Format_OperatingSystem_Value", 459 System.getProperty("os.name", "unknown"), 460 System.getProperty("os.version", "unknown"), 461 System.getProperty("os.arch", "unknown")); 462 } 463 464 public static String getJavaValue () { 465 return System.getProperty("java.version", "unknown"); 466 } 467 468 public static String getVMValue () { 469 return System.getProperty("java.vm.name", "unknown") + " " + System.getProperty("java.vm.version", ""); 470 } 471 472 private String getVendorValue () { 473 return System.getProperty("java.vendor", "unknown"); 474 } 475 476 private String getJavaHomeValue () { 477 return System.getProperty("java.home", "unknown"); 478 } 479 480 public static String getSystemLocaleValue () { 481 String branding; 482 return Locale.getDefault().toString() + ((branding = NbBundle.getBranding()) == null ? "" : (" (" + branding + ")")); } 484 485 private String getHomeDirValue () { 486 return System.getProperty("user.home", "unknown"); 487 } 488 489 private String getCurrentDirValue () { 490 return System.getProperty("user.dir", "unknown"); 491 } 492 493 private String getIDEInstallValue () { 494 String nbhome = System.getProperty("netbeans.home"); 495 String nbdirs = System.getProperty("netbeans.dirs"); 496 497 Enumeration <Object > more; 498 if (nbdirs != null) { 499 more = new StringTokenizer (nbdirs, File.pathSeparator); 500 } else { 501 more = Enumerations.empty(); 502 } 503 504 Enumeration <Object > all = Enumerations.concat(Enumerations.singleton(nbhome), more); 505 506 Set <File > files = new HashSet <File >(); 507 StringBuilder sb = new StringBuilder (); 508 String prefix = ""; 509 while (all.hasMoreElements ()) { 510 String s = (String )all.nextElement (); 511 if (s == null) { 512 continue; 513 } 514 File f = FileUtil.normalizeFile(new File (s)); 515 if (files.add (f)) { 516 sb.append (prefix); 518 sb.append(f.getAbsolutePath()); 519 prefix = "\n"; 520 } 521 } 522 523 return sb.toString (); 524 } 525 526 private String getUserDirValue () { 527 return System.getProperty("netbeans.user"); 528 } 529 530 public static String getEncodingValue() { 531 return System.getProperty("file.encoding", "unknown"); 532 } 533 534 public static Clipboard getExClipboard() { 535 if (clipboard == null) { 536 clipboard = Lookup.getDefault().lookup(ExClipboard.class); 537 if (clipboard == null) { 538 clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); 539 } 540 } 541 return clipboard; 542 } 543 544 546 static class FocusableLabel extends JLabel { 547 548 private boolean isFocused = false; 549 550 public FocusableLabel(){ 551 addFocusListener( 552 new java.awt.event.FocusListener () { 553 public void focusGained(FocusEvent event) { 554 isFocused = true; 555 repaint(); 556 } 557 public void focusLost(FocusEvent event) { 558 isFocused = false; 559 repaint(); 560 } 561 }); 562 563 getAccessibleContext().setAccessibleDescription(getText()); 564 getAccessibleContext().setAccessibleName(getText()); 565 } 566 567 public boolean isFocusable() { 568 return (true); 569 } 570 571 public void paintComponent(Graphics g) { 572 if (ui != null) { 573 try { 574 ui.update(g, this); 575 } 576 finally { 577 g.dispose(); 578 } 579 } 580 581 if (isFocused) { 582 Dimension size = getSize(); 583 g.setColor(UIManager.getColor("Button.focus")); g.drawRect(0, 0, size.width-1, size.height-1); 585 } 586 } 587 588 } 589 590 591 593 private void initAccessibility(){ 594 595 598 productVersionValueLabel.getAccessibleContext().setAccessibleName(productVersionLabel.getText() + " " + productVersionValueLabel.getText()); 599 productVersionValueLabel.getAccessibleContext().setAccessibleDescription(productVersionValueLabel.getText()); 600 601 operatingSystemValueLabel.getAccessibleContext().setAccessibleName(operatingSystemLabel.getText() + " " + operatingSystemValueLabel.getText()); 602 operatingSystemValueLabel.getAccessibleContext().setAccessibleDescription(operatingSystemValueLabel.getText()); 603 604 javaValueLabel.getAccessibleContext().setAccessibleName(javaLabel.getText() + " " + javaValueLabel.getText()); 605 javaValueLabel.getAccessibleContext().setAccessibleDescription(javaValueLabel.getText()); 606 607 vmValueLabel.getAccessibleContext().setAccessibleName(vmLabel.getText() + " " + vmValueLabel.getText()); 608 vmValueLabel.getAccessibleContext().setAccessibleDescription(vmValueLabel.getText()); 609 610 vendorValueLabel.getAccessibleContext().setAccessibleName(vendorLabel.getText() + " " + vendorValueLabel.getText()); 611 vendorValueLabel.getAccessibleContext().setAccessibleDescription(vendorValueLabel.getText()); 612 613 javaHomeValueLabel.getAccessibleContext().setAccessibleName(javaHomeLabel.getText() + " " + javaHomeValueLabel.getText()); 614 javaHomeValueLabel.getAccessibleContext().setAccessibleDescription(javaHomeValueLabel.getText()); 615 616 systemLocaleValueLabel.getAccessibleContext().setAccessibleName(systemLocaleLabel.getText() + " " + systemLocaleValueLabel.getText()); 617 systemLocaleValueLabel.getAccessibleContext().setAccessibleDescription(systemLocaleValueLabel.getText()); 618 619 homeDirValueLabel.getAccessibleContext().setAccessibleName(homeDirLabel.getText() + " " + homeDirValueLabel.getText()); 620 homeDirValueLabel.getAccessibleContext().setAccessibleDescription(homeDirValueLabel.getText()); 621 622 currentDirValueLabel.getAccessibleContext().setAccessibleName(currentDirLabel.getText() + " " + currentDirValueLabel.getText()); 623 currentDirValueLabel.getAccessibleContext().setAccessibleDescription(currentDirValueLabel.getText()); 624 625 ideInstallValueField.getAccessibleContext().setAccessibleName(ideInstallLabel.getText() + " " + ideInstallValueField.getText()); 626 ideInstallValueField.getAccessibleContext().setAccessibleDescription(ideInstallValueField.getText()); 627 628 userDirValueLabel.getAccessibleContext().setAccessibleName(userDirLabel.getText() + " " + userDirValueLabel.getText()); 629 userDirValueLabel.getAccessibleContext().setAccessibleDescription(userDirValueLabel.getText()); 630 } 631 } 632 | Popular Tags |