KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > changelog > html > HtmlPanelCustomizer


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 Ralph Krueger.
17  */

18 package org.netbeans.modules.changelog.html;
19
20 /**
21  *
22  * @author ralph
23  */

24
25 import org.openide.util.*;
26 import javax.swing.event.*;
27 import javax.swing.*;
28 import org.netbeans.modules.changelog.*;
29
30
31 public class HtmlPanelCustomizer extends javax.swing.JPanel JavaDoc implements java.beans.Customizer JavaDoc {
32
33     ChangeLogHTMLService service;
34     private boolean disableFiring = false;
35     /** Creates new form FilterPanel */
36     public HtmlPanelCustomizer() {
37         initComponents();
38         java.awt.event.ActionListener JavaDoc actionList = new java.awt.event.ActionListener JavaDoc() {
39             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
40                 setData();
41             }
42         };
43         txCVSROOT.addActionListener(actionList);
44         txDiffURL.addActionListener(actionList);
45         txRevisionURL.addActionListener(actionList);
46         javax.swing.event.DocumentListener JavaDoc docList = new javax.swing.event.DocumentListener JavaDoc() {
47                 public void insertUpdate(javax.swing.event.DocumentEvent JavaDoc e) {
48                     setData();
49                 }
50                 public void removeUpdate(javax.swing.event.DocumentEvent JavaDoc e) {
51                     setData();
52                 }
53                 public void changedUpdate(javax.swing.event.DocumentEvent JavaDoc e) {
54                  // setData();
55
}
56         };
57         txCVSROOT.getDocument().addDocumentListener(docList);
58         txDiffURL.getDocument().addDocumentListener(docList);
59         txRevisionURL.getDocument().addDocumentListener(docList);
60         // set the same background as the panel has..
61
taExplanation.setBackground(this.getBackground());
62     }
63     
64     /** This method is called from within the constructor to
65      * initialize the form.
66      * WARNING: Do NOT modify this code. The content of this method is
67      * always regenerated by the Form Editor.
68      */

69     private void initComponents() {//GEN-BEGIN:initComponents
70
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
71
72         lblDiffURL = new javax.swing.JLabel JavaDoc();
73         txDiffURL = new javax.swing.JTextField JavaDoc();
74         lblRevisionURL = new javax.swing.JLabel JavaDoc();
75         txRevisionURL = new javax.swing.JTextField JavaDoc();
76         spExplanation = new javax.swing.JScrollPane JavaDoc();
77         taExplanation = new javax.swing.JTextArea JavaDoc();
78         lblCVSROOT = new javax.swing.JLabel JavaDoc();
79         txCVSROOT = new javax.swing.JTextField JavaDoc();
80
81         setLayout(new java.awt.GridBagLayout JavaDoc());
82
83         setPreferredSize(new java.awt.Dimension JavaDoc(600, 300));
84         setMinimumSize(new java.awt.Dimension JavaDoc(400, 200));
85         lblDiffURL.setText(org.openide.util.NbBundle.getBundle(HtmlPanelCustomizer.class).getString("HtmlPanel.lblDiffURL"));
86         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
87         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
88         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 6, 6);
89         add(lblDiffURL, gridBagConstraints);
90
91         txDiffURL.setText("jTextField1");
92         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
93         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
94         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
95         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 6, 12);
96         add(txDiffURL, gridBagConstraints);
97
98         lblRevisionURL.setText(org.openide.util.NbBundle.getBundle(HtmlPanelCustomizer.class).getString("HtmlPanel.lblRevisionURL.text"));
99         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
100         gridBagConstraints.gridx = 0;
101         gridBagConstraints.gridy = 1;
102         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
103         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 6, 6);
104         add(lblRevisionURL, gridBagConstraints);
105
106         txRevisionURL.setText("jTextField2");
107         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
108         gridBagConstraints.gridx = 1;
109         gridBagConstraints.gridy = 1;
110         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
111         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
112         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 6, 12);
113         add(txRevisionURL, gridBagConstraints);
114
115         taExplanation.setEditable(false);
116         taExplanation.setText(org.openide.util.NbBundle.getBundle(HtmlPanelCustomizer.class).getString("HtmlPanel.taExplanation.text"));
117         spExplanation.setViewportView(taExplanation);
118
119         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
120         gridBagConstraints.gridx = 0;
121         gridBagConstraints.gridy = 2;
122         gridBagConstraints.gridwidth = 2;
123         gridBagConstraints.gridheight = 2;
124         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
125         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
126         gridBagConstraints.weightx = 0.5;
127         gridBagConstraints.weighty = 0.5;
128         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 6, 12);
129         add(spExplanation, gridBagConstraints);
130
131         lblCVSROOT.setLabelFor(txCVSROOT);
132         lblCVSROOT.setText(org.openide.util.NbBundle.getBundle(HtmlPanelCustomizer.class).getString("HtmlPanel.lblCVSROOT.text"));
133         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
134         gridBagConstraints.gridx = 0;
135         gridBagConstraints.gridy = 4;
136         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
137         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 12, 6);
138         add(lblCVSROOT, gridBagConstraints);
139
140         txCVSROOT.setPreferredSize(new java.awt.Dimension JavaDoc(150, 20));
141         txCVSROOT.setMinimumSize(new java.awt.Dimension JavaDoc(50, 22));
142         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
143         gridBagConstraints.gridx = 1;
144         gridBagConstraints.gridy = 4;
145         gridBagConstraints.ipadx = 45;
146         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
147         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 12, 12);
148         add(txCVSROOT, gridBagConstraints);
149
150     }//GEN-END:initComponents
151

152     /** Set the object to be customized. This method should be called only
153      * once, before the Customizer has been added to any parent AWT container.
154      * @param bean The object to be customized.
155      */

156     public void setObject(Object JavaDoc bean) {
157         if (bean instanceof ChangeLogHTMLService) {
158             service = (ChangeLogHTMLService)bean;
159             disableFiring = true;
160             if (service.getCvsRootPrefix() != null) {
161                 txCVSROOT.setText(service.getCvsRootPrefix());
162             } else {
163                 txCVSROOT.setText("");
164             }
165             if (service.getDiffURL() != null) {
166                 txDiffURL.setText(service.getDiffURL());
167             } else {
168                 txDiffURL.setText("");
169             }
170             if (service.getRevisionURL() != null) {
171                 txRevisionURL.setText(service.getRevisionURL());
172             } else {
173                 txRevisionURL.setText("");
174             }
175             disableFiring = false;
176         }
177     }
178
179     
180     public void setData() {
181         if (service != null && !disableFiring) {
182             if (txCVSROOT.getText() != null &&
183                       txCVSROOT.getText().length() > 0) {
184                 service.setCvsRootPrefix(txCVSROOT.getText());
185             } else {
186                 service.setCvsRootPrefix(null);
187             }
188             if (txDiffURL.getText() != null &&
189                       txDiffURL.getText().length() > 0) {
190                 service.setDiffURL(txDiffURL.getText());
191             } else {
192                 service.setDiffURL(null);
193             }
194             if (txRevisionURL.getText() != null &&
195                       txRevisionURL.getText().length() > 0) {
196                 service.setRevisionURL(txRevisionURL.getText());
197             } else {
198                 service.setRevisionURL(null);
199             }
200         }
201     }
202     
203     public void disableEditing(boolean disable) {
204         txCVSROOT.setEnabled(!disable);
205         txDiffURL.setEnabled(!disable);
206         txRevisionURL.setEnabled(!disable);
207     }
208     
209     // Variables declaration - do not modify//GEN-BEGIN:variables
210
private javax.swing.JTextField JavaDoc txDiffURL;
211     private javax.swing.JLabel JavaDoc lblCVSROOT;
212     private javax.swing.JTextField JavaDoc txRevisionURL;
213     private javax.swing.JLabel JavaDoc lblRevisionURL;
214     private javax.swing.JTextField JavaDoc txCVSROOT;
215     private javax.swing.JTextArea JavaDoc taExplanation;
216     private javax.swing.JScrollPane JavaDoc spExplanation;
217     private javax.swing.JLabel JavaDoc lblDiffURL;
218     // End of variables declaration//GEN-END:variables
219

220 }
221
Popular Tags