Browse Source

* refactored the way the SeriveLocator is being called. Now instead of being called from multiple locations, it listens for incoming event messages
* implemented the rename event on the typescript service so that it auto renames the corresponding js file
* added some new events that are called after certain actions are carried out: SaveResourceNotification, DeleteResourceNotification, RenameResourceNotification

Shaddock Heath 10 years ago
parent
commit
0d2b649977

+ 25 - 2
Script/AtomicEditor/editor/EditorEvents.ts

@@ -75,10 +75,14 @@ export interface LoadProjectEvent {
 export const SaveAllResources = "EditorSaveAllResources";
 export const SaveAllResources = "EditorSaveAllResources";
 
 
 export const SaveResource = "EditorSaveResource";
 export const SaveResource = "EditorSaveResource";
+/**
+ * Called once the resource has been saved
+ * @type {String}
+ */
+export const SaveResourceNotification = "EditorSaveResourceNotification";
 export interface SaveResourceEvent {
 export interface SaveResourceEvent {
 
 
-  // The full path to the resource to save
-  // empty or undefined for current
+  // The full path to the resource to save / empty or undefined for current
   path: string;
   path: string;
 
 
 }
 }
@@ -100,11 +104,30 @@ export interface EditResourceEvent {
 }
 }
 
 
 export const DeleteResource = "EditorDeleteResource";
 export const DeleteResource = "EditorDeleteResource";
+/**
+ * Called once the resource has been deleted
+ * @type {String}
+ */
+export const DeleteResourceNotification = "EditorDeleteResourceNotification";
 export interface DeleteResourceEvent {
 export interface DeleteResourceEvent {
 
 
   // The full path to the resource to edit
   // The full path to the resource to edit
   path: string;
   path: string;
 
 
+}
+
+export const RenameResource = "EditorRenameResource";
+/**
+ * Called once the resource has been renamed
+ * @type {String}
+ */
+export const RenameResourceNotification = "EditorRenameResourceNotification";
+export interface RenameResourceEvent {
+
+  // The full path to the resource to edit
+  path: string;
+  newPath: string;
+
   // the asset to delete
   // the asset to delete
   asset: ToolCore.Asset;
   asset: ToolCore.Asset;
 }
 }

+ 83 - 23
Script/AtomicEditor/extensionServices/EditorExtensionServices.ts

@@ -35,6 +35,8 @@ export interface ResourceService extends EditorService {
     canSave?(ev: EditorEvents.SaveResourceEvent);
     canSave?(ev: EditorEvents.SaveResourceEvent);
     canDelete?(ev: EditorEvents.DeleteResourceEvent);
     canDelete?(ev: EditorEvents.DeleteResourceEvent);
     delete?(ev: EditorEvents.DeleteResourceEvent);
     delete?(ev: EditorEvents.DeleteResourceEvent);
+    canRename?(ev: EditorEvents.RenameResourceEvent);
+    rename?(ev: EditorEvents.RenameResourceEvent);
 }
 }
 
 
 export interface ProjectService extends EditorService {
 export interface ProjectService extends EditorService {
@@ -42,6 +44,14 @@ export interface ProjectService extends EditorService {
     projectLoaded?(ev: EditorEvents.LoadProjectEvent);
     projectLoaded?(ev: EditorEvents.LoadProjectEvent);
 }
 }
 
 
+interface ServiceEventSubscriber {
+    /**
+     * Allow this service registry to subscribe to events that it is interested in
+     * @param  {Atomic.UIWidget} topLevelWindow The top level window that will be receiving these events
+     */
+    subscribeToEvents(topLevelWindow: Atomic.UIWidget);
+}
+
 /**
 /**
  * Generic registry for storing Editor Extension Services
  * Generic registry for storing Editor Extension Services
  */
  */
@@ -55,29 +65,39 @@ class ServiceRegistry<T extends EditorService> {
     register(service: T) {
     register(service: T) {
         this.registeredServices.push(service);
         this.registeredServices.push(service);
     }
     }
+
 }
 }
 
 
 /**
 /**
  * Registry for service extensions that are concerned about project events
  * Registry for service extensions that are concerned about project events
  */
  */
-class ProjectServiceRegistry extends ServiceRegistry<ProjectService> {
+class ProjectServiceRegistry extends ServiceRegistry<ProjectService> implements ServiceEventSubscriber {
     constructor() {
     constructor() {
         super();
         super();
     }
     }
 
 
+    /**
+     * Allow this service registry to subscribe to events that it is interested in
+     * @param  {Atomic.UIWidget} topLevelWindow The top level window that will be receiving these events
+     */
+    subscribeToEvents(topLevelWindow: Atomic.UIWidget) {
+        topLevelWindow.subscribeToEvent(EditorEvents.LoadProject, (ev) => this.projectLoaded(ev));
+        topLevelWindow.subscribeToEvent(EditorEvents.CloseProject, (ev) => this.projectUnloaded(ev));
+    }
+
     /**
     /**
      * Called when the project is unloaded
      * Called when the project is unloaded
      * @param  {[type]} data Event info from the project unloaded event
      * @param  {[type]} data Event info from the project unloaded event
      */
      */
     projectUnloaded(data) {
     projectUnloaded(data) {
         this.registeredServices.forEach((service) => {
         this.registeredServices.forEach((service) => {
-            // Verify that the service contains the appropriate methods and that it can save
-            if (service.projectUnloaded) {
-                try {
+            // Notify services that the project has been unloaded
+            try {
+                if (service.projectUnloaded) {
                     service.projectUnloaded();
                     service.projectUnloaded();
-                } catch (e) {
-                    EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}\n ${e}\n ${e.stack}`);
                 }
                 }
+            } catch (e) {
+                EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}\n ${e}\n ${e.stack}`);
             }
             }
         });
         });
     }
     }
@@ -86,15 +106,15 @@ class ProjectServiceRegistry extends ServiceRegistry<ProjectService> {
      * Called when the project is loaded
      * Called when the project is loaded
      * @param  {[type]} data Event info from the project unloaded event
      * @param  {[type]} data Event info from the project unloaded event
      */
      */
-    projectLoaded(ev:EditorEvents.LoadProjectEvent) {
+    projectLoaded(ev: EditorEvents.LoadProjectEvent) {
         this.registeredServices.forEach((service) => {
         this.registeredServices.forEach((service) => {
-            // Verify that the service contains the appropriate methods and that it can save
-            if (service.projectLoaded) {
-                try {
+            try {
+                // Notify services that the project has just been loaded
+                if (service.projectLoaded) {
                     service.projectLoaded(ev);
                     service.projectLoaded(ev);
-                } catch (e) {
-                    EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}\n ${e}\n ${e.stack}`);
                 }
                 }
+            } catch (e) {
+                EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}\n ${e}\n ${e.stack}`);
             }
             }
         });
         });
     }
     }
@@ -108,33 +128,64 @@ class ResourceServiceRegistry extends ServiceRegistry<ResourceService> {
         super();
         super();
     }
     }
 
 
+    /**
+     * Allow this service registry to subscribe to events that it is interested in
+     * @param  {Atomic.UIWidget} topLevelWindow The top level window that will be receiving these events
+     */
+    subscribeToEvents(topLevelWindow: Atomic.UIWidget) {
+        topLevelWindow.subscribeToEvent(EditorEvents.SaveResourceNotification, (ev) => this.saveResource(ev));
+        topLevelWindow.subscribeToEvent(EditorEvents.DeleteResourceNotification, (ev) => this.deleteResource(ev));
+        topLevelWindow.subscribeToEvent(EditorEvents.RenameResourceNotification, (ev) => this.renameResource(ev));
+    }
+
+    /**
+     * Called after a resource has been saved
+     * @param  {EditorEvents.SaveResourceEvent} ev
+     */
     saveResource(ev: EditorEvents.SaveResourceEvent) {
     saveResource(ev: EditorEvents.SaveResourceEvent) {
         // run through and find any services that can handle this.
         // run through and find any services that can handle this.
         this.registeredServices.forEach((service) => {
         this.registeredServices.forEach((service) => {
-            // Verify that the service contains the appropriate methods and that it can save
-            if (service.canSave && service.save && service.canSave(ev)) {
-                try {
+            try {
+                // Verify that the service contains the appropriate methods and that it can save
+                if (service.canSave && service.save && service.canSave(ev)) {
                     service.save(ev);
                     service.save(ev);
-                } catch (e) {
-                    EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}\n ${e}\n ${e.stack}`);
                 }
                 }
+            } catch (e) {
+                EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}\n ${e}\n ${e.stack}`);
             }
             }
         });
         });
     }
     }
 
 
     /**
     /**
-     * Called when a resource is being deleted
+     * Called when a resource has been deleted
      * @return {[type]} [description]
      * @return {[type]} [description]
      */
      */
     deleteResource(ev: EditorEvents.DeleteResourceEvent) {
     deleteResource(ev: EditorEvents.DeleteResourceEvent) {
         this.registeredServices.forEach((service) => {
         this.registeredServices.forEach((service) => {
-            // Verify that the service contains the appropriate methods and that it can save
-            if (service.canDelete && service.delete && service.canDelete(ev)) {
-                try {
+            try {
+                // Verify that the service contains the appropriate methods and that it can delete
+                if (service.canDelete && service.delete && service.canDelete(ev)) {
                     service.delete(ev);
                     service.delete(ev);
-                } catch (e) {
-                    EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}\n ${e}\n ${e.stack}`);
                 }
                 }
+            } catch (e) {
+                EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}\n ${e}\n ${e.stack}`);
+            }
+        });
+    }
+
+    /**
+     * Called when a resource has been renamed
+     * @param  {EditorEvents.RenameResourceEvent} ev
+     */
+    renameResource(ev: EditorEvents.RenameResourceEvent) {
+        this.registeredServices.forEach((service) => {
+            try {
+                // Verify that the service contains the appropriate methods and that it can handle the rename
+                if (service.canRename && service.rename && service.canRename(ev)) {
+                    service.rename(ev);
+                }
+            } catch (e) {
+                EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}\n ${e}\n ${e.stack}`);
             }
             }
         });
         });
     }
     }
@@ -158,4 +209,13 @@ export class ServiceLocatorType {
     loadService(service: EditorService) {
     loadService(service: EditorService) {
         service.initialize(this);
         service.initialize(this);
     }
     }
+
+    /**
+     * This is where the top level window will allow the service locator to listen for events and act on them.
+     * @param  {Atomic.UIWidget} frame
+     */
+    subscribeToEvents(frame: Atomic.UIWidget) {
+        this.resourceServices.subscribeToEvents(frame);
+        this.projectServices.subscribeToEvents(frame);
+    }
 }
 }

+ 79 - 36
Script/AtomicEditor/extensionServices/resourceServices/TypescriptLanguageService.ts

@@ -17,9 +17,9 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
     name: string = "TypeScriptResourceService";
     name: string = "TypeScriptResourceService";
     description: string = "This service transpiles TypeScript into JavaScript on save.";
     description: string = "This service transpiles TypeScript into JavaScript on save.";
 
 
-    languageService: ts.LanguageService;
-    projectFiles: string[];
-    versionMap: ts.Map<{ version: number, snapshot?: ts.IScriptSnapshot }> = {};
+    private languageService: ts.LanguageService;
+    private projectFiles: string[];
+    private versionMap: ts.Map<{ version: number, snapshot?: ts.IScriptSnapshot }> = {};
 
 
     /**
     /**
      * Perform a full compile on save, or just transpile the current file
      * Perform a full compile on save, or just transpile the current file
@@ -31,7 +31,7 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
      * used by the compile to build a registery of all of the project files
      * used by the compile to build a registery of all of the project files
      * @param {string[]} files optional list of files to refresh.  If not provided, then all files will be reloaded
      * @param {string[]} files optional list of files to refresh.  If not provided, then all files will be reloaded
      */
      */
-    refreshProjectFiles(files?: string[]) {
+    private refreshProjectFiles(files?: string[]) {
         if (!this.projectFiles || !files) {
         if (!this.projectFiles || !files) {
             // First time in, let's index the entire project
             // First time in, let's index the entire project
             this.projectFiles = [];
             this.projectFiles = [];
@@ -73,7 +73,7 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
      * @param {string[]}           fileNames array of files to transpile
      * @param {string[]}           fileNames array of files to transpile
      * @param {ts.CompilerOptions} options   compiler options
      * @param {ts.CompilerOptions} options   compiler options
      */
      */
-    transpile(fileNames: string[], options: ts.CompilerOptions): void {
+    private transpile(fileNames: string[], options: ts.CompilerOptions): void {
         fileNames.forEach((fileName) => {
         fileNames.forEach((fileName) => {
             console.log(`${this.name}:  Transpiling ${fileName}`);
             console.log(`${this.name}:  Transpiling ${fileName}`);
             let script = new Atomic.File(fileName, Atomic.FILE_READ);
             let script = new Atomic.File(fileName, Atomic.FILE_READ);
@@ -104,7 +104,7 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
      * @param  {string}  a list of file names to compile
      * @param  {string}  a list of file names to compile
      * @param  {ts.CompilerOptions} options for the compiler
      * @param  {ts.CompilerOptions} options for the compiler
      */
      */
-    compile(files: string[], options: ts.CompilerOptions): void {
+    private compile(files: string[], options: ts.CompilerOptions): void {
         let start = new Date().getTime();
         let start = new Date().getTime();
         //scan all the files in the project
         //scan all the files in the project
         this.refreshProjectFiles(files);
         this.refreshProjectFiles(files);
@@ -182,7 +182,7 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
      * @param  {string} filename the file to compile
      * @param  {string} filename the file to compile
      * @return {[ts.Diagnostic]} a list of any errors
      * @return {[ts.Diagnostic]} a list of any errors
      */
      */
-    compileFile(filename: string): ts.Diagnostic[] {
+    private compileFile(filename: string): ts.Diagnostic[] {
         console.log(`${this.name}: Compiling version ${this.versionMap[filename].version} of ${filename}`);
         console.log(`${this.name}: Compiling version ${this.versionMap[filename].version} of ${filename}`);
         //if (!filename.match("\.d\.ts$")) {
         //if (!filename.match("\.d\.ts$")) {
         try {
         try {
@@ -200,7 +200,7 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
      * @param  {string} filename [description]
      * @param  {string} filename [description]
      * @return {[ts.Diagnostic]} a list of any errors
      * @return {[ts.Diagnostic]} a list of any errors
      */
      */
-    emitFile(filename: string): ts.Diagnostic[] {
+    private emitFile(filename: string): ts.Diagnostic[] {
         let output = this.languageService.getEmitOutput(filename);
         let output = this.languageService.getEmitOutput(filename);
         let allDiagnostics: ts.Diagnostic[] = [];
         let allDiagnostics: ts.Diagnostic[] = [];
         if (output.emitSkipped) {
         if (output.emitSkipped) {
@@ -227,7 +227,7 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
      * @param {ts.Diagnostic} diagnostics information about the errors
      * @param {ts.Diagnostic} diagnostics information about the errors
      * @return {[type]}          [description]
      * @return {[type]}          [description]
      */
      */
-    logErrors(diagnostics: ts.Diagnostic[]) {
+    private logErrors(diagnostics: ts.Diagnostic[]) {
         let msg = [];
         let msg = [];
 
 
         diagnostics.forEach(diagnostic => {
         diagnostics.forEach(diagnostic => {
@@ -247,11 +247,24 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
     /**
     /**
      * clear out any caches, etc.
      * clear out any caches, etc.
      */
      */
-    resetLanguageService() {
+    private resetLanguageService() {
         this.projectFiles = null;
         this.projectFiles = null;
         this.versionMap = {};
         this.versionMap = {};
     }
     }
 
 
+    /**
+     * Determines if the file name/path provided is something we care about
+     * @param  {string} path
+     * @return {boolean}
+     */
+    private isValidFiletype(path: string): boolean {
+        const ext = Atomic.getExtension(path);
+        if (ext == ".ts") {
+            return true;
+        }
+        return false;
+    }
+
     /**
     /**
      * Inject this language service into the registry
      * Inject this language service into the registry
      * @return {[type]}             True if successful
      * @return {[type]}             True if successful
@@ -263,6 +276,14 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
     }
     }
 
 
     /*** ResourceService implementation ****/
     /*** ResourceService implementation ****/
+    /**
+     * Can this service extension handle the save event for the resource?
+     * @param  {EditorEvents.SaveResourceEvent} ev the
+     * @return {boolean}                return true if this service can handle the resource
+     */
+    canSave(ev: EditorEvents.SaveResourceEvent): boolean {
+        return this.isValidFiletype(ev.path);
+    }
 
 
     /**
     /**
      * Called once a resource has been saved
      * Called once a resource has been saved
@@ -289,31 +310,13 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
         }
         }
     }
     }
 
 
-    /**
-     * Can this service extension handle the save event for the resource?
-     * @param  {EditorEvents.SaveResourceEvent} ev the
-     * @return {boolean}                return true if this service can handle the resource
-     */
-    canSave(ev: EditorEvents.SaveResourceEvent): boolean {
-        const ext = Atomic.getExtension(ev.path);
-        //if (ext == ".ts" && !ev.path.match("\.d\.ts$")) {
-        if (ext == ".ts") {
-            return true;
-        }
-        return false;
-    }
-
     /**
     /**
      * Determine if we care if an asset has been deleted
      * Determine if we care if an asset has been deleted
      * @param  {EditorEvents.DeleteResourceEvent} ev
      * @param  {EditorEvents.DeleteResourceEvent} ev
-     * @return {boolean}                            true if we care
+     * @return {boolean} true if we care
      */
      */
     canDelete(ev: EditorEvents.DeleteResourceEvent): boolean {
     canDelete(ev: EditorEvents.DeleteResourceEvent): boolean {
-        const ext = Atomic.getExtension(ev.path);
-        if (ext == ".ts") {
-            return true;
-        }
-        return false;
+        return this.isValidFiletype(ev.path);
     }
     }
 
 
     /**
     /**
@@ -322,12 +325,14 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
      */
      */
     delete(ev: EditorEvents.DeleteResourceEvent) {
     delete(ev: EditorEvents.DeleteResourceEvent) {
         console.log(`${this.name}: received a delete resource event`);
         console.log(`${this.name}: received a delete resource event`);
-        if (this.versionMap[ev.path]) {
-            delete this.versionMap[ev.path];
-        }
-        let idx = this.projectFiles.indexOf(ev.path);
-        if (idx > -1) {
-            this.projectFiles.splice(idx, 1);
+        if (this.versionMap && this.projectFiles) {
+            if (this.versionMap[ev.path]) {
+                delete this.versionMap[ev.path];
+            }
+            let idx = this.projectFiles.indexOf(ev.path);
+            if (idx > -1) {
+                this.projectFiles.splice(idx, 1);
+            }
         }
         }
 
 
         // Delete the corresponding js file
         // Delete the corresponding js file
@@ -337,6 +342,44 @@ export default class TypescriptLanguageService implements ExtensionServices.Reso
             console.log(`${this.name}: deleting corresponding .js file`);
             console.log(`${this.name}: deleting corresponding .js file`);
             ToolCore.assetDatabase.deleteAsset(jsFileAsset);
             ToolCore.assetDatabase.deleteAsset(jsFileAsset);
         }
         }
+
+    }
+
+    /**
+     * Determine if we want to respond to resource renames
+     * @param  {EditorEvents.RenameResourceEvent} ev
+     * @return {boolean} true if we care
+     */
+    canRename(ev: EditorEvents.RenameResourceEvent): boolean {
+        return this.isValidFiletype(ev.path);
+    }
+
+    /**
+     * Handle the rename.  Should rename the corresponding .js file
+     * @param  {EditorEvents.RenameResourceEvent} ev
+     */
+    rename(ev: EditorEvents.RenameResourceEvent) {
+        console.log(`${this.name}: received a rename resource event`);
+        if (this.versionMap && this.projectFiles) {
+            let oldFile = this.versionMap[ev.path];
+            if (oldFile) {
+                delete this.versionMap[ev.path];
+                this.versionMap[ev.newPath] = oldFile;
+            }
+            let idx = this.projectFiles.indexOf(ev.path);
+            if (idx > -1) {
+                this.projectFiles[idx] = ev.newPath;
+            }
+        }
+
+        // Rename the corresponding js file
+        let jsFile = ev.path.replace(/\.ts$/, ".js");
+        let jsFileNew = ev.newPath.replace(/\.ts$/, ".js");
+        let jsFileAsset = ToolCore.assetDatabase.getAssetByPath(jsFile);
+        if (jsFileAsset) {
+            console.log(`${this.name}: renaming corresponding .js file`);
+            jsFileAsset.rename(jsFileNew);
+        }
     }
     }
 
 
     /*** ProjectService implementation ****/
     /*** ProjectService implementation ****/

+ 4 - 0
Script/AtomicEditor/ui/frames/MainFrame.ts

@@ -33,6 +33,7 @@ import ScriptWidget = require("ui/ScriptWidget");
 import MainFrameMenu = require("./menus/MainFrameMenu");
 import MainFrameMenu = require("./menus/MainFrameMenu");
 
 
 import MenuItemSources = require("./menus/MenuItemSources");
 import MenuItemSources = require("./menus/MenuItemSources");
+import ServiceLocator from "../../extensionServices/ServiceLocator";
 
 
 class MainFrame extends ScriptWidget {
 class MainFrame extends ScriptWidget {
 
 
@@ -73,6 +74,9 @@ class MainFrame extends ScriptWidget {
             this.disableProjectMenus();
             this.disableProjectMenus();
         });
         });
 
 
+        // Allow the service locator to hook into the event system
+        ServiceLocator.subscribeToEvents(this);
+
         this.showWelcomeFrame(true);
         this.showWelcomeFrame(true);
 
 
     }
     }

+ 0 - 20
Script/AtomicEditor/ui/frames/ProjectFrame.ts

@@ -25,7 +25,6 @@ import Editor = require("editor/Editor");
 import EditorEvents = require("editor/EditorEvents");
 import EditorEvents = require("editor/EditorEvents");
 import ProjectFrameMenu = require("./menus/ProjectFrameMenu");
 import ProjectFrameMenu = require("./menus/ProjectFrameMenu");
 import MenuItemSources = require("./menus/MenuItemSources");
 import MenuItemSources = require("./menus/MenuItemSources");
-import ServiceLocator from "../../extensionServices/ServiceLocator";
 
 
 class ProjectFrame extends ScriptWidget {
 class ProjectFrame extends ScriptWidget {
 
 
@@ -69,7 +68,6 @@ class ProjectFrame extends ScriptWidget {
 
 
         this.subscribeToEvent("ResourceAdded", (ev: ToolCore.ResourceAddedEvent) => this.handleResourceAdded(ev));
         this.subscribeToEvent("ResourceAdded", (ev: ToolCore.ResourceAddedEvent) => this.handleResourceAdded(ev));
         this.subscribeToEvent("ResourceRemoved", (ev: ToolCore.ResourceRemovedEvent) => this.handleResourceRemoved(ev));
         this.subscribeToEvent("ResourceRemoved", (ev: ToolCore.ResourceRemovedEvent) => this.handleResourceRemoved(ev));
-        this.subscribeToEvent(EditorEvents.DeleteResource, (ev: EditorEvents.DeleteResourceEvent) => this.handleDeleteResource(ev));
         this.subscribeToEvent("AssetRenamed", (ev: ToolCore.AssetRenamedEvent) => this.handleAssetRenamed(ev));
         this.subscribeToEvent("AssetRenamed", (ev: ToolCore.AssetRenamedEvent) => this.handleAssetRenamed(ev));
         this.subscribeToEvent(EditorEvents.InspectorProjectReference, (ev: EditorEvents.InspectorProjectReferenceEvent) => { this.handleInspectorProjectReferenceHighlight(ev.path) });
         this.subscribeToEvent(EditorEvents.InspectorProjectReference, (ev: EditorEvents.InspectorProjectReferenceEvent) => { this.handleInspectorProjectReferenceHighlight(ev.path) });
 
 
@@ -105,23 +103,9 @@ class ProjectFrame extends ScriptWidget {
 
 
     }
     }
 
 
-    /**
-     * Called when the user deletes a resource
-     * @param  {EditorEvents.DeleteResourceEvent} ev
-     */
-    handleDeleteResource(ev: EditorEvents.DeleteResourceEvent) {
-        var db = ToolCore.getAssetDatabase();
-        db.deleteAsset(ev.asset);
-        ServiceLocator.resourceServices.deleteResource(ev);
-    }
-
     handleResourceRemoved(ev: ToolCore.ResourceRemovedEvent) {
     handleResourceRemoved(ev: ToolCore.ResourceRemovedEvent) {
 
 
         var folderList = this.folderList;
         var folderList = this.folderList;
-        let asset = ToolCore.assetDatabase.getAssetByGUID(ev.guid);
-        if (asset) {
-            ServiceLocator.resourceServices.deleteResource({ path: asset.path, asset: asset });
-        }
         folderList.deleteItemByID(ev.guid);
         folderList.deleteItemByID(ev.guid);
 
 
         var container: Atomic.UILayout = <Atomic.UILayout>this.getWidget("contentcontainer");
         var container: Atomic.UILayout = <Atomic.UILayout>this.getWidget("contentcontainer");
@@ -410,8 +394,6 @@ class ProjectFrame extends ScriptWidget {
         this.folderList.setExpanded(this.resourcesID, true);
         this.folderList.setExpanded(this.resourcesID, true);
         this.refreshContent(this.resourceFolder);
         this.refreshContent(this.resourceFolder);
 
 
-        // tell extensions that the project has been unloaded
-        ServiceLocator.projectServices.projectLoaded(data);
     }
     }
 
 
     handleProjectUnloaded(data) {
     handleProjectUnloaded(data) {
@@ -422,8 +404,6 @@ class ProjectFrame extends ScriptWidget {
         var container: Atomic.UILayout = <Atomic.UILayout>this.getWidget("contentcontainer");
         var container: Atomic.UILayout = <Atomic.UILayout>this.getWidget("contentcontainer");
         container.deleteAllChildren();
         container.deleteAllChildren();
 
 
-        // tell extensions that the project has been loaded
-        ServiceLocator.projectServices.projectUnloaded(data);
     }
     }
 
 
     // Shows referenced file in projectframe
     // Shows referenced file in projectframe

+ 5 - 4
Script/AtomicEditor/ui/frames/ResourceFrame.ts

@@ -23,7 +23,6 @@
 import ScriptWidget = require("ui/ScriptWidget");
 import ScriptWidget = require("ui/ScriptWidget");
 import EditorEvents = require("editor/EditorEvents");
 import EditorEvents = require("editor/EditorEvents");
 import UIEvents = require("ui/UIEvents");
 import UIEvents = require("ui/UIEvents");
-import ServiceLocator from "../../extensionServices/ServiceLocator";
 
 
 // the root content of editor widgets (rootContentWidget property) are extended with an editor field
 // the root content of editor widgets (rootContentWidget property) are extended with an editor field
 // so we can access the editor they belong to from the widget itself
 // so we can access the editor they belong to from the widget itself
@@ -57,8 +56,8 @@ class ResourceFrame extends ScriptWidget {
         if (this.currentResourceEditor) {
         if (this.currentResourceEditor) {
             this.currentResourceEditor.save();
             this.currentResourceEditor.save();
             // Grab the path to this file and pass it to the save resource
             // Grab the path to this file and pass it to the save resource
-            ServiceLocator.resourceServices.saveResource({
-                path: ev.path || this.currentResourceEditor.fullPath,
+            this.sendEvent(EditorEvents.SaveResourceNotification, {
+                path: ev.path || this.currentResourceEditor.fullPath
             });
             });
         }
         }
 
 
@@ -68,7 +67,9 @@ class ResourceFrame extends ScriptWidget {
 
 
         for (var i in this.editors) {
         for (var i in this.editors) {
             this.editors[i].save();
             this.editors[i].save();
-            ServiceLocator.resourceServices.saveResource({ path: this.editors[i].fullPath });
+            this.sendEvent(EditorEvents.SaveResourceNotification, {
+                path: this.editors[i].fullPath
+            });
         }
         }
 
 
     }
     }

+ 16 - 2
Script/AtomicEditor/ui/modal/UIResourceOps.ts

@@ -56,7 +56,14 @@ export class ResourceDelete extends ModalWindow {
 
 
                 this.hide();
                 this.hide();
 
 
-                this.sendEvent(EditorEvents.DeleteResource, { path: this.asset.path, asset: this.asset });
+                let eventData = {
+                    path: this.asset.path
+                };
+
+                var db = ToolCore.getAssetDatabase();
+                db.deleteAsset(this.asset);
+
+                this.sendEvent(EditorEvents.DeleteResourceNotification, eventData);
 
 
                 return true;
                 return true;
             }
             }
@@ -363,8 +370,15 @@ export class RenameAsset extends ModalWindow {
 
 
                 this.hide();
                 this.hide();
 
 
-                if (this.asset.name != this.nameEdit.text)
+                if (this.asset.name != this.nameEdit.text) {
+                    let eventData = {
+                        path: this.asset.path,
+                        newPath: this.nameEdit.text,
+                        asset: this.asset
+                    };
                     this.asset.rename(this.nameEdit.text);
                     this.asset.rename(this.nameEdit.text);
+                    this.sendEvent(EditorEvents.RenameResourceNotification, eventData);
+                }
 
 
                 return true;
                 return true;
             }
             }