use of org.eclipse.swt.dnd.TextTransfer in project tdq-studio-se by Talend.
the class DataSetTableKeyListener method keyPressed.
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
*/
public void keyPressed(KeyEvent e) {
// _logger.fatal(Integer.toString((int)e.character));
switch(e.character) {
case CTRL_C:
try {
Clipboard clipBoard = SQLExplorerPlugin.getDefault().getConnectionsView().getClipboard();
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 ex) {
SQLExplorerPlugin.error(Messages.getString("CopyColumnNameAction.error"), ex);
}
break;
case CTRL_F:
// column name typeahead
createPopup();
break;
}
}
use of org.eclipse.swt.dnd.TextTransfer in project portfolio by buchen.
the class DisplayTextDialog method createButtonsForButtonBar.
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
Button button = createButton(parent, 9999, Messages.LabelCopyToClipboard, false);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (entryText.isDisposed())
return;
Clipboard cb = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
cb.setContents(new Object[] { entryText.getText() }, new Transfer[] { textTransfer });
}
});
}
use of org.eclipse.swt.dnd.TextTransfer in project epp.mpc by eclipse.
the class ShareSolutionLink method copyLinkToClipboard.
protected void copyLinkToClipboard() {
Clipboard clipboard = new Clipboard(control.getDisplay());
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { getUrl() };
clipboard.setContents(data, transfers);
clipboard.dispose();
}
use of org.eclipse.swt.dnd.TextTransfer in project webtools.servertools by eclipse.
the class TextAction method update.
/**
* Update the actions enabled/disabled state.
*/
protected void update() {
if (getControl() == null) {
setEnabled(false);
return;
}
Point selection = getControlSelection();
String text = getControlText();
try {
if (type == CUT_ACTION)
setEnabled(text != null && text.length() > 0 && selection != null && selection.x < selection.y);
else if (type == COPY_ACTION)
setEnabled(text != null && text.length() > 0 && selection != null && selection.x < selection.y);
else if (type == PASTE_ACTION) {
Control control = getControl();
if (!control.isEnabled()) {
setEnabled(false);
return;
}
if (!(control instanceof Text)) {
setEnabled(false);
return;
}
Text text2 = (Text) control;
if (!text2.getEditable()) {
setEnabled(false);
return;
}
TextTransfer transfer = TextTransfer.getInstance();
String newText = (String) clipboard.getContents(transfer);
setEnabled(newText != null && newText.length() > 0);
}
} catch (Exception e) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, "Error updating text action", e);
}
}
}
use of org.eclipse.swt.dnd.TextTransfer in project webtools.servertools by eclipse.
the class TextAction method paste.
/**
* Replaces the selection with the clipboard text or insert the text at
* the current caret offset if there is no selection.
* If the widget has the SWT.SINGLE style and the clipboard text contains
* more than one line, only the first line without line delimiters is
* inserted in the widget.
*/
public void paste() {
TextTransfer transfer = TextTransfer.getInstance();
Point selection = getControlSelection();
String text = getControlText();
if (selection == null)
return;
String newText = (String) clipboard.getContents(transfer);
if (newText != null && newText.length() > 0) {
if (text == null)
text = newText;
else
text = text.substring(0, selection.x) + newText + text.substring(selection.y);
setControlText(text);
// set the selection to the end of the paste
int x = selection.x + newText.length();
setControlSelection(new Point(x, x));
}
}
Aggregations