|
Lines 41-46
Link Here
|
| 41 |
import org.eclipse.jface.wizard.WizardPage; |
41 |
import org.eclipse.jface.wizard.WizardPage; |
| 42 |
import org.eclipse.swt.SWT; |
42 |
import org.eclipse.swt.SWT; |
| 43 |
import org.eclipse.swt.dnd.Clipboard; |
43 |
import org.eclipse.swt.dnd.Clipboard; |
|
|
44 |
import org.eclipse.swt.dnd.ImageTransfer; |
| 44 |
import org.eclipse.swt.dnd.TextTransfer; |
45 |
import org.eclipse.swt.dnd.TextTransfer; |
| 45 |
import org.eclipse.swt.events.ModifyEvent; |
46 |
import org.eclipse.swt.events.ModifyEvent; |
| 46 |
import org.eclipse.swt.events.ModifyListener; |
47 |
import org.eclipse.swt.events.ModifyListener; |
|
Lines 48-53
Link Here
|
| 48 |
import org.eclipse.swt.events.SelectionEvent; |
49 |
import org.eclipse.swt.events.SelectionEvent; |
| 49 |
import org.eclipse.swt.events.ShellAdapter; |
50 |
import org.eclipse.swt.events.ShellAdapter; |
| 50 |
import org.eclipse.swt.events.ShellEvent; |
51 |
import org.eclipse.swt.events.ShellEvent; |
|
|
52 |
import org.eclipse.swt.graphics.ImageData; |
| 51 |
import org.eclipse.swt.graphics.Point; |
53 |
import org.eclipse.swt.graphics.Point; |
| 52 |
import org.eclipse.swt.layout.GridData; |
54 |
import org.eclipse.swt.layout.GridData; |
| 53 |
import org.eclipse.swt.layout.GridLayout; |
55 |
import org.eclipse.swt.layout.GridLayout; |
|
Lines 114-120
Link Here
|
| 114 |
|
116 |
|
| 115 |
private NewAttachmentWizard wizard; |
117 |
private NewAttachmentWizard wizard; |
| 116 |
|
118 |
|
| 117 |
private String clipboardContents; |
119 |
private Object clipboardContents; |
| 118 |
|
120 |
|
| 119 |
private boolean initUseClipboard = false; |
121 |
private boolean initUseClipboard = false; |
| 120 |
|
122 |
|
|
Lines 424-442
Link Here
|
| 424 |
if (inputMethod == CLIPBOARD) { |
426 |
if (inputMethod == CLIPBOARD) { |
| 425 |
Control c = getControl(); |
427 |
Control c = getControl(); |
| 426 |
if (c != null) { |
428 |
if (c != null) { |
| 427 |
Clipboard clipboard = new Clipboard(c.getDisplay()); |
429 |
Object o = retrieveClipboardContents(); |
| 428 |
Object o = clipboard.getContents(TextTransfer.getInstance()); |
|
|
| 429 |
clipboard.dispose(); |
| 430 |
if (o instanceof String) { |
430 |
if (o instanceof String) { |
| 431 |
String s = ((String) o).trim(); |
431 |
String s = ((String) o).trim(); |
| 432 |
if (s.length() > 0) |
432 |
if (s.length() > 0) { |
| 433 |
attachmentFound = true; |
433 |
attachmentFound = true; |
| 434 |
else |
434 |
} else { |
| 435 |
error = "Clipboard is empty"; |
435 |
error = "Clipboard is empty"; |
| 436 |
} else |
436 |
} |
| 437 |
error = "Clipboard does not contain text"; |
437 |
} else if(o instanceof ImageData) { |
| 438 |
} else |
438 |
attachmentFound = true; |
|
|
439 |
} else { |
| 440 |
error = "Unsupported clipboard content"; |
| 441 |
} |
| 442 |
} else { |
| 439 |
error = "Cannot retrieve clipboard contents"; |
443 |
error = "Cannot retrieve clipboard contents"; |
|
|
444 |
} |
| 440 |
} else if (inputMethod == SCREENSHOT) { |
445 |
} else if (inputMethod == SCREENSHOT) { |
| 441 |
attachmentFound = true; |
446 |
attachmentFound = true; |
| 442 |
} else if (inputMethod == FILE) { |
447 |
} else if (inputMethod == FILE) { |
|
Lines 620-641
Link Here
|
| 620 |
} |
625 |
} |
| 621 |
|
626 |
|
| 622 |
private void storeClipboardContents() { |
627 |
private void storeClipboardContents() { |
|
|
628 |
clipboardContents = retrieveClipboardContents(); |
| 629 |
} |
| 630 |
|
| 631 |
private Object retrieveClipboardContents() { |
| 623 |
Control c = getControl(); |
632 |
Control c = getControl(); |
| 624 |
if (c != null) { |
633 |
if (c != null) { |
| 625 |
Clipboard clipboard = new Clipboard(c.getDisplay()); |
634 |
Clipboard clipboard = new Clipboard(c.getDisplay()); |
| 626 |
Object o = clipboard.getContents(TextTransfer.getInstance()); |
635 |
|
| 627 |
clipboard.dispose(); |
636 |
Object o = clipboard.getContents(ImageTransfer.getInstance()); |
| 628 |
if (o instanceof String) { |
637 |
if(o instanceof ImageData) { |
| 629 |
clipboardContents = ((String) o).trim(); |
638 |
return o; |
|
|
639 |
} else { |
| 640 |
o = clipboard.getContents(TextTransfer.getInstance()); |
| 641 |
if (o instanceof String) { |
| 642 |
return ((String) o).trim(); |
| 643 |
} |
| 630 |
} |
644 |
} |
|
|
645 |
|
| 646 |
clipboard.dispose(); |
| 631 |
} |
647 |
} |
|
|
648 |
return null; |
| 632 |
} |
649 |
} |
| 633 |
|
650 |
|
| 634 |
public String getClipboardContents() { |
651 |
public Object getClipboardContents() { |
| 635 |
return clipboardContents; |
652 |
return clipboardContents; |
| 636 |
} |
653 |
} |
| 637 |
|
654 |
|
| 638 |
public void setClipboardContents(String attachContents) { |
655 |
public void setClipboardContents(Object attachContents) { |
| 639 |
clipboardContents = attachContents; |
656 |
clipboardContents = attachContents; |
| 640 |
} |
657 |
} |