public void unfold(boolean programmaticaly) {
    if (!isFolded()) {
      return;
    }
    setFolded(false);
    if (!isUnderFolded()) {
      removeUnfoldingListener();
      addUnfoldingListenerForChildren();
    }

    if (!programmaticaly) {
      getContext().flushEvents();
      getEditor().relayout();
      adjustSelectionToFoldingState(getEditor());
    }
  }
 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());
   }
 }