Ignore:
Timestamp:
11/12/19 14:37:28 (5 years ago)
Author:
bnemhaus
Message:

When dnd'ing a or copy/pasting a image that is external to expeditee (not a sub file of expedite.home) then that image is imported into the expeditee file system with a randomly generated name. A users FolderSettings are used to determine location to import image too.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/importer/ImageImporter.java

    r1441 r1447  
    2121import java.io.File;
    2222import java.io.IOException;
     23import java.nio.file.Files;
    2324import java.nio.file.Path;
    2425import java.nio.file.Paths;
     26import java.nio.file.StandardCopyOption;
    2527import java.util.Collection;
    2628import java.util.HashSet;
     
    9092                Path imagePath = Paths.get(fullPath);
    9193                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                }
    92102                source = DragAndDropManager.importString("@i: " + imagePathRelitivized.toString() + size, location, attachToFreeItems);
    93103//              final Path imagesPath = Paths.get(FrameIO.IMAGES_PATH);
     
    107117                return source.getEnclosures().iterator().next();
    108118        }
     119       
     120        private boolean isInternal(Path p) {
     121                Path expediteeHomePath = Paths.get(FrameIO.PARENT_FOLDER).toAbsolutePath();
     122                return p.startsWith(expediteeHomePath);
     123        }
    109124}
Note: See TracChangeset for help on using the changeset viewer.