use of org.eclipse.swt.dnd.TextTransfer in project epp.mpc by eclipse.
the class ShareSolutionLink method openNewMail.
protected void openNewMail() {
String subject = NLS.bind(Messages.ShareSolutionLink_mailSubject, new Object[] { catalogItem.getName() });
String body = computeMessage();
String recipient = Messages.ShareSolutionLink_recipient;
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String mailToString = "mailto:" + recipient + "?subject=" + subject + "&body=" + body;
try {
URI uri = URIUtil.fromString(mailToString);
openMail(uri);
} catch (Exception e) {
boolean copyToClipboard = MessageDialog.openQuestion(WorkbenchUtil.getShell(), Messages.ShareSolutionLink_share, Messages.ShareSolutionLink_failed_to_open_manually_share);
if (copyToClipboard) {
Clipboard clipboard = new Clipboard(control.getDisplay());
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { body };
clipboard.setContents(data, transfers);
clipboard.dispose();
}
MarketplaceClientUi.error(e);
}
}
use of org.eclipse.swt.dnd.TextTransfer in project webtools.servertools by eclipse.
the class TextAction method copy.
/**
* Copies the selected text to the clipboard. The text will be put in the
* clipboard in plain text format.
*/
public void copy() {
Point selection = getControlSelection();
Control control = getControl();
if (control == null)
return;
if (control instanceof Text) {
Text textcontrol = (Text) control;
if ((textcontrol.getStyle() & SWT.PASSWORD) != 0)
return;
}
String text = getControlText();
if (selection == null || text == null)
return;
int length = selection.y - selection.x;
if (length > 0) {
TextTransfer plainTextTransfer = TextTransfer.getInstance();
try {
clipboard.setContents(new String[] { text.substring(selection.x, selection.y) }, new Transfer[] { plainTextTransfer });
} catch (SWTError error) {
// Copy to clipboard failed. This happens when another application
// is accessing the clipboard while we copy. Ignore the error.
}
}
}
use of org.eclipse.swt.dnd.TextTransfer in project core by jcryptool.
the class HexTextbox method paste.
@Override
public void paste() {
final Clipboard cb = new Clipboard(this.getDisplay());
TextTransfer transfer = TextTransfer.getInstance();
String data = (String) cb.getContents(transfer);
for (int i = 0; i < data.length(); i++) enteredCharacter(data.charAt(i));
}
use of org.eclipse.swt.dnd.TextTransfer in project tdq-studio-se by Talend.
the class CopyColumnNameAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
try {
Clipboard clipBoard = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
TableItem[] items = _table.getSelection();
if (items == null || items.length == 0) {
return;
}
int columnIndex = _cursor.getColumn();
TableColumn column = _table.getColumn(columnIndex);
clipBoard.setContents(new Object[] { column.getText() }, new Transfer[] { textTransfer });
} catch (Exception e) {
SQLExplorerPlugin.error(Messages.getString("CopyColumnNameAction.error"), e);
}
}
use of org.eclipse.swt.dnd.TextTransfer in project tdq-studio-se by Talend.
the class CopyCellAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
try {
Clipboard clipBoard = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
TableItem[] items = _table.getSelection();
if (items == null || items.length == 0) {
return;
}
int columnIndex = _cursor.getColumn();
clipBoard.setContents(new Object[] { items[0].getText(columnIndex) }, new Transfer[] { textTransfer });
} catch (Exception e) {
SQLExplorerPlugin.error("Error exporting cell to clipboard ", e);
}
}
Aggregations