1 19 20 package org.netbeans.modules.j2ee.oc4j.customizer; 21 22 import java.awt.event.ItemEvent ; 23 import java.awt.event.ItemListener ; 24 import javax.swing.event.ChangeListener ; 25 import javax.swing.event.DocumentEvent ; 26 import javax.swing.event.DocumentListener ; 27 import javax.swing.event.ListDataEvent ; 28 import javax.swing.event.ListDataListener ; 29 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 30 import org.netbeans.modules.j2ee.oc4j.OC4JDeploymentManager; 31 import org.netbeans.modules.j2ee.oc4j.util.OC4JPluginProperties; 32 33 39 public class OC4JCustomizerDataSupport { 40 41 private OC4JCustomizerSupport.PathModel classModel; 42 private OC4JCustomizerSupport.PathModel javadocModel; 43 44 private boolean javadocModelFlag; 45 46 private OC4JPluginProperties properties; 47 private OC4JDeploymentManager dm; 48 49 52 public OC4JCustomizerDataSupport(OC4JDeploymentManager dm) { 53 this.dm = dm; 54 this.properties = dm.getProperties(); 55 init(); 56 } 57 58 61 private void init() { 62 classModel = new OC4JCustomizerSupport.PathModel(properties.getClasses()); 64 65 javadocModel = new OC4JCustomizerSupport.PathModel(properties.getJavadocs()); 67 javadocModel.addListDataListener(new ModelChangeAdapter() { 68 public void modelChanged() { 69 javadocModelFlag = true; 70 store(); } 72 }); 73 } 74 75 public InstanceProperties getInstanceProperties() { 76 return dm.getInstanceProperties(); 77 } 78 79 public OC4JCustomizerSupport.PathModel getClassModel() { 80 return classModel; 81 } 82 83 public OC4JCustomizerSupport.PathModel getJavadocsModel() { 84 return javadocModel; 85 } 86 87 90 private void store() { 91 if (javadocModelFlag) { 92 properties.setJavadocs(javadocModel.getData()); 93 javadocModelFlag = false; 94 } 95 } 96 97 101 private abstract class ModelChangeAdapter implements ListDataListener , 102 DocumentListener , ItemListener , ChangeListener { 103 104 public abstract void modelChanged(); 105 106 public void contentsChanged(ListDataEvent e) { 107 modelChanged(); 108 } 109 110 public void intervalAdded(ListDataEvent e) { 111 modelChanged(); 112 } 113 114 public void intervalRemoved(ListDataEvent e) { 115 modelChanged(); 116 } 117 118 public void changedUpdate(DocumentEvent e) { 119 modelChanged(); 120 } 121 122 public void removeUpdate(DocumentEvent e) { 123 modelChanged(); 124 } 125 126 public void insertUpdate(DocumentEvent e) { 127 modelChanged(); 128 } 129 130 public void itemStateChanged(ItemEvent e) { 131 modelChanged(); 132 } 133 134 public void stateChanged(javax.swing.event.ChangeEvent e) { 135 modelChanged(); 136 } 137 } 138 } | Popular Tags |