From 852220e716e411bb0b6809aa5f3fb86ec0748acb Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Thu, 25 Oct 2012 17:52:11 +0400 Subject: [PATCH] IDEA-19061 Integrate the Rearranger-plugin into core-IDE Allow rearrangers to customize colors used at the settings UI --- .../settings/ArrangementColorsAware.java | 18 +- .../AbstractArrangementColorsProvider.java | 46 ------ .../ArrangementColorsProvider.java | 11 +- .../ArrangementColorsProviderImpl.java | 155 ++++++++++++++++++ .../arrangement/ArrangementColorsService.java | 76 --------- .../arrangement/ArrangementRuleEditor.java | 8 +- .../arrangement/ArrangementRuleTree.java | 4 +- .../arrangement/ArrangementSettingsPanel.java | 16 +- .../DefaultArrangementColorsProvider.java | 67 -------- .../ArrangementAtomMatchNodeComponent.java | 20 ++- ...ArrangementGroupingMatchNodeComponent.java | 9 - .../ArrangementMatchNodeComponentFactory.java | 9 +- .../src/META-INF/LangExtensions.xml | 1 - 13 files changed, 210 insertions(+), 230 deletions(-) delete mode 100644 platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/AbstractArrangementColorsProvider.java create mode 100644 platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProviderImpl.java delete mode 100644 platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsService.java delete mode 100644 platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/DefaultArrangementColorsProvider.java diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/settings/ArrangementColorsAware.java b/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/settings/ArrangementColorsAware.java index 8935573ca0f3..8884a845a6d3 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/settings/ArrangementColorsAware.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/settings/ArrangementColorsAware.java @@ -15,13 +15,27 @@ */ package com.intellij.psi.codeStyle.arrangement.settings; +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.psi.codeStyle.arrangement.model.ArrangementSettingType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; + /** - * Strategy which hints on what colors should be used at arrangement setting UI. + * Callback which allows to customize colors used at the arrangement UI on the basis of existing coloring scheme. * * @author Denis Zhdanov * @since 10/23/12 11:53 PM */ public interface ArrangementColorsAware { - // TODO den implement + @Nullable + TextAttributesKey getTextKey(@NotNull ArrangementSettingType type, boolean selected); + + @Nullable + TextAttributesKey getTextBackgroundKey(@NotNull ArrangementSettingType type, boolean selected); + + @Nullable + Color getBorderColor(boolean selected); } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/AbstractArrangementColorsProvider.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/AbstractArrangementColorsProvider.java deleted file mode 100644 index ae79c9c8e6a0..000000000000 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/AbstractArrangementColorsProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2000-2012 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. - */ -package com.intellij.application.options.codeStyle.arrangement; - -import com.intellij.ui.GroupedElementsRenderer; -import com.intellij.util.ui.UIUtil; -import org.jetbrains.annotations.NotNull; - -import java.awt.*; - -/** - * @author Denis Zhdanov - * @since 10/23/12 11:47 PM - */ -public abstract class AbstractArrangementColorsProvider implements ArrangementColorsProvider { - - @NotNull private Color myNormalBorderColor; - @NotNull private Color mySelectedBorderColor; - - @NotNull - public Color getBorderColor(boolean selected) { - return selected ? mySelectedBorderColor : myNormalBorderColor; - } - - public void updateColors() { - myNormalBorderColor = UIUtil.getBorderColor(); - Color selectionBorderColor = UIUtil.getTreeSelectionBorderColor(); - if (selectionBorderColor == null) { - selectionBorderColor = GroupedElementsRenderer.SELECTED_FRAME_FOREGROUND; - } - mySelectedBorderColor = selectionBorderColor; - } -} diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProvider.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProvider.java index 5a9d29c7b06b..117bc1b8c409 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProvider.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProvider.java @@ -25,18 +25,13 @@ import java.awt.*; * @since 10/23/12 11:46 PM */ public interface ArrangementColorsProvider { + @NotNull Color getBorderColor(boolean selected); @NotNull - Color getTextColor(@NotNull ArrangementSettingType type); + Color getTextColor(@NotNull ArrangementSettingType type, boolean selected); @NotNull - Color getTextBackgroundColor(@NotNull ArrangementSettingType type); - - @NotNull - Color getSelectedTextColor(@NotNull ArrangementSettingType type); - - @NotNull - Color getSelectedTextBackgroundColor(@NotNull ArrangementSettingType type); + Color getTextBackgroundColor(@NotNull ArrangementSettingType type, boolean selected); } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProviderImpl.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProviderImpl.java new file mode 100644 index 000000000000..9b1858692ae3 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProviderImpl.java @@ -0,0 +1,155 @@ +/* + * Copyright 2000-2012 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. + */ +package com.intellij.application.options.codeStyle.arrangement; + +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.psi.codeStyle.arrangement.model.ArrangementSettingType; +import com.intellij.psi.codeStyle.arrangement.settings.ArrangementColorsAware; +import com.intellij.ui.GroupedElementsRenderer; +import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.util.EnumMap; +import java.util.Map; + +/** + * @author Denis Zhdanov + * @since 10/24/12 4:25 PM + */ +public class ArrangementColorsProviderImpl implements ArrangementColorsProvider { + + @Nullable private final ArrangementColorsAware myColorsAware; + + @NotNull private final Map myTextColors + = new EnumMap(ArrangementSettingType.class); + @NotNull private final Map myBackgroundColors + = new EnumMap(ArrangementSettingType.class); + @NotNull private final Map mySelectedTextColors + = new EnumMap(ArrangementSettingType.class); + @NotNull private final Map mySelectedBackgroundColors + = new EnumMap(ArrangementSettingType.class); + + @NotNull private Color myBorderColor; + @NotNull private Color mySelectedBorderColor; + + public ArrangementColorsProviderImpl(@Nullable ArrangementColorsAware colorsAware) { + myColorsAware = colorsAware; + applyDefaultColors(); + if (colorsAware != null) { + applyCustomColors(colorsAware); + } + } + + @NotNull + @Override + public Color getBorderColor(boolean selected) { + return selected ? myBorderColor : mySelectedBorderColor; + } + + @NotNull + @Override + public Color getTextColor(@NotNull ArrangementSettingType type, boolean selected) { + return selected ? mySelectedTextColors.get(type) : myTextColors.get(type); + } + + @NotNull + @Override + public Color getTextBackgroundColor(@NotNull ArrangementSettingType type, boolean selected) { + return selected ? mySelectedBackgroundColors.get(type) : myBackgroundColors.get(type); + } + + /** + * Asks the implementation to ensure that it uses the most up-to-date colors. + *

+ * I.e. this method is assumed to be called when color settings has been changed and gives a chance to reflect the changes + * accordingly. + */ + public void refresh() { + if (myColorsAware == null) { + return; + } + + myTextColors.clear(); + myBackgroundColors.clear(); + mySelectedTextColors.clear(); + mySelectedBackgroundColors.clear(); + + applyDefaultColors(); + applyCustomColors(myColorsAware); + } + + private void applyDefaultColors() { + Color textColor = UIUtil.getTreeTextForeground(); + Color selectedTextColor = UIUtil.getTreeSelectionForeground(); + Color backgroundColor = UIUtil.getPanelBackground(); + Color selectedBackgroundColor = UIUtil.getTreeSelectionBackground(); + for (ArrangementSettingType type : ArrangementSettingType.values()) { + myTextColors.put(type, textColor); + mySelectedTextColors.put(type, selectedTextColor); + myBackgroundColors.put(type, backgroundColor); + mySelectedBackgroundColors.put(type, selectedBackgroundColor); + } + + myBorderColor = UIUtil.getBorderColor(); + Color selectionBorderColor = UIUtil.getTreeSelectionBorderColor(); + if (selectionBorderColor == null) { + selectionBorderColor = GroupedElementsRenderer.SELECTED_FRAME_FOREGROUND; + } + mySelectedBorderColor = selectionBorderColor; + } + + private void applyCustomColors(@NotNull ArrangementColorsAware colorsAware) { + EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); + for (ArrangementSettingType type : ArrangementSettingType.values()) { + applyColorIfPossible(scheme, colorsAware.getTextKey(type, false), type, myTextColors); + applyColorIfPossible(scheme, colorsAware.getTextKey(type, true), type, mySelectedTextColors); + applyColorIfPossible(scheme, colorsAware.getTextBackgroundKey(type, false), type, myBackgroundColors); + applyColorIfPossible(scheme, colorsAware.getTextBackgroundKey(type, true), type, mySelectedBackgroundColors); + } + + Color borderColor = colorsAware.getBorderColor(false); + if (borderColor != null) { + myBorderColor = borderColor; + } + Color selectedBorderColor = colorsAware.getBorderColor(true); + if (selectedBorderColor != null) { + mySelectedBorderColor = selectedBorderColor; + } + } + + private static void applyColorIfPossible(@NotNull EditorColorsScheme scheme, + @Nullable TextAttributesKey key, + @NotNull ArrangementSettingType type, + @NotNull Map holder) + { + if (key == null) { + return; + } + TextAttributes attributes = scheme.getAttributes(key); + if (attributes == null) { + return; + } + Color color = attributes.getForegroundColor(); + if (color != null) { + holder.put(type, color); + } + } +} diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsService.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsService.java deleted file mode 100644 index f7d2bb280b62..000000000000 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsService.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2000-2012 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. - */ -package com.intellij.application.options.codeStyle.arrangement; - -import com.intellij.ide.ui.LafManager; -import com.intellij.ide.ui.LafManagerListener; -import com.intellij.ui.GroupedElementsRenderer; -import com.intellij.util.ui.UIUtil; -import org.jetbrains.annotations.NotNull; - -import java.awt.*; - -/** - * @author Denis Zhdanov - * @since 9/6/12 2:30 PM - */ -public class ArrangementColorsService { - - @NotNull private Color myNormalTextColor; - @NotNull private Color mySelectedTextColor; - @NotNull private Color myNormalBackgroundColor; - @NotNull private Color mySelectedBackgroundColor; - @NotNull private Color myNormalBorderColor; - @NotNull private Color mySelectedBorderColor; - - public ArrangementColorsService(@NotNull LafManager lafManager) { - lafManager.addLafManagerListener(new LafManagerListener() { - @Override - public void lookAndFeelChanged(LafManager source) { - updateColors(); - } - }); - updateColors(); - } - - @NotNull - public Color getTextColor(boolean selected) { - return selected ? mySelectedTextColor : myNormalTextColor; - } - - @NotNull - public Color getBackgroundColor(boolean selected) { - return selected ? mySelectedBackgroundColor : myNormalBackgroundColor; - } - - @NotNull - public Color getBorderColor(boolean selected) { - return selected ? mySelectedBorderColor : myNormalBorderColor; - } - - private void updateColors() { - myNormalTextColor = UIUtil.getTreeTextForeground(); - mySelectedTextColor = UIUtil.getTreeSelectionForeground(); - myNormalBackgroundColor = UIUtil.getPanelBackground(); - mySelectedBackgroundColor = UIUtil.getTreeSelectionBackground(); - myNormalBorderColor = UIUtil.getBorderColor(); - Color selectionBorderColor = UIUtil.getTreeSelectionBorderColor(); - if (selectionBorderColor == null) { - selectionBorderColor = GroupedElementsRenderer.SELECTED_FRAME_FOREGROUND; - } - mySelectedBorderColor = selectionBorderColor; - } -} diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementRuleEditor.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementRuleEditor.java index 3768fab1eeef..ae81b35468ff 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementRuleEditor.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementRuleEditor.java @@ -49,10 +49,14 @@ public class ArrangementRuleEditor extends JPanel { new HashMap(); @NotNull private final ArrangementStandardSettingsAware myFilter; + @NotNull private final ArrangementColorsProvider myColorsProvider; @Nullable private ArrangementRuleEditingModel myModel; - public ArrangementRuleEditor(@NotNull ArrangementStandardSettingsAware filter, @NotNull ArrangementNodeDisplayManager displayManager) { + public ArrangementRuleEditor(@NotNull ArrangementStandardSettingsAware filter, + @NotNull ArrangementColorsProvider provider, + @NotNull ArrangementNodeDisplayManager displayManager) { myFilter = filter; + myColorsProvider = provider; init(displayManager); addMouseListener(new MouseAdapter() { @Override @@ -82,7 +86,7 @@ public class ArrangementRuleEditor extends JPanel { JPanel valuesPanel = new MultiRowFlowPanel(FlowLayout.LEFT, 8, 5); for (Object value : manager.sort(values)) { ArrangementAtomMatchNodeComponent component = - new ArrangementAtomMatchNodeComponent(manager, new ArrangementAtomMatchCondition(key, value), null); + new ArrangementAtomMatchNodeComponent(manager, myColorsProvider, new ArrangementAtomMatchCondition(key, value), null); myComponents.put(value, component); valuesPanel.add(component.getUiComponent()); } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementRuleTree.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementRuleTree.java index 38d8b5c2c725..afc042f73807 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementRuleTree.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementRuleTree.java @@ -42,7 +42,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; -import javax.swing.plaf.TreeUI; import javax.swing.tree.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -92,10 +91,11 @@ public class ArrangementRuleTree { public ArrangementRuleTree(@Nullable StdArrangementSettings settings, @NotNull List> uiGroupingRules, @NotNull ArrangementNodeDisplayManager displayManager, + @NotNull ArrangementColorsProvider colorsProvider, @NotNull ArrangementStandardSettingsAware settingsFilter) { myUiGroupingRules = uiGroupingRules; - myFactory = new ArrangementMatchNodeComponentFactory(displayManager, new Runnable() { + myFactory = new ArrangementMatchNodeComponentFactory(displayManager, colorsProvider, new Runnable() { @Override public void run() { notifySelectionListeners(); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementSettingsPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementSettingsPanel.java index 51fb899b95b0..e72d642e24a0 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementSettingsPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementSettingsPanel.java @@ -32,10 +32,7 @@ import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.arrangement.Rearranger; import com.intellij.psi.codeStyle.arrangement.StdArrangementSettings; import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition; -import com.intellij.psi.codeStyle.arrangement.settings.ArrangementConditionsGrouper; -import com.intellij.psi.codeStyle.arrangement.settings.ArrangementStandardSettingsAware; -import com.intellij.psi.codeStyle.arrangement.settings.ArrangementStandardSettingsRepresentationAware; -import com.intellij.psi.codeStyle.arrangement.settings.DefaultArrangementSettingsRepresentationManager; +import com.intellij.psi.codeStyle.arrangement.settings.*; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.SideBorder; import com.intellij.ui.components.JBScrollPane; @@ -94,6 +91,13 @@ public abstract class ArrangementSettingsPanel extends CodeStyleAbstractPanel { final ArrangementNodeDisplayManager displayManager = new ArrangementNodeDisplayManager( mySettingsAware, representationManager, groupingRules ); + final ArrangementColorsProvider colorsProvider; + if (rearranger instanceof ArrangementColorsAware) { + colorsProvider = new ArrangementColorsProviderImpl((ArrangementColorsAware)rearranger); + } + else { + colorsProvider = new ArrangementColorsProviderImpl(null); + } final ActionManager actionManager = ActionManager.getInstance(); final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(ArrangementConstants.ACTION_GROUP_RULE_EDITOR_TOOL_WINDOW); @@ -103,7 +107,7 @@ public abstract class ArrangementSettingsPanel extends CodeStyleAbstractPanel { toolbarControl.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.TOP | SideBorder.RIGHT)); myContent.add(toolbarControl, new GridBag().weightx(1).fillCellHorizontally().coverLine()); - myRuleTree = new ArrangementRuleTree(getSettings(settings), groupingRules, displayManager, mySettingsAware); + myRuleTree = new ArrangementRuleTree(getSettings(settings), groupingRules, displayManager, colorsProvider, mySettingsAware); final Tree treeComponent = myRuleTree.getTreeComponent(); actionToolbar.setTargetComponent(treeComponent); JBScrollPane scrollPane = new JBScrollPane(treeComponent); @@ -113,7 +117,7 @@ public abstract class ArrangementSettingsPanel extends CodeStyleAbstractPanel { ); final JXTaskPane editorPane = new JXTaskPane(ApplicationBundle.message("arrangement.title.editor")); - final ArrangementRuleEditor ruleEditor = new ArrangementRuleEditor(mySettingsAware, displayManager); + final ArrangementRuleEditor ruleEditor = new ArrangementRuleEditor(mySettingsAware, colorsProvider, displayManager); ruleEditor.applyBackground(treeComponent.getBackground()); editorPane.getContentPane().setBackground(treeComponent.getBackground()); editorPane.add(ruleEditor); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/DefaultArrangementColorsProvider.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/DefaultArrangementColorsProvider.java deleted file mode 100644 index 5a19c477973b..000000000000 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/DefaultArrangementColorsProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2000-2012 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. - */ -package com.intellij.application.options.codeStyle.arrangement; - -import com.intellij.psi.codeStyle.arrangement.model.ArrangementSettingType; -import com.intellij.util.ui.UIUtil; -import org.jetbrains.annotations.NotNull; - -import java.awt.*; - -/** - * @author Denis Zhdanov - * @since 10/23/12 11:50 PM - */ -public class DefaultArrangementColorsProvider extends AbstractArrangementColorsProvider { - - @NotNull private Color myNormalTextColor; - @NotNull private Color mySelectedTextColor; - @NotNull private Color myNormalBackgroundColor; - @NotNull private Color mySelectedBackgroundColor; - - @NotNull - @Override - public Color getTextColor(@NotNull ArrangementSettingType type) { - return myNormalTextColor; - } - - @NotNull - @Override - public Color getTextBackgroundColor(@NotNull ArrangementSettingType type) { - return myNormalBackgroundColor; - } - - @NotNull - @Override - public Color getSelectedTextColor(@NotNull ArrangementSettingType type) { - return mySelectedTextColor; - } - - @NotNull - @Override - public Color getSelectedTextBackgroundColor(@NotNull ArrangementSettingType type) { - return mySelectedBackgroundColor; - } - - @Override - public void updateColors() { - super.updateColors(); - myNormalTextColor = UIUtil.getTreeTextForeground(); - mySelectedTextColor = UIUtil.getTreeSelectionForeground(); - myNormalBackgroundColor = UIUtil.getPanelBackground(); - mySelectedBackgroundColor = UIUtil.getTreeSelectionBackground(); - } -} diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementAtomMatchNodeComponent.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementAtomMatchNodeComponent.java index deb96ee2c09a..ca55456b1b61 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementAtomMatchNodeComponent.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementAtomMatchNodeComponent.java @@ -43,8 +43,6 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo public static final int VERTICAL_PADDING = 2; public static final int HORIZONTAL_PADDING = 8; - @NotNull private final ArrangementColorsService myColorsService = ServiceManager.getService(ArrangementColorsService.class); - @NotNull private final JPanel myRenderer = new JPanel(new GridBagLayout()) { @Override public void paint(Graphics g) { @@ -77,11 +75,13 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo return myLabelSize == null ? super.getPreferredSize() : myLabelSize; } }; - @NotNull private final RoundedLineBorder myBorder; - @NotNull private final ArrangementAtomMatchCondition myCondition; - @Nullable private final ActionButton myCloseButton; - @Nullable private final Runnable myCloseCallback; + @NotNull private final ArrangementColorsProvider myColorsProvider; + @NotNull private final RoundedLineBorder myBorder; + @NotNull private final ArrangementAtomMatchCondition myCondition; + + @Nullable private final ActionButton myCloseButton; + @Nullable private final Runnable myCloseCallback; @NotNull private Color myBackgroundColor; @@ -93,9 +93,11 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo private boolean myCloseButtonHovered; public ArrangementAtomMatchNodeComponent(@NotNull ArrangementNodeDisplayManager manager, + @NotNull ArrangementColorsProvider colorsProvider, @NotNull ArrangementAtomMatchCondition condition, @Nullable Runnable closeCallback) { + myColorsProvider = colorsProvider; myCondition = condition; myCloseCallback = closeCallback; myLabel.setHorizontalAlignment(SwingConstants.CENTER); @@ -186,9 +188,9 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo * @param selected flag that indicates if current component should be drawn as 'selected' */ public void setSelected(boolean selected) { - myLabel.setForeground(myColorsService.getTextColor(selected)); - myBorder.setColor(myColorsService.getBorderColor(selected)); - myBackgroundColor = myColorsService.getBackgroundColor(selected); + myLabel.setForeground(myColorsProvider.getTextColor(myCondition.getType(), selected)); + myBorder.setColor(myColorsProvider.getBorderColor(selected)); + myBackgroundColor = myColorsProvider.getTextBackgroundColor(myCondition.getType(), selected); } public boolean isEnabled() { diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementGroupingMatchNodeComponent.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementGroupingMatchNodeComponent.java index 4d76c007e4b6..ecef8af22361 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementGroupingMatchNodeComponent.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementGroupingMatchNodeComponent.java @@ -15,10 +15,8 @@ */ package com.intellij.application.options.codeStyle.arrangement.node.match; -import com.intellij.application.options.codeStyle.arrangement.ArrangementColorsService; import com.intellij.application.options.codeStyle.arrangement.ArrangementConfigUtil; import com.intellij.application.options.codeStyle.arrangement.ArrangementNodeDisplayManager; -import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition; import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition; @@ -40,12 +38,10 @@ public class ArrangementGroupingMatchNodeComponent extends JPanel implements Arr private static final int TOP_INSET = 3; - @NotNull private final ArrangementColorsService myColorsService = ServiceManager.getService(ArrangementColorsService.class); @NotNull private final ArrangementAtomMatchCondition myCondition; @Nullable private Rectangle myScreenBounds; @NotNull private Dimension myPreferredSize; - private boolean mySelected; public ArrangementGroupingMatchNodeComponent(@NotNull ArrangementNodeDisplayManager manager, @NotNull ArrangementAtomMatchCondition condition) @@ -104,7 +100,6 @@ public class ArrangementGroupingMatchNodeComponent extends JPanel implements Arr @Override public void setSelected(boolean selected) { - mySelected = selected; } @Nullable @@ -126,10 +121,6 @@ public class ArrangementGroupingMatchNodeComponent extends JPanel implements Arr int y = TOP_INSET; g.drawLine(cornerX, y, bounds.width, y); g.drawLine(cornerX, y, cornerX, y + bounds.height); - if (mySelected) { - g.setColor(myColorsService.getBackgroundColor(true)); - g.fillRect(cornerX + 1, y + 1, bounds.width - 1, bounds.height - 1); - } Point point = ArrangementConfigUtil.getLocationOnScreen(this); if (point != null) { diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementMatchNodeComponentFactory.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementMatchNodeComponentFactory.java index 72542769a6c5..6fb7e6b6a9a0 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementMatchNodeComponentFactory.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementMatchNodeComponentFactory.java @@ -15,6 +15,7 @@ */ package com.intellij.application.options.codeStyle.arrangement.node.match; +import com.intellij.application.options.codeStyle.arrangement.ArrangementColorsProvider; import com.intellij.application.options.codeStyle.arrangement.ArrangementNodeDisplayManager; import com.intellij.application.options.codeStyle.arrangement.ArrangementRuleEditingModel; import com.intellij.openapi.util.Ref; @@ -37,13 +38,15 @@ public class ArrangementMatchNodeComponentFactory { @NotNull private final Set myGroupingConditions = ContainerUtilRt.newHashSet(); @NotNull private final ArrangementNodeDisplayManager myDisplayManager; + @NotNull private final ArrangementColorsProvider myColorsProvider; @NotNull private final Runnable myRemoveConditionCallback; public ArrangementMatchNodeComponentFactory(@NotNull ArrangementNodeDisplayManager manager, - @NotNull Runnable removeConditionCallback, + @NotNull ArrangementColorsProvider provider, @NotNull Runnable removeConditionCallback, @NotNull List> groupingRules) { myDisplayManager = manager; + myColorsProvider = provider; myRemoveConditionCallback = removeConditionCallback; for (Set rules : groupingRules) { myGroupingConditions.addAll(rules); @@ -63,7 +66,9 @@ public class ArrangementMatchNodeComponentFactory { component = new ArrangementGroupingMatchNodeComponent(myDisplayManager, condition); } else { - component = new ArrangementAtomMatchNodeComponent(myDisplayManager, condition, prepareRemoveCallback(condition, model)); + component = new ArrangementAtomMatchNodeComponent( + myDisplayManager, myColorsProvider, condition, prepareRemoveCallback(condition, model) + ); } ref.set(component); } diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index fbba86501d4e..9c0e12d04f60 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -185,7 +185,6 @@ -