Features

Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Help  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 3
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 2094 times and has 2 replies Next Thread
enkonyito
Advanced Member
Member's Avatar


Joined: May 28, 2015
Post Count: 164
Status: Offline
Reply to this Post  Reply with Quote 
Add a new home property to a change listener

The setProperty method allow to set a new property associated with a home.
But can this property be taken into account by the addPropertyChangeListener method without returning an IllegalArgumentException if you use valueOf (String name)?

With this code:
this.home.addPropertyChangeListener(Home.Property.valueOf(ENHANCED_EXTERNAL_BRIGHTNESS),
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
isEnhancedExternalBrightness = Boolean.parseBoolean(home.getProperty(ENHANCED_EXTERNAL_BRIGHTNESS));
externalBrightnessEnabledCheckBox.setSelected(isEnhancedExternalBrightness);
}
});

I have this error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: No enum constant com.eteks.sweethome3d.model.Home.Property.enhancedExternalBrightness

----------------------------------------
EnkoNyito gallery
[Jun 7, 2017 2:15:35 AM] Show Printable Version of Post    View Member Profile    Send Private Message    https://sites.google.com/site/enkonyitogallery/ [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 5837
Status: Offline
Reply to this Post  Reply with Quote 
Re: Add a new home property to a change listener

The method valueOf of an enum takes into account only values of the enum that exist.
The main problem comes from the fact that enums are final, and using enums for these properties is actually a wrong idea I had sad
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Jun 7, 2017 10:51:44 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest    http://www.eteks.com [Link] Report threatening or abusive post: please login first  Go to top 
enkonyito
Advanced Member
Member's Avatar


Joined: May 28, 2015
Post Count: 164
Status: Offline
Reply to this Post  Reply with Quote 
Re: Add a new home property to a change listener

I wanted to bind the enhance external brightness option of the photo panel to the video panel.
The alternative would be an implicit selection from the photo panel only.

The main problem comes from the fact that enums are final, and using enums for these properties is actually a wrong idea I had sad
I do not know if other developers needed to add a new home property to existing ones but if there is a solution for it to be possible without too much changing the source code, why not?
----------------------------------------
EnkoNyito gallery
[Jun 7, 2017 8:29:22 PM] Show Printable Version of Post    View Member Profile    Send Private Message    https://sites.google.com/site/enkonyitogallery/ [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

    Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads
   
© Copyright 2006-2017 eTeks - All rights reserved