Updated Branches: refs/heads/master ebbe6f1c4 -> 788a23497
WICKET-4745 Allow to set initial state of DebugBar to expanded / collapsed Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/788a2349 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/788a2349 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/788a2349 Branch: refs/heads/master Commit: 788a23497e3aae423877cb04c3c790e20dee545b Parents: ebbe6f1 Author: Peter Ertl <[email protected]> Authored: Mon Sep 3 19:26:43 2012 +0200 Committer: Peter Ertl <[email protected]> Committed: Mon Sep 3 19:26:43 2012 +0200 ---------------------------------------------------------------------- .../apache/wicket/devutils/debugbar/DebugBar.html | 2 +- .../apache/wicket/devutils/debugbar/DebugBar.java | 42 ++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/788a2349/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.html ---------------------------------------------------------------------- diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.html b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.html index f72f495..f6db5d2 100644 --- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.html +++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.html @@ -22,7 +22,7 @@ <wicket:panel> <a id="wicketDebugBarCollapse" onclick="wicketDebugBarCollapse();"><img wicket:id="logo" src="wicket.png" alt="Wicket" /></a> - <span id="wicketDebugBarContents"> + <span id="wicketDebugBarContents" wicket:id="content"> <span wicket:id="contributors"><span wicket:id="contrib" class="contributor"></span></span> <a id="wicketDebugBarRemove" onclick="wicketDebugBarRemove();"><img wicket:id="removeImg" src="remove.png" alt="Remove" /></a> </span> http://git-wip-us.apache.org/repos/asf/wicket/blob/788a2349/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java ---------------------------------------------------------------------- diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java index beb14b2..9a58821 100644 --- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java +++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java @@ -23,10 +23,12 @@ import org.apache.wicket.Application; import org.apache.wicket.AttributeModifier; import org.apache.wicket.Component; import org.apache.wicket.MetaDataKey; +import org.apache.wicket.behavior.AttributeAppender; import org.apache.wicket.devutils.DevUtilsPanel; import org.apache.wicket.markup.head.CssHeaderItem; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.image.Image; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; @@ -65,13 +67,34 @@ public class DebugBar extends DevUtilsPanel private static final long serialVersionUID = 1L; }; + /** * Construct. + * <p/> + * Create debug bar (initially expanded) * * @param id + * component id + * + * @see #DebugBar(String, boolean) */ public DebugBar(final String id) { + this(id, true); + } + + /** + * Construct. + * + * @param id + * component id + * @param initiallyExpanded + * {@code true} to show debug bar initially expanded + * + * @see #DebugBar(String) + */ + public DebugBar(final String id, boolean initiallyExpanded) + { super(id); setMarkupId("wicketDebugBar"); setOutputMarkupId(true); @@ -87,10 +110,21 @@ public class DebugBar extends DevUtilsPanel })); add(new Image("logo", new PackageResourceReference(DebugBar.class, "wicket.png"))); - add(new Image("removeImg", new PackageResourceReference(DebugBar.class, "remove.png"))); + + add(contentSection("content", initiallyExpanded)); + } + + private Component contentSection(final String id, boolean initiallyExpanded) + { + WebMarkupContainer section = new WebMarkupContainer(id); + if (!initiallyExpanded) + { + section.add(AttributeModifier.append("style", "display:none").setSeparator(";")); + } + List<IDebugBarContributor> contributors = getContributors(); - add(new ListView<IDebugBarContributor>("contributors", contributors) + section.add(new ListView<IDebugBarContributor>("contributors", contributors) { private static final long serialVersionUID = 1L; @@ -111,6 +145,10 @@ public class DebugBar extends DevUtilsPanel } } }); + + section.add(new Image("removeImg", new PackageResourceReference(DebugBar.class, "remove.png"))); + + return section; } @Override
