Adapter.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { Geometry } from "babylonjs";
  2. import { PropertyLine } from "../details/PropertyLine";
  3. import { AbstractTreeTool } from "../treetools/AbstractTreeTool";
  4. export abstract class Adapter {
  5. protected _obj: any;
  6. // a unique name for this adapter, to retrieve its own key in the local storage
  7. private static _name: string = Geometry.RandomId();
  8. constructor(obj: any) {
  9. this._obj = obj;
  10. }
  11. /** Returns the name displayed in the tree */
  12. public abstract id(): string;
  13. /** Returns the type of this object - displayed in the tree */
  14. public abstract type(): string;
  15. /** Returns the list of properties to be displayed for this adapter */
  16. public abstract getProperties(): Array<PropertyLine>;
  17. /** Returns true if the given object correspond to this */
  18. public correspondsTo(obj: any) {
  19. return obj === this._obj;
  20. }
  21. /** Returns the adapter unique name */
  22. public get name(): string {
  23. return Adapter._name;
  24. }
  25. /**
  26. * Returns the actual object used for this adapter
  27. */
  28. public get object(): any {
  29. return this._obj;
  30. }
  31. /** Returns the list of tools available for this adapter */
  32. public abstract getTools(): Array<AbstractTreeTool>;
  33. }