KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > i18n > java > JavaPropertyPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.modules.i18n.java;
22
23 import java.awt.Dialog JavaDoc;
24 import java.awt.event.ActionEvent JavaDoc;
25 import java.awt.event.ActionListener JavaDoc;
26 import java.awt.GridBagConstraints JavaDoc;
27 import java.awt.GridBagLayout JavaDoc;
28 import java.awt.Insets JavaDoc;
29 import java.util.ResourceBundle JavaDoc;
30 import javax.swing.JButton JavaDoc;
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 /**
41  * Property panel for <code>JavaI18nString</code>'s.
42  *
43  * @author Peter Zavadsky
44  */

45 public class JavaPropertyPanel extends PropertyPanel {
46
47     private final ResourceBundle JavaDoc bundle;
48     
49     /** Creates new form JavaPropertyPanel */
50     public JavaPropertyPanel() {
51         bundle = org.openide.util.NbBundle.getBundle(JavaPropertyPanel.class);
52         initComponents();
53     }
54     
55     /** This method is called from within the constructor to
56      * initialize the form.
57      * WARNING: Do NOT modify this code. The content of this method is
58      * always regenerated by the Form Editor.
59      */

60     private void initComponents() {
61         argumentsButton.setVisible(true);
62         argumentsButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_CTL_Arguments"));
63         argumentsButton.addActionListener(new ActionListener JavaDoc() {
64             public void actionPerformed(ActionEvent JavaDoc evt) {
65                 argumentsButtonActionPerformed(evt);
66             }
67         }
68         );
69     }
70
71     /** Action handler for arguments button. */
72     private void argumentsButtonActionPerformed(ActionEvent JavaDoc evt) {
73         final JavaI18nString javaI18nString = (JavaI18nString)i18nString;
74         
75         final Dialog JavaDoc[] dialogs = new Dialog JavaDoc[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"), // NOI18N
83
true,
84             DialogDescriptor.OK_CANCEL_OPTION,
85             DialogDescriptor.OK_OPTION,
86             new ActionListener JavaDoc() {
87                 public void actionPerformed(ActionEvent JavaDoc 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     /** Overrides superclass method. */
105     protected void updateReplaceText() {
106         super.updateReplaceText();
107         
108         argumentsButton.setEnabled(i18nString.getReplaceFormat().indexOf("{arguments}") >= 0 ); // NOI18N
109
}
110
111 }
112
Popular Tags