Can you create a CellTable composed of CellTables? - gwt

This is a GWT question.
I need to create a hierarchical view of a data set. Let me describe what this hierarchical view is supposed to be:
Lay down a rectangle that is 640 by 480 pixels on your screen.
Now embed 4 rectangles inside the rectangle from the previous step.
The 4 rectangles shall evenly take up the space from the enclosing rectangle.
Continue recursively embedding 4 rectangles inside each 4 rectangle...
So on and so forth until a stop condition (like stop recursing at level N).
I plan on doing this with GWT's CellTable. I know how to make a CellTable out of the various out-of-the-box Cell's (what I mean to say is: all the classes that implement the Cell interface ).
But I can't figure out how to make a CellTable of Widgets... or a CellTable of CellTables. I guess my question boils down to... How would you make a new Cell type that is: WidgetCell or CellTableCell?
UPDATE:
I found an answer that describes how to make a Cell out of a Widget: how-can-i-put-a-widget-in-a-celltable-cell
Given the above answer, is my original idea of making a CellTable out of CellTables practically feasible? Is there a more elegant solution? Am I on the right-track?

CellTables do not support widgets. Grid or FlexTable might work better for you, since they do accept widgets - you could make a Grid of CellTables, for instance. Unfortunately, there is no built-in solution that accepts widgets and provides paging.

Related

Nattable Cell with Multiple combination of images

We have a requirement to visualize a state of the cell.
Each cell represents user's DB CRUD access so each cell has four boolean flags for create, read, update and delete. To visualize, each cell should show four images with each image showing state of that flag.
We defined 8 labels (CREATE, NO_CREATE, READ, NO_READ etc) and adding these labels based on underlying model. So at any time, each cell will have 4 labels. We want to show 4 images in each cell with each image showing the state of corresponding flag.
Based on the research and from Dirk's suggestion, CellDecoratorPainter is the preferred approach. But each cell with a label is associated with one cell painter (in this case CellDecoratorPainter) so how do we use that to render combination of these images?
One approach I could think of is, instead of creating individual labels for READ, NO_READ etc., create 4x4x2 labels like READ_CREATE_UPDATE_DELETE, NO_READ_CREATE_UPDATE_DELETE and associate each of these labels with one cell painter decorator to paint series of images accordingly.
Not sure if that is the only possible approach. If any of you come across this type of situation, can you please share some thoughts?
PS: This is posted at Eclipse forums at https://www.eclipse.org/forums/index.php/m/1782700/#msg_1782700
It is suggested that we use custom image painter to achieve this as explained at https://www.eclipse.org/forums/index.php/m/1782739/#msg_1782739.
Snippet of response is
You could implement a custom ImagePainter that inspects the cell
labels and draws images based on the labels in the label stack. Or
stack CellPainterDecorators so that every decorator has an image as
decoration that is only painted in case of the cell label, and has
another decorator as base painter.
But honestly, writing a custom ImagePainter that inspects the labels and draws the images on occurence of a label seems to be more
intuitive.
We implemented CombinationImagePainter to achieve this and is available at https://gist.github.com/brsanthu/cd2f91da7777aa994e011f7acedd900a if you are interested.
We had a similar requirement wherein an image was to be displayed at the start and at the end. Almost the way you showed however we extended the AbstractTextPainter class and wrote the implementation according.

Different cell appearance for a single collection view

I was asking here about the option to make a collectionView with multiple cells since our cells have a different appearance for different indexs.
The answer was not sufficient because other then just create multiple cells and pick one for every index, you have all sorts of problems such as :
How can you register multiple classes ? collectionView.register(FlowViewCell.self
Reusable cells system gets crazy because they are different
Every action you do on a cell must be identified with its class and it becomes a mess.
So, I am searching for another way to do so with a single cell.
What would be a good way to set different buttons in the same position of a cell, and show/enable a different button with different indexes ?
So for index 1 I have 2 circle buttons, and for index 2 I have one large wide button? if you just put them on the same spot and hide one you get a strange design.
The answer you linked is what you are looking for.
We use 4 different types of cell in our app and we don't have any problem with it.
You don't have to register multiple classes, you can all create them in your storyboard (inside the collectionview), the system will register the classes for you.
And then you call the cells like explain in the answer.
The hard part is having different sizes, we only have two (large cell and square cell, so two square cells fit on the same level), more than that would be tricky, especially different height.
But apart from that you can have different content on each cell without any problem.

How can I enforce vertical alignment of GTK widgets across containers?

I'm using PyGTK on Windows to develop a small application.
How can I enforce vertical alignment of widgets across containers to achieve something like this?
In the mockup, widgets are in separate frames, but I want to maintain vertical alignment as if they were in the same gtk.Table. If I put them in the same table then I can't put a gtk.Frame around the groups of widgets.
Maybe it's already too late for you, but for other people that find this question. You can create an array of SizeGroup with 8 elements, and add to each element every widget that should go on the same column, this will make the width of each cell on the respective grid to be the same size, if all widgets are added, this will have the side effect of also align them vertically. Just be sure the amount of columns in the grid below is the same as above.
Also, if your labels need some special alignment there is currently a bug that does not let you use halign and valign when using SizeGroup, see https://bugzilla.gnome.org/show_bug.cgi?id=733981 .

Any "Grid Panel" with GXT?

I'm quite new to GXT. Is there a widget that is similar to a GWT native FlexTable with GXT?
Something that can display a widget in a grid fashion, set by something like setWidget(int row, int col) ?
I tried inserting a FlexTable in a LayoutContainer however it does not render properly. My requirement is not like a table grid with data, but much like a "grid panel" that will display widgets in a grid way.
I might compare your 'chessboard' with a spreadsheet - the rows/columns dont have particular meaning/data/widths/headers, symmetry and flexibility is what is important. In contrast, GXT's Grid (and GWT's CellTable, DataTable) is designed more like a database, where each column has particular meaning, and almost always a fixed (but somewhat flexible) number of columns, but the row count can grow.
I'd look into GWT's own FlexTable or Grid. If it doesn't work correctly with GXT 2's LayoutContainer, make sure you either add it before the LayoutContainer is added to a parent, or call layout() after adding it to be sure it is drawn.
Drawing a chessboard style grid with widgets means you are drawing a lot of widgets, which isn't going to be terribly fast/efficient. If you don't actually need widgets, but cells will suffice, I'd look into making a cell widget that draws the same cell over and over for a number of rows/columns, but with the specific data you need for each position.
If you have code that almost works, SO allows that to be posted, to perhaps discuss what you are doing, and how it might be done differently.

How can I force a ListBox to fill entire free area?

I put a ListBox into a tabele cell an want it to ocupy the whole cell (width="100% height="100%") and show as many rows as possible but:
not specifyng setVisibleItemCount causes to show a big dropdownbox (i want a list)
specifying setVisibleCout makes listbox to ignore height (it takes as much place as it needet to exacly display n rows)
i there a workaround ? (in Swing a number of wisible rows ia a funcion of height and I'd like it this way in gwt).
Thanks in advance
ListBox is a native GWT component, and that's the way it works. If you're using GWT 2.1 you can create your own CellRenderer
You could approximate a solution by calculating how many items should be shown based on the height you want.