
Update: Additonal features have been added for Vault 2012. This article focuses on the Vault 2011 features.
You have a command or tab view in Vault Explorer. And you have your command and tab view handlers in place for when the user interacts with your control. These handlers get a Context object passed in so that your code can know things about the state of the application. More specifically, your code can determine which things have been selected.
Let's take a deeper look at these selection sets.
Each set is a collection of ISelection objects. Each object consists of three pieces of data. The Label is the display value of the things selected. The TypeId tells you what type of object is selected. The ID tells you the Vault ID of the thing selected. So the things you can do with a selection is dependant on what type it is.
TypeId |
Id meaning |
File |
File.MasterId |
Folder |
Folder.Id |
Item |
Item.Id |
Bom |
Item.Id |
Change Order |
ChangeOrder.Id |
Other |
"-1" Whatever is selected is not supported. |
None |
Not used |
Make sure to always check the type before you attempt to use the ID value. The HelloWorld sample in the SDK has a great example of not following this rule.
The Current Selection Set represents the currently selected thing, assuming the thing supports the selection set framework. It's possible to have nothing selected, so this set may be empty. But if you are running from a context menu, this should always always have at least 1 value.
Here is a list of things that can have selection sets :
- The navigation tree
- The main View grid
- The history tab (items only)
- The where used tab (items only)
- The change order tab
- The records tab (items only)
- The Find dialog
The Nav Selection Set represents the tree view on the left. If a Folder is selected, this will contain a selection type Folder with an ID value. For non-folder items, such as saved searches or the Item Master, you will get Other as the type with -1 as the ID. There should always be 1 value in this set.
The View Selection Set represents the selections in the main grid. It works pretty much how you would expect. In cases where there is a pop-up menu, like the find dialog, the View selection set is still from the main grid on the parent dialog.
The Preview Selection Set seems to be mostly useless for files. Even if you do have a file selected, it shows up as an Other type with -1 as the ID.
However, with Items, you can select BOM Items and get BOM selection data. The History and Where Used tabs both give Item selections as you would expect. For the other tabs (General, View and custom) the selection set will match the view selection set.
Change Orders mostly don't use this set. With the Records tab, you can get all the Item objects properly, but Files show up as Other with -1 Ids.
