Tree Services

1. Explorer tree filters

Register a Spring service implementing org.eclipse.sirius.components.collaborative.trees.api.ITreeFilterProvider to contribute filters to the Explorer toolbar. Implement List<TreeFilter> get(String editingContextId, TreeDescription treeDescription) and return the filters that apply to that editing context and tree description.

To change the tree when the user enables a filter, register an IExplorerTreeAlteredContentProvider for root items or an IExplorerTreeItemAlteredContentProvider for children. In canHandle, check that the active filter IDs contain the ID you declared and that the provider applies to the context or item. In apply, return the items that should appear in the tree.

1.1. Initial filter state

record TreeFilter(String id, String label, boolean defaultState)

Give each TreeFilter a stable ID and a label to display in the filter menu.

The third argument of TreeFilter is defaultState. Set it to true to enable the filter when the Explorer opens, or to false to leave it available in the menu. For example, the built-in filter for studio projects is declared as follows.

new TreeFilter("hide-color-palettes", "Hide In-Memory Studio Color Palettes", true)

If the initial Explorer view configuration supplies an activeTreeFilters entry with the same ID, the entry’s state takes precedence over defaultState. This lets a shared configuration restore a filter that the user enabled or disabled.

2. Palette

The palette computed in a tree for a tree item can be customized by using a service implementing o.e.s.c.collaborative.trees.palette.api.ITreeItemPaletteCustomizer. Thanks to a implementation of this interface, a service can add, transform or even remove any tools, tool sections or quick access tools from the computed palette.

The tool of a tree palette can be overridden using the paletteToolOverrideExtensionPoint. Some configuration is required to make an overridden tool work with the last tool used & the search feature of the palette. Some props are available to make it easier.

For a tree, using the canHandle: (representationKind: string, tool: GQLTool) method, the value of representationKind will be TREE_REPRESENTATION_KIND (exported from the tree package).

2.1. Last tool used

The last tool used is displayed on top the tool section. You need to call the prop onInvoked() after the execution of a tool to set it as the last tool used.

2.2. Search feature

The current searched value is available from the prop searchedValue. Palette package export the function fuzzyMatch = (candidate: string, searchTerm: string): MatchResult. If there is a searchedValue you need to test your label with fuzzyMatch it in order to know if the tool is candidate. If there is a searchedValue but the attributed matches of MatchResult is false then the contributed component should not render.