1 2 25 26 27 package org.aspectj.ajde.ui.internal; 28 29 import java.util.*; 30 import java.io.*; 31 import org.aspectj.ajde.Ajde; 32 import org.aspectj.asm.associations.*; 33 34 37 public class BrowserViewProperties { 38 public static final String FILE_NAME = "/.ajbrowser"; 39 private final String VALUE_SEP = ";"; 40 private Properties properties = new Properties(); 41 42 public BrowserViewProperties() { 43 try { 44 if (new File(getPropertiesFilePath()).exists()) { 45 properties.load(new FileInputStream(getPropertiesFilePath())); 46 } 47 } catch (IOException ioe) { 48 Ajde.getDefault().getErrorHandler().handleError("Could not read properties", ioe); 49 } 50 } 51 52 public List getStructureViewOrdering() { 53 return getPropertyValues("structureView.ordering"); 54 } 55 56 public void setStructureViewOrdering(List ordering) { 57 storeProperty("structureView.ordering", ordering); 58 } 59 60 84 public void setActiveAssociations(List associations) { 85 storeProperty("structureView.associations", associations); 86 } 87 88 public void setActiveFilteredMemberKinds(List associations) { 89 storeProperty("structureView.filtering.memberKinds", associations); 90 } 91 92 public String getActiveHierarchy() { 93 return getProperty("structureView.hierarchy"); 94 } 95 96 public void setActiveHierarchy(String hierarchy) { 97 storeProperty("structureView.hierarchy", hierarchy); 98 } 99 100 public List getActiveVisibility() { 101 return getPropertyValues("structureView.filtering.accessibility"); 102 } 103 104 public void setActiveVisiblity(List visibility) { 105 storeProperty("structureView.filtering.accessibility", visibility); 106 } 107 108 public List getActiveModifiers() { 109 return getPropertyValues("structureView.filtering.modifiers"); 110 } 111 112 public List getActiveFilteredMemberKinds() { 113 return getPropertyValues("structureView.filtering.memberKinds"); 114 } 115 116 public String getActiveGranularity() { 117 return getProperty("structureView.granularity"); 118 } 119 120 public void setActiveGranularity(String granularity) { 121 storeProperty("structureView.granularity", granularity); 122 } 123 124 public void setActiveModifiers(List modifiers) { 125 storeProperty("structureView.filtering.modifiers", modifiers); 126 } 127 128 protected String getProperty(String name) { 129 return properties.getProperty(name); 130 } 131 132 protected List getPropertyValues(String name) { 133 List values = new ArrayList(); 134 String valuesString = properties.getProperty(name); 135 if (valuesString != null && !valuesString.trim().equals("")) { 136 StringTokenizer st = new StringTokenizer(valuesString, VALUE_SEP); 137 while (st.hasMoreTokens()) { 138 values.add(st.nextToken()); 139 } 140 } 141 return values; 142 } 143 144 private void storeProperty(String name, String value) { 145 properties.setProperty(name, value); 146 saveProperties(); 147 } 148 149 private void storeProperty(String name, List values) { 150 String valuesString = ""; 151 for (Iterator it = values.iterator(); it.hasNext(); ) { 152 valuesString += (String )it.next() + ';'; 153 } 154 properties.setProperty(name, valuesString); 155 saveProperties(); 156 } 157 158 private void saveProperties() { 159 try { 160 properties.store(new FileOutputStream(getPropertiesFilePath()), "AJDE Settings"); 161 } catch (IOException ioe) { 162 Ajde.getDefault().getErrorHandler().handleError("Could not write properties", ioe); 163 } 164 } 165 166 protected String getPropertiesFilePath() { 167 String path = System.getProperty("user.home"); 168 if (path == null) { 169 path = "."; 170 } 171 return path + FILE_NAME; 172 } 173 } 174 | Popular Tags |