How to set a selection in the GWT CellBrowser - gwt

somehow I have the feeling that I miss the forest for the trees. I have a CellBrowser filled with categorys and I have a search dialog to find the categorys by name. If I now select a category in the search dialog I also want it to be selected in the CellBrowser.
What I can already do is, find the node in the category tree. I also have the path from the root node to the leaf. I can open the nodes until the selected leaf (getCellBrowser().getRootTreeNode().setChildOpen(i, true). But how do I select the leaf itself?
And frankly speaking, is that the right way to do it? (I doubt it somehow)
Greetings Ole

Selecting an Object in the CellWidgets can be done by via the SelectionModel.
Assuming that you have defined a SelectionModel (i.e. SingleSelectionModel) for your CellBrowser/TreeViewModel you can just select a node in a CellBrowser by calling:
selectionModel.setSelected(MyObject, true);
MyObject is the object/type which is displayed as a node in your CellBrowser.
Note you can have different types/objects for each CellBrowser level.
SelectionModel will use either a KeyProvider or the equals function to select the object.

Related

Drools Business Central Workbench - Test Scenario: List subproperty on object

Is there a way to populate a List property on an object being tested under the "new style" test scenario?
I see some "legacy" test cases which seem to achieve this so am wondering if the new style test scenario handles this.
I added the List model to my test case, which enabled me to expand the sub-property on the object, however there is only one field available there, "empty" (boolean). Is there a way to add an object here? If it makes any difference, the model is an external java dependency.
Update
The reason I wasn't able to add the List of objects was because I didn't explicitly import that object dependency into the test. Once you import it you can follow the steps given in the answer below.
It's definitely possible to manage a List property under the Test Scenario Editor.
Please consider the following example: A Book class with a List<String> property named topics.
Creating a new Test Scenario assets, please select the column where you need to add the List property, and in the right part of the editor select the property expanding the Book class, as shown below:
Pressing Insert Data Ojbect button will assign the selected List property to the selected column:
To fill the data in the List property, please double click on the Insert value cell, in the first scenario data row. A popup will appear. Its aim is to fill data inside a collection
To add a value, please press the Add list value link in the bottom part of the popup. Here, you'll be able to fill a single item on the list
Repeat this step for all the items you need to add to the list. When completed, simply press to Save button
The popup will close and you should see the previously selected data cell filled with a label similar to List(2), the number represents the number of the items in the list.

Locating TreeObject in large Tree

I have a large tree and I can 'select' (i.e.highlight) any node of it. But if I have a large tree with all nodes expanded the user still needs to manually scroll down or up in order to locate the highlighted element. Is there a way which not only highlights the selected element but also locates it by automatically scrolling up/down in the tree?
TreePath path = createTreePath(editorID, treeObject);
getTreeViewer().setSelection(new TreeSelection(path), true);
getTreeViewer().refresh();
getTreeViewer().jumpToSelectedElement(true); // I need something like this. I made up the name of this imaginary method.
Use
public void reveal(Object elementOrTreePath)
As its name suggests elementOrTreePath can be a tree path or just an element.

Keep node selection from spreading to PropertySheet

I'm developing an application based on the netbeans platform.
The problem I'm having is this; I have a TopComponent that contains two panels, A and B, each with a ExplorerManager. I have two BeanTreeViews in each panel with different sets of nodes. When I change selection in the A panel, the nodes in the B panel will be created. Now, I'd like to be able to select a node in the B panel and see it's properties in the default property view. But I still have a selected node in the A panel, and therefore the property view only says 'Multiple objects.' Is there any way to keep the selection in the A panel from spreading to the PropertyView?
I'd like to be able to use NodeActions on both sets of nodes, and therefore I've added
associateLookup(new ProxyLookup(
ExplorerUtils.createLookup(PanelA.getExlporerManager(), map),
ExplorerUtils.createLookup(PanelB.getExplorerManager(), map)
));
to the TopComponent if i only associate PanelA's ExplorerManager then this isn't a problem.
Ok some after testing around I found a solution that works for me. Perhaps I was a bit quick to post this question. Anyway;
In the TopComponent I did
associateLookup(new ProxyLookup(
ExplorerUtils.createLookup(PanelA.getExlporerManager(), map)
));
Then only the Nodes in PanelA will be spread to the PropertyView. And then to get the NodeActions to work in PanelB, I made it implement Lookup.Provider, and created it's Lookup with
lookup = ExplorerUtils.createLookup(explorerManager, map);

how to create a cell browser in GWT

I am trying to create a cell browser , gettign help from GWT Showcase
Here i am creating CellBrowser
final MultiSelectionModel<MyDTO> selectionModel = new MultiSelectionModel<MyDTO>();
CellBrowser cellBrowser = new CellBrowser(new ContactTreeViewModel(selectionModel), null);
What i am not getting is that , What is ContactTreeViewModel? I have read the class contacttreeviewmodel in GwtShowcase , but couldnt understand, what is it exactly
thanks for the help
It's your view model, that is the interface between the tree view and your actual model (in MVC or MVP parlance). The CellBrowser (same for a CellTree) will ask your TreeViewModel for the nodes of the tree (in the form of NodeInfo objects), their children, how to display them (the associated Cell), how to select them (the associated SelectionModel: you can have a tree where you can only select nodes from the 2nd level, and/or only one node per branch at the 2nd level, or any node, or ...), and finally how to update them (the ValueUpdater).
Basically (disclaimer: this is a simplification of the process!), each level in the tree is a CellList that a NodeInfo is responsible for. The setDataDisplay associates that CellList with the NodeInfo so that changes to the model can be reflected in the tree, then the Cell, ProvidesKey, SelectionModel and ValueUpdater all have the same behavior as for a CellList. The CellBrowser asks your NodeInfo for them in order to setup the CellList. When expanding a node, the CellBrowser asks your TreeViewModel for the NodeInfo associated to the expanded node and uses it to create a new CellList.
The ContactTreeViewModel from the Showcase is thus a specific implementation of the TreeViewModel to display contacts (the model) as a tree.
The GWT showcase is an example of what you can do with code samples.
I think you should read the documentation of cell widgets before trying to understand such a code from scratch.
Here is the documentation, read it, and retry to understand the code.
https://developers.google.com/web-toolkit/doc/latest/DevGuideUiCellWidgets#available

wicket: Dropdownchoice

i have two dropdowns using same model and sets the value into it. Dropdown1 will visible on screen always and Dropdown2, will be visible for only one particular option choosen in Dropdown1. and i am making an query to the DB based on the selections in dropdowns.
But when i have both the dropdown first and then hide the second one, The value already set but the Dropdown2 is still avalible in my model, and making my query to fetch improper data.
So can any one suggest me an idea, how to set the value to null for the attribute which is actually set but dropdown2, if dropdown2 is inVisible.
(i tried to set the ModelObject to null, when making the dropdown2 invisible (using AjaxFormComponentupdateBehavior), but when i make the dropdown2, visible again, it returns null,even if i make any selection in it)
Are you using a LoadableDetachableModel ? try to explicitly detach model from that dropdown on setHide event. I did not try it though.