1 19 20 package org.netbeans.modules.autoupdate; 21 22 import java.awt.Font ; 23 import javax.swing.JButton ; 24 import java.net.URL ; 25 26 import org.openide.DialogDescriptor; 27 import org.openide.DialogDisplayer; 28 import org.openide.util.Exceptions; 29 import org.openide.util.NbBundle; 30 31 34 class ExternalDialog extends javax.swing.JPanel { 35 36 37 private static final java.awt.Dimension preferredSize = new java.awt.Dimension ( 450, 250 ); 38 39 40 private static ExternalDialog externalPanel; 41 42 private static DialogDescriptor dialogDescriptor = null; 43 44 private static java.awt.Dialog dialog = null; 45 46 private static JButton acceptButton; 47 48 private static JButton declineButton; 49 50 private static String module_name; 51 private static ModuleUpdate.External external; 52 53 static final long serialVersionUID =-4862117522808181670L; 54 55 public ExternalDialog() { 56 initComponents (); 57 58 commentTextArea.setText(NbBundle.getMessage( ExternalDialog.class, "LBL_Ext_Comment", 59 module_name)); 60 nameTextField.setText( external.getName() ); 61 targetTextField.setText( external.getTarget_name() ); 62 descTextArea.setText( external.getDescription() ); 63 initAccessibility(); 64 } 65 66 67 public java.awt.Dimension getPreferredSize() { 68 return preferredSize; 69 } 70 71 76 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 78 79 commentTextArea = new javax.swing.JTextArea (); 80 jScrollPane1 = new javax.swing.JScrollPane (); 81 descTextArea = new javax.swing.JTextArea (); 82 nameLabel = new javax.swing.JLabel (); 83 nameTextField = new javax.swing.JTextField (); 84 targetLabel = new javax.swing.JLabel (); 85 descLabel = new javax.swing.JLabel (); 86 targetTextField = new javax.swing.JTextField (); 87 88 setLayout(new java.awt.GridBagLayout ()); 89 90 setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (8, 8, 8, 8))); 91 commentTextArea.setWrapStyleWord(true); 92 commentTextArea.setLineWrap(true); 93 commentTextArea.setEditable(false); 94 commentTextArea.setBackground(nameLabel.getBackground()); 95 gridBagConstraints = new java.awt.GridBagConstraints (); 96 gridBagConstraints.gridwidth = 4; 97 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 98 add(commentTextArea, gridBagConstraints); 99 100 descTextArea.setEditable(false); 101 descTextArea.setFont(new Font ("Monospaced", Font.PLAIN, descTextArea.getFont().getSize() + 1)); 102 descTextArea.setLineWrap(true); 103 descTextArea.setWrapStyleWord(true); 104 jScrollPane1.setViewportView(descTextArea); 105 106 gridBagConstraints = new java.awt.GridBagConstraints (); 107 gridBagConstraints.gridy = 3; 108 gridBagConstraints.gridwidth = 4; 109 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 110 gridBagConstraints.weightx = 1.0; 111 gridBagConstraints.weighty = 1.0; 112 add(jScrollPane1, gridBagConstraints); 113 114 nameLabel.setLabelFor(nameTextField); 115 nameLabel.setText(getBundle("LBL_Ext_Name")); 116 gridBagConstraints = new java.awt.GridBagConstraints (); 117 gridBagConstraints.gridx = 0; 118 gridBagConstraints.gridy = 1; 119 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 120 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 121 add(nameLabel, gridBagConstraints); 122 123 nameTextField.setEditable(false); 124 gridBagConstraints = new java.awt.GridBagConstraints (); 125 gridBagConstraints.gridx = 1; 126 gridBagConstraints.gridy = 1; 127 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 128 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 129 gridBagConstraints.weightx = 1.0; 130 gridBagConstraints.insets = new java.awt.Insets (12, 6, 0, 0); 131 add(nameTextField, gridBagConstraints); 132 133 targetLabel.setLabelFor(targetTextField); 134 targetLabel.setText(getBundle("LBL_Ext_Target")); 135 gridBagConstraints = new java.awt.GridBagConstraints (); 136 gridBagConstraints.gridx = 2; 137 gridBagConstraints.gridy = 1; 138 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 139 gridBagConstraints.insets = new java.awt.Insets (12, 24, 0, 0); 140 add(targetLabel, gridBagConstraints); 141 142 descLabel.setLabelFor(descTextArea); 143 descLabel.setText(getBundle("LBL_Ext_Desc")); 144 gridBagConstraints = new java.awt.GridBagConstraints (); 145 gridBagConstraints.gridx = 0; 146 gridBagConstraints.gridy = 2; 147 gridBagConstraints.gridwidth = 2; 148 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 149 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 150 add(descLabel, gridBagConstraints); 151 152 targetTextField.setEditable(false); 153 gridBagConstraints = new java.awt.GridBagConstraints (); 154 gridBagConstraints.gridx = 3; 155 gridBagConstraints.gridy = 1; 156 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 157 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 158 gridBagConstraints.weightx = 1.0; 159 gridBagConstraints.insets = new java.awt.Insets (12, 6, 0, 0); 160 add(targetTextField, gridBagConstraints); 161 162 } 164 private void initAccessibility(){ 165 getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACSD_ExtDialog")); 166 getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("CTL_Ext_Title")); 167 commentTextArea.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACSD_Comment_Text")); 168 commentTextArea.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACSN_Comment_Text")); 169 descTextArea.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACSD_Ext_Desc")); 170 nameLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACS_Ext_Name_mnc").charAt(0)); 171 nameTextField.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACSD_Ext_Name")); 172 targetLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACS_Ext_Target_mnc").charAt(0)); 173 descLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACS_Ext_Desc_mnc").charAt(0)); 174 targetTextField.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACSD_Ext_Target")); 175 } 176 177 private javax.swing.JTextArea commentTextArea; 179 private javax.swing.JLabel descLabel; 180 private javax.swing.JTextArea descTextArea; 181 private javax.swing.JScrollPane jScrollPane1; 182 private javax.swing.JLabel nameLabel; 183 private javax.swing.JTextField nameTextField; 184 private javax.swing.JLabel targetLabel; 185 private javax.swing.JTextField targetTextField; 186 188 static void showExternal( String name, ModuleUpdate.External ext_upd ) { 189 module_name = name; 190 external = ext_upd; 191 192 createDialog(); 193 194 dialog.setVisible(true); 195 } 196 197 private static void createDialog() { 198 externalPanel = new ExternalDialog(); 199 200 acceptButton = new JButton ( getBundle( "BTN_Ext_OK" ) ); 201 acceptButton.getAccessibleContext().setAccessibleDescription(getBundle( "ACSD_Ext_OK" )); 202 acceptButton.setMnemonic(getBundle( "ACS_Ext_OK_mnc" ).charAt(0)); 203 declineButton = new JButton ( getBundle( "BTN_Ext_Cancel" ) ); 204 declineButton.getAccessibleContext().setAccessibleDescription(getBundle( "ACSD_Ext_Cancel" )); 205 declineButton.setMnemonic(getBundle( "ACS_Ext_Cancel_mnc" ).charAt(0)); 206 207 dialogDescriptor = new DialogDescriptor( 208 externalPanel, 209 getBundle( "CTL_Ext_Title" ), 210 true, new Object [] { acceptButton, declineButton }, acceptButton, DialogDescriptor.BOTTOM_ALIGN, null, new java.awt.event.ActionListener () { 216 217 public void actionPerformed(java.awt.event.ActionEvent evt) { 218 if (evt.getSource() == acceptButton) 219 try { 220 org.openide.awt.HtmlBrowser.URLDisplayer.getDefault().showURL(new URL (external.getStart_url())); 221 } 222 catch (java.net.MalformedURLException e) { 223 Exceptions.printStackTrace(e); 224 } 225 dialog.setVisible(false); 226 } 227 }); 228 229 dialog = DialogDisplayer.getDefault().createDialog( dialogDescriptor ); 230 } 231 232 private static String getBundle( String key ) { 233 return NbBundle.getMessage( ExternalDialog.class, key ); 234 } 235 } 236 | Popular Tags |