| | |
| | | import org.apache.wicket.PageParameters;
|
| | | import org.apache.wicket.behavior.SimpleAttributeModifier;
|
| | | import org.apache.wicket.markup.html.basic.Label;
|
| | | import org.eclipse.jgit.diff.DiffEntry.ChangeType;
|
| | | import org.eclipse.jgit.lib.Constants;
|
| | |
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.utils.JGitUtils.SearchType;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.utils.TimeUtils;
|
| | |
|
| | | public class WicketUtils {
|
| | |
| | |
|
| | | public static void setHtmlTitle(Component container, String value) {
|
| | | container.add(new SimpleAttributeModifier("title", value));
|
| | | }
|
| | |
|
| | | public static void setChangeTypeCssClass(Component container, ChangeType type) {
|
| | | switch (type) {
|
| | | case ADD:
|
| | | setCssClass(container, "addition");
|
| | | break;
|
| | | case COPY:
|
| | | case RENAME:
|
| | | setCssClass(container, "rename");
|
| | | break;
|
| | | case DELETE:
|
| | | setCssClass(container, "deletion");
|
| | | break;
|
| | | case MODIFY:
|
| | | setCssClass(container, "modification");
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | public static void setTicketCssClass(Component container, String state) {
|
| | |
| | | }
|
| | |
|
| | | public static PageParameters newObjectParameter(String repositoryName, String objectId) {
|
| | | if (objectId == null || objectId.trim().length() == 0) {
|
| | | if (StringUtils.isEmpty(objectId)) {
|
| | | return newRepositoryParameter(repositoryName);
|
| | | }
|
| | | return new PageParameters("r=" + repositoryName + ",h=" + objectId);
|
| | | }
|
| | |
|
| | | public static PageParameters newPathParameter(String repositoryName, String objectId, String path) {
|
| | | if (path == null || path.trim().length() == 0) {
|
| | | if (StringUtils.isEmpty(path)) {
|
| | | return newObjectParameter(repositoryName, objectId);
|
| | | }
|
| | | return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",f=" + path);
|
| | |
| | | return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",page=" + pageNumber);
|
| | | }
|
| | |
|
| | | public static PageParameters newHistoryPageParameter(String repositoryName, String objectId, String path, int pageNumber) {
|
| | | if (pageNumber <= 1) {
|
| | | return newObjectParameter(repositoryName, objectId);
|
| | | }
|
| | | return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",f=" + path + ",page=" + pageNumber);
|
| | | }
|
| | |
|
| | | public static PageParameters newBlobDiffParameter(String repositoryName, String baseCommitId, String commitId, String path) {
|
| | | return new PageParameters("r=" + repositoryName + ",h=" + commitId + ",f=" + path + ",hb=" + baseCommitId);
|
| | | }
|
| | |
|
| | | public static PageParameters newSearchParameter(String repositoryName, String commitId, String search, SearchType type) {
|
| | | if (StringUtils.isEmpty(commitId)) {
|
| | | return new PageParameters("r=" + repositoryName + ",s=" + search + ",st=" + type.name());
|
| | | }
|
| | | return new PageParameters("r=" + repositoryName + ",h=" + commitId + ",s=" + search + ",st=" + type.name());
|
| | | }
|
| | |
|
| | | public static PageParameters newSearchParameter(String repositoryName, String commitId, String search, SearchType type, int pageNumber) {
|
| | | return new PageParameters("r=" + repositoryName + ",h=" + commitId + ",s=" + search + ",st=" + type.name() + ",page=" + pageNumber);
|
| | | }
|
| | |
|
| | | public static String getRepositoryName(PageParameters params) {
|
| | | return params.getString("r", "");
|
| | | }
|
| | |
| | | return params.getString("f", null);
|
| | | }
|
| | |
|
| | | public static String getBaseObjectId(PageParameters params) {
|
| | | return params.getString("hb", null);
|
| | | }
|
| | |
|
| | | public static String getSearchString(PageParameters params) {
|
| | | return params.getString("s", null);
|
| | | }
|
| | |
|
| | | public static String getSearchType(PageParameters params) {
|
| | | return params.getString("st", null);
|
| | | }
|
| | |
|
| | | public static int getPage(PageParameters params) {
|
| | | return params.getInt("page", 1); // index from 1
|
| | | }
|