transferring data between applications
play

Transferring Data Between Applications Handling the system clipboard - PowerPoint PPT Presentation

Transferring Data Between Applications Handling the system clipboard Drag-and-Drop operations Data transfer classes Data Transfer GUI architectures require a mechanism to Drag-drop is move data between application windows. expected with


  1. Transferring Data Between Applications Handling the system clipboard Drag-and-Drop operations Data transfer classes

  2. Data Transfer § GUI architectures require a mechanism to Drag-drop is move data between application windows. expected with direct § Ideally, something that aligns well with manipulation direct-manipulation principles interfaces - e.g. select data, drag-to-move it elsewhere § Two primary methods evolved to enable “user-interface level data transfer” - Clipboard : copy, cut, paste operations to a system-wide storage area (’clipboard’) that is used to transfer data. - Drag-and-drop : drag data directly from one view/application window to another. § They are different mechanisms that attempt to address some of the same problems (and there’s overlap in implementations). 2

  3. Clipboard Transfer § We want to copy-paste data between applications , so the clipboard need to be managed at the system level. § Data transfer method using a generic data buffer - Copy/Cut data from document to clipboard - Paste data from clipboard to document § Issues that arise - Is access to clipboard contents a potential security risk? - How to you handle different data, and different formats, between applications? e.g. text, image, data table, HTML, SVG. 3

  4. Clipboard Supported Data Formats Sender and Receiver negotiate the data format § When data is placed on clipboard (cut/copy), the sender indicates the data formats that it can support § When data is retrieved (paste) by the receiver , it can request a list of supported formats and then specifically request the data in a supported format. All requests are routed through the system clipboard! There are a wide variety of formats that are handled this way: § Formatted text like HTML, RTF, MS Office, … § Vector-based drawing? (SVG, Illustrator, …) § Images in different file formats (JPG, PNG, TIF, …) § PostScript/PDF drawings? § Tables? Charts? Grouped objects? Filters? § Proprietary graphics formats? (Photoshop layers) § 3D meshes? Video? 4

  5. JavaFX Classes javafx.scene.input.Clipboard Represents an operating system clipboard, on which data may be placed during, for example, cut, copy, and paste operations. javafx.scene.input.ClipboardContent Data container for Clipboard data. It can hold multiple data in several data formats. javafx.scene.input.DataFormat Data format identifier used as means of identifying the data stored on a clipboard/dragboard. 5

  6. Copying Data to the Clipboard Get a reference to the system clipboard. 1. Create a clipboard content instance to hold the data (it’s a map, 2. with each named method storing a particular representation of data). You should put Store the content on the clipboard. LOTS of different 3. formats on the clipboard. 6

  7. Pasting Data from the Clipboard Get a reference to the system clipboard. 1. If your desired format exists on the clipboard, fetch the data 2. directly. You can also fetch and iterate through the list of data formats (e.g. 3. HTML, IMAGE) and then decide which one to fetch. 7

  8. Drag-and-Drop § User clicks-and-drags the source window - Mouse drag listener needs to be setup to start the drag operation § User drops on the destination window - Receiving operation needs to define nodes that will handle the drop operation (e.g. window below) 8

  9. Receiving a Drag-and-Drop Operation § Any node in JavaFX can accept drag-and-drop data from another application through the supported event handler mechanism (see DragBoard below). § Node method setOnDragOver() n eeds to be overridden and implemented to handle the drop on the receiving application. § Data is transferred as a file from the sending application. 9

Recommend


More recommend