How to use the @bentley/ui-framework.UiFramework.getIModelConnection function in @bentley/ui-framework

To help you get started, we’ve selected a few @bentley/ui-framework 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 / test-apps / ui-test-app / src / frontend / appui / frontstages / ViewsFrontstage.tsx View on Github external
iconSpec: "icon-placeholder", labelKey: "SampleApp:buttons.restoreContentLayout", badgeType: BadgeType.New, execute: async () => {
        const iModelConnection = UiFramework.getIModelConnection();
        if (ViewsFrontstage.savedViewLayoutProps && iModelConnection) {
          // Parse SavedViewLayoutProps
          const savedViewLayoutProps: SavedViewLayoutProps = JSON.parse(ViewsFrontstage.savedViewLayoutProps);
          // Create ContentLayoutDef
          const contentLayoutDef = new ContentLayoutDef(savedViewLayoutProps.contentLayoutProps);
          // Create ViewStates
          const viewStates = await SavedViewLayout.viewStatesFromProps(iModelConnection, savedViewLayoutProps);

          // Add applicationData to the ContentProps
          savedViewLayoutProps.contentGroupProps.contents.forEach((contentProps: ContentProps, index: number) => {
            contentProps.applicationData = { viewState: viewStates[index], iModelConnection, rulesetId: "Items" };
          });
          const contentGroup = new ContentGroup(savedViewLayoutProps.contentGroupProps);

          // activate the layout
          await ContentLayoutManager.setActiveLayout(contentLayoutDef, contentGroup);
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / index.tsx View on Github external
public static async showIModelIndex(contextId: string, iModelId: string) {
    const currentConnection = UiFramework.getIModelConnection();
    if (!currentConnection || (currentConnection.iModelToken.iModelId !== iModelId)) {
      // Close the current iModelConnection
      await SampleAppIModelApp.closeCurrentIModel();

      // open the imodel
      Logger.logInfo(SampleAppIModelApp.loggerCategory(this), `showIModelIndex: projectId=${contextId}&iModelId=${iModelId}`);
      const iModelConnection = await UiFramework.iModelServices.openIModel(contextId, iModelId);
      SampleAppIModelApp.setIsIModelLocal(false, true);

      SyncUiEventDispatcher.initializeConnectionEvents(iModelConnection);

      // store the IModelConnection in the sample app store
      UiFramework.setIModelConnection(iModelConnection, true);
    }

    await SampleAppIModelApp.showFrontstage("IModelIndex");
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / frontstages / IModelIndexFrontstage.tsx View on Github external
constructor(info: ConfigurableCreateInfo, options: any) {
    super(info, options);

    const iModelConnection = UiFramework.getIModelConnection();
    if (iModelConnection && UiFramework.oidcClient && UiFramework.oidcClient.isAuthorized)
      this.reactElement = ;
    else
      this.reactElement = null;
  }
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / contentviews / ScheduleAnimationViewport.tsx View on Github external
constructor(info: ConfigurableCreateInfo, options: any) {
    super(info, options);

    const _iModelConnection = UiFramework.getIModelConnection();

    if (_iModelConnection)
      this.reactElement =  { this.viewport = v; }} />;
    else
      this.reactElement = null;
  }
}
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / index.tsx View on Github external
public static async closeCurrentIModel() {
    const currentIModelConnection = UiFramework.getIModelConnection();
    if (currentIModelConnection) {
      SyncUiEventDispatcher.clearConnectionEvents(currentIModelConnection);

      if (SampleAppIModelApp.isIModelLocal)
        await currentIModelConnection.closeSnapshot();
      else
        await currentIModelConnection.close();
      UiFramework.setIModelConnection(undefined);
    }
  }
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / widgets / TreeDemoWidget.tsx View on Github external
constructor(info: ConfigurableCreateInfo, options: any) {
    super(info, options);

    if (UiFramework.getIModelConnection())
      this.reactElement = ;
    else
      this.reactElement = null;
  }
}
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / widgets / BreadcrumbDemoWidget.tsx View on Github external
constructor(info: ConfigurableCreateInfo, options: any) {
    super(info, options);

    if (UiFramework.getIModelConnection())
      this.reactElement = ;
    else
      this.reactElement = null;
  }
}
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / widgets / TableDemoWidget.tsx View on Github external
constructor(info: ConfigurableCreateInfo, options: any) {
    super(info, options);

    if (UiFramework.getIModelConnection())
      this.reactElement = ;
    else
      this.reactElement = null;
  }
}
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / frontstages / IModelIndexFrontstage.tsx View on Github external
private _onOpen = async (viewIds: Id64String[]) => {
    const iModelConnection = UiFramework.getIModelConnection();
    if (iModelConnection) {
      const contextId = iModelConnection.iModelToken.contextId!;
      const iModelId = iModelConnection.iModelToken.iModelId!;
      await SampleAppIModelApp.openIModelAndViews(contextId, iModelId, viewIds);
    }
  }
}