1 56 package org.objectstyle.cayenne.modeler.dialog.pref; 57 58 import org.objectstyle.cayenne.modeler.Application; 59 import org.objectstyle.cayenne.modeler.FileClassLoadingService; 60 import org.objectstyle.cayenne.pref.Domain; 61 import org.objectstyle.cayenne.pref.HSQLEmbeddedPreferenceEditor; 62 import org.objectstyle.cayenne.pref.HSQLEmbeddedPreferenceService; 63 import org.objectstyle.cayenne.pref.PreferenceDetail; 64 65 70 public class CayenneModelerPreferenceEditor extends HSQLEmbeddedPreferenceEditor { 71 72 protected boolean refreshingClassLoader; 73 protected Application application; 74 75 public CayenneModelerPreferenceEditor(Application application) { 76 super((HSQLEmbeddedPreferenceService) application.getPreferenceService()); 77 this.application = application; 78 } 79 80 public boolean isRefreshingClassLoader() { 81 return refreshingClassLoader; 82 } 83 84 public void setRefreshingClassLoader(boolean refreshingClassLoader) { 85 this.refreshingClassLoader = refreshingClassLoader; 86 } 87 88 public void save() { 89 super.save(); 90 91 if (isRefreshingClassLoader()) { 92 application.initClassLoader(); 93 refreshingClassLoader = false; 94 } 95 } 96 97 public PreferenceDetail createDetail(Domain domain, String key) { 98 changeInDomain(domain); 99 return super.createDetail(domain, key); 100 } 101 102 public PreferenceDetail deleteDetail(Domain domain, String key) { 103 changeInDomain(domain); 104 return super.deleteDetail(domain, key); 105 } 106 107 protected void changeInDomain(Domain domain) { 108 if (!refreshingClassLoader 109 && domain != null 110 && FileClassLoadingService.class.getName().equals(domain.getName())) { 111 refreshingClassLoader = true; 112 } 113 } 114 } | Popular Tags |