1 28 29 package org.objectweb.util.browser.plugins.fractal.icon; 30 31 import javax.swing.Icon ; 32 33 import org.objectweb.fractal.api.Component; 34 import org.objectweb.fractal.api.NoSuchInterfaceException; 35 import org.objectweb.fractal.api.control.LifeCycleController; 36 import org.objectweb.fractal.api.control.SuperController; 37 import org.objectweb.util.browser.plugins.fractal.FcBrowser; 38 39 44 public class LifeCycleComponentIconProvider 45 extends InterfaceIconProvider 46 { 47 51 protected void loadFc(String name) { 52 getIcons().put(name, 53 new Icon [] {load("Fc"+name+"Started.png"), 54 load("Fc"+name+"Stopped.png")}); 55 } 56 57 58 public LifeCycleComponentIconProvider() { 59 super(); 60 loadFc("Primitive"); 61 loadFc("Composite"); 62 loadFc("Shared"); 63 } 64 65 71 76 protected Icon [] loadIcon(Component cpt) { 77 try { 78 SuperController sc = FcBrowser.getSuperController(cpt); 79 if (sc.getFcSuperComponents().length > 1) 80 return (Icon []) getIcons().get("Shared"); 81 } catch (NoSuchInterfaceException e) {} 82 try { 83 FcBrowser.getContentController(cpt); 84 return (Icon []) getIcons().get("Composite"); 85 } catch (NoSuchInterfaceException e) {} 86 return (Icon []) getIcons().get("Primitive"); 87 } 88 89 95 100 public Icon newIcon(Object object) { 101 Component ci = (Component)object; 102 Icon [] icons = loadIcon(ci); 103 if (icons == null) return null; 104 LifeCycleController lcc=null; 105 try { 106 lcc = FcBrowser.getLifeCycleController(ci); 107 } catch (NoSuchInterfaceException e) { 108 return icons[0]; 109 } 110 String status = lcc.getFcState(); 111 if (status.equals(LifeCycleController.STARTED)) 112 return icons[0]; 113 else if (status.equals(LifeCycleController.STOPPED)) 114 return icons[1]; 115 else 116 return null; 117 } 118 } | Popular Tags |