1 18 19 package org.objectweb.jac.aspects.gui; 20 21 import org.aopalliance.intercept.ConstructorInvocation; 22 import org.aopalliance.intercept.MethodInvocation; 23 import org.apache.log4j.Logger; 24 import org.objectweb.jac.core.AspectComponent; 25 import org.objectweb.jac.core.Display; 26 import org.objectweb.jac.core.Interaction; 27 import org.objectweb.jac.core.Wrapper; 28 29 33 public class WaitWrapper extends Wrapper { 34 static Logger logger = Logger.getLogger("gui.wait"); 35 36 public WaitWrapper(AspectComponent ac) { 37 super(ac); 38 } 39 40 public Object pleaseWait(Interaction interaction) { 41 DialogView page = null; 42 CustomizedDisplay display = null; 43 Object result = null; 44 try { 45 if (GuiAC.isSlowOperation(interaction.method)) { 46 logger.debug("pleaseWait "+interaction); 47 DisplayContext context = 48 (DisplayContext)attr(GuiAC.DISPLAY_CONTEXT); 49 if (context!=null) { 50 display = context.getDisplay(); 51 page = 52 (DialogView)display.showRefreshMessage( 53 "Please wait", 54 "Please wait: "+interaction.method.getName()+" is running..."); 55 } else { 56 logger.error("pleaseWait: no display context available for "+ 57 interaction.method); 58 } 59 } 60 result = interaction.proceed(); 61 } finally { 62 if (page!=null) 63 page.waitForClose(); 64 } 65 return result; 66 } 67 68 public Object invoke(MethodInvocation invocation) throws Throwable { 69 return pleaseWait((Interaction)invocation); 70 } 71 72 public Object construct(ConstructorInvocation invocation) throws Throwable { 73 return pleaseWait((Interaction)invocation); 74 } 75 } 76 | Popular Tags |