Exemplo n.º 1
0
        public bool OnAddCustomField(object argument)
        {
            CheckDisposed();

            // Only allow adding custom fields when a single client is connected.
            if (Cache.NumberOfRemoteClients > 1 || (Cache.ProjectId.IsLocal && Cache.NumberOfRemoteClients > 0))
            {
                MessageBoxUtils.Show(ParentForm, xWorksStrings.ksCustomFieldsCanNotBeAddedDueToRemoteClientsText,
                                     xWorksStrings.ksCustomFieldsCanNotBeAddedDueToRemoteClientsCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(true);
            }

            AddCustomFieldDlg.LocationType locationType = AddCustomFieldDlg.LocationType.Lexicon;
            string areaChoice = m_mediator.PropertyTable.GetStringProperty("areaChoice", string.Empty);

            switch (areaChoice)
            {
            case "lexicon":
                locationType = AddCustomFieldDlg.LocationType.Lexicon;
                break;

            case "notebook":
                locationType = AddCustomFieldDlg.LocationType.Notebook;
                break;
            }
            using (var dlg = new AddCustomFieldDlg(m_mediator, locationType))
                dlg.ShowDialog(this);

            return(true);               // handled
        }
Exemplo n.º 2
0
        private void DeleteCustomField(FieldDescription fd)
        {
            // delete custom field that was added to a LexEntry for testing
            if (fd.IsCustomField && fd.IsInstalled)
            {
                fd.MarkForDeletion = true;
                AddCustomFieldDlg.UpdateCachedObjects(Cache, fd);

                Cache.ActionHandlerAccessor.BeginUndoTask("UndoUpdateCustomField", "RedoUpdateCustomField");
                fd.UpdateCustomField();
                Cache.ActionHandlerAccessor.EndUndoTask();
            }
            FieldDescription.ClearDataAbout();
        }
Exemplo n.º 3
0
        public bool OnAddCustomField(object argument)
        {
            CheckDisposed();

            // initialize the dialog according to the proper context. (cf. LT-4404)
            int owningFlid = Clerk.OwningFlid;
            int dstClass   = (int)Cache.GetDestinationClass((uint)owningFlid);

            if (dstClass == 0)
            {
                dstClass = LexEntry.kclsidLexEntry;                     // default will be Entry Class.
            }
            using (AddCustomFieldDlg dlg = new AddCustomFieldDlg(m_mediator, dstClass))
            {
                dlg.ShowDialog();
            }

            return(true);               // handled
        }
Exemplo n.º 4
0
        public bool OnAddCustomField(object argument)
        {
            CheckDisposed();

            if (SharedBackendServices.AreMultipleApplicationsConnected(Cache))
            {
                MessageBoxUtils.Show(ParentForm, xWorksStrings.ksCustomFieldsCanNotBeAddedDueToOtherAppsText,
                                     xWorksStrings.ksCustomFieldsCanNotBeAddedDueToOtherAppsCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(true);
            }

            AddCustomFieldDlg.LocationType locationType = AddCustomFieldDlg.LocationType.Lexicon;
            string areaChoice = m_propertyTable.GetStringProperty("areaChoice", string.Empty);

            switch (areaChoice)
            {
            case "lexicon":
                locationType = AddCustomFieldDlg.LocationType.Lexicon;
                break;

            case "notebook":
                locationType = AddCustomFieldDlg.LocationType.Notebook;
                break;

            case "textsWords":
                locationType = AddCustomFieldDlg.LocationType.Interlinear;
                break;
            }
            using (var dlg = new AddCustomFieldDlg(m_mediator, m_propertyTable, locationType))
            {
                if (dlg.ShowCustomFieldWarning(this))
                {
                    dlg.ShowDialog(this);
                }
            }

            return(true);               // handled
        }
        public void PopulateListsCombo()
        {
            string source =
                @"<window>
					  <lists>
						<list id='AreasList'>
						  <item label='Lists' value='lists'>
							<parameters id='lists'>
							  <clerks>
								<clerk id='SemanticDomainList'>
								  <recordList owner='LangProject' property='SemanticDomainList'>
								  </recordList>
								</clerk>
								<clerk id='customList'>
								  <recordList owner='unowned' property='placeholder'>
								  </recordList>
								</clerk>
								<clerk id='GenreList'>
								  <recordList owner='LangProject' property='GenreList'>
								  </recordList>
								</clerk>
							  </clerks>
							  <tools>
								<tool label='Genres' value='genresEdit'>
								  <control>
									<parameters>
									  <control>
										<parameters area='lists' clerk='GenreList'  />
									  </control>
									</parameters>
								  </control>
								</tool>
								<tool label='Semantic Domains' value='semanticDomainEdit' icon='SideBySideView'>
								  <control>
									<parameters>
									  <control>
										<parameters area='lists' dummy='control has no clerk' />
									  </control>
									  <SomeSillyWrapper>
										  <control>
											<parameters area='lists' clerk='SemanticDomainList' />
										  </control>
									  </SomeSillyWrapper>
									</parameters>
								  </control>
								</tool>
								<tool label='Custom 1' value='custom1list'>
								  <control>
									<parameters>
									  <control>
										<parameters area='lists' clerk='customList' />
									  </control>
									</parameters>
								  </control>
								</tool>
							  </tools>
							</parameters>
						  </item>
						  <item label='Grammar' value='grammar'>
							<parameters id='lists'>
							  <clerks>
								<clerk id='categories'>
								  <recordList owner='LangProject' property='PartsOfSpeech'>
								  </recordList>
								</clerk>
							  </clerks>
							  <tools>
								<tool label='Categories Browse' value='categories'>
								  <control>
									<parameters>
									  <control>
										<parameters area='grammar' clerk='categories'  />
									  </control>
									</parameters>
								  </control>
								</tool>
								<tool label='Categories Edit' value='categories'>
								  <control>
									<parameters>
									  <control>
										<parameters area='grammar' clerk='categories'  />
									  </control>
									</parameters>
								  </control>
								</tool>
							  </tools>
							</parameters>
						  </item>
						</list>
					  </lists>
					 </window>"                    ;
            var cmPossibilityListFactory = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>();
            var customList = cmPossibilityListFactory.Create();

            if (Cache.LangProject.SemanticDomainListOA == null)
            {
                Cache.LangProject.SemanticDomainListOA = cmPossibilityListFactory.Create();
            }
            if (Cache.LangProject.GenreListOA == null)
            {
                Cache.LangProject.GenreListOA = cmPossibilityListFactory.Create();
            }
            var realSource = source.Replace("placeholder", customList.Guid.ToString());
            var doc        = new XmlDocument();

            doc.LoadXml(realSource);
            var windowConfiguration = doc.DocumentElement;
            var items = AddCustomFieldDlg.GetListsComboItems(Cache, windowConfiguration);

            Assert.That(items, Has.Count.EqualTo(4));
            Assert.That(items[0].Name, Is.EqualTo("Custom 1"));
            Assert.That(items[1].Name, Is.EqualTo("Genres"));
            Assert.That(items[2].Name, Is.EqualTo("PartsOfSpeech"));
            Assert.That(items[3].Name, Is.EqualTo("Semantic Domains"));
            Assert.That(items[0].Id, Is.EqualTo(customList.Guid));
            Assert.That(items[1].Id, Is.EqualTo(Cache.LangProject.GenreListOA.Guid));
            Assert.That(items[2].Id, Is.EqualTo(Cache.LangProject.PartsOfSpeechOA.Guid));
            Assert.That(items[3].Id, Is.EqualTo(Cache.LangProject.SemanticDomainListOA.Guid));
        }