You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Per Newgro <pe...@gmx.ch> on 2008/02/21 19:30:24 UTC

Can i add multiple lines to a node-link in tree?

Hi *,

i would like to present a bit longer text in a tree node. One condition is 
that the tree can't have the vertical scrollbar. Thus if i a my text FF and 
IE are presenting empty notes, because text doesnt fit into visible area. My 
i add a break or something so that the link will be presented with 2 lines as 
one node?

I hope i explained my problem well.

Thanks for helping me out here
Per

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can i add multiple lines to a node-link in tree?

Posted by Thomas Kappler <tk...@googlemail.com>.
On Fri, Feb 29, 2008 at 12:25 PM, Newgro <pe...@gmx.ch> wrote:
>
>  I exchanged the tree-table by tree and have the same problem.
>  Can you please provide me a little example how you did this?

Extend BaseTree and let newNodeComponent() return a MultiLineLabel.
My code here is more complex and not suitable as an example.

Thomas


>  Cheers
>  Per
>  --
>  View this message in context: http://www.nabble.com/Can-i-add-multiple-lines-to-a-node-link-in-tree--tp15617892p15756637.html
>
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can i add multiple lines to a node-link in tree?

Posted by Newgro <pe...@gmx.ch>.
I exchanged the tree-table by tree and have the same problem.
Can you please provide me a little example how you did this?

Cheers
Per
-- 
View this message in context: http://www.nabble.com/Can-i-add-multiple-lines-to-a-node-link-in-tree--tp15617892p15756637.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can i add multiple lines to a node-link in tree?

Posted by Matej Knopp <ma...@gmail.com>.
The problem is that TreeTable doesn't use <table> for building the
actual layout. So it's not something easily fixable. It's on my todo
list to rework the TreeTable to use <table> but I'm kinda short of
time right now.

-Matej

On Fri, Feb 29, 2008 at 11:58 AM, Newgro <pe...@gmx.ch> wrote:
>
>  Hello Matej,
>
>  is there a cause for fix single line? Or is it only not implemented yet?
>
>  Thanks
>  Per
>  --
>  View this message in context: http://www.nabble.com/Can-i-add-multiple-lines-to-a-node-link-in-tree--tp15617892p15756237.html
>
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Resizable and reorderable grid components.
http://www.inmethod.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can i add multiple lines to a node-link in tree?

Posted by Newgro <pe...@gmx.ch>.
Hello Matej,

is there a cause for fix single line? Or is it only not implemented yet?

Thanks
Per
-- 
View this message in context: http://www.nabble.com/Can-i-add-multiple-lines-to-a-node-link-in-tree--tp15617892p15756237.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can i add multiple lines to a node-link in tree?

Posted by Matej Knopp <ma...@gmail.com>.
It is not possible to do this with tree table. That is fixed for one line only.

-Matej

On Fri, Feb 29, 2008 at 11:26 AM, Newgro <pe...@gmx.ch> wrote:
>
>  I added a NRFE
>  https://issues.apache.org/jira/browse/WICKET-1384
>  https://issues.apache.org/jira/browse/WICKET-1384
>
>  Maybe someone will take care for this.
>
>  Thanks for your taken time
>  Cheers
>  Per
>  --
>  View this message in context: http://www.nabble.com/Can-i-add-multiple-lines-to-a-node-link-in-tree--tp15617892p15755831.html
>
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Resizable and reorderable grid components.
http://www.inmethod.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can i add multiple lines to a node-link in tree?

Posted by Newgro <pe...@gmx.ch>.
I added a NRFE 
https://issues.apache.org/jira/browse/WICKET-1384
https://issues.apache.org/jira/browse/WICKET-1384 

Maybe someone will take care for this.

Thanks for your taken time
Cheers
Per
-- 
View this message in context: http://www.nabble.com/Can-i-add-multiple-lines-to-a-node-link-in-tree--tp15617892p15755831.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can i add multiple lines to a node-link in tree?

Posted by Thomas Kappler <tk...@googlemail.com>.
On Thu, Feb 28, 2008 at 10:54 AM, Newgro <pe...@gmx.ch> wrote:

>  firstly sorry if i brought you to the wrong way - i use a treetable, not a
>  tree. My effects on code below is that the nodes are diplayed only in one
>  row. The second row is not visible.

OK, I have never used TreeTable, and I cannot test it right now, but
it should not affect the MultiLineLabel where it appears.  Perhaps
it's that the \n is the last character, try adding something after it.
 Other than that, no idea.

Thomas


>  My html:
>  <wicket:panel>
>   <form wicket:id="treeform">
>     <div class="tree" wicket:id="treeTable"></div>
>   </form>
>  </wicket:panel>
>
>  My data code
>  public String getName() {
>   StringBuilder sb= new StringBuilder();
>   sb.append("EZ: ").append(getPrice(getRoomRate().getPrice())).append(" €");
>   sb.append(" DZ: ").append(getPrice(getRoomRate().getPrice2())).append("
>  €\n"); <-- here the newline!!
>   sb.append("  (").append(getDate(getRoomRate().getFromDate()));
>   sb.append(" - ");
>   sb.append(getDate(getRoomRate().getToDate())).append(")");
>   return sb.toString();
>  }
>
>
>  Here is my code:
>
>     TreeTable tree = new TreeTable("treeTable", treeModel, columns) {
>
>       /**
>        * Represents a content of a cell in TreeColumn (column containing the
>  actual tree).
>        * This has been copied to switch the label to a multiline instance.
>        * @author Matej Knopp
>        * @author r.dieckmann
>        */
>       class MyTreeFragment extends Fragment {
>
>         /**
>          * Constructor.
>          * @param id the wicket:id of component
>          * @param node current
>          * @param level
>          * @param renderNodeCallback
>          *            The call back for rendering nodes
>          */
>         @SuppressWarnings("deprecation")
>         public MyTreeFragment(String id, final TreeNode node, int level,
>  final IRenderNodeCallback renderNodeCallback) {
>           super(id, "fragment");
>
>           add(newIndentation(this, "indent", node, level));
>           add(newJunctionLink(this, "link", "image", node));
>
>           MarkupContainer nodeLink = newNodeLink(this, "nodeLink", node);
>           nodeLink.add(newNodeIcon(nodeLink, "icon", node));
>           nodeLink.add(new MultiLineLabel("label", new
>  AbstractReadOnlyModel() {
>             /**
>              * @see
>  org.apache.wicket.model.AbstractReadOnlyModel#getObject()
>              */
>             public Object getObject() {
>               return renderNodeCallback.renderNode(node);
>             }
>           }));
>           add(nodeLink);
>         }
>       }
>
>       /**
>        * @see
>  org.apache.wicket.extensions.markup.html.tree.table.TreeTable#newTreePanel(org.apache.wicket.MarkupContainer,
>  java.lang.String, javax.swing.tree.TreeNode, int,
>  org.apache.wicket.extensions.markup.html.tree.table.TreeTable.IRenderNodeCallback)
>        */
>       @Override
>       protected Component newTreePanel(MarkupContainer pParent, String pId,
>  TreeNode pNode, int pLevel, IRenderNodeCallback pRenderNodeCallback) {
>         return new MyTreeFragment(pId, pNode, pLevel, pRenderNodeCallback);
>       }
>
>       /**
>        * @see
>  org.apache.wicket.extensions.markup.html.tree.DefaultAbstractTree#newNodeLink(org.apache.wicket.MarkupContainer,
>  java.lang.String, javax.swing.tree.TreeNode)
>        */
>       protected MarkupContainer newNodeLink(MarkupContainer pParent, String
>  pId, final TreeNode pNode) {
>         MarkupContainer m = newLink(pParent, pId, new ILinkCallback() {
>
>           /**
>            * @see
>  org.apache.wicket.extensions.markup.html.tree.DefaultAbstractTree.ILinkCallback#onClick(org.apache.wicket.ajax.AjaxRequestTarget)
>            */
>           public void onClick(AjaxRequestTarget target) {
>             if (!getTreeState().isNodeSelected(pNode)) {
>               getTreeState().selectNode(pNode, true);
>               onNodeLinkClicked(target, pNode);
>               updateTree(target);
>             }
>           }
>         });
>         DefaultMutableTreeNode t = (DefaultMutableTreeNode) pNode;
>         if (t.getUserObject() instanceof TreeModelCategoryBean) {
>           TreeModelCategoryBean c = (TreeModelCategoryBean)
>  t.getUserObject();
>           ICategoryTO categoryTO = c.getCategory();
>           m.setEnabled(categoryTO != null && categoryTO.isAvailable());
>         }
>         return m;
>       }
>
>       /**
>        * @see
>  org.apache.wicket.extensions.markup.html.tree.DefaultAbstractTree#onNodeLinkClicked(org.apache.wicket.ajax.AjaxRequestTarget,
>  javax.swing.tree.TreeNode)
>        */
>       protected void onNodeLinkClicked(AjaxRequestTarget pTarget, TreeNode
>  pNode) {
>         super.onNodeLinkClicked(pTarget, pNode);
>         DefaultMutableTreeNode dnode = (DefaultMutableTreeNode) pNode;
>         ITreeModelBean current = (ITreeModelBean) dnode.getUserObject();
>         if (current instanceof TreeModelCategoryBean) {
>           refreshNodes(pTarget, pNode);
>         } else if (current instanceof TreeModelPackageBean) {
>           refreshNodes(pTarget, dnode.getParent());
>         }
>       }
>
>       private void refreshNodes(AjaxRequestTarget pTarget, TreeNode
>  pCategoryNode) {
>         DefaultMutableTreeNode dnode = (DefaultMutableTreeNode)
>  pCategoryNode;
>         ITreeModelBean current = (ITreeModelBean) dnode.getUserObject();
>         if (current instanceof TreeModelCategoryBean) {
>           TreeModelCategoryBean c = (TreeModelCategoryBean) current;
>           getTreeState().expandNode(pCategoryNode);
>           TreeNode firstChild = dnode.getFirstChild();
>           selectAllRoomRates(this, pCategoryNode);
>           if (getTreeState().isNodeSelected(firstChild)) {
>             try {
>               onNodeChanged(pTarget, c.getCategory());
>             } catch (Exception e) {
>               ServiceOfferingCategoryPanel.this.handleException(e, pTarget);
>             }
>           }
>         }
>       }
>     };
>
>  Cheers
>  Per
>  --
>  View this message in context: http://www.nabble.com/Can-i-add-multiple-lines-to-a-node-link-in-tree--tp15617892p15733117.html
>
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Can i add multiple lines to a node-link in tree?

Posted by Newgro <pe...@gmx.ch>.
Thanks for your help,

firstly sorry if i brought you to the wrong way - i use a treetable, not a
tree. My effects on code below is that the nodes are diplayed only in one
row. The second row is not visible.

My html:
<wicket:panel>
  <form wicket:id="treeform">
    <div class="tree" wicket:id="treeTable"></div>
  </form>
</wicket:panel>

My data code
public String getName() {
  StringBuilder sb= new StringBuilder();
  sb.append("EZ: ").append(getPrice(getRoomRate().getPrice())).append(" €");
  sb.append(" DZ: ").append(getPrice(getRoomRate().getPrice2())).append("
€\n"); <-- here the newline!!
  sb.append("  (").append(getDate(getRoomRate().getFromDate()));
  sb.append(" - ");
  sb.append(getDate(getRoomRate().getToDate())).append(")");
  return sb.toString();
}


Here is my code:

    TreeTable tree = new TreeTable("treeTable", treeModel, columns) {

      /**
       * Represents a content of a cell in TreeColumn (column containing the
actual tree).
       * This has been copied to switch the label to a multiline instance.
       * @author Matej Knopp
       * @author r.dieckmann
       */
      class MyTreeFragment extends Fragment {

        /**
         * Constructor.
         * @param id the wicket:id of component
         * @param node current 
         * @param level
         * @param renderNodeCallback
         *            The call back for rendering nodes
         */
        @SuppressWarnings("deprecation")
        public MyTreeFragment(String id, final TreeNode node, int level,
final IRenderNodeCallback renderNodeCallback) {
          super(id, "fragment");

          add(newIndentation(this, "indent", node, level));
          add(newJunctionLink(this, "link", "image", node));

          MarkupContainer nodeLink = newNodeLink(this, "nodeLink", node);
          nodeLink.add(newNodeIcon(nodeLink, "icon", node));
          nodeLink.add(new MultiLineLabel("label", new
AbstractReadOnlyModel() {
            /**
             * @see
org.apache.wicket.model.AbstractReadOnlyModel#getObject()
             */
            public Object getObject() {
              return renderNodeCallback.renderNode(node);
            }
          }));
          add(nodeLink);
        }
      }

      /**
       * @see
org.apache.wicket.extensions.markup.html.tree.table.TreeTable#newTreePanel(org.apache.wicket.MarkupContainer,
java.lang.String, javax.swing.tree.TreeNode, int,
org.apache.wicket.extensions.markup.html.tree.table.TreeTable.IRenderNodeCallback)
       */
      @Override
      protected Component newTreePanel(MarkupContainer pParent, String pId,
TreeNode pNode, int pLevel, IRenderNodeCallback pRenderNodeCallback) {
        return new MyTreeFragment(pId, pNode, pLevel, pRenderNodeCallback);
      }

      /**
       * @see
org.apache.wicket.extensions.markup.html.tree.DefaultAbstractTree#newNodeLink(org.apache.wicket.MarkupContainer,
java.lang.String, javax.swing.tree.TreeNode)
       */
      protected MarkupContainer newNodeLink(MarkupContainer pParent, String
pId, final TreeNode pNode) {
        MarkupContainer m = newLink(pParent, pId, new ILinkCallback() {

          /**
           * @see
org.apache.wicket.extensions.markup.html.tree.DefaultAbstractTree.ILinkCallback#onClick(org.apache.wicket.ajax.AjaxRequestTarget)
           */
          public void onClick(AjaxRequestTarget target) {
            if (!getTreeState().isNodeSelected(pNode)) {
              getTreeState().selectNode(pNode, true);
              onNodeLinkClicked(target, pNode);
              updateTree(target);
            }
          }
        });
        DefaultMutableTreeNode t = (DefaultMutableTreeNode) pNode;
        if (t.getUserObject() instanceof TreeModelCategoryBean) {
          TreeModelCategoryBean c = (TreeModelCategoryBean)
t.getUserObject();
          ICategoryTO categoryTO = c.getCategory();
          m.setEnabled(categoryTO != null && categoryTO.isAvailable());
        }
        return m;
      }

      /**
       * @see
org.apache.wicket.extensions.markup.html.tree.DefaultAbstractTree#onNodeLinkClicked(org.apache.wicket.ajax.AjaxRequestTarget,
javax.swing.tree.TreeNode)
       */
      protected void onNodeLinkClicked(AjaxRequestTarget pTarget, TreeNode
pNode) {
        super.onNodeLinkClicked(pTarget, pNode);
        DefaultMutableTreeNode dnode = (DefaultMutableTreeNode) pNode;
        ITreeModelBean current = (ITreeModelBean) dnode.getUserObject();
        if (current instanceof TreeModelCategoryBean) {
          refreshNodes(pTarget, pNode);
        } else if (current instanceof TreeModelPackageBean) {
          refreshNodes(pTarget, dnode.getParent());
        }
      }

      private void refreshNodes(AjaxRequestTarget pTarget, TreeNode
pCategoryNode) {
        DefaultMutableTreeNode dnode = (DefaultMutableTreeNode)
pCategoryNode;
        ITreeModelBean current = (ITreeModelBean) dnode.getUserObject();
        if (current instanceof TreeModelCategoryBean) {
          TreeModelCategoryBean c = (TreeModelCategoryBean) current;
          getTreeState().expandNode(pCategoryNode);
          TreeNode firstChild = dnode.getFirstChild();
          selectAllRoomRates(this, pCategoryNode);
          if (getTreeState().isNodeSelected(firstChild)) {
            try {
              onNodeChanged(pTarget, c.getCategory());
            } catch (Exception e) {
              ServiceOfferingCategoryPanel.this.handleException(e, pTarget);
            }
          }
        }
      }
    };

Cheers
Per
-- 
View this message in context: http://www.nabble.com/Can-i-add-multiple-lines-to-a-node-link-in-tree--tp15617892p15733117.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can i add multiple lines to a node-link in tree?

Posted by Thomas Kappler <tk...@googlemail.com>.
On Wed, Feb 27, 2008 at 2:55 PM, Newgro <pe...@gmx.ch> wrote:

>  i got it now with the multilinelabel. The text i add to a node contains an
>  \n. But i only see one row. I experimented a bit with the css, but i can't
>  get the tree node to show me 2 lines.

I just tried it, it works for me.  Added "\n bla" for testing:

add(new MultiLineLabel("sense", senseLabel + "\n bla"));

In the HTML it's a <span>.

No idea what the problem could be, best show the relevant code.

Cheers,
Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can i add multiple lines to a node-link in tree?

Posted by Newgro <pe...@gmx.ch>.
Hi Thomas,

i got it now with the multilinelabel. The text i add to a node contains an
\n. But i only see one row. I experimented a bit with the css, but i can't
get the tree node to show me 2 lines.

Do you have an idea on that?

Cheers
Per
-- 
View this message in context: http://www.nabble.com/Can-i-add-multiple-lines-to-a-node-link-in-tree--tp15617892p15713698.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can i add multiple lines to a node-link in tree?

Posted by Thomas Kappler <tk...@googlemail.com>.
Hi Per,

did you try using a wicket.markup.html.basic.MultiLineLabel?

If your tree nodes have more than one component, encapsulate them into
a Panel and return instances of that from
BaseTree.newNodeComponent(String id, IModel model).

Cheers,
Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org