Changeset 1441 for trunk/src/org/expeditee/gui/management
- Timestamp:
- 11/07/19 12:22:50 (5 years ago)
- Location:
- trunk/src/org/expeditee/gui/management
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/management/ProfileManager.java
r1440 r1441 28 28 public class ProfileManager { 29 29 30 private static final String USER_NAME_PATTERN_INTERNAL = "USER_NAME";31 30 private static final String DEFAULT = UserSettings.DEFAULT_PROFILE_NAME; 32 31 private static final String[] startPages = { "exploratorysearch", "webbrowser" }; 33 public static final String USER_NAME_ PATTERN = "${" + USER_NAME_PATTERN_INTERNAL+ "}";32 public static final String USER_NAME_FLAG = "${" + "USER.NAME" + "}"; 34 33 35 34 public static Frame createProfile(String profileFor, Map<String, Setting> specifiedSettings, … … 85 84 if (item instanceof Text) { 86 85 String content = item.getText(); 87 item.setText(ResourceUtil.substitute(content, ProfileManager.USER_NAME_ PATTERN, profileFor));86 item.setText(ResourceUtil.substitute(content, ProfileManager.USER_NAME_FLAG, profileFor)); 88 87 } 89 88 } -
trunk/src/org/expeditee/gui/management/ResourceManager.java
r1439 r1441 25 25 private static boolean commonInvalidated = false; 26 26 private static ResourceManager instance = new ResourceManager(); 27 private static ResolvedDirectoryList frames = instance.new ResolvedDirectoryList(FolderSettings.FrameDirs); 28 private static ResolvedDirectoryList images = instance.new ResolvedDirectoryList(FolderSettings.ImageDirs); 29 private static ResolvedDirectoryList audio = instance.new ResolvedDirectoryList(FolderSettings.AudioDirs); 30 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 54 public static Path relativiseImagePath(Path path, Frame context) { 55 Path expediteeHome = Paths.get(FrameIO.PARENT_FOLDER); 56 if (path.startsWith(expediteeHome)) { 57 return expediteeHome.relativize(path); 58 } else { 59 return path; 60 } 61 } 62 27 protected static ResolvedDirectoryList frames = instance.new ResolvedDirectoryList(FolderSettings.FrameDirs); 28 protected static ResolvedDirectoryList images = instance.new ResolvedDirectoryList(FolderSettings.ImageDirs); 29 protected static ResolvedDirectoryList audio = instance.new ResolvedDirectoryList(FolderSettings.AudioDirs); 30 63 31 /** 64 32 * Creates a Frame object from an associated resour … … 256 224 } 257 225 258 pr ivateclass ResolvedDirectoryList {226 protected class ResolvedDirectoryList { 259 227 private List<String> directories = null; 260 228 private String contextFramesetPath = null; -
trunk/src/org/expeditee/gui/management/ResourceUtil.java
r1439 r1441 1 1 package org.expeditee.gui.management; 2 3 import java.nio.file.Path; 4 import java.nio.file.Paths; 5 import java.util.List; 6 7 import org.expeditee.gui.Frame; 8 import org.expeditee.gui.FrameIO; 2 9 3 10 public class ResourceUtil { … … 10 17 public static final String CURRENT_FRAMESET_FLAG = "${CURRENT_FRAMESET}"; 11 18 public static final String CURRENT_USER = "${CURRENT_USER}"; 19 20 /** 21 * Attempts to relativise a image path using expeditee.home (FrameIO.PARENT_FOLDER). 22 * @param path The path to attempt to relativise 23 * @return Returns the most relativised path if one exists, otherwise returns a copy of the ref parameter passed in. 24 */ 25 public static Path relativiseImagePath(Path path) { 26 Path expediteeHome = Paths.get(FrameIO.PARENT_FOLDER); 27 if (path.startsWith(expediteeHome)) { 28 return expediteeHome.relativize(path); 29 } else { 30 return path; 31 } 32 } 33 34 public static Path resolveImagePath(Path path, Frame context) { 35 List<String> directories = ResourceManager.images.getDirectories(context); 36 directories.add(FrameIO.PARENT_FOLDER); 37 38 for (String dir: directories) { 39 Path canditate = Paths.get(dir).resolve(path); 40 if (canditate.toFile().exists()) { 41 return canditate; 42 } 43 } 44 45 return null; 46 } 12 47 13 48 /**
Note:
See TracChangeset
for help on using the changeset viewer.