This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 143368 - html palette broken: DnD does not postition to the insertion point
Summary: html palette broken: DnD does not postition to the insertion point
Status: RESOLVED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Editor (show other bugs)
Version: 6.x
Hardware: All Mac OS X
: P2 blocker (vote)
Assignee: Vitezslav Stejskal
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-09 01:54 UTC by _ ludo
Modified: 2009-05-18 10:42 UTC (History)
9 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ ludo 2008-08-09 01:54:35 UTC
html palette is broken: DnD does not position caret to the insertion point.
Nightly 6.5.
To reproduce, install 6.5 clean user dir, create web app, inser html file in it, select a palette item and try to drop
it in the middle or the end of the html file. Insertion point does not change.

Noticed this when trying to add jMaki palette on HTML, but this is not jmaki specific.
Mac OSX

JSP palette works
Comment 1 hisie 2008-08-31 21:29:10 UTC
Ubuntu Linux 8.04
Netbeans 6.5 Beta.
Drag and drop HTML Elements cause crash of the program. 
Positioning the cursor in the correct place of insert and double works.
To reproduce:
Start Netbeans and open a Java Web project. 
in index.jsp drag and drop a form in the <body> of the document.
Comment 2 pslechta 2008-09-04 11:31:10 UTC
Product Version: NetBeans IDE Dev (Build 200809040201)
Java: 1.6.0; Java HotSpot(TM) Client VM 1.6.0-b105
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)

Not able to reproduce, works fine for me.
Comment 3 _ ludo 2008-09-04 12:24:39 UTC
Bug is for mac osx macbookpro jdk 1.5 from apple
Comment 4 _ ludo 2008-09-04 16:28:28 UTC
Can still reproduce with :

Product Version: NetBeans IDE Dev (Build 080903)
Java: 1.5.0_13; Java HotSpot(TM) Client VM 1.5.0_13-119
System: Mac OS X version 10.5.4 running on i386; MacRoman; en_US (nb)
Userdir: /Users/ludo/.netbeans/dev

Comment 5 Petr Jiricka 2008-09-05 14:38:50 UTC
I have the same behavior as Ludo. Stando or Marku, do you know what the problem could be? Does HTML editor have any
special handling of drop?
Comment 6 Marek Fukala 2008-09-05 15:09:07 UTC
Yes, there is quite a lot of DND specific code written by Libor Kotouc. Besides others, we have own DragAndDropHandler
impl. which otoh seems not to change the semantic of its superclass much. There is also ActiveEditorDrop impl. but I am
not familiar with the code and I couldn't find any specific code doing the insertion poing handling. I would say there
isn't any.

BTW I cannot reproduce the isue either (Mac OSX 10.5.4) I belive Standa will know more... 
Comment 7 Stanislav Aubrecht 2008-09-05 16:00:47 UTC
this problem doesn't seem to be palette related. when i selected and dragged some text directly in html editor the drop
cursor didn't update either. (win xp, jdk 1.5)
Comment 8 Marek Fukala 2008-09-16 10:39:25 UTC
I'll take a look at it...
Comment 9 Marek Fukala 2008-09-16 10:53:52 UTC
The problem is reproducible on Mac OSX 10.5.4 with 1.5.0 JDK. On 1.6.0 JDK it works as expected.
Comment 10 Marek Fukala 2008-09-16 18:30:29 UTC
This really looks like a JDK bug combined with a problem in org.openide.text.QuietEditorPane.

In HTMLKit.install() method we set our own TransferHandler instance to the JComponent.

the call to  
JComponent c;
c.setTransferHandler(new HTMLTransferHandler());

triggers 

c.setDropTarget(new TransferHandler.SwingDropTarget(this));

However to make the drop support properly working the 

SwingDropTarget sdt;
sdt.addDropTargetListener(new TextDropTargetListener());

needs to be called. This is however done only if the UI is installed to the component and only by some private methods.
The SwingDropTarget and TextDropTargetListener are also not accessible.

This issue is fixed in jdk 1.6.0 already.

So far so good, I could workaround this issue by getting the original DropHandler from the component, setting the new
transfer handler and setting the original (properly initialized) drop handler back.

However after that JEditorPane.setDocument() is called which calls to QuietEditorPane.setDocument() which then test if
the current transfer handler is of its own delegating instance (DelegatingTransferHandler). If it is not (which is our
case since we previously set the instance to the HTMLTransferHandler) then it wraps the instance and sets it to the
JComponent by setTransferHandler(). And we are back - the new DropHandler is created, but later not properly initialized
by adding the proper DropTargetListener.

So as I see it now, it doesn't seem to be easy to solve, maybe someone from editor familiar with all the stuff may help.
One more hacky option could be to wrap the HTMLTransferHandler by the QuietEditorPane.DelegatingTransferHandler directly
in the HTMLKit.install, but I these classes are private.

Any ideas?
Comment 11 Marek Fukala 2008-09-16 18:39:22 UTC
jsedek or mschovanek, could you please be so nice and try to test this issue on linux and windows?
Comment 12 Marek Fukala 2008-09-16 18:47:43 UTC
btw, ludo, did it work before 6.5?
Comment 13 Jindrich Sedek 2008-09-17 09:46:44 UTC
I'm able to reproduce the problem on Ubuntu jdk1.5 and it works well for jdk1.6.

I've also taken note that while moving mouse over editor pane having dragged some item from the palette, editor caret is
moved according to mouse cursor on jdk1.6, but it's not moved on jdk1.5
Comment 14 Marek Fukala 2008-09-17 10:04:06 UTC
Can you jindro please check it on older netbeans versions? 6.1 and 6.0? Thanks
Comment 15 Jindrich Sedek 2008-09-17 10:41:03 UTC
problem is not reproducible on 6.0 and 6.1 using jdk1.5
Comment 16 Marek Fukala 2008-09-22 16:17:40 UTC
Finally the problem looks like a regression of vita's change (issue #132669) to CloneableEditor and QuietEditorPane
introducing filtering of some swing events in some stage of the document loading. IMHO it would be better to remove the
filtering or filter only selected events since there might be more tricky issues like this one.

BTW, if the change would be too difficult and risky to 6.5 I can do a workaround that would work for all platforms and
jdks except windows on jdk 1.5
Comment 17 Marek Fukala 2008-09-22 16:17:46 UTC
Finally the problem looks like a regression of vita's change (issue #132669) to CloneableEditor and QuietEditorPane
introducing filtering of some swing events in some stage of the document loading. IMHO it would be better to remove the
filtering or filter only selected events since there might be more tricky issues like this one.

BTW, if the change would be too difficult and risky to 6.5 I can do a workaround that would work for all platforms and
jdks except windows on jdk 1.5
Comment 18 Vitezslav Stejskal 2008-09-29 08:54:39 UTC
Ok, I finally got to look into this.
Comment 19 Vitezslav Stejskal 2008-09-29 10:05:39 UTC
http://hg.netbeans.org/main/rev/0df8a0f00095
Comment 20 Quality Engineering 2008-09-29 18:39:28 UTC
Integrated into 'main-golden', will be available in build *200809291401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/0df8a0f00095
User: Vita Stejskal <vstejskal@netbeans.org>
Log: #143368: firing as many property changes as possible, but swallowing those that are expensive to handle