提交 f52df628 编写于 作者: S serge-rider

Generate UUID: copy to clipboard if no active editor found

上级 71fded2d
......@@ -22,6 +22,10 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jkiss.dbeaver.model.data.DBDAttributeBinding;
......@@ -45,6 +49,7 @@ public class GenerateUUIDHandler extends NavigatorHandlerObjectBase {
if (activePart == null) {
return null;
}
String uuid = generateUUID();
IResultSetController rsc = activePart.getAdapter(IResultSetController.class);
if (rsc != null && UIUtils.hasFocus(rsc.getControl())) {
......@@ -61,7 +66,6 @@ public class GenerateUUIDHandler extends NavigatorHandlerObjectBase {
IValueController.EditType.NONE,
null);
DBDValueHandler valueHandler = valueController.getValueHandler();
String uuid = generateUUID();
valueController.updateValue(uuid, false);
}
}
......@@ -76,7 +80,6 @@ public class GenerateUUIDHandler extends NavigatorHandlerObjectBase {
try {
int offset = ((TextSelection) selection).getOffset();
int length = ((TextSelection) selection).getLength();
String uuid = generateUUID();
textViewer.getDocument().replace(
offset,
length, uuid);
......@@ -85,6 +88,17 @@ public class GenerateUUIDHandler extends NavigatorHandlerObjectBase {
DBWorkbench.getPlatformUI().showError("Insert UUID", "Error inserting UUID in text editor", e);
}
}
} else {
Clipboard clipboard = new Clipboard(Display.getCurrent());
try {
TextTransfer textTransfer = TextTransfer.getInstance();
clipboard.setContents(
new Object[]{uuid},
new Transfer[]{textTransfer});
} finally {
clipboard.dispose();
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册