IDEA-220279: calculate a location of RA popup on expected monitor

GitOrigin-RevId: d531730c2793ddceebb11553c7d1eb29e563a69d
This commit is contained in:
Sergey Malenkov
2019-09-17 10:31:42 +00:00
committed by intellij-monorepo-bot
parent 02be21793d
commit d71ea6b5f7
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide.actions.runAnything;
import com.intellij.ide.IdeEventQueue;
@@ -9,8 +9,8 @@ import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.DimensionService;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.WindowStateService;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ui.JBInsets;
import org.jetbrains.annotations.NotNull;
@@ -67,7 +67,7 @@ public class RunAnythingManager {
.addUserData("SIMPLE_WINDOW")
.setResizable(true)
.setMovable(true)
.setDimensionServiceKey(project, LOCATION_SETTINGS_KEY, true)
.setDimensionServiceKey(myProject, LOCATION_SETTINGS_KEY, true)
.setLocateWithinScreenBounds(false)
.createPopup();
Disposer.register(myBalloon, myRunAnythingUI);
@@ -87,7 +87,7 @@ public class RunAnythingManager {
});
if (myRunAnythingUI.getViewType() == RunAnythingPopupUI.ViewType.SHORT) {
myBalloonFullSize = DimensionService.getInstance().getSize(LOCATION_SETTINGS_KEY, project);
myBalloonFullSize = WindowStateService.getInstance(myProject).getSize(LOCATION_SETTINGS_KEY);
Dimension prefSize = myRunAnythingUI.getPreferredSize();
myBalloon.setSize(prefSize);
}
@@ -117,7 +117,7 @@ public class RunAnythingManager {
}
private void calcPositionAndShow(Project project, JBPopup balloon) {
Point savedLocation = DimensionService.getInstance().getLocation(LOCATION_SETTINGS_KEY, project);
Point savedLocation = WindowStateService.getInstance(myProject).getLocation(LOCATION_SETTINGS_KEY);
if (project != null) {
balloon.showCenteredInCurrentWindow(project);
@@ -182,7 +182,7 @@ public class RunAnythingManager {
private void saveSize() {
if (myRunAnythingUI.getViewType() == RunAnythingPopupUI.ViewType.SHORT) {
DimensionService.getInstance().setSize(LOCATION_SETTINGS_KEY, myBalloonFullSize, myProject);
WindowStateService.getInstance(myProject).putSize(LOCATION_SETTINGS_KEY, myBalloonFullSize);
}
}
}