Use AccessPolicyPanel in EditRepositoryPage
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
index d2d1454..13abcc0 100644
--- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
+++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
@@ -687,7 +687,7 @@
 gb.extensions = extensions
 gb.pleaseSelectProject = Please select the project!
 gb.accessPolicy = Access Policy
-gb.accessPolicyDescription = Choose an access policy to control visibility, cloning, and pushing to this repository.
+gb.accessPolicyDescription = Choose an access policy to control repository visibility and git permissions.
 gb.anonymousPolicy = Anonymous View, Clone, & Push
 gb.anonymousPolicyDescription = Anyone can see, clone, and push to this repository.
 gb.authenticatedPushPolicy = Restrict Push (Authenticated)
@@ -704,5 +704,3 @@
 gb.initWithReadmeDescription = This will generate a simple README document for your repository.
 gb.initWithGitignore = Include a .gitignore file
 gb.initWithGitignoreDescription = This will insert a config file that instructs your Git clients to ignore files or directories that match defined patterns.
-gb.initWithGitflow = Include a .gitflow file
-gb.initWithGitflowDescription = This will generate a config file which guides Git clients in setting up Gitflow branches.
\ No newline at end of file
diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html
index ccb60a5..ab44803 100644
--- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html
+++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html
@@ -58,9 +58,7 @@
 				<tbody class="settings">

 					<tr><th><wicket:message key="gb.owners"></wicket:message></th><td class="edit"><span wicket:id="owners" tabindex="19" /> </td></tr>

 					<tr><th colspan="2"><hr/></th></tr>

-					<tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="20" /></td></tr>

-					<tr><th colspan="2"><hr/></th></tr>

-					<tr><th><wicket:message key="gb.authorizationControl"></wicket:message></th><td style="padding:2px;"><span class="authorizationControl" wicket:id="authorizationControl"></span></td></tr>

+					<tr><th></th><td style="padding:2px;"><span wicket:id="accessPolicyPanel"></span></td></tr>

 					<tr><th colspan="2"><hr/></th></tr>

 					<tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="21" /> &nbsp;<span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>

 					<tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="22" /> &nbsp;<span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>

diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
index 4759fd0..e86bd1e 100644
--- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -29,7 +29,6 @@
 import org.apache.wicket.PageParameters;

 import org.apache.wicket.ajax.AjaxRequestTarget;

 import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;

-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;

 import org.apache.wicket.behavior.SimpleAttributeModifier;

 import org.apache.wicket.extensions.markup.html.form.palette.Palette;

 import org.apache.wicket.markup.html.WebMarkupContainer;

@@ -40,7 +39,6 @@
 import org.apache.wicket.markup.html.form.DropDownChoice;

 import org.apache.wicket.markup.html.form.Form;

 import org.apache.wicket.markup.html.form.IChoiceRenderer;

-import org.apache.wicket.markup.html.form.RadioChoice;

 import org.apache.wicket.markup.html.form.TextField;

 import org.apache.wicket.markup.html.link.Link;

 import org.apache.wicket.markup.html.list.ListItem;

@@ -69,6 +67,7 @@
 import com.gitblit.wicket.GitBlitWebSession;

 import com.gitblit.wicket.StringChoiceRenderer;

 import com.gitblit.wicket.WicketUtils;

+import com.gitblit.wicket.panels.AccessPolicyPanel;

 import com.gitblit.wicket.panels.BasePanel.JavascriptEventConfirmation;

 import com.gitblit.wicket.panels.BulletListPanel;

 import com.gitblit.wicket.panels.RegistrantPermissionsPanel;

@@ -80,6 +79,8 @@
 

 	RepositoryNamePanel namePanel;

 

+	AccessPolicyPanel accessPolicyPanel;

+

 	private boolean isAdmin;

 

 	RepositoryModel repositoryModel;

@@ -396,9 +397,6 @@
 

 		form.add(ownersPalette);

 		form.add(new CheckBox("allowForks").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true)));

-		DropDownChoice<AccessRestrictionType> accessRestriction = new DropDownChoice<AccessRestrictionType>("accessRestriction",

-				AccessRestrictionType.choices(app().settings().getBoolean(Keys.git.allowAnonymousPushes, false)), new AccessRestrictionRenderer());

-		form.add(accessRestriction);

 		form.add(new CheckBox("isFrozen"));

 		// TODO enable origin definition

 		form.add(new TextField<String>("origin").setEnabled(false/* isCreate */));

@@ -456,11 +454,6 @@
 		form.add(new TextField<String>("mailingLists", mailingLists));

 		form.add(indexedBranchesPalette);

 

-		List<AuthorizationControl> acList = Arrays.asList(AuthorizationControl.values());

-		final RadioChoice<AuthorizationControl> authorizationControl = new RadioChoice<Constants.AuthorizationControl>(

-				"authorizationControl", acList, new AuthorizationControlRenderer());

-		form.add(authorizationControl);

-

 		final CheckBox verifyCommitter = new CheckBox("verifyCommitter");

 		verifyCommitter.setOutputMarkupId(true);

 		form.add(verifyCommitter);

@@ -484,12 +477,10 @@
 			// anonymous everything, disable all controls

 			usersPalette.setEnabled(false);

 			teamsPalette.setEnabled(false);

-			authorizationControl.setEnabled(false);

 			verifyCommitter.setEnabled(false);

 		} else {

 			// authenticated something

 			// enable authorization controls

-			authorizationControl.setEnabled(true);

 			verifyCommitter.setEnabled(true);

 

 			boolean allowFineGrainedControls = repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);

@@ -497,15 +488,15 @@
 			teamsPalette.setEnabled(allowFineGrainedControls);

 		}

 

-		accessRestriction.add(new AjaxFormComponentUpdatingBehavior("onchange") {

+		AjaxFormChoiceComponentUpdatingBehavior callback = new AjaxFormChoiceComponentUpdatingBehavior() {

 

 			private static final long serialVersionUID = 1L;

 

 			@Override

 			protected void onUpdate(AjaxRequestTarget target) {

-				// enable/disable permissions panel based on access restriction

+				accessPolicyPanel.updateModel(repositoryModel);

+

 				boolean allowAuthorizationControl = repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE);

-				authorizationControl.setEnabled(allowAuthorizationControl);

 				verifyCommitter.setEnabled(allowAuthorizationControl);

 

 				boolean allowFineGrainedControls = allowAuthorizationControl && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);

@@ -516,36 +507,14 @@
 					repositoryModel.authorizationControl = AuthorizationControl.NAMED;

 				}

 

-				target.addComponent(authorizationControl);

 				target.addComponent(verifyCommitter);

 				target.addComponent(usersPalette);

 				target.addComponent(teamsPalette);

 			}

-		});

+		};

 

-		authorizationControl.add(new AjaxFormChoiceComponentUpdatingBehavior() {

-

-			private static final long serialVersionUID = 1L;

-

-			@Override

-			protected void onUpdate(AjaxRequestTarget target) {

-				// enable/disable permissions panel based on access restriction

-				boolean allowAuthorizationControl = repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE);

-				authorizationControl.setEnabled(allowAuthorizationControl);

-

-				boolean allowFineGrainedControls = allowAuthorizationControl && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);

-				usersPalette.setEnabled(allowFineGrainedControls);

-				teamsPalette.setEnabled(allowFineGrainedControls);

-

-				if (allowFineGrainedControls) {

-					repositoryModel.authorizationControl = AuthorizationControl.NAMED;

-				}

-

-				target.addComponent(authorizationControl);

-				target.addComponent(usersPalette);

-				target.addComponent(teamsPalette);

-			}

-		});

+		accessPolicyPanel = new AccessPolicyPanel("accessPolicyPanel", repositoryModel, callback);

+		form.add(accessPolicyPanel);

 

 		List<CommitMessageRenderer> renderers = Arrays.asList(CommitMessageRenderer.values());

 		DropDownChoice<CommitMessageRenderer> messageRendererChoice = new DropDownChoice<CommitMessageRenderer>("commitMessageRenderer", renderers);

@@ -656,27 +625,6 @@
 		}

 	}

 

-	private class AccessRestrictionRenderer implements IChoiceRenderer<AccessRestrictionType> {

-

-		private static final long serialVersionUID = 1L;

-

-		private final Map<AccessRestrictionType, String> map;

-

-		public AccessRestrictionRenderer() {

-			map = getAccessRestrictions();

-		}

-

-		@Override

-		public String getDisplayValue(AccessRestrictionType type) {

-			return map.get(type);

-		}

-

-		@Override

-		public String getIdValue(AccessRestrictionType type, int index) {

-			return Integer.toString(index);

-		}

-	}

-

 	private class FederationTypeRenderer implements IChoiceRenderer<FederationStrategy> {

 

 		private static final long serialVersionUID = 1L;

@@ -698,27 +646,6 @@
 		}

 	}

 

-	private class AuthorizationControlRenderer implements IChoiceRenderer<AuthorizationControl> {

-

-		private static final long serialVersionUID = 1L;

-

-		private final Map<AuthorizationControl, String> map;

-

-		public AuthorizationControlRenderer() {

-			map = getAuthorizationControls();

-		}

-

-		@Override

-		public String getDisplayValue(AuthorizationControl type) {

-			return map.get(type);

-		}

-

-		@Override

-		public String getIdValue(AuthorizationControl type, int index) {

-			return Integer.toString(index);

-		}

-	}

-

 	private class GCPeriodRenderer implements IChoiceRenderer<Integer> {

 

 		private static final long serialVersionUID = 1L;

diff --git a/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.html b/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.html
index 8e4e74a..df55381 100644
--- a/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.html
+++ b/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.html
@@ -14,7 +14,7 @@
 		

 		<hr/>

 		

-		<div wicket:id="permissionPanel"></div>

+		<div wicket:id="accessPolicyPanel"></div>

 		

 		<hr/>

 		

@@ -39,8 +39,8 @@
 				<input type="checkbox" wicket:id="addGitflow" />

 			</div>

 			<div style="display: inline-block;">

-				<b><wicket:message key="gb.initWithGitflow"></wicket:message></b>

-				<p><wicket:message key="gb.initWithGitflowDescription"></wicket:message></p>

+				<b>Include a .gitflow file</b>

+				<p>This will generate a config file which guides Git clients in setting up Gitflow branches.</p>

 			</div>

 		</div>

 		

diff --git a/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java
index 0adb1dd..d5ae344 100644
--- a/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java
@@ -59,8 +59,8 @@
 import com.gitblit.utils.StringUtils;

 import com.gitblit.wicket.GitBlitWebSession;

 import com.gitblit.wicket.WicketUtils;

-import com.gitblit.wicket.panels.RepositoryNamePanel;

 import com.gitblit.wicket.panels.AccessPolicyPanel;

+import com.gitblit.wicket.panels.RepositoryNamePanel;

 

 public class NewRepositoryPage extends RootSubPage {

 

@@ -69,7 +69,7 @@
 	private Model<String> gitignoreModel;

 	private IModel<Boolean> addGitflowModel;

 	private IModel<Boolean> addGitignoreModel;

-	private AccessPolicyPanel permissionPanel;

+	private AccessPolicyPanel accessPolicyPanel;

 	private RepositoryNamePanel namePanel;

 

 	public NewRepositoryPage() {

@@ -108,7 +108,7 @@
 					if (!namePanel.updateModel(repositoryModel)) {

 						return;

 					}

-					permissionPanel.updateModel(repositoryModel);

+					accessPolicyPanel.updateModel(repositoryModel);

 

 					repositoryModel.owners = new ArrayList<String>();

 					repositoryModel.owners.add(GitBlitWebSession.get().getUsername());

@@ -174,8 +174,8 @@
 		repositoryModel.authorizationControl = defaultControl;

 		repositoryModel.accessRestriction = defaultRestriction;

 

-		permissionPanel = new AccessPolicyPanel("permissionPanel", repositoryModel);

-		form.add(permissionPanel);

+		accessPolicyPanel = new AccessPolicyPanel("accessPolicyPanel", repositoryModel);

+		form.add(accessPolicyPanel);

 

 		//

 		// initial commit options

diff --git a/src/main/java/com/gitblit/wicket/panels/AccessPolicyPanel.java b/src/main/java/com/gitblit/wicket/panels/AccessPolicyPanel.java
index a115e25..057b96f 100644
--- a/src/main/java/com/gitblit/wicket/panels/AccessPolicyPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/AccessPolicyPanel.java
@@ -19,6 +19,7 @@
 import java.util.ArrayList;

 import java.util.List;

 

+import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;

 import org.apache.wicket.markup.html.basic.Label;

 import org.apache.wicket.markup.html.form.Radio;

 import org.apache.wicket.markup.html.form.RadioGroup;

@@ -44,11 +45,18 @@
 

 	private final RepositoryModel repository;

 

+	private final AjaxFormChoiceComponentUpdatingBehavior callback;

+

 	private RadioGroup<AccessPolicy> policiesGroup;

 

 	public AccessPolicyPanel(String wicketId, RepositoryModel repository) {

+		this(wicketId, repository, null);

+	}

+

+	public AccessPolicyPanel(String wicketId, RepositoryModel repository, AjaxFormChoiceComponentUpdatingBehavior callback) {

 		super(wicketId);

 		this.repository = repository;

+		this.callback = callback;

 	}

 

 	@Override

@@ -128,10 +136,13 @@
 			}

 		};

 		policiesGroup.add(policiesList);

+		if (callback != null) {

+			policiesGroup.add(callback);

+			policiesGroup.setOutputMarkupId(true);

+		}

+		add(policiesGroup);

 

 		setOutputMarkupId(true);

-

-		add(policiesGroup);

 	}

 

 	public void updateModel(RepositoryModel repository) {

@@ -145,7 +156,7 @@
 		return false;

 	}

 

-	private static class AccessPolicy implements Serializable {

+	public static class AccessPolicy implements Serializable {

 

 		private static final long serialVersionUID = 1L;