From a502d96a860456ec5e8c96761db70f7cabb74751 Mon Sep 17 00:00:00 2001
From: Paul Martin <paul@paulsputer.com>
Date: Sat, 30 Apr 2016 04:19:14 -0400
Subject: [PATCH] Merge pull request #1073 from gitblit/1062-DocEditorUpdates

---
 src/main/java/com/gitblit/wicket/WicketUtils.java |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/gitblit/wicket/WicketUtils.java b/src/main/java/com/gitblit/wicket/WicketUtils.java
index d47390d..99c1e08 100644
--- a/src/main/java/com/gitblit/wicket/WicketUtils.java
+++ b/src/main/java/com/gitblit/wicket/WicketUtils.java
@@ -29,12 +29,14 @@
 import org.apache.wicket.Component;
 import org.apache.wicket.PageParameters;
 import org.apache.wicket.Request;
+import org.apache.wicket.behavior.AttributeAppender;
 import org.apache.wicket.behavior.HeaderContributor;
 import org.apache.wicket.behavior.SimpleAttributeModifier;
 import org.apache.wicket.markup.html.IHeaderContributor;
 import org.apache.wicket.markup.html.IHeaderResponse;
 import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.image.ContextImage;
+import org.apache.wicket.model.Model;
 import org.apache.wicket.protocol.http.WebRequest;
 import org.apache.wicket.resource.ContextRelativeResource;
 import org.eclipse.jgit.diff.DiffEntry.ChangeType;
@@ -46,6 +48,7 @@
 import com.gitblit.Keys;
 import com.gitblit.models.FederationModel;
 import com.gitblit.models.Metric;
+import com.gitblit.utils.DiffUtils.DiffComparator;
 import com.gitblit.utils.HttpUtils;
 import com.gitblit.utils.StringUtils;
 import com.gitblit.utils.TimeUtils;
@@ -54,6 +57,10 @@
 
 	public static void setCssClass(Component container, String value) {
 		container.add(new SimpleAttributeModifier("class", value));
+	}
+
+	public static void addCssClass(Component container, String value) {
+		container.add(new AttributeAppender("class", new Model<String>(value), " "));
 	}
 
 	public static void setCssStyle(Component container, String value) {
@@ -66,8 +73,8 @@
 		container.add(new SimpleAttributeModifier("style", background));
 	}
 
-	public static void setHtmlTooltip(Component container, String value) {
-		container.add(new SimpleAttributeModifier("title", value));
+	public static Component setHtmlTooltip(Component container, String value) {
+		return container.add(new SimpleAttributeModifier("title", value));
 	}
 
 	public static void setInputPlaceholder(Component container, String value) {
@@ -324,6 +331,31 @@
 		return new PageParameters(parameterMap);
 	}
 
+	public static PageParameters newDiffParameter(String repositoryName,
+			String objectId, DiffComparator diffComparator) {
+		Map<String, String> parameterMap = new HashMap<String, String>();
+		if (StringUtils.isEmpty(objectId)) {
+			return newRepositoryParameter(repositoryName);
+		}
+		parameterMap.put("r", repositoryName);
+		parameterMap.put("h", objectId);
+		parameterMap.put("w", "" + diffComparator.ordinal());
+		return new PageParameters(parameterMap);
+	}
+
+	public static PageParameters newDiffParameter(String repositoryName,
+			String objectId, DiffComparator diffComparator, String blobPath) {
+		Map<String, String> parameterMap = new HashMap<String, String>();
+		if (StringUtils.isEmpty(objectId)) {
+			return newRepositoryParameter(repositoryName);
+		}
+		parameterMap.put("r", repositoryName);
+		parameterMap.put("h", objectId);
+		parameterMap.put("w", "" + diffComparator.ordinal());
+		parameterMap.put("f", blobPath);
+		return new PageParameters(parameterMap);
+	}
+
 	public static PageParameters newRangeParameter(String repositoryName,
 			String startRange, String endRange) {
 		Map<String, String> parameterMap = new HashMap<String, String>();
@@ -382,6 +414,19 @@
 		parameterMap.put("h", objectId);
 		parameterMap.put("f", path);
 		parameterMap.put("pg", String.valueOf(pageNumber));
+		return new PageParameters(parameterMap);
+	}
+
+	public static PageParameters newFilestorePageParameter(int pageNumber, String filter) {
+		Map<String, String> parameterMap = new HashMap<String, String>();
+		
+		if (pageNumber > 1) {
+			parameterMap.put("pg", String.valueOf(pageNumber));
+		}
+		if (filter != null) {
+			parameterMap.put("s", String.valueOf(filter));
+		}
+		
 		return new PageParameters(parameterMap);
 	}
 
@@ -488,6 +533,11 @@
 		return params.getString("st", null);
 	}
 
+	public static DiffComparator getDiffComparator(PageParameters params) {
+		int ordinal = params.getInt("w", 0);
+		return DiffComparator.values()[ordinal];
+	}
+
 	public static int getPage(PageParameters params) {
 		// index from 1
 		return params.getInt("pg", 1);

--
Gitblit v1.9.1