NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Reset Windows calls componentOpened a second time

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
billooms



Joined: 24 Oct 2009
Posts: 51

PostPosted: Sun Mar 25, 2012 8:05 pm    Post subject: Reset Windows calls componentOpened a second time Reply with quote

I have a TopComponent in the editor mode. I generally add all my propertyChangeListeners in the componentOpened method and removePropertyChangeListeners in the componentClosed method.

The problem comes when a user does a "Windows" -> "Reset Windows". Something causes the componentOpened method to be called again so that now I get a second propertyChangeListener attached. When I fire a propertyChangeEvent, it gets handled twice (which is not what I want).

This only seems to be a problem with TopComponents in the editor mode. Another TopComponent in the properties mode will behave differently -- "Reset Windows" calls componentClosed first then componentOpened is called.

This is easily demonstrated:
Create a new NetBeans Platform Application
Add a module
Add a Window to the module in the editor mode and open on application start
Put print statements in the componentOpened and componentClosed methods (so that you can see when they are called).
Run the application -- you'll see that componentOpened was called when the program was launched. Then do a "Reset Windows" and you'll see that componentOpened was called again without having called componentClosed.

Is this a bug? Why should TopComponents in different modes behave differently with regard to "Reset Windows"?

How can I determine if there are already propertyChangeListeners attached to the TopComponent so that within the componentOpened method I can avoid attaching a second time?

I'm running on NetBeans 7.1 with all updates as of this writing, Mac OSX 10.6.8 (also with all latest updates) on a Mac Pro 2.66GHz Quad-Core Xeon. Java is 1.6.0_29-b11-402.jdk.
Back to top
Stanislav Aubrecht
Posted via mailing list.





PostPosted: Thu Mar 29, 2012 9:14 am    Post subject: [platform-dev] Re: Reset Windows calls componentOpened a second time Reply with quote

On 25.3.2012 22:05, billooms wrote:
Quote:
I have a TopComponent in the editor mode. I generally add all my propertyChangeListeners in the componentOpened method and removePropertyChangeListeners in the componentClosed method.

The problem comes when a user does a "Windows" -> "Reset Windows". Something causes the componentOpened method to be called again so that now I get a second propertyChangeListener attached. When I fire a propertyChangeEvent, it gets handled twice (which is not what I want).

This only seems to be a problem with TopComponents in the editor mode. Another TopComponent in the properties mode will behave differently -- "Reset Windows" calls componentClosed first then componentOpened is called.

This is easily demonstrated:
Create a new NetBeans Platform Application
Add a module
Add a Window to the module in the editor mode and open on application start
Put print statements in the componentOpened and componentClosed methods (so that you can see when they are called).
Run the application -- you'll see that componentOpened was called when the program was launched. Then do a "Reset Windows" and you'll see that componentOpened was called again without having called componentClosed.

Is this a bug? Why should TopComponents in different modes behave differently with regard to "Reset Windows"?
It is a bug, please file it under 'platform/Window System' category, thanks!

Stan
Back to top
billooms



Joined: 24 Oct 2009
Posts: 51

PostPosted: Thu Mar 29, 2012 3:46 pm    Post subject: Reply with quote

Thanks for the feedback, Stan. I filed a Bug Report today.

It appears that this was reported a number of years ago (Bug 150151) and was resolved on 2008-12-12. It seems to have reared it's head again.
Back to top
Mvek



Joined: 31 Oct 2011
Posts: 43
Location: Prague, Czech Republic

PostPosted: Fri Apr 06, 2012 6:05 pm    Post subject: Reply with quote

And can someone confirm this bug: http://forums.netbeans.org/viewtopic.php?p=126519#126519 ? This might be related. I got problem while opening TC from TC in explorer mode, but without saying, where the new TC should be. It called componentOpened() after componentShowing(). Just moving the window while running the app. changed this behaviour.
Back to top
billooms



Joined: 24 Oct 2009
Posts: 51

PostPosted: Fri Apr 06, 2012 11:44 pm    Post subject: Reply with quote

Is sounds like a different bug. However you confirm by checking one of the latest builds. The bug I reported has been fixed on one of the nightly builds. see the bug report for details:

http://netbeans.org/bugzilla/show_bug.cgi?id=210380
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo