HW5: More questions


Subject: HW5: More questions
From: Kojarski Sergei (kojarski@ccs.neu.edu)
Date: Tue Nov 05 2002 - 19:40:19 EST


> One more detail: we add an aspect nature to a java nature project the first
> time we use the checker. Next time we open the platform, the project we'll
> have two natures, but in this case the RemoveAspect check box won't appear
> or will be disabled for the user. Or we should read the pesistant properties
> and see that WE ADDED the aspect nature (it wasn't there originally) and in
> this case the Check box will appear on our property page, right?
  Absolutely.

> But there
> is sth more - if the first time we didn't want to remove the aspect nature
> after we added, aspect nature becomes an integrated part of this project and
> there is no need to display the check box again, next time we open the
> platform, I am right ?
  Not completely.
  Properties are associated with the project, so, we can keep information
  about initial state (whether project had AspectJ nature before user
  first time set properties for the checker) of the project as long as
  project exists.
  From this point we always know whether to show "AspectJ nature
  removing" checkbox or not.

   And remember
  - we add AspectJ nature (if it's not in the project's
   natures list) as well as checker files when user CHANGES state of
   checker checkbox/radiobutton to "enabled" checker button and presses
   "OK"
   (CHANGES here means that value of the checkbox/radiobutton
   on "OK" event is different from the value it was when page was shown
   to the user (different from values we keep in the persistent storage)
   And, of course, after processing OK event we should resave properties
   in the storage accordingly to the current settings on the page)

  - we remove AspectJ nature as well as checker files when user CHANGES
    state of checker checkbox/radiobutton to "disabled" and presses "OK"
    IF "aspectJ nature removing" checkbox is set to "enabled" state.
    (of course, we don't want to allow user to change "aspectj nature
     removing" checkbox state if this project inherently is AspectJ
     project)

  Sergei.
>
>
>
>
>
> >
> >It's good you want to make sure.
> >
> > > We save user's preferences from the property page in the project
> >resource -
> > > there are 2 types of resource properties - session and persistant. The
> >way I
> > > undestand the difference between them:
> > >
> > > Session properties are kept during the lifetime of the resource (project
> >in
> > > our case). By project lifetime I mean between project is open and
> >project is
> > > closed. Persistant properties on the other hand are saved in an external
> > > file I guess and reused after the project is closed and reopen, right ?
> > My understanding is:
> > session properties are kept during one start-up - shutdown session of
> > the Platform.
> > persistent properties are kept through any platform start-up - shutdown
> >events. They are kept externally somewhere under your .workspace
> >directory.
> >
> > > If this is correct I think what we need are the session ones. If I
> > > understand correctly the problem, we don't need to keep anything after
> >the
> > > project is closed. But we need to keep the state of the project and I
> >think
> > > we should do this in session properties.
> > What exactly do you mean by project opening/closing?
> > Session properties will expire when you shutdown the Platform and it's
> >not really what we want. We need PERSISTENT properties. We don't want to
> >force user set all the checker properties on every start-up again and
> >again.
> >
> > >
> > > However you said we need to save information between start-ups which
> >implies
> > > persistant properties. I am not sure what kind of information is that.
> >You
> > > further say to check persistant properties storage for nulls in order to
> > > find out if this is the first time we open the property page. what is
> >the
> > > drawback of using session properties and the advantages of the
> >persistant
> > > in our case?
> > Let's imagine you keep the information in session properties.
> > you want to add checker to some Java nature project.
> > For the first time you check, whether your project has AspectJ nature.
> > It's not. So, you save this information to the session property and make
> > your "aspectj nature remove" checkbox enabled to the user.
> > While your platform is running - everything is fine!!!!
> > But when user shutdowns the Platform and then starts it again - your
> > extension now nothing about previous settings, and even don't know
> > whether the project was enriched with the checker.
> > So, when you go to the prop. page -> your code tests the project ->
> > founds AspectJ nature (from this point user will not be able any more
> > remove AspectJ nature from the project with your plugin). And of course,
> > no settings user made first time are stored - user can see only default
> > settings once again.
> > I hope it'll help you understand that we need to use persistent
> > properties.
> >
> > > There is sth else. Suppose the java project hasn't aspect nature and the
> > > Checker is enabled. We add aspect nature. When the checker is disabled
> >by
> > > the user we remove the aspect nature. Suppose that the user closes the
> > > project or exits from Eclipse before disabling the Checker. So the
> >aspect
> > > nature is saved with the project. Next time we open the project it will
> >have
> > > aspect nature and we won't remove it on disabling the Checker because
> > > "initially" it has aspect nature. Is that what will happen ?
> >
> > Exactly, with session properties. Not with persistent.
> >
> > Good luck,
> > Sergei.
> >
> >
> > >
> > >
> > >
> > >
> > > >you try to load saved information from persistent
> > > >resource (project) properties storage and it returns nulls.
> > >
> > >
> > > >
> > > > > 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
> > > > >
> > >
> > >
> > >
> > >
> > > _________________________________________________________________
> > > Get faster connections?- switch to MSN Internet Access!
> > > http://resourcecenter.msn.com/access/plans/default.asp
> > >
>
>
>
>
> _________________________________________________________________
> Broadband? Dial-up? Get reliable MSN Internet Access.
> http://resourcecenter.msn.com/access/plans/default.asp
>



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