Bug 109513 - Project Specific Code Templates are not persisted across sessions
Summary: Project Specific Code Templates are not persisted across sessions
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: JDT-Text-Inbox CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-14 12:04 EDT by Richard Kulp CLA Friend
Modified: 2005-09-26 05:33 EDT (History)
3 users (show)

See Also:


Attachments
patch on ProjectTemplateStore (1.38 KB, patch)
2005-09-15 06:14 EDT, Martin Aeschlimann CLA Friend
no flags Details | Diff
patch for TemplateStore (1.09 KB, patch)
2005-09-15 06:25 EDT, Martin Aeschlimann CLA Friend
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Kulp CLA Friend 2005-09-14 12:04:47 EDT
I tried changing the Code templates for a project. I enabled "Project Specific
Settings" and changed the method template. It worked for that session, but if I
closed Eclipse and opened it again the settings were restored to Workspace settings.

I would of expected the project specific settings to be stored in the .settings
directory of the project so that they can be persisted and sent to CVS.

This is important to us because we do combined open source and commercial
development based upon the opensource in the same workspace. The two different
types of plugins require different license/copyrights at the head of new java
files. We were going to use this capability of project specific template to
prevent accidentally having the wrong copyright on the wrong class.
Comment 1 Dirk Baeumer CLA Friend 2005-09-14 18:34:10 EDT
Richard,

this works for me. I tested the following setup:

- new workspace
- change method comment template to:

/**
 * Custom comment
 * ${tags}
 */

- change method code template to:

// ${todo} Auto-generated method stub; custom comment
${body_statement}

- added class 

package p;

public class A {
	public void foo(String s) {
		
	}
}

- shutdown Eclipse
- restarted Eclipse
- create class 

package p;

public class B extends A {

}

- execute "Override/Implements method"
- checked foo and generate comments (if you want to have that checked you have 
  to enable the preference Java->Code Style->Autmoatically add comments for ...
- pressing OK results in 

	/* (non-Javadoc)
	 * @see p.A#foo(java.lang.String)
	 */
	public void foo(String s) {
		// TODO Auto-generated method stub; custom comment
		super.foo(s);
	}

- which is expected
- typing in 

	public void bar() {
		
	}

- executing "Add comment" results in 

	/**
	 * Custom comment
	 */
	public void bar() {
		
	}

Both results are correct IMO. 

Can you please provide steps to reproduce the problem.
Comment 2 Dirk Baeumer CLA Friend 2005-09-14 19:05:19 EDT
Actually, I was able to reproduce. It depends on whether there are other setting
changed to be local to the project. Steps to reproduce:

- new workspace
- new Java project
- deselect .* filter
- change code templates to be project specific and change the file comment
- press OK

observe: no .setting directory is created. 

I think it worked for me in the first test since if you make the Java code style
setting local all setting are saved correctly.

Martin, can you please investigate. We might want to fix this for 3.1.1
depending on the impact of the fix.
Comment 3 Martin Aeschlimann CLA Friend 2005-09-15 06:14:15 EDT
Created attachment 27158 [details]
patch on ProjectTemplateStore
Comment 4 Martin Aeschlimann CLA Friend 2005-09-15 06:21:29 EDT
This is really Tom's land. For consistency it would be good if the TemplateStore
also ssaves the preference store, but I realize that it you could also argue
that this is not the job of the TemplateStore.

Tom, can you give your opinion to both patches. So far nothing is released.
Comment 5 Martin Aeschlimann CLA Friend 2005-09-15 06:25:20 EDT
Created attachment 27159 [details]
patch for TemplateStore
Comment 6 Tom Hofmann CLA Friend 2005-09-15 09:27:27 EDT
Hm, I would think that persistence management is not the job of TemplateStore.
Currently the preference page saves the plug-ins preferences when pressing OK,
but even without that, I think that the preferences should be saved to disk when
a plug-in is shutdown (no?). 

I don't see why this does not work when changing project's properties -
shouldn't the property dialog flush the preference on OK? Why are project
preference not flushed automatically on shutdown?

--

On the other hand, the patch is minimally intrusive and I could live with the
patch in comment 5.
Comment 7 Dirk Baeumer CLA Friend 2005-09-15 10:09:57 EDT
CC Dani. What's your opinion regarding 3.1.1.
Comment 8 Dani Megert CLA Friend 2005-09-20 05:58:52 EDT
Already reviewed yesterady and released to HEAD (will be in 3.2 M2).
Now also backported to 3.1.1.
Comment 9 Dani Megert CLA Friend 2005-09-21 06:09:42 EDT
Verified for 3.2 M2 using I20050921-0010.
Comment 10 Philip Mayer CLA Friend 2005-09-26 05:31:23 EDT
Verified in M20050923-1430.