@PublicAPI public final class ClipboardHandler extends java.lang.Object
Facade of the Clipboard handling in Marvin.
Utility class that can be used to transfer Molecule or other data from Marvin to the system clipboard using cut/copy/paste operations.
Modifier and Type | Method and Description |
---|---|
static void |
addTransferable(java.lang.String name,
java.lang.String className,
java.lang.Integer priority,
java.lang.Integer inputPriority,
boolean isdefault,
boolean copyAsTransferable)
Deprecated.
|
static void |
addTransferable(java.lang.String name,
java.lang.String className,
java.lang.Integer priority,
java.lang.Integer inputPriority,
boolean isdefault,
boolean copyAsTransferable,
boolean dndTransferable)
Add a
TransferableDescriptor to the registry, and constructing it by the given
parameters. |
static void |
addTransferable(TransferableDescriptor d)
Add a
TransferableDescriptor to the MTransferable Registry. |
static void |
clearClipboard()
Clears the clipboard by creating an empty Transferable and placing it on the clipboard.
|
static void |
clearClipboardConditionally()
Clears the clipboard, if
isClearClipboardBeforeExport() is true. |
static boolean |
convert(chemaxon.marvin.modules.datatransfer.TransferDataImporter converter)
Convert transfer data available on clipboard in one of the requested flavors.
|
static java.awt.datatransfer.Clipboard |
getClipboard()
Returns the default Toolkit's system clipboard if available, otherwise returns a new
singleton clipboard instance.
|
static java.awt.datatransfer.Transferable |
getClipboardContents()
Inits and return the transferable of the Clipboard for later import.
|
static java.util.List<java.lang.String> |
getCopyAsTransferableNames()
Returns the format's names that are available in the current environment as transfer types
for the Copy As dialog.
|
static java.lang.Object |
getObjectFromClipboard()
Returns the current content of the clipboard if the data can be imported in any of data
formats supported by MolImporter.
|
static java.lang.Object |
getObjectFromClipboard(java.lang.String imageImportServiceURL)
Returns the current content of the clipboard if the data can be imported in any of data
formats supported by MolImporter.
|
static java.lang.Object |
getObjectFromTransferable(java.awt.datatransfer.Transferable transfer)
Returns the content of Transferable if the data can be imported in any of data formats
supported by MolImporter.
|
static java.lang.Object |
getObjectFromTransferable(java.awt.datatransfer.Transferable transfer,
java.lang.String imageImportServiceURL)
Returns the content of Transferable if the data can be imported in any of data formats
supported by MolImporter.
|
static java.lang.String |
getStringFromClipboard()
Returns the String data from the clipboard contents, if the clipboard contains a Transferable
that provides support to
DataFlavor.stringFlavor |
static java.awt.datatransfer.Transferable |
getTransferableFor(Molecule mol,
java.util.Properties props)
Creates a
MTransferable object to the given Molecule with the given
properties. |
static java.awt.datatransfer.Transferable |
getTransferableFor(Molecule mol,
java.util.Properties props,
java.lang.String fmt)
Creates a
MTransferable to the given Molecule with the given properties in
the given format. |
static boolean |
getWorkOnBackGround()
Returns whether the subsystem works on the current thread or on a background thread.
|
static boolean |
isClearClipboardBeforeExport()
Returns whether the subsystem clears the clipboard before a copy operation.
|
static boolean |
isSupportedTransferFormat(java.lang.String fmtId)
Checks whether the given format is available in the current environment or not.
|
static void |
putFormattedTextToClipboard(javax.swing.text.Document doc,
int start,
int end)
Deprecated.
|
static void |
putImageToClipboard(java.awt.Image img)
Places the given Image to the clipboard.
|
static void |
putMoleculeToClipboard(Molecule mol,
java.util.Properties props)
Places a Molecule object to the clipboard which is represented as a Transferable being
configured to support all the default Transfer types of Marvin.
|
static void |
putMoleculeToClipboard(Molecule mol,
java.util.Properties props,
java.lang.String fmt)
Places a Molecule object to the clipboard which is represented as a Transferable configured
to support the transfer types of the specified format identifier.
|
static void |
putOLEToClipboard(Molecule mol,
java.util.Properties props) |
static void |
putStringToClipboard(java.lang.String str)
Places the given String to the clipboard as a
StringSelection . |
static void |
putTransferableToClipboard(java.awt.datatransfer.Transferable t)
A generic way to put content to clipboard.
|
static void |
releasePermanentResources()
Releases all clipboard related native libraries and resources.
|
static void |
removeOLESupport()
Removing the support of OLE transfer format.
|
static TransferableDescriptor |
removeTransferable(java.lang.String name)
Removes a
TransferableDescriptor to the MTransferable Registry by name. |
static TransferableDescriptor |
removeTransferable(TransferableDescriptor d)
Removes a
TransferableDescriptor to the MTransferable Registry. |
static void |
setClearClipboardBeforeExport(boolean b)
Sets whether the subsystem should clear the clipboard before a copy operation.
|
static void |
setWorkOnBackground(boolean b)
Starts or stops the background worker thread and ensures the required state for the type of
work.
|
static void |
startPermanentResources()
Starts all the permanent native resources that have to be started to do fast and reliable
copy in Marvin.
|
public static void setWorkOnBackground(boolean b)
b
- true means working in the background, false means working on the current thread.public static boolean getWorkOnBackGround()
public static void setClearClipboardBeforeExport(boolean b)
b
- true or falsepublic static boolean isClearClipboardBeforeExport()
public static void putStringToClipboard(java.lang.String str)
StringSelection
. When processing on a
background thread, this method will continuously try to put the String to the clipboard until
the operation has succeeded.str
- the String to be placed to the clipboardjava.lang.IllegalStateException
- if the clipboard is currently unavailable, and running on the current thread.@Deprecated public static void putFormattedTextToClipboard(javax.swing.text.Document doc, int start, int end)
doc
- start
- end
- public static void putImageToClipboard(java.awt.Image img)
img
- the Image to be placed to the clipboardjava.lang.IllegalStateException
- if the clipboard is currently unavailable, and running on the current thread.public static void putMoleculeToClipboard(Molecule mol, java.util.Properties props)
mol
- the Molecule to be placed to the clipboardprops
- display properties of the Molecule, this parameter will be used when transferring
Molecule images to clipboard, and can be one of, or the union of properties stored
in UserSettings
, and in the result of
MDocument.getGUIPropertyContainer()
java.lang.IllegalStateException
- if the clipboard is currently unavailable, and running on the current thread.ImageExportUtil
public static void putMoleculeToClipboard(Molecule mol, java.util.Properties props, java.lang.String fmt)
mol
- the Molecule to be placed to the clipboardprops
- display properties of the Molecule, this parameter is useful when transferring
Molecule images to clipboard, and can be one of, or the union of properties stored
in UserSettings
, and in the result of
MDocument.getGUIPropertyContainer()
fmt
- format identifier in which the data will be represented on the clipboard. It can
be null in which case the Molecule will be transferred in the default formats.java.lang.IllegalStateException
- if the clipboard is currently unavailable, and running on the current thread.ImageExportUtil
public static void putOLEToClipboard(Molecule mol, java.util.Properties props)
public static void putTransferableToClipboard(java.awt.datatransfer.Transferable t)
t
- public static boolean convert(chemaxon.marvin.modules.datatransfer.TransferDataImporter converter)
converter
- public static void removeOLESupport()
public static java.lang.String getStringFromClipboard()
DataFlavor.stringFlavor
public static java.lang.Object getObjectFromClipboard() throws java.io.IOException
java.io.IOException
public static java.lang.Object getObjectFromClipboard(java.lang.String imageImportServiceURL) throws java.io.IOException
imageImportServiceURL
- if it points to a working http based image import service url the importer will
use that service when importing images from clipboard.java.io.IOException
public static java.awt.datatransfer.Transferable getClipboardContents()
Transferable
object.public static java.lang.Object getObjectFromTransferable(java.awt.datatransfer.Transferable transfer) throws java.io.IOException
transfer
- the Transferable which represents the datajava.io.IOException
public static java.lang.Object getObjectFromTransferable(java.awt.datatransfer.Transferable transfer, java.lang.String imageImportServiceURL) throws java.io.IOException
transfer
- the Transferable which represents the dataimageImportServiceURL
- if it points to a working http based image import service url the importer will
use that service when importing images from clipboard.java.io.IOException
public static java.awt.datatransfer.Transferable getTransferableFor(Molecule mol, java.util.Properties props)
MTransferable
object to the given Molecule
with the given
properties.mol
- the Molecule which has to be represented by the Transferableprops
- display properties of the Molecule, this parameter will be used when transferring
Molecule images to clipboard, and can be one of, or the union of properties stored
in UserSettings
, and in the result of
MDocument.getGUIPropertyContainer()
ImageExportUtil
public static java.awt.datatransfer.Transferable getTransferableFor(Molecule mol, java.util.Properties props, java.lang.String fmt)
MTransferable
to the given Molecule
with the given properties in
the given format.mol
- the Molecule which has to be represented by the Transferableprops
- display properties of the Molecule, this parameter will be used when transferring
Molecule images to clipboard, and can be one of, or the union of properties stored
in UserSettings
, and in the result of
MDocument.getGUIPropertyContainer()
fmt
- format identifier in which the data will be represented on the clipboard. It can
be null in which case the Molecule will be transferred in the default formats. If
null is given, the default will be used.ImageExportUtil
public static boolean isSupportedTransferFormat(java.lang.String fmtId)
fmtId
- the format identifierpublic static java.util.List<java.lang.String> getCopyAsTransferableNames()
public static void clearClipboard()
public static void clearClipboardConditionally()
isClearClipboardBeforeExport()
is true.public static java.awt.datatransfer.Clipboard getClipboard()
Toolkit.getSystemClipboard()
public static TransferableDescriptor removeTransferable(TransferableDescriptor d)
TransferableDescriptor
to the MTransferable
Registry.d
- the descriptor.public static TransferableDescriptor removeTransferable(java.lang.String name)
TransferableDescriptor
to the MTransferable
Registry by name.name
- the name of the MTransferablepublic static void addTransferable(TransferableDescriptor d)
TransferableDescriptor
to the MTransferable
Registry.d
- the descriptor.@Deprecated public static void addTransferable(java.lang.String name, java.lang.String className, java.lang.Integer priority, java.lang.Integer inputPriority, boolean isdefault, boolean copyAsTransferable)
addTransferable(String, String, Integer, Integer, boolean, boolean, boolean)
instead.TransferableDescriptor
to the registry, and constructing it by the given
parameters.public static void addTransferable(java.lang.String name, java.lang.String className, java.lang.Integer priority, java.lang.Integer inputPriority, boolean isdefault, boolean copyAsTransferable, boolean dndTransferable)
TransferableDescriptor
to the registry, and constructing it by the given
parameters.name
- of the MTransferable represented by the descriptor.className
- The representing class name of the MTransferable represented by the descriptor.priority
- priority on the Copy as dialog of the MTransferable represented by the descriptor.inputPriority
- priority used when importing with the help of the MTransferable represented by the
descriptor.isdefault
- decides whether the MTransferable should be used in default copy.copyAsTransferable
- decides whether the MTrasnferable should be displayed in the copy as dialog.dndTransferable
- flag to indicate whether the transferable is used when importing data from a
dropped objectpublic static void releasePermanentResources()
public static void startPermanentResources()