Custom Terminology Provider - Cannot display language selection

I'm building a custom Terminology Provider and following the example in the ExcelTerminology sample project.

Once a terminology provider (i.e. termbase) has been selected, I should be able to map the termbase's languages to the project's languages...  but the termbase's languages never appear.

I suspect this is because there's something wrong with the termbase -  there is a red 'x' appearing adjacent to the termbase name once selected...

I've stepped through the code when a termbase gets selected and there are no exceptions, but I strongly suspect that between calling the constructor of my AbstractTerminologyProvider implementation and the GetLanguages method something is going wrong - the GetLanguages method is never called.

Here is the code which is called once the termbases have been browsed and selected...

My BridgeTerminologyProvider (referenced in the above code) has a constructor...

As can be seen, at the conclusion of this constructor I present a MessageBox showing the termbases's languages; this MessageBox is presented and contains the expected languages so I assume that everything has gone ok with this constructor. However, this is when the red 'x' appears next to the termbase's name (2nd image above).

I've also followed the documentation guide here, and the next step is to populate the GetLanguages method, but in my case GetLanguages is never called. So the process goes from my constructor - which appears to succeed - and never calls the subsequent method in the documentation. Perhaps there's something wrong with my implementation of ITerminologyProvider but no exceptions are thrown and the red 'x' doesn't have a tooltip offering an explanation.

I've F11'd my way through the code and upon leaving the TerminologyProviderWinFormsUI.Browse method (without any exceptions) the termbase name appears with a red 'x' and no languages are selectable.

What might be going wrong? What happens between TerminologyProviderWinFormsUI.Browse returning and ITerminologyProvider.GetLanguages being called?

  • Hi  

    Just wanted to give you an update on this. The guys spent the best part of today on this issue after making sure they could build a working application themselves... they could. But they can't figure out what's wrong with your source code yet. Will update you later when they get to the bottom of it.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

  • Hi Andrew,

    Really appreciate your support in making your plugin available for debug purposes.


    The issue was realted to the provider being cast to the incorrect interface by the project termbase provider.  Updating the architecture of your project to resemble more what is demonstrated in the Sdl.Community.ExcelTerminology project resolved the issue.

    I have uploaded a new version of your plugin that is identified correctly by the terminology provider; (location via e-mail).  Please use this as an example in furthering your progress in development of this plugin.

    for now, I have created an action item for myself -> to identify how we can improve the API + provide better support in avoiding the issue you raised here.

    Thank you,

    Patrick Andrew

    Patrick Andrew Hartnett | RWS Group

  • Hi Patrick,

    Thanks very much for the help. I'm now able to display search results as expected. However, the next problem occurs when the user double-clicks on a search result (or right-clicks and then selects "View term details"): I've created a UserControl which gets passed the expected object.

    [TerminologyProviderViewerWinFormsUI]
    public class TerminologyProviderViewerWinFormsUI : ITerminologyProviderViewerWinFormsUI
    {
        private TerminologyProvider _terminologyProvider;
        private TermsList _control;


        public Control Control
        {
            get
            {
                _control = new TermsList(_terminologyProvider)
                               {
                                   Text = @"TerminologyProviderViewerWinFormsUITermbaseBridge",
                                   BackColor = Color.White
                               };

                JumpToTermAction += _control.DisplayConcept;

                return _control;
            }
        }

        // code elided
    }

    The above method is called and returns my TermsList user control, as expected.

    The JumpToTermAction event is also invoked, as expected, and I can step through the code and see that the concept argument is as expected.

    public partial class TermsList : UserControl
    {
        public TermsList(TerminologyProvider provider)
        {
        }


        public void DisplayConcept(IEntry entry)
        {
            if (!(entry is Concept concept))
            {
                return;
            }

            label1 = new Label();
            label1.Text = concept.TermGroups.First(tg => tg.Language != null).Language.Code;

        // code elided
    }

    Screenshot of Trados Studio code showing the TermsList class with DisplayConcept method and a QuickWatch window displaying the 'entry' object properties.

    However, there are two things that puzzle me:

    1. I placed a Label control on the TermsList user control; in the DisplayConcept method this Label control is null.
      Following the documentation here I also tried to place a WebBrowser control onto the user control - again, when the method was called I found that the WebBrowser control was null.
      Why?
      DisplayConcept is not a static method, the user control has been instantiated, so why are its constituent controls not instantiated?

    2. Despite populating a new instance of a Label control in the above code snippet (as well as trying with a WebBrowser control) the Termbase Viewer panel is empty.
      It's as if the TermsList control that I'm working with is not the same instance which was instantiated by the TerminologyProviderViewerWinFormsUI class.

    Screenshot of Trados Studio's Termbase Viewer panel with an empty white space indicating no term details are displayed.



    Generated Image Alt-Text
    [edited by: Trados AI at 1:07 PM (GMT 0) on 5 Mar 2024]