- Timestamp:
- 11/07/19 12:22:50 (4 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 7 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 /** -
trunk/src/org/expeditee/importer/ImageImporter.java
r1436 r1441 34 34 import org.expeditee.gui.FrameIO; 35 35 import org.expeditee.gui.FrameUtils; 36 import org.expeditee.gui.management.Resource Manager;36 import org.expeditee.gui.management.ResourceUtil; 37 37 import org.expeditee.items.Item; 38 38 import org.expeditee.items.Text; … … 89 89 Text source; 90 90 Path imagePath = Paths.get(fullPath); 91 Path imagePathRelitivized = Resource Manager.relativiseImagePath(imagePath, DisplayController.getCurrentFrame());91 Path imagePathRelitivized = ResourceUtil.relativiseImagePath(imagePath); 92 92 source = DragAndDropManager.importString("@i: " + imagePathRelitivized.toString() + size, location, attachToFreeItems); 93 93 // final Path imagesPath = Paths.get(FrameIO.IMAGES_PATH); -
trunk/src/org/expeditee/importer/pdfImporter.java
r1436 r1441 39 39 import org.expeditee.gui.FrameIO; 40 40 import org.expeditee.gui.MessageBay; 41 import org.expeditee.gui.management.Resource Manager;41 import org.expeditee.gui.management.ResourceUtil; 42 42 import org.expeditee.items.Item; 43 43 import org.expeditee.items.Text; … … 139 139 //save it as a file 140 140 Path p = Paths.get(framesetPath+i+".png"); 141 p = Resource Manager.relativiseImagePath(p, DisplayController.getCurrentFrame());141 p = ResourceUtil.relativiseImagePath(p); 142 142 File out = p.toFile(); 143 143 bimg.writeToDisk("png", out); -
trunk/src/org/expeditee/items/Picture.java
r1431 r1441 21 21 import java.io.File; 22 22 import java.io.IOException; 23 import java.nio.file.Files; 24 import java.nio.file.Path; 25 import java.nio.file.Paths; 26 import java.nio.file.StandardCopyOption; 23 27 import java.text.DecimalFormat; 24 28 … … 47 51 import org.expeditee.gui.FrameUtils; 48 52 import org.expeditee.gui.MessageBay; 53 import org.expeditee.gui.management.ResourceUtil; 49 54 50 55 /** … … 626 631 p._image = _image; 627 632 p._highlightMode = _highlightMode; 633 634 String copyFileName = _fileName; 635 try { 636 String name = getName(); 637 Path imageFilePath = ResourceUtil.resolveImagePath(Paths.get(name), this.getSource().getParent()); 638 Path imageDirectoryPath = imageFilePath.getParent(); 639 String fileName = name.substring(0, name.indexOf('.')); 640 String suffix = name.substring(name.indexOf('.')); 641 File copiedFile = File.createTempFile(fileName, suffix, imageDirectoryPath.toFile()); 642 Path newFilePath = Files.copy(imageFilePath, Paths.get(copiedFile.getAbsolutePath()), StandardCopyOption.REPLACE_EXISTING); 643 Path newFilePathResolved = ResourceUtil.resolveImagePath(newFilePath.getFileName(), this.getSource().getParent()); 644 Path newFilePathRelativeToExpediteeHome = ResourceUtil.relativiseImagePath(newFilePathResolved); 645 copyFileName = newFilePathRelativeToExpediteeHome.toString(); 646 } catch (IOException e) { 647 MessageBay.displayMessage("Unable to duplicate image file, new copy refers to existing image file."); 648 MessageBay.displayMessage("Caused by IOException with message: " + e.getMessage()); 649 } 650 628 651 // Doing Duplicate item duplicates link mark which we dont want to do 629 652 // when in audience mode because the linkMark will be copied incorrectly … … 668 691 p._scaleType = _scaleType; 669 692 p._path = _path; 670 p._fileName = _fileName;693 p._fileName = copyFileName; 671 694 672 695 p.updateSource(); -
trunk/src/org/expeditee/settings/UserSettings.java
r1440 r1441 69 69 String profileName = UserSettings.ProfileName.get(); 70 70 if(text.getText().indexOf(':') == -1 || !text.hasLink()) { 71 if (!profileName.equals(ProfileManager.USER_NAME_ PATTERN)) {71 if (!profileName.equals(ProfileManager.USER_NAME_FLAG)) { 72 72 text.setLink(profileName + "1"); 73 73 }
Note:
See TracChangeset
for help on using the changeset viewer.