use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class NavBarUpdateQueue method processUserActivity.
private void processUserActivity() {
if (myPanel == null || !myPanel.isShowing()) {
return;
}
final Project project = myPanel.getProject();
IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(() -> {
Window wnd = SwingUtilities.windowForComponent(myPanel);
if (wnd == null)
return;
Component focus = null;
if (!wnd.isActive()) {
IdeFrame frame = UIUtil.getParentOfType(IdeFrame.class, myPanel);
if (frame != null) {
focus = IdeFocusManager.getInstance(project).getLastFocusedFor(frame);
}
} else {
final Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
if (window instanceof Dialog) {
final Dialog dialog = (Dialog) window;
if (dialog.isModal() && !SwingUtilities.isDescendingFrom(myPanel, dialog)) {
return;
}
}
}
if (focus != null && focus.isShowing()) {
if (!myPanel.hasFocus() && !myPanel.isNodePopupShowing()) {
requestModelUpdate(DataManager.getInstance().getDataContext(focus), null, false);
}
} else if (wnd.isActive()) {
requestModelUpdate(null, myPanel.getContextObject(), false);
}
});
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class PlaybackDebugger method startWhenFrameActive.
private void startWhenFrameActive() {
myLog.setText(null);
addInfo("Waiting for IDE frame activation", -1, MESSAGE_COLOR, 0);
myRunner = new PlaybackRunner(myCodeEditor.getText(), this, false, true, false);
VirtualFile file = pathToFile();
if (file != null) {
VirtualFile scriptDir = file.getParent();
if (scriptDir != null) {
myRunner.setScriptDir(new File(scriptDir.getPresentableUrl()));
}
}
new Thread("playback debugger") {
@Override
public void run() {
new WaitFor(60000) {
@Override
protected boolean condition() {
return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow() instanceof IdeFrame || myRunner == null;
}
};
if (myRunner == null) {
message(null, "Script stopped", -1, Type.message, true);
return;
}
message(null, "Starting script...", -1, Type.message, true);
TimeoutUtil.sleep(1000);
if (myRunner == null) {
message(null, "Script stopped", -1, Type.message, true);
return;
}
final PlaybackRunner runner = myRunner;
myRunner.run().doWhenProcessed(() -> {
if (runner == myRunner) {
SwingUtilities.invokeLater(() -> myRunner = null);
}
});
}
}.start();
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class DimensionService method keyPair.
/**
* @return Pair(key, scale) where:
* key is the HiDPI-aware key,
* scale is the HiDPI-aware factor to transform size metrics.
*/
@NotNull
private static Pair<String, Float> keyPair(String key, @Nullable Project project) {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (env.isHeadlessInstance()) {
return new Pair<>(key + ".headless", 1f);
}
JFrame frame = null;
final Component owner = IdeFocusManager.findInstance().getFocusOwner();
if (owner != null) {
frame = UIUtil.getParentOfType(JFrame.class, owner);
}
if (frame == null) {
frame = WindowManager.getInstance().findVisibleFrame();
}
if (project != null && (frame == null || (frame instanceof IdeFrame && project != ((IdeFrame) frame).getProject()))) {
frame = WindowManager.getInstance().getFrame(project);
}
Rectangle screen = new Rectangle(0, 0, 0, 0);
GraphicsDevice gd = null;
if (frame != null) {
final Point topLeft = frame.getLocation();
Point2D center = new Point2D.Float(topLeft.x + frame.getWidth() / 2, topLeft.y + frame.getHeight() / 2);
for (GraphicsDevice device : env.getScreenDevices()) {
Rectangle bounds = device.getDefaultConfiguration().getBounds();
if (bounds.contains(center)) {
screen = bounds;
gd = device;
break;
}
}
}
if (gd == null) {
gd = env.getDefaultScreenDevice();
screen = gd.getDefaultConfiguration().getBounds();
}
float scale = 1f;
if (UIUtil.isJreHiDPIEnabled()) {
scale = JBUI.sysScale(gd.getDefaultConfiguration());
// normalize screen bounds
screen.setBounds((int) Math.floor(screen.x * scale), (int) Math.floor(screen.y * scale), (int) Math.ceil(screen.width * scale), (int) Math.ceil(screen.height * scale));
}
String realKey = key + '.' + screen.x + '.' + screen.y + '.' + screen.width + '.' + screen.height;
if (JBUI.isPixHiDPI(gd.getDefaultConfiguration())) {
int dpi = ((int) (96 * JBUI.pixScale(gd.getDefaultConfiguration())));
realKey += "@" + dpi + "dpi";
}
return new Pair<>(realKey, scale);
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class ActionMenu method showDescriptionInStatusBar.
public static void showDescriptionInStatusBar(boolean isIncluded, Component component, String description) {
IdeFrame frame = (IdeFrame) (component instanceof IdeFrame ? component : SwingUtilities.getAncestorOfClass(IdeFrame.class, component));
StatusBar statusBar;
if (frame != null && (statusBar = frame.getStatusBar()) != null) {
statusBar.setInfo(isIncluded ? description : null);
}
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class ActionMenu method fillMenu.
private void fillMenu() {
DataContext context;
boolean mayContextBeInvalid;
if (myContext != null) {
context = myContext;
mayContextBeInvalid = false;
} else {
@SuppressWarnings("deprecation") DataContext contextFromFocus = DataManager.getInstance().getDataContext();
context = contextFromFocus;
if (PlatformDataKeys.CONTEXT_COMPONENT.getData(context) == null) {
IdeFrame frame = UIUtil.getParentOfType(IdeFrame.class, this);
context = DataManager.getInstance().getDataContext(IdeFocusManager.getGlobalInstance().getLastFocusedFor(frame));
}
mayContextBeInvalid = true;
}
Utils.fillMenu(myGroup.getAction(), this, myMnemonicEnabled, myPresentationFactory, context, myPlace, true, mayContextBeInvalid, LaterInvocator.isInModalContext());
}
Aggregations