2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
41
package org.netbeans.modules.xml.tax.beans.customizer;
43
import java.beans.PropertyChangeEvent;
45
import org.netbeans.tax.TreeException;
46
import org.netbeans.tax.TreeComment;
47
import org.netbeans.tax.TreeData;
49
import org.netbeans.modules.xml.tax.util.TAXUtil;
53
* @author Libor Kramolis
56
public class TreeCommentCustomizer extends AbstractTreeCustomizer {
58
/** Serial Version UID */
59
private static final long serialVersionUID =-2298790138555257739L;
67
public TreeCommentCustomizer () {
81
protected final TreeComment getComment () {
82
return (TreeComment)getTreeObject ();
87
protected final void safePropertyChange (PropertyChangeEvent pche) {
88
super.safePropertyChange (pche);
90
if (pche.getPropertyName ().equals (TreeData.PROP_DATA)) {
91
updateDataComponent ();
97
protected final void updateCommentData () {
99
getComment ().setData (dataTextArea.getText ());
100
} catch (TreeException exc) {
101
updateDataComponent ();
102
TAXUtil.notifyTreeException (exc);
108
protected final void updateDataComponent () {
109
dataTextArea.setText (getComment ().getData ());
114
protected final void initComponentValues () {
115
updateDataComponent ();
121
protected final void updateReadOnlyStatus (boolean editable) {
122
dataTextArea.setEditable (editable);
126
/** This method is called from within the constructor to
127
* initialize the form.
128
* WARNING: Do NOT modify this code. The content of this method is
129
* always regenerated by the FormEditor.
131
private void initComponents() {//GEN-BEGIN:initComponents
132
java.awt.GridBagConstraints gridBagConstraints;
134
dataPanel = new javax.swing.JPanel();
135
dataScroll = new javax.swing.JScrollPane();
136
dataTextArea = new javax.swing.JTextArea();
138
setLayout(new java.awt.GridBagLayout());
140
setPreferredSize(new java.awt.Dimension(350, 230));
141
dataPanel.setLayout(new java.awt.BorderLayout());
143
dataTextArea.addFocusListener(new java.awt.event.FocusAdapter() {
144
public void focusGained(java.awt.event.FocusEvent evt) {
145
dataTextAreaFocusGained(evt);
147
public void focusLost(java.awt.event.FocusEvent evt) {
148
dataTextAreaFocusLost(evt);
152
dataTextArea.addKeyListener(new java.awt.event.KeyAdapter() {
153
public void keyPressed(java.awt.event.KeyEvent evt) {
154
dataTextAreaKeyPressed(evt);
158
dataScroll.setViewportView(dataTextArea);
160
dataPanel.add(dataScroll, java.awt.BorderLayout.CENTER);
162
gridBagConstraints = new java.awt.GridBagConstraints();
163
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
164
gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
165
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
166
gridBagConstraints.weightx = 1.0;
167
gridBagConstraints.weighty = 1.0;
168
gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 11);
169
add(dataPanel, gridBagConstraints);
171
}//GEN-END:initComponents
173
private void dataTextAreaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_dataTextAreaFocusGained
174
if ("new".equals(getClientProperty("xml-edit-mode"))) { // NOI18N
175
dataTextArea.selectAll();
177
}//GEN-LAST:event_dataTextAreaFocusGained
179
private void dataTextAreaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dataTextAreaKeyPressed
180
// Add your handling code here:
181
if ( applyKeyPressed (evt) ) {
182
updateCommentData ();
184
}//GEN-LAST:event_dataTextAreaKeyPressed
186
private void dataTextAreaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_dataTextAreaFocusLost
187
// Add your handling code here:
188
updateCommentData ();
189
}//GEN-LAST:event_dataTextAreaFocusLost
191
// Variables declaration - do not modify//GEN-BEGIN:variables
192
private javax.swing.JTextArea dataTextArea;
193
private javax.swing.JPanel dataPanel;
194
private javax.swing.JScrollPane dataScroll;
195
// End of variables declaration//GEN-END:variables
197
/** Initialize accesibility
199
public void initAccessibility (){
201
this.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_TreeCommentCustomizer"));
202
dataTextArea.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_dataPanel"));
203
dataTextArea.getAccessibleContext ().setAccessibleName (Util.THIS.getString ("ACSN_dataPanel"));