Ticket #2185 (closed feature: obsolete)

Opened 10 years ago

Last modified 8 years ago

external-dnd - Drag resources from Finder to Sophie

Reported by: deyan Owned by: deni
Priority: critical Milestone: X3
Component: uncategorized Version: 2.0
Keywords: Cc:
Category: unknown Effort: 3
Importance: 78 Ticket_group:
Estimated Number of Hours: 0 Add Hours to Ticket: 0
Billable?: yes Total Hours: 0
Analysis_owners: deyan Design_owners: deni
Imp._owners: deni Test_owners:
Analysis_reviewers: deni Changelog:
Design_reviewers: meddle Imp._reviewers: todor, meddle
Test_reviewers: Analysis_score: 4
Design_score: 3.5 Imp._score: 4.5
Test_score: 0

Description

drag and drop resources from finder to book page or resource tab

Change History

comment:1 Changed 10 years ago by deyan

  • Importance changed from 51 to 78
  • Summary changed from external-dnd to external-dnd – Drag resources from Finder to Sophie

Batch update from file report_1.csv

comment:2 Changed 10 years ago by deyan

  • Priority changed from normal to critical
  • Summary changed from external-dnd – Drag resources from Finder to Sophie to external-dnd – Drag resources from Finder to Sophie

Batch update from file 0911261.csv

comment:3 Changed 10 years ago by todor

  • Category set to unknown
  • Analysis_score set to 0
  • Test_score set to 0
  • Summary changed from external-dnd – Drag resources from Finder to Sophie to external-dnd - Drag resources from Finder to Sophie
  • Design_score set to 0
  • Imp._score set to 0

comment:4 Changed 10 years ago by deyan

  • Owner set to deyan
  • Status changed from new to s1a_analysis_started
  • If the resource(s) (folder) was dropped on a page, new frames with starting coordinates the drop point and offset of 10px top and right should be created.
  • If the resource(s) (folder) was dropped on the Resources palette, they should be imported without creating frames for them. The behavior here should be the same as in the Import resources.
  • Make sure the cursors show where the resources can be dropped.

comment:5 Changed 10 years ago by deyan

  • Status changed from s1a_analysis_started to s1b_analysis_finished
  • Analysis_owners set to deyan

comment:6 Changed 10 years ago by deni

  • Design_owners set to deni
  • Status changed from s1b_analysis_finished to s1c_analysis_ok
  • Imp._owners set to deni
  • Analysis_reviewers set to deni
  • Analysis_score changed from 0 to 4

comment:7 Changed 10 years ago by deni

  • Owner changed from deyan to deni
  • Status changed from s1c_analysis_ok to s2a_design_started

comment:8 Changed 10 years ago by deni

  • Status changed from s2a_design_started to s2b_design_finished
  • Dragging files from the desktop to the page work area:
    • Add a new DndData responsible for tranferring java.io.File-s:
      • new class FileListData in org.sophie2.main.dnd.dnddata package;
      • supported flavor - DataFlavor.javaFileListFlavor;
      • nested class FileListDndProvider implements DndProvider - an extension for FileListData objects, registered in MainDndModule
    • Mark that page work area supports dropping FileListData in ScenePageLogic's ON_DND_PRE_IMPORT operation.
    • Add a new ON_DROP_FILE operation in ResourceImportLogic that handles dropping one or multiple files over the page work area.
      • It gets the list of files from the FileListData of the tranferable.
      • For each of them it finds the appropriate ResourceImportProvider - one whose file filter accepts the extension of the file - and calls a new helper method dropFile(...) from ResourceImportUtil.
    • ResourceImportUtil changes:
      • Move the common logic for inserting a dropped resource from dropResource(ResourceImportProvider, BookH, ElementH, ImmPoint, DndTransferable) to a private helper method dropResource(ResourceImportProvider, BookH, ElementH, ImmPoint, ResourceImportManager<D>, D) which will be used for inserting resources not only from transferables, but also from files.
    • In the original dropResource get the import manager, get the resource data from it and call the new one.
    • In the new dropFile(ResourceImportProvider, BookH, ElementH, ImmPoint, File) method again get the import manager, the resource data from it (but using a different method) and call dropResource.
  • Dragging resources from the desktop to the Resources palette:
    • Enable drop over the Resources palette in AllResourcesPalette.initHead().
    • Add a new operation ON_DND_PRE_IMPORT in AllResourcesPaletteLogic which specifies what kind of data could be dropped over the palette.
      • For now, the only type is FileListData.
      • Make sure that dropping files over the palette is forbidden in reader and preview mode.
    • Move the logic for importing resources to the current book (without creating new frames) from ON_IMPORT_RESOURCE to helper methods in ResourceImportLogic:
      • private static boolean importFiles(List<File>, VisualElement) - the most important, uses the next two;
      • private static List<File> getFlatAndExtracted(List<File> files) - formerly called getArchieved, recursively replaces zip files and directories with the files they contain
        • feel free to rename it, if you think of a better name
      • private static ResourceImportProvider getSophieFormatProvider(VisualElement) - no changes, maybe it should be used in ON_INSERT_FRAME and ON_DROP_FILE, but I tried it and it didn't work...
    • Add a new ON_DROP_FILES_OVER_RESOURCES_PALETTE operation in ResourceImportLogic that handles importing resources to the current book by dropping one or multiple files over the Resources palette.
      • It should get the files from the transferable and call importFiles(files, palette).


  • Meddle's fix about dragging embedded books from the Resources palette to the page work area:
    • The problem is that ResourceAccess.getHead() returns a revision of the top containing resource.
      • Therefore, SophieFormatImportManager.getResourceData(ResourceAccess) if necessary, we should get a submodel of the head revision's model.
      • To do so, we need an inner reference from the top resource to the resource of the given access. We will acquire it using the new private ResourceRefR4 getSubRef(ResourceRefR4 ref) method.
    • Some changes in ON_DROP_RESOURCE operation might be neccesary in order for it to handle dropping embedded book. Otherwise it will be done by ON_FRAME_TEMPLATE_DND_IMPORT.
      • Maybe we should check whether the transferable contains ResourceRefData and if so, fire a DND_IMPORT_RESOURCE event without searching for the import role.
  • Not yet implemented:
    • Dragging files in Sophie2 format other than books from the desktop to the page work area.
    • Maybe a message when some of the files dropped over the page work area could not be imported.

comment:9 Changed 10 years ago by meddle

  • Status changed from s2b_design_finished to s2c_design_ok
  • Design_score changed from 0 to 3.5
  • Design_reviewers set to meddle

Some notes:

  • supported flavor - DataFlavor.javaFileListFlavor; -> this thing is strange for me, can you describe it with more details?
  • ON_DROP_FILES_OVER_RESOURCES_PALETTE -> this thing is for the ResourcePaletteLogic
  • You should sync with the trunk when the ResourceChooser is merged (may be today), because it divides the ON_IMPORT_RESOURCE on helper methods too...
  • "Dragging files in Sophie2 format other than books" make sure for the implementation to put design for that.
  • Don't forget that part of the analysis -> "If the resource(s) (folder) was dropped on a page, new frames with starting coordinates the drop point and offset of 10px top and right should be created.". I can help you with it.
  • Make sure the import/export tests are not failing after your changes, if some of them currently fails, fix them :)

3.5p

comment:10 Changed 10 years ago by deni

  • Status changed from s2c_design_ok to s3a_implementation_started

comment:11 Changed 10 years ago by deni

  • Status changed from s3a_implementation_started to s3b_implementation_finished
  • DataFlavor.javaFileListFlavor is a java.awt.datatransfer.DataFlavor used to transfer a list of files to/from Java (and the underlying platform)...
  • I think that ON_DROP_FILES_OVER_RESOURCES_PALETTE should be in the same logic as ON_IMPORT_RESOURCE that handles clicking on the Import button from the resources palette. They do similar things and use common helper methods.
  • Drag&drop of files in Sophie2 format other that books (for example, *.image.s2) will not be implemented now. Only files which can be inserted from the Insert menu can be dropped over the page work area.
  • In ON_DROP_FILE before iterating over the dropped files, recursively replace the directories with the files they contain and extract archives.
  • In ON_DROP_FILE keep a list of all files that could not be inserted and show and error message using ResourceImportUtil.showInvalidInfo(List<File>);

comment:12 Changed 10 years ago by deni

The implementation described above didn't work under Linux. It turned out that when dragging a file or group of files, the transferable does not support DataFlavor.javaFileListFlavor. However, it supports "text/plain" data flavor, so a new text frame containing the filenames was inserted.

  • See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4899516
  • I copied the workaround suggested there:
    • Added "text/uri-list" data flavor to FileListData and a private method that given a string containing URIs, parses and opens them and returns a list of Files.
  • I changed the sort keys of ON_DROP_RESOURCE and ON_DROP_FILE, so if we drag one or multiple files, the ON_DROP_FILE operation will handle the event and insert a frame of the appropriate kind.

comment:13 Changed 10 years ago by meddle

  • Status changed from s3b_implementation_finished to s3c_implementation_ok
  • Imp._score changed from 0 to 4.5
  • Imp._reviewers set to todor, meddle

Merged to the trunk at [8568].

Very good, only that bug with the names was not fixed, but now is fixed.

4.5p

comment:14 Changed 8 years ago by meddle

  • Status changed from s3c_implementation_ok to closed
  • Resolution set to obsolete

Closing all the tickets before M Y1

Note: See TracTickets for help on using tickets.