Container swapping or component swapping - lwuit

I have four buttons at the bottom of my form. Clicking on any of these buttons results into a container preparation. In this container I've five components(includes buttons) and this container can be in three states(changes on button click which is inside the container).
By three states I mean every time I press a button which is added to this container as a component I need to replace a few/ add one or two components and then display the container again.
Now, here I'm confused whether should I go for the replacement of the components which are there inside the container or should I create a new container on every button click and swap the whole container itself.
PS:more concerned about the performance.
regards.

You can add and remove element from the container with addComponent() and removeComponent(). Is is quite similar to an vector of elements.
I wrote about an example for Codename One, where I swap components in a grid:
http://meier-online.com/en/2012/10/codename-one-mirror-grid/
This should work the same in lwuit (except perhaps the animation)
I don't think there is much performance difference between changing containers or changing components inside them. For repaint, the layout must be recalculated in both cases, and the container itself has not such a big memory footprint (like for example an image).
But you should notice that a Component has a method getParent(), so it is meant to have only one parent. So I would use only one container and swap the elements.

You can swap the components using a Container method called replace, where you only need to pass the new Component and the old one. You can use an animation too or set it to null.

Related

How to fix the shape of the dashbord, esp. its parts?

I have built my first dashboard in tableau. When I am logged in and look at this, it looks fine, it consists of 2 horizontal blocks (on the left a double one, on the right it consists of three vizes). When I am logged out and look at the dashboard the right part shows only 1st viz correct, the other two are diminished and you can bearly see them. What might be the reason?
There could be a few things going on. Without a picture, it may be one or more of these:
Use Layout
Containers.
The layout containers will ensure that each part of the dashboard is
exactly where you want it relative to a parent container.
Use tiled
layouts. Floating layouts may cause dashboard parts to be in different places depending on the screen size.
Check to see if you are using Fixed, Automatic or Range sized dashboards. These can also make a difference in appearance based on screen size.
If you are using custom fonts, install them on server to ensure this isn't a part of the problem.
Please do share a picture (or preferably, the workbook) so further investigation can happen.
In the Dashboard tab -> Layout pane, check the Item hierarchy.
When a viz/sheet is dragged and dropped on to the dashboard, tableau, by default arranges them in tiled container.
If you have adjusted the width manually, disable the option fixed width which is pin symbol when sheet is selected.
Make sure that no tiled containers are present and all the sheets are dropped into respective Horizontal containers.
Adjust the width of the viz in the sheet to fit in the view.
These are some common resolutions. Share screenshot for much accurate solution.

How to set a fixed part sash container data value

I am trying to make different UI layouts for my e4 RCP application depending on the resolution. I am trying to set a fixed container data value for my parts but have no idea how to do this. Basically in the layout below I have a partstash container with a part and another partstash with two parts. I want the partstashes to be a fixed size and not resizeable. How do i achieve this? Alternatively is there a way to ensure that the content within a stash container will auto resize and always fit?
Add the tag NoMove to the 'Part Sash Container' containing the parts that should not be resizable.
So here:
Setting the NoMove tag prevents the child part stacks and sash container from being resized

GTK3: Making a container aligned to bottom, filling horizontal space but not vertical

all.
I am writing an app in C with GTK3 and using Glade to build the UI.
What I am trying to do is making a container that will stay on the bottom of the frame, filling the horizontal space but not vertical. I will place a few buttons there and don't want them loose in the frame. Right now I just have enough code to show the window to see how it looks in runtime, focusing just on UI.
What I have tried so far:
GtkBox: would be perfect if I could adjust its height so I have free space above it, for another container. But it seems to take whatever free space is left (that is, the whole screen).
GtkPaned: would be perfect if I could prevent it from being resized in runtime and hide the handle. But, well, this is the purpose of this widget, so it doesn't seem to be possible.
GtkGrid: same thing as GtkBox.
For those who already worked with Borland C++ Builder or Delphi, it is the functionality of a "Panel" I'm trying to repeat. That is, you drop the container in the frame, align it to bottom (which makes it fill the horizontal space) and then you adjust the height in design time.
Any ideas? If you need more information, just let me know.
*EDIT: Alexander, this is when I try to expand on your comment, that is, using more than 1 button and container inside a container (see top right of Glade for the hierarchy).
When all buttons have Expand "Off", which works for 1 button, and when it is "On" (then I don't get to adjust the height anymore).
"No" to all buttons
"Yes" to all buttons
The simpliest solution: take GtkBox and use gtk_box_pack_end.
Another way is to control container align and expand behaviour (use gtk_widget_set_halign/gtk_widget_set_valign and gtk_widget_set_hexpand/gtk_widget_set_vexpand on the container itself)
Edit: didn't notice you are using glade. Create a gtkbox, add a child and change child's pack type
Also notice: if you want to add container near another container, you should pack both containers in another container.

TabItems versus Parented TRectangles - Firemonkey Mobile Application

What would be more efficient in a kinda big application for a mobile application? Make a separate TabItem for each menu item or have one TabItem with an empty Rectangle that will become parent of the form of each Menu Item's Unit?
(I assume you mean reparenting the controls on a child form to appear within a container on your main form. If so you'll need to use (e.g.) a TLayout which will handle child controls better rather than a TRectange).
It depends what you mean by 'efficient'.
One big form will take longer at start up and consume more memory.
Creating content on demand will take longer at run time as each form is created and destroyed.

Add paging animation to CellTable in GWT

I'm trying to come up with way to animate a page change on a CellTable in GWT which would work the same way as changing tabs on (http://gwt.google.com/samples/Showcase/Showcase.html#!CwTabLayoutPanel). In other words the new table page would slide in from the top (or bottom for that matter).
The CellTable uses a SimplePager to initiate the page change at the moment.
Thanks, Matyas
There's no way to do that in simple way, because to make slide animation you have to have at least 2 already rendered pages: first one that is shifted out and second one that replaces first. In showcase example with animated tabset all tabs are rendered and are ready to use, but CellTable with SimplePager has no rendered pages except visible one - new page is simply rendered just directly into CellTable body.
So, if you really want to create such effect using CellTable and Pager, you have to implement your own pair of CellTable and Pager that will do following:
Keep 2 containers with rendered rows: one is visible, second is hidden.
CellTable body should have viewport (just a <div> with "overflow:hidden" CSS rule) that will have both containers inside.
When pager change page, you have to force CellTable to render new rows into hidden container.
When new data was rendered, place your hidden container into proper position to make illusion that it continues visible one, and make it visible;
Provide animation that will move both containers into new positions. I'd recommend do not use coding for animations (e.g. Timer) - much better and effective to use CSS3 transformation rules (see "CSS3 transform Property" and/or "CSS3 transition Property").
When animation finished, make first container hidden and switch pointers to visible and hidden containers - so that you return to initial state.
Hope this helps.