GXT: Different context menu for the columns of a tree grid - gwt

I'm using GXT 3.1.4 with GWT 2.7.0 and I'm in the process of migrating a tree grid from GXT 2 to GXT 3. This tree grid displayed a different context menu for each column and also the menu contained different entries depending on the value displayed in the cell or some other properties of the model.
This was done by overriding the onMouse method of the column config that was used there, where we had easy access to the model and the menu for that grid was constructed and set inside that method. How can this be achieved in GXT3? I need to easily identify the cell that was right clicked and access the model behind.
Thanks.

Related

How to retrieve data from a dynamic changing DBRef in MongoDB

I would like to build the following architecture:
There are 3 models - projects, views, and components.
A component, with different attributes for each type, is an item on a view or on a different component, and thus the blue lines. A view is an item on a project or on a different view (red lines).
I need to implement it in MongoDB (is there any other preferable database?).
How should I build the entities in spring to dynamically get the parent's data from the correct table (for components - sometimes it's from the components table and sometimes from the views table)?
Thanks!

How to do "in-place editing" of a JFace Table?

In WPF (.net), when a DataGrid is made editable and set to an observable collection, there is a placeholder row. When one clicks on it, a new element is added to the backing collection and the table is put into edit mode.
Is something like this possible with JFace Table Viewers as well?
The only solution I can think of is to create a custom observable list that delegates to the "real" list I want to observe, but always adds an additional placeholder object to the end, which gets inserted into the "real" list as soon as it is edited. But that seems a bit hackish to me...

NatTable cell selection provider

Although NatTable already has a class RowSelectionProvider, my data is provided through cells, not rows, so I cannot use this class. Is it possible to create a class CellSelectionProvider, or it would be too difficult?
What I want to do is select a cell in the NatTable, which is linked to an EObject. Then select the EObject in the editor and show its properties in the properties view. The first part I'm able to do, but not the second.
I've seen some tutorials about how connect to the properties view using JFace viewers as the selection provider, but nothing related to NatTable.
The ISelectionProvider interface specifies a getSelection() and a setSelection() method. The selection in NatTable is implemented via the SelectionLayer. While it should be quite easy to implement getSelection() based on the SelectionLayer it could become quite difficult to implement setSelection() in a general way. Since you are working with a model based approach it is maybe possible for you to get the cell coordinates for the element that is sent via an ISelection to correctly implement setSelection(), but typically this is not possible as the same value in a column can be set for multiple rows.
Maybe you also don't need setSelection() and you can implement it empty as you only want to provide a selection to the properties view. But that also depends on your use case and what you want to achieve in whole.

How to create columns dynamically in MVVM

i have to create a dialog where columns has to be generated at run time, earlier i was using WPF data grid so generating columns at runtime was not a problem. Now i have to use View Model i need to have properties for whatever fields i want to display in view as columns. the number of columns are not known at design time, its not possible for set binding for the data grid.It will be crazy if i create properties at runtime using reflection, is there any way that i can bind runtime generated fields to a data grid column.
If you're on .NET 4 you can use ExpandoObject. It implements INotifyPropertyChanged for you.

GWT SelectionModel in Cell widgets - setSelected by key?

Is there any way to select items by key with GWT's selection model? setSelected only seems to take an object from which it can derive a Key, but using that function means I have to construct a sort of fake object. If my KeyProvider ever changes, that part of my code could break without my knowledge, so I'd like to just construct a key directly somehow.
"I have a celltable that shows a list of entities. When the user creates a new entity, I want to refresh the list (which will have the new entity) and automatically select the new entity."
I have this behaviour in my app as well. I manipulate the ListDataProvider. I find the item or items of interest, move them to the top of the list, call the selection model to set them to selected, and refresh the attached data displays. I use the same approach for picklist tables I use when I want to pre-select the default choices for the user (usually based on the item that is spawning the picklist) and move them to the top of the list. I spent a lot of time looking through the selection model api and there is nothing for keys. I suspect that the GWT designers figured it wasn't necessary, since you have access to the ListDataProvider. Find the items of interest there and then call the selection model select method on those specific objects. I can see their point -- replicating the functionality in ListDataProvider and SelectionModel would blur the distinction between the two classes, and perhaps limit the reusability of the SelectionModel construction in other (future) data structures that don't use keys.