Java Doc for UndoableEdit.java in  » 6.0-JDK-Core » swing » javax » swing » undo » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing.undo 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.swing.undo.UndoableEdit

All known Subclasses:   javax.swing.undo.AbstractUndoableEdit,
UndoableEdit
public interface UndoableEdit (Code)
An UndoableEdit represents an edit. The edit may be undone, or if already undone the edit may be redone.

UndoableEdit is designed to be used with the UndoManager. As UndoableEdits are generated by an UndoableEditListener they are typically added to the UndoManager. When an UndoableEdit is added to an UndoManager the following occurs (assuming end has not been called on the UndoManager):

  1. If the UndoManager contains edits it will call addEdit on the current edit passing in the new edit as the argument. If addEdit returns true the new edit is assumed to have been incorporated into the current edit and the new edit will not be added to the list of current edits. Edits can use addEdit as a way for smaller edits to be incorporated into a larger edit and treated as a single edit.
  2. If addEdit returns false replaceEdit is called on the new edit with the current edit passed in as the argument. This is the inverse of addEdit — if the new edit returns true from replaceEdit, the new edit replaces the current edit.
The UndoManager makes use of isSignificant to determine how many edits should be undone or redone. The UndoManager will undo or redo all insignificant edits (isSignificant returns false) between the current edit and the last or next significant edit. addEdit and replaceEdit can be used to treat multiple edits as a single edit, returning false from isSignificant allows for treating can be used to have many smaller edits undone or redone at once. Similar functionality can also be done using the addEdit method.
version:
   1.27, 05/05/07
author:
   Ray Ryan




Method Summary
public  booleanaddEdit(UndoableEdit anEdit)
     Adds an UndoableEdit to this UndoableEdit. This method can be used to coalesce smaller edits into a larger compound edit.
public  booleancanRedo()
     Returns true if this edit may be redone.
public  booleancanUndo()
     Returns true if this edit may be undone.
public  voiddie()
     Informs the edit that it should no longer be used.
public  StringgetPresentationName()
     Returns a localized, human-readable description of this edit, suitable for use in a change log, for example.
public  StringgetRedoPresentationName()
     Returns a localized, human-readable description of the redoable form of this edit, suitable for use as a Redo menu item, for example.
public  StringgetUndoPresentationName()
     Returns a localized, human-readable description of the undoable form of this edit, suitable for use as an Undo menu item, for example.
public  booleanisSignificant()
     Returns true if this edit is considered significant.
public  voidredo()
     Re-applies the edit.
public  booleanreplaceEdit(UndoableEdit anEdit)
     Returns true if this UndoableEdit should replace anEdit.
public  voidundo()
     Undo the edit.



Method Detail
addEdit
public boolean addEdit(UndoableEdit anEdit)(Code)
Adds an UndoableEdit to this UndoableEdit. This method can be used to coalesce smaller edits into a larger compound edit. For example, text editors typically allow undo operations to apply to words or sentences. The text editor may choose to generate edits on each key event, but allow those edits to be coalesced into a more user-friendly unit, such as a word. In this case, the UndoableEdit would override addEdit to return true when the edits may be coalesced.

A return value of true indicates anEdit was incorporated into this edit. A return value of false indicates anEdit may not be incorporated into this edit.

Typically the receiver is already in the queue of a UndoManager (or other UndoableEditListener), and is being given a chance to incorporate anEdit rather than letting it be added to the queue in turn.

If true is returned, from now on anEdit must return false from canUndo and canRedo, and must throw the appropriate exception on undo or redo.


Parameters:
  anEdit - the edit to be added true if anEdit may be incorporated into thisedit



canRedo
public boolean canRedo()(Code)
Returns true if this edit may be redone. true if this edit may be redone



canUndo
public boolean canUndo()(Code)
Returns true if this edit may be undone. true if this edit may be undone



die
public void die()(Code)
Informs the edit that it should no longer be used. Once an UndoableEdit has been marked as dead it can no longer be undone or redone.

This is a useful hook for cleaning up state no longer needed once undoing or redoing is impossible--for example, deleting file resources used by objects that can no longer be undeleted. UndoManager calls this before it dequeues edits.

Note that this is a one-way operation. There is no "un-die" method.
See Also:   CompoundEdit.die




getPresentationName
public String getPresentationName()(Code)
Returns a localized, human-readable description of this edit, suitable for use in a change log, for example. description of this edit



getRedoPresentationName
public String getRedoPresentationName()(Code)
Returns a localized, human-readable description of the redoable form of this edit, suitable for use as a Redo menu item, for example. This is typically derived from getPresentationName. a description of the redoable form of this edit



getUndoPresentationName
public String getUndoPresentationName()(Code)
Returns a localized, human-readable description of the undoable form of this edit, suitable for use as an Undo menu item, for example. This is typically derived from getPresentationName. a description of the undoable form of this edit



isSignificant
public boolean isSignificant()(Code)
Returns true if this edit is considered significant. A significant edit is typically an edit that should be presented to the user, perhaps on a menu item or tooltip. The UndoManager will undo, or redo, all insignificant edits to the next significant edit. true if this edit is significant



redo
public void redo() throws CannotRedoException(Code)
Re-applies the edit.
throws:
  CannotRedoException - if this edit can not be redone



replaceEdit
public boolean replaceEdit(UndoableEdit anEdit)(Code)
Returns true if this UndoableEdit should replace anEdit. This method is used by CompoundEdit and the UndoManager; it is called if anEdit could not be added to the current edit (addEdit returns false).

This method provides a way for an edit to replace an existing edit.

This message is the opposite of addEdit--anEdit has typically already been queued in an UndoManager (or other UndoableEditListener), and the receiver is being given a chance to take its place.

If true is returned, from now on anEdit must return false from canUndo() and canRedo(), and must throw the appropriate exception on undo() or redo().


Parameters:
  anEdit - the edit that replaces the current edit true if this edit should replace anEdit



undo
public void undo() throws CannotUndoException(Code)
Undo the edit.
throws:
  CannotUndoException - if this edit can not be undone



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.