| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package org.xmlhammer.gui.history; |
| 22 |
|
|
| 23 |
|
import java.net.URI; |
| 24 |
|
import java.util.List; |
| 25 |
|
|
| 26 |
|
import org.bounce.util.URIUtils; |
| 27 |
|
import org.xmlhammer.PreferencesHandler; |
| 28 |
|
import org.xmlhammer.model.preferences.HistoryList; |
| 29 |
|
|
| 30 |
|
public class HistoryUtilities { |
| 31 |
22 |
private static HistoryUtilities utils = null; |
| 32 |
22 |
private HistoryListModel searches = null; |
| 33 |
22 |
private HistoryListModel sources = null; |
| 34 |
22 |
private HistoryListModel results = null; |
| 35 |
22 |
private HistoryListModel schemas = null; |
| 36 |
22 |
private HistoryListModel patterns = null; |
| 37 |
22 |
private HistoryListModel expressions = null; |
| 38 |
22 |
private HistoryListModel directories = null; |
| 39 |
22 |
private HistoryListModel extensions = null; |
| 40 |
22 |
private HistoryListModel stylesheets = null; |
| 41 |
22 |
private HistoryListModel doctypeSystems = null; |
| 42 |
22 |
private HistoryListModel doctypePublics = null; |
| 43 |
22 |
private HistoryListModel cdataSectionElements = null; |
| 44 |
22 |
private HistoryListModel medias = null; |
| 45 |
22 |
private HistoryListModel titles = null; |
| 46 |
22 |
private HistoryListModel charsets = null; |
| 47 |
|
|
| 48 |
|
|
| 49 |
22 |
private HistoryUtilities() { |
| 50 |
22 |
} |
| 51 |
|
|
| 52 |
|
public static HistoryUtilities getInstance() { |
| 53 |
8096 |
if ( utils == null) { |
| 54 |
22 |
utils = new HistoryUtilities(); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
8096 |
return utils; |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
public void addOpenedProject(URI uri) { |
| 62 |
572 |
if ( uri != null) { |
| 63 |
462 |
add(PreferencesHandler.getInstance().getPreferences().getHistory().getProjects(), URIUtils.toString(uri)); |
| 64 |
|
} |
| 65 |
572 |
} |
| 66 |
|
|
| 67 |
|
private void add(HistoryList hist, String value) { |
| 68 |
462 |
if (value != null && value.length() > 0) { |
| 69 |
462 |
List<String> list = hist.getValue(); |
| 70 |
|
|
| 71 |
462 |
for (String item : list) { |
| 72 |
1276 |
if (item.equals(value)) { |
| 73 |
0 |
list.remove(item); |
| 74 |
0 |
break; |
| 75 |
|
} |
| 76 |
1276 |
} |
| 77 |
|
|
| 78 |
462 |
list.add(0, value); |
| 79 |
|
|
| 80 |
420 |
if (hist.getSize() < list.size()) { |
| 81 |
|
|
| 82 |
0 |
list.remove(list.size()-1); |
| 83 |
42 |
} |
| 84 |
|
} |
| 85 |
462 |
} |
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
public HistoryListModel getSearches() { |
| 141 |
0 |
if (searches == null) { |
| 142 |
0 |
searches = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getSearches()); |
| 143 |
|
} |
| 144 |
|
|
| 145 |
0 |
return searches; |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
public HistoryListModel getSourcesModel() { |
| 149 |
792 |
if ( sources == null) { |
| 150 |
22 |
sources = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getSources()); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
792 |
return sources; |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
public HistoryListModel getResultsModel() { |
| 157 |
0 |
if (results == null) { |
| 158 |
0 |
results = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getResults()); |
| 159 |
|
} |
| 160 |
|
|
| 161 |
0 |
return results; |
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
public HistoryListModel getSchemasModel() { |
| 165 |
594 |
if ( schemas == null) { |
| 166 |
22 |
schemas = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getSchemas()); |
| 167 |
|
} |
| 168 |
|
|
| 169 |
594 |
return schemas; |
| 170 |
|
} |
| 171 |
|
|
| 172 |
|
public HistoryListModel getExpressions() { |
| 173 |
154 |
if ( expressions == null) { |
| 174 |
22 |
expressions = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getExpressions()); |
| 175 |
|
} |
| 176 |
|
|
| 177 |
154 |
return expressions; |
| 178 |
|
} |
| 179 |
|
|
| 180 |
|
public HistoryListModel getPatterns() { |
| 181 |
792 |
if ( patterns == null) { |
| 182 |
22 |
patterns = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getPatterns()); |
| 183 |
|
} |
| 184 |
|
|
| 185 |
792 |
return patterns; |
| 186 |
|
} |
| 187 |
|
|
| 188 |
|
public HistoryListModel getDirectories() { |
| 189 |
1078 |
if ( directories == null) { |
| 190 |
22 |
directories = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getDirectories()); |
| 191 |
|
} |
| 192 |
|
|
| 193 |
1078 |
return directories; |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
public HistoryListModel getExtensions() { |
| 197 |
286 |
if ( extensions == null) { |
| 198 |
22 |
extensions = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getExtensions()); |
| 199 |
|
} |
| 200 |
|
|
| 201 |
286 |
return extensions; |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
public HistoryListModel getStylesheets() { |
| 205 |
528 |
if (stylesheets == null) { |
| 206 |
22 |
stylesheets = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getStylesheets()); |
| 207 |
|
} |
| 208 |
|
|
| 209 |
528 |
return stylesheets; |
| 210 |
|
} |
| 211 |
|
|
| 212 |
|
public HistoryListModel getDoctypeSystems() { |
| 213 |
814 |
if (doctypeSystems == null) { |
| 214 |
22 |
doctypeSystems = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getDoctypeSystems()); |
| 215 |
|
} |
| 216 |
|
|
| 217 |
814 |
return doctypeSystems; |
| 218 |
|
} |
| 219 |
|
|
| 220 |
|
public HistoryListModel getDoctypePublics() { |
| 221 |
1100 |
if (doctypePublics == null) { |
| 222 |
22 |
doctypePublics = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getDoctypePublics()); |
| 223 |
|
} |
| 224 |
|
|
| 225 |
1100 |
return doctypePublics; |
| 226 |
|
} |
| 227 |
|
|
| 228 |
|
public HistoryListModel getCDataSectionElements() { |
| 229 |
528 |
if (cdataSectionElements == null) { |
| 230 |
22 |
cdataSectionElements = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getCdataSectionElements()); |
| 231 |
|
} |
| 232 |
|
|
| 233 |
528 |
return cdataSectionElements; |
| 234 |
|
} |
| 235 |
|
|
| 236 |
|
public HistoryListModel getMedias() { |
| 237 |
286 |
if (medias == null) { |
| 238 |
22 |
medias = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getMedias()); |
| 239 |
|
} |
| 240 |
|
|
| 241 |
286 |
return medias; |
| 242 |
|
} |
| 243 |
|
|
| 244 |
|
public HistoryListModel getTitles() { |
| 245 |
286 |
if (titles == null) { |
| 246 |
22 |
titles = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getTitles()); |
| 247 |
|
} |
| 248 |
|
|
| 249 |
286 |
return titles; |
| 250 |
|
} |
| 251 |
|
|
| 252 |
|
public HistoryListModel getCharsets() { |
| 253 |
286 |
if (charsets == null) { |
| 254 |
22 |
charsets = createModel(PreferencesHandler.getInstance().getPreferences().getHistory().getCharsets()); |
| 255 |
|
} |
| 256 |
|
|
| 257 |
286 |
return charsets; |
| 258 |
|
} |
| 259 |
|
|
| 260 |
|
private HistoryListModel createModel( HistoryList hist) { |
| 261 |
286 |
return new HistoryListModel( hist); |
| 262 |
|
} |
| 263 |
|
} |