Example #1
0
        private void InitializeRelationControl(LexRelation relation)
        {
            //TODO: refactor this (sortHelper, pairStringLexEntryIdList, _keyIdMap, GetKeyIdPairFromLexEntry)
            //      to use ApproximateFinder. Eventually refactor the automcompletetextbox to just take one

            IWritingSystemDefinition writingSystem   = GetWritingSystemFromField();
            ResultSet <LexEntry>     recordTokenList =
                _lexEntryRepository.GetAllEntriesSortedByLexicalFormOrAlternative(writingSystem);

            _resultSet = recordTokenList;

            AutoCompleteWithCreationBox <RecordToken <LexEntry>, string> picker =
                CreatePicker <RecordToken <LexEntry> >(relation);

            picker.GetKeyValueFromValue = GetRecordTokenFromTargetId;
            picker.GetValueFromKeyValue = GetTargetIdFromRecordToken;

            picker.Box.ItemDisplayStringAdaptor = new PairStringLexEntryIdDisplayProvider();
            picker.Box.FormToObjectFinder       = FindRecordTokenFromForm;
            picker.Box.ItemFilterer             = FindClosestAndNextClosestAndPrefixedPairStringLexEntryForms;

            picker.Box.Items = recordTokenList;
            if (!String.IsNullOrEmpty(relation.TargetId))
            {
                picker.Box.SelectedItem = GetRecordTokenFromLexEntry(_lexEntryRepository.GetLexEntryWithMatchingId(relation.TargetId));
            }

            picker.CreateNewClicked += OnCreateNewPairStringLexEntryId;
            _control = picker;
        }
Example #2
0
        public void GoToEntryWithId(string entryId)
        {
            //NB: this was written in Dec 2009 while we were discussing getting rid of non-guid ids.

            Guid g = default(Guid);

            try
            {
                g = new Guid(entryId);
            }
            catch
            {
            }
            LexEntry entry;

            if (g != default(Guid))
            {
                entry = _lexEntryRepository.GetLexEntryWithMatchingGuid(g);
            }
            else
            {
                entry = _lexEntryRepository.GetLexEntryWithMatchingId(entryId);
            }

            if (entry == null)
            {
                throw new NavigationException("Could not find the entry with id " + entryId);
            }
            _recordsListBox.SelectedIndex = _records.FindFirstIndex(entry);
        }
        public void ChangeBoundRelation_Single_ToNonExistantCreate_CreatesRelation()
        {
            LexRelation relation = AddRelation(_source, _singleSynonymRelationField.FieldName, _target.Id);

            Control c = RelationController.CreateWidget(_source,
                                                        _singleSynonymRelationType,
                                                        _singleSynonymRelationField,
                                                        _lexEntryRepository,
                                                        delegate { });

            c.Text = "new";

            AutoCompleteWithCreationBox <RecordToken <LexEntry>, string> picker =
                (AutoCompleteWithCreationBox <RecordToken <LexEntry>, string>)c;

            picker.CreateNewObjectFromText();

            LexEntry newEntry = _lexEntryRepository.GetLexEntryWithMatchingId(relation.Key);

            Assert.IsNotNull(newEntry);
            Assert.AreEqual("new", newEntry.LexicalForm[WritingSystemsIdsForTests.OtherIdForTest]);
        }
Example #4
0
 public LexEntry FindFirstEntryMatchingId(string id)
 {
     return(_lexEntryRepository.GetLexEntryWithMatchingId(id));
 }
Example #5
0
 protected override bool EntryDoesExist(string id)
 {
     return(null != _lexEntryRepository.GetLexEntryWithMatchingId(id));
 }