From: <ma...@us...> - 2011-09-15 13:22:02
|
Revision: 1369 http://j-trac.svn.sourceforge.net/j-trac/?rev=1369&view=rev Author: magog96 Date: 2011-09-15 13:21:52 +0000 (Thu, 15 Sep 2011) Log Message: ----------- -added special form for password editing where the entered value is hidden (Note: The value is still visible in the list of configuration parameters) Modified Paths: -------------- trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigFormPage.java trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigListPage.java Added Paths: ----------- trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigPasswordFormPage.html trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigPasswordFormPage.java Modified: trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigFormPage.java =================================================================== --- trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigFormPage.java 2011-09-15 11:42:42 UTC (rev 1368) +++ trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigFormPage.java 2011-09-15 13:21:52 UTC (rev 1369) @@ -27,7 +27,12 @@ * config value edit form */ public class ConfigFormPage extends BasePage { - + /** + * Constructor + * + * @param param + * @param value + */ public ConfigFormPage(String param, String value) { add(new ConfigForm("form", param, value)); } @@ -61,7 +66,6 @@ add(new Label("heading", localize("config." + param))); add(new Label("param", param)); - add(new TextField("value")); // cancel ========================================================== Modified: trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigListPage.java =================================================================== --- trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigListPage.java 2011-09-15 11:42:42 UTC (rev 1368) +++ trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigListPage.java 2011-09-15 13:21:52 UTC (rev 1369) @@ -27,11 +27,17 @@ import org.apache.wicket.markup.html.list.ListView; /** - * config list + * This class is responsible to list all configuration parameters. + * It also declares which edit forms will be called to modify the + * configuration parameters. */ public class ConfigListPage extends BasePage { - - public ConfigListPage(final String selectedParam) { + /** + * Constructor + * + * @param selectedParam + */ + public ConfigListPage(final String selectedParam) { final Map<String, String> configMap = getJtrac().loadAllConfig(); @@ -43,22 +49,34 @@ protected void populateItem(ListItem listItem) { final String param = (String) listItem.getModelObject(); final String value = configMap.get(param); + if (param.equals(selectedParam)) { listItem.add(new SimpleAttributeModifier("class", "selected")); } else if(listItem.getIndex() % 2 == 1) { listItem.add(sam); - } + } + listItem.add(new Label("param", param)); listItem.add(new Label("value", value)); - listItem.add(new Link("link") { - public void onClick() { - setResponsePage(new ConfigFormPage(param, value)); - } - }); + + if (param.toLowerCase().indexOf("password") != -1) { + // Password value to be edited + listItem.add(new Link("link") { + public void onClick() { + setResponsePage(new ConfigPasswordFormPage(param, value)); + } + }); + } else { + // Normal text value to be edited + listItem.add(new Link("link") { + public void onClick() { + setResponsePage(new ConfigFormPage(param, value)); + } + }); + } listItem.add(new Label("description", localize("config." + param))); } }); } - -} +} \ No newline at end of file Added: trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigPasswordFormPage.html =================================================================== --- trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigPasswordFormPage.html (rev 0) +++ trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigPasswordFormPage.html 2011-09-15 13:21:52 UTC (rev 1369) @@ -0,0 +1,20 @@ +<html> + <body> + <wicket:extend> + <form wicket:id="form"> + <div wicket:id="heading" class="heading"></div> + <table class="jtrac"> + <tr> + <td wicket:id="param" class="label"></td> + <td> + <input type="password" wicket:id="value"/> + <input type="submit" wicket:message="value:submit"/> + </td> + </tr> + </table> + <p/> + <a href="#" wicket:id="cancel"><img src="resources/cancel.gif" class="nav-link"/><wicket:message key="cancel"/></a> + </form> + </wicket:extend> + </body> +</html> \ No newline at end of file Property changes on: trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigPasswordFormPage.html ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigPasswordFormPage.java =================================================================== --- trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigPasswordFormPage.java (rev 0) +++ trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigPasswordFormPage.java 2011-09-15 13:21:52 UTC (rev 1369) @@ -0,0 +1,85 @@ +/* + * Copyright 2002-2005 the original author or authors. + * + * 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 info.jtrac.wicket; + +import info.jtrac.domain.Config; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.PasswordTextField; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.BoundCompoundPropertyModel; + +/** + * config value edit form + */ +public class ConfigPasswordFormPage extends BasePage { + /** + * Constructor + * + * @param param + * @param value + */ + public ConfigPasswordFormPage(String param, String value) { + add(new ConfigPasswordForm("form", param, value)); + } + + /** + * wicket form + */ + private class ConfigPasswordForm extends Form { + + private String param; + + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public ConfigPasswordForm(String id, final String param, final String value) { + + super(id); + + this.param = param; + this.value = value; + + final BoundCompoundPropertyModel model = new BoundCompoundPropertyModel(this); + setModel(model); + + add(new Label("heading", localize("config." + param))); + add(new Label("param", param)); + add(new PasswordTextField("value")); + + // cancel ========================================================== + add(new Link("cancel") { + public void onClick() { + setResponsePage(new ConfigListPage(param)); + } + }); + } + + @Override + protected void onSubmit() { + getJtrac().storeConfig(new Config(param, value)); + setResponsePage(new ConfigListPage(param)); + } + } +} \ No newline at end of file Property changes on: trunk/jtrac/src/main/java/info/jtrac/wicket/ConfigPasswordFormPage.java ___________________________________________________________________ Added: svn:mime-type + text/plain This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |