Exemple #1
0
        /// <summary>
        /// Gets the new/edited <code>PropertyItem</code>
        /// </summary>
        public SvnPropertyValue GetPropertyItem()
        {
            SvnPropertyValue result = this._currentEditor == null ? null : this._currentEditor.PropertyItem;

            if (result != null)
            {
                if (!_currentEditor.AllowNodeKind(_currentNodeKind))
                {
                    MessageBox.Show(
                        "Can not set a file property on a directory. ",
                        "Invalid Directory Property", MessageBoxButtons.OK,
                        MessageBoxIcon.Hand);
                    return(null);
                }
                string propertyName = this.nameComboBox.Text;
                if (string.IsNullOrEmpty(propertyName))
                {
                    result = null;
                }
                else
                {
                    if (result.Key != propertyName)
                    {
                        result = new SvnPropertyValue(propertyName, (byte[])result.RawValue);
                    }
                }
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Bring up Property Dialog in Add mode.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addButton_Click(object sender, System.EventArgs e)
        {
            using (PropertyDialog propDialog = new PropertyDialog(_currentNodeKind))
            {
                if (propDialog.ShowDialog(Context) != DialogResult.OK)
                {
                    return;
                }

                SvnPropertyValue value = propDialog.GetPropertyItem();
                if (value != null)
                {
                    PropertyEditItem pi;
                    if (!_propItems.TryGetValue(value.Key, out pi))
                    {
                        _propItems[value.Key] = pi = new PropertyEditItem(propListView, value.Key);
                    }

                    pi.Value = value;
                    pi.Refresh();

                    if (!propListView.Items.Contains(pi))
                    {
                        PopulateListView();
                    }

                    this.UpdateButtons();
                }
            }
        }
        private bool TryParseBool(SvnPropertyValue pv, out bool boolValue)
        {
            string val = pv.StringValue;

            boolValue = false;
            if (string.IsNullOrEmpty(val))
            {
                return(false);
            }

            if (string.Equals(val, "true", StringComparison.OrdinalIgnoreCase) ||
                string.Equals(val, "yes", StringComparison.OrdinalIgnoreCase) ||
                string.Equals(val, SvnPropertyNames.SvnBooleanValue))
            {
                boolValue = true;
                return(true);
            }

            if (string.Equals(val, "false", StringComparison.OrdinalIgnoreCase) ||
                string.Equals(val, "no", StringComparison.OrdinalIgnoreCase))
            {
                boolValue = false;
                return(true);
            }

            return(false);
        }
Exemple #4
0
        internal static unsafe SvnPropertyCollection CreatePropertyDictionary(apr_hash_t propHash, AprPool pool)
        {
            if (propHash == null)
            {
                throw new ArgumentNullException(nameof(propHash));
            }
            if (pool == null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

            var _properties = new SvnPropertyCollection();

            for (var hi = apr_hash.apr_hash_first(pool.Handle, propHash); hi != null; hi = apr_hash.apr_hash_next(hi))
            {
                sbyte *pKey;
                long   keyLen = 0;
                svn_string_t.__Internal *propValPtr;

                apr_hash.apr_hash_this(hi, (void **)&pKey, ref keyLen, (void **)&propValPtr);

                var propVal = svn_string_t.__CreateInstance(new IntPtr(propValPtr));
                _properties.Add(SvnPropertyValue.Create(pKey, propVal, null));
            }

            return(_properties);
        }
Exemple #5
0
        public static string CreateValue(SvnPropertyValue value)
        {
            if (value == null)
            {
                return("");
            }
            else if (value.StringValue != null)
            {
                return(value.StringValue.Replace("\r", "").Replace("\n", "\x23CE"));
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("0x");
                int n = 0;
                foreach (byte b in value.RawValue)
                {
                    sb.AppendFormat(CultureInfo.InvariantCulture, "{0:x2}", b);
                    if (n++ > 128)
                    {
                        sb.Append("...");
                        break;
                    }
                }

                return(sb.ToString());
            }
        }
Exemple #6
0
 public PropertyDialog(SvnPropertyValue editItem, SvnNodeKind currentNodeKind)
 {
     InitializeComponent();
     // Dialog is in Edit mode if the "existingItem" is not null.
     this._existingItem = editItem;
     _currentNodeKind = currentNodeKind;
     InitializeEditors();
 }
Exemple #7
0
 public PropertyDialog(SvnPropertyValue editItem, SvnNodeKind currentNodeKind)
 {
     InitializeComponent();
     // Dialog is in Edit mode if the "existingItem" is not null.
     this._existingItem = editItem;
     _currentNodeKind   = currentNodeKind;
     InitializeEditors();
 }
Exemple #8
0
        /// <summary>
        /// Brings up the Property Dialog in edit mode.
        /// </summary>
        private void editButton_Click(object sender, System.EventArgs e)
        {
            PropertyEditItem item = (PropertyEditItem)this.propListView.SelectedItems[0];

            using (PropertyDialog pDialog = new PropertyDialog(item.Value, _currentNodeKind))
            {
                if (pDialog.ShowDialog(Context) != DialogResult.OK)
                {
                    return;
                }

                SvnPropertyValue value = pDialog.GetPropertyItem();
                if (value != null)
                {
                    if (value.Key != item.PropertyName)
                    {
                        item.Value = null; // Deleted
                        item.Refresh();

                        PropertyEditItem pi;

                        if (!_propItems.TryGetValue(value.Key, out pi))
                        {
                            _propItems[value.Key] = pi = new PropertyEditItem(propListView, value.Key);
                        }

                        pi.Value = value;

                        PopulateListView(); // Add new item
                    }
                    else
                    {
                        item.Value = value;
                        item.Refresh();
                    }
                }
                else
                {
                    item.Value = null;
                    if (item.BaseValue == null)
                    {
                        _propItems.Remove(item.PropertyName);
                        propListView.Items.Remove(item);
                    }
                    else
                    {
                        item.Refresh();
                    }
                }
            }
        }
        private void LoadPropertyBoth(SettingsCache cache, SvnPropertyValue pv)
        {
            bool boolValue;
            int  intValue;

            switch (pv.Key)
            {
            case SvnPropertyNames.BugTrackAppend:
                if (!cache.BugTrackAppend.HasValue && TryParseBool(pv, out boolValue))
                {
                    cache.BugTrackAppend = boolValue;
                }
                break;

            case SvnPropertyNames.BugTrackLabel:
                if (cache.BugTrackLabel == null)
                {
                    cache.BugTrackLabel = pv.StringValue;
                }
                break;

            case SvnPropertyNames.BugTrackLogRegex:
                if (cache.BugTrackLogRegexes == null)
                {
                    cache.BugTrackLogRegexes = pv.StringValue;
                }
                break;

            case SvnPropertyNames.BugTrackMessage:
                if (cache.BugTrackMessage == null)
                {
                    cache.BugTrackMessage = pv.StringValue.Replace("\r", "");
                }
                break;

            case SvnPropertyNames.BugTrackNumber:
                if (!cache.BugTrackNumber.HasValue && TryParseBool(pv, out boolValue))
                {
                    cache.BugTrackNumber = boolValue;
                }
                break;

            case SvnPropertyNames.BugTrackUrl:
                if (cache.BugTrackUrl == null)
                {
                    cache.BugTrackUrl = pv.StringValue;
                }
                break;

            case SvnPropertyNames.BugTrackWarnIfNoIssue:
                if (!cache.BugTrackWarnIfNoIssue.HasValue && TryParseBool(pv, out boolValue))
                {
                    cache.BugTrackWarnIfNoIssue = boolValue;
                }
                break;

            case SvnPropertyNames.TortoiseSvnLogMinSize:
                if (!cache.LogMessageMinSize.HasValue && !string.IsNullOrEmpty(pv.StringValue) &&
                    int.TryParse(pv.StringValue, out intValue))
                {
                    cache.LogMessageMinSize = intValue;
                }
                break;

            case SvnPropertyNames.TortoiseSvnLockMsgMinSize:
                if (!cache.LockMessageMinSize.HasValue && !string.IsNullOrEmpty(pv.StringValue) &&
                    int.TryParse(pv.StringValue, out intValue))
                {
                    cache.LockMessageMinSize = intValue;
                }
                break;

            case SvnPropertyNames.TortoiseSvnLogWidthLine:
                if (!cache.LogWidth.HasValue && !string.IsNullOrEmpty(pv.StringValue) &&
                    int.TryParse(pv.StringValue, out intValue))
                {
                    cache.LogWidth = intValue;
                }
                break;

            case SvnPropertyNames.TortoiseSvnLogSummary:
                if (cache.LogSummary == null)
                {
                    cache.LogSummary = pv.StringValue;
                }
                break;

            case SvnPropertyNames.TortoiseSvnLogRevRegex:
                if (cache.RevisionRegex == null)
                {
                    cache.RevisionRegex = pv.StringValue;
                }
                break;

            case SvnPropertyNames.WebViewerRevision:
                if (cache.RevisionUrl == null)
                {
                    cache.RevisionUrl = pv.StringValue;
                }
                break;

            case SvnPropertyNames.WebViewerPathRevision:
                if (cache.RevisionPathUrl == null)
                {
                    cache.RevisionPathUrl = pv.StringValue;
                }
                break;

            case AnkhSccPropertyNames.IssueRepositoryConnector:
                cache.IssueRepositoryConnectorName = pv.StringValue;
                break;

            case AnkhSccPropertyNames.IssueRepositoryUri:
                cache.IssueRepositoryUri = pv.StringValue;
                break;

            case AnkhSccPropertyNames.IssueRepositoryId:
                cache.IssueRepositoryId = pv.StringValue;
                break;

            case AnkhSccPropertyNames.IssueRepositoryPropertyNames:
                cache.IssueRepositoryPropertyNames = pv.StringValue;
                break;

            case AnkhSccPropertyNames.IssueRepositoryPropertyValues:
                cache.IssueRepositoryPropertyValues = pv.StringValue;
                break;
            }
        }
Exemple #10
0
 /// <summary>
 /// Gets the new/edited <code>PropertyItem</code>
 /// </summary>
 public SvnPropertyValue GetPropertyItem()
 {
     SvnPropertyValue result = this._currentEditor == null ? null : this._currentEditor.PropertyItem;
     if (result != null)
     {
         if (!_currentEditor.AllowNodeKind(_currentNodeKind))
         {
             MessageBox.Show(
                 "Can not set a file property on a directory. ",
                 "Invalid Directory Property", MessageBoxButtons.OK,
                 MessageBoxIcon.Hand);
             return null;
         }
         string propertyName = this.nameComboBox.Text;
         if (string.IsNullOrEmpty(propertyName))
         {
             result = null;
         }
         else
         {
             if (result.Key != propertyName)
                 result = new SvnPropertyValue(propertyName, (byte[])result.RawValue);
         }
     }
     return result;
 }
Exemple #11
0
        public static string CreateValue(SvnPropertyValue value)
        {
            if (value == null)
                return "";
            else if (value.StringValue != null)
                return value.StringValue.Replace("\r", "").Replace("\n", "\x23CE");
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("0x");
                int n = 0;
                foreach (byte b in value.RawValue)
                {
                    sb.AppendFormat(CultureInfo.InvariantCulture, "{0:x2}", b);
                    if (n++ > 128)
                    {
                        sb.Append("...");
                        break;
                    }
                }

                return sb.ToString();
            }
        }
Exemple #12
0
        private bool TryParseBool(SvnPropertyValue pv, out bool boolValue)
        {
            string val = pv.StringValue;

            boolValue = false;
            if (string.IsNullOrEmpty(val))
                return false;

            if (string.Equals(val, "true", StringComparison.OrdinalIgnoreCase)
                || string.Equals(val, "yes", StringComparison.OrdinalIgnoreCase)
                || string.Equals(val, SvnPropertyNames.SvnBooleanValue, StringComparison.OrdinalIgnoreCase))
            {
                boolValue = true;
                return true;
            }

            if (string.Equals(val, "false", StringComparison.OrdinalIgnoreCase)
                || string.Equals(val, "no", StringComparison.OrdinalIgnoreCase))
            {
                boolValue = false;
                return true;
            }

            return false;
        }
Exemple #13
0
 private void LoadPropertyBoth(SettingsCache cache, SvnPropertyValue pv)
 {
     bool boolValue;
     int intValue;
     switch (pv.Key)
     {
         case SvnPropertyNames.BugTrackAppend:
             if (!cache.BugTrackAppend.HasValue && TryParseBool(pv, out boolValue))
                 cache.BugTrackAppend = boolValue;
             break;
         case SvnPropertyNames.BugTrackLabel:
             if (cache.BugTrackLabel == null)
                 cache.BugTrackLabel = pv.StringValue;
             break;
         case SvnPropertyNames.BugTrackLogRegex:
             if (cache.BugTrackLogRegexes == null)
                 cache.BugTrackLogRegexes = pv.StringValue;
             break;
         case SvnPropertyNames.BugTrackMessage:
             if (cache.BugTrackMessage == null)
                 cache.BugTrackMessage = pv.StringValue.Replace("\r", "");
             break;
         case SvnPropertyNames.BugTrackNumber:
             if (!cache.BugTrackNumber.HasValue && TryParseBool(pv, out boolValue))
                 cache.BugTrackNumber = boolValue;
             break;
         case SvnPropertyNames.BugTrackUrl:
             if (cache.BugTrackUrl == null)
                 cache.BugTrackUrl = pv.StringValue;
             break;
         case SvnPropertyNames.BugTrackWarnIfNoIssue:
             if (!cache.BugTrackWarnIfNoIssue.HasValue && TryParseBool(pv, out boolValue))
                 cache.BugTrackWarnIfNoIssue = boolValue;
             break;
         case SvnPropertyNames.TortoiseSvnLogMinSize:
             if (!cache.LogMessageMinSize.HasValue && !string.IsNullOrEmpty(pv.StringValue)
                 && int.TryParse(pv.StringValue, out intValue))
             {
                 cache.LogMessageMinSize = intValue;
             }
             break;
         case SvnPropertyNames.TortoiseSvnLockMsgMinSize:
             if (!cache.LockMessageMinSize.HasValue && !string.IsNullOrEmpty(pv.StringValue)
                 && int.TryParse(pv.StringValue, out intValue))
             {
                 cache.LockMessageMinSize = intValue;
             }
             break;
         case SvnPropertyNames.TortoiseSvnLogWidthLine:
             if (!cache.LogWidth.HasValue && !string.IsNullOrEmpty(pv.StringValue)
                 && int.TryParse(pv.StringValue, out intValue))
             {
                 cache.LogWidth = intValue;
             }
             break;
         case SvnPropertyNames.TortoiseSvnLogSummary:
             if (cache.LogSummary == null)
                 cache.LogSummary = pv.StringValue;
             break;
         case AnkhSccPropertyNames.IssueRepositoryConnector:
             cache.IssueRepositoryConnectorName = pv.StringValue;
             break;
         case AnkhSccPropertyNames.IssueRepositoryUri:
             cache.IssueRepositoryUri = pv.StringValue;
             break;
         case AnkhSccPropertyNames.IssueRepositoryId:
             cache.IssueRepositoryId = pv.StringValue;
             break;
         case AnkhSccPropertyNames.IssueRepositoryPropertyNames:
             cache.IssueRepositoryPropertyNames = pv.StringValue;
             break;
         case AnkhSccPropertyNames.IssueRepositoryPropertyValues:
             cache.IssueRepositoryPropertyValues = pv.StringValue;
             break;
     }
 }