use of com.intellij.ide.ui.laf.darcula.DarculaInstaller in project intellij-community by JetBrains.
the class ColorAndFontOptions method changeLafIfNecessary.
private static void changeLafIfNecessary(boolean isDarkEditorTheme) {
String propKey = "change.laf.on.editor.theme.change";
String value = PropertiesComponent.getInstance().getValue(propKey);
if ("false".equals(value))
return;
boolean applyAlways = "true".equals(value);
DialogWrapper.DoNotAskOption doNotAskOption = new DialogWrapper.DoNotAskOption.Adapter() {
@Override
public void rememberChoice(boolean isSelected, int exitCode) {
if (isSelected) {
PropertiesComponent.getInstance().setValue(propKey, Boolean.toString(exitCode == Messages.YES));
}
}
@Override
public boolean shouldSaveOptionsOnCancel() {
return true;
}
};
final String productName = ApplicationNamesInfo.getInstance().getFullProductName();
final LafManager lafManager = LafManager.getInstance();
if (isDarkEditorTheme && !UIUtil.isUnderDarcula()) {
if (applyAlways || Messages.showYesNoDialog("Looks like you have set a dark editor theme. Would you like to set dark theme for entire " + productName, "Change " + productName + " theme", Messages.YES_BUTTON, Messages.NO_BUTTON, Messages.getQuestionIcon(), doNotAskOption) == Messages.YES) {
lafManager.setCurrentLookAndFeel(new DarculaLookAndFeelInfo());
lafManager.updateUI();
//noinspection SSBasedInspection
SwingUtilities.invokeLater(DarculaInstaller::install);
}
} else if (!isDarkEditorTheme && UIUtil.isUnderDarcula()) {
if (lafManager instanceof LafManagerImpl && (applyAlways || Messages.showYesNoDialog("Looks like you have set a bright editor theme. Would you like to set bright theme for entire " + productName, "Change " + productName + " theme", Messages.YES_BUTTON, Messages.NO_BUTTON, Messages.getQuestionIcon(), doNotAskOption) == Messages.YES)) {
lafManager.setCurrentLookAndFeel(((LafManagerImpl) lafManager).getDefaultLaf());
lafManager.updateUI();
//noinspection SSBasedInspection
SwingUtilities.invokeLater(DarculaInstaller::uninstall);
}
}
}
use of com.intellij.ide.ui.laf.darcula.DarculaInstaller 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