private FontRenderContext getCurrentContext(Editor editor) { FontRenderContext editorContext = FontInfo.getFontRenderContext(editor.getContentComponent()); return new FontRenderContext(editorContext.getTransform(), AntialiasingType.getKeyForCurrentScope(false), editor instanceof EditorImpl ? ((EditorImpl)editor).myFractionalMetricsHintValue : RenderingHints.VALUE_FRACTIONALMETRICS_OFF); } }
/** * Turns off the ex entry field and optionally puts the focus back to the original component */ public void deactivate(boolean refocusOwningEditor) { if (!myActive) return; myActive = false; myText.setText(""); if (refocusOwningEditor) { UiHelper.requestFocus(myEditor.getContentComponent()); } if (myOldGlass != null) { myOldGlass.removeComponentListener(myAdapter); myOldGlass.setVisible(false); myOldGlass.remove(this); myOldGlass.setOpaque(myWasOpaque); myOldGlass.setLayout(myOldLayout); } }
public ModalEntryDialog(@NotNull Editor editor, @NotNull String prompt) { super((Frame)null, true); myParent = editor.getContentComponent(); myLabel = new JLabel(prompt); myEntry = new JTextField();
/** * Turns on the more window for the given editor */ private void activate() { JRootPane root = SwingUtilities.getRootPane(myEditor.getContentComponent()); myOldGlass = (JComponent)root.getGlassPane(); if (myOldGlass != null) { myOldLayout = myOldGlass.getLayout(); myWasOpaque = myOldGlass.isOpaque(); myOldGlass.setLayout(null); myOldGlass.setOpaque(false); myOldGlass.add(this); myOldGlass.addComponentListener(myAdapter); } setFontForElements(); positionPanel(); if (myOldGlass != null) { myOldGlass.setVisible(true); } myActive = true; UiHelper.requestFocus(myText); }
private void positionPanel() { final JComponent contentComponent = myEditor.getContentComponent(); Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, contentComponent); setSize(scroll.getSize()); myLineHeight = myText.getFontMetrics(myText.getFont()).getHeight(); int count = countLines(myText.getText()); int visLines = getSize().height / myLineHeight - 1; int lines = Math.min(count, visLines); setSize(getSize().width, lines * myLineHeight + myLabel.getPreferredSize().height + getBorder().getBorderInsets(this).top * 2); int height = getSize().height; Rectangle bounds = scroll.getBounds(); bounds.translate(0, scroll.getHeight() - height); bounds.height = height; Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(), SwingUtilities.getRootPane(contentComponent).getGlassPane()); bounds.setLocation(pos); setBounds(bounds); myScrollPane.getVerticalScrollBar().setValue(0); if (!Options.getInstance().isSet("more")) { // FIX scrollOffset(100000); } else { scrollOffset(0); } }
@Override public JComponent getRequestFocusComponent() { return this.selectEditor.getContentComponent(); }
@Override public JComponent getRequestFocusComponent() { return this.editor.getContentComponent(); }
entry.setText(initText); entry.setType(label); parent = editor.getContentComponent(); if (!ApplicationManager.getApplication().isUnitTestMode()) { JRootPane root = SwingUtilities.getRootPane(parent);
@Override public void dispose() { unregisterCustomShortcutSet(editor.getContentComponent()); } }
private void doTest() { PsiFile file = myFixture.configureByFile(getTestName(true) + ".go"); resolveAllReferences(file); myFixture.checkHighlighting(); ApplicationManager.getApplication().runWriteAction( () -> OptimizeImportsAction.actionPerformedImpl(DataManager.getInstance().getDataContext(myFixture.getEditor().getContentComponent()))); myFixture.checkResultByFile(getTestName(true) + "_after.go"); }
public OperatorCompletionAction(Project project, Editor editor) { this.project = project; this.editor = editor; registerCustomShortcutSet(KeyEvent.VK_SPACE, KeyEvent.CTRL_MASK, editor.getContentComponent()); }
public static int getMouseOffset(Editor editor) { Point mousePosition = editor.getContentComponent().getMousePosition(); LogicalPosition pos=editor.xyToLogicalPosition(mousePosition); int offset = editor.logicalPositionToOffset(pos); return offset; }
public void actionPerformed(ActionEvent e) { debug("key typed " + e); if (getSelectedElement() == null) return; Editor editor = _caretMover.openInEditor(getSelectedElement()); selectElementAtCaret(editor, TREE_SELECTION_CHANGED); editor.getContentComponent().requestFocus(); } });
public void dispose() { editor.getCaretModel().removeCaretListener(this); editor.getContentComponent().removeKeyListener(this.extraHighlightTrigger); }
public HighlightEditorComponent(Editor editor) { this.editor = editor; this.extraHighlightTrigger = new ExtraHighlightTrigger(this); this.editor.getContentComponent().addKeyListener(this.extraHighlightTrigger); editor.getCaretModel().addCaretListener(this); }
public static void moveCursor(Editor editor, int cursorOffset) { CaretModel caretModel = editor.getCaretModel(); caretModel.moveToOffset(cursorOffset); ScrollingModel scrollingModel = editor.getScrollingModel(); scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE); editor.getContentComponent().requestFocus(); }
private void addCommentActionToEditor(Editor editor, String filePath, ChangeInfo changeInfo, String revisionId, Side commentSide) { if (editor == null) return; DefaultActionGroup group = new DefaultActionGroup(); final AddCommentAction addCommentAction = addCommentActionBuilder .create(this, changeInfo, revisionId, editor, filePath, commentSide) .withText("Add Comment") .withIcon(AllIcons.Toolwindows.ToolWindowMessages) .get(); addCommentAction.registerCustomShortcutSet(CustomShortcutSet.fromString("C"), editor.getContentComponent()); group.add(addCommentAction); PopupHandler.installUnknownPopupHandler(editor.getContentComponent(), group, ActionManager.getInstance()); }
public void jumpToGrammarPosition(Project project, int start) { final ANTLRv4PluginController controller = ANTLRv4PluginController.getInstance(project); if ( controller==null ) return; final Editor grammarEditor = controller.getEditor(previewState.grammarFile); if ( grammarEditor==null ) return; CaretModel caretModel = grammarEditor.getCaretModel(); caretModel.moveToOffset(start); ScrollingModel scrollingModel = grammarEditor.getScrollingModel(); scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE); grammarEditor.getContentComponent().requestFocus(); }
Point mousePosition = editor.getContentComponent().getMousePosition(); if ( mousePosition!=null ) { LogicalPosition pos = editor.xyToLogicalPosition(mousePosition);
private void createUIComponents() { final EditorFactory editorFactory = EditorFactory.getInstance(); jsonDocument = editorFactory.createDocument(EMPTY_TEXT); jsonEditor = editorFactory.createEditor(jsonDocument, project, JsonFileType.INSTANCE, false); final EditorSettings settings = jsonEditor.getSettings(); settings.setWhitespacesShown(true); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setLineNumbersShown(true); settings.setFoldingOutlineShown(false); settings.setRightMarginShown(false); settings.setVirtualSpace(false); settings.setWheelFontChangeEnabled(false); settings.setUseSoftWraps(false); settings.setAdditionalColumnsCount(0); settings.setAdditionalLinesCount(1); final EditorColorsScheme colorsScheme = jsonEditor.getColorsScheme(); colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null); jsonEditor.getContentComponent().setFocusable(true); jsonPanel = (JPanel) jsonEditor.getComponent(); }