1 19 20 package org.netbeans.modules.autoupdate; 21 22 import java.awt.Dialog ; 23 import java.awt.Font ; 24 import javax.swing.JButton ; 25 26 import org.openide.DialogDescriptor; 27 import org.openide.DialogDisplayer; 28 import org.openide.util.NbBundle; 29 30 33 class LicenceDialog extends javax.swing.JPanel { 34 35 36 private static final java.awt.Dimension preferredSize = new java.awt.Dimension ( 620, 475 ); 37 38 39 private static LicenceDialog licencePanel; 40 41 private static DialogDescriptor dialogDescriptor = null; 42 43 private static boolean accepted = false; 44 45 static final long serialVersionUID =-4862117522808181670L; 46 47 public LicenceDialog () { 48 initComponents (); 49 50 getAccessibleContext ().setAccessibleName (getBundle ("CTL_Licence_Title")); 51 getAccessibleContext ().setAccessibleDescription (getBundle ("ACS_LicenceDialog")); 52 licenceTextArea.getAccessibleContext ().setAccessibleName (getBundle ("ACS_LicenceDialog_Licence")); 53 licenceTextArea.getAccessibleContext ().setAccessibleDescription (getBundle ("ACSD_LicenceDialog_Licence")); 54 } 55 56 57 public java.awt.Dimension getPreferredSize () { 58 return preferredSize; 59 } 60 61 66 private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane (); 68 licenceTextArea = new javax.swing.JTextArea (); 69 70 setLayout(new java.awt.BorderLayout ()); 71 72 setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (8, 8, 8, 8))); 73 licenceTextArea.setEditable(false); 74 licenceTextArea.setFont(new Font ("Monospaced", Font.PLAIN, licenceTextArea.getFont().getSize() + 1)); 75 jScrollPane1.setViewportView(licenceTextArea); 76 77 add(jScrollPane1, java.awt.BorderLayout.CENTER); 78 79 } 81 82 private javax.swing.JScrollPane jScrollPane1; 84 private javax.swing.JTextArea licenceTextArea; 85 87 void setLicenceText ( String licenceText ) { 88 licenceTextArea.setText ( licenceText ); 89 licenceTextArea.setCaretPosition (0); 90 licenceTextArea.revalidate (); 91 } 92 93 static boolean acceptLicence ( String licenceText ) { 94 createDialog (licenceText).setVisible (true); 95 96 return accepted; 97 } 98 99 private static Dialog createDialog (String licenseText) { 100 licencePanel = new LicenceDialog (); 101 licencePanel.setLicenceText (licenseText); 102 103 final JButton acceptButton = new JButton ( getBundle ( "CTL_Licence_Accept" ) ); 104 acceptButton.setMnemonic (getBundle ( "ACS_Licence_Accept_mnc" ).charAt (0) ); 105 final JButton declineButton = new JButton ( getBundle ( "CTL_Licence_Decline" )); 106 declineButton.setMnemonic (getBundle ( "ACS_Licence_Decline_mnc" ).charAt (0) ); 107 108 acceptButton.getAccessibleContext ().setAccessibleDescription (getBundle ("ACS_Licence_Accept")); 109 declineButton.getAccessibleContext ().setAccessibleDescription (getBundle ("ACS_Licence_Decline")); 110 111 accepted = false; 112 113 dialogDescriptor = new DialogDescriptor ( 114 licencePanel, 115 getBundle ( "CTL_Licence_Title" ), 116 true, new Object [] { acceptButton, declineButton }, acceptButton, DialogDescriptor.BOTTOM_ALIGN, null, new java.awt.event.ActionListener () { 122 public void actionPerformed ( java.awt.event.ActionEvent evt ) { 123 accepted = evt.getSource ().equals (acceptButton); 124 } 125 }); 126 127 dialogDescriptor.setClosingOptions (null); 128 129 return DialogDisplayer.getDefault ().createDialog ( dialogDescriptor ); 130 } 131 132 private static String getBundle ( String key ) { 133 return NbBundle.getMessage ( LicenceDialog.class, key ); 134 } 135 } 136 | Popular Tags |