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
  • Hey Andrea

    We've based our tool on your Anonymizer. But the locking function does not work:

            public override void ProcessParagraphUnit(IParagraphUnit paragraphUnit)
            {
                base.ProcessParagraphUnit(paragraphUnit);
                if (paragraphUnit.IsStructure) { return; }
    
                foreach (var segmentPair in paragraphUnit.SegmentPairs.ToList())
                {
                    var segmentVisitor = new SegmentVisitor(_patterns, _includeTagContent);
    
                    segmentVisitor.ReplaceText(segmentPair.Source, ItemFactory, PropertiesFactory);
    
                    if (segmentVisitor.ShouldLockSegment)
                    {
                        segmentPair.Properties.IsLocked = true;
                    }
                }
            }
    
Children
No Data