Changeset 1441 for trunk/src/org/expeditee/items/Picture.java
- Timestamp:
- 11/07/19 12:22:50 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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();
Note:
See TracChangeset
for help on using the changeset viewer.