vaadin 7 - move data between sub windows - vaadin

I have the main UI class with a button that shows a subwindow when clicked. That subwindow has a textField and a button. When you press the subwindow's button, another sub window opens. You could call it the sub-sub window. This sub-sub window has a textfield and a button that will close this sub-sub window. I would like to update the textfield in the subwindow when i close this sub-sub window with the textfield value on the sub-sub window. is there a way to do this without creating everything on the main UI Class? I would like to create 2 classes for these sub windows and would like to pass the data back. I got it to work by putting everything on the main UI class but i thought there would be a better way.
TIA,
Thomas Kim

You can either bind all your components which acces shared data to same model, using Vaadin Data Binding or you can use Events to propagate value changes from subwindows to whichever component may be concerned.
Consider using Model View Presenter pattern to structure you view layer. There is a nice article to explain basics of MVP and its implementation in Vaadin.
https://vaadin.com/web/magi/home/-/blogs/model-view-presenter-pattern-with-vaadin
This approach will not only solve your problem, but also lead to better separated and maintable presentation layer.

Related

how to implement non-modal dialog in IOS like this (image attached)?

Question: How would one best implement non-modal dialog in IOS like this (image attached)? Allow ability to drag move map still and select (long press) another location, which then that detail is populated in the pop-up "non-modal" dialog. Dialog can have ability to "delete" / "add to favourites" etc.
To clarify:
I'm asking how to implement the dialogs in the image I have marked "Non Modal Popup"
so for the iPad/horizontal regular case, I'm highlighting the dialog would be associated with the ViewController on the right, so therefore in this case the user could still drag the map within VC2, but also access/use VC1 as well
Some notes re my pondering:
can UIViewController.present NOT be used here as it is modal? If it can be used what settings to get this working?
it not would you recommend using an (a) separate UIViewControllerto implement, and show it up using the manual means of adding a UIViewController, OR (b) is it better to just keep it as a UIView in this case? In either of these cases one would have to do any adaption programmatically?

Instanciate object in parent with parameters

I'm trying to make a simple list editor in Dart, with Polymer, but I have some problems.
I will start by showing a screenshot of what it will look like.
design of the app
The left drawer is filled dynamically at run-time (a rest api is used to get the items).
The items are "MLayers" and clicking the button should add the corresponding "Layer" to the right part of the app.
The thing is I can't find a way to do this! I tried to launch a customEvent when the button is clicked but the method responsible of adding the new layer need the layer name (and I can't find a way to add parameters to customEvents...).
What do you recommand?
The structure of the app is:
mainApp
_ Drawer
__ MLayer
__ Layer
I think the class responsible of adding Layers should be the Drawer (in fact it contain the drawer AND the content). The Layer constructor should use the name (or ID) of the MLayer to display corresponding properties (lets say the MLayer "Dense" has properties "name" and "size"; the Layer is in fact an instance, while the MLayer is the maquette).
Thanks for the read!
EDIT: as requested, here's the code
Ok, so I didn't find the right way to do it, so I simply broke encapsulation by adding a property "MLayerDrawer" to my "MLayer" object and calling its method...
I'm still open to suggestions because this clearly isn't the right way to do it, it just work but is really dirty.

Bring Control to Front when Selected in the Structure Pane

I would like to build a Wizard component, where I can guid the user through different pages. When the last page is reached, an action is performed.
That component should work similar as the TPageControl, where I can create sheets at design-time. Creating that 'sheets' is already done, but my problem is, that the last added sheet is always on top of the other sheets, and I cannot select another one anymore (which are behind). In the TPageControl component, I can select a sheet in the Structure Pane, and it comes to the front, where can I put controls on it.
And this is my question: How can I bring a control (my wizard sheet) to the front, when it is selected in the Structre Pane?
I have to override the TWinControl.ShowControl function. That function is fired when you click in the structure pane on the child control. Then, I just need to invoke the BringToFront function of that child.

Make primefaces data table behaving like a split window?

I've a requirement to modify a primefaces datatable as the changes are made in another datatable. It should perform like the split window, where the user can type in the top window and he can see changes in the bottom window.
Can't you use the Collector widget?

Design-time drag and drop in Delphi?

Before Delphi 2006 (I think) introduced the TFlowPanel and TGridPanel, I did a control that was similar in concept. It still does a couple of things those controls do not do, and when upgrading my code to Delphi 2009, I decided to add a couple of enhancements to that as well.
Right now, the order of the child controls is determined by their creation order. The FlowPanel and GridPanel show a better way with ControlIndex and other filtered properties, but I was wondering if there is a way to handle drag and drop reordering in design-time? As far as I can tell, dragging an edit control and dropping it onto my panel doesn't call anything that I can access at design-time.
I was half-fantasising about a way to either detect the drop operation directly, or to perhaps detect when a control is moved so I can determine where it should go.
Any ideas?
Update:
OK, got it working. The container control was already overriding AlignControls to manage the placement of the controls. When you drag the nested control and drop it, AlignControls is again called. I then compared the new coordinates of the control with the other controls in the list and moved it to the appropriate position.
There were a couple of problems that I had to work through (mostly related to the many calls to AlignControls) but the basic concept is simple enough. Thanks to all the commenters for all the help.
You can't drag a control that's already on the form and drop it onto your panel. Dragging is only for moving a control, not for changing its parent. To change the parent, cut and paste.
If the control is already on your panel, and you want to move it to another position on your panel, then the panel can control the layout by overriding the TWinControl.AlignControls method. When a control is moved, its SetBounds method is called, and among the things tha happens is that it calls AlignControl(Self) on its parent window. That calls AlignControls. Look in Controls.pas, and you'll see that that's a complicated method, but it's what is responsible for the layout of the children on a control, and that's exactly what you're planning to change.
Perhaps some of these suggestions might help.
You can re-parent a control in the designer without having to do cut-and-paste. View the structure pane, and simply drag the visual control to the node of another parent in the structure pane. If you have things in a flowpanel, drag everything out of the flow panel and drag them back in the order that you want them to be.
(You can re-parent ANY visual control this way, without changing anything other than its parent. I highly recommend doing it this way.)
You can view the form as text, and move the declaration order around in there -- but obviously you'll need to be careful when editing the "resource" file directly.
You can set tab order in the designer, so you could make a different control based on tab order that works as you want. You can right click on the form and change the creation order of the non-visual controls, but that doesn't work with visual controls.
Have you tried to write an "OnDragDrop" event for your grid component, where you check if your component is in design mode?
I haven't written such a component yet, but I don't see why the event shouldn't trigger.

Resources