当前位置: 首页>>代码示例>>Java>>正文


Java IdeFocusManager.findInstanceByComponent方法代码示例

本文整理汇总了Java中com.intellij.openapi.wm.IdeFocusManager.findInstanceByComponent方法的典型用法代码示例。如果您正苦于以下问题:Java IdeFocusManager.findInstanceByComponent方法的具体用法?Java IdeFocusManager.findInstanceByComponent怎么用?Java IdeFocusManager.findInstanceByComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.wm.IdeFocusManager的用法示例。


在下文中一共展示了IdeFocusManager.findInstanceByComponent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: typeAheadDispatchToFocusManager

import com.intellij.openapi.wm.IdeFocusManager; //导入方法依赖的package包/类
private static boolean typeAheadDispatchToFocusManager(AWTEvent e) {
  if (e instanceof KeyEvent) {
    final KeyEvent event = (KeyEvent)e;
    if (!event.isConsumed()) {
      final IdeFocusManager focusManager = IdeFocusManager.findInstanceByComponent(event.getComponent());
      return focusManager.dispatch(event);
    }
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:IdeEventQueue.java

示例2: editCellAt

import com.intellij.openapi.wm.IdeFocusManager; //导入方法依赖的package包/类
@Override
public boolean editCellAt(final int row, final int column, final EventObject e) {
  if (cellEditor != null && !cellEditor.stopCellEditing()) {
    return false;
  }

  if (row < 0 || row >= getRowCount() || column < 0 || column >= getColumnCount()) {
    return false;
  }

  if (!isCellEditable(row, column)) {
    return false;
  }

  if (e instanceof KeyEvent) {
    // do not start editing in autoStartsEdit mode on Ctrl-Z and other non-typed events
    if (!UIUtil.isReallyTypedEvent((KeyEvent)e) || ((KeyEvent)e).getKeyChar() == KeyEvent.CHAR_UNDEFINED) return false;

    SpeedSearchSupply supply = SpeedSearchSupply.getSupply(this);
    if (supply != null && supply.isPopupActive()) {
      return false;
    }
  }

  final TableCellEditor editor = getCellEditor(row, column);
  if (editor != null && editor.isCellEditable(e)) {
    editorComp = prepareEditor(editor, row, column);
    //((JComponent)editorComp).setBorder(null);
    if (editorComp == null) {
      removeEditor();
      return false;
    }
    editorComp.setBounds(getCellRect(row, column, false));
    add(editorComp);
    editorComp.validate();

    if (surrendersFocusOnKeyStroke()) {
      // this replaces focus request in JTable.processKeyBinding
      final IdeFocusManager focusManager = IdeFocusManager.findInstanceByComponent(this);
      focusManager.setTypeaheadEnabled(false);
      focusManager.requestFocus(editorComp, true).doWhenProcessed(new Runnable() {
        @Override
        public void run() {
          focusManager.setTypeaheadEnabled(true);
        }
      });
    }

    setCellEditor(editor);
    setEditingRow(row);
    setEditingColumn(column);
    editor.addCellEditorListener(this);

    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:58,代码来源:JBTable.java

示例3: getFocusedComponent

import com.intellij.openapi.wm.IdeFocusManager; //导入方法依赖的package包/类
@Nullable
private Component getFocusedComponent() {
  if (myWindowManager == null) {
    return null;
  }
  Window activeWindow = myWindowManager.getMostRecentFocusedWindow();
  if (activeWindow == null) {
    activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
    if (activeWindow == null) {
      activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
      if (activeWindow == null) return null;
    }
  }

  if (Registry.is("actionSystem.noContextComponentWhileFocusTransfer")) {
    IdeFocusManager fm = IdeFocusManager.findInstanceByComponent(activeWindow);
    if (fm.isFocusBeingTransferred()) {
      return null;
    }
  }

  // In case we have an active floating toolwindow and some component in another window focused,
  // we want this other component to receive key events.
  // Walking up the window ownership hierarchy from the floating toolwindow would have led us to the main IdeFrame
  // whereas we want to be able to type in other frames as well.
  if (activeWindow instanceof FloatingDecorator) {
    IdeFocusManager ideFocusManager = IdeFocusManager.findInstanceByComponent(activeWindow);
    IdeFrame lastFocusedFrame = ideFocusManager.getLastFocusedFrame();
    JComponent frameComponent = lastFocusedFrame != null ? lastFocusedFrame.getComponent() : null;
    Window lastFocusedWindow = frameComponent != null ? SwingUtilities.getWindowAncestor(frameComponent) : null;
    boolean toolWindowIsNotFocused = myWindowManager.getFocusedComponent(activeWindow) == null;
    if (toolWindowIsNotFocused && lastFocusedWindow != null) {
      activeWindow = lastFocusedWindow;
    }
  }

  // try to find first parent window that has focus
  Window window = activeWindow;
  Component focusedComponent = null;
  while (window != null) {
    focusedComponent = myWindowManager.getFocusedComponent(window);
    if (focusedComponent != null) {
      break;
    }
    window = window.getOwner();
  }
  if (focusedComponent == null) {
    focusedComponent = activeWindow;
  }

  return focusedComponent;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:53,代码来源:DataManagerImpl.java


注:本文中的com.intellij.openapi.wm.IdeFocusManager.findInstanceByComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。