use of com.intellij.ide.ui.laf.LafManagerImpl in project intellij-community by JetBrains.
the class InitialConfigurationDialog method doOKAction.
@Override
protected void doOKAction() {
Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myMainPanel));
super.doOKAction();
// set keymap
((KeymapManagerImpl) KeymapManager.getInstance()).setActiveKeymap((Keymap) myKeymapComboBox.getSelectedItem());
// set color scheme
EditorColorsManager.getInstance().setGlobalScheme((EditorColorsScheme) myColorSchemeComboBox.getSelectedItem());
// create default todo_pattern for color scheme
TodoConfiguration.getInstance().resetToDefaultTodoPatterns();
final boolean createScript = myCreateScriptCheckbox.isSelected();
final boolean createEntry = myCreateEntryCheckBox.isSelected();
if (createScript || createEntry) {
final String pathName = myScriptPathTextField.getText();
final boolean globalEntry = myGlobalEntryCheckBox.isSelected();
ProgressManager.getInstance().run(new Task.Backgroundable(project, getTitle()) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
indicator.setFraction(0.0);
if (createScript) {
indicator.setText("Creating launcher script...");
try {
CreateLauncherScriptAction.createLauncherScript(pathName);
} catch (Exception e) {
CreateLauncherScriptAction.reportFailure(e, getProject());
}
}
indicator.setFraction(0.5);
if (createEntry) {
indicator.setText("Creating desktop entry...");
try {
CreateDesktopEntryAction.createDesktopEntry(globalEntry);
} catch (Exception e) {
CreateDesktopEntryAction.reportFailure(e, getProject());
}
}
indicator.setFraction(1.0);
}
});
}
UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) myAppearanceComboBox.getSelectedItem();
LafManagerImpl lafManager = (LafManagerImpl) LafManager.getInstance();
if (info.getName().contains("Darcula") != (LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo)) {
lafManager.setLookAndFeelAfterRestart(info);
String message = "IDE appearance settings will be applied after restart. Would you like to restart now?";
int rc = Messages.showYesNoDialog(project, message, "IDE Appearance", Messages.getQuestionIcon());
if (rc == Messages.YES) {
((ApplicationImpl) ApplicationManager.getApplication()).restart(true);
}
} else if (!info.equals(lafManager.getCurrentLookAndFeel())) {
lafManager.setCurrentLookAndFeel(info);
lafManager.updateUI();
}
}
use of com.intellij.ide.ui.laf.LafManagerImpl 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.LafManagerImpl in project intellij-community by JetBrains.
the class CustomizeUIThemeStepPanel method applyLaf.
private void applyLaf(ThemeInfo theme, Component component) {
UIManager.LookAndFeelInfo info = new UIManager.LookAndFeelInfo(theme.name, theme.laf);
try {
boolean wasUnderDarcula = UIUtil.isUnderDarcula();
UIManager.setLookAndFeel(info.getClassName());
String className = info.getClassName();
if (!myInitial) {
WelcomeWizardUtil.setWizardLAF(className);
}
Window window = SwingUtilities.getWindowAncestor(component);
if (window != null) {
if (SystemInfo.isMac) {
window.setBackground(new Color(UIUtil.getPanelBackground().getRGB()));
}
SwingUtilities.updateComponentTreeUI(window);
}
if (ApplicationManager.getApplication() != null) {
LafManager lafManager = LafManager.getInstance();
lafManager.setCurrentLookAndFeel(info);
if (lafManager instanceof LafManagerImpl) {
//Actually updateUI would be called inside EditorColorsManager
((LafManagerImpl) lafManager).updateWizardLAF(wasUnderDarcula);
} else {
lafManager.updateUI();
}
}
if (myColumnMode) {
myPreviewLabel.setIcon(theme.getIcon());
myPreviewLabel.setBorder(BorderFactory.createLineBorder(UIManager.getColor("Label.disabledForeground")));
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations