Exemplo n.º 1
0
 public int getIconCoordinate(EditorMessageIconRenderer renderer) {
   jetbrains.mps.openapi.editor.cells.EditorCell anchorCell = getAnchorCell(renderer);
   if (anchorCell == null || APICellAdapter.isUnderFolded(anchorCell)) {
     // no anchorCell
     return -1;
   }
   if (renderer.getIcon() == null) {
     LOG.error("null icon was returned by renderer: " + renderer);
     return -1;
   }
   return anchorCell.getY() + anchorCell.getHeight() / 2 - renderer.getIcon().getIconHeight() / 2;
 }
Exemplo n.º 2
0
 @Override
 public int compare(
     IconRendererLayoutConstraint constraint1, IconRendererLayoutConstraint constraint2) {
   if (constraint1 == constraint2) {
     return 0;
   }
   EditorMessageIconRenderer renderer1 = constraint1.getIconRenderer();
   EditorMessageIconRenderer renderer2 = constraint2.getIconRenderer();
   if (renderer1.getType() != renderer2.getType()) {
     return renderer1.getType().getWeight() - renderer2.getType().getWeight();
   }
   jetbrains.mps.openapi.editor.cells.EditorCell anchorCell1 = getAnchorCell(renderer1);
   jetbrains.mps.openapi.editor.cells.EditorCell anchorCell2 = getAnchorCell(renderer2);
   // [++] Debugging assertion
   if (anchorCell1 == anchorCell2
       && renderer1 instanceof EditorMessage
       && renderer2 instanceof EditorMessage) {
     EditorMessage editorMessage1 = (EditorMessage) renderer1;
     EditorMessage editorMessage2 = (EditorMessage) renderer2;
     assert false
         : "Two EditorMessages with same type are attached to the same EditorCell: m1 = "
             + editorMessage1
             + ", m2 = "
             + editorMessage2
             + "; owner1 = "
             + editorMessage1.getOwner()
             + ", owner2 = "
             + editorMessage2.getOwner();
   }
   // [--] Debugging assertion
   if (anchorCell1 != null) {
     if (anchorCell2 == null) {
       return 1;
     } else {
       return anchorCell1.getX() - anchorCell2.getX();
     }
   } else if (anchorCell2 != null) {
     return -1;
   }
   return 0;
 }