wiki:BASE_DND_R2
Last modified 16 years ago Last modified on 09/07/09 16:49:04

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=BASE_DND_R2, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

Analysis

(Give as much as possible of the needed information for designing and implementing the task in the following sections.)

Overview

Drag and drop aims to provide seamless and intuitive integration between Sophie2 and other applications. This way importing and exporting different files (resources) is going to be easier and more user friendly.There are three basic kinds of drag and drop behavior:

  • In Sophie application
    • Dragging a resource to book or book desktop should create frame with the corresponding content (e.g. dragging image resource should create an image frame to the location where the image is dropped).
    • User should be able to embed a book by dragging book from open books palette to the current book.
    • When not appropriate action is executed (e.g. trying to embed a book in itself) message warning for the inappropriate must be evoked.
      • The user should be able to turn off this kind of messages (something like checkbox for "Do not show this message anymore" could be used).
      • In case that the messages are forbidden by the user, inappropriate drag and drop must have no visible results.
    • The user should be able to reorder the pages by drag and drop in the page preview palette.
  • From Sophie to other application/desktop
    • Drag and drop outside Sophie must be available only for the resources (drag and drop outside Sophie must be available only from the resources palette)
    • An item dragged from Sophie resources to program that is able to open such file should result in opening this resource. (e.g. If you drag an image from Sophie resources and drop it in Gimp the result must be like dragging and dropping an image from your desktop to Gimp, namely the image is loaded in Gimp.)
    • This behavior should be consistent and with other types of resources. (Dragging video frame from Sophie resources to vlc palyer, should result in playing the video, dragging and dropping text resource in text editor like notepad, should behave like dragging and dropping a text file from your desktop to notepad (if the editor supports formatting, it should be preserved).)
    • However here we should consider if there won't be legal issues with authors of books who don't want the resources they use in the book to be available as standalone resources.
  • From other application/desktop to Sophie.
    • The user must be able to drag file from the desktop to Sophie application. In this case if the file is dropped on the page and if the file is supported, a corresponding frame type must be created.
    • If the file is dropped in the resource palette a corresponding resource must be added.
    • If the file is not supported, nothing should happen.
    • If the user has selected a text from browser or text editor, he/she should be able to drag the selection in Sophie, this will result in copying the text in text frame, or adding the text in the resource palette (this depends on where the text is dropped).
  • Some specific behavior.
    • When text resource is dragged to frame text frame that is on focus, the text is appended after the cursor position. When the text resource is dropped outside of the focused frame or there is no text frame on focus, a text frame with the selected text resource should appear on the exact position of the drop.

Task requirements

  • Add menu entries for Cut, Copy, Paste in the Edit menu.
  • Provide support for drag and drop of resources.
    • From resource palette to the page work area
      • Dragging an image resource from the resources palette and dropping it to the page work area should create a new image frame with the selected resource.
      • Dragging text resource from the resource palette and dropping it to the page work area should create a new text frame with the selected resource.
      • It is optional to do this for other resources at this revision.
    • From resources palette to an application outside Sophie.
      • Drag an image resource from the resources palette and drop it to an image editor.
  • Create the hierarchy and logic how resources from the resources palette will be dragged and dropped.
  • (optional) Dragging an image from image editor to resource palette and from text editor to resource palette should create corresponding rsources.

Task result

The result of this task must be code.

Implementation idea

  • The Edit menu could look like:
    • Edit
      • Undo Ctrl+Z
      • Redo Ctrl+Y
      • Separator
      • Cut Ctrl+X
      • Copy Ctrl+C
      • Paste Ctrl+V
      • Delete Delete
      • Separator
      • Book Title (no need for "set" as it is implied by being in the Edit menu)
      • Page Dimensions
  • Supply base classes for drag and drop management.
    • Create a global drag and drop manager that will handle part of the drag and drop operations. The rest should be handled in the corresponding logic.
    • Create DndData implementations for resources.
    • After creating the drag and drop base classes, implement D'n'D for:
      • images
      • plain text
      • resources.
      • This should be rather easy having in mind that we have already implemented the necessary DndDatas and SophieTransferables...

BASE_DND_R1

How to demo

  • Use case 1:
    • Start sophie.
    • Drag and drop or cut/copy and paste an image resource from resources palette to an image editor. (for example gimp).
      • The image should appear in the editor.
  • Use case 2:
    • Start sophie.
      • Create some frames.
      • Drag and drop or cut/copy and paste a frame resource from the resource palette to the page work area.
        • The corresponding frame should appear as a copy of the selected one.

Design

  • Remove class ResourceData. Create classes ResourceRefData and ResourceRevisionData - implementations of DndDatas for ResourcesR4.
    • ResourceRefData will be used when resource dragged from AllResourcesPalette is dropped in the same book - the resource won't be copied.
    • ResourceRevisionData will be used when resource dragged from AllResourcesPalette is dropped in another book or in another application - the resource will be copied.
  • In DndData - exportToAwt() should be final. Classes that extends DndData should override exportToBinData(). When exporting, resources will be converted to BinData and code that will convert from BinData to InputStream will be hidden. The same when importing a resource.
  • Create class FileAccessUtil that will contain helper methods for converting from ResourceRevision to BinData and from BinData to ResourceRevision.
  • Remove class SophieTransferHandler and create class SophieDragDropHandler that implements DropTargetListener, DragSourceListener, DragGestureListener.
    • This is done because with TransferHandler from java 1.5 is not possible to get the point of the drop, and Sophie should work with java 1.5, so listeners from java 1.2 will be used.
  • Create classes DndAction, DndExport, DndExportDone, DndPreImport, DndImport - these classes represents transactions that are open when drag'n'drop operation is started. Different transactions are for the different states of the drag'n'drop operation.
  • Create enum in SophieDragDropHandler TransferEventIds with constants
    • DND_EXPORT - @EventParams( { DndExport.class, ImmPoint.class })
    • DND_IMPORT - @EventParams( { DndImport.class, ImmPoint.class, String.class }
    • DND_PRE_IMPORT - @EventParams( { DndPreImport.class, ImmPoint.class })
  • Different menu item will extend AppMenuItem. For every item, logic will be created that will handles click over it.

Implementation

(Describe and link the implementation results here (from the wiki or the repository).)

Testing

(Place the testing results here.)

Comments

(Write comments for this or later revisions here.)