1 26 package org.objectweb.openccm.explorer.Deployment; 27 28 import java.net.URL ; 29 30 import javax.swing.ImageIcon ; 31 32 import org.objectweb.util.explorer.api.IconProvider; 33 import org.omg.Components.Deployment.Assembly; 34 35 42 public class AssemblyIcon 43 implements IconProvider 44 { 45 46 52 53 protected ImageIcon assemblyBuilt_, assemblyNotBuilt_; 54 55 61 64 public AssemblyIcon() 65 { 66 assemblyBuilt_ = createIcon("icons/assembly_built.png"); 67 assemblyNotBuilt_ = createIcon("icons/assembly_tear_down.png"); 68 } 69 70 76 protected Assembly getAssembly(Object obj){ 77 return (Assembly)obj; 78 } 79 80 81 protected static ImageIcon createIcon(String imageName) 82 { 83 if (imageName != null) { 84 URL urlFile = null; 85 urlFile = Thread.currentThread().getContextClassLoader().getResource(imageName); 86 if(urlFile==null){ 87 try { 88 urlFile = new URL (imageName); 89 } catch (java.net.MalformedURLException e) { 90 System.out.println(imageName + ": Malformed URL !"); 91 } 92 } 93 if(urlFile!=null){ 94 return new ImageIcon (urlFile); 95 } 96 } 97 return null; 98 } 99 100 106 110 public Object newIcon(Object object) 111 { 112 Assembly assembly = getAssembly(object); 113 org.omg.Components.Deployment.AssemblyState state = assembly.get_state(); 114 if(!state.equals(org.omg.Components.Deployment.AssemblyState.INACTIVE)) 115 return assemblyBuilt_; 116 else 117 return assemblyNotBuilt_; 118 } 119 120 } | Popular Tags |