1 19 package org.netbeans.modules.java.j2seplatform.platformdefinition; 20 21 import java.awt.Color ; 22 import java.awt.Font ; 23 import java.io.File ; 24 import java.net.URI ; 25 import java.net.URL ; 26 import java.util.Collection ; 27 import javax.swing.JLabel ; 28 import javax.swing.text.html.HTMLEditorKit ; 29 import javax.swing.text.html.StyleSheet ; 30 import org.openide.util.NbBundle; 31 32 36 public class BrokenPlatformCustomizer extends javax.swing.JPanel { 37 38 private J2SEPlatformImpl platform; 39 40 41 public BrokenPlatformCustomizer(J2SEPlatformImpl platform) { 42 this.platform = platform; 43 initComponents(); 44 postInitComponents (); 45 } 46 47 52 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 54 55 jLabel1 = new javax.swing.JLabel (); 56 platformName = new javax.swing.JTextField (); 57 jLabel2 = new javax.swing.JLabel (); 58 platformHome = new javax.swing.JTextField (); 59 jTextPane1 = new javax.swing.JTextPane (); 60 61 setLayout(new java.awt.GridBagLayout ()); 62 63 jLabel1.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seplatform/platformdefinition/Bundle").getString("MNE_PlatformName").charAt(0)); 64 jLabel1.setLabelFor(platformName); 65 jLabel1.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seplatform/platformdefinition/Bundle").getString("CTL_PlatformName")); 66 gridBagConstraints = new java.awt.GridBagConstraints (); 67 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 68 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 6); 69 add(jLabel1, gridBagConstraints); 70 71 platformName.setEditable(false); 72 gridBagConstraints = new java.awt.GridBagConstraints (); 73 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 74 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 75 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 76 gridBagConstraints.weightx = 1.0; 77 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 78 add(platformName, gridBagConstraints); 79 80 jLabel2.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seplatform/platformdefinition/Bundle").getString("MNE_PlatformHome").charAt(0)); 81 jLabel2.setLabelFor(platformHome); 82 jLabel2.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seplatform/platformdefinition/Bundle").getString("CTL_PlatformHome")); 83 gridBagConstraints = new java.awt.GridBagConstraints (); 84 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 85 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 6); 86 add(jLabel2, gridBagConstraints); 87 88 platformHome.setEditable(false); 89 gridBagConstraints = new java.awt.GridBagConstraints (); 90 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 91 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 92 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 93 gridBagConstraints.weightx = 1.0; 94 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 95 add(platformHome, gridBagConstraints); 96 97 jTextPane1.setEditable(false); 98 jTextPane1.setOpaque(false); 99 gridBagConstraints = new java.awt.GridBagConstraints (); 100 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 101 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 102 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 103 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 104 gridBagConstraints.weightx = 1.0; 105 gridBagConstraints.weighty = 1.0; 106 gridBagConstraints.insets = new java.awt.Insets (12, 0, 12, 12); 107 add(jTextPane1, gridBagConstraints); 108 109 } 111 112 private void postInitComponents () { 113 this.platformName.setText (platform.getDisplayName()); 114 Collection installFolders = platform.getInstallFolderURLs(); 115 if (installFolders.size() > 0) { 116 this.platformHome.setForeground(new Color (164,0,0)); 117 this.platformHome.setText (new File (URI.create(((URL )installFolders.iterator().next()).toExternalForm())).getAbsolutePath()); 118 } 119 HTMLEditorKit htmlkit = new HTMLEditorKit (); 120 StyleSheet css = htmlkit.getStyleSheet(); 121 if (css.getStyleSheets() == null) { 122 StyleSheet css2 = new StyleSheet (); 123 Font f = jLabel1.getFont(); 124 css2.addRule(new StringBuffer ("body { font-size: ").append(f.getSize()) .append("; font-family: ").append(f.getName()).append("; }").toString()); css2.addStyleSheet(css); 127 htmlkit.setStyleSheet(css2); 128 } 129 jTextPane1.setEditorKit(htmlkit); 130 jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class,"MSG_BrokenProject")); 131 } 132 133 private javax.swing.JLabel jLabel1; 135 private javax.swing.JLabel jLabel2; 136 private javax.swing.JTextPane jTextPane1; 137 private javax.swing.JTextField platformHome; 138 private javax.swing.JTextField platformName; 139 141 } 142 | Popular Tags |