Author: scabanovich
Date: 2011-06-13 20:10:07 -0400 (Mon, 13 Jun 2011)
New Revision: 32075
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/dnd/TextEditorDrop.java
Log:
JBIDE-9040
https://issues.jboss.org/browse/JBIDE-9040
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/dnd/TextEditorDrop.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/dnd/TextEditorDrop.java 2011-06-14
00:08:10 UTC (rev 32074)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/dnd/TextEditorDrop.java 2011-06-14
00:10:07 UTC (rev 32075)
@@ -17,6 +17,7 @@
import org.eclipse.swt.graphics.*;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.dnd.*;
+import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.source.ISourceViewer;
import org.jboss.tools.common.model.XModelObject;
@@ -79,14 +80,25 @@
x = pp.x;
y = pp.y;
int lineIndex = (t.getTopPixel() + y) / t.getLineHeight();
+ int result = 0;
if (lineIndex >= t.getLineCount()) {
- return t.getCharCount();
+ result = t.getCharCount();
} else {
int c = 0;
c = t.getOffsetAtLocation(new Point(x, y));
if(c < 0) c = 0;
- return c;
+ result = c;
}
+
+ if (v instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 ext = (ITextViewerExtension5) v;
+ int off = ext.widgetOffset2ModelOffset(result);
+ if (off >= 0) {
+ result = off;
+ }
+ }
+
+ return result;
}
public void drop(Properties p) {