use of com.intellij.ide.ui.LafManagerListener in project intellij-community by JetBrains.
the class BalloonLayoutImpl method add.
@Override
public void add(@NotNull final Balloon balloon, @Nullable Object layoutData) {
ApplicationManager.getApplication().assertIsDispatchThread();
Balloon merge = merge(layoutData);
if (merge == null) {
if (getVisibleCount() > 0 && layoutData instanceof BalloonLayoutData && ((BalloonLayoutData) layoutData).groupId != null) {
int index = -1;
int count = 0;
for (int i = 0, size = myBalloons.size(); i < size; i++) {
BalloonLayoutData ld = myLayoutData.get(myBalloons.get(i));
if (ld != null && ld.groupId != null) {
if (index == -1) {
index = i;
}
count++;
}
}
if (count > 0 && count == getVisibleCount()) {
remove(myBalloons.get(index));
}
}
myBalloons.add(balloon);
} else {
int index = myBalloons.indexOf(merge);
remove(merge);
myBalloons.add(index, balloon);
}
if (layoutData instanceof BalloonLayoutData) {
BalloonLayoutData balloonLayoutData = (BalloonLayoutData) layoutData;
balloonLayoutData.closeAll = myCloseAll;
balloonLayoutData.doLayout = myLayoutRunnable;
myLayoutData.put(balloon, balloonLayoutData);
}
Disposer.register(balloon, new Disposable() {
public void dispose() {
clearNMore(balloon);
remove(balloon, false);
queueRelayout();
}
});
if (myLafListener == null && layoutData != null) {
myLafListener = new LafManagerListener() {
@Override
public void lookAndFeelChanged(LafManager source) {
for (BalloonLayoutData layoutData : myLayoutData.values()) {
if (layoutData.lafHandler != null) {
layoutData.lafHandler.run();
}
}
}
};
LafManager.getInstance().addLafManagerListener(myLafListener);
}
calculateSize();
relayout();
if (!balloon.isDisposed()) {
balloon.show(myLayeredPane);
}
fireRelayout();
}
use of com.intellij.ide.ui.LafManagerListener in project intellij-community by JetBrains.
the class QuickChangeLookAndFeel method switchLafAndUpdateUI.
public static void switchLafAndUpdateUI(@NotNull LafManager lafMan, @NotNull UIManager.LookAndFeelInfo lf) {
UIManager.LookAndFeelInfo cur = lafMan.getCurrentLookAndFeel();
if (cur == lf)
return;
boolean wasDarcula = UIUtil.isUnderDarcula();
lafMan.setCurrentLookAndFeel(lf);
// a twist not to updateUI twice: here and in DarculaInstaller
// double updateUI shall be avoided and causes NPE in some components (HelpView)
Ref<Boolean> updated = Ref.create(false);
LafManagerListener listener = (s) -> updated.set(true);
lafMan.addLafManagerListener(listener);
try {
if (UIUtil.isUnderDarcula()) {
DarculaInstaller.install();
} else if (wasDarcula) {
DarculaInstaller.uninstall();
}
} finally {
lafMan.removeLafManagerListener(listener);
if (!updated.get()) {
lafMan.updateUI();
}
}
}
Aggregations