Skip to content

Commit

Permalink
Initial changes to custom template project creation through File/New
Browse files Browse the repository at this point in the history
(reference #62)
  • Loading branch information
rat-moonshine committed Nov 22, 2017
1 parent 77b5915 commit ecb4d56
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
////////////////////////////////////////////////////////////////////////////////
package actionScripts.plugins.as3project
{
import actionScripts.events.RefreshTreeEvent;
import actionScripts.utils.UtilsCore;

import flash.display.DisplayObject;
import flash.events.Event;
import flash.filesystem.File;
Expand All @@ -33,10 +30,13 @@ package actionScripts.plugins.as3project
import actionScripts.events.NewProjectEvent;
import actionScripts.events.OpenFileEvent;
import actionScripts.events.ProjectEvent;
import actionScripts.events.RefreshTreeEvent;
import actionScripts.factory.FileLocation;
import actionScripts.locator.IDEModel;
import actionScripts.plugin.actionscript.as3project.settings.NewProjectSourcePathListSetting;
import actionScripts.plugin.actionscript.as3project.vo.AS3ProjectVO;
import actionScripts.plugin.project.ProjectTemplateType;
import actionScripts.plugin.project.ProjectType;
import actionScripts.plugin.settings.SettingsView;
import actionScripts.plugin.settings.vo.BooleanSetting;
import actionScripts.plugin.settings.vo.ISetting;
Expand All @@ -48,14 +48,14 @@ package actionScripts.plugins.as3project
import actionScripts.plugin.settings.vo.StaticLabelSetting;
import actionScripts.plugin.settings.vo.StringSetting;
import actionScripts.plugin.templating.TemplatingHelper;
import actionScripts.plugin.templating.TemplatingPlugin;
import actionScripts.plugins.as3project.exporter.FlashDevelopExporter;
import actionScripts.plugins.as3project.importer.FlashDevelopImporter;
import actionScripts.ui.tabview.CloseTabEvent;
import actionScripts.plugin.project.ProjectTemplateType;
import actionScripts.plugin.project.ProjectType;
import actionScripts.utils.SDKUtils;
import actionScripts.utils.UtilsCore;
import actionScripts.valueObjects.ConstantsCoreVO;
import actionScripts.valueObjects.TemplateVO;
import actionScripts.valueObjects.TemplateVO;

public class CreateProject
{
Expand All @@ -77,6 +77,7 @@ package actionScripts.plugins.as3project
private var isFeathersProject:Boolean;
private var isVisualEditorProject:Boolean;
private var isAway3DProject:Boolean;
private var isCustomTemplateProject:Boolean;

private var _isProjectFromExistingSource:Boolean;
private var _projectTemplateType:String;
Expand All @@ -86,18 +87,20 @@ package actionScripts.plugins.as3project
{
if (!allProjectTemplates)
{
allProjectTemplates = new ArrayCollection();
allProjectTemplates.addAll(ConstantsCoreVO.TEMPLATES_PROJECTS);
allProjectTemplates.addAll(ConstantsCoreVO.TEMPLATES_PROJECTS_SPECIALS);
allProjectTemplates = new ArrayCollection(TemplatingPlugin.projectTemplates);
}

if (isAllowedTemplateFile(event.projectFileEnding))
// determine if a given project is custom or Moonshine default
var customTemplateDirectory:FileLocation = model.fileCore.resolveApplicationStorageDirectoryPath("templates/projects");
if (event.templateDir.fileBridge.nativePath.indexOf(customTemplateDirectory.fileBridge.nativePath) != -1) isCustomTemplateProject = true;

if (isCustomTemplateProject || event.projectFileEnding == "awd")
{
createAS3Project(event);
}
else if (event.projectFileEnding == "awd")
createCustomOrAway3DProject(event);
}
else if (isAllowedTemplateFile(event.projectFileEnding))
{
createAway3DProject(event);
createAS3Project(event);
}
}

Expand Down Expand Up @@ -244,7 +247,7 @@ package actionScripts.plugins.as3project

if (isOpenProjectCall)
{
settings.getSettingsList().splice(3, 0, new ListSetting(this, "projectTemplateType", "Select Template Type", allProjectTemplates, "title"));
settings.getSettingsList().splice(3, 0, new ListSetting(this, "projectTemplateType", "Select Template Type", allProjectTemplates, "name"));
}

settingsView.addEventListener(SettingsView.EVENT_SAVE, createSave);
Expand All @@ -261,7 +264,7 @@ package actionScripts.plugins.as3project
templateLookup[project] = event.templateDir;
}

private function createAway3DProject(event:NewProjectEvent):void
private function createCustomOrAway3DProject(event:NewProjectEvent):void
{
project = new AS3ProjectVO(model.fileCore.resolveDocumentDirectoryPath(), null, false);
cookie = SharedObject.getLocal("moonshine-ide-local");
Expand Down Expand Up @@ -302,7 +305,7 @@ package actionScripts.plugins.as3project

private function isAllowedTemplateFile(projectFileExtension:String):Boolean
{
return projectFileExtension != "as3proj" || projectFileExtension != "veditorproj";
return projectFileExtension != "as3proj" || projectFileExtension != "veditorproj" || !projectFileExtension;
}

private function getProjectSettings(project:AS3ProjectVO, eventObject:NewProjectEvent):SettingsWrapper
Expand All @@ -320,10 +323,10 @@ package actionScripts.plugins.as3project
]));
}

if (eventObject.projectFileEnding == "awd")
if (eventObject.projectFileEnding == "awd" || isCustomTemplateProject)
{
return new SettingsWrapper("Name & Location", Vector.<ISetting>([
new StaticLabelSetting('New Away3D Project'),
new StaticLabelSetting(isCustomTemplateProject ? 'New ' + eventObject.templateDir.fileBridge.name : 'New Away3D Project'),
new StringSetting(project, 'projectName', 'Project name', 'a-zA-Z0-9._'),
new PathSetting(project, 'folderPath', 'Project directory', true, null, false, true)
]));
Expand Down Expand Up @@ -433,9 +436,12 @@ package actionScripts.plugins.as3project
new ProjectEvent(ProjectEvent.ADD_PROJECT, project)
);

GlobalEventDispatcher.getInstance().dispatchEvent(
new OpenFileEvent(OpenFileEvent.OPEN_FILE, project.targets[0], -1, project.projectFolder)
);
if (!isCustomTemplateProject)
{
GlobalEventDispatcher.getInstance().dispatchEvent(
new OpenFileEvent(OpenFileEvent.OPEN_FILE, project.targets[0], -1, project.projectFolder)
);
}
}

if (view.exportProject)
Expand Down Expand Up @@ -553,6 +559,13 @@ package actionScripts.plugins.as3project
isAway3DProject = true;
return pvo;
}

// we copy everything from template to target folder
// in case of custom project template and terminate
if (isCustomTemplateProject)
{
return pvo;
}

// If this an ActionScript Project then we need to copy selective file/folders for web or desktop
var descriptorFileLocation:FileLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ package actionScripts.plugins.away3d
if (!executablePath) openAway3DBuilder(null);
else runAwdFile(awdFileObject);
}
else error("Now Away3D file found.");
else error("No Away3D file found.");
}

private function runAwdFile(withFile:File=null):void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ package actionScripts.factory
return fileBridge.resolvePath(path);
}

public function get name():String
{
return fileBridge.name;
}

//--------------------------------------------------------------------------
//
// WEB METHODS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1028,23 +1028,17 @@ package actionScripts.plugin.templating
{
if ( TemplatingHelper.getTemplateLabel(projectTemplate) == eventName )
{
var customTemplate:FileLocation = getCustomFileFor(projectTemplate);
var extension:String = null;
var settingsFile:FileLocation = null;

if (customTemplate.fileBridge.exists)
{
projectTemplate = customTemplate;
}

if (eventName == "Away3D Project")
{
extension = "awd";
}
else
{
settingsFile = getSettingsTemplateFileLocation(projectTemplate);
extension = TemplatingHelper.getExtension(settingsFile);
extension = settingsFile ? TemplatingHelper.getExtension(settingsFile) : null;
}

dispatcher.dispatchEvent(new NewProjectEvent(NewProjectEvent.CREATE_NEW_PROJECT,
Expand Down

0 comments on commit ecb4d56

Please sign in to comment.