Ignore:
Timestamp:
11/05/19 16:16:11 (5 years ago)
Author:
bnemhaus
Message:

Added the ability to copy/paste recognised files (mostly images) into Expeditee. This functionality already existed when drag n dropping, but now also works when using copy/paste.

At this stage, recognised files get imported as a approapriate Text Item. For example, a image will create a @i Text Item and attach it to your cursor. Ideally this would be the image directly. Unfortunately, items attached to the cursor (FreeItems) are not currently parsed. This is something I will discuss with David as there are confounding issues to consider. For example: surrogates...

Attached to the bottom of this commit message are my current thoughts.

Also made it so when creating a @i through DND or Copy/Paste, that @i is as relative as possible. The users image directories setting is used to achieve this.


  • FreeItems need to be parsed...we would need to deal with primaries/surrogates in them...
  • Do we want FreeItems to be parsed? If I attach an item to my cursor and then enter surrogate mode, should it change?
  • My gut says no. Both because it would be work, and also because it kind of feels like a free win if we do not.
  • But we do want to replace @i with images etc. Therefore, we want an old style parse for FreeItems?
File:
1 edited

Legend:

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

    r1109 r1436  
    3434import org.expeditee.gui.FrameIO;
    3535import org.expeditee.gui.FrameUtils;
     36import org.expeditee.gui.management.ResourceManager;
    3637import org.expeditee.items.Item;
    3738import org.expeditee.items.Text;
     
    5354        }
    5455
    55         public Item importFile(File f, Point location) throws IOException {
     56        public Item importFile(File f, Point location, boolean attachToFreeItems) throws IOException {
    5657
    5758                if (location == null || f == null) {
     
    8788                }
    8889                Text source;
    89                 final Path imagePath = Paths.get(fullPath);
    90                 final Path imagesPath = Paths.get(FrameIO.IMAGES_PATH);
    91                 if(imagePath.startsWith(imagesPath))
    92                         source = DragAndDropManager.importString("@i: " + imagePath.getFileName() + size, location);
    93                 else source = DragAndDropManager.importString("@i: " + fullPath + size, location);
     90                Path imagePath = Paths.get(fullPath);
     91                Path imagePathRelitivized = ResourceManager.relativiseImagePath(imagePath, DisplayController.getCurrentFrame());
     92                source = DragAndDropManager.importString("@i: " + imagePathRelitivized.toString() + size, location, attachToFreeItems);
     93//              final Path imagesPath = Paths.get(FrameIO.IMAGES_PATH);
     94//              if(imagePath.startsWith(imagesPath)) {
     95//                      source = DragAndDropManager.importString("@i: " + imagePath.getFileName() + size, location, attachToFreeItems);
     96//              } else {
     97//                      source = DragAndDropManager.importString("@i: " + fullPath + size, location, attachToFreeItems);
     98//              }
    9499                source.setThickness(thickness);
    95100                source.setBorderColor(borderColor);
Note: See TracChangeset for help on using the changeset viewer.