ModalOps.ts 2.4 KB

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