How to use the @bentley/presentation-common.NodeKey.isInstancesNodeKey function in @bentley/presentation-common

To help you get started, we’ve selected a few @bentley/presentation-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / presentation / components / src / tree / controlled / UseUnifiedSelection.ts View on Github external
protected shouldSelectNode(node: TreeNodeItem, selection: Readonly) {
    const nodeKey = this.getNodeKey(node);
    if (nodeKey === undefined)
      return false;

    // consider node selected if it's key is in selection
    if (selection.has(nodeKey))
      return true;

    // ... or if it's an ECInstances node and any of instance keys is in selection
    if (NodeKey.isInstancesNodeKey(nodeKey) && nodeKey.instanceKeys.some((instanceKey) => selection.has(instanceKey)))
      return true;

    // ... or if it's an ECInstance node and instance key is in selection
    if (NodeKey.isInstanceNodeKey(nodeKey) && selection.has(nodeKey.instanceKey))
      return true;

    return false;
  }
github imodeljs / imodeljs / presentation / components / src / tree / WithUnifiedSelection.tsx View on Github external
private isNodeSelected(node: TreeNodeItem): boolean {
      if (!this._selectionHandler)
        return false;

      const selection = this._selectionHandler.getSelection();

      // consider node selected if it's key is in selection
      const nodeKey = this.props.dataProvider.getNodeKey(node);
      if (selection.has(nodeKey))
        return true;

      // ... or if it's an ECInstances node and any of instance keys is in selection
      if (NodeKey.isInstancesNodeKey(nodeKey) && nodeKey.instanceKeys.some((instanceKey) => selection.has(instanceKey)))
        return true;

      // ... or if it's an ECInstance node and instance key is in selection
      if (NodeKey.isInstanceNodeKey(nodeKey) && selection.has(nodeKey.instanceKey))
        return true;

      return false;
    }
github imodeljs / imodeljs / ui / framework / src / ui-framework / imodel-components / visibility-tree / VisibilityTree.tsx View on Github external
public getDisplayStatus(node: TreeNodeItem): VisibilityStatus | Promise {
    const key = this._props.dataProvider.getNodeKey(node);
    if (!NodeKey.isInstancesNodeKey(key))
      return { isDisplayed: false, isDisabled: true };

    if (isSubjectNode(node)) {
      // note: subject nodes may be merged to represent multiple subject instances
      return this.getSubjectDisplayStatus(key.instanceKeys.map((k) => k.id));
    }
    if (isModelNode(node))
      return this.getModelDisplayStatus(key.instanceKeys[0].id);
    if (isCategoryNode(node))
      return this.getCategoryDisplayStatus(key.instanceKeys[0].id, this.getCategoryParentModelId(node));
    return this.getElementDisplayStatus(key.instanceKeys[0].id, this.getElementModelId(node), this.getElementCategoryId(node));
  }
github imodeljs / imodeljs / ui / framework / src / ui-framework / imodel-components / visibility-tree / VisibilityTree.tsx View on Github external
public async changeVisibility(node: TreeNodeItem, on: boolean) {
    const key = this._props.dataProvider.getNodeKey(node);
    if (!NodeKey.isInstancesNodeKey(key))
      return;

    if (isSubjectNode(node)) {
      await this.changeSubjectState(key.instanceKeys.map((k) => k.id), on);
    } else if (isModelNode(node)) {
      await this.changeModelState(key.instanceKeys[0].id, on);
    } else if (isCategoryNode(node)) {
      this.changeCategoryState(key.instanceKeys[0].id, this.getCategoryParentModelId(node), on);
    } else {
      await this.changeElementState(key.instanceKeys[0].id, this.getElementModelId(node), this.getElementCategoryId(node), on);
    }
  }