Exemple #1
0
 void UseDefaultToggled(object sender, System.EventArgs e)
 {
     if (checkCustom.Active)
     {
         infoTable.Sensitive = true;
         if (info != null)
         {
             nameEntry.Text      = info.Name ?? "";
             emailEntry.Text     = info.Email ?? "";
             copyrightEntry.Text = info.Copyright ?? "";
             companyEntry.Text   = info.Company ?? "";
             trademarkEntry.Text = info.Trademark ?? "";
         }
     }
     else
     {
         infoTable.Sensitive = false;
         info = new AuthorInformation(nameEntry.Text, emailEntry.Text, copyrightEntry.Text, companyEntry.Text, trademarkEntry.Text);
         if (String.IsNullOrEmpty(info.Name) && String.IsNullOrEmpty(info.Email))
         {
             info = null;
         }
         nameEntry.Text      = AuthorInformation.Default.Name ?? "";
         emailEntry.Text     = AuthorInformation.Default.Email ?? "";
         copyrightEntry.Text = AuthorInformation.Default.Copyright ?? "";
     }
 }
Exemple #2
0
        static bool InsertHeader(Document document)
        {
            var textBuffer = document.Editor;

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

            AuthorInformation userInfo = document.Project != null ? document.Project.AuthorInformation : AuthorInformation.Default;

            if (!userInfo.IsValid)
            {
                string title  = GettextCatalog.GetString("ChangeLog entries can't be generated");
                string detail = GettextCatalog.GetString("The name or e-mail of the user has not been configured.");
                MessageService.ShowError(title, detail);
                return(false);
            }
            string eol  = document.Editor != null ? document.Editor.EolMarker : Environment.NewLine;
            string date = DateTime.Now.ToString("yyyy-MM-dd");
            string text = date + "  " + userInfo.Name + "  <" + userInfo.Email + ">"
                          + eol + eol;

            // Read the first line and compare it with the header: if they are
            // the same don't insert a new header.
            int pos = GetHeaderEndPosition(document);

            if (pos < 0 || (pos + 2 > textBuffer.Length) || textBuffer.GetTextAt(0, pos + 2) != text)
            {
                textBuffer.InsertText(0, text);
            }
            return(true);
        }
        private bool InsertHeader(Document document)
        {
            IEditableTextBuffer textBuffer = document.GetContent <IEditableTextBuffer>();

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

            AuthorInformation userInfo = IdeApp.Workspace.GetAuthorInformation(document.Project);

            if (!userInfo.IsValid)
            {
                string title  = GettextCatalog.GetString("ChangeLog entries can't be generated");
                string detail = GettextCatalog.GetString("The name or e-mail of the user has not been configured.");
                MessageService.ShowError(title, detail);
                return(false);
            }

            string date = DateTime.Now.ToString("yyyy-MM-dd");
            string text = date + "  " + userInfo.Name + "  <" + userInfo.Email + ">"
                          + Environment.NewLine + Environment.NewLine;

            // Read the first line and compare it with the header: if they are
            // the same don't insert a new header.
            int pos = GetHeaderEndPosition(document);

            if (pos < 0 || (pos + 2 > textBuffer.Length) || textBuffer.GetText(0, pos + 2) != text)
            {
                textBuffer.InsertText(0, text);
            }
            return(true);
        }
        public AuthorInformationPanelWidget(AuthorInformation info)
        {
            this.Build();

            this.info          = info;
            checkCustom.Active = (info != null);
            UseDefaultToggled(this, EventArgs.Empty);
        }
        public static string GetHeader(AuthorInformation authorInfo, StandardHeaderPolicy policy, TextStylePolicy textPolicy,
                                       string fileName, bool newFile)
        {
            string[] comment = Document.GetCommentTags(fileName);
            if (comment == null)
            {
                return("");
            }

            if (string.IsNullOrEmpty(policy.Text) || (newFile && !policy.IncludeInNewFiles))
            {
                return("");
            }

            string result;
            string eolMarker = TextStylePolicy.GetEolMarker(textPolicy.EolMarker);

            if (comment.Length == 1)
            {
                string cmt = comment[0];
                //make sure there's a space between the comment char and the license text
                if (!char.IsWhiteSpace(cmt[cmt.Length - 1]))
                {
                    cmt = cmt + " ";
                }

                StringBuilder sb    = new StringBuilder(policy.Text.Length);
                string[]      lines = policy.Text.Split('\n');
                foreach (string line in lines)
                {
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        sb.Append(cmt.TrimEnd());
                        sb.Append(eolMarker);
                        continue;
                    }
                    sb.Append(cmt);
                    sb.Append(line);
                    sb.Append(eolMarker);
                }
                result = sb.ToString();
            }
            else
            {
                //multiline comment
                result = String.Concat(comment[0], "\n", policy.Text, "\n", comment[1], "\n");
            }

            return(StringParserService.Parse(result, new string[, ] {
                {   "FileName", Path.GetFileName(fileName) },
                {   "FileNameWithoutExtension", Path.GetFileNameWithoutExtension(fileName) },
                {   "Directory", Path.GetDirectoryName(fileName) },
                {   "FullFileName", fileName },
                { "AuthorName", authorInfo.Name },
                { "AuthorEmail", authorInfo.Email },
                { "CopyrightHolder", authorInfo.Copyright },
            }));
        }
        public static string GetHeader(SolutionItem policyParent, string fileName, bool newFile)
        {
            StandardHeaderPolicy headerPolicy = policyParent != null?policyParent.Policies.Get <StandardHeaderPolicy> () : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <StandardHeaderPolicy> ();

            TextStylePolicy textPolicy = policyParent != null?policyParent.Policies.Get <TextStylePolicy> ("text/plain") : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <TextStylePolicy> ("text/plain");

            AuthorInformation authorInfo = policyParent != null ? policyParent.AuthorInformation : AuthorInformation.Default;

            return(GetHeader(authorInfo, headerPolicy, textPolicy, fileName, newFile));
        }
        public static CommitMessageFormat GetCommitMessageFormat(ChangeSet cset, out AuthorInformation authorInfo)
        {
            // If all files belong to a project, use that project's policy. If not, use the solution policy
            Project project     = null;
            bool    sameProject = true;

            foreach (ChangeSetItem item in cset.Items)
            {
                if (project != null)
                {
                    if (project.Files.GetFile(item.LocalPath) == null)
                    {
                        // Not all files belong to the same project
                        sameProject = false;
                        break;
                    }
                }
                else
                {
                    project = IdeApp.Workspace.GetProjectsContainingFile(item.LocalPath).FirstOrDefault();
                }
            }
            CommitMessageStyle style;

            if (project != null)
            {
                VersionControlPolicy policy;
                if (sameProject)
                {
                    policy = project.Policies.Get <VersionControlPolicy> ();
                }
                else
                {
                    policy = project.ParentSolution.Policies.Get <VersionControlPolicy> ();
                }
                style = policy.CommitMessageStyle;
            }
            else
            {
                style = PolicyService.GetDefaultPolicy <CommitMessageStyle> ();
            }

            authorInfo = project != null ? project.AuthorInformation : AuthorInformation.Default;

            CommitMessageFormat format = new CommitMessageFormat();

            format.Style = style;
            format.ShowFilesForSingleComment = false;

            return(format);
        }
Exemple #8
0
 public void Load(CommitMessageFormat format, AuthorInformation uinfo)
 {
     updating                   = true;
     this.format                = format;
     this.uinfo                 = uinfo;
     checkIndent.Active         = format.Style.LineAlign != 0;
     checkLineSep.Active        = format.Style.InterMessageLines != 0;
     checkMsgInNewLine.Active   = format.Style.LastFilePostfix == ":\n";
     checkOneLinePerFile.Active = format.Style.FileSeparator == ":\n* ";
     checkUseBullets.Active     = format.Style.FirstFilePrefix.Trim().Length > 0;
     checkIndentEntries.Active  = format.Style.Indent.Length > 0;
     entryHeader.Text           = ToCString(format.Style.Header.TrimEnd('\n'));
     UpdatePreview();
     updating = false;
 }
		public void Load (CommitMessageFormat format, AuthorInformation uinfo)
		{
			updating = true;
			this.format = format;
			this.uinfo = uinfo;
			checkIndent.Active = format.Style.LineAlign != 0;
			checkLineSep.Active = format.Style.InterMessageLines != 0;
			checkMsgInNewLine.Active = format.Style.LastFilePostfix == ":\n";
			checkOneLinePerFile.Active = format.Style.FileSeparator == ":\n* ";
			checkUseBullets.Active = format.Style.FirstFilePrefix.Trim ().Length > 0;
			checkIndentEntries.Active = format.Style.Indent.Length > 0;
			entryHeader.Text = ToCString (format.Style.Header.TrimEnd ('\n'));
			UpdatePreview ();
			updating = false;
		}
Exemple #10
0
 public override void ApplyChanges()
 {
     if (solution != null)
     {
         AuthorInformation ainfo = widget.Get();
         if (ainfo != null)
         {
             solution.UserProperties.SetValue <AuthorInformation> ("AuthorInfo", ainfo);
         }
         else if (solution.UserProperties.HasValue("AuthorInfo"))
         {
             solution.UserProperties.RemoveValue("AuthorInfo");
         }
     }
 }
Exemple #11
0
        // Creates new, empty header. Sets Charset to something meaningful ("UTF-8", currently).
        void CreateNewHeaders(TranslationProject project)
        {
            RevisionDate = CreationDate = Catalog.GetDateTimeRfc822Format();

            Language = Country = Project = Team = TeamEmail = "";

            Charset = "utf-8";
            AuthorInformation userInfo = IdeApp.Workspace.GetAuthorInformation(project);

            Translator      = userInfo.Name;
            TranslatorEmail = userInfo.Email;

            //dt.SourceCodeCharset = String.Empty;
            UpdateHeaderDict();
        }
Exemple #12
0
        // Creates new, empty header. Sets Charset to something meaningful ("UTF-8", currently).
        void CreateNewHeaders(TranslationProject project)
        {
            if (project == null)
            {
                return;
            }
            RevisionDate = CreationDate = Catalog.GetDateTimeRfc822Format();

            Language = Country = Project = Team = TeamEmail = "";

            Charset = "utf-8";
            AuthorInformation userInfo = project.AuthorInformation;

            Translator      = userInfo.Name;
            TranslatorEmail = userInfo.Email;

            //dt.SourceCodeCharset = String.Empty;
            UpdateHeaderDict();
        }
Exemple #13
0
 public ChangeLogWriter(string path, AuthorInformation uinfo)
 {
     changelog_path = Path.GetDirectoryName(path);
     this.uinfo     = uinfo;
 }
Exemple #14
0
		public ChangeLogWriter (string path, AuthorInformation uinfo)
		{
			changelog_path = Path.GetDirectoryName (path);
			this.uinfo = uinfo;
		}
Exemple #15
0
        public override Gtk.Widget CreatePanelWidget()
        {
            AuthorInformation info = solution.UserProperties.GetValue <AuthorInformation> ("AuthorInfo");

            return(widget = new AuthorInformationPanelWidget(info));
        }