public EditPoint getEditPoint() { if (editPoint == null) editPoint = new EditPoint((IEntityPart) getFocusEntityPart(), 0); else { IEntityPart focusPart = (IEntityPart) getFocusEntityPart(); if (editPoint.focus != focusPart) { editPoint.focus = focusPart; editPoint.caret = 0; } } return editPoint; }
public boolean navigateModel(KeyEvent event, int direction) { EditPoint focusPoint = getEditPoint(); if (!(focusPoint.focus.getParent() instanceof IEntityPart)) return false; switch (direction) { case NORTH: IEntityPart parentPart = (IEntityPart) focusPoint.focus.getParent(); if (isRootPart(parentPart)) return false; editPoint.focus = parentPart; break; case SOUTH: List<?> children = focusPoint.focus.getChildren(); if (children.isEmpty()) return false; editPoint.focus = (IEntityPart) children.get(0); break; case EAST: parentPart = (IEntityPart) focusPoint.focus.getParent(); if (isRootPart(parentPart)) return false; List<?> siblings = parentPart.getChildren(); int index = siblings.indexOf(editPoint.focus); if (index < siblings.size() - 1) editPoint.focus = findModelFirstChild((IEntityPart) siblings.get(index + 1)); else editPoint.focus = parentPart; break; case WEST: parentPart = (IEntityPart) focusPoint.focus.getParent(); if (isRootPart(parentPart)) return false; siblings = parentPart.getChildren(); index = siblings.indexOf(editPoint.focus); if (index > 0) editPoint.focus = findModelLastChild((IEntityPart) siblings.get(index - 1)); else editPoint.focus = parentPart; break; } editPoint.caret = 0; navigateTo(editPoint.focus, event); return true; }