From c689a0c511df1979dc6f1bd5aaf252fea690ceb4 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Thu, 27 Nov 2014 16:43:10 +0300 Subject: [PATCH] Wrong foreground when already unfocused fixed --- .../src/com/intellij/dvcs/push/ui/PushLog.java | 11 +++++++++++ .../dvcs/push/ui/RepositoryWithBranchPanel.java | 10 ++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java index 6e1abc94bd35..2195c5f70e17 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java @@ -159,6 +159,17 @@ public class PushLog extends JPanel implements TypeSafeDataProvider { updateChangesView(); } }); + myTree.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode)myTree.getLastSelectedPathComponent(); + if (node != null && node instanceof RepositoryNode && myTree.isEditing()) { + //need to force repaint foreground for non-focused editing node + myTree.getCellEditor().getTreeCellEditorComponent(myTree, node, true, false, false, myTree.getRowForPath( + TreeUtil.getPathFromRoot(node))); + } + } + }); myTree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), START_EDITING); //override default tree behaviour. myTree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), ""); diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java index ad3de5e48609..c943ab0b32ff 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java @@ -161,7 +161,10 @@ public class RepositoryWithBranchPanel extends NonOpaquePa if (bounds != null) { setPreferredSize(new Dimension(tree.getVisibleRect().width - bounds.x, bounds.height)); } - myDestPushTargetPanelComponent.requestFocus(); + if (myTextRenderer.getTree().hasFocus()) { + //delegate focus from tree to editable component if needed + myDestPushTargetPanelComponent.requestFocus(true); + } revalidate(); return this; } @@ -218,11 +221,6 @@ public class RepositoryWithBranchPanel extends NonOpaquePa return myCheckBoxLoadingIconGapV; } - public int getVBorderOffset(@NotNull SimpleColoredComponent coloredRenderer) { - Border border = coloredRenderer.getMyBorder(); - return border != null ? border.getBorderInsets(coloredRenderer).top : 0; - } - public int getCheckBoxHeight() { return myCheckBoxHeight; }