Luxor Network: Luxor - Luxilla - Petra - Installer DeLux - Luxor Contrib - Luxor Forum - The Memphis Sun
The Memphis Sun Logo
The Luxor News Blog
« December 2003 | Main | February 2004 »

January 2004 Archives

AspectJ In Action: Weave In Your Own Luxor XUL Widget Attributes

R. Dale Asberry (of Judy project fame) writes in the mail titled "Example of how AOP can help":

While working with Installer DeLux, I ran into some difficulty when I wanted to add a new "feature" to XButton.

Currently, Xul.Attribute.DISABLED is only used for MenuItemDef and ToolBarButtonDef. So that I could disable the "Next" button on the accept license page, I originally subclassed XButton and ButtonDef. However, I was able to determine a simple AOP solution that not only worked for button, but all XUL components. The same technique can be used for setting color, background, border, font, name, and actions. This would eliminate programming errors by eliminating the need to repeat this code.

The pointcut details important OO events (method calls). The around() "advice" tells what should happen when the getJComponent() pointcut is matched. The last two java blocks "introduce" the initialized field and the initialize() method on the luxor.swing.AbstractComponent class.

package luxor.swing;

import javax.swing.JComponent;

import luxor.core.Xul;

public privileged aspect ComponentFunctionalAspect
	private pointcut getJComponent(AbstractComponent pComp):
		execution(JComponent AbstractComponent+.getJComponent()) &&
		target(pComp) &&

	JComponent around(AbstractComponent pComp): getJComponent(pComp)
		JComponent lGuiComp = proceed(pComp);
		return lGuiComp;

	private boolean AbstractComponent.initialized = false;

	public void AbstractComponent.initialize(JComponent pGuiComp)
		initialized = true;
posted by Gerald Bauer on January 03, 2004 | Add Your Comments (0)
Hosted by SourceForge SourceForge Logo For questions related to the use of Luxor, please consult our web pages. If that fails, the luxor-xul-user mailinglist might help.
Please send comments on our web pages and the development of Luxor to our public luxor-xul-develop mailinglist.
Maintained by Luxor Team
Copyright © 2001, 2002, 2003, 2004, 2005 Luxor Foundation