public DefaultCellInfo(final EditorCell cell) { ModelAccess.instance() .runReadAction( new Runnable() { @Override public void run() { SNode node = cell.getSNode(); if (node == null || node.getModel() == null) { myNodeReference = null; } else { myNodeReference = node.getReference(); } } }); myCellId = cell.getCellId(); EditorCell_Collection parent = (EditorCell_Collection) cell.getParent(); if (parent != null && myCellId == null) { myParentInfo = parent.getCellInfo(); myIsInList = parent.hasCellListHandler(); if (myIsInList || myCellId == null) { myCellNumber = parent.getCellNumber(cell); } } }
@Override public EditorCell findCell(final EditorComponent editorComponent) { if (myCellId != null) { final EditorContext editorContext = editorComponent.getEditorContext(); if (myNodeReference == null) return null; final EditorCell[] cell = new EditorCell[] {null}; editorContext .getRepository() .getModelAccess() .runReadAction( new Runnable() { @Override public void run() { cell[0] = editorComponent.findCellWithId( myNodeReference.resolve(editorContext.getRepository()), myCellId); } }); return cell[0]; } else if (myParentInfo != null) { EditorCell parentCell = myParentInfo.findCell(editorComponent); if (!(parentCell instanceof EditorCell_Collection)) { return null; } EditorCell_Collection parentCollection = (EditorCell_Collection) parentCell; if (myCellNumber >= parentCollection.getCellsCount()) { return null; } EditorCell editorCell = parentCollection.getChildAt(myCellNumber); // This editorCell should not have any cellId due to corresponding conditions in constructor return editorCell.getCellId() == null ? editorCell : null; } return null; }
private void removeFoldingListenerForChildren() { Queue<EditorCell> children = new LinkedList<EditorCell>(getEditorCells()); while (!children.isEmpty()) { EditorCell child = children.poll(); if (!(child instanceof EditorCell_Collection)) { continue; } EditorCell_Collection childCollection = (EditorCell_Collection) child; if (childCollection.isFolded()) { childCollection.removeUnfoldingListener(); } else { children.addAll(childCollection.getEditorCells()); } } }