public CustomCommandWidget(IWorkspaceObject entry, CustomCommand cmd, ConfigurationSelector configSelector, CustomCommandType[] supportedTypes)
        {
            this.Build();
            this.supportedTypes = supportedTypes;
            this.cmd = cmd;

            updating = true;

            if (cmd == null)
                comboType.AppendText (GettextCatalog.GetString ("(Select a project operation)"));

            foreach (var ct in supportedTypes)
                comboType.AppendText (commandNames [(int)ct]);

            updating = false;

            this.entry = entry;
            UpdateControls ();
            this.WidgetFlags |= Gtk.WidgetFlags.NoShowAll;

            StringTagModelDescription tagModel;
            if (entry is SolutionItem)
                tagModel = ((SolutionItem)entry).GetStringTagModelDescription (configSelector);
            else if (entry is WorkspaceItem)
                tagModel = ((WorkspaceItem)entry).GetStringTagModelDescription ();
            else
                tagModel = new StringTagModelDescription ();

            tagSelectorDirectory.TagModel = tagModel;
            tagSelectorDirectory.TargetEntry = workingdirEntry;

            tagSelectorCommand.TagModel = tagModel;
            tagSelectorCommand.TargetEntry = entryCommand;
        }
		public CustomCommandWidget (IWorkspaceObject entry, CustomCommand cmd, ConfigurationSelector configSelector)
		{
			this.Build();
			this.cmd = cmd;
			if (cmd != null) {
				updating = true;
				comboType.RemoveText (0);
				updating = false;
			}
			
			this.entry = entry;
			UpdateControls ();
			this.WidgetFlags |= Gtk.WidgetFlags.NoShowAll;
			
			StringTagModelDescription tagModel;
			if (entry is SolutionItem)
				tagModel = ((SolutionItem)entry).GetStringTagModelDescription (configSelector);
			else if (entry is WorkspaceItem)
				tagModel = ((WorkspaceItem)entry).GetStringTagModelDescription ();
			else
				tagModel = new StringTagModelDescription ();

			tagSelectorDirectory.TagModel = tagModel;
			tagSelectorDirectory.TargetEntry = workingdirEntry;
			
			tagSelectorCommand.TagModel = tagModel;
			tagSelectorCommand.TargetEntry = entryCommand;
		}
		public VersionControlItem (Repository repository, IWorkspaceObject workspaceObject, FilePath path, bool isDirectory)
		{
			this.path = path;
			this.repository = repository;
			this.workspaceObject = workspaceObject;
			this.isDirectory = isDirectory;
		}
		protected UnitTest (string name, IWorkspaceObject ownerSolutionItem)
		{
			this.name = name;
			this.ownerSolutionItem = ownerSolutionItem;
			ownerSolutionEntityItem = ownerSolutionItem as SolutionEntityItem;
			if (ownerSolutionEntityItem != null)
				ownerSolutionEntityItem.DefaultConfigurationChanged += OnConfugurationChanged;
		}
		public VersionControlItem (Repository repository, IWorkspaceObject workspaceObject, FilePath path, bool isDirectory, VersionInfo versionInfo)
		{
			Path = path;
			Repository = repository;
			WorkspaceObject = workspaceObject;
			IsDirectory = isDirectory;
			this.versionInfo = versionInfo;
		}
Example #6
0
		public Task (FilePath file, string description, int column, int line, TaskSeverity severity, TaskPriority priority, IWorkspaceObject parent, object owner)
		{
			this.file = file;
			this.description = description;
			this.column = column;
			this.line = line;
			this.severity = severity;
			this.priority = priority;
			this.owner = owner;
			this.parentObject = parent;
		}
Example #7
0
 public UnitTest BuildTest(IWorkspaceObject entry)
 {
     foreach (ITestProvider p in providers)
     {
         UnitTest t = p.CreateUnitTest(entry);
         if (t != null)
         {
             return(t);
         }
     }
     return(null);
 }
		public static UnitTest CreateTest (IWorkspaceObject entry)
		{
			var project = entry as DotNetProject;
			if (project != null) {
				foreach (var r in project.References) {
					if (r.Reference == "xunit")
						return new XUnitProjectTestSuite (project);
				}
			}

			return null;
		}
        static void HandleDocumentChanged(object sender, EventArgs e)
        {
            var document = Ide.IdeApp.Workbench.ActiveDocument;

            try {
                if (document == null || !document.IsFile || document.Window.FindView <IDiffView> () >= 0)
                {
                    return;
                }

                IWorkspaceObject project = document.Project;
                if (project == null)
                {
                    // Fix for broken .csproj and .sln files not being seen as having a project.
                    foreach (var projItem in Ide.IdeApp.Workspace.GetAllSolutionItems <UnknownSolutionItem> ())
                    {
                        if (projItem.FileName == document.FileName)
                        {
                            project = projItem;
                        }
                    }

                    if (project == null)
                    {
                        return;
                    }
                }

                var repo = VersionControlService.GetRepository(project);
                if (repo == null)
                {
                    return;
                }

                var versionInfo = repo.GetVersionInfo(document.FileName, VersionInfoQueryFlags.IgnoreCache);
                if (!versionInfo.IsVersioned)
                {
                    return;
                }

                var item   = new VersionControlItem(repo, project, document.FileName, false, null);
                var vcInfo = new VersionControlDocumentInfo(document.PrimaryView, item, item.Repository);
                TryAttachView <IDiffView> (document, vcInfo, DiffCommand.DiffViewHandlers);
                TryAttachView <IBlameView> (document, vcInfo, BlameCommand.BlameViewHandlers);
                TryAttachView <ILogView> (document, vcInfo, LogCommand.LogViewHandlers);
                TryAttachView <IMergeView> (document, vcInfo, MergeCommand.MergeViewHandlers);
            } catch (Exception ex) {
                // If a user is hitting this, it will show a dialog box every time they
                // switch to a document or open a document, so suppress the crash dialog
                // This bug *should* be fixed already, but it's hard to tell.
                LoggingService.LogInternalError(ex);
            }
        }
Example #10
0
        public FilePath GetCommandWorkingDir(IWorkspaceObject entry, ConfigurationSelector configuration)
        {
            StringTagModel tagSource = GetTagModel(entry, configuration);

            if (string.IsNullOrEmpty(workingdir))
            {
                return(entry.BaseDirectory);
            }
            FilePath dir = StringParserService.Parse(workingdir, tagSource);

            return(dir.ToAbsolute(entry.BaseDirectory));
        }
Example #11
0
 public Task(FilePath file, string description, int column, int line, TaskSeverity severity, TaskPriority priority, IWorkspaceObject parent, object owner, string category)
 {
     this.file         = file;
     this.description  = description;
     this.column       = column;
     this.line         = line;
     this.severity     = severity;
     this.priority     = priority;
     this.owner        = owner;
     this.parentObject = parent;
     this.category     = category;
 }
Example #12
0
        protected override void Run()
        {
            IWorkspaceObject ob = IdeApp.ProjectOperations.CurrentSelectedBuildTarget;

            if (ob != null)
            {
                UnitTest test = NUnitService.Instance.FindRootTest(ob);
                if (test != null)
                {
                    NUnitService.Instance.RunTest(test, null);
                }
            }
        }
		public UnitTest CreateUnitTest (IWorkspaceObject entry)
		{
			UnitTest test = null;

			if (entry is DotNetProject)
				test = XUnitProjectTestSuite.CreateTest (entry);

			UnitTestGroup group = test as UnitTestGroup;
			if (group != null && !group.HasTests)
				return null;

			return test;
		}
        public static Repository GetRepository(IWorkspaceObject entry)
        {
            Repository repo = (Repository)entry.ExtendedProperties [typeof(Repository)];

            if (repo != null)
            {
                return(repo);
            }

            repo = VersionControlService.GetRepositoryReference(entry.BaseDirectory, entry.Name);
            entry.ExtendedProperties [typeof(Repository)] = repo;

            return(repo);
        }
Example #15
0
        public override void OnNodeRemoved(object dataObject)
        {
            IWorkspaceObject ob  = (IWorkspaceObject)dataObject;
            GitRepository    rep = VersionControlService.GetRepository(ob) as GitRepository;
            IWorkspaceObject rob;

            if (rep != null && repos.TryGetValue(rep.RootPath.CanonicalPath, out rob))
            {
                if (ob == rob)
                {
                    repos.Remove(rep.RootPath.CanonicalPath);
                }
            }
        }
Example #16
0
 public void ExecuteCommand(IProgressMonitor monitor, IWorkspaceObject entry, CustomCommandType type, ExecutionContext context, ConfigurationSelector configuration)
 {
     foreach (CustomCommand cmd in this)
     {
         if (cmd.Type == type)
         {
             cmd.Execute(monitor, entry, context, configuration);
         }
         if (monitor.IsCancelRequested)
         {
             break;
         }
     }
 }
Example #17
0
        protected override void Update(CommandInfo info)
        {
            IWorkspaceObject ob = IdeApp.ProjectOperations.CurrentSelectedBuildTarget;

            if (ob != null)
            {
                UnitTest test = NUnitService.Instance.FindRootTest(ob);
                info.Enabled = (test != null);
            }
            else
            {
                info.Enabled = false;
            }
        }
		public static UnitTest CreateTest (IWorkspaceObject entry)
		{
			var project = entry as DotNetProject;
			if (project != null) {
				foreach (var r in project.References) {
					if (r.Reference == "xunit") // xUnit.Net 1.x
						return new XUnitProjectTestSuite (project);
					if (r.Reference.StartsWith ("xunit.core")) // xUnit.Net 2.x
						return new XUnitProjectTestSuite (project);
				}
			}

			return null;
		}
Example #19
0
 StringTagModel GetTagModel(IWorkspaceObject entry, ConfigurationSelector configuration)
 {
     if (entry is SolutionItem)
     {
         return(((SolutionItem)entry).GetStringTagModel(configuration));
     }
     else if (entry is WorkspaceItem)
     {
         return(((WorkspaceItem)entry).GetStringTagModel());
     }
     else
     {
         return(new StringTagModel());
     }
 }
Example #20
0
        public ProcessExecutionCommand CreateExecutionCommand(IWorkspaceObject entry, ConfigurationSelector configuration)
        {
            if (string.IsNullOrEmpty(command))
            {
                throw new UserException(GettextCatalog.GetString("Invalid custom command for '{0}' step: the path to the command to execute has not been provided.", TypeLabel));
            }
            string         exe, args;
            StringTagModel tagSource = GetTagModel(entry, configuration);

            ParseCommand(tagSource, out exe, out args);

            //if the executable name matches an executable in the project directory, use that, for back-compat
            //else fall back and let the execution handler handle it via PATH, working directory, etc.
            if (!Path.IsPathRooted(exe))
            {
                string localPath = ((FilePath)exe).ToAbsolute(entry.BaseDirectory).FullPath;
                if (File.Exists(localPath))
                {
                    exe = localPath;
                }
            }

            ProcessExecutionCommand cmd = Runtime.ProcessService.CreateCommand(exe);

            cmd.Arguments = args;

            FilePath workingDir = this.workingdir;

            if (!workingDir.IsNullOrEmpty)
            {
                workingDir = StringParserService.Parse(workingDir, tagSource);
            }
            cmd.WorkingDirectory = workingDir.IsNullOrEmpty
                                ? entry.BaseDirectory
                                : workingDir.ToAbsolute(entry.BaseDirectory);

            if (environmentVariables != null)
            {
                var vars = new Dictionary <string, string> ();
                foreach (var v in environmentVariables)
                {
                    vars [v.Key] = StringParserService.Parse(v.Value, tagSource);
                }
                cmd.EnvironmentVariables = vars;
            }

            return(cmd);
        }
Example #21
0
        public override bool ContainsItem(IWorkspaceObject obj)
        {
            if (base.ContainsItem(obj))
            {
                return(true);
            }

            foreach (SolutionItem it in GetAllSolutionItems <SolutionItem> ())
            {
                if (it == obj)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #22
0
		public UnitTest CreateUnitTest (IWorkspaceObject entry)
		{
			if (entry is DotNetProject) {
				DotNetProject project = (DotNetProject) entry;
				MonoSolutionItemHandler handler = ProjectExtensionUtil.GetItemHandler (project) as MonoSolutionItemHandler;
				if (handler != null) {
					if (handler.UnitTest != null)
						return (UnitTest) handler.UnitTest;
					string testFileBase = handler.GetTestFileBase ();
					UnitTest testSuite = new MonoTestSuite (project, project.Name, testFileBase);
					handler.UnitTest = testSuite;
					return testSuite;
				}
			}
			return null;
		}
Example #23
0
        public override bool ContainsItem(IWorkspaceObject obj)
        {
            if (base.ContainsItem(obj))
            {
                return(true);
            }

            foreach (WorkspaceItem it in Items)
            {
                if (it.ContainsItem(obj))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #24
0
        public bool CanExecute(IWorkspaceObject entry, ExecutionContext context, ConfigurationSelector configuration)
        {
            if (string.IsNullOrEmpty(command))
            {
                return(false);
            }

            if (context == null)
            {
                return(true);
            }

            var cmd = CreateExecutionCommand(entry, configuration);

            return(context.ExecutionHandler.CanExecute(cmd));
        }
Example #25
0
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
        {
            IWorkspaceObject ob  = (IWorkspaceObject)dataObject;
            GitRepository    rep = VersionControlService.GetRepository(ob) as GitRepository;

            if (rep != null)
            {
                IWorkspaceObject rob;
                if (repos.TryGetValue(rep.RootPath.CanonicalPath, out rob))
                {
                    if (ob == rob)
                    {
                        nodeInfo.Label += " (" + rep.GetCurrentBranch() + ")";
                    }
                }
            }
        }
        protected override void Run(object dataItem)
        {
            IWorkspaceObject ce      = IdeApp.ProjectOperations.CurrentSelectedBuildTarget;
            CustomCommand    cmd     = (CustomCommand)dataItem;
            IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor();

            Thread t = new Thread(
                delegate() {
                using (monitor) {
                    cmd.Execute(monitor, ce, IdeApp.Workspace.ActiveConfiguration);
                }
            }
                );

            t.IsBackground = true;
            t.Start();
        }
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
        {
            IWorkspaceObject ob  = (IWorkspaceObject)dataObject;
            GitRepository    rep = VersionControlService.GetRepository(ob) as GitRepository;

            if (rep != null)
            {
                IWorkspaceObject rob;
                if (repos.TryGetValue(rep.RootPath.CanonicalPath, out rob))
                {
                    if (ob == rob)
                    {
                        label += " (" + rep.GetCurrentBranch() + ")";
                    }
                }
            }
        }
        public static UnitTest CreateTest(IWorkspaceObject entry)
        {
            var project = entry as DotNetProject;

            if (project != null)
            {
                foreach (var r in project.References)
                {
                    if (r.Reference == "xunit")
                    {
                        return(new XUnitProjectTestSuite(project));
                    }
                }
            }

            return(null);
        }
        public CustomCommandWidget(IWorkspaceObject entry, CustomCommand cmd, ConfigurationSelector configSelector, CustomCommandType[] supportedTypes)
        {
            this.Build();
            this.supportedTypes = supportedTypes;
            this.cmd            = cmd;

            updating = true;

            if (cmd == null)
            {
                comboType.AppendText(GettextCatalog.GetString("(Select a project operation)"));
            }

            foreach (var ct in supportedTypes)
            {
                comboType.AppendText(commandNames [(int)ct]);
            }

            updating = false;

            this.entry = entry;
            UpdateControls();
            this.WidgetFlags |= Gtk.WidgetFlags.NoShowAll;

            StringTagModelDescription tagModel;

            if (entry is SolutionItem)
            {
                tagModel = ((SolutionItem)entry).GetStringTagModelDescription(configSelector);
            }
            else if (entry is WorkspaceItem)
            {
                tagModel = ((WorkspaceItem)entry).GetStringTagModelDescription();
            }
            else
            {
                tagModel = new StringTagModelDescription();
            }

            tagSelectorDirectory.TagModel    = tagModel;
            tagSelectorDirectory.TargetEntry = workingdirEntry;

            tagSelectorCommand.TagModel    = tagModel;
            tagSelectorCommand.TargetEntry = entryCommand;
        }
		public ExportProjectDialog (IWorkspaceObject entry, FileFormat selectedFormat)
		{
			this.Build();
			
			FileFormat f = entry is WorkspaceItem ? ((WorkspaceItem)entry).FileFormat : ((SolutionEntityItem)entry).FileFormat;
			labelNewFormat.Text = f.Name;
			
			formats = Services.ProjectService.FileFormats.GetFileFormatsForObject (entry);
			foreach (FileFormat format in formats)
				comboFormat.AppendText (format.Name);

			int sel = Array.IndexOf (formats, selectedFormat);
			if (sel == -1) sel = 0;
			comboFormat.Active = sel;
			
			folderEntry.Path = entry.ItemDirectory;
			UpdateControls ();
		}
        public UnitTest CreateUnitTest(IWorkspaceObject entry)
        {
            UnitTest test = null;

            if (entry is DotNetProject)
            {
                test = XUnitProjectTestSuite.CreateTest(entry);
            }

            UnitTestGroup group = test as UnitTestGroup;

            if (group != null && !group.HasTests)
            {
                return(null);
            }

            return(test);
        }
Example #32
0
		public static bool Publish (IWorkspaceObject entry, FilePath localPath, bool test)
		{
			if (test)
				return true;

			if (!VersionControlService.CheckVersionControlInstalled ())
				return false;

			List<FilePath> files = new List<FilePath> ();

			// Build the list of files to be checked in			
			string moduleName = entry.Name;
			if (localPath == entry.BaseDirectory) {
				GetFiles (files, entry);
			} else if (entry is Project) {
				foreach (ProjectFile file in ((Project)entry).Files.GetFilesInPath (localPath))
					if (file.Subtype != Subtype.Directory)
						files.Add (file.FilePath);
			} else
				return false;

			if (files.Count == 0)
				return false;
	
			SelectRepositoryDialog dlg = new SelectRepositoryDialog (SelectRepositoryMode.Publish);
			try {
				dlg.ModuleName = moduleName;
				dlg.Message = GettextCatalog.GetString ("Initial check-in of module {0}", moduleName);
				do {
					if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok && dlg.Repository != null) {
						AlertButton publishButton = new AlertButton ("_Publish");					
						if (MessageService.AskQuestion (GettextCatalog.GetString ("Are you sure you want to publish the project?"), GettextCatalog.GetString ("The project will be published to the repository '{0}', module '{1}'.", dlg.Repository.Name, dlg.ModuleName), AlertButton.Cancel, publishButton) == publishButton) {
							PublishWorker w = new PublishWorker (dlg.Repository, dlg.ModuleName, localPath, files.ToArray (), dlg.Message);
							w.Start ();
							break;
						}
					} else
						break;
				} while (true);
			} finally {
				dlg.Destroy ();
			}
			return true;
		}
Example #33
0
 public UnitTest FindRootTest(IEnumerable <UnitTest> tests, IWorkspaceObject item)
 {
     foreach (UnitTest t in tests)
     {
         if (t.OwnerObject == item)
         {
             return(t);
         }
         UnitTestGroup tg = t as UnitTestGroup;
         if (tg != null)
         {
             UnitTest ct = FindRootTest(tg.Tests, item);
             if (ct != null)
             {
                 return(ct);
             }
         }
     }
     return(null);
 }
Example #34
0
 public UnitTest CreateUnitTest(IWorkspaceObject entry)
 {
     if (entry is DotNetProject)
     {
         DotNetProject           project = (DotNetProject)entry;
         MonoSolutionItemHandler handler = ProjectExtensionUtil.GetItemHandler(project) as MonoSolutionItemHandler;
         if (handler != null)
         {
             if (handler.UnitTest != null)
             {
                 return((UnitTest)handler.UnitTest);
             }
             string   testFileBase = handler.GetTestFileBase();
             UnitTest testSuite    = new MonoTestSuite(project, project.Name, testFileBase);
             handler.UnitTest = testSuite;
             return(testSuite);
         }
     }
     return(null);
 }
Example #35
0
        public static Repository GetRepository(IWorkspaceObject entry)
        {
            InternalRepositoryReference repoRef = (InternalRepositoryReference)entry.ExtendedProperties [typeof(InternalRepositoryReference)];

            if (repoRef != null)
            {
                return(repoRef.Repo);
            }

            Repository repo = VersionControlService.GetRepositoryReference(entry.BaseDirectory, entry.Name);
            InternalRepositoryReference rref = null;

            if (repo != null)
            {
                repo.AddRef();
                rref = new InternalRepositoryReference(repo);
            }
            entry.ExtendedProperties [typeof(InternalRepositoryReference)] = rref;

            return(repo);
        }
Example #36
0
		public UnitTest CreateUnitTest (IWorkspaceObject entry)
		{
			UnitTest test = null;
			
			if (entry is SolutionFolder)
				test = SolutionFolderTestGroup.CreateTest ((SolutionFolder)entry);
			if (entry is Solution)
				test = SolutionFolderTestGroup.CreateTest (((Solution)entry).RootFolder);
			if (entry is Workspace)
				test = WorkspaceTestGroup.CreateTest ((Workspace)entry);
			if (entry is DotNetProject)
				test = NUnitProjectTestSuite.CreateTest ((DotNetProject)entry);
			if (entry is NUnitAssemblyGroupProject)
				test = ((NUnitAssemblyGroupProject)entry).RootTest;
			
			UnitTestGroup grp = test as UnitTestGroup;
			if (grp != null && !grp.HasTests)
				return null;
			
			return test;
		}
Example #37
0
        protected override void Run(object dataItem)
        {
            IWorkspaceObject ce      = IdeApp.ProjectOperations.CurrentSelectedBuildTarget;
            CustomCommand    cmd     = (CustomCommand)dataItem;
            IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor();

            Thread t = new Thread(
                delegate() {
                using (monitor) {
                    try {
                        cmd.Execute(monitor, ce, IdeApp.Workspace.ActiveConfiguration);
                    } catch (Exception ex) {
                        monitor.ReportError(GettextCatalog.GetString("Command execution failed"), ex);
                    }
                }
            }
                );

            t.IsBackground = true;
            t.Start();
        }
Example #38
0
 public Task(BuildError error, object owner)
 {
     parentObject = error.SourceTarget;
     file         = error.FileName;
     description  = error.ErrorText;
     column       = error.Column;
     line         = error.Line;
     if (!string.IsNullOrEmpty(error.ErrorNumber))
     {
         description += " (" + error.ErrorNumber + ")";
     }
     if (error.IsWarning)
     {
         severity = error.ErrorNumber == "COMMENT" ? TaskSeverity.Information : TaskSeverity.Warning;
     }
     else
     {
         severity = TaskSeverity.Error;
     }
     priority = TaskPriority.Normal;
     code     = error.ErrorNumber;
 }
Example #39
0
        internal static void SaveUserTasks(IWorkspaceObject item)
        {
            string fileToSave = GetUserTasksFilename((WorkspaceItem)item);

            try {
                List <Task> utasks = new List <Task> (userTasks.GetItemTasks(item, true));
                if (utasks.Count == 0)
                {
                    if (File.Exists(fileToSave))
                    {
                        File.Delete(fileToSave);
                    }
                }
                else
                {
                    XmlDataSerializer serializer = new XmlDataSerializer(new DataContext());
                    serializer.Serialize(fileToSave, utasks);
                }
            } catch (Exception ex) {
                LoggingService.LogWarning("Could not save user tasks: " + fileToSave, ex);
            }
        }
Example #40
0
        public bool BelongsToItem(IWorkspaceObject item, bool checkHierarchy)
        {
            if (!checkHierarchy)
            {
                return(item == parentObject);
            }

            IWorkspaceObject cit = parentObject;

            do
            {
                if (cit == item)
                {
                    return(true);
                }
                if (cit is SolutionItem)
                {
                    SolutionItem si = (SolutionItem)cit;
                    if (si.ParentFolder != null)
                    {
                        cit = si.ParentFolder;
                    }
                    else
                    {
                        cit = si.ParentSolution;
                    }
                }
                else if (cit is WorkspaceItem)
                {
                    cit = ((WorkspaceItem)cit).ParentWorkspace;
                }
                else
                {
                    cit = null;
                }
            } while (cit != null);

            return(false);
        }
		private Core.FilePath[] GetAllFiles(IWorkspaceObject item)
		{
			var files = new List<Core.FilePath>();
			if (item is Solution) {
				var sln = (Solution)item;
				files.Add(sln.FileName);
				foreach (var childSolution in sln.GetAllSolutions())
					if (childSolution != sln)
						files.AddRange(GetAllFiles(childSolution));

				foreach (var project in sln.GetAllProjects())
					files.AddRange(GetAllFiles(project));
			}

			if (item is Project) {
				var prj = (Project)item;
				files.Add(prj.FileName);
				foreach (var file in ((Project)item).Files)
					files.Add(file.FilePath);
			}

			return files.ToArray();
		}
        public bool CanExecute(IWorkspaceObject entry, CustomCommandType type, ExecutionContext context, ConfigurationSelector configuration)
        {
            // Note: if this gets changed to return true if *any* of the commands can execute, then
            // ExecuteCommand() needs to be fixed to only execute commands that can be executed.
            bool hasCommandType = false;
            bool canExecute     = true;

            foreach (CustomCommand cmd in this)
            {
                if (cmd.Type == type)
                {
                    hasCommandType = true;

                    if (!cmd.CanExecute(entry, context, configuration))
                    {
                        canExecute = false;
                        break;
                    }
                }
            }

            return(hasCommandType && canExecute);
        }
Example #43
0
        public CustomCommandWidget(IWorkspaceObject entry, CustomCommand cmd, ConfigurationSelector configSelector)
        {
            this.Build();
            this.cmd = cmd;
            if (cmd != null)
            {
                updating = true;
                comboType.RemoveText(0);
                updating = false;
            }

            this.entry = entry;
            UpdateControls();
            this.WidgetFlags |= Gtk.WidgetFlags.NoShowAll;

            StringTagModelDescription tagModel;

            if (entry is SolutionItem)
            {
                tagModel = ((SolutionItem)entry).GetStringTagModelDescription(configSelector);
            }
            else if (entry is WorkspaceItem)
            {
                tagModel = ((WorkspaceItem)entry).GetStringTagModelDescription();
            }
            else
            {
                tagModel = new StringTagModelDescription();
            }

            tagSelectorDirectory.TagModel    = tagModel;
            tagSelectorDirectory.TargetEntry = workingdirEntry;

            tagSelectorCommand.TagModel    = tagModel;
            tagSelectorCommand.TargetEntry = entryCommand;
        }
Example #44
0
		public UnitTest FindRootTest (IEnumerable<UnitTest> tests, IWorkspaceObject item)
		{
			foreach (UnitTest t in tests) {
				if (t.OwnerObject == item)
					return t;
				UnitTestGroup tg = t as UnitTestGroup;
				if (tg != null) {
					UnitTest ct = FindRootTest (tg.Tests, item);
					if (ct != null)
						return ct;
				}
			}
			return null;
		}
Example #45
0
		public UnitTest BuildTest (IWorkspaceObject entry)
		{
			foreach (ITestProvider p in providers) {
				try {
					UnitTest t = p.CreateUnitTest (entry);
					if (t != null)
						return t;
				} catch {
				}
			}
			return null;
		}
Example #46
0
 public ProjectFolder(FilePath absolutePath, IWorkspaceObject parentWorkspaceObject)
     : this(absolutePath, parentWorkspaceObject, null)
 {
 }
Example #47
0
		public UnitTest FindRootTest (IWorkspaceObject item)
		{
			return FindRootTest (RootTests, item);
		}
		public static Repository GetRepository (IWorkspaceObject entry)
		{
			InternalRepositoryReference repoRef = (InternalRepositoryReference) entry.ExtendedProperties [typeof(InternalRepositoryReference)];
			if (repoRef != null)
				return repoRef.Repo;
			
			Repository repo = VersionControlService.GetRepositoryReference (entry.BaseDirectory, entry.Name);
			InternalRepositoryReference rref = null;
			if (repo != null) {
				repo.AddRef ();
				rref = new InternalRepositoryReference (repo);
			}
			entry.ExtendedProperties [typeof(InternalRepositoryReference)] = rref;
			
			return repo;
		}
		public void Export (IWorkspaceObject entry, FileFormat format)
		{
			ExportProjectDialog dlg = new ExportProjectDialog (entry, format);
			try {
				if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) {
					
					using (IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (true)) {
						string folder = dlg.TargetFolder;
						
						string file = entry is WorkspaceItem ? ((WorkspaceItem)entry).FileName : ((SolutionEntityItem)entry).FileName;
						Services.ProjectService.Export (mon, file, folder, dlg.Format);
					}
				}
			} finally {
				dlg.Destroy ();
			}
		}
Example #50
0
		public void ShowOptions (IWorkspaceObject entry)
		{
			ShowOptions (entry, null);
		}
		public void Export (IWorkspaceObject item)
		{
			Export (item, null);
		}
Example #52
0
        public static bool Publish(IWorkspaceObject entry, FilePath localPath, bool test)
        {
            if (test)
            {
                return(VersionControlService.CheckVersionControlInstalled() && VersionControlService.GetRepository(entry) == null);
            }

            List <FilePath> files = new List <FilePath> ();

            // Build the list of files to be checked in
            string moduleName = entry.Name;

            if (localPath == entry.BaseDirectory)
            {
                GetFiles(files, entry);
            }
            else if (entry is Project)
            {
                foreach (ProjectFile file in ((Project)entry).Files.GetFilesInPath(localPath))
                {
                    if (file.Subtype != Subtype.Directory)
                    {
                        files.Add(file.FilePath);
                    }
                }
            }
            else
            {
                return(false);
            }

            if (files.Count == 0)
            {
                return(false);
            }

            SelectRepositoryDialog dlg = new SelectRepositoryDialog(SelectRepositoryMode.Publish);

            try {
                dlg.ModuleName = moduleName;
                dlg.Message    = GettextCatalog.GetString("Initial check-in of module {0}", moduleName);
                do
                {
                    if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok && dlg.Repository != null)
                    {
                        AlertButton publishButton = new AlertButton("_Publish");
                        if (MessageService.AskQuestion(GettextCatalog.GetString("Are you sure you want to publish the project?"), GettextCatalog.GetString("The project will be published to the repository '{0}', module '{1}'.", dlg.Repository.Name, dlg.ModuleName), AlertButton.Cancel, publishButton) == publishButton)
                        {
                            PublishWorker w = new PublishWorker(dlg.Repository, dlg.ModuleName, localPath, files.ToArray(), dlg.Message);
                            w.Start();
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                } while (true);
            } finally {
                dlg.Destroy();
            }
            return(true);
        }
Example #53
0
		public SystemFile (FilePath absolutePath, IWorkspaceObject parent): this (absolutePath, parent, true)
		{
		}
Example #54
0
		public SystemFile (FilePath absolutePath, IWorkspaceObject parent, bool showTransparent)
		{
			this.parent = parent;
			this.absolutePath = absolutePath;
			this.showTransparent = showTransparent;
		}
Example #55
0
		internal static void SaveUserTasks (IWorkspaceObject item)
		{
			string fileToSave = GetUserTasksFilename ((WorkspaceItem)item);
			try {
				List<Task> utasks = new List<Task> (userTasks.GetItemTasks (item, true));
				if (utasks.Count == 0) {
					if (File.Exists (fileToSave))
						File.Delete (fileToSave);
				} else {
					XmlDataSerializer serializer = new XmlDataSerializer (new DataContext ());
					serializer.Serialize (fileToSave, utasks);
				}
			} catch (Exception ex) {
				LoggingService.LogWarning ("Could not save user tasks: " + fileToSave, ex);
			}
		}
		public static Repository GetRepository (IWorkspaceObject entry)
		{
			if (IsGloballyDisabled)
				return null;

			InternalRepositoryReference repoRef = (InternalRepositoryReference) entry.ExtendedProperties [typeof(InternalRepositoryReference)];
			if (repoRef != null)
				return repoRef.Repo;
			
			Repository repo = VersionControlService.GetRepositoryReference (entry.BaseDirectory, entry.Name);
			InternalRepositoryReference rref = null;
			if (repo != null) {
				repo.AddRef ();
				if (!referenceCache.TryGetValue (repo, out rref)) {
					rref = new InternalRepositoryReference (repo);
					referenceCache [repo] = rref;
				}
			}
			entry.ExtendedProperties [typeof(InternalRepositoryReference)] = rref;
			
			return repo;
		}
		protected UnitTestGroup (string name, IWorkspaceObject ownerSolutionItem): base (name, ownerSolutionItem)
		{
		}
Example #58
0
 public ProjectFolder(FilePath absolutePath, IWorkspaceObject parentWorkspaceObject, object parent)
 {
     this.parent = parent;
     this.parentWorkspaceObject = parentWorkspaceObject;
     this.absolutePath = absolutePath.CanonicalPath;
 }
Example #59
0
		public void ShowOptions (IWorkspaceObject entry, string panelId)
		{
			if (entry is SolutionEntityItem) {
				var selectedProject = (SolutionEntityItem) entry;
				
				var optionsDialog = new ProjectOptionsDialog (IdeApp.Workbench.RootWindow, selectedProject);
				var conf = selectedProject.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
				optionsDialog.CurrentConfig = conf != null ? conf.Name : null;
				optionsDialog.CurrentPlatform = conf != null ? conf.Platform : null;
				try {
					if (panelId != null)
						optionsDialog.SelectPanel (panelId);
					
					if (MessageService.RunCustomDialog (optionsDialog) == (int)Gtk.ResponseType.Ok) {
						selectedProject.SetNeedsBuilding (true);
						foreach (object ob in optionsDialog.ModifiedObjects) {
							if (ob is Solution) {
								Save ((Solution)ob);
								return;
							}
						}
						Save (selectedProject);
						IdeApp.Workspace.SavePreferences ();
						IdeApp.Workbench.ReparseOpenDocuments ();
					}
				} finally {
					optionsDialog.Destroy ();
				}
			} else if (entry is Solution) {
				Solution solution = (Solution) entry;
				
				var optionsDialog = new CombineOptionsDialog (IdeApp.Workbench.RootWindow, solution);
				optionsDialog.CurrentConfig = IdeApp.Workspace.ActiveConfigurationId;
				try {
					if (panelId != null)
						optionsDialog.SelectPanel (panelId);
					if (MessageService.RunCustomDialog (optionsDialog) == (int) Gtk.ResponseType.Ok) {
						Save (solution);
						IdeApp.Workspace.SavePreferences (solution);
					}
				} finally {
					optionsDialog.Destroy ();
				}
			}
			else {
				ItemOptionsDialog optionsDialog = new ItemOptionsDialog (IdeApp.Workbench.RootWindow, entry);
				try {
					if (panelId != null)
						optionsDialog.SelectPanel (panelId);
					if (MessageService.RunCustomDialog (optionsDialog) == (int) Gtk.ResponseType.Ok) {
						if (entry is IBuildTarget)
							((IBuildTarget)entry).SetNeedsBuilding (true, IdeApp.Workspace.ActiveConfiguration);
						if (entry is IWorkspaceFileObject)
							Save ((IWorkspaceFileObject) entry);
						else {
							SolutionItem si = entry as SolutionItem;
							if (si.ParentSolution != null)
								Save (si.ParentSolution);
						}
						IdeApp.Workspace.SavePreferences ();
					}
				} finally {
					optionsDialog.Destroy ();
				}
			}
		}
		static void GetFiles (List<FilePath> files, IWorkspaceObject entry)
		{
			// Ensure that we strip out all linked files from outside of the solution/projects path.
			if (entry is IWorkspaceFileObject)
				files.AddRange (((IWorkspaceFileObject)entry).GetItemFiles (true).Where (file => file.CanonicalPath.IsChildPathOf (entry.BaseDirectory)));
		}