Updated Branches: refs/heads/wicket-1.5.x a61993c3d -> 31a695336
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/31a69533 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/31a69533 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/31a69533 Branch: refs/heads/wicket-1.5.x Commit: 31a69533610453b523bf2c2d3ef87233aada7039 Parents: a61993c Author: Peter Ertl <[email protected]> Authored: Mon Sep 3 19:26:43 2012 +0200 Committer: Peter Ertl <[email protected]> Committed: Mon Sep 3 19:33:05 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/31a69533/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/31a69533/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 5c1e1e6..f89a720 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,8 +23,10 @@ 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.html.IHeaderResponse; +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; @@ -63,13 +65,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); @@ -85,10 +108,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; @@ -109,6 +143,10 @@ public class DebugBar extends DevUtilsPanel } } }); + + section.add(new Image("removeImg", new PackageResourceReference(DebugBar.class, "remove.png"))); + + return section; } @Override
