Example usage for com.intellij.openapi.ui.popup.util PopupUtil setPopupType

List of usage examples for com.intellij.openapi.ui.popup.util PopupUtil setPopupType

Introduction

In this page you can find the example usage for com.intellij.openapi.ui.popup.util PopupUtil setPopupType.

Prototype

public static void setPopupType(@NotNull final PopupFactory factory, final int type) 

Source Link

Usage

From source file:com.intellij.ide.ui.laf.LafManagerImpl.java

License:Apache License

/**
 * The following code is a trick! By default Swing uses lightweight and "medium" weight
 * popups to show JPopupMenu. The code below force the creation of real heavyweight menus -
 * this increases speed of popups and allows to get rid of some drawing artifacts.
 *///  w ww . ja  v a 2s  . c o m
private static void fixPopupWeight() {
    int popupWeight = OurPopupFactory.WEIGHT_MEDIUM;
    String property = System.getProperty("idea.popup.weight");
    if (property != null)
        property = property.toLowerCase().trim();
    if (SystemInfo.isMacOSLeopard) {
        // force heavy weight popups under Leopard, otherwise they don't have shadow or any kind of border.
        popupWeight = OurPopupFactory.WEIGHT_HEAVY;
    } else if (property == null) {
        // use defaults if popup weight isn't specified
        if (SystemInfo.isWindows) {
            popupWeight = OurPopupFactory.WEIGHT_HEAVY;
        }
    } else {
        if ("light".equals(property)) {
            popupWeight = OurPopupFactory.WEIGHT_LIGHT;
        } else if ("medium".equals(property)) {
            popupWeight = OurPopupFactory.WEIGHT_MEDIUM;
        } else if ("heavy".equals(property)) {
            popupWeight = OurPopupFactory.WEIGHT_HEAVY;
        } else {
            LOG.error("Illegal value of property \"idea.popup.weight\": " + property);
        }
    }

    PopupFactory factory = PopupFactory.getSharedInstance();
    if (!(factory instanceof OurPopupFactory)) {
        factory = new OurPopupFactory(factory);
        PopupFactory.setSharedInstance(factory);
    }
    PopupUtil.setPopupType(factory, popupWeight);
}