public void AddMessage_Had0_Has1()
 {
     var a = new Annotation(XElement.Parse(@"<annotation ref='pretend' class='foo' guid='123'>
     </annotation>"));
     var m = a.AddMessage("joe", "closed", string.Empty);
     Assert.AreEqual(1, a.Messages.Count());
 }
 public void NotifyOfAddition(Annotation annotation)
 {
     if (_includeIndexPredicate(annotation))
     {
         _keyToObjectsMap.Add(_keyMakingFunction(annotation), annotation);
     }
 }
Beispiel #3
0
 public NotePresenter(IXmlChangeReport report, IRetrieveFileVersionsFromRepository fileRetriever)
 {
     Guard.AgainstNull(report,"report");
     _fileRetriever = fileRetriever;
     _report = report;// as XmlAdditionChangeReport;
      _annotation = new Annotation(XElement.Parse(report.ChildNode.OuterXml));
 }
        public void MsarAddsToPrimary()
        {
            var newAnnotation = new Annotation(XElement.Parse("<_primaryAnnotation class='foo' guid='12D388BD-E83D-41AD-BAB3-B7E46D8C13CE'/>"));

            _msar.AddAnnotation(newAnnotation);
            Assert.That(_primary.Results["abc"], Has.Member(newAnnotation));
            // In the event that it mistakenly tries to add to the others, it will crash because their AddKeys are not set.
        }
 public Control CreateWinFormsControl(string contentXml, Annotation parentAnnotation, ChorusUser user)
 {
     var element = XElement.Parse(contentXml);
     var link = new LinkLabel();
     link.Tag = new object[] { parentAnnotation, user };
     link.Text = element.Value + ": when you click this, the annotation should close";
     link.Click += new EventHandler(OnLinkClicked);
     return link;
 }
        public void AddMessage_Had1_Has2InCorrectOrder()
        {
            var a = new Annotation(XElement.Parse(@"<annotation ref='pretend' class='foo' guid='123'>
            <message guid='123' status='open'/></annotation>"));

            var m  = a.AddMessage("joe", "closed", string.Empty);

            Assert.AreEqual(2, a.Messages.Count());
            Assert.AreEqual("open", a.Messages.First().Status);
            Assert.AreEqual("closed", a.Messages.ToArray()[1].Status );
        }
 private static string ExtractKeyOutOfRef(Annotation annotation, string nameOfParameterInRefToIndex)
 {
     if(string.IsNullOrEmpty(annotation.RefStillEscaped))
         return string.Empty;
     return UrlHelper.GetValueFromQueryStringOfRef(annotation.RefStillEscaped,nameOfParameterInRefToIndex, string.Empty);
     //            var parse =HttpUtility.ParseQueryString(annotation.RefStillEscaped);
     //            var values = parse.GetValues(nameOfParameterInRefToIndex);
     //            if(values==null || values.Length == 0)
     //                return string.Empty;
     //            Debug.Assert(values.Length == 1, "Will ignore all but first match (seeing this in debug mode only)");
     //            return values[0];
 }
 public void Remove_FromConstructorOnlyAnnotationsOfKey_RemovesIt()
 {
     using (var r = AnnotationRepository.FromString("id", @"<notes version='0'/>"))
     {
         var a = new Annotation("note", "blah://blah?id=blue", "");
         r.AddAnnotation(a);
         var blues = r.GetMatchesByPrimaryRefKey("blue");
         Assert.AreEqual(a, blues.First());
         r.Remove(a);
         blues = r.GetMatchesByPrimaryRefKey("blue");
         Assert.AreEqual(0, blues.Count(), "should be none left");
     }
 }
 public NoteDetailDialog(Annotation annotation, AnnotationEditorModel.Factory viewModelFactory)
 {
     InitializeComponent();
     var model = viewModelFactory(annotation, false);
     Text = model.GetLongLabel();
     _view = new AnnotationEditorView(model);
     _view.ModalDialogMode = true;
     _view.Dock = DockStyle.Fill;
     //_view.Size  = new Size(Width, Height - 50);
     Controls.Add(_view);
     AcceptButton = _view.OKButton;
     _view.OnClose += (CloseButton_Click);
 }
Beispiel #10
0
        public Annotation CreateAnnotation()
        {
            Guard.AgainstNull(_targetObject, "The program tried to create a note when TargetObject was empty.");
            var id = _mapping.FunctionToGoFromObjectToItsId(_targetObject);
            //nb: it's intentional and necessary to escape the id so it doesn't corrupt
            //the parsing of the url query string, even though the entire url will be
            //escaped again for xml purposes
            var escapedId = UrlHelper.GetEscapedUrl(id);
            var url = _mapping.FunctionToGetCurrentUrlForNewNotes(_targetObject, escapedId);
            var annotation = new Annotation("question", url, "doesntmakesense");
            _repository.AddAnnotation(annotation);

            _repository.SaveNowIfNeeded(new NullProgress());
            return annotation;
        }
 /// <summary>
 /// Remove the annotation (from the repo that claims to contain it, if any).
 /// </summary>
 /// <param name="annotation"></param>
 public void Remove(Annotation annotation)
 {
     if (_primary.ContainsAnnotation(annotation))
         _primary.Remove(annotation);
     else
     {
         foreach (var other in _others)
         {
             if (other.ContainsAnnotation(annotation))
             {
                 other.Remove(annotation);
                 return;
             }
         }
     }
 }
        //TODO: think about or merge these two constructors. this one is for when we're just
        //showing the control with a single annotation... it isn't tied to a list of messages.
        public AnnotationEditorModel(IChorusUser user,
		   StyleSheet styleSheet,
		   EmbeddedMessageContentHandlerRepository embeddedMessageContentHandlerRepository,
			Annotation annotation,
			NavigateToRecordEvent navigateToRecordEventToRaise,
			ChorusNotesDisplaySettings displaySettings,
			bool showLabelAsHyperlink)
        {
            _user = user;
            m_embeddedMessageContentHandlerRepository = embeddedMessageContentHandlerRepository;
            _styleSheet = styleSheet;
            _annotation = annotation;
            _navigateToRecordEventToRaise = navigateToRecordEventToRaise;
            _displaySettings = displaySettings;
            _showLabelAsHyperLink = showLabelAsHyperlink;
        }
        public void GetMatches_AddedBeforeIndexInitialization_FoundViaPredicate()
        {
            using (var r = AnnotationRepository.FromString("id", @"<notes version='0'></notes>"))
            {
                var ann = new Annotation("conflict", "blah://blah?rid=12345", "somepath");
                ann.AddMessage("merger", "open", string.Empty);
                r.AddAnnotation(ann);

                var index = new IndexOfAllOpenConflicts();
                r.AddObserver(index, _progress);
                Assert.AreEqual(1, index.GetMatches(rf => rf.Contains("rid=12345"), _progress).Count());
                Assert.AreEqual(0, index.GetMatches(rf => rf.Contains("rid=333"), _progress).Count());
                ann.SetStatusToClosed("testman");
                Assert.AreEqual(0, index.GetMatches(rf => rf.Contains("rid=12345"), _progress).Count());
            }
        }
Beispiel #14
0
        public void ShowNotesBrowser_LargeNumber()
        {
            using (var f = new TempFile("<notes version='0'/>"))
            {
                var r = AnnotationRepository.FromFile("id", f.Path, new NullProgress());
                for (int i = 0; i < 10000; i++)
                {
                    var annotation = new Annotation("question",
                                                    string.Format("nowhere://blah?id={0}&label={1}", Guid.NewGuid().ToString(), i.ToString()),
                                                    f.Path);
                    r.AddAnnotation(annotation);
                    annotation.AddMessage("test", "open", "blah blah");
                }

                ShowBrowser(new List<AnnotationRepository> {r});
            }
        }
Beispiel #15
0
 public bool CanViewAnnotation(Annotation annotation)
 {
     return true;
 }
 public void NotifyOfDeletion(Annotation annotation)
 {
 }
 public void NotifyOfModification(Annotation annotation)
 {
 }
        public void GetNotesRepository()
        {
            var notes = _chorusSystem.GetNotesRepository(_someDataFilePath, _progress);

            //We can add
            var annotation = new Annotation("question", "blah://blah", _someDataFilePath);
            notes.AddAnnotation(annotation);

            //We can remove
            notes.Remove(annotation);

            //We can retrieve
            notes.GetAllAnnotations();
            notes.GetByCurrentStatus("closed");
            notes.GetMatchesByPrimaryRefKey("1abc3");
            notes.GetMatches(note => note.Messages.Count() > 0);

            //for large repositories, you can also create indexes and add them
            //to the repository, to speed things up.
            var index = new IndexByDate();
            notes.AddObserver(index, _progress);
            var todaysNotes = index.GetByDate(DateTime.Now);

            //Note, index is just one kind of observer, you can add others too.
        }
 public void NotifyOfAddition(Annotation annotation)
 {
 }
        private bool GetShouldBeShown(Annotation annotation, Message message)
        {
            //            if (!ShowClosedNotes)
            //            {
            //                if (annotation.IsClosed)
            //                    return false;
            //            }

            if (string.IsNullOrEmpty(_searchText))
                return true;

            string t = _searchText.ToLowerInvariant();
            if(  annotation.LabelOfThingAnnotated.ToLowerInvariant().StartsWith(t)
                   || annotation.ClassName.ToLowerInvariant().StartsWith(t)
                   || message.Author.ToLowerInvariant().StartsWith(t))
                return true;

            if (t.Length > 2)//arbitrary, but don't want to search on ever last letter
            {
                return message.Text.ToLowerInvariant().Contains(t);
            }
            return false;
        }
        private void Save(Annotation annotation)
        {
            var owningRepo = _repositories.Where(r => r.ContainsAnnotation(annotation)).FirstOrDefault();
            if(owningRepo ==null)
            {
                ErrorReport.NotifyUserOfProblem(
                    "A serious problem has occurred; Chorus cannot find the repository which owns this note, so it cannot be saved.");
                return;
            }

            owningRepo.SaveNowIfNeeded(new NullProgress());
        }
 public void NotifyOfModification(Annotation annotation)
 {
     //NB: this notification would come from the repository, not the view
     _reloadPending = true;
     SaveChanges();
 }
 public bool ContainsAnnotation(Annotation annotation)
 {
     return Results.Any(kvp => kvp.Value.Contains(annotation));
 }
Beispiel #24
0
 public bool ContainsAnnotation(Annotation annotation)
 {
     return(null != _doc.Root.Elements().FirstOrDefault(e => e.GetAttributeValue("guid") == annotation.Guid));
 }
 public void Remove(Annotation annotation)
 {
     Removed = annotation;
     // Note that we don't actually remove it. This makes sure tests don't interfere with each other.
 }
Beispiel #26
0
 public bool ContainsAnnotation(Annotation annotation)
 {
     return null!= _doc.Root.Elements().FirstOrDefault(e => e.GetAttributeValue("guid") == annotation.Guid);
 }
Beispiel #27
0
 public void AddAnnotation(Annotation annotation)
 {
     _doc.Root.Add(annotation.Element);
     _observers.ForEach(index => index.NotifyOfAddition(annotation));
     annotation.Element.Changed += new EventHandler<XObjectChangeEventArgs>(AnnotationElement_Changed);
     _isDirty = true;
 }
 public void MsarDoesNotContainUnknownItem()
 {
     var newAnnotation = new Annotation(XElement.Parse("<_primaryAnnotation class='foo' guid='12D388BD-E83D-41AD-BAB3-B7E46D8C13CE'/>"));
     Assert.That(_msar.ContainsAnnotation(newAnnotation), Is.False);
 }
Beispiel #29
0
 public void Remove(Annotation annotation)
 {
     annotation.Element.Changed -= new EventHandler<XObjectChangeEventArgs>(AnnotationElement_Changed);
      _observers.ForEach(index => index.NotifyOfDeletion(annotation));
      annotation.Element.Remove();
        _isDirty = true;
 }
Beispiel #30
0
 public bool CanCloseAnnotation(Annotation annotation)
 {
     return true;
 }
Beispiel #31
0
 public bool CanDeleteAnnotation(Annotation annotation)
 {
     return true;
 }
Beispiel #32
0
 public IEnumerable <Annotation> GetByCurrentStatus(string status)
 {
     return(from a in _doc.Root.Elements()
            where Annotation.GetStatusOfLastMessage(a) == status
            select new Annotation(a));
 }