1 26 27 package org.objectweb.util.browser.core.panel; 28 29 30 import java.util.Iterator ; 31 import java.util.Vector ; 32 33 import org.objectweb.util.browser.api.Panel; 34 import org.objectweb.util.browser.core.api.PanelFactory; 35 36 44 public class DefaultPanelFactory 45 implements PanelFactory { 46 47 48 protected Class class_ = null; 49 50 51 protected boolean inheritTypePanel_ = false; 52 53 protected Vector subPanels_ = new Vector (); 54 55 protected Panel createPanel(Object object){ 56 if (class_ != null) { 57 try { 58 return (Panel) class_.newInstance(); 59 } catch (java.lang.InstantiationException e) { 60 System.out.println(class_.getName() + " : Instanciation exception"); 61 } catch (java.lang.IllegalAccessException e) { 62 System.out.println(class_.getName() + " : Illegal access exception"); 63 } 64 } 65 return null; 66 } 67 68 73 public Panel newPanel(Object object) { 74 if (subPanels_.size()>0){ 75 DefaultCompositePanel compositePanel = new DefaultCompositePanel(); 76 compositePanel.add(createPanel(object)); 77 Iterator it = subPanels_.iterator(); 78 while(it.hasNext()){ 79 compositePanel.add(((PanelFactory)it.next()).newPanel(object)); 80 } 81 return compositePanel; 82 } else { 83 return createPanel(object); 84 } 85 } 86 87 92 public void setClassName(Class theClass) { 93 class_ = theClass; 94 } 95 96 100 public void setInheritTypePanel(boolean inheritTypePanel){ 101 inheritTypePanel_ = inheritTypePanel; 102 } 103 104 107 public boolean inheritTypePanel(){ 108 return inheritTypePanel_; 109 } 110 111 115 public void addInheritPanelFactory(PanelFactory panelFactory){ 116 subPanels_.add(panelFactory); 117 } 118 } 119 | Popular Tags |