Skip to content

Commit

Permalink
- Menu item is now triggering from File/New after rename performs in
Browse files Browse the repository at this point in the history
Settings/Templating (tested in Windows)

(reference #62)
  • Loading branch information
rat-moonshine committed Nov 27, 2017
1 parent e4ef802 commit df4fc85
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ package actionScripts.plugin.templating
// Resetting a template just removes it from app-storage
var rdr:TemplateRenderer = TemplateRenderer(event.target);
var custom:FileLocation = rdr.setting.customTemplate;
var tmpOldIndex:int;
var oldFileName:String = TemplatingHelper.getTemplateLabel(custom);
var newFileNameWithExtension:String = event.value as String;
var newFileName:String = newFileNameWithExtension.split(".")[0];
Expand All @@ -638,6 +639,8 @@ package actionScripts.plugin.templating
return;
}

custom.fileBridge.moveTo(customNewLocation, true);

if (!custom.fileBridge.isDirectory)
{
// we need to update file location of the (if any) opened instance
Expand All @@ -653,28 +656,37 @@ package actionScripts.plugin.templating
ed.label = newFileNameWithExtension;
}
}
custom.fileBridge.moveTo(customNewLocation, true);
}
else dispatcher.dispatchEvent(new RenameApplicationEvent(RenameApplicationEvent.RENAME_APPLICATION_FOLDER, custom, customNewLocation));

rdr.setting.customTemplate = customNewLocation;
rdr.setting.label = rdr.setting.customTemplate.fileBridge.name;
rdr.dispatchEvent(new Event('refresh'));

// remove the existing File/New listener
if (!custom.fileBridge.isDirectory)
{

// remove the existing File/New listener
dispatcher.removeEventListener("eventNewFileFromTemplate"+ oldFileName, handleNewTemplateFile);
dispatcher.addEventListener("eventNewFileFromTemplate"+ newFileName, handleNewTemplateFile);

// update file list
tmpOldIndex = fileTemplates.indexOf(custom);
if (tmpOldIndex != -1) fileTemplates[tmpOldIndex] = customNewLocation;

// updating file/new menu
dispatcher.dispatchEvent(new TemplatingEvent(TemplatingEvent.RENAME_TEMPLATE, false, oldFileName, null, newFileName));
}
else
else
{
dispatcher.removeEventListener("eventNewFileFromTemplate"+ oldFileName, handleNewProjectFile);
dispatcher.addEventListener("eventNewFileFromTemplate"+ newFileName, handleNewProjectFile);
dispatcher.dispatchEvent(new RenameApplicationEvent(RenameApplicationEvent.RENAME_APPLICATION_FOLDER, custom, customNewLocation));

// remove the existing File/New listener
dispatcher.removeEventListener("eventNewProjectFromTemplate"+ oldFileName, handleNewProjectFile);
dispatcher.addEventListener("eventNewProjectFromTemplate"+ newFileName, handleNewProjectFile);

// update file list
tmpOldIndex = projectTemplates.indexOf(custom);
if (tmpOldIndex != -1) projectTemplates[tmpOldIndex] = customNewLocation;

// updating file/new menu
dispatcher.dispatchEvent(new TemplatingEvent(TemplatingEvent.RENAME_TEMPLATE, true, oldFileName, null, newFileName));
}

// updating file/new menu
dispatcher.dispatchEvent(new TemplatingEvent(TemplatingEvent.RENAME_TEMPLATE, true, oldFileName, null, newFileName));
rdr.setting.customTemplate = customNewLocation;
rdr.setting.label = rdr.setting.customTemplate.fileBridge.name;
rdr.dispatchEvent(new Event('refresh'));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ package actionScripts.ui.menu
{
/*if (buildingNativeMenu) itemsInTopMenu[1].submenu.items[0].submenu.items[0].menu.removeItemAt(i);
else*/ subItemsInItemOfTopMenu[i].label = event.newLabel;
subItemsInItemOfTopMenu[i].data.event = "eventNewFileFromTemplate"+ event.newLabel;
subItemsInItemOfTopMenu[i].data.event = (event.isProject ? "eventNewProjectFromTemplate" : "eventNewFileFromTemplate")+ event.newLabel;
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,6 @@
protected function onProjectRenameRequest(event:RenameApplicationEvent):void
{
event.from.fileBridge.moveTo(event.to, true);
for each (var i:AS3ProjectVO in model.projects)
{
if (i.folderLocation.fileBridge.nativePath == event.from.fileBridge.nativePath)
Expand Down

0 comments on commit df4fc85

Please sign in to comment.