/*
 * @(#) CustomizerImpl.java 1.0 97/7/18 
 * Copyright (c) 1997 Lawrence Rodrigues
 */
package vis.beans.customizers;
import java.io.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
//import java.util.*;
//import vis.util.*;
import java.lang.reflect.*;
import javax.swing.*;
import javax.swing.event.*;

 /** CustomizerImpl Class
   * @version 1.0  18 jul 1997
   * @author Lawrence Rodrigues
   **/
  abstract public class CustomizerImpl extends JPanel implements Customizer{ 
     public Object bean;
     public  PropertyChangeSupport pcs;
     public String title = "Customizer";
    
     /** This method is called by the builder tool to pass the handle to the
       * target bean. 
       * @param bnObj the target bean.
       */
     public void setObject(Object bnObj){
        bean = bnObj;
        pcs = new PropertyChangeSupport(bean);
        createGUI();
     }

     public void setTitle(String title){
        this.title = title;
     }
     public String getTitle(){
        return title;
     }
     /**
       * This method is overriden so as to set the customizer title.
       */
     public void addNotify(){
        super.addNotify();
        Component cmp = getParent();
        if(cmp instanceof Dialog){ 
           ((Dialog)cmp).setTitle(title);
        }
        if(cmp instanceof JFrame){ 
           ((JFrame)cmp).setTitle(title);
        }
        if(cmp instanceof JDialog){ 
           ((JDialog)cmp).setTitle(title);
        }
     }

     /** Adds property change event listeners
       * @param the PropertyChangeListener
       */
     public void addPropertyChangeListener(PropertyChangeListener p){
        //Delegate the event firing job to pcs.
        pcs.addPropertyChangeListener(p);
     }
     /** Removes property change listeners
       * @param the PropertyChangeListener
       */
     public void removePropertyChangeListener(PropertyChangeListener p){
        pcs.removePropertyChangeListener(p);
     }
     /**
       * All the subclasses have to implement this method.
       */
     abstract protected void createGUI();
   
   }


