public Project NewProject()
        {
            NewProjectDialog dialog = new NewProjectDialog();

            if (dialog.ShowDialog(owner) == DialogResult.OK)
            {
                try
                {
                    FlashDevelopActions.CheckAuthorName();
                    ProjectCreator creator = new ProjectCreator();
                    return(creator.CreateProject(dialog.TemplateDirectory, dialog.ProjectLocation, dialog.ProjectName, dialog.PackageName));
                }
                catch (Exception exception)
                {
                    string msg = TextHelper.GetString("Info.CouldNotCreateProject");
                    ErrorManager.ShowInfo(msg + " " + exception.Message);
                }
            }

            return(null);
        }
예제 #2
0
 public FileActions(IMainForm mainForm, FlashDevelopActions fdActions)
 {
     this.fdActions = fdActions;
     this.mainForm = mainForm;
 }
예제 #3
0
        public void AddFileFromTemplate(Project project, string inDirectory, string templatePath, bool noName)
        {
            try
            {
                // the template could be named something like "MXML.fdt", or maybe "Class.as.fdt"
                string extension = "";
                string fileName  = Path.GetFileNameWithoutExtension(templatePath);
                string caption   = TextHelper.GetString("Label.AddNew") + " ";

                if (fileName.IndexOf('.') > -1)
                {
                    // it's something like Class.as.fdt
                    extension = Path.GetExtension(fileName); // .as
                    if (noName)
                    {
                        caption += extension.Substring(1).ToUpper() + " " + TextHelper.GetString("Label.File");
                        fileName = TextHelper.GetString("Label.NewFile");
                    }
                    else
                    {
                        caption += Path.GetFileNameWithoutExtension(fileName);
                        fileName = TextHelper.GetString("Label.New") + Path.GetFileNameWithoutExtension(fileName).Replace(" ", ""); // just Class
                    }
                }
                else
                {
                    // something like MXML.fdt
                    extension = "." + fileName.ToLower();
                    caption  += fileName + " " + TextHelper.GetString("Label.File");
                    fileName  = TextHelper.GetString("Label.NewFile");
                }

                // let plugins handle the file creation
                Hashtable info = new Hashtable();
                info["templatePath"] = templatePath;
                info["inDirectory"]  = inDirectory;
                DataEvent de = new DataEvent(EventType.Command, "ProjectManager.CreateNewFile", info);
                EventManager.DispatchEvent(this, de);
                if (de.Handled)
                {
                    return;
                }

                LineEntryDialog dialog = new LineEntryDialog(caption, TextHelper.GetString("Label.FileName"), fileName + extension);
                dialog.SelectRange(0, fileName.Length);

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    FlashDevelopActions.CheckAuthorName();

                    string newFilePath = Path.Combine(inDirectory, dialog.Line);
                    if (!Path.HasExtension(newFilePath) && extension != ".ext")
                    {
                        newFilePath = Path.ChangeExtension(newFilePath, extension);
                    }

                    if (!ConfirmOverwrite(newFilePath))
                    {
                        return;
                    }

                    // save this so when we are asked to process args, we know what file it's talking about
                    lastFileFromTemplate = newFilePath;

                    mainForm.FileFromTemplate(templatePath, newFilePath);
                }
            }
            catch (UserCancelException) { }
            catch (Exception exception)
            {
                ErrorManager.ShowError(exception);
            }
        }
예제 #4
0
 public FileActions(IMainForm mainForm, FlashDevelopActions fdActions)
 {
     this.fdActions = fdActions;
     this.mainForm  = mainForm;
 }
예제 #5
0
		public void Initialize()
		{
            LoadSettings();
            pluginImage = MainForm.FindImage("100");
            pluginDesc = TextHelper.GetString("Info.Description");
            openFileQueue = new Queue<String>();

            Icons.Initialize(MainForm);
            EventManager.AddEventHandler(this, eventMask);

            showProjectClasspaths = Settings.ShowProjectClasspaths;
            showGlobalClasspaths = Settings.ShowGlobalClasspaths;

            #region Actions and Event Listeners

            menus = new FDMenus(MainForm);
            menus.ProjectMenu.ProjectItemsEnabled = false;
            menus.TestMovie.Enabled = false;
            menus.TestMovie.Click += delegate { TestMovie(); };
            menus.BuildProject.Enabled = false;
            menus.BuildProject.Click += delegate { BuildProject(); };
            menus.View.Click += delegate { OpenPanel(); };
            menus.GlobalClasspaths.Click += delegate { OpenGlobalClasspaths(); };
            menus.ConfigurationSelector.SelectedIndexChanged += delegate 
            {
                bool isDebug = menus.ConfigurationSelector.Text == TextHelper.GetString("Info.Debug");
                FlexCompilerShell.Cleanup();
                pluginUI.IsTraceDisabled = !isDebug;
                Project project = activeProject;
                if (project != null) project.TraceEnabled = isDebug;
            };
            menus.TargetBuildSelector.KeyDown += new KeyEventHandler(TargetBuildSelector_KeyDown);
            menus.TargetBuildSelector.SelectedIndexChanged += delegate { ApplyTargetBuild(); };
            menus.TargetBuildSelector.LostFocus += delegate { ApplyTargetBuild(); };
            
            menus.ProjectMenu.NewProject.Click += delegate { NewProject(); };
            menus.ProjectMenu.OpenProject.Click += delegate { OpenProject(); };
            menus.ProjectMenu.ImportProject.Click += delegate { ImportProject(); };
            menus.ProjectMenu.CloseProject.Click += delegate { CloseProject(false); };
            menus.ProjectMenu.OpenResource.Click += delegate { OpenResource(); };
            menus.ProjectMenu.TestMovie.Click += delegate { TestMovie(); };
            menus.ProjectMenu.RunProject.Click += delegate { RunProject(); };
            menus.ProjectMenu.BuildProject.Click += delegate { BuildProject(); };
            menus.ProjectMenu.CleanProject.Click += delegate { CleanProject(); };
            menus.ProjectMenu.Properties.Click += delegate { OpenProjectProperties(); };
            menus.RecentProjects.ProjectSelected += delegate(string projectPath) { OpenProjectSilent(projectPath); };

            buildActions = new BuildActions(MainForm,menus);
            buildActions.BuildComplete += BuildComplete;
            buildActions.BuildFailed += BuildFailed;

            flashDevelopActions = new FlashDevelopActions(MainForm);

            fileActions = new FileActions(MainForm,flashDevelopActions);
            fileActions.OpenFile += OpenFile;
            fileActions.FileDeleted += FileDeleted;
            fileActions.FileMoved += FileMoved;
            fileActions.FileCopied += FilePasted;

            projectActions = new ProjectActions(pluginUI);

            pluginUI = new PluginUI(this, menus, fileActions, projectActions);
            pluginUI.NewProject += delegate { NewProject(); };
            pluginUI.OpenProject += delegate { OpenProject(); };
            pluginUI.ImportProject += delegate { ImportProject(); };
            pluginUI.Rename += fileActions.Rename;
            pluginUI.TreeBar.ShowHidden.Click += delegate { ToggleShowHidden(); };
            pluginUI.TreeBar.Synchronize.Click += delegate { TreeSyncToCurrentFile(); };
            pluginUI.TreeBar.SynchronizeMain.Click += delegate { TreeSyncToMainFile(); };
            pluginUI.TreeBar.ProjectProperties.Click += delegate { OpenProjectProperties(); };
            pluginUI.TreeBar.RefreshSelected.Click += delegate { TreeRefreshSelectedNode(); };
            pluginUI.TreeBar.ProjectTypes.Click += delegate 
            {
                DataEvent de = new DataEvent(EventType.Command, "ASCompletion.TypesExplorer", null);
                EventManager.DispatchEvent(this, de);
            };

            pluginUI.Menu.Open.Click += delegate { TreeOpenItems(); };
            pluginUI.Menu.Execute.Click += delegate { TreeExecuteItems(); };
            pluginUI.Menu.Insert.Click += delegate { TreeInsertItem(); };
            pluginUI.Menu.AddLibrary.Click += delegate { TreeAddLibraryItems(); };
            pluginUI.Menu.AlwaysCompile.Click += delegate { TreeAlwaysCompileItems(); };
            pluginUI.Menu.SetDocumentClass.Click += delegate { TreeDocumentClass(); };
            pluginUI.Menu.DocumentClass.Click += delegate { TreeDocumentClass(); };
            pluginUI.Menu.Browse.Click += delegate { TreeBrowseItem(); };
            pluginUI.Menu.Cut.Click += delegate { TreeCutItems(); };
            pluginUI.Menu.Copy.Click += delegate { TreeCopyItems(); };
            pluginUI.Menu.Paste.Click += delegate { TreePasteItems(); };
            pluginUI.Menu.Delete.Click += delegate { TreeDeleteItems(); };
            pluginUI.Menu.LibraryOptions.Click += delegate { TreeLibraryOptions(); };
            pluginUI.Menu.HideItem.Click += delegate { TreeHideItems(); };
            pluginUI.Menu.ShowHidden.Click += delegate { ToggleShowHidden(); };
            pluginUI.Menu.AddFileFromTemplate += TreeAddFileFromTemplate;
            pluginUI.Menu.AddNewFolder.Click += delegate { TreeAddFolder(); };
            pluginUI.Menu.AddLibraryAsset.Click += delegate { TreeAddAsset(); };
            pluginUI.Menu.AddExistingFile.Click += delegate { TreeAddExistingFile(); };
            pluginUI.Menu.TestMovie.Click += delegate { TestMovie(); };
            pluginUI.Menu.BuildProject.Click += delegate { 
                BuildProject(); 
            };
            pluginUI.Menu.CloseProject.Click += delegate { CloseProject(false); };
            pluginUI.Menu.Properties.Click += delegate { OpenProjectProperties(); };
            pluginUI.Menu.ShellMenu.Click += delegate { TreeShowShellMenu(); };
            pluginUI.Menu.CommandPrompt.Click += delegate { TreeShowCommandPrompt(); };
            pluginUI.Menu.BuildProjectFile.Click += delegate { BackgroundBuild(); };
            pluginUI.Menu.BuildProjectFiles.Click += delegate { BackgroundBuild(); };
            pluginUI.Menu.BuildAllProjects.Click += delegate { FullBuild(); };
            pluginUI.Menu.TestAllProjects.Click += delegate { TestBuild(); };
            pluginUI.Menu.FindAndReplace.Click += delegate { FindAndReplace(); };
            pluginUI.Menu.FindInFiles.Click += delegate { FindInFiles(); };
            pluginUI.Menu.CopyClassName.Click += delegate { CopyClassName(); };
            pluginUI.Menu.AddSourcePath.Click += delegate { AddSourcePath(); };
            pluginUI.Menu.RemoveSourcePath.Click += delegate { RemoveSourcePath(); };
            pluginUI.Menu.Opening += new CancelEventHandler(this.MenuOpening);

            Tree.MovePath += fileActions.Move;
            Tree.CopyPath += fileActions.Copy;
            Tree.DoubleClick += delegate { TreeDoubleClick(); };

            #endregion

            pluginPanel = MainForm.CreateDockablePanel(pluginUI, Guid, Icons.Project.Img, DockState.DockRight);
            buildQueue = new Queue<String>();
            buildTimer = new Timer();
            buildTimer.Interval = 500;
            buildTimer.Tick += new EventHandler(OnBuildTimerTick);
            buildingAll = false;
            runOutput = false;
        }
예제 #6
0
    public static void Execute()
    {
        if ( Globals.SciControl == null ) return;

        ScintillaControl sci = Globals.SciControl;

        string selectStr = sci.SelText;
        if ( selectStr.Length < 1 ) {
            MessageBox.Show("クラスにするコマンドを選択してください","エラー",MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
        }

        Project project = (Project) PluginBase.CurrentProject;
        if (project == null) return;

        MainForm mainForm = (MainForm) Globals.MainForm;
        FlashDevelopActions flashDevelopActions = new FlashDevelopActions(mainForm);
        FileActions fileActions = new FileActions(mainForm, flashDevelopActions);

        if (!File.Exists(TEMP_PATH))
        {
            StreamWriter tmpWriter = new StreamWriter(TEMP_PATH, false, System.Text.Encoding.UTF8, 512);
            tmpWriter.Write(TMP_FILE);
            tmpWriter.Close();
        }

        ITabbedDocument currentDocument = (ITabbedDocument) mainForm.CurrentDocument;
        String parentPath = System.IO.Path.GetDirectoryName(currentDocument.FileName);

        fileActions.AddFileFromTemplate(project,parentPath,TEMP_PATH);
        String fileName = fileActions.ProcessArgs(project, "$(FileName)");

        String newFilePath = parentPath + "\\" + fileName + ".as";
        if (!File.Exists(newFilePath)) {
            TraceManager.Add( "キャンセルされました" );
            return;
        }

        StreamReader reader = new StreamReader(newFilePath);
        String value = reader.ReadToEnd();
        reader.Close();

        StreamWriter writer = new StreamWriter(newFilePath, false, System.Text.Encoding.UTF8, 512);
        writer.Write(fileActions.ProcessArgs(project, value));
        writer.Close();

        string insText = "new "+fileName+"()";
        sci.BeginUndoAction();
        sci.Clear();
        sci.InsertText(sci.CurrentPos, insText);
        sci.SelectionStart = sci.CurrentPos;
        sci.SelectionEnd = sci.CurrentPos + insText.Length;
        sci.EndUndoAction();
        TraceManager.Add( fileName + " が作成されました" );
    }