Changeset 1447 for trunk/src/org/expeditee
- Timestamp:
- 11/12/19 14:37:28 (5 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/management/ResourceUtil.java
r1446 r1447 26 26 * Attempts to relativise a image path using expeditee.home (FrameIO.PARENT_FOLDER). 27 27 * @param path The path to attempt to relativise 28 * @return Returns the most relativised path if one exists, otherwise returns a copy ofthe ref parameter passed in.28 * @return Returns the most relativised path if one exists, otherwise returns the ref parameter passed in. 29 29 */ 30 30 public static Path relativiseImagePath(Path path) { … … 49 49 50 50 return null; 51 } 52 53 public static Path getImageSaveFileLocation(Frame context) { 54 List<String> directories = ResourceManager.images.getDirectories(context); 55 if (directories.isEmpty()) { 56 return Paths.get(FrameIO.PARENT_FOLDER).toAbsolutePath(); 57 } else { 58 return Paths.get(directories.get(0)); 59 } 51 60 } 52 61 -
trunk/src/org/expeditee/importer/FilePathImporter.java
r1436 r1447 40 40 } 41 41 42 return null; 43 44 } 45 46 42 return null; 43 } 47 44 } -
trunk/src/org/expeditee/importer/ImageImporter.java
r1441 r1447 21 21 import java.io.File; 22 22 import java.io.IOException; 23 import java.nio.file.Files; 23 24 import java.nio.file.Path; 24 25 import java.nio.file.Paths; 26 import java.nio.file.StandardCopyOption; 25 27 import java.util.Collection; 26 28 import java.util.HashSet; … … 90 92 Path imagePath = Paths.get(fullPath); 91 93 Path imagePathRelitivized = ResourceUtil.relativiseImagePath(imagePath); 94 if (!isInternal(imagePathRelitivized)) { 95 Path destinationDirectoryPath = ResourceUtil.getImageSaveFileLocation(DisplayController.getCurrentFrame()); 96 String extension = imagePathRelitivized.toString(); 97 extension = extension.substring(extension.lastIndexOf('.')); 98 Path newFilePath = Files.createTempFile(destinationDirectoryPath, "", extension); 99 Files.copy(imagePathRelitivized, newFilePath, StandardCopyOption.REPLACE_EXISTING); 100 imagePathRelitivized = ResourceUtil.relativiseImagePath(newFilePath); 101 } 92 102 source = DragAndDropManager.importString("@i: " + imagePathRelitivized.toString() + size, location, attachToFreeItems); 93 103 // final Path imagesPath = Paths.get(FrameIO.IMAGES_PATH); … … 107 117 return source.getEnclosures().iterator().next(); 108 118 } 119 120 private boolean isInternal(Path p) { 121 Path expediteeHomePath = Paths.get(FrameIO.PARENT_FOLDER).toAbsolutePath(); 122 return p.startsWith(expediteeHomePath); 123 } 109 124 }
Note:
See TracChangeset
for help on using the changeset viewer.