Tuesday, May 5, 2015

Setting CompositeCell HasCell width

Hello,

I am recently developing an application that is implementing a CellTable, where there are Columns where the underlying Cell object is a CompositeCell.  As you know, a CompositeCell has an underlying List<HasCell<T, C>>.  Generally, i can get this to work just fine when I am simply displaying text with a List<HasCell<Object, ?>>, with each HasCell containing a TextCell, or other Cells that take up a defined amount of visual real estate.  The problem that I encounter is when trying to interact with an EditableTextCell embedded within the CompositeCell, when its underlying value is an empty String.

Here is example code for reference...

        public void test() {

               CellTable<Object> table = new CellTable<Object>();

               table.setTableLayoutFixed(true);

               EditTextCell eCell = new EditTextCell();            

               HasCell<Object, ?> innerColumn = new Column<Object, String>(eCell) {

                       @Override

                       public String getValue(Object object) {

                               return "";

                       }

               };

               List<HasCell<Object, ?>> hasCellList = new ArrayList<HasCell<Object, ?>>();

               hasCellList.add(innerColumn);

               CompositeCell<Object> compCell = new CompositeCell<Object>(hasCellList);

               Column<Object, Object> outerColumn = new Column<Object, Object>(compCell) {

                       @Override

                       public Object getValue(Object object) {

                               return object;

                       }

               };

               table.addColumn(outerColumn, "Outer");

               table.setColumnWidth(outerColumn, 10, Unit.EM);

       }


As this example relates to my actual project, I find that the width of the outerColumn is rendered just fine.  And when eCell has a non-empty String, the cell can be clicked, and edited, and all of that.  However, in the case where the eCell gets an empty String, the clickable area (to edit its contents) is incredibly narrow, and very difficult to find unless you know what to look for.  Considering that i am able to interact with EditableTextCells with emtpy String values at the outerColumn level, I thought that all I would need to do is to define a width of innerColumn.  For the life of me, i cannot figure out how to set the width of innerColumn, as it is not directly attached to the CellTable.  How do I do that, or am I approaching this incorrectly?

Note that the example is a simplification, and that the reason I am using the CompositeCell to optionally render a TextCell or EditableTextCell conditionally based on the Object passed to the CompositeCell.

thanks,
Rob

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment