From 5bb79fbb553a11e6582392f658233cf58a4ceb11 Mon Sep 17 00:00:00 2001 From: Paul Martin <paul@paulsputer.com> Date: Wed, 06 Apr 2016 14:31:41 -0400 Subject: [PATCH] Fix for #1042 - Filestore items now shown as icons --- src/main/java/com/gitblit/wicket/WicketUtils.java | 64 +++++++++++++++++++++++++++++-- 1 files changed, 59 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/WicketUtils.java b/src/main/java/com/gitblit/wicket/WicketUtils.java index 2a34ca8..d9ff34a 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; @@ -42,9 +44,11 @@ import com.gitblit.Constants; import com.gitblit.Constants.AccessPermission; import com.gitblit.Constants.FederationPullStatus; +import com.gitblit.IStoredSettings; 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; @@ -53,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) { @@ -65,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) { @@ -186,9 +194,9 @@ return newImage(wicketId, "file_settings_16x16.png"); } - MarkupProcessor processor = new MarkupProcessor(GitBlitWebApp.get().settings()); String ext = StringUtils.getFileExtension(filename).toLowerCase(); - if (processor.getMarkupExtensions().contains(ext)) { + IStoredSettings settings = GitBlitWebApp.get().settings(); + if (MarkupProcessor.getMarkupExtensions(settings).contains(ext)) { return newImage(wicketId, "file_world_16x16.png"); } return newImage(wicketId, "file_16x16.png"); @@ -300,7 +308,9 @@ public static PageParameters newRepositoryParameter(String repositoryName) { Map<String, String> parameterMap = new HashMap<String, String>(); - parameterMap.put("r", repositoryName); + if (!StringUtils.isEmpty(repositoryName)) { + parameterMap.put("r", repositoryName); + } return new PageParameters(parameterMap); } @@ -318,6 +328,31 @@ } parameterMap.put("r", repositoryName); parameterMap.put("h", objectId); + 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); } @@ -443,6 +478,20 @@ return new PageParameters(parameterMap); } + public static PageParameters newTicketsParameters(String repositoryName, String... states) { + PageParameters tParams = newRepositoryParameter(repositoryName); + if (states != null) { + for (String state : states) { + tParams.add("status", state); + } + } + return tParams; + } + + public static PageParameters newOpenTicketsParameter(String repositoryName) { + return newTicketsParameters(repositoryName, TicketsUI.openStatii); + } + public static String getProjectName(PageParameters params) { return params.getString("p", ""); } @@ -471,6 +520,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