# MPS 2025.1 Logical View: how to replace TREE\_NODE

**URL:** <https://platform.jetbrains.com/t/mps-2025-1-logical-view-how-to-replace-tree-node/2894>\
**Category:** MPS\
**Tags:** ui\
**Created:** [October 8, 2025, 12:59pm UTC](https://platform.jetbrains.com/t/mps-2025-1-logical-view-how-to-replace-tree-node/2894 "2025-10-08T12:59:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergej\_k](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/sergej_k/32/128_2.png) [@sergej\_k](https://platform.jetbrains.com/u/sergej_k)\
**Post date:** [October 8, 2025, 12:59pm UTC](https://platform.jetbrains.com/t/mps-2025-1-logical-view-how-to-replace-tree-node/2894/1 "2025-10-08T12:59:14Z")

</div>

We used to have code like this in our project in MPS 2023.2:

```auto
...
action context parameters:
  TreeNode treeNode key: TREE_NODE required

...

if (this.treeNode instanceof ProjectSolutionTreeNode) { 
  SModule module = ((ProjectSolutionTreeNode) this.treeNode).getModule(); 
  searchScope = new ModulesScope(module); 
} else if (this.treeNode instanceof SModelTreeNode) { 
  SModel model = ((SModelTreeNode) this.treeNode).getModel(); 
  searchScope = new ModelsScope(model); 
} else if (this.treeNode instanceof PackageNode) { 
  PackageNode packageNode = ((PackageNode) this.treeNode); 
  SModel model = packageNode.getModelReference().resolve(this.mpsProject.getRepository()); 
  searchScope = new ModelsScope(model); 
  nodesInPackageScope = packageNode.getNodesUnderPackage(); 
} else { 
  searchScope = new ProjectScope(this.mpsProject); 
}

```

Now we’re migrating to 2025.1 and the TREE\_NODE data key no longer works. I see that there are new VALUE and USER\_OBJECT keys that appear to be the replacement of TREE\_NODE. How would I use them to write code above? I.e. to figure out what kind of entity is currently selected?

---

<div class="post-metadata">

**Author:** ![fisakov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/fisakov/32/1076_2.png) [@fisakov](https://platform.jetbrains.com/u/fisakov)\
**Post date:** [October 8, 2025, 1:27pm UTC](https://platform.jetbrains.com/t/mps-2025-1-logical-view-how-to-replace-tree-node/2894/2 "2025-10-08T13:27:42Z")

</div>

In MPS 2025.1 the Project pane stopped providing the Swing tree node itself via MPSCommonDataKeys.TREE\_NODE. Instead, it now exposes:

- MPSCommonDataKeys.VALUE: the semantic value of the selected item (e.g., SModule, SModel, SNode, or a VirtualFolder like VirtualFolder.Nodes for a package folder).
- MPSCommonDataKeys.USER\_OBJECT: the “node presentation object” that may implement helper interfaces (e.g., ContextValueProvider, StereotypeProvider, DiscoveryValueProvider) to get contextual information.

This means you should not rely on Swing’s TreeNode type anymore to decide what is selected. Use VALUE to detect semantics and USER\_OBJECT only when you need extra context.

You can also use MPSCommonDataKeys.VALUES / USER\_OBJECTS for multi-selection.

Quick mapping from old to new:

- ProjectSolutionTreeNode → VALUE instanceof SModule (Solution)
- SModelTreeNode → VALUE instanceof SModel
- PackageNode (namespace under a model) → VALUE instanceof VirtualFolder.Nodes  
and USER\_OBJECT implements ContextValueProvider → get SModel: `contextValueOfType(SModel.class)`  
and USER\_OBJECT implements DiscoveryValueProvider → get package contents: `discoverValuesOfType(SNode.class)`

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/system/32/40_2.png) [@system](https://platform.jetbrains.com/u/system)\
**Post date:** [October 10, 2025, 1:27pm UTC](https://platform.jetbrains.com/t/mps-2025-1-logical-view-how-to-replace-tree-node/2894/3 "2025-10-10T13:27:44Z")

</div>

Closed on October 10, 2025, 1:27pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
