void setLocation(@NotNull Point screenPoint);
void setSize(@NotNull Dimension size);
+ Dimension getSize();
boolean isPersistent();
void setMinimumSize(Dimension size);
void setFinalRunnable(@Nullable Runnable runnable);
+
+ void moveToFitScreen();
}
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.wm.IdeFocusManager;
+import com.intellij.openapi.wm.WindowManager;
+import com.intellij.openapi.wm.ex.WindowManagerEx;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.awt.RelativeRectangle;
import com.intellij.ui.switcher.SwitchTarget;
myVisibleActions = myNewVisibleActions;
myNewVisibleActions = temp;
+ Dimension oldSize = getPreferredSize();
+
removeAll();
mySecondaryActions.removeAll();
mySecondaryActionsButton = null;
fillToolBar(myVisibleActions, getLayoutPolicy() == AUTO_LAYOUT_POLICY && myOrientation == SwingConstants.HORIZONTAL);
+ Dimension newSize = getPreferredSize();
+
if (changeBarVisibility) {
revalidate();
}
parent.validate();
}
}
+
+ ((WindowManagerEx)WindowManager.getInstance()).adjustContainerWindow(ActionToolbarImpl.this, oldSize, newSize);
+
repaint();
}
}
*/
package com.intellij.openapi.wm.ex;
+import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.IdeFrame;
*/
public abstract void hideDialog(JDialog dialog, Project project);
+ public abstract void adjustContainerWindow(Component c, Dimension oldSize, Dimension newSize);
+
+
}
dialog.dispose();
}
+ @Override
+ public void adjustContainerWindow(Component c, Dimension oldSize, Dimension newSize) {
+ }
+
public final String getComponentName() {
return "TestWindowManager";
}
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
+import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.NamedJDOMExternalizable;
import com.intellij.openapi.util.SystemInfo;
}
}
+ @Override
+ public void adjustContainerWindow(Component c, Dimension oldSize, Dimension newSize) {
+ if (c == null) return;
+
+ Window wnd = SwingUtilities.getWindowAncestor(c);
+
+ if (wnd instanceof JWindow) {
+ JBPopup popup = (JBPopup)((JWindow)wnd).getRootPane().getClientProperty(JBPopup.KEY);
+ if (popup != null) {
+ if (oldSize.height < newSize.height) {
+ Dimension size = popup.getSize();
+ size.height += (newSize.height - oldSize.height);
+ popup.setSize(size);
+ popup.moveToFitScreen();
+ }
+ }
+ }
+ }
+
public final void disposeComponent() {}
public final void initComponent() {
}
}
+ @Override
+ public Dimension getSize() {
+ if (myPopup != null) {
+ final Window popupWindow = SwingUtilities.windowForComponent(myContent);
+ return popupWindow.getSize();
+ } else {
+ return myForcedSize;
+ }
+ }
+
+ @Override
+ public void moveToFitScreen() {
+ if (myPopup == null) return;
+
+ final Window popupWindow = SwingUtilities.windowForComponent(myContent);
+ Rectangle bounds = popupWindow.getBounds();
+
+ ScreenUtil.moveRectangleToFitTheScreen(bounds);
+ setLocation(bounds.getLocation());
+ setSize(bounds.getSize());
+ }
+
+
public static Window setSize(JComponent content, final Dimension size) {
final Window popupWindow = SwingUtilities.windowForComponent(content);
final Point location = popupWindow.getLocation();