private EditorCell createTable_sl01pn_c0(EditorContext editorContext, SNode node) {
   TableModelFactory creator =
       new TableModelFactory() {
         public TableModel createTableModel(final SNode node, final EditorContext editorContext) {
           return new HierarchycalTableModelWithHeader(
               node,
               SLinkOperations.findLinkDeclaration(
                   MetaAdapterFactory.getContainmentLink(
                       0xdf8799e7254a406fL,
                       0xbd67f4cc27337152L,
                       0x28004d411fa3bea0L,
                       0x28004d411fa3bea2L,
                       "rows")),
               SLinkOperations.findLinkDeclaration(
                   MetaAdapterFactory.getContainmentLink(
                       0xdf8799e7254a406fL,
                       0xbd67f4cc27337152L,
                       0x28004d411fa3bea6L,
                       0x28004d411fa3bea7L,
                       "cells")),
               SLinkOperations.findLinkDeclaration(
                   MetaAdapterFactory.getContainmentLink(
                       0xdf8799e7254a406fL,
                       0xbd67f4cc27337152L,
                       0x760c9302beb3e1d1L,
                       0x760c9302beb3e1d4L,
                       "headers")));
         }
       };
   jetbrains.mps.openapi.editor.cells.EditorCell_Collection editorCell =
       EditorCell_Table.createTable(
           editorContext, node, creator.createTableModel(node, editorContext), "Table_sl01pn_c0");
   editorCell.setCellId("Table_sl01pn_c0_0");
   return editorCell;
 }
Exemplo n.º 2
0
 public static boolean isUnderFolded(EditorCell cell) {
   for (EditorCell_Collection parent = cell.getParent();
       parent != null;
       parent = parent.getParent()) {
     if (parent.isCollapsed()) return true;
   }
   return false;
 }
Exemplo n.º 3
0
  private RestorableSelection saveSelection(EditorContext editorContext) {
    EditorCell selectedCell = editorContext.getSelectedCell();

    if (selectedCell == null || selectedCell instanceof EditorCell_Collection) {
      // No need to save selection, it will be restored by normal means
      return null;
    }

    EditorCell_Collection parent = selectedCell.getParent();
    if (parent.getCellsCount() < EXPECTED_CHILD_INDEX + 1
        || parent.getCellAt(EXPECTED_CHILD_INDEX) != selectedCell) {
      // No need to save selection, it will be restored by normal means
      return null;
    }

    return new RestorableSelectionByCell(
        new ChildCellLocator(
            new CellIdLocator(parent.getCellId(), parent.getSNode()), EXPECTED_CHILD_INDEX),
        createCellSelector(selectedCell));
  }
Exemplo n.º 4
0
 private EditorCell createTable_io08np_c0(EditorContext editorContext, SNode node) {
   TableModelFactory creator =
       new TableModelFactory() {
         public TableModel createTableModel(final SNode node, final EditorContext editorContext) {
           return new XYCTableModel(
               node,
               SLinkOperations.findLinkDeclaration(
                   "jetbrains.mps.lang.editor.tableTests.structure.Matrix", "xs"),
               SLinkOperations.findLinkDeclaration(
                   "jetbrains.mps.lang.editor.tableTests.structure.Matrix", "ys"),
               SLinkOperations.findLinkDeclaration(
                   "jetbrains.mps.lang.editor.tableTests.structure.Matrix", "contents"),
               editorContext);
         }
       };
   jetbrains.mps.openapi.editor.cells.EditorCell_Collection editorCell =
       EditorCell_Table.createTable(
           editorContext, node, creator.createTableModel(node, editorContext), "Table_io08np_c0");
   editorCell.setCellId("Table_io08np_c0_0");
   return editorCell;
 }
Exemplo n.º 5
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;
    }
Exemplo n.º 6
0
    private EditorCell getCommonSelectableAncestor(
        jetbrains.mps.openapi.editor.cells.EditorCell first,
        jetbrains.mps.openapi.editor.cells.EditorCell... cells) {
      jetbrains.mps.openapi.editor.cells.EditorCell_Collection result =
          first instanceof jetbrains.mps.openapi.editor.cells.EditorCell_Collection
              ? (jetbrains.mps.openapi.editor.cells.EditorCell_Collection) first
              : first.getParent();
      while (result != null) {
        if (result.isSelectable()) {
          boolean common = true;
          for (jetbrains.mps.openapi.editor.cells.EditorCell cell : cells) {
            if (!result.isAncestorOf(cell) && result != cell) {
              common = false;
              break;
            }
          }
          if (common) return (EditorCell) result;
        }

        result = result.getParent();
      }
      return null;
    }
Exemplo n.º 7
0
  public static void _doLayout(EditorCell_Collection editorCells) {
    final int x = editorCells.getX();
    final int y = editorCells.getY();
    int currentLineWidth = 0;
    int totalWidth = 0;
    int totalHeight = 0;
    int currentLineHeight = 0;
    String nextLineForChildren = editorCells.getStyle().get(StyleAttributes.POSITION_CHILDREN);

    for (EditorCell editorCell : editorCells) {
      String nextLine = editorCell.getStyle().get(StyleAttributes.POSITION);
      if (nextLine != null) {
        System.out.println("nextLine = " + nextLine);
      }
      if (INDENTED.equals(nextLine) || (nextLine == null && INDENTED.equals(nextLineForChildren))) {
        currentLineWidth = INDENT;
        totalHeight += currentLineHeight;
        currentLineHeight = 0;
      } else if (NEXT_LINE.equals(nextLine)
          || (nextLine == null && NEXT_LINE.equals(nextLineForChildren))) {
        currentLineWidth = 0;
        totalHeight += currentLineHeight;
        currentLineHeight = 0;
      }
      editorCell.setX(x + currentLineWidth);
      editorCell.setY(y + totalHeight);
      editorCell.relayout();
      //      System.out.println("EditorCell [" +
      // editorCell.getX()+","+editorCell.getY()+","+editorCell.getWidth()+","+editorCell.getHeight()+"] node:"+editorCell.getSNode().getConceptShortName()+" cell:"+ editorCell.toString());
      currentLineHeight = Math.max(currentLineHeight, editorCell.getHeight());
      currentLineWidth += editorCell.getWidth();
      totalWidth = Math.max(totalWidth, currentLineWidth);
    }
    editorCells.setWidth(totalWidth);
    editorCells.setHeight(totalHeight + currentLineHeight);
  }