- Timestamp:
- 11/05/19 16:16:11 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/management/ResourceManager.java
r1435 r1436 29 29 private static ResolvedDirectoryList audio = instance.new ResolvedDirectoryList(FolderSettings.AudioDirs); 30 30 31 public static void invalidateAllResourceDirectories() { 32 commonInvalidated = true; 33 } 34 35 private static void refreshAll() { 36 Frame currentFrame = DisplayController.getCurrentFrame(); 37 String framesetPath = currentFrame == null ? null : currentFrame.getFramesetPath(); 38 frames.refresh(framesetPath); 39 images.refresh(framesetPath); 40 audio.refresh(framesetPath); 41 } 42 31 /** 32 * Attempts to relativise a image path using the users the directories listed for images in their settings. 33 * @param path The path to attempt to relativise 34 * @param context The context to use. Most likely the Frame that the image is on. 35 * @return Returns the most relativised path if one exists, otherwise returns a copy of the ref parameter passed in. 36 */ 37 public static Path relativiseImagePath(Path path, Frame context) { 38 String pathStr = path.toString(); 39 40 // Consult the resolved images directory for a list of paths to relativise too. 41 List<String> directories = images.getDirectories(context); 42 43 // Find the longest match that can be used to relativise the path. 44 String longestMatch = ""; 45 for (String dir: directories) { 46 if (pathStr.startsWith(dir) && (dir.length() > longestMatch.length())) { 47 longestMatch = dir; 48 } 49 } 50 51 return Paths.get(pathStr.replace(longestMatch, "")); 52 } 53 43 54 /** 44 55 * Creates a Frame object from an associated resour … … 224 235 } 225 236 237 public static void invalidateAllResourceDirectories() { 238 commonInvalidated = true; 239 } 240 241 private static void refreshAll() { 242 Frame currentFrame = DisplayController.getCurrentFrame(); 243 String framesetPath = currentFrame == null ? null : currentFrame.getFramesetPath(); 244 frames.refresh(framesetPath); 245 images.refresh(framesetPath); 246 audio.refresh(framesetPath); 247 } 248 226 249 private class ResolvedDirectoryList { 227 250 private List<String> directories = null; … … 262 285 263 286 private void refresh(String context) { 287 264 288 List<String> unresolved = source.getAbsoluteDirs(); 265 289 directories = resolve(unresolved, context);
Note:
See TracChangeset
for help on using the changeset viewer.