void () { LOG.assertTrue(myInplaceEditorComponent == null, "editor is not released"); beforeShow(); final JComponent hostComponent = getHostComponent(); final JRootPane rootPane = getHostComponent().getRootPane(); if (rootPane == null) { return; } final JLayeredPane layeredPane = rootPane.getLayeredPane(); Rectangle bounds = getEditorBounds(); if (bounds == null) { return; } Point layeredPanePoint = SwingUtilities.convertPoint(hostComponent, bounds.x, bounds.y,layeredPane); final JComponent inplaceEditorComponent = createInplaceEditorComponent(); myInplaceEditorComponent = inplaceEditorComponent; LOG.assertTrue(inplaceEditorComponent != null); setInplaceEditorBounds(inplaceEditorComponent, layeredPanePoint.x, layeredPanePoint.y, bounds.width, bounds.height); layeredPane.add(inplaceEditorComponent, Integer.valueOf(250)); ClientProperty.put(inplaceEditorComponent, ToolWindowManagerImpl.PARENT_COMPONENT, hostComponent); myRemoveActions.add(() -> { layeredPane.remove(inplaceEditorComponent); ClientProperty.put(inplaceEditorComponent, ToolWindowManagerImpl.PARENT_COMPONENT, null); }); inplaceEditorComponent.validate(); inplaceEditorComponent.paintImmediately(0,0,inplaceEditorComponent.getWidth(),inplaceEditorComponent.getHeight()); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown( () -> IdeFocusManager.getGlobalInstance().requestFocus(getPreferredFocusedComponent(), true)); final ComponentAdapter componentListener = new ComponentAdapter() { @Override public void componentMoved(ComponentEvent e) { resetBounds(); } @Override public void componentResized(ComponentEvent e) { resetBounds(); } private void resetBounds() { final Project project = getProject(); ApplicationManager.getApplication().invokeLater(() -> { if (!isShown() || project == null || project.isDisposed()) { return; } JComponent hostComponent = getHostComponent(); JLayeredPane layeredPane1 = hostComponent.getRootPane().getLayeredPane(); Rectangle bounds1 = getEditorBounds(); if (bounds1 == null) { doOKAction(); return; } Point layeredPanePoint1 = SwingUtilities.convertPoint(hostComponent, bounds1.x, bounds1.y, layeredPane1); setInplaceEditorBounds(inplaceEditorComponent, layeredPanePoint1.x, layeredPanePoint1.y, bounds1.width, bounds1.height); inplaceEditorComponent.revalidate(); }); } @Override public void componentHidden(ComponentEvent e) { cancelEditing(); } }; final HierarchyListener hierarchyListener = e -> { if (!hostComponent.isShowing()) { cancelEditing(); } }; hostComponent.addHierarchyListener(hierarchyListener); hostComponent.addComponentListener(componentListener); rootPane.addComponentListener(componentListener); myRemoveActions.add(() -> { hostComponent.removeHierarchyListener(hierarchyListener); hostComponent.removeComponentListener(componentListener); rootPane.removeComponentListener(componentListener); }); getProject().getMessageBus().connect(myDisposable).subscribe(RunContentManager.TOPIC, new RunContentWithExecutorListener() { @Override public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) { cancelEditing(); } @Override public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) { cancelEditing(); } }); final JComponent editorComponent = getEditorComponent(); editorComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enterStroke"); editorComponent.getActionMap().put("enterStroke", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { doOKAction(); } }); editorComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escapeStroke"); editorComponent.getActionMap().put("escapeStroke", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cancelEditing(); } }); final Toolkit defaultToolkit = Toolkit.getDefaultToolkit(); SwingUtilities.invokeLater(() -> { if (!isShown()) return; defaultToolkit.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK); }); myRemoveActions.add(() -> defaultToolkit.removeAWTEventListener(this)); onShown(); }