Class ClipboardUtils
- java.lang.Object
-
- org.openstreetmap.josm.gui.datatransfer.ClipboardUtils
-
public final class ClipboardUtils extends java.lang.Object
This is a utility class that provides methods useful for general data transfer support.- Since:
- 10604
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ClipboardUtils.DoNothingClipboardOwner
-
Field Summary
Fields Modifier and Type Field Description private static java.awt.datatransfer.Clipboard
clipboard
-
Constructor Summary
Constructors Modifier Constructor Description private
ClipboardUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
clear()
Clears the system clipboard.static boolean
copy(java.awt.datatransfer.Transferable transferable)
Copies the given transferable to the clipboard.static boolean
copyString(java.lang.String s)
Copy the given string to the clipboard.static java.awt.datatransfer.Clipboard
getClipboard()
This method should be used from all of JOSM to access the clipboard.static java.awt.datatransfer.Transferable
getClipboardContent()
Extracts clipboard content asTransferable
object.static java.awt.datatransfer.Transferable
getClipboardContent(java.awt.datatransfer.Clipboard clipboard)
Extracts clipboard content asTransferable
object.static java.lang.String
getClipboardStringContent()
Gets the clipboard content as string.static java.awt.datatransfer.Clipboard
getSystemSelection()
Gets the singleton instance of the system selection as aClipboard
object.static java.awt.datatransfer.DataFlavor
newDataFlavor(java.lang.Class<?> c, java.lang.String humanPresentableName)
Returns a newDataFlavor
for the given class and human-readable name.
-
-
-
Field Detail
-
clipboard
private static java.awt.datatransfer.Clipboard clipboard
-
-
Constructor Detail
-
ClipboardUtils
private ClipboardUtils()
-
-
Method Detail
-
getClipboard
public static java.awt.datatransfer.Clipboard getClipboard()
This method should be used from all of JOSM to access the clipboard.It will default to the system clipboard except for cases where that clipboard is not accessible.
- Returns:
- A clipboard.
- See Also:
getClipboardContent()
-
getSystemSelection
public static java.awt.datatransfer.Clipboard getSystemSelection()
Gets the singleton instance of the system selection as aClipboard
object. This allows an application to read and modify the current, system-wide selection.- Returns:
- the system selection as a
Clipboard
, ornull
if the native platform does not support a system selectionClipboard
or if GraphicsEnvironment.isHeadless() returns true - See Also:
Toolkit.getSystemSelection()
-
getClipboardStringContent
public static java.lang.String getClipboardStringContent()
Gets the clipboard content as string.- Returns:
- the content if available,
null
otherwise.
-
getClipboardContent
public static java.awt.datatransfer.Transferable getClipboardContent()
Extracts clipboard content asTransferable
object. Using this method avoids some problems on some platforms.- Returns:
- The content or
null
if it is not available
-
getClipboardContent
public static java.awt.datatransfer.Transferable getClipboardContent(java.awt.datatransfer.Clipboard clipboard)
Extracts clipboard content asTransferable
object. Using this method avoids some problems on some platforms.- Parameters:
clipboard
- clipboard from which contents are retrieved- Returns:
- clipboard contents if available,
null
otherwise.
-
copyString
public static boolean copyString(java.lang.String s)
Copy the given string to the clipboard.- Parameters:
s
- The string to copy.- Returns:
- True if the copy was successful
-
copy
public static boolean copy(java.awt.datatransfer.Transferable transferable)
Copies the given transferable to the clipboard. Handles state problems that occur on some platforms.- Parameters:
transferable
- The transferable to copy.- Returns:
- True if the copy was successful
-
newDataFlavor
public static java.awt.datatransfer.DataFlavor newDataFlavor(java.lang.Class<?> c, java.lang.String humanPresentableName)
Returns a newDataFlavor
for the given class and human-readable name.- Parameters:
c
- classhumanPresentableName
- the human-readable string used to identify this flavor- Returns:
- a new
DataFlavor
for the given class and human-readable name - Since:
- 10801
-
clear
public static boolean clear()
Clears the system clipboard.- Returns:
- True if the clear was successful
- Since:
- 14500
-
-