Skip to content

Commit a361164

Browse files
committed
Fix Spark dual consoles view focus switching issue
1 parent 1f3bf4a commit a361164

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/spark/ui/SparkJobLogConsoleView.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,44 @@ public JComponent getComponent() {
7676
add(mainPanel, BorderLayout.CENTER);
7777
}
7878

79+
getEditor().getContentComponent().setFocusCycleRoot(false);
80+
81+
if (secondaryConsoleView instanceof ConsoleViewImpl) {
82+
((ConsoleViewImpl) secondaryConsoleView).getEditor().getContentComponent().setFocusCycleRoot(false);
83+
}
84+
85+
this.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
86+
@Override
87+
public Component getComponentAfter(Container aContainer, Component aComponent) {
88+
if (aComponent == getEditor().getContentComponent()) {
89+
return secondaryConsoleView.getPreferredFocusableComponent();
90+
}
91+
92+
return null;
93+
}
94+
95+
@Override
96+
public Component getComponentBefore(Container aContainer, Component aComponent) {
97+
if (aComponent == secondaryConsoleView.getPreferredFocusableComponent()) {
98+
return getEditor().getContentComponent();
99+
}
100+
101+
return null;
102+
}
103+
104+
@Override
105+
public Component getFirstComponent(Container aContainer) {
106+
return getEditor().getContentComponent();
107+
}
108+
109+
@Override
110+
public Component getLastComponent(Container aContainer) {
111+
return secondaryConsoleView.getPreferredFocusableComponent();
112+
}
113+
});
114+
115+
this.setFocusCycleRoot(true);
116+
79117
return this;
80118
}
81119

0 commit comments

Comments
 (0)