ModalOps.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. showResourceDelete(asset:ToolCore.Asset) {
  30. if (this.show()) {
  31. this.opWindow = new UIResourceOps.ResourceDelete(asset);
  32. }
  33. }
  34. showNewProject() {
  35. if (this.show()) {
  36. this.opWindow = new NewProject();
  37. }
  38. }
  39. showEULAWindow() {
  40. if (this.show()) {
  41. this.opWindow = new EULAWindow();
  42. }
  43. }
  44. showActivationWindow() {
  45. if (this.show()) {
  46. this.opWindow = new ActivationWindow();
  47. }
  48. }
  49. showActivationSuccessWindow() {
  50. if (this.show()) {
  51. this.opWindow = new ActivationSuccessWindow();
  52. }
  53. }
  54. private show(): boolean {
  55. if (this.dimmer.parent) {
  56. console.log("WARNING: attempting to show modal while dimmer is active");
  57. return false;
  58. }
  59. if (this.opWindow) {
  60. console.log("WARNING: attempting to show modal while another opWindow is active");
  61. return false;
  62. }
  63. var view = EditorUI.getView();
  64. view.addChild(this.dimmer);
  65. return true;
  66. }
  67. hide() {
  68. if (this.opWindow) {
  69. var window = this.opWindow;
  70. this.opWindow = null;
  71. if (window.parent)
  72. window.parent.removeChild(window, false);
  73. var view = EditorUI.getView();
  74. view.setFocusRecursive();
  75. }
  76. if (this.dimmer.parent) {
  77. this.dimmer.parent.removeChild(this.dimmer, false);
  78. }
  79. }
  80. dimmer: Atomic.UIDimmer;
  81. opWindow: ModalWindow;
  82. }
  83. export = ModalOps;