Пример #1
0
 private void mousePressedInIconsArea(MouseEvent e) {
   EditorMessageIconRenderer iconRenderer = getIconRendererUnderMouse(e);
   if (iconRenderer != null) {
     if (e.getButton() == MouseEvent.BUTTON3) {
       JPopupMenu popupMenu = iconRenderer.getPopupMenu();
       if (popupMenu != null && e.getID() == MouseEvent.MOUSE_PRESSED) {
         e.consume();
         Component component = e.getComponent();
         popupMenu.show(component == null ? myEditorComponent : component, e.getX(), e.getY());
       }
       return;
     }
     AnAction action = iconRenderer.getClickAction();
     if (e.getButton() == MouseEvent.BUTTON1 && action != null) {
       if (e.getID() == MouseEvent.MOUSE_CLICKED) {
         AnActionEvent actionEvent =
             new AnActionEvent(
                 e,
                 new LeftEditorHighlighterDataContext(myEditorComponent, iconRenderer.getNode()),
                 ICON_AREA,
                 action.getTemplatePresentation(),
                 ActionManager.getInstance(),
                 e.getModifiers());
         action.update(actionEvent);
         action.actionPerformed(actionEvent);
       }
       e.consume();
     }
   }
 }
Пример #2
0
 private void mouseMovedInIconsArea(MouseEvent e) {
   myMouseIsInFoldingArea = false;
   EditorMessageIconRenderer newRendererUnderMouse = getIconRendererUnderMouse(e);
   if (newRendererUnderMouse != null) {
     setCursor(newRendererUnderMouse.getMouseOverCursor());
   } else if (myRendererUnderMouse != null) {
     setCursor(null);
   }
   myRendererUnderMouse = newRendererUnderMouse;
 }
Пример #3
0
 private jetbrains.mps.openapi.editor.cells.EditorCell getAnchorCell(
     EditorMessageIconRenderer renderer) {
   SNode rendererNode = renderer.getNode();
   EditorCell nodeCell = myEditorComponent.findNodeCell(rendererNode);
   if (nodeCell == null) {
     // no cell for node?..
     return null;
   }
   return renderer.getAnchorCell(nodeCell);
 }
Пример #4
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;
 }
Пример #5
0
 public void removeAllIconRenderers(IconRendererType type) {
   assert SwingUtilities.isEventDispatchThread()
       : "LeftEditorHighlighter.removeAllIconRenderers() should be called in eventDispatchThread";
   boolean wasModified = false;
   for (Iterator<EditorMessageIconRenderer> it = myIconRenderers.iterator(); it.hasNext(); ) {
     EditorMessageIconRenderer renderer = it.next();
     if (renderer.getType() == type) {
       it.remove();
       wasModified = true;
     }
   }
   if (wasModified) {
     relayoutOnIconRendererChanges();
   }
 }
Пример #6
0
 @Override
 public String getMPSTooltipText(MouseEvent e) {
   if (isInFoldingArea(e)) {
     for (AbstractFoldingAreaPainter painter : myFoldingAreaPainters) {
       if (painter.getToolTipText() != null) {
         return painter.getToolTipText();
       }
     }
   } else if (isInTextArea(e)) {
     AbstractLeftColumn column = getTextColumnByX(e.getX());
     if (column != null) {
       return column.getTooltipText(e);
     }
   } else {
     EditorMessageIconRenderer iconRenderer = getIconRendererUnderMouse(e);
     if (iconRenderer != null) {
       return iconRenderer.getTooltipText();
     }
   }
   return null;
 }
Пример #7
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;
 }