How to change segment pair attributes - IsLocked - and refresh the editor screen ??

Hi there,

I'm currently struggling with something which should be quite simple..

By clicking on a custom ribbon button I'd like to

1. loop over the segment pairs displayed in the editor
2. based on a predicate set their property to IsLocked = true
3. change the display filter to "view only locked"
4. refresh the editor grid.

My neurons are probably affected by the flu, because I couldn't make it work..

My main difficulties are:

1. I can't change and persist the IsLocked property as it switches automatically back to false
2. I can't call a refresh on the EditorController because of it's protection level applied to the AbstractViewController
3. I never found in the documentation how to change the display filter.

Any help would be much appreciated,

have a great day ...

Greg

Code :

        public class ApplyAction : AbstractViewControllerAction<EditorController>
        {
            protected override void Execute()
            {
                foreach (var s in Controller.ActiveDocument.SegmentPairs)
                    if (/*specific condition*/)
                        s.Properties.IsLocked = true;
                        // can be persited , it switches back to false immediately

                // Here I'd like to do 2 things
                
                // 1. change the editor display filter to "only locked segment"
                //    I've been looking in vain in the documentation, any hint ?       

                // 2. trigger a refresh of the editor
                //    Controller.Refresh is inaccessible due to its protection level.
            }
        }
Parents Reply Children
  • Hey Andrea

    We're hitting another issue with the Plugin. It works well if it's run standalone as a batch task for at the end of all other batch tasks. But we need to run it now before we do the Pre-Translation. As shown here. The task is called ContextSegmentLocker. It's being hit and runs through.

    Here's the code again:

    public override void ProcessParagraphUnit(IParagraphUnit paragraphUnit)
    {
      base.ProcessParagraphUnit(paragraphUnit);
      if (paragraphUnit.IsStructure) { return; }
      if (paragraphUnit.Properties.Contexts == null) { return; }

      foreach (var context in paragraphUnit.Properties.Contexts.Contexts)
      {
        if (_contextList.Contains(context.DisplayName))
        {
          foreach (var segmentPair in paragraphUnit.SegmentPairs)
          {  
            segmentPair.Properties.IsLocked = true;
          }
        }
      }
    }

    Unfortuantely, paragraphUnit.SegmentPairs is always empty. Why is that?

    Most other properties look fine.