wiki:BASE_DND_R1
Last modified 16 years ago Last modified on 08/24/09 13:11:39

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

Error: Macro TicketQuery(summary=BASE_DND_R1, 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

Overview

This revision of the task will introduce CUT/COPY and PASTE operations for resources in Sophie2.0. It should also provide the implementation for clipboard operations with images(from, to and in Sophie2.0). If there is time left a prototype drag and drop functionality is considered to be implemented.

Task requirements

  • Provide support for CUT/COPY/PASTE of resources.
    • From resource palette to the page work area
      • Copy an image resource from the resources palette and paste it to the page work area should create a new image frame with the selected resource.
      • Copy text resource from the resource palette and paste 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.
      • Copy an image resource from the resources palette and paste it to an image editor.
      • For the text this function is already working.
  • Create the hierarchy and logic how resources from the resources palette will be copied and pasted.

Task result

  • source code.
  • Optional:wiki content with diagrams.

Implementation idea

  • Create implementations of DndData for resources.
    • Either one DndData or multiple for the different types of resources. Depends on the design.
  • Create implementation of SophieTransferable for resources.
    • Again may need only one transferable for resources or several.
  • Note: If implementing clipboard operations for resources turns out to be a difficult thing, consider implementing only Frame clipboard operations.
  • Put the ImageData into the created transferables to support transferring images if needed.
  • Optional: (If not done, SHOULD be put for the next revision!)
    • 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.
        • Note: This should be rather easy having in mind that we have already implemented the necessary DndDatas and SophieTransferables...
      • Provide a diagram of the D'n'd manager.
      • Create a wiki page named BASE_DND, to serve as a reference for all drag and drop and cut/copy/paste functionality. It should have all the design of the base library, as well as the already implemented functionality. For example explaining the use cases that are implemented.
    • Create a DndManager class. It should be able to provide the interaction between VisualElements.
    • Create the diagram using netbeans and put it in the newly created page. Put also the wiki content of the previous revision of this task.

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

  • Create module org.sophie2.main.dnd with packages:
    • org.sophie2.main.dnd - with MainDndModule which is SophieModule for the module.
    • org.sophie2.main.dnd.dnddata - with ResourceData which is DndData for Sophie Resources.
    • org.sophie2.main.dnd.providers - ResourceDataProvider and ImageResourceDataProvider.
    • org.sophie2.main.dnd.transferables - ResourceTransferable which is a SophieTransferable for transfering resources.
  • The org.sophie2.main.dnd module provides an extension point which interface is ResourceDataProvider. The module also attach an extension ImageResourceDataProvider to the extension point.
    • The idea is that every Sophie Resource should give a list with the DndDatas that support providing an extension to the ResourceDataProvider extension point.
    • The ResourceTransferable transfers a resource and fill in the list with the registered datas while going through the extensions that have attached to the extension point.
  • The org.sophie2.main.dnd module provides an extension ResourceDndProvider to DndProvider extension point of org.sophi2.base.dnd.
  • Using serialization, HotText can be copy/pasted between different Sophie-s. HotAttr, HotPos, HotStyleDef, HotStyleValue, HotUnit should implement Serializable.

  • Unit tests
    • ImageDndDataTest in org.sophie2.base.dnd - tests ImageData.
    • ResourceDndDataTest in org.sophie2.main.dnd - tests ResourceData.

Implementation

[5424] [5456] [5457] [5535] [5536] [5539]

Merged to the trunk in [5566].

Testing

(Place the testing results here.)

Comments

  • On paste it is significant what is currently selected - for example, if you paste frame A in a book, but frame B is currently selected, frame A replaces frame B (in page work area, replacement is not a good idea for the resources palette since it is hard to select nothing there. This should be applied to all elements and behavior should be stated.
  • During this revision copy/paste will be done by keyboard shortcuts, add this in the task overview
  • "Duplicate" may be convinient and should be discussed, however, there's no need to add it to this task