public void fold(boolean programmaticaly) {
   if (!canBePossiblyFolded()) return;
   if (isFolded()) {
     // updating editor's myFoldedCells set (sometimes this method is called from Memento)
     getEditor().setFolded(this, true);
     return;
   }
   setFolded(true);
   if (!isUnderFolded()) {
     addUnfoldingListener();
     removeFoldingListenerForChildren();
   }
   if (!programmaticaly) {
     getContext().flushEvents();
     getEditor().relayout();
     adjustSelectionToFoldingState(getEditor());
   }
 }