Grid.setSelectionModel(SelectionModel m);
The selection model affects what happens when a user tries to make a selection on a grid (think excel table). The method accepts any selection model as well as null. If a programmer wanted to disable selection on the grid they would intuitively do:
Grid.setSelectionModel(null); //Sets the selection model to null (disabled)
That would be what you and I would and without any prior knowledge of the library we would think this means that the selection model is disabled when it is not provided.
Obviously this doesn't work otherwise this post would be pointless if you try the above you get a null pointer exception. So how do we disable selection at all? Will through this obscure post we find out that in order to disable selection on the grid you must first provide it with a selection model and then disable it.
SelectionModel sm = Grid.getSelelctionModel();
sm.setLocked(true);
or in a more compact way
Grid.getSelectionModel().setLocked(true);
What's the problem? Well for one you still have a selection model in the system and all selection models have to implement this "locked" mode which means disabled. You can't just disable a selection model.
But you say "It is documented when you dig through the documentation" that much is true their documentation has this to say:
setLocked
public void setLocked(boolean locked)
- True to lock the selection model. When locked, all selection changes are disabled.
-
- Parameters:
locked
- true to lock
But the point is when there is such a thing as the interfaces behaving in an intuitive way. A programmer should take into consideration their fellow programmers and add convenience methods in order to give other programs an intuitive way of doing things. For example if the grid itself had a:
Grid.disableSelection(boolean disabled)
Which sole purpose is to set the selection model locked or unlocked this would be much easier to use.