File

projects/wms-framework/src/lib/regionsframework/adapters/AdapterForTabControl.ts

Description

Adapter for TabControl region

Extends

RegionAdapterBase

Index

Properties
Methods

Constructor

Public constructor(regionBehaviorFactory: IRegionBehaviorFactory)
Parameters :
Name Type Optional
regionBehaviorFactory IRegionBehaviorFactory No

Properties

RegionBehaviorFactory
Type : IRegionBehaviorFactory
Inherited from RegionAdapterBase

Methods

Public Adapt
Adapt(region: IRegion, regionTarget: TabControlModel)
Inherited from RegionAdapterBase

Adapt the region to the target

Parameters :
Name Type Optional
region IRegion No
regionTarget TabControlModel No
Returns : void
Public AttachBehaviors
AttachBehaviors(region: IRegion, regionTarget: TabControlModel)
Inherited from RegionAdapterBaseUnTyped

Attach the behavior to the region target element

Parameters :
Name Type Optional
region IRegion No
regionTarget TabControlModel No
Returns : void
Public CreateRegion
CreateRegion()
Inherited from RegionAdapterBase

Creates the target region for the adapted TabControl

Returns : IRegion
Protected AttachDefaultBehaviors
AttachDefaultBehaviors(region: IRegion, regionTarget: T)
Inherited from RegionAdapterBase

Attach defaults behavior to region

Parameters :
Name Type Optional
region IRegion No
regionTarget T No
Returns : void
Initialize
Initialize(regionTarget: object, regionName: string)
Inherited from RegionAdapterBase
Parameters :
Name Type Optional
regionTarget object No
regionName string No
Returns : IRegion
import { inject, injectable } from 'tsyringe';
import { TabControlModel } from '../../models';
import { regionBehaviorFactoryInjectionToken } from '../injectionTokens';
import { IRegion } from '../IRegion';
import { IRegionBehaviorFactory } from '../IRegionBehaviorFactory';
import { RegionAdapterBase } from '../RegionAdapterBase';
import { SingleActiveRegion } from '../SingleActiveRegion';
import { InvalidOperationException } from '../../baseframework';
import { TabControlRegionSyncBehavior } from './behaviors/TabControlRegionSyncBehavior';

/**
 * Adapter for TabControl region
 *
 * @export
 * @class AdapterForTabControl
 * @extends {RegionAdapterBase<TabControlModel>}
 * @wType Microsoft.Practices.Prism.Regions.TabControlRegionAdapter
 */
@injectable()
export class AdapterForTabControl extends RegionAdapterBase<TabControlModel> {
  public constructor(
    @inject(regionBehaviorFactoryInjectionToken)
    regionBehaviorFactory: IRegionBehaviorFactory
  ) {
    super(regionBehaviorFactory);
  }

  /**
   * Adapt the region to the target
   *
   * @param {IRegion} region
   * @param {TabControlModel} regionTarget
   * @memberof AdapterForTabControl
   */
  public Adapt(region: IRegion, regionTarget: TabControlModel): void {
    let itemsSourceIsSet: boolean = regionTarget.ItemsSource != null;
    if (itemsSourceIsSet) {
      throw new InvalidOperationException(
        'ItemsControl property must not be set when using regions with tabControls'
      );
    }
  }

  /**
   * Attach the behavior to the region target element
   *
   * @param {IRegion} region
   * @param {TabControlModel} regionTarget
   * @memberof AdapterForTabControl
   */
  public AttachBehaviors(region: IRegion, regionTarget: TabControlModel): void {
    if (region == null) {
      throw new Error('Null value for region argument');
    }
    super.AttachBehaviors(region, regionTarget);
    if (
      !region.Behaviors.ContainsKey(TabControlRegionSyncBehavior.BehaviorKey)
    ) {
      region.Behaviors.Add(
        TabControlRegionSyncBehavior.BehaviorKey,
        Object.assign(new TabControlRegionSyncBehavior(), {
          HostControl: regionTarget,
        })
      );
    }
  }

  /**
   * Creates the target region for the adapted TabControl
   *
   * @returns {IRegion}
   * @memberof AdapterForTabControl
   */
  public CreateRegion(): IRegion {
    return new SingleActiveRegion();
  }
}

result-matching ""

    No results matching ""