diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Banner.java b/platform/platform-api/src/com/intellij/openapi/ui/Banner.java index 3f4a92aec5ff..8dbe02228bae 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Banner.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Banner.java @@ -16,6 +16,8 @@ package com.intellij.openapi.ui; import com.intellij.icons.AllIcons; +import com.intellij.openapi.options.OptionsBundle; +import com.intellij.openapi.project.Project; import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; import com.intellij.ui.components.panels.NonOpaquePanel; @@ -35,7 +37,7 @@ import java.util.Set; class Banner extends NonOpaquePanel implements PropertyChangeListener{ private int myBannerMinHeight; private final JComponent myText = new MyText(); - + private final JLabel myProjectIcon = new JLabel(AllIcons.General.ProjectConfigurableBanner, SwingConstants.LEFT); private final NonOpaquePanel myActionsPanel = new NonOpaquePanel(new FlowLayout(FlowLayout.RIGHT, 2, 2)); private final Map myActions = new HashMap(); @@ -45,7 +47,10 @@ class Banner extends NonOpaquePanel implements PropertyChangeListener{ setBorder(new EmptyBorder(2, 6, 2, 4)); - add(myText, BorderLayout.CENTER); + myProjectIcon.setVisible(false); + myProjectIcon.setBorder(new EmptyBorder(0, 12, 0, 4)); + add(myText, BorderLayout.WEST); + add(myProjectIcon, BorderLayout.CENTER); add(myActionsPanel, BorderLayout.EAST); } @@ -112,6 +117,17 @@ class Banner extends NonOpaquePanel implements PropertyChangeListener{ repaint(); } + public void forProject(Project project) { + if (project != null) { + myProjectIcon.setVisible(true); + myProjectIcon.setText(OptionsBundle.message(project.isDefault() + ? "configurable.default.project.tooltip" + : "configurable.current.project.tooltip")); + } else { + myProjectIcon.setVisible(false); + } + } + public void setText(@NotNull final String... text) { myText.removeAll(); for (int i = 0; i < text.length; i++) { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java index 34aaa93d2741..3235533a6760 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java @@ -16,6 +16,7 @@ package com.intellij.openapi.ui; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.ui.components.panels.Wrapper; @@ -174,6 +175,9 @@ public class DetailsComponent { } } + public void forProject(Project project) { + myBannerLabel.forProject(project); + } public void setPrefix(@Nullable String... prefix) { myPrefix = prefix; diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java index 6ee4a1b947ef..07e5a93670e6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java @@ -36,6 +36,7 @@ import com.intellij.openapi.ui.*; import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.EdtRunnable; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeGlassPaneUtil; import com.intellij.ui.DocumentAdapter; @@ -366,6 +367,9 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat myOwnDetails.setContent(myContentWrapper); myOwnDetails.setBannerMinHeight(mySearchWrapper.getHeight()); myOwnDetails.setText(getBannerText(configurable)); + if (Registry.is("ide.file.settings.order.new")) { + myOwnDetails.forProject(myTree.getConfigurableProject(configurable)); + } final ConfigurableContent content = myConfigurable2Content.get(current); diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java index 5524df2bb2cb..0659d9d02a0e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java @@ -308,7 +308,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl myHandle.setOpaque(false); content.add(myHandle, BorderLayout.WEST); content.add(myComponent, BorderLayout.CENTER); - myProjectIcon = new JLabel(" ", AllIcons.General.ProjectConfigurable, SwingConstants.LEFT); + myProjectIcon = new JLabel(" ", SwingConstants.LEFT); myProjectIcon.setOpaque(true); content.add(myProjectIcon, BorderLayout.EAST); myRendererComponent.add(content, BorderLayout.CENTER); @@ -407,6 +407,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl Project project = getConfigurableProject(base); if (project != null && Registry.is("ide.file.settings.order.new")) { myProjectIcon.setBackground(selected ? getSelectionBackground() : getBackground()); + myProjectIcon.setIcon(selected ? AllIcons.General.ProjectConfigurableSelected : AllIcons.General.ProjectConfigurable); myProjectIcon.setVisible(true); tree.setToolTipText(OptionsBundle.message(project.isDefault() ? "configurable.default.project.tooltip" @@ -418,21 +419,6 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl return result; } - private Project getConfigurableProject(SimpleNode node) { - if (node == null) { - return null; - } - if (node instanceof EditorNode) { - EditorNode editor = (EditorNode)node; - Configurable configurable = editor.getConfigurable(); - if (configurable instanceof ConfigurableWrapper) { - ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable; - return wrapper.getExtensionPoint().getProject(); - } - } - return getConfigurableProject(node.getParent()); - } - protected JComponent createItemComponent() { myTextLabel = new ErrorLabel(); return myTextLabel; @@ -877,4 +863,27 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl } } + + Project getConfigurableProject(Configurable configurable) { + if (configurable instanceof ConfigurableWrapper) { + ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable; + return wrapper.getExtensionPoint().getProject(); + } + return getConfigurableProject(myConfigurable2Node.get(configurable)); + } + + private static Project getConfigurableProject(SimpleNode node) { + if (node == null) { + return null; + } + if (node instanceof EditorNode) { + EditorNode editor = (EditorNode)node; + Configurable configurable = editor.getConfigurable(); + if (configurable instanceof ConfigurableWrapper) { + ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable; + return wrapper.getExtensionPoint().getProject(); + } + } + return getConfigurableProject(node.getParent()); + } }