From: Alexey Pegov Date: Tue, 10 Aug 2010 09:05:11 +0000 (+0400) Subject: fix popups one again X-Git-Tag: idea/96.907~20 X-Git-Url: https://git.jetbrains.org/?p=idea%2Fcommunity.git;a=commitdiff_plain;h=b629b049b66b10a05a29e147f88079ce762004fe fix popups one again --- diff --git a/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java index d8edaf74154d..2e1c6f6d74c5 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java @@ -298,6 +298,8 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo }else{ // UNIXes (Linux and MAC) go here popupWeight=MEDIUM_WEIGHT_POPUP; } + } else if (HEAVY_WEIGHT_POPUP.equals(popupWeight) && !MEDIUM_WEIGHT_POPUP.equals(popupWeight)) { + throw new IllegalStateException("unknown value of property -Didea.popup.weight: " + popupWeight); } if (SystemInfo.isMacOSLeopard) { @@ -306,46 +308,34 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo } popupWeight = popupWeight.trim(); + final boolean heavyWeighPopup = HEAVY_WEIGHT_POPUP.equals(popupWeight); PopupFactory popupFactory; final PopupFactory oldFactory = PopupFactory.getSharedInstance(); if (!(oldFactory instanceof OurPopupFactory)) { - if (HEAVY_WEIGHT_POPUP.equals(popupWeight)) { - popupFactory = new OurPopupFactory() { - public Popup getPopup( - Component owner, - Component contents, - int x, - int y - ) throws IllegalArgumentException { - final Point point = fixPopupLocation(contents, x, y); - if (SystemInfo.isLinux) { - return new Popup(owner, contents, point.x, point.y){}; - } - return oldFactory.getPopup(owner, contents, point.x, point.y); - } - }; - } - else if (MEDIUM_WEIGHT_POPUP.equals(popupWeight)) { - popupFactory = new OurPopupFactory() { + popupFactory = new OurPopupFactory() { + public Popup getPopup( + Component owner, + Component contents, + int x, + int y + ) throws IllegalArgumentException { + final Point point = fixPopupLocation(contents, x, y); + try { + final Method method = PopupFactory.class.getDeclaredMethod("setPopupType", int.class); + method.setAccessible(true); + method.invoke(oldFactory, heavyWeighPopup ? 2 : 1); - public Popup getPopup(final Component owner, final Component contents, final int x, final int y) throws IllegalArgumentException { - return createPopup(owner, contents, x, y); } - - private Popup createPopup(final Component owner, final Component contents, final int x, final int y) { - final Point point = fixPopupLocation(contents, x, y); - if (SystemInfo.isLinux) { - return new Popup(owner, contents, point.x, point.y){}; - } - return oldFactory.getPopup(owner, contents, point.x, point.y); + catch (Throwable e) { + LOG.error(e); } - }; - } - else { - throw new IllegalStateException("unknown value of property -Didea.popup.weight: " + popupWeight); - } + + return oldFactory.getPopup(owner, contents, point.x, point.y); + } + }; + PopupFactory.setSharedInstance(popupFactory); }