1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.common; 26 27 import java.awt.Color ; 28 import java.awt.Container ; 29 import java.awt.GridBagConstraints ; 30 import java.awt.Insets ; 31 32 import java.beans.Customizer ; 33 import java.beans.PropertyChangeSupport ; 34 import java.beans.PropertyChangeListener ; 35 36 import java.util.Collection ; 37 import java.util.Iterator ; 38 39 import org.openide.util.HelpCtx; 40 41 import org.netbeans.modules.j2ee.sun.share.configbean.Base; 42 43 51 52 58 public abstract class BeanCustomizer extends javax.swing.JPanel 59 implements Customizer , ErrorSupportClient, HelpCtx.Provider { 60 61 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 bean) { 75 initializing = true; 76 if(theBean != bean) { 78 82 if(bean instanceof Base) { 83 theBean = (Base) bean; 84 } 85 } 86 } 87 88 Base getBean() { 90 return theBean; 91 } 92 93 protected void notifyChange(){ 94 firePropertyChange("", null, null); 97 98 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 getErrorPanelParent(){ 113 return this; 114 } 115 116 117 public GridBagConstraints getErrorPanelConstraints(){ 118 GridBagConstraints gridBagConstraints = new GridBagConstraints (); 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 (6,12,11,11); 123 return gridBagConstraints; 124 } 125 126 127 public Collection getErrors(){ 128 return null; 129 } 130 131 public Color getMessageForegroundColor() { 132 return BaseCustomizer.getErrorForegroundColor(); 133 } 134 135 139 abstract public String getHelpId(); 140 141 144 public HelpCtx getHelpCtx() { 145 return new HelpCtx(getHelpId()); 146 } 147 148 } 149 | Popular Tags |