本文整理汇总了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;
}
示例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;
}
示例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;
}