CMSC 498B: Developing User Interfaces - Spring 2002

Design Patterns

Sharing Information Between Programs

Clipboards

Simple clipboard - can use same model for cut-copy-paste and drag-and-drop

What format to use

Cross format considerations - source and destination are unknown to each other
Reasonable 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 Subscribe

Make 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 editing

Pasted section contains the data, a drawing region, a source program

Clicking on the embedded section constructs a new window over the pasted section

  • Example: Word w/ embedded Excel chart (uses ActiveX "control")

Monitoring

Higher level activities

Undo/redo

Groupware

Macros

All require some overall surveillance of the interactive behavior

Example

Simple Undo

What do we want to Undo

History list model

Push every action on a list
To undo, take top action off of the list and UNDO that action

Intrinsic commands

Editing
Changing of fields

Transient commands

Selection?
Dragging?

Irreversible commands

Save
Load
Mail

Command objects

Command 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 objects

Embedded in the superclass Command

GroupWare

Forward command objects across the net

Macros

Simple strategy

Problems with repeating

Selective Undo

Object relative undo

Delving into the command history

Dependency problems

Change of attribute followed by a delete (undo and redo the change of attribute)

Command objects with dependencies

Problems

Selective undo

Groupware conflicts

Macros relative

Dependency knowledge can help