Changeset 1441 for trunk/src/org/expeditee/gui/management/ResourceUtil.java
- Timestamp:
- 11/07/19 12:22:50 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.