CMSC 498B: Developing User Interfaces - Spring 2002Design Patterns | |
Sharing Information Between ProgramsClipboardsSimple clipboard - can use same model for cut-copy-paste and drag-and-dropWhat format to useCross format considerations - source and destination are unknown to each otherReasonable formats: text, image, rich text, filenames, custom (i.e., within a program)What if destination doesn't understand source format?How to deal with very large clipboard files?Java uses "Data Transfer" model (revised in JDK1.4) - read Sun's description It uses a TransferHandler to manage the basic data types, and Swing has built-in support for cut-copy-paste and drag-and-drop. A Transferable is the actual data that gets transferred, and it uses DataFlavor's to represent the different data types. Most related classes are in the java.awt.datatransfer, java.awt.dnd or javax.swing packages. Java Example CopyPasteExample.java DragAndDropExample.java C# Example copy-paste-example.cs drag-and-drop-example.cs Publish and SubscribeMake pasting "live" Publishable sections Paste means to register a subscription Each change to a published section will post that new data to the edition file Each application with subscriptions will check for edition changes and will repost the published information Embedded editingPasted section contains the data, a drawing region, a source program Clicking on the embedded section constructs a new window over the pasted section
MonitoringHigher level activitiesUndo/redoGroupwareMacrosAll require some overall surveillance of the interactive behaviorExampleSimple UndoWhat do we want to UndoHistory list modelPush every action on a listTo undo, take top action off of the list and UNDO that actionIntrinsic commandsEditingChanging of fieldsTransient commandsSelection?Dragging?Irreversible commandsSaveLoadCommand objectsCommand class execute() undo() redo() One command object for every call on the functional model or atomic collection of calls Command object saves the necessary information Java Example: UndoExample.java History list of command objectsEmbedded in the superclass CommandGroupWareForward command objects across the netMacrosSimple strategyProblems with repeatingSelective UndoObject relative undoDelving into the command historyDependency problemsChange of attribute followed by a delete (undo and redo the change of attribute)Command objects with dependenciesProblemsSelective undoGroupware conflictsMacros relativeDependency knowledge can help
| |