use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class CommonUITool method getTextContentFromClipboard.
/**
*
* Get text content from clipboard
*
* @return the string from clipboard
*/
public static String getTextContentFromClipboard() {
Clipboard clipboard = CommonUITool.getClipboard();
TextTransfer textTransfer = TextTransfer.getInstance();
Object obj = clipboard.getContents(textTransfer);
if (obj == null) {
return "";
} else {
return (String) obj;
}
}
use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class CopyAction 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) {
StyledText stext = (StyledText) control;
String data = stext.getSelectionText();
if (data != null && !data.equals("")) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
FocusAction.changeActionStatus(pasteAction, stext);
}
} else {
/*Copy from the active editor*/
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor != null && editor instanceof ICopiableFromTable) {
ICopiableFromTable copyAbleEditor = (ICopiableFromTable) editor;
copyAbleEditor.copySelectedItems();
}
}
}
}
use of org.eclipse.swt.dnd.TextTransfer 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.TextTransfer 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.TextTransfer 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());
}
}
}
Aggregations