I'm planing to add a third-party Editor to Studio, please help

Hi Friends,

Due to there is some change in Unicode currently there is only one editor can display a small language correctly, Studio even MS Word can not display it correctly.

So I'm planing to develop a plugin reference third-party editor for Studio.

My detailed plan is:

I will Show a small window some where in screen as viewPart, and Third-Party Editor will on it, the editor can set() and get() unicode characters, I will have three major button/functions:

1. GetText() Get Studio Text to Editor  //editorController.ActiveDocument.FocusedDocumentContent.Target.ToString()

                                                            or //activeDocument.get_Selection().get_Target()      //Document.Selection.Current.Target()

2. SetText Send Unicode to Studio   //.....Target().Replace()

3. Move to NextSegment (If Null Stop)  //From API I found Sdl.TranslationStudioAutomation.IntegrationApi.DocumentSelection but no way to move next

Can anybody give some suggesstions on these three steps, currently we are considering pure text only, no tags.

Parents Reply Children
  • Hi Romulus,

    I tried to listen ActiveSegmentChanged but seems failed, can you help?

    this is code:

    [ViewPartLayout(typeof(EditorController), Dock = DockType.Bottom)]
        class MongolianEditorController : AbstractViewPartController
        {
            protected override System.Windows.Forms.Control GetContentControl()
            {
                return _control.Value;
            }
            protected override void Initialize()
            {
                editorController = SdlTradosStudio.Application.GetController<EditorController>();
                _document = editorController.ActiveDocument;
                _document.ActiveSegmentChanged += new EventHandler(_document_ActiveSegmentChanged);
            }
            private void _document_ActiveSegmentChanged(object sender, EventArgs e)
            {
                _control.Value.textBox1.Text = _document.Selection.Target.ToString();
            }
            private Document _document;
            private EditorController editorController;
            private readonly Lazy<MongolianEditer> _control = new Lazy<MongolianEditer>(() => new MongolianEditer());
        }

    I don't understand why readonly Lazy<MongolianEditer> _control, is this cause failed interactive with control?

    Does that means actions should be inside control but not the controller, a little confused.

  • The control is created using Lazy<T> as a small optimization to postpone the creation of the actual control until is actually needed. When Studio starts it will load all ViewPartControllers including the ones from the plugins which in your case means that an instance of MongolianEditorController will be created when Studio is starting. The problem is that the user might not open the editor view which means that your view part will never be displayed. If we don't use Lazy<T> your user control will be created when Studio starts but it might not be used. Hope this make sense :).

    Regarding your problem have you try to set a break-point inside _document_ActiveSegmentChanged and see if is hit? Also you trying to get the target text from the selection property which will always be empty in this event. Selection property represents the text that you select with the mouse cursor inside a segment which will always be empty when you change segments. To get the text from the target segment you can do something like this _document.Target.ToString().

    If you are interested to react when a text is selected you should used the Change event from the _document.Selection.

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • Thanks a lot, It is working now, and for others who want to make the same thing, please also refer to (this https://community.sdl.com/developers/language-developers/f/57/p/5133/18617#18617) and this (http://romuluscrisan.com/sdl%20studio/2015/06/02/Integration%20API%20enhancements%20introduced%20in%20SDL%20Studio%20CU10.html#accessupdate-segment-and-paragraph-unit-properties)