ModalOps.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import EditorUI = require("../EditorUI");
  2. import ModalWindow = require("./ModalWindow");
  3. import NewProject = require("./NewProject");
  4. import CreateProject = require("./CreateProject");
  5. import EULAWindow = require("../license/EULAWindow");
  6. import ActivationWindow = require("../license/ActivationWindow");
  7. import ActivationSuccessWindow = require("../license/ActivationSuccessWindow");
  8. import UIResourceOps = require("./UIResourceOps");
  9. class ModalOps extends Atomic.ScriptObject {
  10. constructor() {
  11. super();
  12. this.dimmer = new Atomic.UIDimmer();
  13. }
  14. showCreateProject(projectTemplateFolder:string) {
  15. if (this.show()) {
  16. this.opWindow = new CreateProject(projectTemplateFolder);
  17. }
  18. }
  19. showCreateFolder(resourcePath:string) {
  20. if (this.show()) {
  21. this.opWindow = new UIResourceOps.CreateFolder(resourcePath);
  22. }
  23. }
  24. showCreateComponent(resourcePath:string) {
  25. if (this.show()) {
  26. this.opWindow = new UIResourceOps.CreateComponent(resourcePath);
  27. }
  28. }
  29. showCreateScene(resourcePath:string) {
  30. if (this.show()) {
  31. this.opWindow = new UIResourceOps.CreateScene(resourcePath);
  32. }
  33. }
  34. showResourceDelete(asset:ToolCore.Asset) {
  35. if (this.show()) {
  36. this.opWindow = new UIResourceOps.ResourceDelete(asset);
  37. }
  38. }
  39. showNewProject() {
  40. if (this.show()) {
  41. this.opWindow = new NewProject();
  42. }
  43. }
  44. showEULAWindow() {
  45. if (this.show()) {
  46. this.opWindow = new EULAWindow();
  47. }
  48. }
  49. showActivationWindow() {
  50. if (this.show()) {
  51. this.opWindow = new ActivationWindow();
  52. }
  53. }
  54. showActivationSuccessWindow() {
  55. if (this.show()) {
  56. this.opWindow = new ActivationSuccessWindow();
  57. }
  58. }
  59. private show(): boolean {
  60. if (this.dimmer.parent) {
  61. console.log("WARNING: attempting to show modal while dimmer is active");
  62. return false;
  63. }
  64. if (this.opWindow) {
  65. console.log("WARNING: attempting to show modal while another opWindow is active");
  66. return false;
  67. }
  68. var view = EditorUI.getView();
  69. view.addChild(this.dimmer);
  70. return true;
  71. }
  72. hide() {
  73. if (this.opWindow) {
  74. var window = this.opWindow;
  75. this.opWindow = null;
  76. if (window.parent)
  77. window.parent.removeChild(window, false);
  78. var view = EditorUI.getView();
  79. view.setFocusRecursive();
  80. }
  81. if (this.dimmer.parent) {
  82. this.dimmer.parent.removeChild(this.dimmer, false);
  83. }
  84. }
  85. dimmer: Atomic.UIDimmer;
  86. opWindow: ModalWindow;
  87. }
  88. export = ModalOps;