mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+16
-2
@@ -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);
|
||||
}
|
||||
|
||||
-46
@@ -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;
|
||||
}
|
||||
}
|
||||
+3
-8
@@ -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);
|
||||
}
|
||||
|
||||
+155
@@ -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<ArrangementSettingType, Color> myTextColors
|
||||
= new EnumMap<ArrangementSettingType, Color>(ArrangementSettingType.class);
|
||||
@NotNull private final Map<ArrangementSettingType, Color> myBackgroundColors
|
||||
= new EnumMap<ArrangementSettingType, Color>(ArrangementSettingType.class);
|
||||
@NotNull private final Map<ArrangementSettingType, Color> mySelectedTextColors
|
||||
= new EnumMap<ArrangementSettingType, Color>(ArrangementSettingType.class);
|
||||
@NotNull private final Map<ArrangementSettingType, Color> mySelectedBackgroundColors
|
||||
= new EnumMap<ArrangementSettingType, Color>(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.
|
||||
* <p/>
|
||||
* 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<ArrangementSettingType, Color> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
-76
@@ -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;
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -49,10 +49,14 @@ public class ArrangementRuleEditor extends JPanel {
|
||||
new HashMap<Object, ArrangementAtomMatchNodeComponent>();
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
+2
-2
@@ -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<Set<ArrangementMatchCondition>> 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();
|
||||
|
||||
+10
-6
@@ -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);
|
||||
|
||||
-67
@@ -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();
|
||||
}
|
||||
}
|
||||
+11
-9
@@ -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() {
|
||||
|
||||
-9
@@ -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) {
|
||||
|
||||
+7
-2
@@ -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<ArrangementMatchCondition> 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<Set<ArrangementMatchCondition>> groupingRules)
|
||||
{
|
||||
myDisplayManager = manager;
|
||||
myColorsProvider = provider;
|
||||
myRemoveConditionCallback = removeConditionCallback;
|
||||
for (Set<ArrangementMatchCondition> 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);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,6 @@
|
||||
|
||||
<applicationService serviceImplementation="com.intellij.psi.codeStyle.arrangement.engine.ArrangementEngine"/>
|
||||
<applicationService serviceImplementation="com.intellij.psi.codeStyle.arrangement.MemberOrderService"/>
|
||||
<applicationService serviceImplementation="com.intellij.application.options.codeStyle.arrangement.ArrangementColorsService"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.ui.EditorTextFieldProvider"
|
||||
serviceImplementation="com.intellij.ui.EditorTextFieldProviderImpl"/>
|
||||
|
||||
Reference in New Issue
Block a user