KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > common > BeanCustomizer


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  * BeanCustomizer.java
21  *
22  * Created on October 8, 2003, 11:13 AM
23  */

24
25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.common;
26
27 import java.awt.Color JavaDoc;
28 import java.awt.Container JavaDoc;
29 import java.awt.GridBagConstraints JavaDoc;
30 import java.awt.Insets JavaDoc;
31
32 import java.beans.Customizer JavaDoc;
33 import java.beans.PropertyChangeSupport JavaDoc;
34 import java.beans.PropertyChangeListener JavaDoc;
35
36 import java.util.Collection JavaDoc;
37 import java.util.Iterator JavaDoc;
38
39 import org.openide.util.HelpCtx;
40
41 import org.netbeans.modules.j2ee.sun.share.configbean.Base;
42
43 /** IMPORTANT
44  *
45  * This file is going to become obsolete and replaced by BaseCustomizer in
46  * the near future.
47  *
48  *
49  * -Peter
50  */

51
52 /**
53  *
54  * @deprecated
55  * @author Rajeshwar Patil
56  * @version %I%, %G%
57  */

58 public abstract class BeanCustomizer extends javax.swing.JPanel JavaDoc
59         implements Customizer JavaDoc, ErrorSupportClient, HelpCtx.Provider {
60             
61     /* A class implementation comment can go here. */
62     
63     protected ErrorSupport errorSupport;
64     protected ValidationSupport validationSupport;
65
66     private Base theBean;
67     protected boolean initializing = false;
68
69     public BeanCustomizer(){
70         errorSupport = new ErrorSupport(this);
71         validationSupport = new ValidationSupport();
72     }
73
74     public void setObject(Object JavaDoc bean) {
75                 initializing = true;
76         // Only do this if the bean is actually changing.
77
if(theBean != bean) {
78 // if(theBean != null) {
79
// // commit old object
80
// }
81

82             if(bean instanceof Base) {
83                 theBean = (Base) bean;
84             }
85         }
86     }
87     
88     // Currently used by getTitlePanel -- may change.
89
Base getBean() {
90         return theBean;
91     }
92
93     protected void notifyChange(){
94         //fire an unspecified property change event
95
//support.firePropertyChange("", null, null);
96
firePropertyChange("", null, null);
97         
98         //do not enable save when initializing customizers
99
if(!initializing){
100             theBean.setDirty();
101         }
102     }
103
104
105     protected void validateEntries(){
106         if(errorSupport != null){
107             errorSupport.showErrors();
108         }
109     }
110
111
112     public Container JavaDoc getErrorPanelParent(){
113         return this;
114     }
115
116
117     public GridBagConstraints JavaDoc getErrorPanelConstraints(){
118         GridBagConstraints JavaDoc gridBagConstraints = new GridBagConstraints JavaDoc();
119         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
120         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
121         gridBagConstraints.weightx = 1.0;
122         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6,12,11,11);
123         return gridBagConstraints;
124     }
125
126
127     public Collection JavaDoc getErrors(){
128         return null;
129     }
130     
131     public Color JavaDoc getMessageForegroundColor() {
132         return BaseCustomizer.getErrorForegroundColor();
133     }
134
135     /** Returns the help ID for this customizer.
136      *
137      * @return String representing the help ID for this customizer
138      */

139     abstract public String JavaDoc getHelpId();
140
141     /** -----------------------------------------------------------------------
142      * Implementation of HelpCtx.Provider interface
143      */

144     public HelpCtx getHelpCtx() {
145         return new HelpCtx(getHelpId());
146     }
147     
148 }
149
Popular Tags