1 19 20 package org.netbeans.modules.apisupport.project.ui.customizer; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import javax.swing.JPanel ; 25 import org.netbeans.spi.project.ui.support.ProjectCustomizer; 26 import org.openide.util.HelpCtx; 27 28 34 abstract class NbPropertyPanel extends JPanel implements 35 ModuleProperties.LazyStorage, PropertyChangeListener , HelpCtx.Provider { 36 37 private Class helpCtxClass; 38 39 40 static final String VALID_PROPERTY = "isPanelValid"; 42 43 static final String ERROR_MESSAGE_PROPERTY = "errorMessage"; 45 protected ModuleProperties props; 46 47 48 NbPropertyPanel(final ModuleProperties props, final Class helpCtxClass) { 49 this.props = props; 50 props.addLazyStorage(this); 51 initComponents(); 52 props.addPropertyChangeListener(this); 53 this.helpCtxClass = helpCtxClass; 54 } 55 56 59 abstract void refresh(); 60 61 String getProperty(String key) { 62 return props.getProperty(key); 63 } 64 65 void setProperty(String key, String property) { 66 props.setProperty(key, property); 67 } 68 69 boolean getBooleanProperty(String key) { 70 return props.getBooleanProperty(key); 71 } 72 73 void setBooleanProperty(String key, boolean property) { 74 props.setBooleanProperty(key, property); 75 } 76 77 78 85 86 protected final void checkForm() {} 88 89 90 public void store() { } 91 92 public void propertyChange(PropertyChangeEvent evt) { 93 if (ModuleProperties.PROPERTIES_REFRESHED == evt.getPropertyName()) { 94 refresh(); 95 } 96 } 97 98 public void addNotify() { 99 super.addNotify(); 100 firePropertyChange(CustomizerProviderImpl.LAST_SELECTED_PANEL, null, this); 102 } 103 104 public HelpCtx getHelpCtx() { 105 return new HelpCtx(helpCtxClass); 106 } 107 108 113 private void initComponents() { 115 116 setLayout(new java.awt.FlowLayout (java.awt.FlowLayout.CENTER, 0, 0)); 117 118 } 119 121 124 abstract static class Single extends NbPropertyPanel { 125 Single(final SingleModuleProperties props, final Class helpCtxClass) { 126 super(props, helpCtxClass); 127 } 128 SingleModuleProperties getProperties() { 129 return (SingleModuleProperties) props; 130 } 131 } 132 133 abstract static class Suite extends NbPropertyPanel { 134 Suite(final SuiteProperties props, final Class helpCtxClass) { 135 super(props, helpCtxClass); 136 } 137 SuiteProperties getProperties() { 138 return (SuiteProperties) props; 139 } 140 } 141 142 } 143 | Popular Tags |