Changeset 1438 for trunk


Ignore:
Timestamp:
11/06/19 13:55:33 (4 years ago)
Author:
bnemhaus
Message:

Relativisation of image paths now only relativies back to expeditee home.
Also, when loading images and audio, paths can now be relative to expeditee home, even if it is not listed in the users settings. It is always tried last.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/management/ResourceManager.java

    r1436 r1438  
    3535         * @return Returns the most relativised path if one exists, otherwise returns a copy of the ref parameter passed in.
    3636         */
    37         public static Path relativiseImagePath(Path path, Frame context) {
     37        /*public static Path relativiseImagePath(Path path, Frame context) {
    3838                String pathStr = path.toString();
    3939               
     
    5050               
    5151                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                }
    5261        }
    5362                       
     
    130139                // by this Expeditee Text Item.
    131140                List<String> canditateDirectoriesForResource = images.getDirectories(source);
     141                canditateDirectoriesForResource.add(FrameIO.PARENT_FOLDER);
    132142               
    133143                // First try finding the resource in the directories specified by the
     
    150160                //              These are of the format "/packageA/packageB/filename".  For
    151161                //              example: "/org/expeditee/gui.management/ResourceManager.java"
    152                 //
    153                 // Bryce: Do we want to allow for the option of
    154                 // it being a path relative to expeditee.home?
    155162                if (resourceFile == null || !resourceFile.exists() || resourceFile.isDirectory()) {
    156163                        // Prepare for case a.
     
    201208        public static File getAudioResource(String localFileName, Frame parentFrame) {
    202209                List<String> directories = audio.getDirectories(parentFrame);
     210                directories.add(FrameIO.PARENT_FOLDER);
    203211                for (String directory: directories) {
    204212                        Path pathToFile = Paths.get(directory).resolve(localFileName);
     
    220228        public static List<File> gatherAudioResources(Predicate<File> includeFile, Frame parentFrame) {
    221229                List<String> directories = audio.getDirectories(parentFrame);
     230                directories.add(FrameIO.PARENT_FOLDER);
    222231                List<File> results = new ArrayList<File>();
    223232                for (String directory: directories) {
Note: See TracChangeset for help on using the changeset viewer.