mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
LafManager topic
GitOrigin-RevId: 30fc34f546fd0846eb77afdfabee45fb8ba1e61c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ed638f4ea4
commit
4016a923a6
@@ -18,6 +18,10 @@ public class Topic<L> {
|
||||
this(displayName, listenerClass, BroadcastDirection.TO_CHILDREN);
|
||||
}
|
||||
|
||||
public Topic(@NotNull Class<L> listenerClass) {
|
||||
this(listenerClass.getSimpleName(), listenerClass, BroadcastDirection.TO_CHILDREN);
|
||||
}
|
||||
|
||||
public Topic(@NonNls @NotNull String displayName, @NotNull Class<L> listenerClass, @NotNull BroadcastDirection broadcastDirection) {
|
||||
myDisplayName = displayName;
|
||||
myListenerClass = listenerClass;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.navigationToolbar;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
@@ -47,7 +47,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class NavBarListener
|
||||
public final class NavBarListener
|
||||
implements ProblemListener, FocusListener, FileStatusListener, AnActionListener, FileEditorManagerListener,
|
||||
PsiTreeChangeListener, ModuleRootListener, NavBarModelListener, PropertyChangeListener, KeyListener, WindowFocusListener,
|
||||
LafManagerListener {
|
||||
@@ -56,7 +56,7 @@ public class NavBarListener
|
||||
private final NavBarPanel myPanel;
|
||||
private boolean shouldFocusEditor;
|
||||
|
||||
static void subscribeTo(NavBarPanel panel) {
|
||||
static void subscribeTo(@NotNull NavBarPanel panel) {
|
||||
if (panel.getClientProperty(LISTENER) != null) {
|
||||
unsubscribeFrom(panel);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class NavBarListener
|
||||
FileStatusManager.getInstance(project).addFileStatusListener(listener);
|
||||
PsiManager.getInstance(project).addPsiTreeChangeListener(listener);
|
||||
|
||||
final MessageBusConnection connection = project.getMessageBus().connect();
|
||||
MessageBusConnection connection = project.getMessageBus().connect();
|
||||
connection.subscribe(AnActionListener.TOPIC, listener);
|
||||
connection.subscribe(ProjectTopics.PROJECT_ROOTS, listener);
|
||||
connection.subscribe(NavBarModelListener.NAV_BAR, listener);
|
||||
@@ -78,29 +78,31 @@ public class NavBarListener
|
||||
panel.addKeyListener(listener);
|
||||
|
||||
if (panel.isInFloatingMode()) {
|
||||
final Window window = SwingUtilities.windowForComponent(panel);
|
||||
Window window = SwingUtilities.windowForComponent(panel);
|
||||
if (window != null) {
|
||||
window.addWindowFocusListener(listener);
|
||||
}
|
||||
} else {
|
||||
LafManager.getInstance().addLafManagerListener(listener);
|
||||
}
|
||||
else {
|
||||
connection.subscribe(LafManagerListener.TOPIC, listener);
|
||||
}
|
||||
}
|
||||
|
||||
static void unsubscribeFrom(NavBarPanel panel) {
|
||||
final NavBarListener listener = (NavBarListener)panel.getClientProperty(LISTENER);
|
||||
static void unsubscribeFrom(@NotNull NavBarPanel panel) {
|
||||
NavBarListener listener = (NavBarListener)panel.getClientProperty(LISTENER);
|
||||
panel.putClientProperty(LISTENER, null);
|
||||
if (listener != null) {
|
||||
final Project project = panel.getProject();
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener(listener);
|
||||
FileStatusManager.getInstance(project).removeFileStatusListener(listener);
|
||||
PsiManager.getInstance(project).removePsiTreeChangeListener(listener);
|
||||
final MessageBusConnection connection = (MessageBusConnection)panel.getClientProperty(BUS);
|
||||
panel.putClientProperty(BUS, null);
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
LafManager.getInstance().removeLafManagerListener(listener);
|
||||
if (listener == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Project project = panel.getProject();
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener(listener);
|
||||
FileStatusManager.getInstance(project).removeFileStatusListener(listener);
|
||||
PsiManager.getInstance(project).removePsiTreeChangeListener(listener);
|
||||
MessageBusConnection connection = (MessageBusConnection)panel.getClientProperty(BUS);
|
||||
panel.putClientProperty(BUS, null);
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.ui;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -22,9 +8,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
*/
|
||||
public abstract class LafManager {
|
||||
public static LafManager getInstance() {
|
||||
return ApplicationManager.getApplication().getComponent(LafManager.class);
|
||||
@@ -42,9 +25,21 @@ public abstract class LafManager {
|
||||
|
||||
public abstract void repaintUI();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link LafManagerListener#TOPIC}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void addLafManagerListener(@NotNull LafManagerListener listener);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link LafManagerListener#TOPIC}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void addLafManagerListener(@NotNull LafManagerListener listener, @NotNull Disposable disposable);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link LafManagerListener#TOPIC}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void removeLafManagerListener(@NotNull LafManagerListener listener);
|
||||
}
|
||||
@@ -1,20 +1,7 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.ui;
|
||||
|
||||
import com.intellij.util.messages.Topic;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EventListener;
|
||||
@@ -26,6 +13,8 @@ import java.util.EventListener;
|
||||
*
|
||||
* @author Vladimir Kondratyev
|
||||
*/
|
||||
public interface LafManagerListener extends EventListener{
|
||||
public interface LafManagerListener extends EventListener {
|
||||
Topic<LafManagerListener> TOPIC = new Topic<>(LafManagerListener.class);
|
||||
|
||||
void lookAndFeelChanged(@NotNull LafManager source);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
@@ -102,7 +88,7 @@ public class ConsoleViewUtil {
|
||||
@Override
|
||||
public void setColorScheme(@NotNull EditorColorsScheme scheme) {}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static DelegateColorScheme updateConsoleColorScheme(@NotNull EditorColorsScheme scheme) {
|
||||
return new DelegateColorScheme(scheme) {
|
||||
@@ -161,13 +147,14 @@ public class ConsoleViewUtil {
|
||||
|
||||
private static class ColorCache {
|
||||
static {
|
||||
LafManager.getInstance().addLafManagerListener(new LafManagerListener() {
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(LafManagerListener.TOPIC, new LafManagerListener() {
|
||||
@Override
|
||||
public void lookAndFeelChanged(@NotNull LafManager source) {
|
||||
mergedTextAttributes.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static final Map<Key, List<TextAttributesKey>> textAttributeKeys = ContainerUtil.newConcurrentMap();
|
||||
static final Map<Key, TextAttributes> mergedTextAttributes = ConcurrentFactoryMap.createMap(contentKey-> {
|
||||
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
|
||||
|
||||
@@ -5,11 +5,14 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaInstaller;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.util.ui.StartupUiUtil;
|
||||
@@ -49,8 +52,8 @@ public class QuickChangeLookAndFeel extends QuickSwitchSchemeAction {
|
||||
// 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);
|
||||
Disposable disposable = Disposer.newDisposable();
|
||||
ApplicationManager.getApplication().getMessageBus().connect(disposable).subscribe(LafManagerListener.TOPIC, source -> updated.set(true));
|
||||
try {
|
||||
if (StartupUiUtil.isUnderDarcula()) {
|
||||
DarculaInstaller.install();
|
||||
@@ -60,7 +63,7 @@ public class QuickChangeLookAndFeel extends QuickSwitchSchemeAction {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
lafMan.removeLafManagerListener(listener);
|
||||
Disposer.dispose(disposable);
|
||||
if (!updated.get()) {
|
||||
lafMan.updateUI();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.InstalledPluginsState;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
import com.intellij.openapi.application.*;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
@@ -37,7 +36,7 @@ import java.util.zip.ZipFile;
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class PluginLogo {
|
||||
public final class PluginLogo {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.plugins.newui.PluginLogo");
|
||||
|
||||
private static final String CACHE_DIR = "imageCache";
|
||||
@@ -50,11 +49,17 @@ public class PluginLogo {
|
||||
private static PluginLogoIconProvider Default;
|
||||
private static List<Pair<IdeaPluginDescriptor, LazyPluginLogoIcon>> myPrepareToLoad;
|
||||
|
||||
private static LafManagerListener myLafListener;
|
||||
private static boolean lafListenerAdded;
|
||||
|
||||
private static void initLafListener() {
|
||||
if (myLafListener == null && !GraphicsEnvironment.isHeadless()) {
|
||||
LafManager.getInstance().addLafManagerListener(myLafListener = _0 -> {
|
||||
if (!lafListenerAdded) {
|
||||
lafListenerAdded = true;
|
||||
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(LafManagerListener.TOPIC, source -> {
|
||||
Default = null;
|
||||
HiDPIPluginLogoIcon.clearCache();
|
||||
});
|
||||
|
||||
@@ -154,11 +154,11 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC
|
||||
|
||||
@Override
|
||||
public void addLafManagerListener(@NotNull LafManagerListener listener, @NotNull Disposable disposable) {
|
||||
myEventDispatcher.addListener(listener, disposable);
|
||||
ApplicationManager.getApplication().getMessageBus().connect(disposable).subscribe(LafManagerListener.TOPIC, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLafManagerListener(@NotNull final LafManagerListener listener) {
|
||||
public void removeLafManagerListener(@NotNull LafManagerListener listener) {
|
||||
myEventDispatcher.removeListener(listener);
|
||||
}
|
||||
|
||||
@@ -426,6 +426,9 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC
|
||||
ActionToolbarImpl.updateAllToolbarsImmediately();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link AppUIUtil#updateForDarcula(boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
public static void updateForDarcula(boolean isDarcula) {
|
||||
@@ -442,14 +445,6 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Icon getAquaMenuInvertedIcon() {
|
||||
if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
|
||||
return AllIcons.Mac.Tree_white_right_arrow;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates LAF of all windows. The method also updates font of components
|
||||
* as it's configured in {@code UISettings}.
|
||||
@@ -484,6 +479,7 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC
|
||||
updateUI(frame);
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(LafManagerListener.TOPIC).lookAndFeelChanged(this);
|
||||
myEventDispatcher.getMulticaster().lookAndFeelChanged(this);
|
||||
}
|
||||
|
||||
@@ -609,17 +605,18 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC
|
||||
defaults.put("hidpi.scaleFactor", JBUIScale.scale(1f));
|
||||
}
|
||||
|
||||
private static void fixMenuIssues(UIDefaults uiDefaults) {
|
||||
private static void fixMenuIssues(@NotNull UIDefaults uiDefaults) {
|
||||
if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
|
||||
// update ui for popup menu to get round corners
|
||||
uiDefaults.put("PopupMenuUI", MacPopupMenuUI.class.getCanonicalName());
|
||||
uiDefaults.put("Menu.invertedArrowIcon", getAquaMenuInvertedIcon());
|
||||
uiDefaults.put("Menu.invertedArrowIcon", AllIcons.Mac.Tree_white_right_arrow);
|
||||
uiDefaults.put("Menu.disabledArrowIcon", getAquaMenuDisabledIcon());
|
||||
}
|
||||
|
||||
if (UIUtil.isUnderWin10LookAndFeel()) {
|
||||
uiDefaults.put("Menu.arrowIcon", new Win10MenuArrowIcon());
|
||||
} else if ((SystemInfo.isLinux || SystemInfo.isWindows) && (UIUtil.isUnderIntelliJLaF() || StartupUiUtil.isUnderDarcula())) {
|
||||
}
|
||||
else if ((SystemInfo.isLinux || SystemInfo.isWindows) && (UIUtil.isUnderIntelliJLaF() || StartupUiUtil.isUnderDarcula())) {
|
||||
uiDefaults.put("Menu.arrowIcon", new DefaultMenuArrowIcon(AllIcons.General.ArrowRight));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.internal;
|
||||
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -34,6 +35,8 @@ public class GrayFilterConfig extends AnAction implements DumbAware {
|
||||
|
||||
private final Object[][] data = new Object[3][2];
|
||||
|
||||
private boolean lafListenerAdded;
|
||||
|
||||
private void setData() {
|
||||
data[0][0] = BRIGHTNESS;
|
||||
data[1][0] = CONTRAST;
|
||||
@@ -46,10 +49,15 @@ public class GrayFilterConfig extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
Window activeFrame = IdeFrameImpl.getActiveFrame();
|
||||
if (activeFrame == null) return;
|
||||
if (activeFrame == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
setData();
|
||||
LafManager.getInstance().addLafManagerListener(source -> setData());
|
||||
if (!lafListenerAdded) {
|
||||
lafListenerAdded = true;
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(LafManagerListener.TOPIC, source -> setData());
|
||||
}
|
||||
|
||||
JTable table = new JTable(data, new String[] {"Property", "Value"}) {
|
||||
@Override
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.internal;
|
||||
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
public class TextGrayFilterConfig extends GrayFilterConfig {
|
||||
public final class TextGrayFilterConfig extends GrayFilterConfig {
|
||||
@Override
|
||||
protected UIUtil.GrayFilter getGrayFilter() {
|
||||
return (UIUtil.GrayFilter)UIUtil.getTextGrayFilter();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.ui.impl;
|
||||
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.ui.JreHiDpiUtil;
|
||||
import com.intellij.ui.scale.JBUIScale;
|
||||
import com.intellij.ui.scale.ScaleContext;
|
||||
@@ -20,7 +21,7 @@ import java.awt.image.BufferedImage;
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ShadowPainter extends ScaleContextSupport {
|
||||
public final class ShadowPainter extends ScaleContextSupport {
|
||||
private final Icon myTop;
|
||||
private final Icon myTopRight;
|
||||
private final Icon myRight;
|
||||
@@ -49,7 +50,7 @@ public class ShadowPainter extends ScaleContextSupport {
|
||||
myTopLeft = topLeft;
|
||||
|
||||
updateIcons(null);
|
||||
LafManager.getInstance().addLafManagerListener(source -> updateIcons(null));
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(LafManagerListener.TOPIC, source -> updateIcons(null));
|
||||
}
|
||||
|
||||
public ShadowPainter(Icon top, Icon topRight, Icon right, Icon bottomRight, Icon bottom, Icon bottomLeft, Icon left, Icon topLeft, @Nullable Color borderColor) {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package com.intellij.openapi.wm.impl;
|
||||
|
||||
import com.intellij.diagnostic.IdeMessagePanel;
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.idea.SplashManager;
|
||||
@@ -83,7 +82,6 @@ public final class IdeFrameImpl extends JFrame implements IdeFrameEx, Accessible
|
||||
private IdeRootPane myRootPane;
|
||||
private BalloonLayout myBalloonLayout;
|
||||
private IdeFrameDecorator myFrameDecorator;
|
||||
private final LafManagerListener myLafListener;
|
||||
private final ComponentListener resizedListener;
|
||||
|
||||
private volatile Image selfie;
|
||||
@@ -97,7 +95,6 @@ public final class IdeFrameImpl extends JFrame implements IdeFrameEx, Accessible
|
||||
myRootPane = new IdeRootPane(this);
|
||||
setRootPane(myRootPane);
|
||||
setBackground(UIUtil.getPanelBackground());
|
||||
LafManager.getInstance().addLafManagerListener(myLafListener = src -> setBackground(UIUtil.getPanelBackground()));
|
||||
|
||||
resizedListener = new ComponentAdapter() {
|
||||
@Override
|
||||
@@ -205,6 +202,8 @@ public final class IdeFrameImpl extends JFrame implements IdeFrameEx, Accessible
|
||||
return;
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(LafManagerListener.TOPIC, source -> setBackground(UIUtil.getPanelBackground()));
|
||||
|
||||
rootPane.init(this);
|
||||
|
||||
// to show window thumbnail under Macs
|
||||
@@ -553,7 +552,6 @@ public final class IdeFrameImpl extends JFrame implements IdeFrameEx, Accessible
|
||||
Disposer.dispose(myFrameDecorator);
|
||||
myFrameDecorator = null;
|
||||
}
|
||||
if (myLafListener != null) LafManager.getInstance().removeLafManagerListener(myLafListener);
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.wm.impl;
|
||||
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
@@ -12,23 +13,23 @@ import com.intellij.ui.scale.ScaleContext;
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.ui.ImageUtil;
|
||||
import com.intellij.util.ui.StartupUiUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.RGBImageFilter;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ToolWindowIcon implements RetrievableIcon, MenuBarIconProvider {
|
||||
private static final Map<Icon, int[]> ourCache = new HashMap<>();
|
||||
public final class ToolWindowIcon implements RetrievableIcon, MenuBarIconProvider {
|
||||
private static final Map<Icon, int[]> ourCache = new THashMap<>();
|
||||
|
||||
static {
|
||||
LafManager.getInstance().addLafManagerListener(x -> ourCache.clear());
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(LafManagerListener.TOPIC, source -> ourCache.clear());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -94,7 +95,7 @@ public class ToolWindowIcon implements RetrievableIcon, MenuBarIconProvider {
|
||||
ScaleContext ctx = ScaleContext.create((Graphics2D)g);
|
||||
Image rawImage = ImageUtil.filter(IconUtil.toImage(myIcon, ctx), filter);
|
||||
Image hidpiImage = ImageUtil.ensureHiDPI(rawImage, ctx);
|
||||
UIUtil.drawImage(g, hidpiImage, x, y, null);
|
||||
StartupUiUtil.drawImage(g, hidpiImage, x, y, null);
|
||||
}
|
||||
|
||||
private static int getBaseGray() {
|
||||
|
||||
@@ -36,7 +36,6 @@ public class JavaFxHtmlPanel implements Disposable {
|
||||
private final JPanel myPanelWrapper;
|
||||
@NotNull
|
||||
private final List<Runnable> myInitActions = new ArrayList<>();
|
||||
private final JavaFXLafManagerListener myLafManagerListener;
|
||||
@Nullable
|
||||
protected JFXPanel myPanel;
|
||||
@Nullable protected WebView myWebView;
|
||||
@@ -84,8 +83,7 @@ public class JavaFxHtmlPanel implements Disposable {
|
||||
}));
|
||||
})));
|
||||
|
||||
myLafManagerListener = new JavaFXLafManagerListener();
|
||||
LafManager.getInstance().addLafManagerListener(myLafManagerListener);
|
||||
ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(LafManagerListener.TOPIC, new JavaFXLafManagerListener());
|
||||
runInPlatformWhenAvailable(() -> updateLaf(StartupUiUtil.isUnderDarcula()));
|
||||
}
|
||||
|
||||
@@ -175,10 +173,7 @@ public class JavaFxHtmlPanel implements Disposable {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
runInPlatformWhenAvailable(
|
||||
() -> getWebViewGuaranteed().getEngine().load(null)
|
||||
);
|
||||
LafManager.getInstance().removeLafManagerListener(myLafManagerListener);
|
||||
runInPlatformWhenAvailable(() -> getWebViewGuaranteed().getEngine().load(null));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+11
-15
@@ -1,7 +1,7 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.intellij.plugins.markdown.settings;
|
||||
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
@@ -9,28 +9,24 @@ import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.util.messages.Topic;
|
||||
import com.intellij.util.ui.StartupUiUtil;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import com.intellij.util.xmlb.annotations.Property;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static org.intellij.plugins.markdown.settings.MarkdownCssSettings.DARCULA;
|
||||
import static org.intellij.plugins.markdown.settings.MarkdownCssSettings.DEFAULT;
|
||||
|
||||
@State(
|
||||
name = "MarkdownApplicationSettings",
|
||||
storages = @Storage("markdown.xml")
|
||||
)
|
||||
public class MarkdownApplicationSettings implements PersistentStateComponent<MarkdownApplicationSettings.State>,
|
||||
MarkdownCssSettings.Holder,
|
||||
MarkdownPreviewSettings.Holder {
|
||||
public final class MarkdownApplicationSettings implements PersistentStateComponent<MarkdownApplicationSettings.State>,
|
||||
MarkdownCssSettings.Holder,
|
||||
MarkdownPreviewSettings.Holder {
|
||||
|
||||
private final State myState = new State();
|
||||
private State myState = new State();
|
||||
|
||||
public MarkdownApplicationSettings() {
|
||||
final MarkdownLAFListener lafListener = new MarkdownLAFListener();
|
||||
LafManager.getInstance().addLafManagerListener(lafListener);
|
||||
MarkdownLAFListener lafListener = new MarkdownLAFListener();
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(LafManagerListener.TOPIC, lafListener);
|
||||
// Let's init proper CSS scheme
|
||||
ApplicationManager.getApplication().invokeLater(() -> lafListener.updateCssSettingsForced(StartupUiUtil.isUnderDarcula()));
|
||||
}
|
||||
@@ -48,7 +44,7 @@ public class MarkdownApplicationSettings implements PersistentStateComponent<Mar
|
||||
|
||||
@Override
|
||||
public void loadState(@NotNull State state) {
|
||||
XmlSerializerUtil.copyBean(state, myState);
|
||||
myState = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,8 +56,8 @@ public class MarkdownApplicationSettings implements PersistentStateComponent<Mar
|
||||
@NotNull
|
||||
@Override
|
||||
public MarkdownCssSettings getMarkdownCssSettings() {
|
||||
if (DARCULA.getStylesheetUri().equals(myState.myCssSettings.getStylesheetUri())
|
||||
|| DEFAULT.getStylesheetUri().equals(myState.myCssSettings.getStylesheetUri())) {
|
||||
if (MarkdownCssSettings.DARCULA.getStylesheetUri().equals(myState.myCssSettings.getStylesheetUri())
|
||||
|| MarkdownCssSettings.DEFAULT.getStylesheetUri().equals(myState.myCssSettings.getStylesheetUri())) {
|
||||
return new MarkdownCssSettings(false,
|
||||
"",
|
||||
myState.myCssSettings.isTextEnabled(),
|
||||
@@ -99,7 +95,7 @@ public class MarkdownApplicationSettings implements PersistentStateComponent<Mar
|
||||
return myState.myHideErrors;
|
||||
}
|
||||
|
||||
public static class State {
|
||||
public static final class State {
|
||||
@Property(surroundWithTag = false)
|
||||
@NotNull
|
||||
private MarkdownCssSettings myCssSettings = MarkdownCssSettings.DEFAULT;
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.intellij.uiDesigner.palette;
|
||||
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
@@ -52,10 +51,9 @@ import java.util.Map;
|
||||
* @author Vladimir Kondratyev
|
||||
*/
|
||||
@State(name = "Palette2", defaultStateAsResource = true, storages = @Storage("uiDesigner.xml"))
|
||||
public final class Palette implements Disposable, PersistentStateComponent<Element> {
|
||||
public final class Palette implements PersistentStateComponent<Element> {
|
||||
private static final Logger LOG = Logger.getInstance(Palette.class);
|
||||
|
||||
private final MyLafManagerListener myLafManagerListener;
|
||||
private final Map<Class, IntrospectedProperty[]> myClass2Properties;
|
||||
private final Map<String, ComponentItem> myClassName2Item;
|
||||
/*All groups in the palette*/
|
||||
@@ -102,9 +100,8 @@ public final class Palette implements Disposable, PersistentStateComponent<Eleme
|
||||
/**
|
||||
* Invoked by reflection
|
||||
*/
|
||||
public Palette(Project project) {
|
||||
public Palette(@Nullable Project project) {
|
||||
myProject = project;
|
||||
myLafManagerListener = project == null ? null : new MyLafManagerListener();
|
||||
myClass2Properties = new HashMap<>();
|
||||
myClassName2Item = new HashMap<>();
|
||||
myGroups = new ArrayList<>();
|
||||
@@ -112,10 +109,8 @@ public final class Palette implements Disposable, PersistentStateComponent<Eleme
|
||||
if (project != null) {
|
||||
mySpecialGroup.setReadOnly(true);
|
||||
mySpecialGroup.addItem(ComponentItem.createAnyComponentItem(project));
|
||||
}
|
||||
|
||||
if (myLafManagerListener != null) {
|
||||
LafManager.getInstance().addLafManagerListener(myLafManagerListener);
|
||||
project.getMessageBus().connect().subscribe(LafManagerListener.TOPIC, new MyLafManagerListener());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,13 +151,6 @@ public final class Palette implements Disposable, PersistentStateComponent<Eleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (myLafManagerListener != null) {
|
||||
LafManager.getInstance().removeLafManagerListener(myLafManagerListener);
|
||||
}
|
||||
}
|
||||
|
||||
private void upgradePalette() {
|
||||
// load new components from the predefined Palette2.xml
|
||||
try {
|
||||
|
||||
+15
-2
@@ -6,7 +6,9 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
@@ -16,6 +18,7 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
@@ -82,6 +85,7 @@ public final class PropertyInspectorTable extends Table implements DataProvider{
|
||||
/**
|
||||
* Updates UIs of synthetic properties
|
||||
*/
|
||||
private Disposable myLafManagerDisposable;
|
||||
private final MyLafManagerListener myLafManagerListener;
|
||||
/**
|
||||
* This is property exists in this map then it's expanded.
|
||||
@@ -301,12 +305,21 @@ public final class PropertyInspectorTable extends Table implements DataProvider{
|
||||
@Override
|
||||
public void addNotify() {
|
||||
super.addNotify();
|
||||
LafManager.getInstance().addLafManagerListener(myLafManagerListener);
|
||||
|
||||
if (myLafManagerDisposable != null) {
|
||||
Disposer.dispose(myLafManagerDisposable);
|
||||
}
|
||||
myLafManagerDisposable = Disposer.newDisposable();
|
||||
ApplicationManager.getApplication().getMessageBus().connect(myLafManagerDisposable).subscribe(LafManagerListener.TOPIC, myLafManagerListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotify() {
|
||||
LafManager.getInstance().removeLafManagerListener(myLafManagerListener);
|
||||
if (myLafManagerDisposable != null) {
|
||||
Disposer.dispose(myLafManagerDisposable);
|
||||
myLafManagerDisposable = null;
|
||||
}
|
||||
|
||||
super.removeNotify();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user