- Timestamp:
- 11/05/19 16:16:11 (4 years ago)
- Location:
- trunk/src/org
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/io/SampledAudioFileImporter.java
r1142 r1436 18 18 public class SampledAudioFileImporter implements FileImporter { 19 19 20 public Item importFile(File f, Point location ) throws IOException20 public Item importFile(File f, Point location, boolean attachToFreeItems) throws IOException 21 21 { 22 22 if (location == null || !AudioIO.canImportFile(f) || DisplayController.getCurrentFrame() == null) return null; -
trunk/src/org/expeditee/actions/Misc.java
r1415 r1436 1044 1044 } 1045 1045 try { 1046 EcosystemManager.getDragAndDropManager().importFileList(files, EcosystemManager.getInputManager().getCursorPosition() );1046 EcosystemManager.getDragAndDropManager().importFileList(files, EcosystemManager.getInputManager().getCursorPosition(), false); 1047 1047 } catch (Exception e) { 1048 1048 } … … 1053 1053 if (file.exists()) { 1054 1054 try { 1055 EcosystemManager.getDragAndDropManager().importFile(file, EcosystemManager.getInputManager().getCursorPosition() );1055 EcosystemManager.getDragAndDropManager().importFile(file, EcosystemManager.getInputManager().getCursorPosition(), false); 1056 1056 } catch (Exception e) { 1057 1057 e.printStackTrace(); -
trunk/src/org/expeditee/agents/mail/MailSession.java
r1304 r1436 517 517 final Frame frame, final Point point) { 518 518 519 final Text source = DragAndDropManager.importString("Reading message " + messageNo + "...", point );519 final Text source = DragAndDropManager.importString("Reading message " + messageNo + "...", point, false); 520 520 521 521 new Thread() { -
trunk/src/org/expeditee/gio/ClipboardManager.java
r1097 r1436 1 1 package org.expeditee.gio; 2 3 import java.io.File; 4 import java.util.List; 2 5 3 6 import org.expeditee.core.Image; … … 41 44 */ 42 45 public String stringRepresentation; 46 /** 47 * A List representation of the clipboard data 48 * (for use when copy/pasting to/from directories), 49 */ 50 public List<File> fileRepresentation; 43 51 44 52 /** Default constructor. */ -
trunk/src/org/expeditee/gio/DragAndDropManager.java
r1142 r1436 11 11 import org.expeditee.core.Point; 12 12 import org.expeditee.gui.DisplayController; 13 import org.expeditee.gui.FreeItems; 13 14 import org.expeditee.importer.FileImporter; 14 15 import org.expeditee.importer.FilePathImporter; … … 79 80 * @param text 80 81 * The text content. 81 *82 82 * @param expediteeDropPoint 83 83 * The location in the current expeditee frame of where to drop 84 84 * 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) 87 88 { 88 89 assert (DisplayController.getCurrentFrame() != null); … … 92 93 importedTextItem.setPosition(expediteeDropPoint); 93 94 94 DisplayController.getCurrentFrame().addItem(importedTextItem); 95 if (attachToFreeItems) { 96 FreeItems.getInstance().add(importedTextItem); 97 98 } else { 99 DisplayController.getCurrentFrame().addItem(importedTextItem); 100 } 95 101 DisplayController.requestRefresh(true); 96 102 … … 98 104 } 99 105 100 /** Imports a list of files into Expeditee's current frame. */101 public void importFileList(List<? extends File> files, Point expediteeDropPoint) throws IOException102 {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 { 103 109 Point currentPoint = new Point(expediteeDropPoint); 104 110 … … 106 112 for (File fileToImport : files) { 107 113 108 Item lastItem = importFile(fileToImport, currentPoint );109 114 Item lastItem = importFile(fileToImport, currentPoint, attachToFreeItems); 115 110 116 if (lastItem == null) { 111 117 currentPoint.setY(currentPoint.getY() + 30); … … 127 133 * @param f 128 134 * The file to import. 129 *130 135 * @param expediteeDropPoint 136 * @param attachToFreeItems If true, instead of adding to generated item at {@code expediteeDropPoint}, add to free items. 131 137 * 132 138 * @throws IOException 133 139 */ 134 public Item importFile(File f, Point expediteeDropPoint ) throws IOException140 public Item importFile(File f, Point expediteeDropPoint, boolean attachToFreeItems) throws IOException 135 141 { 136 142 assert (f != null); … … 139 145 // importing routines... 140 146 Item lastCreatedItem; 141 if (null == (lastCreatedItem = performFileImport(_customFileImporters, f, expediteeDropPoint ))) {147 if (null == (lastCreatedItem = performFileImport(_customFileImporters, f, expediteeDropPoint, attachToFreeItems))) { 142 148 // Standard file importing 143 lastCreatedItem = performFileImport(_standardFileImporters, f, expediteeDropPoint );149 lastCreatedItem = performFileImport(_standardFileImporters, f, expediteeDropPoint, attachToFreeItems); 144 150 } 145 151 … … 150 156 * Imports a single file into Expeditee's current frame. Importers are given the opportunity to 151 157 * 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 154 161 { 155 162 for (FileImporter fi : importers) { 156 Item lastCreated = fi.importFile(f, expediteeDropPoint );163 Item lastCreated = fi.importFile(f, expediteeDropPoint, attachToFreeItems); 157 164 158 165 if (lastCreated != null) return lastCreated; -
trunk/src/org/expeditee/gio/javafx/JavaFXDragAndDropManager.java
r1097 r1436 66 66 List<File> files = dragboard.getFiles(); 67 67 if (files != null && files.size() > 0) { 68 importFileList(files, dropPoint );68 importFileList(files, dropPoint, false); 69 69 } 70 70 } else if (dragboard.hasContent(_URIListDataflavorString)) { 71 71 String data = (String) dragboard.getContent(_URIListDataflavorString); 72 72 List<File> files = textURIListToFileList(data); 73 importFileList(files, dropPoint );73 importFileList(files, dropPoint, false); 74 74 success = true; 75 75 } else if (dragboard.hasContent(_URIListDataflavorCharArray)) { … … 77 77 String uriString = new String(data); 78 78 List<File> files = textURIListToFileList(uriString); 79 importFileList(files, dropPoint );79 importFileList(files, dropPoint, false); 80 80 success = true; 81 81 } else if (dragboard.hasString()) { 82 82 String str = dragboard.getString(); 83 83 if (str != null && str.length() > 0) { 84 importString(str, dropPoint );84 importString(str, dropPoint, false); 85 85 success = true; 86 86 } -
trunk/src/org/expeditee/gio/swing/SwingClipboardManager.java
r1097 r1436 5 5 import java.awt.datatransfer.Transferable; 6 6 import java.awt.datatransfer.UnsupportedFlavorException; 7 import java.io.File; 7 8 import java.io.IOException; 8 9 import java.util.LinkedList; … … 10 11 11 12 import org.expeditee.core.Image; 13 import org.expeditee.core.Point; 12 14 import org.expeditee.gio.ClipboardManager; 15 import org.expeditee.gio.DragAndDropManager; 16 import org.expeditee.gio.EcosystemManager; 17 import org.expeditee.gui.DisplayController; 13 18 14 19 /** TODO: Comment. cts16 */ … … 21 26 SwingClipboardManager.expediteeDataFlavour, 22 27 DataFlavor.imageFlavor, 23 DataFlavor.stringFlavor 28 DataFlavor.stringFlavor, 29 DataFlavor.javaFileListFlavor 24 30 }; 25 31 … … 82 88 } else if (DataFlavor.stringFlavor.equals(flavour)) { 83 89 out.stringRepresentation = (String) content.getTransferData(flavour); 90 } else if (DataFlavor.javaFileListFlavor.equals(flavour)) { 91 @SuppressWarnings("unchecked") 92 List<File> transferData = (List<File>) content.getTransferData(flavour); 93 out.fileRepresentation = transferData; 84 94 } 85 }95 } 86 96 87 97 private Image handleGetImage(Transferable content) throws IOException, UnsupportedFlavorException -
trunk/src/org/expeditee/gio/swing/SwingDragAndDropManager.java
r1097 r1436 115 115 116 116 if (str != null && str.length() > 0) { 117 importString(str, expediteeDropPoint );117 importString(str, expediteeDropPoint, false); 118 118 return true; 119 119 } … … 125 125 List<? extends File> files = (List<? extends File>) support.getTransferable().getTransferData(DataFlavor.javaFileListFlavor); 126 126 127 importFileList(files, expediteeDropPoint );127 importFileList(files, expediteeDropPoint, false); 128 128 129 129 return true; … … 136 136 List<File> files = textURIListToFileList(data); 137 137 138 importFileList(files, expediteeDropPoint );138 importFileList(files, expediteeDropPoint, false); 139 139 140 140 return true; … … 148 148 List<File> files = textURIListToFileList(uriString); 149 149 150 importFileList(files, expediteeDropPoint );150 importFileList(files, expediteeDropPoint, false); 151 151 152 152 return true; -
trunk/src/org/expeditee/gui/management/ResourceManager.java
r1435 r1436 29 29 private static ResolvedDirectoryList audio = instance.new ResolvedDirectoryList(FolderSettings.AudioDirs); 30 30 31 public static void invalidateAllResourceDirectories() { 32 commonInvalidated = true; 33 } 34 35 private static void refreshAll() { 36 Frame currentFrame = DisplayController.getCurrentFrame(); 37 String framesetPath = currentFrame == null ? null : currentFrame.getFramesetPath(); 38 frames.refresh(framesetPath); 39 images.refresh(framesetPath); 40 audio.refresh(framesetPath); 41 } 42 31 /** 32 * Attempts to relativise a image path using the users the directories listed for images in their settings. 33 * @param path The path to attempt to relativise 34 * @param context The context to use. Most likely the Frame that the image is on. 35 * @return Returns the most relativised path if one exists, otherwise returns a copy of the ref parameter passed in. 36 */ 37 public static Path relativiseImagePath(Path path, Frame context) { 38 String pathStr = path.toString(); 39 40 // Consult the resolved images directory for a list of paths to relativise too. 41 List<String> directories = images.getDirectories(context); 42 43 // Find the longest match that can be used to relativise the path. 44 String longestMatch = ""; 45 for (String dir: directories) { 46 if (pathStr.startsWith(dir) && (dir.length() > longestMatch.length())) { 47 longestMatch = dir; 48 } 49 } 50 51 return Paths.get(pathStr.replace(longestMatch, "")); 52 } 53 43 54 /** 44 55 * Creates a Frame object from an associated resour … … 224 235 } 225 236 237 public static void invalidateAllResourceDirectories() { 238 commonInvalidated = true; 239 } 240 241 private static void refreshAll() { 242 Frame currentFrame = DisplayController.getCurrentFrame(); 243 String framesetPath = currentFrame == null ? null : currentFrame.getFramesetPath(); 244 frames.refresh(framesetPath); 245 images.refresh(framesetPath); 246 audio.refresh(framesetPath); 247 } 248 226 249 private class ResolvedDirectoryList { 227 250 private List<String> directories = null; … … 262 285 263 286 private void refresh(String context) { 287 264 288 List<String> unresolved = source.getAbsoluteDirs(); 265 289 directories = resolve(unresolved, context); -
trunk/src/org/expeditee/importer/FileImporter.java
r1102 r1436 42 42 * @param f 43 43 * The file to import. Not null. 44 *45 44 * @param location 46 45 * The location in expeditee space where the import was requested. 47 46 * Null if not applicable. 47 * @param attachToFreeItems TODO 48 48 * 49 49 * @return … … 55 55 * If the import procedure failed. 56 56 */ 57 Item importFile(File f, Point location ) throws IOException;57 Item importFile(File f, Point location, boolean attachToFreeItems) throws IOException; 58 58 } -
trunk/src/org/expeditee/importer/FilePathImporter.java
r1102 r1436 35 35 public class FilePathImporter implements FileImporter { 36 36 37 public Item importFile(File f, Point location ) throws IOException {37 public Item importFile(File f, Point location, boolean attachToFreeItems) throws IOException { 38 38 if (location != null && f != null) { 39 return DragAndDropManager.importString(f.getAbsolutePath(), location );39 return DragAndDropManager.importString(f.getAbsolutePath(), location, false); 40 40 } 41 41 -
trunk/src/org/expeditee/importer/ImageImporter.java
r1109 r1436 34 34 import org.expeditee.gui.FrameIO; 35 35 import org.expeditee.gui.FrameUtils; 36 import org.expeditee.gui.management.ResourceManager; 36 37 import org.expeditee.items.Item; 37 38 import org.expeditee.items.Text; … … 53 54 } 54 55 55 public Item importFile(File f, Point location ) throws IOException {56 public Item importFile(File f, Point location, boolean attachToFreeItems) throws IOException { 56 57 57 58 if (location == null || f == null) { … … 87 88 } 88 89 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 // } 94 99 source.setThickness(thickness); 95 100 source.setBorderColor(borderColor); -
trunk/src/org/expeditee/importer/TextImporter.java
r1102 r1436 40 40 } 41 41 42 public Item importFile(final File f, Point location ) throws IOException {42 public Item importFile(final File f, Point location, boolean attachToFreeItems) throws IOException { 43 43 if (location == null || f == null) { 44 44 return null; … … 46 46 final String fullPath = f.getAbsolutePath(); 47 47 48 final Text source = DragAndDropManager.importString(f.getPath(), location );48 final Text source = DragAndDropManager.importString(f.getPath(), location, false); 49 49 50 50 // Create a frameCreator to write the text -
trunk/src/org/expeditee/importer/pdfImporter.java
r1242 r1436 24 24 import java.nio.ByteBuffer; 25 25 import java.nio.channels.FileChannel; 26 import java.nio.file.Path; 27 import java.nio.file.Paths; 26 28 27 29 import org.expeditee.core.Colour; … … 37 39 import org.expeditee.gui.FrameIO; 38 40 import org.expeditee.gui.MessageBay; 41 import org.expeditee.gui.management.ResourceManager; 39 42 import org.expeditee.items.Item; 40 43 import org.expeditee.items.Text; … … 45 48 public class pdfImporter implements FileImporter { 46 49 47 public Item importFile(final File f, Point location ) throws IOException {50 public Item importFile(final File f, Point location, boolean attachToFreeItems) throws IOException { 48 51 if (location == null || f == null) { 49 52 return null; … … 63 66 } 64 67 65 final Text link = DragAndDropManager.importString(name, location );68 final Text link = DragAndDropManager.importString(name, location, false); 66 69 link.setLink(name+"1"); 67 70 … … 135 138 g.popDrawingSurface(); 136 139 //save it as a file 137 File out = new File(framesetPath+i+".png"); 140 Path p = Paths.get(framesetPath+i+".png"); 141 p = ResourceManager.relativiseImagePath(p, DisplayController.getCurrentFrame()); 142 File out = p.toFile(); 138 143 bimg.writeToDisk("png", out); 139 144 //generate a frame with that image 140 145 System.out.println(width); 141 System.out.println("@i: "+ framesetPath+i+".png "+width);142 currentFrame.addText(x, y, "@i: "+ framesetPath+i+".png "+width, null);146 System.out.println("@i: "+p.toString()+width); 147 currentFrame.addText(x, y, "@i: "+p.toString()+width, null); 143 148 if(i>1) 144 149 { -
trunk/src/org/expeditee/io/ItemSelection.java
r1104 r1436 26 26 27 27 import org.expeditee.core.Image; 28 import org.expeditee.core.Point; 28 29 import org.expeditee.gio.ClipboardManager.ClipboardData; 29 30 import org.expeditee.gio.EcosystemManager; … … 204 205 prevItem = item; 205 206 } 207 } else if (content.fileRepresentation != null) { // Files 208 EcosystemManager.getDragAndDropManager().importFileList(content.fileRepresentation, DisplayController.getMousePosition(), true); 206 209 } /* else if { 207 210 // Next handler -
trunk/src/org/expeditee/setting/DirectoryListSetting.java
r1434 r1436 3 3 import java.io.File; 4 4 import java.util.ArrayList; 5 import java.util.HashMap;6 5 import java.util.LinkedList; 7 6 import java.util.List; 8 import java.util.Map;9 7 10 import org.expeditee.gui.DisplayController;11 8 import org.expeditee.gui.FrameIO; 12 9 import org.expeditee.gui.FrameUtils;
Note:
See TracChangeset
for help on using the changeset viewer.