[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs ...

Christian Bauer christian at hibernate.org
Sat Dec 29 21:33:22 EST 2007


  User: cbauer  
  Date: 07/12/29 21:33:22

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs     
                        WikiPreferences.java UserManagementPreferences.java
                        CommentsPreferences.java
                        DocumentEditorPreferences.java
  Added:       examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs     
                        CorePreferencesSupport.java
  Log:
  Complete overhaul of the preferences system
  
  Revision  Changes    Path
  1.15      +93 -35    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs/WikiPreferences.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WikiPreferences.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs/WikiPreferences.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- WikiPreferences.java	19 Dec 2007 13:33:38 -0000	1.14
  +++ WikiPreferences.java	30 Dec 2007 02:33:22 -0000	1.15
  @@ -6,98 +6,156 @@
    */
   package org.jboss.seam.wiki.core.action.prefs;
   
  -import org.jboss.seam.annotations.Name;
  -import org.jboss.seam.annotations.AutoCreate;
  -import org.jboss.seam.annotations.Scope;
  -import org.jboss.seam.wiki.preferences.PreferenceVisibility;
  -import org.jboss.seam.wiki.preferences.Preference;
  -import org.jboss.seam.wiki.preferences.PreferenceSupport;
  -import org.jboss.seam.ScopeType;
   import org.hibernate.validator.Length;
  -import org.hibernate.validator.Range;
   import org.hibernate.validator.NotNull;
  +import org.hibernate.validator.Range;
  +import org.jboss.seam.wiki.preferences.annotations.Preferences;
  +import org.jboss.seam.wiki.preferences.annotations.PreferenceProperty;
  +import org.jboss.seam.wiki.preferences.PreferenceVisibility;
   
   import java.io.Serializable;
   
  - at Name("wikiPreferences")
  - at AutoCreate
  - at Scope(ScopeType.CONVERSATION)
  - at Preference(description = "Core: Wiki Preferences", visibility = PreferenceVisibility.SYSTEM)
  -public class WikiPreferences extends PreferenceSupport implements Serializable {
  + at Preferences(name = "Wiki", description = "#{messages['lacewiki.preferences.wiki.Name']}")
  +public class WikiPreferences implements Serializable {
   
  -    @Preference(description = "01. Base URL without trailing slash (e.g. 'http://my.wiki.server/installdir')", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.BaseURL']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "AdaptiveTextInput"
  +    )
       @Length(min = 8, max = 255)
       @NotNull
       private String baseUrl;
   
  -    @Preference(description = "02. Timezone of server (ID as defined in java.util.TimeZone)", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.TimeZone']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "SelectOne",
  +        templateComponentName = "timeZonePreferenceValueTemplate"
  +    )
       @Length(min = 3, max = 63)
       @NotNull
       private String timeZone;
   
  -    @Preference(description = "03. Theme directory name", visibility = PreferenceVisibility.SYSTEM)
  -    @Length(min = 3, max = 20)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.ThemeName']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "SelectOne",
  +        templateComponentName = "themePreferenceValueTemplate"
  +    )
  +    @Length(min = 3, max = 255)
       @NotNull
       private String themeName;
   
  -    @Preference(description = "04. Wiki area for user home directorie", visibility = PreferenceVisibility.SYSTEM)
  -    @Length(min = 3, max = 1000)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.MemberArea']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "SelectOne",
  +        templateComponentName = "writeProtectedAreaPreferenceValueTemplate"
  +    )
  +    @Length(min = 3, max = 255)
       @NotNull
       private String memberArea;
   
  -    @Preference(description = "05. Wiki area containing help texts", visibility = PreferenceVisibility.SYSTEM)
  -    @Length(min = 3, max = 1000)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.HelpArea']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "SelectOne",
  +        templateComponentName = "writeProtectedAreaPreferenceValueTemplate"
  +    )
  +    @Length(min = 3, max = 255)
       @NotNull
       private String helpArea;
   
  -    @Preference(description = "06. Identifier of the default start document of the Wiki", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.DefaultDocumentId']}",
  +        visibility = PreferenceVisibility.SYSTEM
  +    )
       @NotNull
       private Long defaultDocumentId;
   
  -    @Preference(description = "07. Render all links as permanent numeric identifier links (or as /Wiki/WordLinks)", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.RenderPermLinks']}",
  +        visibility = PreferenceVisibility.SYSTEM
  +    )
       private Boolean renderPermlinks;
   
  -    @Preference(description = "08. Append this suffix to permanent identifier", visibility = PreferenceVisibility.SYSTEM)
  -    @Length(min = 2, max = 20)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.PermLinkSuffix']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "AdaptiveTextInput"
  +    )
  +    @Length(min = 2, max = 10)
       @org.hibernate.validator.Pattern(regex="\\.[a-zA-z]+")
       @NotNull
       private String permlinkSuffix;
   
  -    @Preference(description = "09. Feed title prefix", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.FeedTitlePrefix']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "AdaptiveTextInput"
  +    )
       @Length(min = 0, max = 255)
       @NotNull
       private String feedTitlePrefix;
   
  -    @Preference(description = "10. Purge feed entries after N days", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.PurgeFeedEntriesAfterDays']}",
  +        visibility = PreferenceVisibility.SYSTEM
  +    )
       @Range(min = 1l, max = 999l)
       @NotNull
       private Long purgeFeedEntriesAfterDays;
   
  -    @Preference(description = "11. Replace @ symbol in e-mail addresses with", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.AtSymbolReplacement']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "AdaptiveTextInput"
  +    )
       @Length(min = 1, max = 20)
       @NotNull
       private String atSymbolReplacement;
   
  -    @Preference(description = "12. Show e-mail addresses only to logged-in users", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.ShowEmailToLoggedInOnly']}",
  +        visibility = PreferenceVisibility.SYSTEM
  +    )
       private Boolean showEmailToLoggedInOnly;
   
  -    @Preference(description = "13. Flatten main menu to levels (set to 0 for unlimited visible levels)", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.MainMenuLevels']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "NumberRange"
  +    )
       @Range(min = 0l, max = 10l)
       @NotNull
       private Long mainMenuLevels;
   
  -    @Preference(description = "14. Maximum depth of main menu nodes", visibility = PreferenceVisibility.SYSTEM)
  -    @Range(min = 1l, max = 99l)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.MainMenuDepth']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "NumberRange"
  +    )
  +    @Range(min = 1l, max = 10l)
       @NotNull
       private Long mainMenuDepth;
   
  -    @Preference(description = "15. Show only nodes owned by system administrator in main menu", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.MainMenuShowAdminOnly']}",
  +        visibility = PreferenceVisibility.SYSTEM
  +    )
       private Boolean mainMenuShowAdminOnly;
   
  -    @Preference(description = "16. Show document creator/edit history in document footer", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.ShowDocumentCreatorHistory']}",
  +        visibility = PreferenceVisibility.SYSTEM
  +    )
       private Boolean showDocumentCreatorHistory;
       
  -    @Preference(description = "17. Show document tags in document footer", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.wiki.ShowTags']}",
  +        visibility = PreferenceVisibility.SYSTEM
  +    )
       private Boolean showTags;
   
       public String getBaseUrl() {
  
  
  
  1.8       +38 -20    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs/UserManagementPreferences.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UserManagementPreferences.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs/UserManagementPreferences.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- UserManagementPreferences.java	24 Sep 2007 08:23:21 -0000	1.7
  +++ UserManagementPreferences.java	30 Dec 2007 02:33:22 -0000	1.8
  @@ -1,45 +1,63 @@
   package org.jboss.seam.wiki.core.action.prefs;
   
  -import org.jboss.seam.wiki.preferences.PreferenceSupport;
  -import org.jboss.seam.wiki.preferences.Preference;
  -import org.jboss.seam.wiki.preferences.PreferenceVisibility;
  -import org.jboss.seam.annotations.Scope;
  -import org.jboss.seam.annotations.Name;
  -import org.jboss.seam.annotations.AutoCreate;
  -import org.jboss.seam.ScopeType;
   import org.hibernate.validator.Length;
   import org.hibernate.validator.NotNull;
  +import org.jboss.seam.wiki.preferences.annotations.Preferences;
  +import org.jboss.seam.wiki.preferences.annotations.PreferenceProperty;
  +import org.jboss.seam.wiki.preferences.PreferenceVisibility;
   
   import java.io.Serializable;
   
  - at Name("userManagementPreferences")
  - at AutoCreate
  - at Scope(ScopeType.CONVERSATION)
  - at Preference(description = "Core: User Management", visibility = PreferenceVisibility.SYSTEM)
  -public class UserManagementPreferences extends PreferenceSupport implements Serializable {
  + at Preferences(name = "UserManagement", description = "#{messages['lacewiki.preferences.userManagement.Name']}")
  +public class UserManagementPreferences implements Serializable {
   
  -    @Preference(description = "01. Secret salt used to generate activation codes", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.userManagement.ActivationCodeSalt']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "AdaptiveTextInput"
  +    )
       @Length(min = 5, max = 20)
       @NotNull
       private String activationCodeSalt;
   
  -    @Preference(description = "02. Regex used for password strength verification", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.userManagement.PasswordRegex']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "AdaptiveTextInput"
  +    )
       @Length(min = 2, max = 100)
       @NotNull
       private String passwordRegex;
   
  -    @Preference(description = "03. Default role name of new users after registration", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.userManagement.NewUserInRole']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "SelectOne",
  +        templateComponentName = "rolesPreferenceValueTemplate"
  +    )
       @Length(min = 3, max = 255)
       @NotNull
       private String newUserInRole;
   
  -    @Preference(description = "04. Enable free user registration", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.userManagement.EnableRegistration']}",
  +        visibility = PreferenceVisibility.SYSTEM
  +    )
  +    @NotNull
       private Boolean enableRegistration;
   
  -    @Preference(description = "05. Create home directory for new user after activation", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.userManagement.CreateHomeAfterUserActivation']}",
  +        visibility = PreferenceVisibility.SYSTEM
  +    )
  +    @NotNull
       private Boolean createHomeAfterUserActivation;
   
  -    @Preference(description = "06. Content of created home page", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.userManagement.HomepageDefaultContent']}",
  +        visibility = PreferenceVisibility.SYSTEM,
  +        editorIncludeName = "AdaptiveTextInput"
  +    )
       @Length(min = 0, max = 1024)
       private String homepageDefaultContent;
   
  @@ -55,11 +73,11 @@
           return newUserInRole;
       }
   
  -    public Boolean isEnableRegistration() {
  +    public Boolean getEnableRegistration() {
           return enableRegistration;
       }
   
  -    public Boolean isCreateHomeAfterUserActivation() {
  +    public Boolean getCreateHomeAfterUserActivation() {
           return createHomeAfterUserActivation;
       }
   
  
  
  
  1.5       +23 -24    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs/CommentsPreferences.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CommentsPreferences.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs/CommentsPreferences.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- CommentsPreferences.java	19 Dec 2007 04:29:27 -0000	1.4
  +++ CommentsPreferences.java	30 Dec 2007 02:33:22 -0000	1.5
  @@ -1,36 +1,35 @@
   package org.jboss.seam.wiki.core.action.prefs;
   
  -import org.jboss.seam.annotations.Name;
  -import org.jboss.seam.annotations.Scope;
  -import org.jboss.seam.annotations.Observer;
  -import org.jboss.seam.annotations.AutoCreate;
  -import org.jboss.seam.ScopeType;
  -import org.jboss.seam.wiki.preferences.Preference;
  +import org.hibernate.validator.NotNull;
  +import org.jboss.seam.wiki.preferences.annotations.PreferenceProperty;
  +import org.jboss.seam.wiki.preferences.annotations.Preferences;
   import org.jboss.seam.wiki.preferences.PreferenceVisibility;
  -import org.jboss.seam.wiki.preferences.PreferenceSupport;
   
   import java.io.Serializable;
   
  - at Name("commentsPreferences")
  - at Scope(ScopeType.CONVERSATION)
  - at Preference(description = "Core: Visitor Comments", visibility = PreferenceVisibility.USER)
  - at AutoCreate
  -public class CommentsPreferences extends PreferenceSupport implements Serializable {
  + at Preferences(name = "Comments", description = "#{messages['lacewiki.preferences.comments.Name']}")
  +public class CommentsPreferences implements Serializable {
   
  -    public String getCurrentUserVariable() { return "currentUser"; }
  -    public String getCurrentInstanceVariable() { return "currentDocument"; }
  -
  -    @Observer("PreferenceEditor.refresh.commentsPreferences")
  -    public void refreshProperties() { super.refreshProperties(); }
  -
  -    @Preference(description = "01. List flat comments ascending by date (or descending)", visibility = PreferenceVisibility.SYSTEM)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.comments.ListAscending']}",
  +        visibility = {PreferenceVisibility.SYSTEM, PreferenceVisibility.USER}
  +    )
  +    @NotNull
       private Boolean listAscending;
   
  -    @Preference(description = "02. Enable comments by default", visibility = PreferenceVisibility.USER)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.comments.EnableByDefault']}",
  +        visibility = {PreferenceVisibility.SYSTEM, PreferenceVisibility.USER}
  +    )
  +    @NotNull
       private Boolean enableByDefault;
   
  -    @Preference(description = "03. Threaded comments (or flat)", visibility = PreferenceVisibility.SYSTEM)
  -    private Boolean threadedComments;
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.comments.Threaded']}",
  +        visibility = {PreferenceVisibility.SYSTEM, PreferenceVisibility.USER}
  +    )
  +    @NotNull
  +    private Boolean threaded;
   
       public Boolean getListAscending() {
           return listAscending;
  @@ -40,7 +39,7 @@
           return enableByDefault;
       }
   
  -    public Boolean getThreadedComments() {
  -        return threadedComments;
  +    public Boolean getThreaded() {
  +        return threaded;
       }
   }
  
  
  
  1.7       +33 -17    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs/DocumentEditorPreferences.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DocumentEditorPreferences.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs/DocumentEditorPreferences.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- DocumentEditorPreferences.java	15 Sep 2007 17:06:16 -0000	1.6
  +++ DocumentEditorPreferences.java	30 Dec 2007 02:33:22 -0000	1.7
  @@ -1,35 +1,51 @@
   package org.jboss.seam.wiki.core.action.prefs;
   
  -import org.jboss.seam.wiki.preferences.Preference;
  -import org.jboss.seam.wiki.preferences.PreferenceSupport;
  -import org.jboss.seam.wiki.preferences.PreferenceVisibility;
  -import org.jboss.seam.annotations.Name;
  -import org.jboss.seam.annotations.Scope;
  -import org.jboss.seam.ScopeType;
  -import org.hibernate.validator.Range;
   import org.hibernate.validator.NotNull;
  +import org.hibernate.validator.Range;
  +import org.jboss.seam.wiki.preferences.PreferenceVisibility;
  +import org.jboss.seam.wiki.preferences.annotations.PreferenceProperty;
  +import org.jboss.seam.wiki.preferences.annotations.Preferences;
   
   import java.io.Serializable;
   
  - at Name("docEditorPreferences")
  - at Scope(ScopeType.CONVERSATION)
  - at Preference(description = "Core: Document Editor", visibility = PreferenceVisibility.USER)
  -public class DocumentEditorPreferences extends PreferenceSupport implements Serializable {
  + at Preferences(name = "DocEditor", description = "#{messages['lacewiki.preferences.documentEditor.Name']}")
  +public class DocumentEditorPreferences implements Serializable {
   
  -    public String getCurrentUserVariable() { return "currentUser"; }
  -    public String getCurrentInstanceVariable() { return "currentDocument"; }
  -
  -    @Preference(description = "01. Enable 'Minor Revision' checkbox by default", visibility = PreferenceVisibility.USER)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.documentEditor.MinorRevisionEnabled']}",
  +        visibility = {PreferenceVisibility.SYSTEM, PreferenceVisibility.USER}
  +    )
  +    @NotNull
       private Boolean minorRevisionEnabled;
   
  -    @Preference(description = "02. Rows shown in text editor by default", visibility = PreferenceVisibility.USER)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.documentEditor.RegularEditAreaRows']}",
  +        visibility = {PreferenceVisibility.SYSTEM, PreferenceVisibility.USER},
  +        editorIncludeName = "NumberRange"
  +    )
       @Range(min = 5l, max = 100l)
       @NotNull
       private Long regularEditAreaRows;
   
  -    @Preference(description = "03. Columns shown in text editor", visibility = PreferenceVisibility.USER)
  +    @PreferenceProperty(
  +        description = "#{messages['lacewiki.preferences.documentEditor.RegularEditAreaColumns']}",
  +        visibility = {PreferenceVisibility.SYSTEM, PreferenceVisibility.USER},
  +        editorIncludeName = "NumberRange"
  +
  +    )
       @Range(min = 5l, max = 250l)
       @NotNull
       private Long regularEditAreaColumns;
   
  +    public Boolean getMinorRevisionEnabled() {
  +        return minorRevisionEnabled;
  +    }
  +
  +    public Long getRegularEditAreaRows() {
  +        return regularEditAreaRows;
  +    }
  +
  +    public Long getRegularEditAreaColumns() {
  +        return regularEditAreaColumns;
  +    }
   }
  
  
  
  1.1      date: 2007/12/30 02:33:22;  author: cbauer;  state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/prefs/CorePreferencesSupport.java
  
  Index: CorePreferencesSupport.java
  ===================================================================
  package org.jboss.seam.wiki.core.action.prefs;
  
  import org.jboss.seam.annotations.Name;
  import org.jboss.seam.wiki.preferences.metamodel.PreferenceEntity;
  import org.jboss.seam.wiki.preferences.metamodel.PreferencesSupport;
  
  import java.util.HashSet;
  import java.util.Set;
  
  @Name("corePreferencesSupport")
  public class CorePreferencesSupport extends PreferencesSupport {
  
      public Set<PreferenceEntity> getPreferenceEntities() {
          return new HashSet<PreferenceEntity>() {{
              add( createPreferenceEntity(WikiPreferences.class) );
              add( createPreferenceEntity(UserManagementPreferences.class) );
              add( createPreferenceEntity(DocumentEditorPreferences.class) );
              add( createPreferenceEntity(CommentsPreferences.class) );
          }};
      }
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list