Search in sources :

Example 1 with LafManager

use of com.intellij.ide.ui.LafManager in project intellij-community by JetBrains.

the class QuickChangeLookAndFeel method fillActions.

protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
    LafManager lafMan = LafManager.getInstance();
    UIManager.LookAndFeelInfo[] lfs = lafMan.getInstalledLookAndFeels();
    UIManager.LookAndFeelInfo current = lafMan.getCurrentLookAndFeel();
    for (UIManager.LookAndFeelInfo lf : lfs) {
        group.add(new DumbAwareAction(lf.getName(), "", lf == current ? ourCurrentAction : ourNotCurrentAction) {

            public void actionPerformed(AnActionEvent e) {
                switchLafAndUpdateUI(lafMan, lf);
            }
        });
    }
}
Also used : LafManager(com.intellij.ide.ui.LafManager) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction)

Example 2 with LafManager

use of com.intellij.ide.ui.LafManager 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();
}
Also used : Disposable(com.intellij.openapi.Disposable) Balloon(com.intellij.openapi.ui.popup.Balloon) LafManager(com.intellij.ide.ui.LafManager) LafManagerListener(com.intellij.ide.ui.LafManagerListener)

Example 3 with LafManager

use of com.intellij.ide.ui.LafManager 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 4 with LafManager

use of com.intellij.ide.ui.LafManager 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)

Example 5 with LafManager

use of com.intellij.ide.ui.LafManager 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();
        }
    }
}
Also used : DarculaInstaller(com.intellij.ide.ui.laf.darcula.DarculaInstaller) UIUtil(com.intellij.util.ui.UIUtil) LafManager(com.intellij.ide.ui.LafManager) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) DataContext(com.intellij.openapi.actionSystem.DataContext) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Project(com.intellij.openapi.project.Project) NotNull(org.jetbrains.annotations.NotNull) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) Ref(com.intellij.openapi.util.Ref) LafManagerListener(com.intellij.ide.ui.LafManagerListener) javax.swing(javax.swing) LafManagerListener(com.intellij.ide.ui.LafManagerListener)

Aggregations

LafManager (com.intellij.ide.ui.LafManager)5 LafManagerListener (com.intellij.ide.ui.LafManagerListener)2 LafManagerImpl (com.intellij.ide.ui.laf.LafManagerImpl)2 DarculaInstaller (com.intellij.ide.ui.laf.darcula.DarculaInstaller)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)2 DarculaLookAndFeelInfo (com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo)1 Disposable (com.intellij.openapi.Disposable)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 Project (com.intellij.openapi.project.Project)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 Balloon (com.intellij.openapi.ui.popup.Balloon)1 Ref (com.intellij.openapi.util.Ref)1 UIUtil (com.intellij.util.ui.UIUtil)1 javax.swing (javax.swing)1 NotNull (org.jetbrains.annotations.NotNull)1