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/gio/DragAndDropManager.java

    r1142 r1436  
    1111import org.expeditee.core.Point;
    1212import org.expeditee.gui.DisplayController;
     13import org.expeditee.gui.FreeItems;
    1314import org.expeditee.importer.FileImporter;
    1415import org.expeditee.importer.FilePathImporter;
     
    7980         * @param text
    8081         *            The text content.
    81          *
    8282         * @param expediteeDropPoint
    8383         *            The location in the current expeditee frame of where to drop
    8484         *            the text item.
    85          */
    86         public static Text importString(String text, Point expediteeDropPoint)
     85         * @param attachToFreeItems TODO
     86         */
     87        public static Text importString(String text, Point expediteeDropPoint, boolean attachToFreeItems)
    8788        {
    8889                assert (DisplayController.getCurrentFrame() != null);
     
    9293                importedTextItem.setPosition(expediteeDropPoint);
    9394
    94                 DisplayController.getCurrentFrame().addItem(importedTextItem);
     95                if (attachToFreeItems) {
     96                        FreeItems.getInstance().add(importedTextItem);
     97                       
     98                } else {
     99                        DisplayController.getCurrentFrame().addItem(importedTextItem);
     100                }
    95101                DisplayController.requestRefresh(true);
    96102
     
    98104        }
    99105
    100         /** Imports a list of files into Expeditee's current frame. */
    101         public void importFileList(List<? extends File> files, Point expediteeDropPoint) throws IOException
    102         {
     106        /** Imports a list of files into Expeditee's current frame.
     107         * @param attachToFreeItems TODO*/
     108        public void importFileList(List<? extends File> files, Point expediteeDropPoint, boolean attachToFreeItems) throws IOException {
    103109                Point currentPoint = new Point(expediteeDropPoint);
    104110
     
    106112                for (File fileToImport : files) {
    107113
    108                         Item lastItem = importFile(fileToImport, currentPoint);
    109 
     114                        Item lastItem = importFile(fileToImport, currentPoint, attachToFreeItems);
     115                       
    110116                        if (lastItem == null) {
    111117                                currentPoint.setY(currentPoint.getY() + 30);
     
    127133         * @param f
    128134         *            The file to import.
    129          *
    130135         * @param expediteeDropPoint
     136         * @param attachToFreeItems If true, instead of adding to generated item at {@code expediteeDropPoint}, add to free items.
    131137         *
    132138         * @throws IOException
    133139         */
    134         public Item importFile(File f, Point expediteeDropPoint) throws IOException
     140        public Item importFile(File f, Point expediteeDropPoint, boolean attachToFreeItems) throws IOException
    135141        {
    136142                assert (f != null);
     
    139145                // importing routines...
    140146                Item lastCreatedItem;
    141                 if (null == (lastCreatedItem = performFileImport(_customFileImporters, f, expediteeDropPoint))) {
     147                if (null == (lastCreatedItem = performFileImport(_customFileImporters, f, expediteeDropPoint, attachToFreeItems))) {
    142148                        // Standard file importing
    143                         lastCreatedItem = performFileImport(_standardFileImporters, f, expediteeDropPoint);
     149                        lastCreatedItem = performFileImport(_standardFileImporters, f, expediteeDropPoint, attachToFreeItems);
    144150                }
    145151               
     
    150156         * Imports a single file into Expeditee's current frame. Importers are given the opportunity to
    151157         * interpret the file in order of their addition to the list.
    152          */
    153         private Item performFileImport(List<FileImporter> importers, File f, Point expediteeDropPoint) throws IOException
     158         * @param attachToFreeItems If true, instead of adding to generated item at {@code expediteeDropPoint}, add to free items.
     159         */
     160        private Item performFileImport(List<FileImporter> importers, File f, Point expediteeDropPoint, boolean attachToFreeItems) throws IOException
    154161        {
    155162                for (FileImporter fi : importers) {
    156                         Item lastCreated = fi.importFile(f, expediteeDropPoint);
     163                        Item lastCreated = fi.importFile(f, expediteeDropPoint, attachToFreeItems);
    157164                       
    158165                        if (lastCreated != null) return lastCreated;
Note: See TracChangeset for help on using the changeset viewer.