navbar location, focus and plainting fixes

This commit is contained in:
Kirill Kalishev
2010-11-08 19:20:48 +03:00
parent e1aa676431
commit 8c868505a3
3 changed files with 41 additions and 8 deletions
@@ -103,7 +103,7 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup
private LightweightHint myHint = null;
private ListPopupImpl myNodePopup = null;
private Container myHintContainer;
private JComponent myHintContainer;
private Component myContextComponent;
private Runnable myRunWhenListRebuilt;
@@ -1041,7 +1041,8 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup
final AsyncResult<RelativePoint> result = new AsyncResult<RelativePoint>();
if (myHintContainer != null) {
final Point p = AbstractPopup.getCenterOf(myHintContainer, this);
p.y -= myHintContainer.getHeight() / 4;
p.y -= myHintContainer.getVisibleRect().height / 4;
result.setDone(RelativePoint.fromScreen(p));
}
else {
@@ -1114,8 +1115,8 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup
boolean selected = myModel.getSelectedIndex() == myIndex;
setPaintFocusBorder(selected);
setFocusBorderAroundIcon(true);
setPaintFocusBorder(!focused && selected);
setFocusBorderAroundIcon(false);
setBackground(selected && focused
? UIUtil.getListSelectionBackground()
@@ -39,6 +39,7 @@ import com.intellij.util.Alarm;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -48,6 +49,7 @@ import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
@@ -569,6 +571,26 @@ public class IdeEventQueue extends EventQueue {
if (!mouseEventsAhead) {
Window showingWindow = mgr.getActiveWindow();
if (showingWindow == null) {
Method getNativeFocusOwner = ReflectionUtil.getDeclaredMethod(KeyboardFocusManager.class, "getNativeFocusOwner");
if (getNativeFocusOwner != null) {
getNativeFocusOwner.setAccessible(true);
try {
Object owner = getNativeFocusOwner.invoke(mgr);
if (owner instanceof Component) {
Component nativeFocusOwner = (Component)owner;
if (nativeFocusOwner instanceof Window) {
showingWindow = (Window)nativeFocusOwner;
} else {
showingWindow = SwingUtilities.getWindowAncestor(nativeFocusOwner);
}
}
}
catch (Exception e1) {
LOG.debug(e1);
}
}
}
if (showingWindow != null) {
final IdeFocusManager fm = IdeFocusManager.findInstanceByComponent(showingWindow);
Runnable requestDefaultFocus = new Runnable() {
@@ -496,19 +496,29 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
private void activateEditorComponent(final boolean forced) {
activateEditorComponent(forced, false);
}
private void activateEditorComponent(final boolean forced, boolean now) {
if (LOG.isDebugEnabled()) {
LOG.debug("enter: activateEditorComponent()");
}
ApplicationManager.getApplication().assertIsDispatchThread();
getFocusManager().doWhenFocusSettlesDown(new Runnable() {
Runnable runnable = new Runnable() {
@Override
public void run() {
final ArrayList<FinalizableCommand> commandList = new ArrayList<FinalizableCommand>();
activateEditorComponentImpl(getSplittersFromFocus(), commandList, forced);
execute(commandList);
}
});
};
if (now) {
runnable.run();
} else {
getFocusManager().doWhenFocusSettlesDown(runnable);
}
}
private EditorsSplitters getSplittersFromFocus() {
@@ -2035,10 +2045,10 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
if (ModalityState.NON_MODAL.equals(ModalityState.current())) {
final String activeId = getActiveToolWindowId();
if (myEditorComponentActive || activeId == null || getToolWindow(activeId) == null) {
activateEditorComponent(forced);
activateEditorComponent(forced, true);
}
else {
activateToolWindow(activeId, forced, false);
activateToolWindow(activeId, forced, true);
}
}
return new ActionCallback.Done();