1 17 18 package org.objectweb.jac.aspects.gui; 19 20 import java.net.MalformedURLException ; 21 import java.net.URL ; 22 import org.apache.log4j.Logger; 23 import org.objectweb.jac.core.Wrappee; 24 import org.objectweb.jac.core.Wrapping; 25 import org.objectweb.jac.core.rtti.ClassRepository; 26 import org.objectweb.jac.core.rtti.CollectionItem; 27 import org.objectweb.jac.core.rtti.FieldItem; 28 import org.objectweb.jac.core.rtti.MethodItem; 29 30 31 35 36 public class Utils { 37 static Logger logger = Logger.getLogger("gui"); 38 39 42 public static URL stringToURL(String string) { 43 if (string.equals("")) { 44 return null; 45 } 46 if (string.indexOf(":")==-1) { 47 string = "file:/"+string; 48 } 49 50 try { 51 return new URL (string); 52 } catch (MalformedURLException e) { 53 logger.warn("Malfromed URL: "+string); 54 return null; 55 } 56 57 } 58 59 60 66 public static void registerObject(Object object, ObjectUpdate client) { 67 if (object instanceof Wrappee) { 68 Wrapping.invokeRoleMethod((Wrappee)object, 69 ViewControlWrapper.class,"registerObject", 70 new Object [] {client,null}); 71 } 72 } 73 74 81 public static void registerObject(Object object, 82 ObjectUpdate client, 83 Object param) { 84 if (object instanceof Wrappee) { 85 Wrapping.invokeRoleMethod((Wrappee)object, 86 ViewControlWrapper.class,"registerObject", 87 new Object [] {client,param}); 88 } 89 } 90 91 98 public static void registerField(Object object, FieldItem field, 99 FieldUpdate client) { 100 if (object instanceof Wrappee && field!=null) { 101 Wrapping.invokeRoleMethod((Wrappee)object, 102 ViewControlWrapper.class,"registerField", 103 new Object [] {field,client,null}); 104 } 105 } 106 107 115 public static void registerField(Object object, FieldItem field, 116 FieldUpdate client, 117 Object param) { 118 if (object instanceof Wrappee && field!=null) { 119 Wrapping.invokeRoleMethod((Wrappee)object, 120 ViewControlWrapper.class,"registerField", 121 new Object [] {field,client,param}); 122 } 123 } 124 125 132 public static void registerCollection(Object object, 133 CollectionItem collection, 134 CollectionUpdate client) { 135 if (object instanceof Wrappee && collection!=null) { 136 Wrapping.invokeRoleMethod((Wrappee)object, 137 ViewControlWrapper.class,"registerCollection", 138 new Object [] {collection,client,null}); 139 } 140 } 141 142 143 150 public static void registerCollection(Object object, 151 String collectionName, 152 CollectionUpdate client) { 153 CollectionItem collection = 154 ClassRepository.get().getClass(object).getCollection(collectionName); 155 registerCollection(object,collection,client); 156 } 157 158 165 public static void registerMethod(Object object, MethodItem method, 166 MethodUpdate client) { 167 if ((object instanceof Wrappee || object==null) && method!=null) { 168 Wrapping.invokeRoleMethod((Wrappee)object, 169 ViewControlWrapper.class,"registerMethod", 170 new Object [] {method,client,null}); 171 } 172 } 173 174 183 public static void registerMethod(Object object, MethodItem method, 184 MethodUpdate client, Object param) { 185 if ((object instanceof Wrappee || object==null )&& method!=null) { 186 Wrapping.invokeRoleMethod((Wrappee)object,method.getClassItem(), 187 ViewControlWrapper.class,"registerMethod", 188 new Object [] {method,client,param}); 189 } 190 } 191 192 200 public static void registerCollection(Object object, 201 CollectionItem collection, 202 CollectionUpdate client, 203 Object param) { 204 if (object instanceof Wrappee && collection!=null) { 205 Wrapping.invokeRoleMethod((Wrappee)object, 206 ViewControlWrapper.class,"registerCollection", 207 new Object [] {collection,client,param}); 208 } 209 } 210 211 214 public static void unregisterObject(Object object, ObjectUpdate client) { 215 if (object instanceof Wrappee) { 216 Wrapping.invokeRoleMethod((Wrappee)object, 217 ViewControlWrapper.class,"unregisterObject", 218 new Object [] {client}); 219 } 220 } 221 222 229 public static void unregisterField(Object object, FieldItem field, 230 FieldUpdate client) { 231 if (object instanceof Wrappee && field!=null) { 232 Wrapping.invokeRoleMethod((Wrappee)object, 233 ViewControlWrapper.class,"unregisterField", 234 new Object [] {field,client}); 235 } 236 } 237 238 245 public static void unregisterCollection(Object object, 246 CollectionItem collection, 247 CollectionUpdate client) { 248 if (object instanceof Wrappee && collection!=null) { 249 Wrapping.invokeRoleMethod((Wrappee)object, 250 ViewControlWrapper.class,"unregisterCollection", 251 new Object [] {collection,client}); 252 } 253 } 254 255 262 public static void unregisterCollection(Object object, 263 String collectionName, 264 CollectionUpdate client) { 265 CollectionItem collection = 266 ClassRepository.get().getClass(object).getCollection(collectionName); 267 unregisterCollection(object,collection,client); 268 } 269 270 277 public static void unregisterMethod(Object object, MethodItem method, 278 MethodUpdate client) { 279 if (object instanceof Wrappee && method!=null) { 280 Wrapping.invokeRoleMethod((Wrappee)object,method.getClassItem(), 281 ViewControlWrapper.class,"unregisterMethod", 282 new Object [] {method,client}); 283 } 284 } 285 286 292 public static void unregister(Object object, CollectionUpdate client) { 293 if (object instanceof Wrappee) { 294 Wrapping.invokeRoleMethod((Wrappee)object, 295 ViewControlWrapper.class,"unregister", 296 new Object [] {client}); 297 } 298 } 299 300 } 301 302 | Popular Tags |