1 11 package org.eclipse.jface.text.templates.persistence; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jface.text.templates.Template; 16 17 18 30 public class TemplatePersistenceData { 31 private final Template fOriginalTemplate; 32 private final String fId; 33 private final boolean fOriginalIsEnabled; 34 35 private Template fCustomTemplate= null; 36 private boolean fIsDeleted= false; 37 private boolean fCustomIsEnabled= true; 38 39 46 public TemplatePersistenceData(Template template, boolean enabled) { 47 this(template, enabled, null); 48 } 49 50 60 public TemplatePersistenceData(Template template, boolean enabled, String id) { 61 Assert.isNotNull(template); 62 fOriginalTemplate= template; 63 fCustomTemplate= template; 64 fOriginalIsEnabled= enabled; 65 fCustomIsEnabled= enabled; 66 fId= id; 67 } 68 69 74 public String getId() { 75 return fId; 76 } 77 78 84 public boolean isDeleted() { 85 return fIsDeleted; 86 } 87 88 93 public void setDeleted(boolean isDeleted) { 94 fIsDeleted= isDeleted; 95 } 96 97 102 public Template getTemplate() { 103 return fCustomTemplate; 104 } 105 106 107 112 public void setTemplate(Template template) { 113 fCustomTemplate= template; 114 } 115 116 124 public boolean isCustom() { 125 return fId == null 126 || fIsDeleted 127 || fOriginalIsEnabled != fCustomIsEnabled 128 || !fOriginalTemplate.equals(fCustomTemplate); 129 } 130 131 137 public boolean isModified() { 138 return isCustom() && !isUserAdded(); 139 } 140 141 147 public boolean isUserAdded() { 148 return fId == null; 149 } 150 151 152 155 public void revert() { 156 fCustomTemplate= fOriginalTemplate; 157 fCustomIsEnabled= fOriginalIsEnabled; 158 fIsDeleted= false; 159 } 160 161 162 167 public boolean isEnabled() { 168 return fCustomIsEnabled; 169 } 170 171 176 public void setEnabled(boolean isEnabled) { 177 fCustomIsEnabled= isEnabled; 178 } 179 } 180 | Popular Tags |