summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-03-05 16:32:18 -0500
committerJames Moger <james.moger@gitblit.com>2012-03-05 16:32:18 -0500
commit6fa6abf07be67bba86e9781a4028c4b3863b50f7 (patch)
tree4894e79d2ef7dba1209ffa9f697137443666f3bb
parent3f0677744e5b0195e3c23de9c5fd94924bfb592e (diff)
downloadgitblit-6fa6abf07be67bba86e9781a4028c4b3863b50f7.tar.gz
gitblit-6fa6abf07be67bba86e9781a4028c4b3863b50f7.zip
Replace ChoiceRenderer with StringChoiceRenderer (issue 71)
-rw-r--r--docs/04_releases.mkd1
-rw-r--r--src/com/gitblit/wicket/StringChoiceRenderer.java43
-rw-r--r--src/com/gitblit/wicket/pages/EditRepositoryPage.java12
-rw-r--r--src/com/gitblit/wicket/pages/EditTeamPage.java14
-rw-r--r--src/com/gitblit/wicket/pages/EditUserPage.java6
5 files changed, 60 insertions, 16 deletions
diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd
index da886334..fed78166 100644
--- a/docs/04_releases.mkd
+++ b/docs/04_releases.mkd
@@ -30,6 +30,7 @@ Push requests to these repositories will be rejected.
#### fixes
+- Uppercase repositories not selectable in edit palettes (issue 71)
- Activity page now displays all local branches (issue 65)
- Fixed (harmless) nullpointer on pushing to an empty repository (issue 69)
- Fixed possible nullpointer from the servlet container on startup (issue 67)
diff --git a/src/com/gitblit/wicket/StringChoiceRenderer.java b/src/com/gitblit/wicket/StringChoiceRenderer.java
new file mode 100644
index 00000000..58ed4798
--- /dev/null
+++ b/src/com/gitblit/wicket/StringChoiceRenderer.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2012 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.wicket;
+
+import org.apache.wicket.markup.html.form.ChoiceRenderer;
+
+/**
+ * Choice renderer for a palette or list of string values. This renderer
+ * controls the id value of each option such that palettes are case insensitive.
+ *
+ * @author James Moger
+ *
+ */
+public class StringChoiceRenderer extends ChoiceRenderer<String> {
+
+ private static final long serialVersionUID = 1L;
+
+ public StringChoiceRenderer() {
+ super("", "");
+ }
+
+ /**
+ * @see org.apache.wicket.markup.html.form.IChoiceRenderer#getIdValue(java.lang.Object, int)
+ */
+ @Override
+ public String getIdValue(String object, int index)
+ {
+ return object.toLowerCase();
+ }
+}
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
index 0361da3e..1eae2c98 100644
--- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java
+++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -30,7 +30,6 @@ import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.extensions.markup.html.form.palette.Palette;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.CheckBox;
-import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
@@ -51,6 +50,7 @@ import com.gitblit.models.UserModel;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.GitBlitWebSession;
+import com.gitblit.wicket.StringChoiceRenderer;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.BulletListPanel;
@@ -104,18 +104,18 @@ public class EditRepositoryPage extends RootSubPage {
// users palette
final Palette<String> usersPalette = new Palette<String>("users", new ListModel<String>(
repositoryUsers), new CollectionModel<String>(GitBlit.self().getAllUsernames()),
- new ChoiceRenderer<String>("", ""), 10, false);
+ new StringChoiceRenderer(), 10, false);
// teams palette
final Palette<String> teamsPalette = new Palette<String>("teams", new ListModel<String>(
repositoryTeams), new CollectionModel<String>(GitBlit.self().getAllTeamnames()),
- new ChoiceRenderer<String>("", ""), 5, false);
+ new StringChoiceRenderer(), 5, false);
// federation sets palette
List<String> sets = GitBlit.getStrings(Keys.federation.sets);
final Palette<String> federationSetsPalette = new Palette<String>("federationSets",
new ListModel<String>(federationSets), new CollectionModel<String>(sets),
- new ChoiceRenderer<String>("", ""), 5, false);
+ new StringChoiceRenderer(), 5, false);
// pre-receive palette
if (!ArrayUtils.isEmpty(repositoryModel.preReceiveScripts)) {
@@ -124,7 +124,7 @@ public class EditRepositoryPage extends RootSubPage {
final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts",
new ListModel<String>(preReceiveScripts), new CollectionModel<String>(GitBlit
.self().getPreReceiveScriptsUnused(repositoryModel)),
- new ChoiceRenderer<String>("", ""), 12, true);
+ new StringChoiceRenderer(), 12, true);
// post-receive palette
if (!ArrayUtils.isEmpty(repositoryModel.postReceiveScripts)) {
@@ -133,7 +133,7 @@ public class EditRepositoryPage extends RootSubPage {
final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts",
new ListModel<String>(postReceiveScripts), new CollectionModel<String>(GitBlit
.self().getPostReceiveScriptsUnused(repositoryModel)),
- new ChoiceRenderer<String>("", ""), 12, true);
+ new StringChoiceRenderer(), 12, true);
CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>(
repositoryModel);
diff --git a/src/com/gitblit/wicket/pages/EditTeamPage.java b/src/com/gitblit/wicket/pages/EditTeamPage.java
index 57e97351..2ed5fba6 100644
--- a/src/com/gitblit/wicket/pages/EditTeamPage.java
+++ b/src/com/gitblit/wicket/pages/EditTeamPage.java
@@ -27,7 +27,6 @@ import org.apache.wicket.PageParameters;
import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.extensions.markup.html.form.palette.Palette;
import org.apache.wicket.markup.html.form.Button;
-import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
@@ -43,6 +42,7 @@ import com.gitblit.models.RepositoryModel;
import com.gitblit.models.TeamModel;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.RequiresAdminRole;
+import com.gitblit.wicket.StringChoiceRenderer;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.BulletListPanel;
@@ -97,12 +97,12 @@ public class EditTeamPage extends RootSubPage {
// repositories palette
final Palette<String> repositories = new Palette<String>("repositories",
new ListModel<String>(new ArrayList<String>(teamModel.repositories)),
- new CollectionModel<String>(repos), new ChoiceRenderer<String>("", ""), 10, false);
+ new CollectionModel<String>(repos), new StringChoiceRenderer(), 10, false);
// users palette
final Palette<String> users = new Palette<String>("users", new ListModel<String>(
new ArrayList<String>(teamUsers)), new CollectionModel<String>(GitBlit.self()
- .getAllUsernames()), new ChoiceRenderer<String>("", ""), 10, false);
+ .getAllUsernames()), new StringChoiceRenderer(), 10, false);
// pre-receive palette
if (teamModel.preReceiveScripts != null) {
@@ -110,8 +110,8 @@ public class EditTeamPage extends RootSubPage {
}
final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts",
new ListModel<String>(preReceiveScripts), new CollectionModel<String>(GitBlit
- .self().getPreReceiveScriptsUnused(null)), new ChoiceRenderer<String>("",
- ""), 12, true);
+ .self().getPreReceiveScriptsUnused(null)), new StringChoiceRenderer(),
+ 12, true);
// post-receive palette
if (teamModel.postReceiveScripts != null) {
@@ -119,8 +119,8 @@ public class EditTeamPage extends RootSubPage {
}
final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts",
new ListModel<String>(postReceiveScripts), new CollectionModel<String>(GitBlit
- .self().getPostReceiveScriptsUnused(null)), new ChoiceRenderer<String>("",
- ""), 12, true);
+ .self().getPostReceiveScriptsUnused(null)), new StringChoiceRenderer(),
+ 12, true);
Form<TeamModel> form = new Form<TeamModel>("editForm", model) {
diff --git a/src/com/gitblit/wicket/pages/EditUserPage.java b/src/com/gitblit/wicket/pages/EditUserPage.java
index 62d955e2..3e14d083 100644
--- a/src/com/gitblit/wicket/pages/EditUserPage.java
+++ b/src/com/gitblit/wicket/pages/EditUserPage.java
@@ -26,7 +26,6 @@ import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.extensions.markup.html.form.palette.Palette;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.CheckBox;
-import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
import org.apache.wicket.markup.html.form.TextField;
@@ -44,6 +43,7 @@ import com.gitblit.models.TeamModel;
import com.gitblit.models.UserModel;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.RequiresAdminRole;
+import com.gitblit.wicket.StringChoiceRenderer;
import com.gitblit.wicket.WicketUtils;
@RequiresAdminRole
@@ -94,10 +94,10 @@ public class EditUserPage extends RootSubPage {
final String oldName = userModel.username;
final Palette<String> repositories = new Palette<String>("repositories",
new ListModel<String>(new ArrayList<String>(userModel.repositories)),
- new CollectionModel<String>(repos), new ChoiceRenderer<String>("", ""), 10, false);
+ new CollectionModel<String>(repos), new StringChoiceRenderer(), 10, false);
final Palette<String> teams = new Palette<String>("teams", new ListModel<String>(
new ArrayList<String>(userTeams)), new CollectionModel<String>(GitBlit.self()
- .getAllTeamnames()), new ChoiceRenderer<String>("", ""), 10, false);
+ .getAllTeamnames()), new StringChoiceRenderer(), 10, false);
Form<UserModel> form = new Form<UserModel>("editForm", model) {
private static final long serialVersionUID = 1L;