mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
"if else -> switch" refactoring
This commit is contained in:
@@ -51,6 +51,12 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.openapi.wm.IdeFocusManager.getGlobalInstance;
|
||||
import static java.awt.AWTEvent.MOUSE_EVENT_MASK;
|
||||
import static java.awt.AWTEvent.MOUSE_MOTION_EVENT_MASK;
|
||||
import static java.awt.event.MouseEvent.MOUSE_ENTERED;
|
||||
import static java.awt.event.MouseEvent.MOUSE_MOVED;
|
||||
import static java.awt.event.WindowEvent.WINDOW_ACTIVATED;
|
||||
import static java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS;
|
||||
|
||||
public class AbstractPopup implements JBPopup {
|
||||
public static final String SHOW_HINTS = "ShowHints";
|
||||
@@ -1111,8 +1117,8 @@ public class AbstractPopup implements JBPopup {
|
||||
|
||||
if (myCancelOnMouseOutCallback != null || myCancelOnWindow) {
|
||||
myMouseOutCanceller = new Canceller();
|
||||
Toolkit.getDefaultToolkit().addAWTEventListener(myMouseOutCanceller, AWTEvent.MOUSE_EVENT_MASK | WindowEvent.WINDOW_ACTIVATED |
|
||||
AWTEvent.MOUSE_MOTION_EVENT_MASK);
|
||||
Toolkit.getDefaultToolkit().addAWTEventListener(myMouseOutCanceller,
|
||||
MOUSE_EVENT_MASK | WINDOW_ACTIVATED | WINDOW_GAINED_FOCUS | MOUSE_MOTION_EVENT_MASK);
|
||||
}
|
||||
|
||||
|
||||
@@ -1506,22 +1512,25 @@ public class AbstractPopup implements JBPopup {
|
||||
|
||||
@Override
|
||||
public void eventDispatched(final AWTEvent event) {
|
||||
if (event.getID() == WindowEvent.WINDOW_ACTIVATED) {
|
||||
if (myCancelOnWindow && myPopup != null && !myPopup.isPopupWindow(((WindowEvent)event).getWindow())) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
else if (event.getID() == MouseEvent.MOUSE_ENTERED) {
|
||||
if (withinPopup(event)) {
|
||||
myEverEntered = true;
|
||||
}
|
||||
}
|
||||
else if (event.getID() == MouseEvent.MOUSE_MOVED) {
|
||||
if (myCancelOnMouseOutCallback != null && myEverEntered && !withinPopup(event)) {
|
||||
if (myCancelOnMouseOutCallback.check((MouseEvent)event)) {
|
||||
switch (event.getID()) {
|
||||
case WINDOW_ACTIVATED:
|
||||
case WINDOW_GAINED_FOCUS:
|
||||
if (myCancelOnWindow && myPopup != null && !myPopup.isPopupWindow(((WindowEvent)event).getWindow())) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MOUSE_ENTERED:
|
||||
if (withinPopup(event)) {
|
||||
myEverEntered = true;
|
||||
}
|
||||
break;
|
||||
case MOUSE_MOVED:
|
||||
if (myCancelOnMouseOutCallback != null && myEverEntered && !withinPopup(event)) {
|
||||
if (myCancelOnMouseOutCallback.check((MouseEvent)event)) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user