001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.visualweb.faces.dt;
042:
043: import java.awt.BorderLayout;
044: import java.awt.event.ActionEvent;
045: import java.awt.event.ActionListener;
046: import java.awt.event.KeyEvent;
047: import java.awt.event.KeyListener;
048: import java.beans.PropertyEditorSupport;
049: import javax.swing.JPanel;
050: import javax.swing.event.DocumentEvent;
051: import javax.swing.event.DocumentListener;
052: import javax.swing.event.ListSelectionEvent;
053: import javax.swing.event.ListSelectionListener;
054: import com.sun.rave.designtime.DesignProperty;
055:
056: /**
057: * @author eric
058: *
059: * TODO To change the template for this generated type comment go to
060: * Window - Preferences - Java - Code Generation - Code and Comments
061: */
062: public abstract class AbstractPropertyJPanel extends JPanel implements
063: ActionListener, KeyListener, DocumentListener,
064: ListSelectionListener {
065:
066: protected boolean initializing;
067: protected DesignProperty liveProperty;
068: protected AbstractPropertyEditor propertyEditor;
069:
070: public AbstractPropertyJPanel(
071: AbstractPropertyEditor propertyEditor,
072: DesignProperty liveProperty) {
073:
074: super (new BorderLayout());
075: initializing = true;
076: setPropertyEditorAndDesignProperty(propertyEditor, liveProperty);
077: initializeComponents();
078: }
079:
080: public void actionPerformed(ActionEvent event) {
081:
082: }
083:
084: /**
085: * Gives notification that an attribute or set of attributes changed.
086: */
087: public void changedUpdate(DocumentEvent event) {
088:
089: if (initializing) {
090: return;
091: }
092: documentEvent(event);
093: }
094:
095: public void documentEvent(DocumentEvent event) {
096: }
097:
098: public void doLayout() {
099:
100: super .doLayout();
101: initializing = false;
102: }
103:
104: protected DesignProperty getDesignProperty() {
105:
106: return liveProperty;
107: }
108:
109: protected PropertyEditorSupport getPropertyEditor() {
110:
111: return propertyEditor;
112: }
113:
114: protected void grabCurrentValueFromPropertyEditor() {
115:
116: }
117:
118: protected abstract void initializeComponents();
119:
120: /**
121: * Gives notification that there was an insert into the document. The
122: * range given by the DocumentEvent bounds the freshly inserted region.
123: *
124: * @param e the document event
125: */
126: public void insertUpdate(DocumentEvent event) {
127:
128: if (initializing) {
129: return;
130: }
131: documentEvent(event);
132: }
133:
134: public void keyPressed(KeyEvent event) {
135: }
136:
137: public void keyReleased(KeyEvent event) {
138: }
139:
140: public void keyTyped(KeyEvent event) {
141: }
142:
143: /**
144: * Gives notification that a portion of the document has been
145: * removed. The range is given in terms of what the view last
146: * saw (that is, before updating sticky positions).
147: *
148: * @param e the document event
149: */
150: public void removeUpdate(DocumentEvent event) {
151:
152: if (initializing) {
153: return;
154: }
155: documentEvent(event);
156: }
157:
158: protected void setPropertyEditorAndDesignProperty(
159: AbstractPropertyEditor propertyEditor,
160: DesignProperty liveProperty) {
161:
162: this .propertyEditor = propertyEditor;
163: this .liveProperty = liveProperty;
164: grabCurrentValueFromPropertyEditor();
165: }
166:
167: public void valueChanged(ListSelectionEvent event) {
168:
169: }
170: }
|