Package org.fife.ui.rtextarea
Class ClipboardHistory
- java.lang.Object
-
- org.fife.ui.rtextarea.ClipboardHistory
-
public final class ClipboardHistory extends java.lang.Object
Listens for cuts and copies from instances ofRTextArea
. This is used for the "clipboard history" shortcut (Ctrl+Shift+V by default).Note that this class does not listen for all events on the system clipboard, because that functionality is pretty fragile. See https://stackoverflow.com/questions/5484927/listen-to-clipboard-changes-check-ownership for more information.
- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_MAX_SIZE
private java.util.List<java.lang.String>
history
private static ClipboardHistory
instance
private int
maxSize
-
Constructor Summary
Constructors Modifier Constructor Description private
ClipboardHistory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String str)
Adds an entry to the clipboard history.static ClipboardHistory
get()
Returns the singleton instance of this class, lazily creating it if necessary.java.util.List<java.lang.String>
getHistory()
Returns the clipboard history, in most-recently-used order.int
getMaxSize()
Returns the maximum number of clipboard values remembered.void
setMaxSize(int maxSize)
Sets the maximum number of clipboard values remembered.private void
trim()
Ensures the remembered set of strings is not larger than the maximum allowed size.
-
-
-
Field Detail
-
instance
private static ClipboardHistory instance
-
history
private java.util.List<java.lang.String> history
-
maxSize
private int maxSize
-
DEFAULT_MAX_SIZE
private static final int DEFAULT_MAX_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
add
public void add(java.lang.String str)
Adds an entry to the clipboard history.- Parameters:
str
- The text to add.- See Also:
getHistory()
-
get
public static ClipboardHistory get()
Returns the singleton instance of this class, lazily creating it if necessary.This method should only be called on the EDT.
- Returns:
- The singleton instance of this class.
-
getHistory
public java.util.List<java.lang.String> getHistory()
Returns the clipboard history, in most-recently-used order.- Returns:
- The clipboard history.
-
getMaxSize
public int getMaxSize()
Returns the maximum number of clipboard values remembered.- Returns:
- The maximum number of clipboard values remembered.
- See Also:
setMaxSize(int)
-
setMaxSize
public void setMaxSize(int maxSize)
Sets the maximum number of clipboard values remembered.- Parameters:
maxSize
- The maximum number of clipboard values to remember.- Throws:
java.lang.IllegalArgumentException
- IfmaxSize
is not greater than zero.- See Also:
getMaxSize()
-
trim
private void trim()
Ensures the remembered set of strings is not larger than the maximum allowed size.
-
-