You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Ralph Goers <Ra...@dslextreme.com> on 2006/02/13 06:43:49 UTC

Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

I'm having a hard time understanding this.  populate seems to go through 
and figure out what all the page labels should be, but it doesn't do 
anything with them.  I assume this is part of the discussion we've been 
having? As I said there I'm not even sure this is necessary. When Castor 
builds the layout each named item should be able to create its page 
label by doing:

Item item = getParent().getParent();
if (item == null || !(item instanceof NamedItem)) {
    this.label = this.name;
} else {
    this.label = item.getLabel() + "." + this.name;
}

cziegeler@apache.org wrote:
>
> Added: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java
> URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java?rev=377171&view=auto
> ==============================================================================
> --- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java (added)
> +++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java Sun Feb 12 05:09:54 2006
> @@ -0,0 +1,59 @@
> +/*
> + * Copyright 2006 The Apache Software Foundation.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.apache.cocoon.portal.profile.impl;
> +
> +import org.apache.avalon.framework.thread.ThreadSafe;
> +import org.apache.cocoon.portal.layout.CompositeLayout;
> +import org.apache.cocoon.portal.layout.Item;
> +import org.apache.cocoon.portal.layout.Layout;
> +import org.apache.cocoon.portal.layout.NamedItem;
> +import org.apache.cocoon.portal.profile.ProfileManagerAspect;
> +import org.apache.cocoon.portal.profile.ProfileManagerAspectContext;
> +import org.apache.cocoon.portal.scratchpad.Profile;
> +
> +/**
> + * $Id$
> + */
> +public class PageLabelProfileManagerAspect
> +    implements ProfileManagerAspect, ThreadSafe {
> +
> +    /**
> +     * @see org.apache.cocoon.portal.profile.ProfileManagerAspect#prepare(org.apache.cocoon.portal.profile.ProfileManagerAspectContext, org.apache.cocoon.portal.scratchpad.Profile)
> +     */
> +    public void prepare(ProfileManagerAspectContext context, Profile profile) {
> +        final Layout rootLayout = profile.getRootLayout();
> +        if ( rootLayout instanceof CompositeLayout ) {
> +            this.populate((CompositeLayout)rootLayout, "");
> +        }
> +        context.invokeNext();
> +    }
> +
> +    private void populate(CompositeLayout layout, String name) {
> +        for (int j = 0; j < layout.getSize(); j++) {
> +            final Item tab = layout.getItem(j);
> +            final StringBuffer label = new StringBuffer(name);
> +            if (label.length() > 0) {
> +                label.append(".");
> +            }
> +            label.append((tab instanceof NamedItem) ? ((NamedItem) tab).getName()
> +                                                    : Integer.toString(j));
> +            final Layout child = tab.getLayout();
> +            if (child != null && child instanceof CompositeLayout) {
> +                this.populate((CompositeLayout) child, label.toString());
> +            }
> +        }
> +    }
> +}
>
>
>   

Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

Posted by Ralph Goers <Ra...@dslextreme.com>.

Carsten Ziegeler wrote:
> Ralph Goers wrote:
>   
>>>> Item item = getParent().getParent();
>>>> if (item == null || !(item instanceof NamedItem)) {
>>>>     this.label = this.name;
>>>> } else {
>>>>     this.label = item.getLabel() + "." + this.name;
>>>> }
>>>>
>>>>     
>>>>         
>>>   
>>>       
>> I would create a setLabel method to NamedItem (probably protected or 
>> even private) and then have setName() call it.
>>     
> Ok, sounds good to me - I'll change that today. Don't we need a loop in
> the code you provided above? For example if there sub tabs are not
> directly nested inside the main tab?
>   
I don't believe a loop is required. Castor is creating each of the 
NamedItems and so it provides the "looping".

Ralph

Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

Posted by Carsten Ziegeler <cz...@apache.org>.
Ralph Goers wrote:
> 
>>>
>>> Item item = getParent().getParent();
>>> if (item == null || !(item instanceof NamedItem)) {
>>>     this.label = this.name;
>>> } else {
>>>     this.label = item.getLabel() + "." + this.name;
>>> }
>>>
>>>     
>>   
> I would create a setLabel method to NamedItem (probably protected or 
> even private) and then have setName() call it.
Ok, sounds good to me - I'll change that today. Don't we need a loop in
the code you provided above? For example if there sub tabs are not
directly nested inside the main tab?

Carsten

-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

Posted by Ralph Goers <Ra...@dslextreme.com>.

Carsten Ziegeler wrote:
> Ralph Goers schrieb:
>   
>> I'm having a hard time understanding this.  populate seems to go through 
>> and figure out what all the page labels should be, but it doesn't do 
>> anything with them.  I assume this is part of the discussion we've been 
>> having? As I said there I'm not even sure this is necessary. When Castor 
>> builds the layout each named item should be able to create its page 
>> label by doing:
>>
>> Item item = getParent().getParent();
>> if (item == null || !(item instanceof NamedItem)) {
>>     this.label = this.name;
>> } else {
>>     this.label = item.getLabel() + "." + this.name;
>> }
>>
>>     
> Yes, that's true. Now the question is: Where to put this code? We could
> add this to the item.
> My idea was to provide extensions to the profile manager which are able
> to post process the profile, like adding the page labels.
> This label will then picked up by the tab renderer - and this part is
> currently missing. Hmm, perhaps you're right and we can add this code
> directly to an item or named item. Have to think about it.
>   
I would create a setLabel method to NamedItem (probably protected or 
even private) and then have setName() call it.
>
>
> Carsten
>   

Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

Posted by Carsten Ziegeler <cz...@apache.org>.
Ralph Goers schrieb:
> I'm having a hard time understanding this.  populate seems to go through 
> and figure out what all the page labels should be, but it doesn't do 
> anything with them.  I assume this is part of the discussion we've been 
> having? As I said there I'm not even sure this is necessary. When Castor 
> builds the layout each named item should be able to create its page 
> label by doing:
> 
> Item item = getParent().getParent();
> if (item == null || !(item instanceof NamedItem)) {
>     this.label = this.name;
> } else {
>     this.label = item.getLabel() + "." + this.name;
> }
> 
Yes, that's true. Now the question is: Where to put this code? We could
add this to the item.
My idea was to provide extensions to the profile manager which are able
to post process the profile, like adding the page labels.
This label will then picked up by the tab renderer - and this part is
currently missing. Hmm, perhaps you're right and we can add this code
directly to an item or named item. Have to think about it.



Carsten
-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/