Search in sources :

Example 1 with LafManagerImpl

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();
    }
}
Also used : Task(com.intellij.openapi.progress.Task) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) Project(com.intellij.openapi.project.Project) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) LafManagerImpl(com.intellij.ide.ui.laf.LafManagerImpl) KeymapManagerImpl(com.intellij.openapi.keymap.impl.KeymapManagerImpl)

Example 2 with LafManagerImpl

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);
        }
    }
}
Also used : DarculaInstaller(com.intellij.ide.ui.laf.darcula.DarculaInstaller) LafManager(com.intellij.ide.ui.LafManager) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) LafManagerImpl(com.intellij.ide.ui.laf.LafManagerImpl) DialogWrapper(com.intellij.openapi.ui.DialogWrapper)

Example 3 with LafManagerImpl

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();
    }
}
Also used : LafManager(com.intellij.ide.ui.LafManager) LafManagerImpl(com.intellij.ide.ui.laf.LafManagerImpl)

Aggregations

LafManagerImpl (com.intellij.ide.ui.laf.LafManagerImpl)3 LafManager (com.intellij.ide.ui.LafManager)2 DarculaLookAndFeelInfo (com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo)2 DarculaInstaller (com.intellij.ide.ui.laf.darcula.DarculaInstaller)1 ApplicationImpl (com.intellij.openapi.application.impl.ApplicationImpl)1 KeymapManagerImpl (com.intellij.openapi.keymap.impl.KeymapManagerImpl)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 Project (com.intellij.openapi.project.Project)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1