1 19 20 package org.netbeans.modules.autoupdate; 21 22 import java.awt.Font ; 23 import javax.swing.*; 24 import java.beans.PropertyChangeListener ; 25 import java.beans.PropertyChangeEvent ; 26 27 28 import org.openide.DialogDescriptor; 29 import org.openide.DialogDisplayer; 30 import org.openide.util.NbBundle; 31 32 36 class DuplicateWarningDialog extends javax.swing.JPanel { 37 38 static final int YES = 0; 39 static final int YES_ALL = 1; 40 static final int NO = 2; 41 static final int NO_ALL = 3; 42 43 static int result = NO; 44 45 46 public DuplicateWarningDialog(String ucname) { 47 initComponents(); 48 49 iconLabel.setText(NbBundle.getMessage( DuplicateWarningDialog.class, "MSG_DuplicateModule" , 50 ucname )); 51 iconLabel.setFont(ResultsPanel.doDeriveFont(iconLabel.getFont(), Font.BOLD)); 53 54 initAccessibility(); 55 } 56 57 62 private void initComponents() { 64 iconLabel = new javax.swing.JLabel (); 65 66 setLayout(new java.awt.BorderLayout ()); 67 68 setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (18, 18, 18, 18))); 69 iconLabel.setText(getBundle("MSG_DuplicateModule")); 70 iconLabel.setIconTextGap(16); 71 add(iconLabel, java.awt.BorderLayout.CENTER); 72 73 } 74 76 private void initAccessibility(){ 77 getAccessibleContext().setAccessibleDescription(getBundle("ACSD_DuplicateWarning")); 78 getAccessibleContext().setAccessibleName(getBundle( "CTL_Duplicate_Title" )); 79 } 80 81 private javax.swing.JLabel iconLabel; 83 85 private static DialogDescriptor createDialog(String ucname) { 86 87 final JButton yesButton = new JButton(getBundle( "CTL_Duplicate_Yes" ) ); 88 yesButton.setToolTipText( getBundle( "CTL_Duplicate_Yes_ToolTip" ) ); 89 yesButton.setMnemonic(getBundle( "ACS_Duplicate_Yes_mnc" ).charAt(0) ); 90 yesButton.addActionListener(new java.awt.event.ActionListener () { 91 public void actionPerformed(java.awt.event.ActionEvent evt) { 92 result = YES; 93 } 94 }); 95 96 final JButton yes_allButton = new JButton(getBundle( "CTL_Duplicate_Yes_All" ) ); 97 yes_allButton.setToolTipText( getBundle( "CTL_Duplicate_Yes_All_ToolTip" ) ); 98 yes_allButton.setMnemonic(getBundle( "ACS_Duplicate_Yes_All_mnc" ).charAt(0) ); 99 yes_allButton.getAccessibleContext ().setAccessibleName (getBundle ("ACSN_Duplicate_Yes_All")); 100 yes_allButton.getAccessibleContext ().setAccessibleDescription (getBundle ("ACSD_Duplicate_Yes_All")); 101 yes_allButton.addActionListener(new java.awt.event.ActionListener () { 102 public void actionPerformed(java.awt.event.ActionEvent evt) { 103 result = YES_ALL; 104 } 105 }); 106 107 final JButton noButton = new JButton(getBundle( "CTL_Duplicate_No" ) ); 108 noButton.setToolTipText( getBundle( "CTL_Duplicate_No_ToolTip" ) ); 109 noButton.setMnemonic(getBundle( "ACS_Duplicate_No_mnc" ).charAt(0) ); 110 noButton.addActionListener(new java.awt.event.ActionListener () { 111 public void actionPerformed(java.awt.event.ActionEvent evt) { 112 result = NO; 113 } 114 }); 115 116 final JButton no_allButton = new JButton(getBundle( "CTL_Duplicate_No_All" ) ); 117 no_allButton.setToolTipText( getBundle( "CTL_Duplicate_No_All_ToolTip" ) ); 118 no_allButton.setMnemonic(getBundle( "ACS_Duplicate_No_All_mnc" ).charAt(0) ); 119 no_allButton.addActionListener(new java.awt.event.ActionListener () { 120 public void actionPerformed(java.awt.event.ActionEvent evt) { 121 result = NO_ALL; 122 } 123 }); 124 125 126 127 DialogDescriptor dd; 128 dd = new DialogDescriptor( 129 new DuplicateWarningDialog(ucname), 130 getBundle( "CTL_Duplicate_Title" ), 131 true, new Object [] { 133 yesButton, 134 yes_allButton, 135 noButton, 136 no_allButton 137 }, noButton, DialogDescriptor.DEFAULT_ALIGN, null, null); 142 143 dd.addPropertyChangeListener( new PropertyChangeListener () { 144 public void propertyChange(PropertyChangeEvent event) { 145 if (event.getPropertyName().equals(DialogDescriptor.PROP_VALUE)) { 146 Object option = event.getNewValue(); 147 if (option == DialogDescriptor.CLOSED_OPTION) 148 result = NO; 149 } 150 } 151 }); 152 153 dd.setClosingOptions( null ); 154 155 return dd; 156 } 157 158 static void closeDialog(java.awt.Dialog dialog) { 159 dialog.dispose(); 160 } 161 162 static int getResult() { 163 return result; 164 } 165 166 static java.awt.Dialog getDialog(String ucname) { 167 DialogDescriptor dd = createDialog(ucname); 168 result = NO; 169 java.awt.Dialog dialog = DialogDisplayer.getDefault().createDialog( dd ); 170 return dialog; 171 } 172 173 private static String getBundle( String key ) { 174 return NbBundle.getMessage( DuplicateWarningDialog.class, key ); 175 } 176 } 177 178 | Popular Tags |