List of usage examples for com.intellij.openapi.wm IdeFocusManager getInstance
public static IdeFocusManager getInstance(@Nullable Project project)
From source file:com.android.tools.idea.configurations.ThemeSelectionPanel.java
License:Apache License
public void focus() { final Project project = myConfiguration.getModule().getProject(); final IdeFocusManager focusManager = project.isDefault() ? IdeFocusManager.getGlobalInstance() : IdeFocusManager.getInstance(project); focusManager.doWhenFocusSettlesDown(new Runnable() { @Override// w ww.j av a2 s. c om public void run() { focusManager.requestFocus(myThemeList, true); } }); }
From source file:com.android.tools.idea.editors.vmtrace.TraceViewPanel.java
License:Apache License
public void showSearchComponent() { CardLayout layout = (CardLayout) myHeaderPanel.getLayout(); layout.show(myHeaderPanel, CARD_FIND); IdeFocusManager.getInstance(myProject).requestFocus(mySearchField, true); }
From source file:com.android.tools.idea.editors.vmtrace.TraceViewPanel.java
License:Apache License
private void closeSearchComponent() { CardLayout layout = (CardLayout) myHeaderPanel.getLayout(); layout.show(myHeaderPanel, CARD_DEFAULT); IdeFocusManager.getInstance(myProject).requestFocus(myTraceViewCanvas, true); }
From source file:com.ansorgit.plugins.bash.runner.repl.AbstractConsoleRunnerWithHistory.java
License:Apache License
/** * Launch process, setup history, actions etc. * * @throws ExecutionException//from www . ja v a 2s . co m */ public void initAndRun() throws ExecutionException { // Create Server process final Process process = createProcess(); // Init console view myConsoleView = createConsoleView(); myProcessHandler = createProcessHandler(process); ProcessTerminatedListener.attach(myProcessHandler); myProcessHandler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(ProcessEvent event) { myRunAction.getTemplatePresentation().setEnabled(false); myConsoleView.getConsole().setPrompt(""); myConsoleView.getConsole().getConsoleEditor().setRendererMode(true); ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { myConsoleView.getConsole().getConsoleEditor().getComponent().updateUI(); } }); } }); // Attach to process myConsoleView.attachToProcess(myProcessHandler); // Runner creating final Executor defaultExecutor = ExecutorRegistry.getInstance() .getExecutorById(DefaultRunExecutor.EXECUTOR_ID); final DefaultActionGroup toolbarActions = new DefaultActionGroup(); final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false); // Runner creating final JPanel panel = new JPanel(new BorderLayout()); panel.add(actionToolbar.getComponent(), BorderLayout.WEST); panel.add(myConsoleView.getComponent(), BorderLayout.CENTER); final RunContentDescriptor myDescriptor = new RunContentDescriptor(myConsoleView, myProcessHandler, panel, myConsoleTitle); // tool bar actions final AnAction[] actions = fillToolBarActions(toolbarActions, defaultExecutor, myDescriptor); registerActionShortcuts(actions, getLanguageConsole().getConsoleEditor().getComponent()); registerActionShortcuts(actions, panel); panel.updateUI(); // Show in run toolwindow ExecutionManager.getInstance(myProject).getContentManager().showRunContent(defaultExecutor, myDescriptor); // Request focus final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(defaultExecutor.getId()); window.activate(new Runnable() { public void run() { IdeFocusManager.getInstance(myProject) .requestFocus(getLanguageConsole().getCurrentEditor().getContentComponent(), true); } }); // Run myProcessHandler.startNotify(); }
From source file:com.antoine.ideaplugin.greenrobot.ShowUsagesAction.java
License:Apache License
private void navigateAndHint(@NotNull Usage usage, @Nullable final String hint, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final int maxUsages, @NotNull final FindUsagesOptions options) { usage.navigate(true);//from w w w . ja v a2 s . c o m if (hint == null) return; final Editor newEditor = getEditorFor(usage); if (newEditor == null) return; final Project project = handler.getProject(); //opening editor is performing in invokeLater IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() { @Override public void run() { newEditor.getScrollingModel().runActionOnScrollingFinished(new Runnable() { @Override public void run() { // after new editor created, some editor resizing events are still bubbling. To prevent hiding hint, invokeLater this IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() { @Override public void run() { if (newEditor.getComponent().isShowing()) { showHint(hint, newEditor, popupPosition, handler, maxUsages, options); } } }); } }); } }); }
From source file:com.intellij.codeInsight.documentation.DocumentationManager.java
License:Apache License
@Override protected void restorePopupBehavior() { if (myPreviouslyFocused != null) { IdeFocusManager.getInstance(myProject).requestFocus(myPreviouslyFocused, true); }// w w w. j a v a 2 s. c o m super.restorePopupBehavior(); updateComponent(); }
From source file:com.intellij.codeInsight.documentation.DocumentationManager.java
License:Apache License
private void closeDocHint() { JBPopup hint = getDocInfoHint();// www.ja v a2s .c om if (hint == null) { return; } myCloseOnSneeze = false; hint.cancel(); Component toFocus = myPreviouslyFocused; hint.cancel(); if (toFocus != null) { IdeFocusManager.getInstance(myProject).requestFocus(toFocus, true); } }
From source file:com.intellij.codeInsight.documentation.DocumentationManager.java
License:Apache License
private void doShowJavaDocInfo(@NotNull final PsiElement element, boolean requestFocus, PopupUpdateProcessor updateProcessor, final PsiElement originalElement, @Nullable final Runnable closeCallback) { Project project = getProject(element); if (!project.isOpen()) return;/* ww w . j a v a 2 s . c o m*/ storeOriginalElement(project, originalElement, element); myPreviouslyFocused = WindowManagerEx.getInstanceEx().getFocusedComponent(project); JBPopup _oldHint = getDocInfoHint(); if (myToolWindow == null && PropertiesComponent.getInstance().isTrueValue(SHOW_DOCUMENTATION_IN_TOOL_WINDOW)) { createToolWindow(element, originalElement); } else if (myToolWindow != null) { Content content = myToolWindow.getContentManager().getSelectedContent(); if (content != null) { DocumentationComponent component = (DocumentationComponent) content.getComponent(); if (element.getManager().areElementsEquivalent(component.getElement(), element)) { JComponent preferredFocusableComponent = content.getPreferredFocusableComponent(); // focus toolwindow on the second actionPerformed boolean focus = requestFocus || CommandProcessor.getInstance().getCurrentCommand() != null; if (preferredFocusableComponent != null && focus) { IdeFocusManager.getInstance(myProject).requestFocus(preferredFocusableComponent, true); } } else { content.setDisplayName(getTitle(element, true)); fetchDocInfo(getDefaultCollector(element, originalElement), component, true); } } if (!myToolWindow.isVisible()) { myToolWindow.show(null); } } else if (_oldHint != null && _oldHint.isVisible() && _oldHint instanceof AbstractPopup) { DocumentationComponent oldComponent = (DocumentationComponent) ((AbstractPopup) _oldHint) .getComponent(); fetchDocInfo(getDefaultCollector(element, originalElement), oldComponent); } else { showInPopup(element, requestFocus, updateProcessor, originalElement, closeCallback); } }
From source file:com.intellij.codeInsight.documentation.DocumentationManager.java
License:Apache License
void showHint(final JBPopup hint) { final Component focusOwner = IdeFocusManager.getInstance(myProject).getFocusOwner(); DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner); PopupPositionManager.positionPopupInBestPosition(hint, myEditor, dataContext); }
From source file:com.intellij.codeInsight.lookup.impl.LookupUi.java
License:Apache License
private void fixMouseCheaters() { myLookup.getComponent().addFocusListener(new FocusAdapter() { @Override/*from w ww . java 2 s . c om*/ public void focusGained(FocusEvent e) { final ActionCallback done = IdeFocusManager.getInstance(myProject) .requestFocus(myLookup.getEditor().getContentComponent(), true); IdeFocusManager.getInstance(myProject).typeAheadUntil(done); new Alarm(myLookup).addRequest(new Runnable() { @Override public void run() { if (!done.isDone()) { done.setDone(); } } }, 300, myModalityState); } }); }