commit | author | age
|
f13c4c
|
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 |
*/
|
1f9dae
|
16 |
package com.gitblit.wicket.panels;
|
5fe7df
|
17 |
|
JM |
18 |
import org.apache.wicket.PageParameters;
|
1e47ab
|
19 |
import org.apache.wicket.behavior.SimpleAttributeModifier;
|
5fe7df
|
20 |
import org.apache.wicket.markup.html.WebPage;
|
JM |
21 |
import org.apache.wicket.markup.html.basic.Label;
|
|
22 |
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
|
23 |
import org.apache.wicket.markup.html.link.Link;
|
|
24 |
import org.apache.wicket.markup.html.panel.Panel;
|
|
25 |
import org.apache.wicket.model.IModel;
|
|
26 |
import org.apache.wicket.model.Model;
|
|
27 |
|
|
28 |
public class LinkPanel extends Panel {
|
|
29 |
|
|
30 |
private static final long serialVersionUID = 1L;
|
|
31 |
|
1e47ab
|
32 |
private final IModel<String> labelModel;
|
5fe7df
|
33 |
|
2a7306
|
34 |
public LinkPanel(String wicketId, String linkCssClass, String label,
|
JM |
35 |
Class<? extends WebPage> clazz) {
|
87cc1e
|
36 |
this(wicketId, linkCssClass, new Model<String>(label), clazz, null);
|
JM |
37 |
}
|
2a7306
|
38 |
|
JM |
39 |
public LinkPanel(String wicketId, String linkCssClass, String label,
|
|
40 |
Class<? extends WebPage> clazz, PageParameters parameters) {
|
1e47ab
|
41 |
this(wicketId, linkCssClass, new Model<String>(label), clazz, parameters);
|
JM |
42 |
}
|
|
43 |
|
2a7306
|
44 |
public LinkPanel(String wicketId, String linkCssClass, IModel<String> model,
|
JM |
45 |
Class<? extends WebPage> clazz, PageParameters parameters) {
|
5fe7df
|
46 |
super(wicketId);
|
1e47ab
|
47 |
this.labelModel = model;
|
JM |
48 |
Link<Void> link = null;
|
5fe7df
|
49 |
if (parameters == null) {
|
1e47ab
|
50 |
link = new BookmarkablePageLink<Void>("link", clazz);
|
5fe7df
|
51 |
} else {
|
1e47ab
|
52 |
link = new BookmarkablePageLink<Void>("link", clazz, parameters);
|
5fe7df
|
53 |
}
|
JM |
54 |
if (linkCssClass != null) {
|
1e47ab
|
55 |
link.add(new SimpleAttributeModifier("class", linkCssClass));
|
155bf7
|
56 |
}
|
5fe7df
|
57 |
link.add(new Label("label", labelModel));
|
JM |
58 |
add(link);
|
|
59 |
}
|
|
60 |
|
|
61 |
}
|