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 210416 - editor supports are initialized when context menu for file is shown or select file in explorer view
Summary: editor supports are initialized when context menu for file is shown or select...
Status: RESOLVED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.2
Hardware: All All
: P3 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2012-03-30 10:22 UTC by Vladimir Voskresensky
Modified: 2012-08-09 13:40 UTC (History)
3 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 Vladimir Voskresensky 2012-03-30 10:22:52 UTC
if user right clicks on cnd file => popup menu is displayed, but it force creation of editor supports because of lookups of OpenCookie and EditCookie. It can be improved
Comment 1 Vladimir Voskresensky 2012-03-30 10:23:48 UTC
side effect is: if project is under vcs which manipulates writable states of files popup menu can be blocked by vcs checks
Comment 2 Alexander Simon 2012-03-30 11:39:24 UTC
CES is initialized if node gets focus in method:
EditorContextDispatcher.updateCurrentOpenedPane() line 663:
if (ec.getDocument() == null &&
   !currentEditorCookie.prepareDocument().isFinished() &&
   (ec instanceof EditorCookie.Observable)) {
Comment 3 Vladimir Voskresensky 2012-04-02 10:21:07 UTC
currentEditorCookie.prepareDocument().isFinished() is commented out
Comment 4 Vladimir Voskresensky 2012-04-02 10:39:41 UTC
we can hardly do anything on cnd side.

ProxyLookup does initialization when compare allItems during collectFires.
Jarda, is it expected behavior that ProxyLookup instantiate everything? In that case not clear benefits of InstanceContent.Convertor
Comment 5 Vladimir Voskresensky 2012-04-02 10:41:20 UTC
I've added trace 

java.lang.Exception: called instantiation for org.netbeans.modules.cnd.source.HDataObject@1eea38[/home/vvoskres/NetBeansProjects/Quote_1/cpu.h@5529c656:13516d7]
        at org.netbeans.modules.cnd.source.CppEditorSupportProvider$CppEditorSupportFactory.convert(CppEditorSupportProvider.java:83)
        at org.netbeans.modules.cnd.source.CppEditorSupportProvider$CppEditorSupportFactory.convert(CppEditorSupportProvider.java:73)
        at org.openide.util.lookup.InstanceContent$ConvertingItem.getInstance(InstanceContent.java:316)
        at org.openide.explorer.DefaultEMLookup$NoNodeLookup$ExclusionResult.allItems(DefaultEMLookup.java:258)
        at org.openide.util.lookup.ProxyLookup$LazyCollection.computeSingleResult(ProxyLookup.java:1252)
        at org.openide.util.lookup.ProxyLookup$LazyCollection.computeDelegate(ProxyLookup.java:1083)
        at org.openide.util.lookup.ProxyLookup$LazyCollection.delegate(ProxyLookup.java:1050)
        at org.openide.util.lookup.ProxyLookup$LazyCollection.delegate(ProxyLookup.java:1033)
        at org.openide.util.lookup.ProxyLookup$LazyList.delegateList(ProxyLookup.java:1274)
        at org.openide.util.lookup.ProxyLookup$LazyList.listIterator(ProxyLookup.java:1299)
        at java.util.AbstractList.equals(AbstractList.java:503)
        at java.util.Collections$UnmodifiableList.equals(Collections.java:1151)
        at org.openide.util.lookup.ProxyLookup$R.collectFires(ProxyLookup.java:592)
        at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:170)
        at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:126)
        at org.openide.explorer.DefaultEMLookup.updateLookups(DefaultEMLookup.java:134)
        at org.openide.explorer.DefaultEMLookup.propertyChange(DefaultEMLookup.java:166)
        at org.openide.util.WeakListenerImpl$PropertyChange.propertyChange(WeakListenerImpl.java:196)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
        at org.openide.explorer.ExplorerManager$2.run(ExplorerManager.java:869)
        at org.openide.util.Mutex.doEvent(Mutex.java:1341)
        at org.openide.util.Mutex.readAccess(Mutex.java:348)
        at org.openide.explorer.ExplorerManager.fireInAWT(ExplorerManager.java:866)
        at org.openide.explorer.ExplorerManager$1AtomicSetSelectedNodes.fire(ExplorerManager.java:286)
        at org.openide.explorer.ExplorerManager.setSelectedNodes(ExplorerManager.java:297)
        at org.openide.explorer.ExplorerManager$1SetExploredContextAndSelection.run(ExplorerManager.java:391)
        at org.openide.util.Mutex.readAccess(Mutex.java:365)
        at org.openide.util.Mutex$1R.run(Mutex.java:1307)
        at org.openide.util.Mutex.doWrapperAccess(Mutex.java:1324)
        at org.openide.util.Mutex.readAccess(Mutex.java:354)
        at org.openide.explorer.ExplorerManager.setExploredContextAndSelection(ExplorerManager.java:412)
        at org.openide.explorer.view.BeanTreeView.selectionChanged(BeanTreeView.java:149)
        at org.openide.explorer.view.TreeView.callSelectionChanged(TreeView.java:849)
        at org.openide.explorer.view.TreeView$TreePropertyListener.run(TreeView.java:1491)
        at org.openide.util.Mutex$1Exec.run(Mutex.java:1244)
        at org.openide.nodes.Children$ProjectManagerDeadlockDetector.execute(Children.java:1920)
        at org.openide.util.Mutex.postRequest(Mutex.java:1250)
        at org.openide.util.Mutex.postRequest(Mutex.java:1213)
        at org.openide.util.Mutex.postReadRequest(Mutex.java:568)
        at org.openide.explorer.view.TreeView$TreePropertyListener.valueChanged(TreeView.java:1460)
        at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:629)
        at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1078)
        at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:287)
        at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(DefaultTreeSelectionModel.java:170)
        at javax.swing.JTree.setSelectionPath(JTree.java:1598)
        at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(BasicTreeUI.java:2311)
        at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(BasicTreeUI.java:3520)
        at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressedDND(BasicTreeUI.java:3497)
        at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(BasicTreeUI.java:3456)
        at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
        at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
        at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
        at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
        at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
        at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
        at java.awt.Component.processMouseEvent(Component.java:6285)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6053)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4651)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4481)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4235)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4481)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
        at java.awt.EventQueue.access$000(EventQueue.java:84)
        at java.awt.EventQueue$1.run(EventQueue.java:602)
        at java.awt.EventQueue$1.run(EventQueue.java:600)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
        at java.awt.EventQueue$2.run(EventQueue.java:616)
        at java.awt.EventQueue$2.run(EventQueue.java:614)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
        at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Comment 6 Jaroslav Tulach 2012-04-18 15:26:27 UTC
explorer.DefaultEMLookup$NoNodeLookup$ExclusionResult.allItems instantiates your instances.
Comment 7 Jaroslav Tulach 2012-04-18 16:24:23 UTC
ergonomics#0a362f23c9f5
Comment 8 Vladimir Voskresensky 2012-04-18 16:32:38 UTC
Jarda, thank you very much, now InstanceContent.Convertor should make sense again.
Comment 9 Quality Engineering 2012-04-26 10:37:17 UTC
Integrated into 'main-golden', will be available in build *201204260400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/0a362f23c9f5
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #210416: Improving behavior by removing propriatary lookup and using standard implementation
Comment 10 Vladimir Voskresensky 2012-05-29 21:26:04 UTC
can not verify fix.
change of selection in explorer view still instantiate full editor support.
 
"AWT-EventQueue-1"
org.netbeans.modules.cnd.source.CppEditorSupportProvider$CppEditorSupportFactory.convert(CppEditorSupportProvider.java:90)
org.netbeans.modules.cnd.source.CppEditorSupportProvider$CppEditorSupportFactory.convert(CppEditorSupportProvider.java:73)
org.openide.util.lookup.InstanceContent$ConvertingItem.getInstance(InstanceContent.java:316)
org.openide.util.lookup.AbstractLookup$R.allInstances(AbstractLookup.java:1044)
org.openide.util.lookup.AbstractLookup$R.allInstances(AbstractLookup.java:1024)
org.openide.nodes.FilterNode$FilterLookup$ProxyResult.allInstances(FilterNode.java:2225)
org.openide.nodes.FilterNode$FilterLookup$ProxyResult.allInstances(FilterNode.java:2225)
org.openide.util.lookup.ProxyLookup$LazyCollection.computeSingleResult(ProxyLookup.java:1249)
org.openide.util.lookup.ProxyLookup$LazyCollection.computeDelegate(ProxyLookup.java:1091)
org.openide.util.lookup.ProxyLookup$LazyCollection.delegate(ProxyLookup.java:1058)
org.openide.util.lookup.ProxyLookup$LazyCollection.delegate(ProxyLookup.java:1041)
org.openide.util.lookup.ProxyLookup$LazyCollection.size(ProxyLookup.java:1122)
org.openide.explorer.DefaultEMLookup$NoNodeLookup$ExclusionResult.allInstances(DefaultEMLookup.java:237)
org.openide.util.lookup.ProxyLookup$LazyCollection.computeSingleResult(ProxyLookup.java:1249)
org.openide.util.lookup.ProxyLookup$LazyCollection.computeDelegate(ProxyLookup.java:1091)
org.openide.util.lookup.ProxyLookup$LazyCollection.delegate(ProxyLookup.java:1058)
org.openide.util.lookup.ProxyLookup$LazyCollection.delegate(ProxyLookup.java:1041)
org.openide.util.lookup.ProxyLookup$LazyCollection.size(ProxyLookup.java:1122)
org.openide.util.lookup.ExcludingLookup$R.openCol(ExcludingLookup.java:334)
org.openide.util.lookup.ExcludingLookup$R.allInstances(ExcludingLookup.java:326)
org.openide.util.lookup.ProxyLookup$LazyCollection.computeSingleResult(ProxyLookup.java:1249)
org.openide.util.lookup.ProxyLookup$LazyCollection.computeDelegate(ProxyLookup.java:1091)
org.openide.util.lookup.ProxyLookup$LazyCollection.delegate(ProxyLookup.java:1058)
org.openide.util.lookup.ProxyLookup$LazyCollection.delegate(ProxyLookup.java:1041)
org.openide.util.lookup.ProxyLookup$LazyCollection.size(ProxyLookup.java:1122)
org.netbeans.spi.debugger.ui.EditorContextDispatcher$EditorLookupListener.lookupChanged(EditorContextDispatcher.java:588)
org.netbeans.spi.debugger.ui.EditorContextDispatcher$EditorLookupListener.resultChanged(EditorContextDispatcher.java:547)
org.openide.util.lookup.SimpleProxyLookup.checkLookup(SimpleProxyLookup.java:114)
org.openide.util.lookup.SimpleProxyLookup.lookup(SimpleProxyLookup.java:156)
org.netbeans.modules.openide.windows.GlobalActionContextImpl.blickActionMapImpl(GlobalActionContextImpl.java:121)
org.netbeans.modules.openide.windows.GlobalActionContextImpl.blickActionMap(GlobalActionContextImpl.java:97)
org.netbeans.modules.openide.windows.GlobalActionContextImpl.propertyChange(GlobalActionContextImpl.java:182)
java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:347)
java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
java.awt.KeyboardFocusManager.firePropertyChange(KeyboardFocusManager.java:1389)
java.awt.KeyboardFocusManager.setGlobalPermanentFocusOwner(KeyboardFocusManager.java:687)
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:546)
java.awt.Component.dispatchEventImpl(Component.java:4523)
java.awt.Container.dispatchEventImpl(Container.java:2099)
java.awt.Component.dispatchEvent(Component.java:4481)
java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
java.awt.EventQueue.access$000(EventQueue.java:84)
java.awt.EventQueue$1.run(EventQueue.java:602)
java.awt.EventQueue$1.run(EventQueue.java:600)
java.security.AccessController.doPrivileged(AccessController.java)
java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
java.awt.EventQueue$2.run(EventQueue.java:616)
java.awt.EventQueue$2.run(EventQueue.java:614)
java.security.AccessController.doPrivileged(AccessController.java)
java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Comment 11 Jaroslav Tulach 2012-06-07 13:46:05 UTC
The code goes from 

org.netbeans.spi.debugger.ui.EditorContextDispatcher$EditorLookupListener.lookupChanged(EditorContextDispatcher.java:588)
org.netbeans.spi.debugger.ui.EditorContextDispatcher$EditorLookupListener.resultChanged(EditorContextDispatcher.java:547)

so you need to talk to debugger guys. On the other hand, I don't think this is avoidable.
Comment 12 Martin Entlicher 2012-06-12 15:57:00 UTC
I do not think I can do anything with this.
I need to listen on Utilities.actionsGlobalContext().lookupResult(EditorCookie.class) and then track the current EditorCookie.
Perhaps the problem is that Window system puts an uninitialized EditorCookie into the global lookup?
Comment 13 Stanislav Aubrecht 2012-06-13 13:55:45 UTC
Window system doesn't insert any cookies into the global Lookup.
I can also see the lookup events in the debugger has been scheduled out of EDT so it shouldn't be blocking the UI anymore.
Comment 14 Jaroslav Tulach 2012-06-14 05:30:21 UTC
As far as I know the debugger cares only about opened editors. It tracks them by asking for EditorCookie and getOpenedPanes(). Right?

The problem, as seen in CND data objects, is that just by selecting a node in explorer the debugger asks for EditorCookie, just to find out the editor is not opened.

I don't see how to eliminate this in current state of our APIs. It can be done, if it is the highest priority, but not for 7.2.
Comment 15 Vladimir Voskresensky 2012-06-14 06:00:01 UTC
(In reply to comment #14)> 
> I don't see how to eliminate this in current state of our APIs. It can be done,
> if it is the highest priority, but not for 7.2.
EditorRegistry and it's listeners gives what they need
Comment 16 Martin Entlicher 2012-06-14 12:05:05 UTC
EditorRegistry might be a good hint. I'll try to rewrite the EditorContextDispatcher to use it instead of the lookup listener.
Comment 17 Martin Entlicher 2012-06-18 14:30:15 UTC
I've changed the code to use EditorRegistry. changeset:   224661:20c5a9fd4d71
http://hg.netbeans.org/main/rev/20c5a9fd4d71
Comment 18 Quality Engineering 2012-06-20 04:37:51 UTC
Integrated into 'main-golden', will be available in build *201206200001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/20c5a9fd4d71
User: mentlicher@netbeans.org
Log: #210416: Use EditorRegistry to track currently opened and last focused editor.
Comment 19 Martin Entlicher 2012-08-09 13:40:29 UTC
FYI: This fix has caused regression issue #216601.