Author: scabanovich
Date: 2008-03-05 08:13:03 -0500 (Wed, 05 Mar 2008)
New Revision: 6689
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java
Log:
JBIDE-1847
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java 2008-03-05
10:25:31 UTC (rev 6688)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java 2008-03-05
13:13:03 UTC (rev 6689)
@@ -63,7 +63,9 @@
import org.w3c.dom.Text;
import org.jboss.tools.common.meta.action.XActionInvoker;
+import org.jboss.tools.common.model.XModelBuffer;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelTransferBuffer;
import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.common.text.xml.ui.FreeCaretStyledText;
@@ -620,8 +622,15 @@
}
public void runDropCommand(final String flavor, final String data) {
+ XModelBuffer b = XModelTransferBuffer.getInstance().getBuffer();
+ final XModelObject o = b == null ? null : b.source();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
+ if(o != null && !XModelTransferBuffer.getInstance().isEnabled()) {
+ XModelTransferBuffer.getInstance().enable();
+ XModelTransferBuffer.getInstance().getBuffer().addSource(o);
+ }
+ try {
DropCommandFactory.getInstance()
.getDropCommand(flavor, EmptyTagProposalFactory.getInstance())
.execute(
@@ -632,7 +641,10 @@
getSourceViewer(),
getSelectionProvider()
)
- );
+ );
+ } finally {
+ XModelTransferBuffer.getInstance().disable();
+ }
}
});
}
@@ -653,7 +665,10 @@
try {
c = t.getOffsetAtLocation(new Point(x, y));
if(c < 0) c = 0;
- } catch (Exception ex) {
+ } catch (IllegalArgumentException ex) {
+ if(lineIndex + 1 >= t.getLineCount()) {
+ return t.getCharCount();
+ }
c = t.getOffsetAtLine(lineIndex + 1) -
(t.getLineDelimiter() == null ? 0 : t.getLineDelimiter().length());
}
Show replies by date