Saved property not taken into account correctly

This topic has been viewed 7211 times and has 4 replies
Thread status: Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Saved property not taken into account correctly

Post by enkonyito »

In a derived version of SH3D-6.1, I added a new CEILING_LIGHT_ENABLED room property.
Although it is saved in the Home.xml file after modifying the HomeXMLExporter.java file, only the default value is taken into account when opening a project.

I based on the methods related to the CEILING_VISIBLE room property but it seems that I missed something because the expected operation is not the same.
EnkoNyito
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Saved property not taken into account correctly

Post by Puybaret »

The additional attributes you save in a subclass of [font=courier new]HomeXMLExporter[/font] should be read in a subclass of [font=courier new]HomeXMLHandler[/font].
But why don't you manage your additional information with the methods [font=courier new]setProperty[/font] / [font=courier new]getProperty[/font] available on subclasses of HomeObject, like the [font=courier new]Room[/font] class? This would prevent you from subclassing classes which handle XML files.
Emmanuel Puybaret, Sweet Home 3D creator
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Re: Saved property not taken into account correctly

Post by enkonyito »

But why don't you manage your additional information with the methods [font=courier new]setProperty[/font] / [font=courier new]getProperty[/font] available on subclasses of HomeObject, like the [font=courier new]Room[/font] class? This would prevent you from subclassing classes which handle XML files.
Indeed, it's more practical!

Code: Select all

<room level='level0' areaVisible='true' areaXOffset='-130.0' areaYOffset='55.99997' floorColor='FF586178' ceilingVisible='false'>
  <point x='503.75' y='50.30641'/>
  <point x='503.75' y='426.80637'/>
  <point x='11.25' y='426.8065'/>
  <point x='11.25' y='50.30641'/>
</room>
<room level='level1' areaVisible='true' areaXOffset='-132.15613' areaYOffset='109.9032' floorVisible='false' floorColor='FF586178'>
  <property name='ceilingLightEnabled' value='true'/>
  <point x='503.8' y='50.3'/>
  <point x='503.8' y='426.8'/>
  <point x='11.2' y='426.8'/>
  <point x='11.2' y='50.3'/>
</room>
By selecting rooms of different state:
- with [font=courier new]NullableCheckBox[/font], I get the error

Code: Select all

Caused by: java.lang.NullPointerException
    at com.eteks.sweethome3d.viewcontroller.RoomController.setCeilingLightEnabled(RoomController.java:982)
    at com.eteks.sweethome3d.viewcontroller.RoomController.updateProperties(RoomController.java:420)
    at com.eteks.sweethome3d.viewcontroller.RoomController.<init>(RoomController.java:119)
    at com.eteks.sweethome3d.viewcontroller.PlanController.modifySelectedRooms(PlanController.java:1691)
- with [font=courier new]JCheckBox[/font] or by capturing the exception, the global state is not indicated (empty).
EnkoNyito
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Saved property not taken into account correctly

Post by Puybaret »

A NullableCheckBox instance isn't nullable by default. You should call [font=courier new]setNullable(true)[/font] to be able to call [font=courier new]setValue(null)[/font].
Just look in source code, there are plenty of examples.
Emmanuel Puybaret, Sweet Home 3D creator
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Re: Saved property not taken into account correctly

Post by enkonyito »

My mistake, by declaring the ceilingLightEnabled global variable in the [font=courier new]RoomController.java[/font] file I had used [font=courier new]boolean [/font] instead of [font=courier new]Boolean [/font]. [:(]

Thanks!
EnkoNyito
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest