MainFrameMenu.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import strings = require("./EditorStrings");
  2. import EditorEvents = require("../editor/EditorEvents");
  3. import EditorUI = require("./EditorUI");
  4. import MenuItemSources = require("./menus/MenuItemSources");
  5. class MainFrameMenu extends Atomic.ScriptObject {
  6. constructor() {
  7. super();
  8. MenuItemSources.createMenuItemSource("menu atomic editor", editorItems);
  9. MenuItemSources.createMenuItemSource("menu edit", editItems);
  10. MenuItemSources.createMenuItemSource("menu file", fileItems);
  11. }
  12. handlePopupMenu(target: Atomic.UIWidget, refid: string): boolean {
  13. if (target.id == "menu atomic editor popup") {
  14. if (refid == "about atomic editor") {
  15. EditorUI.getModelOps().showAbout();
  16. return true;
  17. }
  18. if (refid == "quit") {
  19. this.sendEvent(EditorEvents.Quit);
  20. return true;
  21. }
  22. } else if (target.id == "menu edit popup") {
  23. if (refid == "edit play") {
  24. EditorUI.getShortcuts().invokePlay();
  25. return true;
  26. }
  27. if (refid == "edit format code") {
  28. EditorUI.getShortcuts().invokeFormatCode();
  29. return true;
  30. }
  31. return false;
  32. } else if (target.id == "menu file popup") {
  33. if (refid == "file new project") {
  34. var mo = EditorUI.getModelOps();
  35. mo.showNewProject();
  36. return true;
  37. }
  38. if (refid == "file save file") {
  39. EditorUI.getShortcuts().invokeFileSave();
  40. return true;
  41. }
  42. if (refid == "file close file") {
  43. EditorUI.getShortcuts().invokeFileClose();
  44. return true;
  45. }
  46. if (refid == "file save all") {
  47. this.sendEvent(EditorEvents.SaveAllResources);
  48. return true;
  49. }
  50. return false;
  51. }
  52. }
  53. }
  54. export = MainFrameMenu;
  55. // initialization
  56. var StringID = strings.StringID;
  57. var editorItems = {
  58. "About Atomic Editor": "about atomic editor",
  59. "-1": null,
  60. "Manage License": "manage license",
  61. "-2": null,
  62. "Check for Updates": "check update",
  63. "-3": null,
  64. "Quit": "quit"
  65. };
  66. var editItems = {
  67. "Undo": ["edit undo", StringID.ShortcutUndo],
  68. "Redo": ["edit redo", StringID.ShortcutRedo],
  69. "-1": null,
  70. "Cut": ["edit cut", StringID.ShortcutCut],
  71. "Copy": ["edit copy", StringID.ShortcutCopy],
  72. "Paste": ["edit paste", StringID.ShortcutPaste],
  73. "Select All": ["edit select all", StringID.ShortcutSelectAll],
  74. "-2": null,
  75. "Find": ["edit find", StringID.ShortcutFind],
  76. "Find Next": ["edit find next", StringID.ShortcutFindNext],
  77. "Find Prev": ["edit find prev", StringID.ShortcutFindPrev],
  78. "-3": null,
  79. "Format Code": ["edit format code", StringID.ShortcutBeautify],
  80. "-4": null,
  81. "Play": ["edit play", StringID.ShortcutPlay]
  82. };
  83. var fileItems = {
  84. "New Project": ["file new project"],
  85. "Open Project": ["file open project"],
  86. "Save Project": ["file save project"],
  87. "-1": null,
  88. "Close Project": ["file close project"],
  89. "-2": null,
  90. "Save File": ["file save file"],
  91. "Save All Files": ["file save all"],
  92. "Close File": ["file close file"]
  93. }