Skip to content

Commit

Permalink
More fixes towards File/New enable/disable state changes between VE and
Browse files Browse the repository at this point in the history
non-VE projects, and during template creation/renaming etc. (reference
#62)
  • Loading branch information
rat-moonshine committed Nov 30, 2017
1 parent d0dc140 commit dfd8ea1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ package actionScripts.plugin.templating
protected var newCSSComponentPopup:NewCSSFilePopup;
protected var newFilePopup:NewFilePopup;

private var resetIndex:int = -1;

public function TemplatingPlugin()
{
super();
Expand Down Expand Up @@ -139,9 +141,13 @@ package actionScripts.plugin.templating

override public function resetSettings():void
{
for each (var i:ISetting in settingsList)
resetIndex = 0;
for (resetIndex; resetIndex < settingsList.length; resetIndex++)
{
if (i is TemplateSetting) TemplateSetting(i).resetTemplate();
if (settingsList[resetIndex] is TemplateSetting)
{
TemplateSetting(settingsList[resetIndex]).resetTemplate();
}
}

readTemplates();
Expand Down Expand Up @@ -614,6 +620,8 @@ package actionScripts.plugin.templating
// deletes the file
custom.fileBridge.deleteFile();
}

resetIndex --;
}

if (!original)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
private function rename():void
{
isProject = setting.customTemplate.fileBridge.isDirectory;
txtRename.prompt = isProject ? "Enter a name" : "Enter a name and extension";
txtRename.prompt = isProject ? "Enter a name" : "Enter a name including an extension";
// show the file name cutting down .template word
var lastIndex:int = setting.label.indexOf(".template");
Expand All @@ -103,7 +103,7 @@
{
if (StringUtil.trim(txtRename.text).length == 0)
{
Alert.show("Please enter a valid file "+ (isProject ? "name." : "name with extension."), "Error!");
Alert.show("Please enter a valid file "+ (isProject ? "name." : "name including an extension."), "Error!");
return;
}
Expand All @@ -112,7 +112,7 @@
var tmpArr:Array = txtRename.text.split(".");
if (tmpArr.length < 2 || StringUtil.trim(tmpArr[tmpArr.length - 1]).length == 0)
{
Alert.show("Please enter a valid file name with extension.", "Error!");
Alert.show("Please enter a valid file name including an extension.", "Error!");
return;
}
}
Expand Down
27 changes: 21 additions & 6 deletions ide/MoonshineSharedCore/src/actionScripts/ui/menu/MenuPlugin.as
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ package actionScripts.ui.menu
import actionScripts.locator.IDEModel;
import actionScripts.plugin.PluginBase;
import actionScripts.plugin.actionscript.as3project.vo.AS3ProjectVO;
import actionScripts.plugin.fullscreen.FullscreenPlugin;
import actionScripts.plugin.settings.ISettingsProvider;
import actionScripts.plugin.settings.vo.ISetting;
import actionScripts.plugin.settings.vo.MultiOptionSetting;
Expand Down Expand Up @@ -110,6 +111,7 @@ package actionScripts.ui.menu

protected static var shortcutManager:KeyboardShortcutManager = KeyboardShortcutManager.getInstance();
private var buildingNativeMenu:Boolean = false;
private var lastSelectedProjectBeforeMacDisableStateChange:AS3ProjectVO;

override public function activate():void
{
Expand Down Expand Up @@ -210,9 +212,9 @@ package actionScripts.ui.menu
disableMenuOptionsForVEProject();
}

private function disableMenuOptionsForVEProject():void
private function disableMenuOptionsForVEProject(lastSelectedProject:AS3ProjectVO=null):void
{
var activeProject:AS3ProjectVO = model.activeProject as AS3ProjectVO;
var activeProject:AS3ProjectVO = lastSelectedProject ? lastSelectedProject : model.activeProject as AS3ProjectVO;

if (ConstantsCoreVO.IS_AIR)
{
Expand Down Expand Up @@ -404,6 +406,8 @@ package actionScripts.ui.menu
var itemsInTopMenu:Array = tmpTopMenu.items; // top-level menus, i.e. Moonshine, File etc.
var subItemsInItemOfTopMenu:Array = itemsInTopMenu[1].submenu.items; // i.e. File
subItemsInItemOfTopMenu[0].submenu.items[0].menu.addItemAt(menuObject, itemToAddAt);

windowMenus[1].items[0].items.insertAt(itemToAddAt, new MenuItem(event.label, null, event.listener));
}
else
{
Expand Down Expand Up @@ -435,7 +439,11 @@ package actionScripts.ui.menu
{
if (subItemsInItemOfTopMenu[i].label == event.label)
{
if (buildingNativeMenu) itemsInTopMenu[1].submenu.items[0].submenu.items[0].menu.removeItemAt(i);
if (buildingNativeMenu)
{
itemsInTopMenu[1].submenu.items[0].submenu.items[0].menu.removeItemAt(i);
windowMenus[1].items[0].items.removeAt(i);
}
else CustomMenuItem(menuBarMenu.items[0].submenu.items[0]).data.items.removeAt(i);
return;
}
Expand Down Expand Up @@ -471,9 +479,9 @@ package actionScripts.ui.menu
// in case of mac we need to update windowMenus for latter use
if (buildingNativeMenu)
{
windowMenus[1].items[0].items[i-1].label = event.newLabel;
windowMenus[1].items[0].items[i-1].event = (event.isProject ? "eventNewProjectFromTemplate" : "eventNewFileFromTemplate")+ event.newLabel;
windowMenus[1].items[0].items[i-1].data = event.newFileTemplate;
windowMenus[1].items[0].items[i].label = event.newLabel;
windowMenus[1].items[0].items[i].event = (event.isProject ? "eventNewProjectFromTemplate" : "eventNewFileFromTemplate")+ event.newLabel;
windowMenus[1].items[0].items[i].data = event.newFileTemplate;
}
return;
}
Expand All @@ -491,6 +499,8 @@ package actionScripts.ui.menu
FlexGlobals.topLevelApplication.nativeApplication.menu = mainMenu;
FlexGlobals.topLevelApplication.nativeWindow.menu = mainMenu;
}

lastSelectedProjectBeforeMacDisableStateChange = model.activeProject as AS3ProjectVO;
}

private function onMacNoMenuStateChange(event:Event):void
Expand All @@ -504,6 +514,8 @@ package actionScripts.ui.menu
FlexGlobals.topLevelApplication.nativeApplication.menu = mainMenu;
FlexGlobals.topLevelApplication.nativeWindow.menu = mainMenu;
}

lastSelectedProjectBeforeMacDisableStateChange = model.activeProject as AS3ProjectVO;
}

private function onMacEnableStateChange(event:Event):void
Expand All @@ -517,6 +529,9 @@ package actionScripts.ui.menu
FlexGlobals.topLevelApplication.nativeApplication.menu = mainMenu;
FlexGlobals.topLevelApplication.nativeWindow.menu = mainMenu;
}

// update menus for VE project
disableMenuOptionsForVEProject(lastSelectedProjectBeforeMacDisableStateChange);
}

private function onSDKStateChange(event:Event):void
Expand Down

0 comments on commit dfd8ea1

Please sign in to comment.