GUIAdapter.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { PropertyLine } from "../details/PropertyLine";
  2. import { Helpers } from "../helpers/Helpers";
  3. import { AbstractTreeTool } from "../treetools/AbstractTreeTool";
  4. import { Checkbox, IToolVisible } from "../treetools/Checkbox";
  5. import { Adapter } from "./Adapter";
  6. export class GUIAdapter
  7. extends Adapter
  8. implements IToolVisible {
  9. constructor(obj: any) {
  10. super(obj);
  11. }
  12. /** Returns the name displayed in the tree */
  13. public id(): string {
  14. let str = '';
  15. if (this._obj.name) {
  16. str = this._obj.name;
  17. } // otherwise nothing displayed
  18. return str;
  19. }
  20. /** Returns the type of this object - displayed in the tree */
  21. public type(): string {
  22. return Helpers.GET_TYPE(this._obj);
  23. }
  24. /** Returns the list of properties to be displayed for this adapter */
  25. public getProperties(): Array<PropertyLine> {
  26. return Helpers.GetAllLinesProperties(this._obj);
  27. }
  28. public getTools(): Array<AbstractTreeTool> {
  29. let tools = [];
  30. tools.push(new Checkbox(this));
  31. return tools;
  32. }
  33. public setVisible(b: boolean) {
  34. (this._obj).isVisible = b;
  35. }
  36. public isVisible(): boolean {
  37. return (this._obj).isVisible;
  38. }
  39. }