use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class PasteAction method isHasContent.
/**
* Return whether has content in clipboard
*
* @return boolean
*/
private boolean isHasContent() {
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
if (clipboard != null) {
Object contents = clipboard.getContents(textTransfer);
if (contents instanceof String) {
String str = (String) contents;
return str != null && str.length() > 0;
}
}
return false;
}
use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class QueryExecuter method copySelectedItems.
public void copySelectedItems() {
CommonUITool.clearClipboard();
StringBuilder content = new StringBuilder();
List<Point> selectedList = selectableSupport.getSelectedLocations();
int currentRow = -1;
int len = selectedList.size();
for (int i = 0; i < len; i++) {
Point location = selectedList.get(i);
if (i == 0) {
currentRow = location.y;
} else if (currentRow != location.y) {
content.append(StringUtil.NEWLINE);
currentRow = location.y;
}
TableItem item = tblResult.getItem(currentRow);
if (!DataType.VALUE_NULL.equals(item.getData(location.x + ""))) {
content.append(item.getText(location.x));
} else {
content.append("");
}
if (i + 1 < len) {
content.append("\t");
}
}
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
if (clipboard != null) {
IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
pasteAction.setEnabled(true);
clipboard.setContents(new Object[] { content.toString() }, new Transfer[] { textTransfer });
}
}
use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class LogEditorPart method copyDataToClipboard.
/**
*
* Copy the selected data to clipboard
*
* @param type String
*/
private void copyDataToClipboard(String type) {
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
StringBuilder content = new StringBuilder();
TableItem[] items = table.getSelection();
for (int i = 0; i < items.length; i++) {
if (CubridNodeType.BROKER_SQL_LOG.equals(type)) {
content.append(items[i].getText(1) + System.getProperty("line.separator"));
}
if (CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(type)) {
content.append(items[i].getText(1) + blank + items[i].getText(2) + blank + items[i].getText(3) + blank + items[i].getText(4) + blank + items[i].getText(5) + blank + items[i].getText(6) + blank + System.getProperty("line.separator"));
}
if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type)) {
content.append(items[i].getText(1) + blank + items[i].getText(2) + blank + items[i].getText(3) + blank + items[i].getText(4) + blank + System.getProperty("line.separator"));
}
if (CubridNodeType.LOGS_SERVER_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_APPLY_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_COPY_DATABASE_LOG.equals(type)) {
content.append(items[i].getText(1) + blank + items[i].getText(2) + blank + items[i].getText(3) + blank + items[i].getText(4) + blank + items[i].getText(5) + blank + items[i].getText(6) + blank + System.getProperty("line.separator"));
}
}
String data = content.toString();
if (data != null && !data.equals("")) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
}
}
use of org.eclipse.swt.dnd.TextTransfer in project tdi-studio-se by Talend.
the class GEFCopyAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
List objects = GEFDeleteAction.filterSameObject(getSelectedObjects());
if (!objects.isEmpty()) {
Clipboard clipboard = Clipboard.getDefault();
org.eclipse.swt.dnd.Clipboard systemClipboard = new org.eclipse.swt.dnd.Clipboard(Display.getCurrent());
boolean noteTextActived = false;
boolean connectionTextActived = false;
boolean nodeLabelActived = false;
Text text = null;
if (objects.size() == 1) {
if (objects.get(0) instanceof NoteEditPart) {
NoteDirectEditManager directEditManager = ((NoteEditPart) objects.get(0)).getDirectEditManager();
if (directEditManager != null && directEditManager.getCellEditor() != null) {
noteTextActived = true;
}
} else if (objects.get(0) instanceof ConnLabelEditPart) {
ConnLabelEditPart connLabelEditPart = (ConnLabelEditPart) objects.get(0);
if (connLabelEditPart.getDirectEditManager() != null && connLabelEditPart.getDirectEditManager().getTextControl() != null) {
connectionTextActived = true;
}
} else if (objects.get(0) instanceof NodeLabelEditPart) {
NodeLabelEditPart nodeLabelEditPart = (NodeLabelEditPart) objects.get(0);
if (nodeLabelEditPart.getDirectEditManager() != null && nodeLabelEditPart.getDirectEditManager().getCellEditor() != null) {
nodeLabelActived = true;
}
}
}
if (noteTextActived) {
text = ((NoteEditPart) objects.get(0)).getDirectEditManager().getTextControl();
clipboard.setContents(text.getSelectionText());
} else if (connectionTextActived) {
text = ((ConnLabelEditPart) objects.get(0)).getDirectEditManager().getTextControl();
clipboard.setContents(text.getSelectionText());
} else if (nodeLabelActived) {
text = (Text) ((NodeLabelEditPart) objects.get(0)).getDirectEditManager().getCellEditor().getControl();
clipboard.setContents(text.getSelectionText());
} else {
clipboard.setContents(objects);
}
if (text != null && !("").equals(text.getSelectionText())) {
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { text.getSelectionText() };
systemClipboard.setContents(data, transfers);
}
}
// Refreshes the pasteAction's enable status.
IWorkbenchPart part = getWorkbenchPart();
if (part instanceof AbstractTalendEditor) {
AbstractTalendEditor talendEditor = (AbstractTalendEditor) part;
IAction action = talendEditor.getActionRegistry().getAction(ActionFactory.PASTE.getId());
action.setEnabled(true);
}
}
use of org.eclipse.swt.dnd.TextTransfer in project tdi-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 = ptable.getSelection();
if (items == null || items.length == 0) {
return;
}
int columnIndex = pcursor.getColumn();
TableColumn column = ptable.getColumn(columnIndex);
clipBoard.setContents(new Object[] { column.getText() }, new Transfer[] { textTransfer });
} catch (Exception e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(org.talend.sqlbuilder.Messages.getString("CopyColumnNameAction.logMessage"), e);
}
}
Aggregations