Lines 17-29
Link Here
|
17 |
import java.util.Iterator; |
17 |
import java.util.Iterator; |
18 |
import java.util.List; |
18 |
import java.util.List; |
19 |
|
19 |
|
20 |
import org.eclipse.swt.SWTError; |
|
|
21 |
import org.eclipse.swt.custom.ST; |
20 |
import org.eclipse.swt.custom.ST; |
22 |
import org.eclipse.swt.custom.StyledText; |
21 |
import org.eclipse.swt.custom.StyledText; |
23 |
import org.eclipse.swt.dnd.Clipboard; |
|
|
24 |
import org.eclipse.swt.dnd.DND; |
25 |
import org.eclipse.swt.dnd.TextTransfer; |
26 |
import org.eclipse.swt.dnd.Transfer; |
27 |
import org.eclipse.swt.events.VerifyEvent; |
22 |
import org.eclipse.swt.events.VerifyEvent; |
28 |
import org.eclipse.swt.graphics.Point; |
23 |
import org.eclipse.swt.graphics.Point; |
29 |
import org.eclipse.swt.widgets.Composite; |
24 |
import org.eclipse.swt.widgets.Composite; |
Lines 1551-1590
Link Here
|
1551 |
} |
1546 |
} |
1552 |
|
1547 |
|
1553 |
private void copyToClipboard(ITextSelection selection, boolean delete, StyledText textWidget) { |
1548 |
private void copyToClipboard(ITextSelection selection, boolean delete, StyledText textWidget) { |
|
|
1549 |
if (isProjectionMode()) { |
1550 |
int offset= selection.getOffset(); |
1551 |
int length= selection.getLength(); |
1552 |
ProjectionAnnotation[] collapsed= computeCollapsedNestedAnnotations(offset, length); |
1554 |
|
1553 |
|
1555 |
String copyText= selection.getText(); |
1554 |
if (collapsed != null) { |
1556 |
if (copyText == null) // selection.getText failed - backup using widget |
1555 |
for (int i= 0; i < collapsed.length; i++) { |
1557 |
textWidget.copy(); |
1556 |
collapsed[i].markExpanded(); |
1558 |
|
1557 |
} |
1559 |
if (copyText != null && copyText.equals(textWidget.getSelectionText())) { |
1558 |
fProjectionAnnotationModel.modifyAnnotations(null, null, collapsed); |
1560 |
/* |
1559 |
setSelection(selection); |
1561 |
* XXX: Reduce pain of https://bugs.eclipse.org/bugs/show_bug.cgi?id=64498 |
1560 |
} |
1562 |
* by letting the widget handle the copy operation in this special case. |
|
|
1563 |
*/ |
1564 |
textWidget.copy(); |
1565 |
} else if (copyText != null) { |
1566 |
|
1567 |
Clipboard clipboard= new Clipboard(textWidget.getDisplay()); |
1568 |
|
1561 |
|
1569 |
try { |
1562 |
try { |
1570 |
Transfer[] dataTypes= new Transfer[] { TextTransfer.getInstance() }; |
1563 |
textWidget.copy(); |
1571 |
Object[] data= new Object[] { copyText }; |
|
|
1572 |
try { |
1573 |
clipboard.setContents(data, dataTypes); |
1574 |
} catch (SWTError e) { |
1575 |
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) |
1576 |
throw e; |
1577 |
/* |
1578 |
* TODO see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59459 |
1579 |
* we should either log and/or inform the user |
1580 |
* silently fail for now. |
1581 |
*/ |
1582 |
return; |
1583 |
} |
1584 |
|
1585 |
} finally { |
1564 |
} finally { |
1586 |
clipboard.dispose(); |
1565 |
if (collapsed != null) { |
|
|
1566 |
for (int i= 0; i < collapsed.length; i++) { |
1567 |
collapsed[i].markCollapsed(); |
1568 |
} |
1569 |
fProjectionAnnotationModel.modifyAnnotations(null, null, collapsed); |
1570 |
setSelection(selection); |
1571 |
} |
1587 |
} |
1572 |
} |
|
|
1573 |
|
1574 |
} else { |
1575 |
textWidget.copy(); |
1588 |
} |
1576 |
} |
1589 |
|
1577 |
|
1590 |
if (delete) { |
1578 |
if (delete) { |