Esempio n. 1
0
        public static IAsyncOperation DebugFile(this ProjectOperations opers, string file)
        {
            var context = new ExecutionContext(DebuggingService.GetExecutionHandler(), IdeApp.Workbench.ProgressMonitors, IdeApp.Workspace.ActiveExecutionTarget);

            return(opers.ExecuteFile(file, context));
        }
Esempio n. 2
0
        public static void Initialize(IProgressMonitor monitor)
        {
            Counters.Initialization.Trace("Creating Workbench");
            workbench = new Workbench();
            Counters.Initialization.Trace("Creating Root Workspace");
            workspace = new RootWorkspace();
            Counters.Initialization.Trace("Creating Services");
            projectOperations = new ProjectOperations();
            helpOperations    = new HelpOperations();
            commandService    = new CommandManager();
            ideServices       = new IdeServices();
            CustomToolService.Init();
            AutoTestService.Start(commandService, Preferences.EnableAutomatedTesting);

            commandService.CommandTargetScanStarted  += CommandServiceCommandTargetScanStarted;
            commandService.CommandTargetScanFinished += CommandServiceCommandTargetScanFinished;

            KeyBindingService.LoadBindingsFromExtensionPath("/MonoDevelop/Ide/KeyBindingSchemes");
            KeyBindingService.LoadCurrentBindings("MD2");

            commandService.CommandError += delegate(object sender, CommandErrorArgs args) {
                MessageService.ShowException(args.Exception, args.ErrorMessage);
            };

            FileService.ErrorHandler = FileServiceErrorHandler;

            monitor.BeginTask(GettextCatalog.GetString("Loading Workbench"), 5);
            Counters.Initialization.Trace("Loading Commands");

            commandService.LoadCommands("/MonoDevelop/Ide/Commands");
            monitor.Step(1);

            Counters.Initialization.Trace("Initializing Workbench");
            workbench.Initialize(monitor);
            monitor.Step(1);

            InternalLog.EnableErrorNotification();

            monitor.Step(1);

            Counters.Initialization.Trace("Restoring Workbench State");
            workbench.Show("SharpDevelop.Workbench.WorkbenchMemento");
            monitor.Step(1);

            Counters.Initialization.Trace("Flushing GUI events");
            DispatchService.RunPendingEvents();
            Counters.Initialization.Trace("Flushed GUI events");

            MessageService.RootWindow = workbench.RootWindow;

            commandService.EnableIdleUpdate = true;

            // Default file format
            MonoDevelop.Projects.Services.ProjectServiceLoaded += delegate(object sender, EventArgs e) {
                ((ProjectService)sender).DefaultFileFormatId = IdeApp.Preferences.DefaultProjectFileFormat;
            };

            IdeApp.Preferences.DefaultProjectFileFormatChanged += delegate {
                IdeApp.Services.ProjectService.DefaultFileFormatId = IdeApp.Preferences.DefaultProjectFileFormat;
            };

            // Perser service initialization
            MonoDevelop.Projects.Dom.Parser.ProjectDomService.TrackFileChanges            = true;
            MonoDevelop.Projects.Dom.Parser.ProjectDomService.ParseProgressMonitorFactory = new ParseProgressMonitorFactory();


            // Startup commands
            Counters.Initialization.Trace("Running Startup Commands");
            AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/StartupHandlers", OnExtensionChanged);
            monitor.Step(1);
            monitor.EndTask();

            // Set initial run flags
            Counters.Initialization.Trace("Upgrading Settings");

            if (PropertyService.Get("MonoDevelop.Core.FirstRun", false))
            {
                isInitialRun = true;
                PropertyService.Set("MonoDevelop.Core.FirstRun", false);
                PropertyService.Set("MonoDevelop.Core.LastRunVersion", BuildVariables.PackageVersion);
                PropertyService.Set("MonoDevelop.Core.LastRunVersion", CurrentRevision);
                PropertyService.SaveProperties();
            }

            string lastVersion  = PropertyService.Get("MonoDevelop.Core.LastRunVersion", "1.9.1");
            int    lastRevision = PropertyService.Get("MonoDevelop.Core.LastRunRevision", 0);

            if (lastRevision != CurrentRevision && !isInitialRun)
            {
                isInitialRunAfterUpgrade = true;
                if (lastRevision == 0)
                {
                    switch (lastVersion)
                    {
                    case "1.0": lastRevision = 1; break;

                    case "2.0": lastRevision = 2; break;

                    case "2.2": lastRevision = 3; break;

                    case "2.2.1": lastRevision = 4; break;
                    }
                }
                upgradedFromRevision = lastRevision;
                PropertyService.Set("MonoDevelop.Core.LastRunVersion", BuildVariables.PackageVersion);
                PropertyService.Set("MonoDevelop.Core.LastRunRevision", CurrentRevision);
                PropertyService.SaveProperties();
            }

            // The ide is now initialized

            isInitialized = true;

            if (isInitialRun)
            {
                try {
                    OnInitialRun();
                } catch (Exception e) {
                    LoggingService.LogError("Error found while initializing the IDE", e);
                }
            }

            if (isInitialRunAfterUpgrade)
            {
                try {
                    OnUpgraded(upgradedFromRevision);
                } catch (Exception e) {
                    LoggingService.LogError("Error found while initializing the IDE", e);
                }
            }

            if (initializedEvent != null)
            {
                initializedEvent(null, EventArgs.Empty);
            }

            // load previous combine
            if ((bool)PropertyService.Get("SharpDevelop.LoadPrevProjectOnStartup", true))
            {
                var proj = DesktopService.RecentFiles.GetProjects().FirstOrDefault();
                if (proj != null)
                {
                    IdeApp.Workspace.OpenWorkspaceItem(proj.FileName);
                }
            }

            commandService.CommandSelected   += OnCommandSelected;
            commandService.CommandDeselected += OnCommandDeselected;

            //FIXME: we should really make this on-demand. consumers can display a "loading help cache" message like VS
            MonoDevelop.Projects.HelpService.AsyncInitialize();

            UpdateInstrumentationIcon();
            IdeApp.Preferences.EnableInstrumentationChanged += delegate {
                UpdateInstrumentationIcon();
            };
            AutoTestService.NotifyEvent("MonoDevelop.Ide.IdeStart");
        }
Esempio n. 3
0
        public static bool CanDebug(this ProjectOperations opers, IBuildTarget entry)
        {
            ExecutionContext context = new ExecutionContext(DebuggingService.GetExecutionHandler(), IdeApp.Workbench.ProgressMonitors, IdeApp.Workspace.ActiveExecutionTarget);

            return(opers.CanExecute(entry, context));
        }
Esempio n. 4
0
        public static void Initialize(ProgressMonitor monitor)
        {
            // Already done in IdeSetup, but called again since unit tests don't use IdeSetup.
            DispatchService.Initialize();

            Counters.Initialization.Trace("Creating Workbench");
            workbench = new Workbench();
            Counters.Initialization.Trace("Creating Root Workspace");
            workspace = new RootWorkspace();
            Counters.Initialization.Trace("Creating Services");
            projectOperations = new ProjectOperations();
            helpOperations    = new HelpOperations();
            commandService    = new CommandManager();
            ideServices       = new IdeServices();
            CustomToolService.Init();

            commandService.CommandTargetScanStarted  += CommandServiceCommandTargetScanStarted;
            commandService.CommandTargetScanFinished += CommandServiceCommandTargetScanFinished;
            commandService.KeyBindingFailed          += KeyBindingFailed;

            KeyBindingService.LoadBindingsFromExtensionPath("/MonoDevelop/Ide/KeyBindingSchemes");
            KeyBindingService.LoadCurrentBindings("MD2");

            commandService.CommandError += delegate(object sender, CommandErrorArgs args) {
                LoggingService.LogInternalError(args.ErrorMessage, args.Exception);
            };

            FileService.ErrorHandler = FileServiceErrorHandler;

            monitor.BeginTask(GettextCatalog.GetString("Loading Workbench"), 6);
            Counters.Initialization.Trace("Loading Commands");

            commandService.LoadCommands("/MonoDevelop/Ide/Commands");
            monitor.Step(1);

            // Before startup commands.
            Counters.Initialization.Trace("Running Pre-Startup Commands");
            AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/PreStartupHandlers", OnExtensionChanged);
            monitor.Step(1);

            Counters.Initialization.Trace("Initializing Workbench");
            workbench.Initialize(monitor);
            monitor.Step(1);

            MonoDevelop.Ide.WelcomePage.WelcomePageService.Initialize();
            MonoDevelop.Ide.WelcomePage.WelcomePageService.ShowWelcomePage();

            monitor.Step(1);

            Counters.Initialization.Trace("Restoring Workbench State");
            workbench.Show("SharpDevelop.Workbench.WorkbenchMemento");
            monitor.Step(1);

            Counters.Initialization.Trace("Flushing GUI events");
            DispatchService.RunPendingEvents();
            Counters.Initialization.Trace("Flushed GUI events");

            MessageService.RootWindow    = workbench.RootWindow;
            Xwt.MessageDialog.RootWindow = Xwt.Toolkit.CurrentEngine.WrapWindow(workbench.RootWindow);

            commandService.EnableIdleUpdate = true;

            if (Customizer != null)
            {
                Customizer.OnIdeInitialized();
            }

            // Startup commands
            Counters.Initialization.Trace("Running Startup Commands");
            AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/StartupHandlers", OnExtensionChanged);
            monitor.Step(1);
            monitor.EndTask();

            // Set initial run flags
            Counters.Initialization.Trace("Upgrading Settings");

            if (PropertyService.Get("MonoDevelop.Core.FirstRun", false))
            {
                isInitialRun = true;
                PropertyService.Set("MonoDevelop.Core.FirstRun", false);
                PropertyService.Set("MonoDevelop.Core.LastRunVersion", BuildInfo.Version);
                PropertyService.Set("MonoDevelop.Core.LastRunRevision", CurrentRevision);
                PropertyService.SaveProperties();
            }

            string lastVersion  = PropertyService.Get("MonoDevelop.Core.LastRunVersion", "1.9.1");
            int    lastRevision = PropertyService.Get("MonoDevelop.Core.LastRunRevision", 0);

            if (lastRevision != CurrentRevision && !isInitialRun)
            {
                isInitialRunAfterUpgrade = true;
                if (lastRevision == 0)
                {
                    switch (lastVersion)
                    {
                    case "1.0": lastRevision = 1; break;

                    case "2.0": lastRevision = 2; break;

                    case "2.2": lastRevision = 3; break;

                    case "2.2.1": lastRevision = 4; break;
                    }
                }
                upgradedFromRevision = lastRevision;
                PropertyService.Set("MonoDevelop.Core.LastRunVersion", BuildInfo.Version);
                PropertyService.Set("MonoDevelop.Core.LastRunRevision", CurrentRevision);
                PropertyService.SaveProperties();
            }

            // The ide is now initialized

            isInitialized = true;

            if (isInitialRun)
            {
                try {
                    OnInitialRun();
                } catch (Exception e) {
                    LoggingService.LogError("Error found while initializing the IDE", e);
                }
            }

            if (isInitialRunAfterUpgrade)
            {
                try {
                    OnUpgraded(upgradedFromRevision);
                } catch (Exception e) {
                    LoggingService.LogError("Error found while initializing the IDE", e);
                }
            }

            if (initializedEvent != null)
            {
                initializedEvent(null, EventArgs.Empty);
                initializedEvent = null;
            }

            //FIXME: we should really make this on-demand. consumers can display a "loading help cache" message like VS
            MonoDevelop.Projects.HelpService.AsyncInitialize();

            UpdateInstrumentationIcon();
            IdeApp.Preferences.EnableInstrumentation.Changed += delegate {
                UpdateInstrumentationIcon();
            };
            AutoTestService.Start(commandService, Preferences.EnableAutomatedTesting);
            AutoTestService.NotifyEvent("MonoDevelop.Ide.IdeStart");

            Gtk.LinkButton.SetUriHook((button, uri) => Xwt.Desktop.OpenUrl(uri));
        }
Esempio n. 5
0
        void DropNode(HashSet <SolutionEntityItem> projectsToSave, object dataObject, HashSet <ProjectFile> groupedFiles, DragOperation operation)
        {
            FilePath targetDirectory = GetFolderPath(CurrentNode.DataItem);
            FilePath source;
            string   what;
            Project  targetProject = (Project)CurrentNode.GetParentDataItem(typeof(Project), true);
            Project  sourceProject;
            IEnumerable <ProjectFile> groupedChildren = null;

            if (dataObject is ProjectFolder)
            {
                source        = ((ProjectFolder)dataObject).Path;
                sourceProject = ((ProjectFolder)dataObject).Project;
                what          = Path.GetFileName(source);
            }
            else if (dataObject is ProjectFile)
            {
                ProjectFile file = (ProjectFile)dataObject;

                // if this ProjectFile is one of the grouped files being pulled in by a parent being copied/moved, ignore it
                if (groupedFiles.Contains(file))
                {
                    return;
                }

                if (file.DependsOnFile != null && operation == DragOperation.Move)
                {
                    // unlink this file from its parent (since its parent is not being moved)
                    file.DependsOn = null;

                    // if moving a linked file into its containing folder, simply unlink it from its parent
                    if (file.FilePath.ParentDirectory == targetDirectory)
                    {
                        projectsToSave.Add(targetProject);
                        return;
                    }
                }

                sourceProject = file.Project;
                if (sourceProject != null && file.IsLink)
                {
                    source = sourceProject.BaseDirectory.Combine(file.ProjectVirtualPath);
                }
                else
                {
                    source = file.FilePath;
                }
                groupedChildren = file.DependentChildren;
                what            = null;
            }
            else if (dataObject is Gtk.SelectionData)
            {
                SelectionData data = (SelectionData)dataObject;
                if (data.Type != "text/uri-list")
                {
                    return;
                }
                string sources = System.Text.Encoding.UTF8.GetString(data.Data);
                Console.WriteLine("text/uri-list:\n{0}", sources);
                string[] files = sources.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                for (int n = 0; n < files.Length; n++)
                {
                    Uri uri = new Uri(files[n]);
                    if (uri.Scheme != "file")
                    {
                        return;
                    }
                    if (Directory.Exists(uri.LocalPath))
                    {
                        return;
                    }
                    files[n] = uri.LocalPath;
                }

                IdeApp.ProjectOperations.AddFilesToProject(targetProject, files, targetDirectory);
                projectsToSave.Add(targetProject);
                return;
            }
            else
            {
                return;
            }

            var targetPath = targetDirectory.Combine(source.FileName);

            // If copying to the same directory, make a copy with a different name
            if (targetPath == source)
            {
                targetPath = ProjectOperations.GetTargetCopyName(targetPath, dataObject is ProjectFolder);
            }

            var targetChildPaths = groupedChildren != null?groupedChildren.Select(child => {
                var targetChildPath = targetDirectory.Combine(child.FilePath.FileName);

                if (targetChildPath == child.FilePath)
                {
                    targetChildPath = ProjectOperations.GetTargetCopyName(targetChildPath, false);
                }

                return(targetChildPath);
            }).ToList() : null;

            if (dataObject is ProjectFolder)
            {
                string q;
                if (operation == DragOperation.Move)
                {
                    if (targetPath.ParentDirectory == targetProject.BaseDirectory)
                    {
                        q = GettextCatalog.GetString("Do you really want to move the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
                    }
                    else
                    {
                        q = GettextCatalog.GetString("Do you really want to move the folder '{0}' to the folder '{1}'?", what, targetDirectory.FileName);
                    }
                    if (!MessageService.Confirm(q, AlertButton.Move))
                    {
                        return;
                    }
                }
                else
                {
                    if (targetPath.ParentDirectory == targetProject.BaseDirectory)
                    {
                        q = GettextCatalog.GetString("Do you really want to copy the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
                    }
                    else
                    {
                        q = GettextCatalog.GetString("Do you really want to copy the folder '{0}' to the folder '{1}'?", what, targetDirectory.FileName);
                    }
                    if (!MessageService.Confirm(q, AlertButton.Copy))
                    {
                        return;
                    }
                }
            }
            else if (dataObject is ProjectFile)
            {
                foreach (var file in new FilePath[] { targetPath }.Concat(targetChildPaths))
                {
                    if (File.Exists(file))
                    {
                        if (!MessageService.Confirm(GettextCatalog.GetString("The file '{0}' already exists. Do you want to overwrite it?", file.FileName), AlertButton.OverwriteFile))
                        {
                            return;
                        }
                    }
                }
            }

            var filesToSave = new List <Document> ();

            foreach (Document doc in IdeApp.Workbench.Documents)
            {
                if (doc.IsDirty && doc.IsFile)
                {
                    if (doc.Name == source || doc.Name.StartsWith(source + Path.DirectorySeparatorChar))
                    {
                        filesToSave.Add(doc);
                    }
                    else if (groupedChildren != null)
                    {
                        foreach (ProjectFile f in groupedChildren)
                        {
                            if (doc.Name == f.Name)
                            {
                                filesToSave.Add(doc);
                            }
                        }
                    }
                }
            }

            if (filesToSave.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (Document doc in filesToSave)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(",\n");
                    }
                    sb.Append(Path.GetFileName(doc.Name));
                }

                string question;

                if (operation == DragOperation.Move)
                {
                    if (filesToSave.Count == 1)
                    {
                        question = GettextCatalog.GetString("Do you want to save the file '{0}' before the move operation?", sb.ToString());
                    }
                    else
                    {
                        question = GettextCatalog.GetString("Do you want to save the following files before the move operation?\n\n{0}", sb.ToString());
                    }
                }
                else
                {
                    if (filesToSave.Count == 1)
                    {
                        question = GettextCatalog.GetString("Do you want to save the file '{0}' before the copy operation?", sb.ToString());
                    }
                    else
                    {
                        question = GettextCatalog.GetString("Do you want to save the following files before the copy operation?\n\n{0}", sb.ToString());
                    }
                }
                AlertButton noSave = new AlertButton(GettextCatalog.GetString("Don't Save"));
                AlertButton res    = MessageService.AskQuestion(question, AlertButton.Cancel, noSave, AlertButton.Save);
                if (res == AlertButton.Cancel)
                {
                    return;
                }
                if (res == AlertButton.Save)
                {
                    try {
                        foreach (Document doc in filesToSave)
                        {
                            doc.Save();
                        }
                    } catch (Exception ex) {
                        MessageService.ShowError(GettextCatalog.GetString("Save operation failed."), ex);
                        return;
                    }
                }
            }

            if (operation == DragOperation.Move && sourceProject != null)
            {
                projectsToSave.Add(sourceProject);
            }
            if (targetProject != null)
            {
                projectsToSave.Add(targetProject);
            }

            bool move   = operation == DragOperation.Move;
            var  opText = move ? GettextCatalog.GetString("Moving files...") : GettextCatalog.GetString("Copying files...");

            using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor(opText, Stock.StatusSolutionOperation, true)) {
                // If we drag and drop a node in the treeview corresponding to a directory, do not move
                // the entire directory. We should only move the files which exist in the project. Otherwise
                // we will need a lot of hacks all over the code to prevent us from incorrectly moving version
                // control related files such as .svn directories

                // Note: if we are transferring a ProjectFile, this will copy/move the ProjectFile's DependentChildren as well.
                IdeApp.ProjectOperations.TransferFiles(monitor, sourceProject, source, targetProject, targetPath, move, true);
            }
        }
Esempio n. 6
0
        public static AsyncOperation Debug(this ProjectOperations opers, IBuildTarget entry, bool buildBeforeExecuting = true)
        {
            ExecutionContext context = new ExecutionContext(DebuggingService.GetExecutionHandler(), IdeApp.Workbench.ProgressMonitors.ConsoleFactory, IdeApp.Workspace.ActiveExecutionTarget);

            return(opers.Execute(entry, context, buildBeforeExecuting));
        }
Esempio n. 7
0
        void DropNode(Set <SolutionEntityItem> projectsToSave, object dataObject, DragOperation operation)
        {
            FilePath targetPath = GetFolderPath(CurrentNode.DataItem);
            FilePath source;
            string   what;
            Project  targetProject = (Project)CurrentNode.GetParentDataItem(typeof(Project), true);
            Project  sourceProject;

            System.Collections.Generic.IEnumerable <ProjectFile> groupedChildren = null;

            if (dataObject is ProjectFolder)
            {
                source        = ((ProjectFolder)dataObject).Path;
                sourceProject = ((ProjectFolder)dataObject).Project;
                what          = Path.GetFileName(source);
            }
            else if (dataObject is ProjectFile)
            {
                ProjectFile file = (ProjectFile)dataObject;
                sourceProject = file.Project;
                if (sourceProject != null && file.IsLink)
                {
                    source = sourceProject.BaseDirectory.Combine(file.ProjectVirtualPath);
                }
                else
                {
                    source = file.FilePath;
                }
                groupedChildren = file.DependentChildren;
                what            = null;
            }
            else if (dataObject is Gtk.SelectionData)
            {
                SelectionData data = (SelectionData)dataObject;
                if (data.Type != "text/uri-list")
                {
                    return;
                }
                string   sources = System.Text.Encoding.UTF8.GetString(data.Data);
                string[] files   = sources.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                for (int n = 0; n < files.Length; n++)
                {
                    Uri uri = new Uri(files[n]);
                    if (uri.Scheme != "file")
                    {
                        return;
                    }
                    if (Directory.Exists(uri.LocalPath))
                    {
                        return;
                    }
                    files[n] = uri.LocalPath;
                }

                IdeApp.ProjectOperations.AddFilesToProject(targetProject, files, targetPath);
                projectsToSave.Add(targetProject);
                return;
            }
            else
            {
                return;
            }

            targetPath = targetPath.Combine(source.FileName);
            // If copying to the same directory, make a copy with a different name
            if (targetPath == source)
            {
                targetPath = ProjectOperations.GetTargetCopyName(targetPath, dataObject is ProjectFolder);
            }

            if (dataObject is ProjectFolder)
            {
                string q;
                if (operation == DragOperation.Move)
                {
                    if (targetPath.ParentDirectory == targetProject.BaseDirectory)
                    {
                        q = GettextCatalog.GetString("Do you really want to move the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
                    }
                    else
                    {
                        q = GettextCatalog.GetString("Do you really want to move the folder '{0}' to the folder '{1}'?", what, targetPath.ParentDirectory.FileName);
                    }
                    if (!MessageService.Confirm(q, AlertButton.Move))
                    {
                        return;
                    }
                }
                else
                {
                    if (targetPath.ParentDirectory == targetProject.BaseDirectory)
                    {
                        q = GettextCatalog.GetString("Do you really want to copy the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
                    }
                    else
                    {
                        q = GettextCatalog.GetString("Do you really want to copy the folder '{0}' to the folder '{1}'?", what, targetPath.ParentDirectory.FileName);
                    }
                    if (!MessageService.Confirm(q, AlertButton.Copy))
                    {
                        return;
                    }
                }
            }
            else if (dataObject is ProjectFile)
            {
                if (File.Exists(targetPath))
                {
                    if (!MessageService.Confirm(GettextCatalog.GetString("The file '{0}' already exists. Do you want to overwrite it?", targetPath.FileName), AlertButton.OverwriteFile))
                    {
                        return;
                    }
                }
            }

            ArrayList filesToSave = new ArrayList();

            foreach (Document doc in IdeApp.Workbench.Documents)
            {
                if (doc.IsDirty && doc.IsFile)
                {
                    if (doc.Name == source || doc.Name.StartsWith(source + Path.DirectorySeparatorChar))
                    {
                        filesToSave.Add(doc);
                    }
                    else if (groupedChildren != null)
                    {
                        foreach (ProjectFile f in groupedChildren)
                        {
                            if (doc.Name == f.Name)
                            {
                                filesToSave.Add(doc);
                            }
                        }
                    }
                }
            }

            if (filesToSave.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (Document doc in filesToSave)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(",\n");
                    }
                    sb.Append(Path.GetFileName(doc.Name));
                }

                string question;

                if (operation == DragOperation.Move)
                {
                    if (filesToSave.Count == 1)
                    {
                        question = GettextCatalog.GetString("Do you want to save the file '{0}' before the move operation?", sb.ToString());
                    }
                    else
                    {
                        question = GettextCatalog.GetString("Do you want to save the following files before the move operation?\n\n{0}", sb.ToString());
                    }
                }
                else
                {
                    if (filesToSave.Count == 1)
                    {
                        question = GettextCatalog.GetString("Do you want to save the file '{0}' before the copy operation?", sb.ToString());
                    }
                    else
                    {
                        question = GettextCatalog.GetString("Do you want to save the following files before the copy operation?\n\n{0}", sb.ToString());
                    }
                }
                AlertButton noSave = new AlertButton(GettextCatalog.GetString("Don't Save"));
                AlertButton res    = MessageService.AskQuestion(question, AlertButton.Cancel, noSave, AlertButton.Save);
                if (res == AlertButton.Cancel)
                {
                    return;
                }
                else if (res == AlertButton.Save)
                {
                    try {
                        foreach (Document doc in filesToSave)
                        {
                            doc.Save();
                        }
                    } catch (Exception ex) {
                        MessageService.ShowException(ex, GettextCatalog.GetString("Save operation failed."));
                        return;
                    }
                }
            }

            if (operation == DragOperation.Move && sourceProject != null)
            {
                projectsToSave.Add(sourceProject);
            }
            if (targetProject != null)
            {
                projectsToSave.Add(targetProject);
            }

            using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor(GettextCatalog.GetString("Copying files..."), MonoDevelop.Ide.Gui.Stock.CopyIcon, true))
            {
                // If we drag and drop a node in the treeview corresponding to a directory, do not move
                // the entire directory. We should only move the files which exist in the project. Otherwise
                // we will need a lot of hacks all over the code to prevent us from incorrectly moving version
                // control related files such as .svn directories
                bool move = operation == DragOperation.Move;
                IdeApp.ProjectOperations.TransferFiles(monitor, sourceProject, source, targetProject, targetPath, move, true);
            }
        }
Esempio n. 8
0
        public static bool CanDebugFile(this ProjectOperations opers, string file)
        {
            ExecutionContext context = new ExecutionContext(DebuggingService.GetExecutionHandler(), IdeApp.Workbench.ProgressMonitors);

            return(opers.CanExecuteFile(file, context));
        }
Esempio n. 9
0
        // GET api/project/5
        public Project Get(int id)
        {
            ProjectOperations projectOperation = new ProjectOperations();

            return(projectOperation.GetProject(id).FirstOrDefault());
        }
Esempio n. 10
0
        //use this api to get all projects
        // GET api/project
        public List <Project> Get()
        {
            ProjectOperations projectOperation = new ProjectOperations();

            return(projectOperation.GetProject(-1));
        }