Good Hw5 questions & answers.


Subject: Good Hw5 questions & answers.
From: Kojarski Sergei (kojarski@ccs.neu.edu)
Date: Tue Nov 05 2002 - 14:40:22 EST


> My LoD Property Page has now 2 radio buttons (enablle Checker and disable
> Checker) and one check box (Remove aspect nature from project on disabling).
> You said that our plugin is activated when:
>
> >Ok, the "enabling" of the plug-in code occurs when you
> >right-click-on-the-project->properties->select your prop. page->
> >activation.
>
> by "activation" I guess you mean clicking the OK button or Apply button,
> right?

 By activation I meant "loading plug-in Java code into Eclipse JVM" and
"calling createControl(Composite parent) method of your property page
class"
 Clicking OK button will call performOK() method of your property page
class.

> What exactly happens at this point? I know a method performOK or
> performApply is called so we should implement them. What I did is, for
> performOK I check if the project has an aspect nature, if not - I added and
> it works. Should I do this ONLY when the radio button EnableChecker is
> selected ? and respectively when DisableChecker is on , just do nothing when
> OK is pushed. Is that all for now?

You should use resources API to save information between start-ups and
load it each time you show prop. page on some particular resource
(project in our case)
 You see, you need to find out:

1. When your class was started first time on some particular project you
should save whether the project has AspectJ nature.
How to find out if your page is shown first time for selected project?
It happens, when you try to load saved information from persistent
resource (project) properties storage and it returns nulls. Then you just
need to see whether project has AspectJ nature AND SAVE THIS INFORMATION +
SAVE THE "DEFAULT SETTINGS" INFORMATION into project properties storage
(see resources API)
2. Set values of checkboxes/radiobuttons/whatever else accordingly to
values you obtain from properties you store along with your resource
(project).
3. comment -> if initially project had AspectJ nature -> we are not
allowed to withdraw it anyway -> your AspectJ checkbox MUST be
inaccessible to user and always has value "disabled" that means NOT TO
REMOVE AspectJ nature on disabling checker.

3. When perfomOK is called:
 1. See if EnableChecker has different value from what is stored.
    If yes - user changed EnableChecker value -> we need to perform some
    action.
 2.
   - If NEW EnableChecker has "enabled" state -> we need to add checker
into project -> add AspectJ nature if necessary + copy checker files into project
   - if NEW EnableChecker has "disabled" state -> delete checker files
from the project + look at the value of
     AspectJ nature removing checkbox.
     If it's enabled -> we remove AspectJ nature from the project
     otherwise do nothing about AspectJ nature.

that's it.

>
> For the remove aspect nature check box I understood that if the project
> didn't have aspect nature we add it but when the project is closed we must
> remove the aspect nature. On the other hand if the project had already
> aspect nature we don't remove it at closing project time. Is that the
> business logic behind these controls?

  Yes, but remove "closing project" with "disabling checker".

> Can you give me a hint on how to catch the moment when a project is closed.
> Now I know how to deal with natures and I am able to add/remove them to
> project but my changes are permanent. (saved in the .project file)What is
> the event I have to listen to when a project closes so I'll be able to
> remove a nature if necessary?

   It's not about closing project - it's only about "disabling" checker

> I was thinking about sth else that confuses me. We should add our Checker
> files to the project. Suppose the project has only a java nature and for now
> we don't want to use the checker - so we disable it and no aspect nature is
> added. When we try to build the project eclipse will use javac compiler but
> our aspect files will cause errors, am I right?

  Our files should be added ONLY when checker is enabled. And it always
comes along with adding AspectJ nature.

> Another situation - we add an aspect nature and now the project has two
> natures. When we build the project how eclipse knows which compiler to use -
> ajc or javac ? Are there some precedence rules in a sense that one nature
> dominates the other ?

   Go see AspectJ projectNature extension -> you'll see how it works.
   Don't worry about it. AspectJ nature extension will do this.

> thanks again for your effort
  No problem.

>
> rado
>
> > > I managed to add a "LoD checker properties" page. I was wondering what
> >the
> > > content of this page should be. For now I just added some Label. I can
> >add different widgets. I
> > > guess we should have some text fields where the user can input the
> >stable classes and configure
> > > the checker. But the checker as it is now (from hw4) doesn't allow an
> >user interaction. The
> > > stable classes (Stable pointcut) are hard-coded.
> >
> >It's not really necessary on this stage, I suppose.
> >Just create
> > 1. checkbox for enabling/disabling checker
> > 2. checkbox that allows user to remove AspectJ nature if possible &
> >checker turned off.
> >
> > > 1.So how can we congigure it using the properties page ?
> >
> > At this moment we don't need this.
> >
> > > You say the property page must appear only for Java projects. I
> > > implemented org.eclipse.ui.IWorkbenchPropertyPage by extending the
> >default
> > > implementation PropertyPage class but there is nothing in this class
> >about
> > > the project nature.
> >
> > See manifest file -> each extension to the propertyPage point can have
> >filter. Try to take a look at AspectJ plugin.xml. Good example how to set
> >nature filter.
> >
> > > 2.Should I define another extension to org.eclipse.team.core.repository
> > > then implement a repository provider and get an IProject resource and
> >then
> > > find its nature or there is another way to find what the project nature
> >is
> > > and if it's Java display the properties page? Or we just need to provide
> > > an implementation for the extension point
> > > org.eclipse.core.resources.natures ?
> >
> > We need only one extension to propertyPage point.
> > Use manifest file to filter on project natures,
> > and API to find out if project has AspectJ nature
> > in the code of your property page.
> >
> > > >From part2.
> > >
> > > 3. The code I have to add for part 2 should be again in the LoDChecker
> > > plugin, right ? We are not suposed to touch neither aspectj nor java
> >plugins, right ?
> >
> > Exactly.
> >
> > > We have to find out if the Java project has also an Aspect nature , and
> > > if not and the Lod Checker is enabled - add it.
> > >
> >
> > More on it: use resources API. Take a look at IProject interface.
> > Use IProject.getDescription() to obtain IProjectDescription.
> > Use IProjectDescription to get/set all the nature-relative information
> > (Don't forget to say IProject.setDescription(IDescription,null) after
> >you put new information into IProjectDescription object)
> >
> > > 4. How our plugin will be enabled and what is the extension point we
> >have
> > > to supply a behaviour for, in order to check for an aspect nature? What
> >extension point is
> > > activated when the plugin is enabled and when exactly the "enabling"
> >occurs ?
> >
> > Ok, the "enabling" of the plug-in code occurs when you
> >right-click-on-the-project->properties->select your prop. page->
> >activation.
> >See org.eclipse.ui.IWorkbenchProperyPage to find out what will happen in
> >your implementation class at this moment and any other events.
> > At this moment the Platform will call some method and inside this method
> > you can easily find out, for what resource (project) this page is shown.
> > Having the project, you can easily find all the natures it has and
> >add/remove some of them (see above)
> >
> >
> > > 5. Should we use repository provider and provide an extesion to
> > > org.eclipse.team.core.repository extension point in order to get to the
> >IProject object and make the
> > > appropiate check for an aspect nature
> >
> > Absolutely not.
> > Use (IProject)IWorkbenchPropertyPage.getElement() -> it'll return you
> >selected resource, atually, the project.
> >
> >
> > > 6. last question - you said in class we have to copy the checker files
> > > into every java project we want to check for LoD violations. Why we need
> >the Lod.jar (this is my jar
> > > containing all the checker files)
> >
> > Actually, you can not to copy but just add LoD.jar to classpath of your
> >project -> compile ->it should work.
> > BUT, in the future we'll need to set Stable&GlobalPreffered, that is
> >done by rewriting java source code & can be unique for each project ->
> > it's better to copy java files from your plugin directory to project
> > and change source code correspondingly to user's properties for
> >Stable&Globalpreffered.
> >
> > Use resource API, org.eclipse.core.runtime.Plugin to find out how to
> >find file in your plugin dir and copy into the project +
> >see JDT api to find out how to tell Eclipse the file you copied is java
> >source file.
> >
> >Hope it'll help,
> >
> >Sergei
>
>
>
>
> _________________________________________________________________
> Get a speedy connection with MSN Broadband.  Join now!
> http://resourcecenter.msn.com/access/plans/freeactivation.asp
>



This archive was generated by hypermail 2b28 : Tue Nov 05 2002 - 14:40:28 EST