01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package info.jtrac.wicket;
18:
19: import info.jtrac.domain.Config;
20: import java.util.ArrayList;
21: import java.util.List;
22: import java.util.Map;
23: import org.apache.wicket.behavior.SimpleAttributeModifier;
24: import org.apache.wicket.markup.html.basic.Label;
25: import org.apache.wicket.markup.html.link.Link;
26: import org.apache.wicket.markup.html.list.ListItem;
27: import org.apache.wicket.markup.html.list.ListView;
28:
29: /**
30: * config list
31: */
32: public class ConfigListPage extends BasePage {
33:
34: public ConfigListPage(final String selectedParam) {
35:
36: final Map<String, String> configMap = getJtrac()
37: .loadAllConfig();
38:
39: List<String> params = new ArrayList(Config.getParams());
40:
41: final SimpleAttributeModifier sam = new SimpleAttributeModifier(
42: "class", "alt");
43:
44: add(new ListView("configs", params) {
45: protected void populateItem(ListItem listItem) {
46: final String param = (String) listItem.getModelObject();
47: final String value = configMap.get(param);
48: if (param.equals(selectedParam)) {
49: listItem.add(new SimpleAttributeModifier("class",
50: "selected"));
51: } else if (listItem.getIndex() % 2 == 1) {
52: listItem.add(sam);
53: }
54: listItem.add(new Label("param", param));
55: listItem.add(new Label("value", value));
56: listItem.add(new Link("link") {
57: public void onClick() {
58: setResponsePage(new ConfigFormPage(param, value));
59: }
60: });
61: listItem.add(new Label("description",
62: localize("config." + param)));
63: }
64: });
65:
66: }
67:
68: }
|