use of java.awt.datatransfer.DataFlavor in project nhin-d by DirectProject.
the class MessageServiceImplService method copyAttachments.
/**
* @param body - The incoming unmarshalled SOAP message
* @param mailBody - The mail message that we're constructing
* @throws IOException
* @throws MessagingException
*/
private void copyAttachments(EmailType body, Multipart mailBody) throws IOException, MessagingException {
if (log.isDebugEnabled())
log.debug("Enter");
if (body.getBody().getAttachment().size() > 0) {
for (AttachmentType document : body.getBody().getAttachment()) {
try {
MimeBodyPart mailAttachment = new MimeBodyPart();
if (log.isDebugEnabled()) {
DataHandler dh = document.getContent();
log.debug("Attachment: " + document.getFilename() + "\r\n Type: " + dh.getContentType());
DataFlavor[] flavors = dh.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
log.debug("Flavor: " + flavor.getMimeType());
}
try {
InputStream is = dh.getInputStream();
log.debug("Size: " + is.available());
log.debug("Content class is: " + dh.getContent().getClass().getName());
} catch (Exception e) {
log.error("Could not get an InputStream for Attachment DataHandler object", e);
}
}
mailAttachment.setDataHandler(document.getContent());
mailAttachment.setFileName(document.getFilename());
mailBody.addBodyPart(mailAttachment);
} catch (MessagingException e) {
log.error(e);
throw new MessagingException("Unable to process attachment", e);
}
}
}
if (log.isDebugEnabled())
log.debug("Exit");
}
use of java.awt.datatransfer.DataFlavor in project android by JetBrains.
the class DropTargetDragEventBuilder method build.
public DropTargetDragEvent build() {
DropTargetDragEvent event = mock(DropTargetDragEvent.class);
when(event.getSource()).thenReturn(mySource);
when(event.getLocation()).thenReturn(new Point(myX, myY));
when(event.getDropTargetContext()).thenReturn(myDropTargetContext);
when(event.getDropAction()).thenReturn(myDropAction);
when(event.getSourceActions()).thenReturn(mySourceActions);
when(event.getTransferable()).thenReturn(myTransferable);
DataFlavor[] flavors = myTransferable.getTransferDataFlavors();
when(event.getCurrentDataFlavors()).thenReturn(flavors);
when(event.getCurrentDataFlavorsAsList()).thenReturn(Arrays.asList(flavors));
return event;
}
use of java.awt.datatransfer.DataFlavor in project intellij-community by JetBrains.
the class RawText method getDataFlavor.
public static DataFlavor getDataFlavor() {
if (ourFlavor != null)
return ourFlavor;
try {
DataFlavor flavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + RawText.class.getName(), "Raw Text");
ourFlavor = flavor;
return flavor;
} catch (NoClassDefFoundError | IllegalArgumentException ignore) {
}
return null;
}
use of java.awt.datatransfer.DataFlavor in project jdk8u_jdk by JetBrains.
the class XDataTransferer method getCharsetForTextFormat.
protected String getCharsetForTextFormat(Long lFormat) {
long format = lFormat.longValue();
if (isMimeFormat(format, "text")) {
String nat = getNativeForFormat(format);
DataFlavor df = new DataFlavor(nat, null);
// doesn't support charset.
if (!DataTransferer.doesSubtypeSupportCharset(df)) {
return null;
}
String charset = df.getParameter("charset");
if (charset != null) {
return charset;
}
}
return super.getCharsetForTextFormat(lFormat);
}
use of java.awt.datatransfer.DataFlavor in project jdk8u_jdk by JetBrains.
the class MissedHtmlAndRtfBug method main.
public static void main(String[] args) throws InterruptedException {
Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extractInt(args), InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extractInt(args));
Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extractInt(args), InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extractInt(args));
String[] names = InterprocessArguments.DATA_FLAVOR_NAMES.extractStringArray(args);
DataFlavor df = DataFlavorSearcher.getByteDataFlavorForNative(names);
try {
new MissedHtmlAndRtfBug(targetFrameLocation, dragSourcePoint, df);
} catch (InterruptedException e) {
e.printStackTrace();
}
sleep(5000);
System.exit(InterprocessMessages.NO_DROP_HAPPENED);
}
Aggregations