1 19 20 21 package org.netbeans.modules.i18n.java; 22 23 import java.awt.Dialog ; 24 import java.awt.event.ActionEvent ; 25 import java.awt.event.ActionListener ; 26 import java.awt.GridBagConstraints ; 27 import java.awt.GridBagLayout ; 28 import java.awt.Insets ; 29 import java.util.ResourceBundle ; 30 import javax.swing.JButton ; 31 32 import org.netbeans.modules.i18n.I18nString; 33 import org.netbeans.modules.i18n.I18nUtil; 34 import org.netbeans.modules.i18n.PropertyPanel; 35 36 import org.openide.DialogDescriptor; 37 import org.openide.DialogDisplayer; 38 39 40 45 public class JavaPropertyPanel extends PropertyPanel { 46 47 private final ResourceBundle bundle; 48 49 50 public JavaPropertyPanel() { 51 bundle = org.openide.util.NbBundle.getBundle(JavaPropertyPanel.class); 52 initComponents(); 53 } 54 55 60 private void initComponents() { 61 argumentsButton.setVisible(true); 62 argumentsButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_CTL_Arguments")); 63 argumentsButton.addActionListener(new ActionListener () { 64 public void actionPerformed(ActionEvent evt) { 65 argumentsButtonActionPerformed(evt); 66 } 67 } 68 ); 69 } 70 71 72 private void argumentsButtonActionPerformed(ActionEvent evt) { 73 final JavaI18nString javaI18nString = (JavaI18nString)i18nString; 74 75 final Dialog [] dialogs = new Dialog [1]; 76 final ParamsPanel paramsPanel = new ParamsPanel(); 77 78 paramsPanel.setArguments(javaI18nString.getArguments()); 79 80 DialogDescriptor dd = new DialogDescriptor( 81 paramsPanel, 82 bundle.getString("CTL_ParamsPanelTitle"), true, 84 DialogDescriptor.OK_CANCEL_OPTION, 85 DialogDescriptor.OK_OPTION, 86 new ActionListener () { 87 public void actionPerformed(ActionEvent ev) { 88 if(ev.getSource() == DialogDescriptor.OK_OPTION) { 89 javaI18nString.setArguments(paramsPanel.getArguments()); 90 updateReplaceText(); 91 92 dialogs[0].setVisible(false); 93 dialogs[0].dispose(); 94 } else { 95 dialogs[0].setVisible(false); 96 dialogs[0].dispose(); 97 } 98 } 99 }); 100 dialogs[0] = DialogDisplayer.getDefault().createDialog(dd); 101 dialogs[0].setVisible(true); 102 } 103 104 105 protected void updateReplaceText() { 106 super.updateReplaceText(); 107 108 argumentsButton.setEnabled(i18nString.getReplaceFormat().indexOf("{arguments}") >= 0 ); } 110 111 } 112 | Popular Tags |