@Override public void menuShown(MenuEvent e) { copyItem.setEnabled(canCopy()); }
public boolean canCopy() { return (bodyText!=null && !bodyText.isDisposed())?bodyText.canCopy():false; } public void copy() {
@Override public void menuShown(MenuEvent e) { copyItem.setEnabled(canCopy()); }
private void updateState() { setEnabled(target != null && target.canCopy()); }
@Override public void widgetSelected(SelectionEvent e) { Action copyAction = viewer.getCopyAction(); if (copyAction!=null) copyAction.setEnabled(bodyText.canCopy()); } });
@Override public void focusGained(FocusEvent e) { Action copyAction = viewer.getCopyAction(); if (copyAction!=null) copyAction.setEnabled(bodyText.canCopy()); } @Override
/** * Copies the selected text into the clipboard. Does nothing if no text is * selected or the text cannot be copied for any other reason. * * @since 3.1 */ public void copy() { if (!canCopy()) return; Clipboard clipboard = new Clipboard(getDisplay()); Object[] o = new Object[] { getSelectionText() }; Transfer[] t = new Transfer[] { TextTransfer.getInstance() }; clipboard.setContents(o, t); clipboard.dispose(); }
/** * Copies the selected text into the clipboard. Does nothing if no text is * selected or the text cannot be copied for any other reason. * * @since 3.1 */ public void copy() { if (!canCopy()) return; Clipboard clipboard = new Clipboard(getDisplay()); Object[] o = new Object[] { getSelectionText() }; Transfer[] t = new Transfer[] { TextTransfer.getInstance() }; clipboard.setContents(o, t); clipboard.dispose(); }