James Moger
2012-10-22 eba89539a29deba954035056437279088c3e047b
commit | author | age
0d013a 1 /*
JM 2  * Copyright 2011 gitblit.com.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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 package com.gitblit.wicket.panels;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.wicket.markup.html.basic.Label;
22 import org.apache.wicket.markup.html.panel.Panel;
23 import org.apache.wicket.markup.repeater.Item;
24 import org.apache.wicket.markup.repeater.data.DataView;
25 import org.apache.wicket.markup.repeater.data.ListDataProvider;
26
27 public class BulletListPanel extends Panel {
28
29     private static final long serialVersionUID = 1L;
30
31     public BulletListPanel(String id, String header, List<String> list) {
32         super(id);
33         if (list == null) {
34             list = new ArrayList<String>();
35         }
36         add(new Label("header", header).setVisible(list.size() > 0));
37         ListDataProvider<String> listDp = new ListDataProvider<String>(list);
38         DataView<String> listView = new DataView<String>("list", listDp) {
39             private static final long serialVersionUID = 1L;
40
41             public void populateItem(final Item<String> item) {
42                 String entry = item.getModelObject();
43                 item.add(new Label("listItem", entry));
44             }
45         };
46         add(listView.setVisible(list.size() > 0));
47     }
48 }