Search in sources :

Example 1 with MinimizeButton

use of com.intellij.openapi.ui.popup.util.MinimizeButton in project intellij-community by JetBrains.

the class ProcessPopup method show.

public void show(boolean requestFocus) {
    JComponent toFocus = myRootContent.getTargetComponent() == myActiveContentComponent ? myActiveFocusedContent : myInactiveContentComponent;
    final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(myRootContent, toFocus);
    builder.addListener(new JBPopupAdapter() {

        public void onClosed(LightweightWindowEvent event) {
            myProgressPanel.hideProcessPopup();
        }
    });
    builder.setMovable(true);
    builder.setResizable(true);
    builder.setTitle(IdeBundle.message("progress.window.title"));
    builder.setDimensionServiceKey(null, "ProcessPopupWindow", true);
    builder.setCancelOnClickOutside(false);
    builder.setRequestFocus(requestFocus);
    builder.setBelongsToGlobalPopupStack(false);
    builder.setLocateByContent(true);
    builder.setCancelButton(new MinimizeButton("Hide"));
    JFrame frame = (JFrame) UIUtil.findUltimateParent(myProgressPanel);
    updateContentUI();
    myActiveContentComponent.setBorder(null);
    if (frame != null) {
        Dimension contentSize = myRootContent.getPreferredSize();
        Rectangle bounds = frame.getBounds();
        int width = Math.max(bounds.width / 4, contentSize.width);
        int height = Math.min(bounds.height / 4, contentSize.height);
        int x = (int) (bounds.getMaxX() - width);
        int y = (int) (bounds.getMaxY() - height);
        myPopup = builder.createPopup();
        StatusBarEx sb = (StatusBarEx) ((IdeFrame) frame).getStatusBar();
        if (sb.isVisible()) {
            y -= sb.getSize().height;
        }
        myPopup.showInScreenCoordinates(myProgressPanel.getRootPane(), new Point(x - 5, y - 5));
    } else {
        myPopup = builder.createPopup();
        myPopup.showInCenterOf(myProgressPanel.getRootPane());
    }
}
Also used : MinimizeButton(com.intellij.openapi.ui.popup.util.MinimizeButton) StatusBarEx(com.intellij.openapi.wm.ex.StatusBarEx)

Aggregations

MinimizeButton (com.intellij.openapi.ui.popup.util.MinimizeButton)1 StatusBarEx (com.intellij.openapi.wm.ex.StatusBarEx)1