use of org.eclipse.swt.dnd.Clipboard in project cubrid-manager by CUBRID.
the class CreateSqlJavaCodeAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
// FIXME move this logic to core module
Control control = getFocusProvider();
if (control instanceof StyledText) {
StyledText stext = (StyledText) control;
String data = stext.getSelectionText();
if (data != null && !data.equals("")) {
StringBuilder res = new StringBuilder();
Vector<String> list = QueryUtil.queriesToQuery(data);
for (int i = 0; i < list.size(); i++) {
String row = list.get(i);
if (res.length() > 0) {
res.append("\n\n");
}
res.append(parseToJavaCode(row));
}
if (res.length() == 0) {
CommonUITool.openErrorBox(Messages.errCreatedSqlNotSelected);
return;
}
Clipboard clipboard = CommonUITool.getClipboard();
TextTransfer textTransfer = TextTransfer.getInstance();
clipboard.setContents(new Object[] { res.toString() }, new Transfer[] { textTransfer });
CommonUITool.openInformationBox(Messages.titleCreateCode, Messages.msgCreatedSqlJavaCode);
} else {
CommonUITool.openErrorBox(Messages.errCreatedSqlNotSelected);
}
}
}
use of org.eclipse.swt.dnd.Clipboard in project cubrid-manager by CUBRID.
the class CreateSqlPhpCodeAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
// FIXME move this logic to core module
Control control = getFocusProvider();
if (control instanceof StyledText) {
StyledText stext = (StyledText) control;
String data = stext.getSelectionText();
if (StringUtil.isNotEmpty(data)) {
StringBuilder res = new StringBuilder();
Vector<String> list = QueryUtil.queriesToQuery(data);
for (int i = 0; i < list.size(); i++) {
String row = list.get(i);
if (res.length() > 0) {
res.append("\n\n");
}
res.append(parseToPhpCode(row));
}
if (res.length() == 0) {
CommonUITool.openErrorBox(Messages.errCreatedSqlNotSelected);
return;
}
Clipboard clipboard = CommonUITool.getClipboard();
TextTransfer textTransfer = TextTransfer.getInstance();
clipboard.setContents(new Object[] { res.toString() }, new Transfer[] { textTransfer });
CommonUITool.openInformationBox(Messages.titleCreateCode, Messages.msgCreatedSqlPhpCode);
} else {
CommonUITool.openErrorBox(Messages.errCreatedSqlNotSelected);
}
}
}
use of org.eclipse.swt.dnd.Clipboard in project cubrid-manager by CUBRID.
the class PasteAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
Control control = getFocusProvider();
if (control instanceof StyledText) {
Object contents = clipboard.getContents(textTransfer);
if (contents instanceof String) {
String str = (String) contents;
StyledText text = (StyledText) control;
Point range = text.getSelectionRange();
text.replaceTextRange(range.x, range.y, str);
text.setSelection(range.x + str.length());
}
}
}
use of org.eclipse.swt.dnd.Clipboard 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.Clipboard 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 });
}
}
Aggregations