com.intellij.openapi.editor.Editor.getContentComponent()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(184)

本文整理了Java中com.intellij.openapi.editor.Editor.getContentComponent()方法的一些代码示例,展示了Editor.getContentComponent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Editor.getContentComponent()方法的具体详情如下:
包路径:com.intellij.openapi.editor.Editor
类名称:Editor
方法名:getContentComponent

Editor.getContentComponent介绍

暂无

代码示例

代码示例来源:origin: JetBrains/ideavim

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);
 }
}

代码示例来源:origin: JetBrains/ideavim

/**
 * 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);
 }
}

代码示例来源:origin: JetBrains/ideavim

public ModalEntryDialog(@NotNull Editor editor, @NotNull String prompt) {
 super((Frame)null, true);
 myParent = editor.getContentComponent();
 myLabel = new JLabel(prompt);
 myEntry = new JTextField();

代码示例来源:origin: JetBrains/ideavim

/**
 * 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);
}

代码示例来源:origin: JetBrains/ideavim

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);
 }
}

代码示例来源:origin: dboissier/mongo4idea

@Override
public JComponent getRequestFocusComponent() {
  return this.selectEditor.getContentComponent();
}

代码示例来源:origin: dboissier/mongo4idea

@Override
public JComponent getRequestFocusComponent() {
  return this.editor.getContentComponent();
}

代码示例来源:origin: JetBrains/ideavim

entry.setText(initText);
entry.setType(label);
parent = editor.getContentComponent();
if (!ApplicationManager.getApplication().isUnitTestMode()) {
 JRootPane root = SwingUtilities.getRootPane(parent);

代码示例来源:origin: dboissier/mongo4idea

@Override
  public void dispose() {
    unregisterCustomShortcutSet(editor.getContentComponent());
  }
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

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");
}

代码示例来源:origin: dboissier/mongo4idea

public OperatorCompletionAction(Project project, Editor editor) {
  this.project = project;
  this.editor = editor;
  registerCustomShortcutSet(KeyEvent.VK_SPACE, KeyEvent.CTRL_MASK, editor.getContentComponent());
}

代码示例来源:origin: antlr/intellij-plugin-v4

public static int getMouseOffset(Editor editor) {
  Point mousePosition = editor.getContentComponent().getMousePosition();
  LogicalPosition pos=editor.xyToLogicalPosition(mousePosition);
  int offset = editor.logicalPositionToOffset(pos);
  return offset;
}

代码示例来源:origin: cmf/psiviewer

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();
  }
});

代码示例来源:origin: qeesung/HighlightBracketPair

public void dispose() {
  editor.getCaretModel().removeCaretListener(this);
  editor.getContentComponent().removeKeyListener(this.extraHighlightTrigger);
}

代码示例来源:origin: qeesung/HighlightBracketPair

public HighlightEditorComponent(Editor editor) {
  this.editor = editor;
  this.extraHighlightTrigger = new ExtraHighlightTrigger(this);
  this.editor.getContentComponent().addKeyListener(this.extraHighlightTrigger);
  editor.getCaretModel().addCaretListener(this);
}

代码示例来源:origin: antlr/intellij-plugin-v4

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();
}

代码示例来源:origin: uwolfer/gerrit-intellij-plugin

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());
}

代码示例来源:origin: antlr/intellij-plugin-v4

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();
}

代码示例来源:origin: antlr/intellij-plugin-v4

Point mousePosition = editor.getContentComponent().getMousePosition();
if ( mousePosition!=null ) {
  LogicalPosition pos = editor.xyToLogicalPosition(mousePosition);

代码示例来源:origin: t28hub/json2java4idea

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();
}

相关文章