Ignore:
Timestamp:
11/07/19 12:22:50 (5 years ago)
Author:
bnemhaus
Message:

Copying images in Expeditee now duplicates the associated file on the filesystem.
Also changed USER_NAME back to USER.NAME on David's direction.

Location:
trunk/src/org/expeditee/gui/management
Files:
3 edited

Legend:

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

    r1440 r1441  
    2828public class ProfileManager {
    2929
    30         private static final String USER_NAME_PATTERN_INTERNAL = "USER_NAME";
    3130        private static final String DEFAULT = UserSettings.DEFAULT_PROFILE_NAME;
    3231        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" + "}";
    3433
    3534        public static Frame createProfile(String profileFor, Map<String, Setting> specifiedSettings,
     
    8584                                        if (item instanceof Text) {
    8685                                                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));
    8887                                        }
    8988                                }
  • trunk/src/org/expeditee/gui/management/ResourceManager.java

    r1439 r1441  
    2525        private static boolean commonInvalidated = false;
    2626        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       
    6331        /**
    6432         * Creates a Frame object from an associated resour
     
    256224        }
    257225       
    258         private class ResolvedDirectoryList {
     226        protected class ResolvedDirectoryList {
    259227                private List<String> directories = null;
    260228                private String contextFramesetPath = null;
  • trunk/src/org/expeditee/gui/management/ResourceUtil.java

    r1439 r1441  
    11package org.expeditee.gui.management;
     2
     3import java.nio.file.Path;
     4import java.nio.file.Paths;
     5import java.util.List;
     6
     7import org.expeditee.gui.Frame;
     8import org.expeditee.gui.FrameIO;
    29
    310public class ResourceUtil {
     
    1017        public static final String CURRENT_FRAMESET_FLAG = "${CURRENT_FRAMESET}";
    1118        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        }
    1247       
    1348        /**
Note: See TracChangeset for help on using the changeset viewer.