Damians, Thanks for your reply. Your solution would put month, day and
year into a new table. The new table would be nested inside the cell
of the original table.  This is not quite what I need. I would like
three columns in the original table.

I have created a new class ListPanel. It is derived from HTMLPanel,
but it does not add <div> </div>.

BTW, I could not get java.util.regex.Pattern to work in GWT, so I
wrote my own replace function.

printNodeStack() helped me to debug the code. I left it in as
comments.



import java.util.Vector;

import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.user.client.ui.HTMLPanel;

public class ListPanel extends HTMLPanel{
    Vector<Node> aunts= new Vector<Node>(); // aunts should actually
be auntsOrUncles , but that's too long
    public ListPanel(String html) {
        super(html);
    }

/*
 Make the children of ListPanel into aunts/uncles of ListPanel
 The parent of ListPanel is just a temporary proxy. Remove it.
 ***********SomeLayout.ui.xml *************************
<tag1>
    <tag2>
         <my:ListPanel>
             text1
             <tag3> </tag3>
             <tag4> </tag4>
                ...
             <tagn> </tagn>
             text2
         </my:ListPanel>
    </tag2>
</tag1>
*********** Results ********************
<tag1>
             text1
             <tag3> </tag3>
             <tag4> </tag4>
                ...
             <tagn> </tagn>
             text2
</tag1>
 */

    @Override
    protected void onLoad() {
        super.onLoad();
//        printNodeStack("ListPanel.onLoad1", getElement());
        // turn children into uncles/aunts
        aunts.clear();
        Node proxyParent = getElement().getParentNode();
        aunts.add(proxyParent); // The proxy element becomes the first
sibling.

        for(Node child = getElement().getFirstChild();child != null;
child = child.getNextSibling()){
            aunts.add(child);
        }
        Element grandParent = proxyParent.getParentElement();
        for(int i = 1; i < aunts.size();i++){
            Node refChild = aunts.get(i-1);
            Node newChild  = aunts.get(i);
            grandParent.insertAfter(newChild, refChild);
        }

        // remove proxy element
        proxyParent.removeFromParent();
        aunts.remove(proxyParent);
        if(aunts.size()> 0){
//            printNodeStack("ListPanel.onLoad2", aunts.get(0));
        }
    }


//   static private void printNodeStack(String location, Node
elementI) {
//        Node previousElement = null;
//         for(int i = 1; i < 4 && elementI != null; i++){
//             if(i==1){
//                 System.out.println(location + " stack[" + i+"] " +
elementI.toString());
//             }else {
//                 String msg0 = previousElement.toString();
//                 String msg1 = elementI.toString();
//                 System.out.println(location + " stack[" + i+"] " +
replace(msg1,msg0, " Message"+(i-1) + " "));
//             }
//             previousElement = elementI;
//             elementI = elementI.getParentElement();
//         }
//    }
//   static private String replace(String contents, String match,
String replacement){
//        int beginIndex = 0;
//        StringBuffer buf = new StringBuffer();
//        for(int matchIndex = contents.indexOf(match); matchIndex !=
-1; matchIndex = contents.indexOf(match,beginIndex) ){
//            if(matchIndex != beginIndex){
//                buf.append(contents.substring(beginIndex,
matchIndex-1));
//            }
//            buf.append(replacement);
//            beginIndex = matchIndex+match.length();
//        }
//        if(beginIndex < contents.length()){
//            buf.append(contents.substring(beginIndex));
//        }
//        return buf.toString();
//    }


}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to