コード例 #1
0
    private EditorCell findTarget(SelectionManager selectionManager) {
      Selection selection = selectionManager.getSelection();
      if (selection == null) {
        return null;
      }

      jetbrains.mps.openapi.editor.cells.EditorCell cell = selection.getSelectedCells().get(0);
      if (cell instanceof EditorCell_Label && !((EditorCell_Label) cell).isEverythingSelected()) {
        return (EditorCell) cell;
      }

      if (cell.getParent() == null) {
        return null;
      }

      while (cell.getParent() != null && cell.getParent().isTransparentCollection()) {
        cell = cell.getParent();
      }
      jetbrains.mps.openapi.editor.cells.EditorCell_Collection parent = cell.getParent();
      while (parent != null) {
        if (parent.isSelectable()) {
          while (parent.getParent() != null
              && parent.getParent().isTransparentCollection()
              && parent.getParent().isSelectable()) {
            parent = parent.getParent();
          }
          return (EditorCell) parent;
        }
        parent = parent.getParent();
      }
      return null;
    }
コード例 #2
0
 private EditorCell findTarget(EditorComponent editorComponent) {
   Selection selection = editorComponent.getSelectionManager().getSelection();
   if (selection == null) {
     return null;
   }
   List<EditorCell> selectedCells = selection.getSelectedCells();
   EditorCell cell = selectedCells.get(selectedCells.size() - 1);
   return cell.getEndCell(CellConditions.SELECTABLE);
 }
コード例 #3
0
 private EditorCell findTarget(SelectionManager selectionManager) {
   Selection selection = selectionManager.getSelection();
   if (selection == null) {
     return null;
   }
   EditorCell cell = selection.getSelectedCells().get(0);
   while (cell.getParent() != null) {
     cell = (EditorCell) cell.getParent();
   }
   if (cell instanceof EditorCell_Collection) {
     return cell.findChild(
         myHome ? CellFinders.FIRST_SELECTABLE_LEAF : CellFinders.LAST_SELECTABLE_LEAF);
   }
   return cell;
 }
コード例 #4
0
 private EditorCell findTarget(SelectionManager selectionManager) {
   Selection selection = selectionManager.getSelection();
   if (selection == null) {
     return null;
   }
   List<EditorCell> selectedCells = selection.getSelectedCells();
   EditorCell cell = myHome ? selectedCells.get(0) : selectedCells.get(selectedCells.size() - 1);
   EditorCell leaf =
       myHome
           ? cell.getLeafToLeft(CellConditions.SELECTABLE)
           : cell.getLeafToRight(CellConditions.SELECTABLE);
   if (leaf != null) {
     return leaf;
   }
   return myHome
       ? cell.getPrevLeaf(CellConditions.SELECTABLE)
       : cell.getNextLeaf(CellConditions.SELECTABLE);
 }