if (HermesBrowser.getBrowser().getDocumentPane().getActiveDocument() instanceof BrowserAction)
{
try
{
BrowserAction browserAction = (BrowserAction) HermesBrowser.getBrowser().getDocumentPane().getActiveDocument();
final String message = browserAction.getSelectedMessages().size() == 1 ? "You are about to copy this message to the clipboard and delete it from "
: "You are about to copy " + browserAction.getSelectedMessages().size() + " messages to the clipboard and delete them from ";
if (JOptionPane.showConfirmDialog(HermesBrowser.getBrowser(), message + browserAction.getDestination() + " - are you sure ?", "Warning",
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
{
Collection<Message> messages = browserAction.getSelectedMessages();
Clipboard systemcClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable t = new StringSelection(xml.toXML(messages));
systemcClipboard.setContents(t, null);
Hermes.ui.getDefaultMessageSink().add(messages.size() + TextUtils.plural(messages.size()) + " messages copied to clipboard, now deleting.");
if (browserAction instanceof MessageStoreBrowserAction)
{
final MessageStoreBrowserAction storeAction = (MessageStoreBrowserAction) browserAction;
HermesBrowser.getBrowser().getActionFactory().createDeleteFromMessageStoreAction(storeAction.getMessageStore(),
browserAction.getSelectedMessages(), false);
}
else
{
HermesBrowser.getBrowser().getActionFactory().createTruncateAction(browserAction.getHermes(), browserAction.getConfig(),
browserAction.getSelectedMessageIDs(), false, browserAction);
}
}
else
{
Hermes.ui.getDefaultMessageSink().add("Cut from " + browserAction.getDestination() + " cancelled");
}
}
catch (HeadlessException e)
{
log.error("doCopy(): " + e.getMessage(), e);