diff options
Diffstat (limited to 'platform/lang-impl/src/com/intellij/ui')
4 files changed, 30 insertions, 40 deletions
diff --git a/platform/lang-impl/src/com/intellij/ui/DuplicateNodeRenderer.java b/platform/lang-impl/src/com/intellij/ui/DuplicateNodeRenderer.java index 3083ffed6de9..663dccce5ed8 100644 --- a/platform/lang-impl/src/com/intellij/ui/DuplicateNodeRenderer.java +++ b/platform/lang-impl/src/com/intellij/ui/DuplicateNodeRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.awt.*; import java.util.Enumeration; @@ -84,9 +85,9 @@ public class DuplicateNodeRenderer { private static Rectangle getExpandedNodesRect(JTree tree, DefaultMutableTreeNode node, TreePath path) { Rectangle rect = tree.getRowBounds(tree.getRowForPath(path)); if (tree.isExpanded(path)) { - Enumeration<DefaultMutableTreeNode> children = node.children(); + Enumeration<TreeNode> children = node.children(); while (children.hasMoreElements()) { - DefaultMutableTreeNode child = children.nextElement(); + DefaultMutableTreeNode child = (DefaultMutableTreeNode)children.nextElement(); TreePath childPath = path.pathByAddingChild(child); assert !path.equals(childPath) : path+";"+child; rect = union(rect, getExpandedNodesRect(tree, child, childPath)); diff --git a/platform/lang-impl/src/com/intellij/ui/popup/PopupPositionManager.java b/platform/lang-impl/src/com/intellij/ui/popup/PopupPositionManager.java index ea9a263d5713..81d09d7886f8 100644 --- a/platform/lang-impl/src/com/intellij/ui/popup/PopupPositionManager.java +++ b/platform/lang-impl/src/com/intellij/ui/popup/PopupPositionManager.java @@ -53,7 +53,7 @@ public class PopupPositionManager { @Nullable final Editor editor, @Nullable DataContext dataContext) { final LookupEx lookup = LookupManager.getActiveLookup(editor); - if (lookup != null && lookup.getCurrentItem() != null) { + if (lookup != null && lookup.getCurrentItem() != null && lookup.getComponent().isShowing()) { new PositionAdjuster(lookup.getComponent()).adjust(hint); lookup.addLookupListener(new LookupAdapter() { @Override diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java b/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java index a7721a8b826f..bfa1e14ec88e 100644 --- a/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java +++ b/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java @@ -96,24 +96,24 @@ public class ColorSelectionComponent extends JPanel { } @Nullable - private ColorButton getSelectedButtonInner() { + public String getSelectedColorName() { for (String name : myColorToButtonMap.keySet()) { ColorButton button = myColorToButtonMap.get(name); - if (button.isSelected()) return button; + if (!button.isSelected()) continue; + if (button instanceof CustomColorButton) return ColorUtil.toHex(button.getColor()); + return name; } return null; } @Nullable - public String getSelectedColorName() { - ColorButton button = getSelectedButtonInner(); - return button == null? null : button instanceof CustomColorButton ? ColorUtil.toHex(button.getColor()) : button.getText(); - } - - @Nullable public Color getSelectedColor() { - ColorButton button = getSelectedButtonInner(); - return button == null? null : button.getColor(); + for (String name : myColorToButtonMap.keySet()) { + ColorButton button = myColorToButtonMap.get(name); + if (!button.isSelected()) continue; + return button.getColor(); + } + return null; } public void initDefault(@NotNull FileColorManager manager, @Nullable String selectedColorName) { diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java index a60889bb9f93..c65af1ecdb4f 100644 --- a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java @@ -18,24 +18,25 @@ package com.intellij.ui.tabs; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.components.*; -import com.intellij.openapi.components.StoragePathMacros; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiManager; import com.intellij.ui.ColorUtil; import com.intellij.ui.FileColorManager; +import com.intellij.ui.JBColor; import com.intellij.ui.LightColors; -import com.intellij.util.containers.hash.LinkedHashMap; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.awt.*; -import java.util.*; +import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Map; /** * @author spleaner @@ -52,25 +53,14 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent private final FileColorsModel myModel; private FileColorSharedConfigurationManager mySharedConfigurationManager; - private static final Map<String, Color> ourDefaultColors; - private static final Map<String, Color> ourDefaultDarkColors; - - static { - ourDefaultColors = new LinkedHashMap<String, Color>(); - ourDefaultColors.put("Blue", new Color(0xdcf0ff)); - ourDefaultColors.put("Green", new Color(231, 250, 219)); - ourDefaultColors.put("Orange", new Color(246, 224, 202)); - ourDefaultColors.put("Rose", new Color(242, 206, 202)); - ourDefaultColors.put("Violet", new Color(222, 213, 241)); - ourDefaultColors.put("Yellow", new Color(255, 255, 228)); - ourDefaultDarkColors = new LinkedHashMap<String, Color>(); - ourDefaultDarkColors.put("Blue", new Color(0x2B3557)); - ourDefaultDarkColors.put("Green", new Color(0x2A3B2C)); - ourDefaultDarkColors.put("Orange", new Color(0x823B1C)); - ourDefaultDarkColors.put("Rose", new Color(0x542F3A)); - ourDefaultDarkColors.put("Violet", new Color(0x4f4056)); - ourDefaultDarkColors.put("Yellow", new Color(0x494539)); - } + private static final Map<String, Color> ourDefaultColors = ContainerUtil.<String, Color>immutableMapBuilder() + .put("Blue", new JBColor(new Color(0xdcf0ff), new Color(0x2B3557))) + .put("Green", new JBColor(new Color(231, 250, 219), new Color(0x2A3B2C))) + .put("Orange", new JBColor(new Color(246, 224, 202), new Color(0x823B1C))) + .put("Rose", new JBColor(new Color(242, 206, 202), new Color(0x542F3A))) + .put("Violet", new JBColor(new Color(222, 213, 241), new Color(0x4f4056))) + .put("Yellow", new JBColor(new Color(255, 255, 228), new Color(0x494539))) + .build(); public FileColorManagerImpl(@NotNull final Project project) { myProject = project; @@ -133,7 +123,7 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent @SuppressWarnings({"MethodMayBeStatic"}) @Nullable public Color getColor(@NotNull final String name) { - final Color color = UIUtil.isUnderDarcula() ? ourDefaultDarkColors.get(name) : ourDefaultColors.get(name); + Color color = ourDefaultColors.get(name); return color == null ? ColorUtil.fromHex(name, null) : color; } @@ -151,8 +141,7 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent @Override @SuppressWarnings({"MethodMayBeStatic"}) public Collection<String> getColorNames() { - final Set<String> names = ourDefaultColors.keySet(); - final List<String> sorted = new ArrayList<String>(names); + List<String> sorted = ContainerUtil.newArrayList(ourDefaultColors.keySet()); Collections.sort(sorted); return sorted; } |