In traditional AspectJ I would do something like below. I didn't get one 
working, but it was something like this.

after(String s) : call(javax.swing.JTextField.new(s)) && args(s) && 
if(s.equals("textField1") //find out where the JTextfield with text 
"textField1" is instantiated, and run the code below
{
    //code here (is there a technical term to call the code block in here?)
    undoService.addCallback(new ActionListener()
    {
           public void actionPerformed(ActionEvent ae)
          {
           undoService.addEdit(new UndoableEditDocumentCustom(textField));
           }
    });
}

The point is to find the JTextField with a starting text of "textField1", which 
is not a good way to identify the JTextField I want, but this is just for proof 
of concept purposes. Once the correct JTextField is found, execute the code. 
With annotations, would it be simple to add this code for a specific 
JComponent? Can the annotation go right on top of the JComponent instantiation 
code? Can the annotation do some extra processing to know if the JComponent is 
a JTextField or JButton so I can call specific code for both? Sorry if I am not 
perfectly clear, I am still really green.
________________________________________
From: [email protected] [[email protected]] On 
Behalf Of Ramnivas Laddad [[email protected]]
Sent: Wednesday, June 30, 2010 5:30 PM
To: [email protected]
Subject: Re: [aspectj-users] Question about @AspectJ and what it can do

Can you show what you intent to do with the traditional syntax? That will help 
in showing if and how it can be mapped to @AspectJ.

-Ramnivas

On Wed, Jun 30, 2010 at 1:47 PM, Kashtan, Daniel 
<[email protected]<mailto:[email protected]>> wrote:
Hey all,

I have AspectJ working real nice right now and I would like to see if @AspectJ 
can let me do those same things in a slicker fashion. I can illustrate want I 
am thinking about by showing my function:

undoService.addCallback(new ActionListener()
{
       public void actionPerformed(ActionEvent ae)
       {
       undoService.addEdit(new UndoableEditDocumentCustom(textField));
       }
});

Right now my actionPerformed is hard-wired to send my undoService that 
particular UndoableEdit for a JTextfield. I'd like to automate the process of 
adding these edits. Could I possibly add an annotation above my JComponents 
that would be able to call the code above based on the type of JComponent it 
is? I think I know how to do this in AspectJ, but I am having a hard time 
grasping how @AspectJ works, so any suggestions or pointers would be great :)

This e-mail and any files transmitted with it may be proprietary and are 
intended solely for the use of the individual or entity to whom they are 
addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely 
those of the author and do not necessarily represent those of ITT Corporation. 
The recipient should check this e-mail and any attachments for the presence of 
viruses. ITT accepts no liability for any damage caused by any virus 
transmitted by this e-mail.
_______________________________________________
aspectj-users mailing list
[email protected]<mailto:[email protected]>
https://dev.eclipse.org/mailman/listinfo/aspectj-users

_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to