Re: Plugin - Creating Objects with other Properties

by alied » Thu Apr 21, 2011 6:50 pm

Still, there is something you can do without messing with the code.
in your Plugin constructor, get the Home and add a listener:

Code: Select all

getHome().addFurnitureListener(new CollectionListener<HomePieceOfFurniture>(){
  void collectionChanged(CollectionEvent<HomePieceOfFurniture> ev){
    //check whether it is a ADD action
    //get the newly added item (which should de a HomePieceOfFurniture)
    //here, either remove your listener (in which case you should not
    //use a anonymous listener like here)
    //or check whether it is your class or not
    //if it is your class, end(remember to add your listener if you
    //previously removed it)
    //otherwise, create your own object from the newly added HomePieceOfFurniture
    //add it to the Home
  }
}
Next, create a PluginAction which shows your properties dialog (which you might extend from com.eteks.sweethome3d.swing.HomeFurniturePanel if you are interesred in) iff the selected items(s) are of your class.

I hope this can hep you.