예제 #1
0
 public static void CheckAuthorName()
 {
     if (nameAsked) return;
     nameAsked = true;
     foreach (Argument arg in PluginBase.MainForm.CustomArguments)
     {
         if (arg.Key == "DefaultUser" && arg.Value == "...")
         {
             String caption = TextHelper.GetString("Title.AuthorName");
             LineEntryDialog prompt = new LineEntryDialog(caption, "Author", "");
             if (prompt.ShowDialog() == DialogResult.OK)
             {
                 arg.Value = prompt.Line;
             }
         }
     }
 }
예제 #2
0
 public static void AddToQueue(ASResult target, bool outputResults)
 {
     string originalName = RefactoringHelper.GetRefactorTargetName(target);
     string label = TextHelper.GetString("Label.NewName");
     string title = string.Format(TextHelper.GetString("Title.RenameDialog"), originalName);
     LineEntryDialog askName = new LineEntryDialog(title, label, originalName);
     if (askName.ShowDialog() == DialogResult.OK)
     {
         string newName = askName.Line.Trim();
         if (newName.Length == 0 || newName == originalName) return;
         queue.Add(new Rename(target, outputResults, newName));
         if (ASContext.Context.CurrentModel.haXe && target.Member != null &&
             (target.Member.Flags & (FlagType.Getter | FlagType.Setter)) > 0)
         {
             List<MemberModel> list = target.Member.Parameters;
             if (list[0].Name == "get") RenameMember(target.InClass, "get_" + originalName, "get_" + newName, outputResults);
             if (list[1].Name == "set") RenameMember(target.InClass, "set_" + originalName, "set_" + newName, outputResults);
         }
         if (currentCommand == null) ExecuteFirst();
     }
 }
예제 #3
0
 /// <summary>
 /// Invoked when the user selects the "Extract Local Variable" command
 /// </summary>
 private void ExtractLocalVariableClicked(Object sender, EventArgs e)
 {
     try
     {
         String suggestion = "newVar";
         String label = TextHelper.GetString("Label.NewName");
         String title = TextHelper.GetString("Title.ExtractLocalVariableDialog");
         LineEntryDialog askName = new LineEntryDialog(title, label, suggestion);
         DialogResult choice = askName.ShowDialog();
         if (choice == DialogResult.OK && askName.Line.Trim().Length > 0 && askName.Line.Trim() != suggestion)
         {
             suggestion = askName.Line.Trim();
         }
         if (choice == DialogResult.OK)
         {
             ExtractLocalVariableCommand command = new ExtractLocalVariableCommand(suggestion);
             command.Execute();
         }
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }
예제 #4
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 (!FileHelper.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);
            }
        }
예제 #5
0
        public void Copy(string fromPath, string toPath)
        {
            if (CancelAction(ProjectFileActionsEvents.FileCopy, new string[] { fromPath, toPath })) return;

            try
            {
                // try to fix toPath if it's a filename
                if (File.Exists(toPath))
                    toPath = Path.GetDirectoryName(toPath);

                // avoid recursive copy
                if (Directory.Exists(fromPath) && toPath.StartsWith(fromPath, StringComparison.OrdinalIgnoreCase))
                    throw new IOException(TextHelper.GetString("Info.RecursiveCopyDetected"));

                toPath = Path.Combine(toPath, Path.GetFileName(fromPath));

                // create copies of a file
                if (toPath == fromPath)
                {
                    string copyPath = Path.Combine(
                        Path.GetDirectoryName(toPath),
                        String.Format(TextHelper.GetString("Label.CopyOf"), Path.GetFileNameWithoutExtension(fromPath))
                        ) + Path.GetExtension(fromPath);

                    int copies = 1;
                    while (File.Exists(copyPath))
                    {
                        copies++;
                        copyPath = Path.Combine(
                            Path.GetDirectoryName(toPath),
                            String.Format(TextHelper.GetString("Label.CopyOf") + " ({1})", Path.GetFileNameWithoutExtension(fromPath), copies)
                            ) + Path.GetExtension(fromPath);
                    }

                    // offer to choose the new name
                    string label = TextHelper.GetString("Info.NewDuplicateName");
                    string title = String.Format(TextHelper.GetString("Info.DuplicatingFile"), Path.GetFileName(toPath));
                    string suggestion = Path.GetFileNameWithoutExtension(copyPath);
                    LineEntryDialog askName = new LineEntryDialog(title, label, suggestion);
                    DialogResult choice = askName.ShowDialog();
                    if (choice == DialogResult.OK && askName.Line.Trim().Length > 0)
                    {
                        copyPath = Path.Combine(Path.GetDirectoryName(toPath), askName.Line.Trim()) + Path.GetExtension(toPath);
                    }
                    else throw new UserCancelException();
                    toPath = copyPath;
                }

                if (!FileHelper.ConfirmOverwrite(toPath)) return;

                OnFileCreated(toPath);

                if (Directory.Exists(fromPath)) FileHelper.CopyDirectory(fromPath, toPath, true);
                else File.Copy(fromPath, toPath, true);

                OnFilePasted(fromPath, toPath);
            }
            catch (UserCancelException uex)
            {
                throw uex;
            }
            catch (Exception exception)
            {
                ErrorManager.ShowError(exception);
            }
        }
예제 #6
0
        void Commit_Click(object sender, EventArgs e)
        {
            String title = TextHelper.GetString("Label.Commit");
            String msg = TextHelper.GetString("Info.EnterMessage");
            LineEntryDialog led = new LineEntryDialog(title, msg, "");
            if (led.ShowDialog() != DialogResult.OK || led.Line == "")
                return;

            new CommitCommand(GetPathsArray(), led.Line);
        }
예제 #7
0
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
		{
            TextEvent te = e as TextEvent;
            DataEvent de = e as DataEvent;
            Project project;
            switch (e.Type)
            {
                case EventType.UIStarted:
                    // for some reason we have to do this on the next message loop for the tree
                    // state to be restored properly.
                    pluginUI.BeginInvoke((MethodInvoker)delegate 
                    { 
                        BroadcastMenuInfo(); 
                        BroadcastToolBarInfo(); 
                        OpenLastProject(); 
                    });
                    break;

                // replace $(SomeVariable) type stuff with things we know about
                case EventType.ProcessArgs:
                    project = activeProject; // replace arguments using active project data

                    if (!ProjectCreator.IsRunning)
                    {
                        if (project != null && te.Value.IndexOf('$') >= 0)
                        {
                            // steal macro names and values from the very useful BuildEvent macros
                            BuildEventVars vars = new BuildEventVars(project);

                            vars.AddVar("CompilerConfiguration", menus.ConfigurationSelector.Text);
                            vars.AddVar("BuildIPC", buildActions.IPCName);

                            foreach (BuildEventInfo info in vars.GetVars())
                                te.Value = te.Value.Replace(info.FormattedName, info.Value);

                            // give the FileActions class an opportunity to process arguments
                            // it may know about (if it was responsible for creating the file)
                            te.Value = fileActions.ProcessArgs(project, te.Value);
                        }
                        else
                        {
                            BuildEventVars vars = new BuildEventVars(null);
                            vars.AddVar("ProjectDir", PluginBase.MainForm.WorkingDirectory);
                            foreach (BuildEventInfo info in vars.GetVars())
                                te.Value = te.Value.Replace(info.FormattedName, info.Value);
                        }
                    }
                    break;

                case EventType.FileOpening:
                    // if this is a project file, we can handle it ourselves
                    if (FileInspector.IsProject(te.Value))
                    {
                        te.Handled = true;
                        OpenProjectSilent(te.Value);
                    }
                    else if (te.Value.EndsWith(".swf"))
                    {
                        te.Handled = true;
                        OpenSwf(te.Value);
                    }
                    break;

                case EventType.FileOpen:
                    SetDocumentIcon(MainForm.CurrentDocument);
                    OpenNextFile(); // it's safe to open any other files on the queue
                    break;

                case EventType.FileSave:
                    // refresh the tree to update any included <mx:Script> tags
                    string path = MainForm.CurrentDocument.FileName;
                    if (Settings.EnableMxmlMapping && FileInspector.IsMxml(path, Path.GetExtension(path).ToLower()) && Tree.NodeMap.ContainsKey(path))
                    {
                        Tree.RefreshNode(Tree.NodeMap[path]);
                    }
                    TabColors.UpdateTabColors(Settings);
                    break;

                case EventType.FileSwitch:
                    TabColors.UpdateTabColors(Settings);
                    break;

                case EventType.ProcessStart:
                    buildActions.NotifyBuildStarted();
                    break;

                case EventType.ProcessEnd:
                    string result = te.Value;
                    buildActions.NotifyBuildEnded(result);
                    break;

                case EventType.ApplySettings:
                    TabColors.UpdateTabColors(Settings);
                    break;

                case EventType.Command:
                    if (de.Action.StartsWith("ProjectManager."))
                    if (de.Action == ProjectManagerCommands.NewProject)
                    {
                        NewProject();
                        e.Handled = true;
                    }
                    else if (de.Action == ProjectManagerCommands.OpenProject)
                    {
                        if (de.Data != null && File.Exists((string)de.Data))
                        {
                            OpenProjectSilent((string)de.Data);
                        }
                        else OpenProject();
                        e.Handled = true;
                    }
                    else if (de.Action == ProjectManagerCommands.SendProject)
                    {
                        BroadcastProjectInfo(activeProject);
                        e.Handled = true;
                    }
                    else if (de.Action == ProjectManagerCommands.InstalledSDKsChanged)
                    {
                        project = activeProject; // TODO refresh SDK for all projects
                        BuildActions.GetCompilerPath(project); // refresh project's SDK
                        e.Handled = true;
                    }
                    else if (de.Action == ProjectManagerCommands.BuildProject)
                    {
                        if (Tree.Projects.Count > 0)
                        {
                            AutoSelectConfiguration((string)de.Data);
                            BuildProject();
                            e.Handled = true;
                        }
                    }
                    else if (de.Action == ProjectManagerCommands.TestMovie)
                    {
                        project = activeProject; // TODO we need a "runnable" project
                        if (project != null)
                        {
                            AutoSelectConfiguration((string)de.Data);
                            TestMovie();
                            e.Handled = true;
                        }
                    }
                    else if (de.Action == ProjectManagerCommands.PlayOutput)
                    {
                        if (activeProject != null || de.Data != null)
                        {
                            OpenSwf((string)de.Data);
                            de.Handled = true;
                        }
                    }
                    else if (de.Action == ProjectManagerCommands.RestartFlexShell)
                    {
                        FlexCompilerShell.Cleanup();
                    }
                    else if (de.Action == ProjectManagerCommands.SetConfiguration)
                    {
                        AutoSelectConfiguration((string)de.Data);
                    }
                    else if (de.Action == ProjectManagerCommands.HotBuild)
                    {
                        if (activeProject != null)
                        {
                            AutoSelectConfiguration((string)de.Data);
                            TestMovie();
                            e.Handled = true;
                        }
                    }
                    else if (de.Action == ProjectManagerCommands.RefreshTree)
                    {
                        TreeRefreshSelectedNode();
                    }
                    else if (de.Action == ProjectManagerCommands.LineEntryDialog)
                    {
                        Hashtable info = (Hashtable)de.Data;
                        LineEntryDialog askName = new LineEntryDialog((string)info["title"], (string)info["label"], (string)info["suggestion"]);
                        DialogResult choice = askName.ShowDialog();
                        if (choice == DialogResult.OK && askName.Line.Trim().Length > 0 && askName.Line.Trim() != (string)info["suggestion"])
                        {
                            info["suggestion"] = askName.Line.Trim();
                        }
                        if (choice == DialogResult.OK)
                        {
                            e.Handled = true;
                        }
                    }
                    break;

                case EventType.Keys:
                    e.Handled = HandleKeyEvent(e as KeyEvent);
                    break;
            }
        }
예제 #8
0
 private void editCommandButton_Click(object sender, System.EventArgs e)
 {
     string caption;
     string label;
     if (testMovieCombo.SelectedIndex == 4)
     {
         caption = TextHelper.GetString("Title.CustomTestMovieDocument");
         label = TextHelper.GetString("Label.CustomTestMovieDocument");
     }
     else
     {
         caption = TextHelper.GetString("Title.CustomTestMovieCommand");
         label = TextHelper.GetString("Label.CustomTestMovieCommand");
     }
     LineEntryDialog dialog = new LineEntryDialog(caption, label, project.TestMovieCommand ?? "");
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         project.TestMovieCommand = dialog.Line;
         Modified();
         btnOK.Focus();
     }
 }
예제 #9
0
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
		{
            TextEvent te = e as TextEvent;
            DataEvent de = e as DataEvent;
            switch (e.Type)
            {
                case EventType.UIStarted:
                    // for some reason we have to do this on the next message loop for the tree
                    // state to be restored properly.
                    pluginUI.BeginInvoke((MethodInvoker)delegate { BroadcastMenuInfo(); OpenLastProject(); });
                    break;

                // replace $(SomeVariable) type stuff with things we know about
                case EventType.ProcessArgs:
                    if (!ProjectCreator.IsRunning && project != null && te.Value.IndexOf('$') >= 0)
                    {
                        // steal macro names and values from the very useful BuildEvent macros
                        BuildEventVars vars = new BuildEventVars(project);

                        // this operation requires a message to ASCompletion so we don't add it to the BuildEventVars
                        string cpath = BuildActions.GetCompilerPath(project);
                        if (File.Exists(cpath)) cpath = Path.GetDirectoryName(cpath);

                        if (project.Language == "as3") vars.AddVar("FlexSDK", cpath);
                        vars.AddVar("CompilerPath", cpath);
                        vars.AddVar("CompilerConfiguration", menus.ConfigurationSelector.Text);
                        vars.AddVar("BuildConfiguration", pluginUI.IsTraceDisabled ? "release" : "debug");
                        vars.AddVar("BuildIPC", buildActions.IPCName);

                        foreach (BuildEventInfo info in vars.GetVars())
                            te.Value = te.Value.Replace(info.FormattedName, info.Value);

                        // give the FileActions class an opportunity to process arguments
                        // it may know about (if it was responsible for creating the file)
                        te.Value = fileActions.ProcessArgs(project, te.Value);
                    }
                    break;

                case EventType.FileOpening:
                    // if this is a project file, we can handle it ourselves
                    if (FileInspector.IsProject(te.Value))
                    {
                        te.Handled = true;
                        OpenProjectSilent(te.Value);
                    }
                    break;

                case EventType.FileOpen:
                    SetDocumentIcon(MainForm.CurrentDocument);
                    OpenNextFile(); // it's safe to open any other files on the queue
                    break;

                case EventType.FileSave:
                    // refresh the tree to update any included <mx:Script> tags
                    string path = MainForm.CurrentDocument.FileName;
                    if (Settings.EnableMxmlMapping 
                        && FileInspector.IsMxml(path, Path.GetExtension(path).ToLower()) 
                        && Tree.NodeMap.ContainsKey(path))
                        Tree.RefreshNode(Tree.NodeMap[path]);
                    break;

                case EventType.ApplySettings:
                    MainForm.IgnoredKeys.Add(Settings.ShortcutTestMovie);
                    MainForm.IgnoredKeys.Add(Settings.ShortcutBuildProject);
                    MainForm.IgnoredKeys.Add(Settings.ShortcutOpenResource);
                    menus.ProjectMenu.OpenResource.ShortcutKeyDisplayString = DataConverter.KeysToString(Settings.ShortcutOpenResource);
                    menus.ProjectMenu.BuildProject.ShortcutKeyDisplayString = DataConverter.KeysToString(Settings.ShortcutBuildProject);
                    menus.ProjectMenu.TestMovie.ShortcutKeyDisplayString = DataConverter.KeysToString(Settings.ShortcutTestMovie);
                    break;

                case EventType.ProcessStart:
                    buildActions.NotifyBuildStarted();
                    break;

                case EventType.ProcessEnd:
                    string result = te.Value;
                    buildActions.NotifyBuildEnded(result);
                    break;

                case EventType.Command:
                    if (de.Action == ProjectManagerCommands.NewProject)
                    {
                        NewProject();
                        e.Handled = true;
                    }
                    else if (de.Action == ProjectManagerCommands.OpenProject)
                    {
                        if (de.Data != null && File.Exists((string)de.Data))
                        {
                            projectActions.OpenProjectSilent((string)de.Data);
                        }
                        else OpenProject();
                        e.Handled = true;
                    }
                    else if (de.Action == ProjectManagerCommands.SendProject)
                    {
                        BroadcastProjectInfo();
                        e.Handled = true;
                    }
                    else if (de.Action == ProjectManagerCommands.BuildProject)
                    {
                        if (project != null)
                        {
                            AutoSelectConfiguration((string)de.Data);
                            BuildProject();
                            e.Handled = true;
                        }
                    }
                    else if (de.Action == ProjectManagerCommands.TestMovie)
                    {
                        if (project != null)
                        {
                            AutoSelectConfiguration((string)de.Data);
                            TestMovie();
                            e.Handled = true;
                        }
                    }
                    else if (de.Action == ProjectManagerCommands.PlayOutput)
                    {
                        OpenSwf((string)de.Data);
                    }
                    else if (de.Action == ProjectManagerCommands.RestartFlexShell)
                    {
                        FlexCompilerShell.Cleanup();
                    }
                    else if (de.Action == ProjectManagerCommands.SetConfiguration)
                    {
                        AutoSelectConfiguration((string)de.Data);
                    }
                    else if (de.Action == "HotBuild")
                    {
                        if (project != null)
                        {
                            AutoSelectConfiguration((string)de.Data);
                            TestMovie();
                            e.Handled = true;
                        }
                    }
                    else if (de.Action == "LineEntryDialog")
                    {
                        Hashtable info = (Hashtable)de.Data;
                        LineEntryDialog askName = new LineEntryDialog((string)info["title"], (string)info["label"], (string)info["suggestion"]);
                        DialogResult choice = askName.ShowDialog();
                        if (choice == DialogResult.OK && askName.Line.Trim().Length > 0 && askName.Line.Trim() != (string)info["suggestion"])
                        {
                            info["suggestion"] = askName.Line.Trim();
                        }
                        if (choice == DialogResult.OK)
                        {
                            e.Handled = true;
                        }
                    }
                    break;

                case EventType.Keys:
                    e.Handled = HandleKeyEvent(e as KeyEvent);
                    break;
            }
        }