internal static bool HandleTestProject()
        {
            WatcherVCResult result = fsWatchers.ResolveVC(currentProject.OutputPathAbsolute, true);

            if (result == null || result.Status == VCItemStatus.Unknown)
            {
                return(false);
            }

            return(result.Manager.FileActions.TestProject());
        }
        internal static bool HandleSaveProject(string fileName)
        {
            WatcherVCResult result = fsWatchers.ResolveVC(fileName, true);

            if (result == null || result.Status == VCItemStatus.Unknown)
            {
                return(false);
            }

            return(result.Manager.FileActions.SaveProject());
        }
        internal static bool HandleFileRename(string[] paths)
        {
            WatcherVCResult result = fsWatchers.ResolveVC(paths[0], true);

            if (result == null || result.Status == VCItemStatus.Unknown)
            {
                return(false);
            }

            return(result.Manager.FileActions.FileRename(paths[0], paths[1]));
        }
Esempio n. 4
0
        internal static bool HandleFileMove(string[] paths)
        {
            WatcherVCResult result  = fsWatchers.ResolveVC(paths[0], true);
            WatcherVCResult result2 = fsWatchers.ResolveVC(paths[1], true);

            var fromVCed = result != null && result.Status >= VCItemStatus.UpToDate && result.Status != VCItemStatus.Added;
            var toVCed   = result2 != null && result2.Status >= VCItemStatus.UpToDate && result2.Status != VCItemStatus.Added;

            if (!fromVCed || !toVCed) // origin or target not under VC, ignore
            {
                return(false);
            }

            return(result.Manager.FileActions.FileMove(paths[0], paths[1]));
        }
        internal static bool HandleFileModifyRO(string path)
        {
            if (!initialized)
            {
                return(false);
            }

            WatcherVCResult result = fsWatchers.ResolveVC(path, true);

            if (result == null || result.Status == VCItemStatus.Unknown)
            {
                return(false);
            }

            return(result.Manager.FileActions.FileModifyRO(path));
        }
        internal static bool HandleFileMove(string[] paths)
        {
            WatcherVCResult result = fsWatchers.ResolveVC(paths[0], true);

            if (result == null || result.Status == VCItemStatus.Unknown)
            {
                return(false); // origin not under VC, ignore
            }
            WatcherVCResult result2 = fsWatchers.ResolveVC(paths[1], true);

            if (result2 == null || result2.Status == VCItemStatus.Unknown)
            {
                return(false); // target dir not under VC, ignore
            }
            return(result.Manager.FileActions.FileMove(paths[0], paths[1]));
        }
Esempio n. 7
0
        internal static bool HandleFileNew(string path)
        {
            if (!initialized)
            {
                return(false);
            }

            WatcherVCResult result = fsWatchers.ResolveVC(path, true);

            if (result == null || result.Status == VCItemStatus.Unknown || result.Status == VCItemStatus.Ignored)
            {
                return(false);
            }

            addBuffer.Add(path); //at this point there is not yet an ITabbedDocument for the file

            return(false);
        }
        internal static bool HandleFileDelete(string[] paths, bool confirm)
        {
            if (paths == null || paths.Length == 0)
            {
                return(false);
            }
            WatcherVCResult result = fsWatchers.ResolveVC(Path.GetDirectoryName(paths[0]));

            if (result == null)
            {
                return(false);
            }

            List <string> svnRemove       = new List <string>();
            List <string> regularRemove   = new List <string>();
            List <string> hasModification = new List <string>();
            List <string> hasUnknown      = new List <string>();

            try
            {
                foreach (string path in paths)
                {
                    result = fsWatchers.ResolveVC(path, true);
                    if (result == null || result.Status == VCItemStatus.Unknown || result.Status == VCItemStatus.Ignored)
                    {
                        regularRemove.Add(path);
                    }
                    else
                    {
                        IVCManager manager = result.Manager;
                        string     root    = result.Watcher.Path;
                        int        p       = root.Length + 1;

                        if (Directory.Exists(path))
                        {
                            List <string> files = new List <string>();
                            GetAllFiles(path, files);
                            foreach (string file in files)
                            {
                                VCItemStatus status = manager.GetOverlay(file, root);
                                if (status == VCItemStatus.Unknown || status == VCItemStatus.Ignored)
                                {
                                    hasUnknown.Add(file.Substring(p));
                                }
                                else if (status > VCItemStatus.UpToDate)
                                {
                                    hasModification.Add(file.Substring(p));
                                }
                            }
                        }
                        else if (result.Status > VCItemStatus.UpToDate)
                        {
                            hasModification.Add(path);
                        }

                        if (svnRemove.Count > 0)
                        {
                            if (Path.GetDirectoryName(svnRemove[0]) != Path.GetDirectoryName(path))
                            {
                                throw new UnsafeOperationException(TextHelper.GetString("SourceControl.Info.ElementsLocatedInDiffDirs"));
                            }
                        }
                        svnRemove.Add(path);
                    }
                }
                if (regularRemove.Count > 0 && svnRemove.Count > 0)
                {
                    throw new UnsafeOperationException(TextHelper.GetString("SourceControl.Info.MixedSelectionOfElements"));
                }

                if (svnRemove.Count == 0 && regularRemove.Count > 0)
                {
                    return(false); // regular deletion
                }
            }
            catch (UnsafeOperationException upex)
            {
                MessageBox.Show(upex.Message, TextHelper.GetString("SourceControl.Info.UnsafeDeleteOperation"), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(true); // prevent regular deletion
            }

            if (hasUnknown.Count > 0 && confirm)
            {
                string title = TextHelper.GetString("FlashDevelop.Title.ConfirmDialog");
                string msg   = TextHelper.GetString("SourceControl.Info.ConfirmUnversionedDelete") + "\n\n" + GetSomeFiles(hasUnknown);
                if (MessageBox.Show(msg, title, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                {
                    return(true);
                }
            }

            if (hasModification.Count > 0 && confirm)
            {
                string title = TextHelper.GetString("FlashDevelop.Title.ConfirmDialog");
                string msg   = TextHelper.GetString("SourceControl.Info.ConfirmLocalModsDelete") + "\n\n" + GetSomeFiles(hasModification);
                if (MessageBox.Show(msg, title, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                {
                    return(true);
                }
            }

            return(result.Manager.FileActions.FileDelete(paths, confirm));
        }