On Thu, Oct 23, 2014 at 10:59 PM, <[email protected]> wrote:
> Repository: wicket
> Updated Branches:
> refs/heads/improvingQueuing 1f04e9e43 -> 1128d3c50
>
>
> WICKET-5732 added IQueueRegion#getRegionMarkup to specify the markup of
> queue region.
>
> Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
> Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/1128d3c5
> Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/1128d3c5
> Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/1128d3c5
>
> Branch: refs/heads/improvingQueuing
> Commit: 1128d3c50804b8bb07f16882622f58558f4c8373
> Parents: 1f04e9e
> Author: Andrea Del Bene <[email protected]>
> Authored: Thu Oct 23 21:57:59 2014 +0200
> Committer: Andrea Del Bene <[email protected]>
> Committed: Thu Oct 23 21:57:59 2014 +0200
>
> ----------------------------------------------------------------------
> .../java/org/apache/wicket/IQueueRegion.java | 16 +++++++++
> .../java/org/apache/wicket/MarkupContainer.java | 8 ++++-
> .../apache/wicket/markup/html/MarkupUtil.java | 37 ++++++++++++++++++++
> .../wicket/markup/html/border/Border.java | 22 ++++++++++++
> .../panel/AssociatedMarkupSourcingStrategy.java | 36 ++-----------------
> .../apache/wicket/markup/html/panel/Panel.java | 23 ++++++++++++
> 6 files changed, 107 insertions(+), 35 deletions(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/wicket/blob/1128d3c5/wicket-core/src/main/java/org/apache/wicket/IQueueRegion.java
> ----------------------------------------------------------------------
> diff --git a/wicket-core/src/main/java/org/apache/wicket/IQueueRegion.java
> b/wicket-core/src/main/java/org/apache/wicket/IQueueRegion.java
> index 93fa2fa..6127782 100644
> --- a/wicket-core/src/main/java/org/apache/wicket/IQueueRegion.java
> +++ b/wicket-core/src/main/java/org/apache/wicket/IQueueRegion.java
> @@ -16,6 +16,8 @@
> */
> package org.apache.wicket;
>
> +import org.apache.wicket.markup.IMarkupFragment;
> +
>
> /**
> * Demarcates components that act as a root can dequeue children. These
> are usually components with
> @@ -31,6 +33,12 @@ package org.apache.wicket;
> */
> public interface IQueueRegion
> {
> + /**
> + * TODO: this interface might be a perfect candidate for Java 8
> interface default methods.
> + * Now methods implementation is in MarkupContainer while it
> should simply be in those
> + * class which implement this interface.
>
It is not clear to me:
1) when this TODO should be resolved/removed. I guess Wicket 8 (assuming it
requires Java 8). Then use "TODO Wicket 8:" as a prefix so it is easier
later to grep for it. We have used this approach for previous versions
2) Where the impls should be ? How #getRegionMarkup() can be implemented
here as default method ?
> + * */
> +
> /**
> * Creates a new {@link DequeueContext} that will be used to
> dequeue children of this region.
> *
> @@ -48,4 +56,12 @@ public interface IQueueRegion
> * actual dequeueing. The context's markup is retrieved using the
> {@link MarkupContainer#getAssociatedMarkup()}.
> */
> public void dequeue();
> +
> + /**
> + * Returns the markup to use for queuing. Normally, this is the
> markup of the component
> + * implementing this interface.
> + *
> + * @return the markup to use for queuing
> + */
> + public IMarkupFragment getRegionMarkup();
> }
>
>
> http://git-wip-us.apache.org/repos/asf/wicket/blob/1128d3c5/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
> ----------------------------------------------------------------------
> diff --git
> a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
> b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
> index a2b94a8..6b0ddb1 100644
> --- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
> +++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
> @@ -2112,7 +2112,7 @@ public abstract class MarkupContainer extends
> Component implements Iterable<Comp
> /** @see IQueueRegion#newDequeueContext() */
> public DequeueContext newDequeueContext()
> {
> - IMarkupFragment markup = getAssociatedMarkup();
> + IMarkupFragment markup = getRegionMarkup();
>
> if (markup == null)
> {
> @@ -2122,6 +2122,12 @@ public abstract class MarkupContainer extends
> Component implements Iterable<Comp
> return new DequeueContext(markup, this, false);
> }
>
> + /** @see IQueueRegion#getRegionMarkup() */
>
No need to use @see as javadoc. It is inherited by javadoc tool anyway.
Better use @Override annotation to make if safer for refactoring.
> + public IMarkupFragment getRegionMarkup()
> + {
> + return getAssociatedMarkup();
> + }
> +
> /**
> * Checks if this container can dequeue a child represented by the
> specified tag. This method
> * should be overridden when containers can dequeue components
> represented by non-standard tags.
>
>
> http://git-wip-us.apache.org/repos/asf/wicket/blob/1128d3c5/wicket-core/src/main/java/org/apache/wicket/markup/html/MarkupUtil.java
> ----------------------------------------------------------------------
> diff --git
> a/wicket-core/src/main/java/org/apache/wicket/markup/html/MarkupUtil.java
> b/wicket-core/src/main/java/org/apache/wicket/markup/html/MarkupUtil.java
> index 3831ede..614bbab 100644
> ---
> a/wicket-core/src/main/java/org/apache/wicket/markup/html/MarkupUtil.java
> +++
> b/wicket-core/src/main/java/org/apache/wicket/markup/html/MarkupUtil.java
> @@ -19,8 +19,11 @@ package org.apache.wicket.markup.html;
> import org.apache.wicket.MarkupContainer;
> import org.apache.wicket.Page;
> import org.apache.wicket.WicketRuntimeException;
> +import org.apache.wicket.markup.ComponentTag;
> import org.apache.wicket.markup.IMarkupFragment;
> import org.apache.wicket.markup.MarkupResourceStream;
> +import org.apache.wicket.markup.MarkupStream;
> +import org.apache.wicket.markup.WicketTag;
> import org.apache.wicket.util.lang.Args;
> import org.apache.wicket.util.visit.IVisit;
> import org.apache.wicket.util.visit.IVisitor;
> @@ -71,4 +74,38 @@ public class MarkupUtil
>
> return rtn[0];
> }
> +
> + /**
> + * Searches for {@code tagName} in the given {@code markup}.
> + *
> + * @param markup
> + * @param tagName
> + * @return The {@link IMarkupFragment} corresponding to {@code
> tagName}. Null, if such {@code tagName} is not found
> + */
> + public static IMarkupFragment findStartTag(final IMarkupFragment
> markup, final String tagName)
> + {
> + MarkupStream stream = new MarkupStream(markup);
> +
> + while (stream.skipUntil(ComponentTag.class))
>
Why not skipUntil(WicketTag.class) ?
The javadoc doesn't say anything about the requirement to be a WicketTag
> + {
> + ComponentTag tag = stream.getTag();
> + if (tag.isOpen() || tag.isOpenClose())
> + {
> + if (tag instanceof WicketTag)
> + {
> + WicketTag wtag = (WicketTag)tag;
> + if
> (tagName.equalsIgnoreCase(wtag.getName()))
> + {
> + return
> stream.getMarkupFragment();
> + }
> + }
> +
> + stream.skipToMatchingCloseTag(tag);
> + }
> +
> + stream.next();
> + }
> +
> + return null;
> + }
> }
>
>
> http://git-wip-us.apache.org/repos/asf/wicket/blob/1128d3c5/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
> ----------------------------------------------------------------------
> diff --git
> a/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
> b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
> index 934ab39..aba5b7f 100644
> ---
> a/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
> +++
> b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
> @@ -29,6 +29,7 @@ import org.apache.wicket.markup.MarkupFragment;
> import org.apache.wicket.markup.MarkupStream;
> import org.apache.wicket.markup.TagUtils;
> import org.apache.wicket.markup.WicketTag;
> +import org.apache.wicket.markup.html.MarkupUtil;
> import org.apache.wicket.markup.html.WebMarkupContainer;
> import org.apache.wicket.markup.html.panel.BorderMarkupSourcingStrategy;
> import org.apache.wicket.markup.html.panel.IMarkupSourcingStrategy;
> @@ -608,4 +609,25 @@ public abstract class Border extends
> WebMarkupContainer implements IComponentRes
> // components queued in border get dequeued into the
> border not into the body container
> addToBorder(component);
> }
> +
> + /**
> + * Returns the markup inside <wicket:border> tag.
> + * If such tag is not found, all the markup is returned.
> + *
> + * @see IQueueRegion#getRegionMarkup()
> + */
> + @Override
> + public IMarkupFragment getRegionMarkup()
> + {
> + IMarkupFragment markup = super.getRegionMarkup();
> +
> + if (markup == null)
> + {
> + return markup;
> + }
> +
> + IMarkupFragment panelMarkup =
> MarkupUtil.findStartTag(markup, BORDER);
>
copy/paste error ?
borderMarkup as a variable name sounds more correct
> +
> + return panelMarkup != null ? panelMarkup : markup;
>
could panelMarkup be null ?! In what cases ?
> + }
> }
>
>
> http://git-wip-us.apache.org/repos/asf/wicket/blob/1128d3c5/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java
> ----------------------------------------------------------------------
> diff --git
> a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java
> b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java
> index a16707d..0ac0647 100644
> ---
> a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java
> +++
> b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java
> @@ -28,6 +28,7 @@ import org.apache.wicket.markup.MarkupStream;
> import org.apache.wicket.markup.TagUtils;
> import org.apache.wicket.markup.WicketTag;
> import org.apache.wicket.markup.html.HeaderPartContainer;
> +import org.apache.wicket.markup.html.MarkupUtil;
> import org.apache.wicket.markup.html.WebMarkupContainer;
> import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
> import org.apache.wicket.util.lang.Args;
> @@ -99,7 +100,7 @@ public abstract class AssociatedMarkupSourcingStrategy
> extends AbstractMarkupSou
> }
>
> // Find <wicket:panel>
> - IMarkupFragment markup = findStartTag(associatedMarkup);
> + IMarkupFragment markup =
> MarkupUtil.findStartTag(associatedMarkup, tagName);
> if (markup == null)
> {
> throw new MarkupNotFoundException("Expected to
> find <wicket:" + tagName +
> @@ -129,39 +130,6 @@ public abstract class
> AssociatedMarkupSourcingStrategy extends AbstractMarkupSou
> }
>
> /**
> - * Search for <wicket:panel ...> on the same level.
> - *
> - * @param markup
> - * @return null, if not found
> - */
> - private IMarkupFragment findStartTag(final IMarkupFragment markup)
> - {
> - MarkupStream stream = new MarkupStream(markup);
> -
> - while (stream.skipUntil(ComponentTag.class))
> - {
> - ComponentTag tag = stream.getTag();
> - if (tag.isOpen() || tag.isOpenClose())
> - {
> - if (tag instanceof WicketTag)
> - {
> - WicketTag wtag = (WicketTag)tag;
> - if
> (tagName.equalsIgnoreCase(wtag.getName()))
> - {
> - return
> stream.getMarkupFragment();
> - }
> - }
> -
> - stream.skipToMatchingCloseTag(tag);
> - }
> -
> - stream.next();
> - }
> -
> - return null;
> - }
> -
> - /**
> * Search the child's markup in the header section of the markup
> *
> * @param container
>
>
> http://git-wip-us.apache.org/repos/asf/wicket/blob/1128d3c5/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java
> ----------------------------------------------------------------------
> diff --git
> a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java
> b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java
> index 0a2456b..1520c07 100644
> ---
> a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java
> +++
> b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java
> @@ -17,6 +17,8 @@
> package org.apache.wicket.markup.html.panel;
>
> import org.apache.wicket.IQueueRegion;
> +import org.apache.wicket.markup.IMarkupFragment;
> +import org.apache.wicket.markup.html.MarkupUtil;
> import org.apache.wicket.markup.html.WebMarkupContainer;
> import org.apache.wicket.model.IModel;
>
> @@ -81,4 +83,25 @@ public abstract class Panel extends WebMarkupContainer
> implements IQueueRegion
> {
> return new PanelMarkupSourcingStrategy(false);
> }
> +
> + /**
> + * Returns the markup inside <wicket:panel> tag.
> + * If such tag is not found, all the markup is returned.
> + *
> + * @see IQueueRegion#getRegionMarkup()
> + */
> + @Override
> + public IMarkupFragment getRegionMarkup()
> + {
> + IMarkupFragment markup = super.getRegionMarkup();
> +
> + if (markup == null)
> + {
> + return markup;
> + }
> +
> + IMarkupFragment panelMarkup =
> MarkupUtil.findStartTag(markup, PANEL);
> +
> + return panelMarkup != null ? panelMarkup : markup;
> + }
> }
>
>