|
@@ -23,6 +23,8 @@
|
|
|
import * as EditorEvents from "../editor/EditorEvents";
|
|
import * as EditorEvents from "../editor/EditorEvents";
|
|
|
import * as EditorUI from "../ui/EditorUI";
|
|
import * as EditorUI from "../ui/EditorUI";
|
|
|
import MainFramMenu = require("../ui/frames/menus/MainFrameMenu");
|
|
import MainFramMenu = require("../ui/frames/menus/MainFrameMenu");
|
|
|
|
|
+import HierarchyFrameMenu = require("../ui/frames/menus/HierarchyFrameMenu");
|
|
|
|
|
+import ProjectFrameMenu = require("../ui/frames/menus/ProjectFrameMenu");
|
|
|
import ModalOps = require("../ui/modal/ModalOps");
|
|
import ModalOps = require("../ui/modal/ModalOps");
|
|
|
/**
|
|
/**
|
|
|
* Generic registry for storing Editor Extension Services
|
|
* Generic registry for storing Editor Extension Services
|
|
@@ -205,12 +207,20 @@ export class UIServicesProvider extends ServicesProvider<Editor.HostExtensions.U
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private mainFrameMenu: MainFramMenu = null;
|
|
private mainFrameMenu: MainFramMenu = null;
|
|
|
|
|
+ private hierarchyFrameMenu: HierarchyFrameMenu = null;
|
|
|
|
|
+ private projectFrameMenu: ProjectFrameMenu = null;
|
|
|
private modalOps: ModalOps;
|
|
private modalOps: ModalOps;
|
|
|
|
|
|
|
|
- init(menu: MainFramMenu, modalOps: ModalOps) {
|
|
|
|
|
|
|
+ init(mainFrameMenu: MainFramMenu, hierarchyFrameMenu: HierarchyFrameMenu, projectFrameMenu: ProjectFrameMenu, modalOps: ModalOps) {
|
|
|
// Only set these once
|
|
// Only set these once
|
|
|
if (this.mainFrameMenu == null) {
|
|
if (this.mainFrameMenu == null) {
|
|
|
- this.mainFrameMenu = menu;
|
|
|
|
|
|
|
+ this.mainFrameMenu = mainFrameMenu;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.hierarchyFrameMenu == null) {
|
|
|
|
|
+ this.hierarchyFrameMenu = hierarchyFrameMenu;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.projectFrameMenu == null) {
|
|
|
|
|
+ this.projectFrameMenu = projectFrameMenu;
|
|
|
}
|
|
}
|
|
|
if (this.modalOps == null) {
|
|
if (this.modalOps == null) {
|
|
|
this.modalOps = modalOps;
|
|
this.modalOps = modalOps;
|
|
@@ -235,6 +245,42 @@ export class UIServicesProvider extends ServicesProvider<Editor.HostExtensions.U
|
|
|
this.mainFrameMenu.removePluginMenuItemSource(id);
|
|
this.mainFrameMenu.removePluginMenuItemSource(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Adds a new menu to the hierarchy context menu
|
|
|
|
|
+ * @param {string} id
|
|
|
|
|
+ * @param {any} items
|
|
|
|
|
+ * @return {Atomic.UIMenuItemSource}
|
|
|
|
|
+ */
|
|
|
|
|
+ createHierarchyContextMenuItemSource(id: string, items: any): Atomic.UIMenuItemSource {
|
|
|
|
|
+ return this.hierarchyFrameMenu.createPluginItemSource(id, items);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Removes a previously added menu from the hierarchy context menu
|
|
|
|
|
+ * @param {string} id
|
|
|
|
|
+ */
|
|
|
|
|
+ removeHierarchyContextMenuItemSource(id: string) {
|
|
|
|
|
+ this.hierarchyFrameMenu.removePluginItemSource(id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Adds a new menu to the project context menu
|
|
|
|
|
+ * @param {string} id
|
|
|
|
|
+ * @param {any} items
|
|
|
|
|
+ * @return {Atomic.UIMenuItemSource}
|
|
|
|
|
+ */
|
|
|
|
|
+ createProjectContextMenuItemSource(id: string, items: any): Atomic.UIMenuItemSource {
|
|
|
|
|
+ return this.projectFrameMenu.createPluginItemSource(id, items);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Removes a previously added menu from the project context menu
|
|
|
|
|
+ * @param {string} id
|
|
|
|
|
+ */
|
|
|
|
|
+ removeProjectContextMenuItemSource(id: string) {
|
|
|
|
|
+ this.projectFrameMenu.removePluginItemSource(id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Disaplays a modal window
|
|
* Disaplays a modal window
|
|
|
* @param {Editor.Modal.ModalWindow} window
|
|
* @param {Editor.Modal.ModalWindow} window
|
|
@@ -248,14 +294,63 @@ export class UIServicesProvider extends ServicesProvider<Editor.HostExtensions.U
|
|
|
* @param {string} refId
|
|
* @param {string} refId
|
|
|
* @type {boolean} return true if handled
|
|
* @type {boolean} return true if handled
|
|
|
*/
|
|
*/
|
|
|
- menuItemClicked(refId: string): boolean {
|
|
|
|
|
|
|
+ menuItemClicked(refid: string): boolean {
|
|
|
// run through and find any services that can handle this.
|
|
// run through and find any services that can handle this.
|
|
|
let holdResult = false;
|
|
let holdResult = false;
|
|
|
this.registeredServices.forEach((service) => {
|
|
this.registeredServices.forEach((service) => {
|
|
|
try {
|
|
try {
|
|
|
// Verify that the service contains the appropriate methods and that it can handle it
|
|
// Verify that the service contains the appropriate methods and that it can handle it
|
|
|
if (service.menuItemClicked) {
|
|
if (service.menuItemClicked) {
|
|
|
- if (service.menuItemClicked(refId)) {
|
|
|
|
|
|
|
+ if (service.menuItemClicked(refid)) {
|
|
|
|
|
+ holdResult = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return holdResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Called when a context menu item in the hierarchy pane has been clicked
|
|
|
|
|
+ * @param {Atomic.UIWidget} target
|
|
|
|
|
+ * @param {string} refId
|
|
|
|
|
+ * @type {boolean} return true if handled
|
|
|
|
|
+ */
|
|
|
|
|
+ hierarchyContextItemClicked(target: Atomic.UIWidget, refid: string): boolean {
|
|
|
|
|
+ // run through and find any services that can handle this.
|
|
|
|
|
+ let holdResult = false;
|
|
|
|
|
+ this.registeredServices.forEach((service) => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // Verify that the service contains the appropriate methods and that it can handle it
|
|
|
|
|
+ if (service.hierarchyContextItemClicked) {
|
|
|
|
|
+ if (service.hierarchyContextItemClicked(target, refid)) {
|
|
|
|
|
+ holdResult = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return holdResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Called when a context menu item in the hierarchy pane has been clicked
|
|
|
|
|
+ * @param {Atomic.UIWidget} target
|
|
|
|
|
+ * @param {string} refId
|
|
|
|
|
+ * @type {boolean} return true if handled
|
|
|
|
|
+ */
|
|
|
|
|
+ projectContextItemClicked(target: Atomic.UIWidget, refid: string): boolean {
|
|
|
|
|
+ // run through and find any services that can handle this.
|
|
|
|
|
+ let holdResult = false;
|
|
|
|
|
+ this.registeredServices.forEach((service) => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // Verify that the service contains the appropriate methods and that it can handle it
|
|
|
|
|
+ if (service.projectContextItemClicked) {
|
|
|
|
|
+ if (service.projectContextItemClicked(target, refid)) {
|
|
|
holdResult = true;
|
|
holdResult = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|