From f517480f33bcb73f9c3ddf6d463b6530fcb8d5d6 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 20 Mar 2017 17:04:55 +0300 Subject: [PATCH 01/10] diff: remove dead code --- .../diff/tools/simple/SimpleDiffViewer.java | 1 - .../simple/ThreesideTextDiffViewerEx.java | 1 - .../diff/util/DiffDividerDrawUtil.java | 31 ++----------------- .../com/intellij/diff/util/DiffDrawUtil.java | 7 ----- .../diff/util/DiffLineSeparatorRenderer.java | 11 ------- .../properties/SvnPropertiesDiffViewer.java | 2 +- 6 files changed, 4 insertions(+), 49 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java index 683fcd8a6f98..b6d8220062b1 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java @@ -749,7 +749,6 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { gg.setColor(DiffDrawUtil.getDividerColor(getEditor1())); gg.fill(gg.getClipBounds()); - //DividerPolygonUtil.paintSimplePolygons(gg, divider.getWidth(), getEditor1(), getEditor2(), this); DiffDividerDrawUtil.paintPolygons(gg, divider.getWidth(), getEditor1(), getEditor2(), this); myFoldingModel.paintOnDivider(gg, divider); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/ThreesideTextDiffViewerEx.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/ThreesideTextDiffViewerEx.java index 264204dcefd3..8b85d7a84a13 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/ThreesideTextDiffViewerEx.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/ThreesideTextDiffViewerEx.java @@ -399,7 +399,6 @@ public abstract class ThreesideTextDiffViewerEx extends ThreesideTextDiffViewer Editor editor1 = mySide.select(getEditor(ThreeSide.LEFT), getEditor(ThreeSide.BASE)); Editor editor2 = mySide.select(getEditor(ThreeSide.BASE), getEditor(ThreeSide.RIGHT)); - //DividerPolygonUtil.paintSimplePolygons(gg, divider.getWidth(), editor1, editor2, myPaintable); DiffDividerDrawUtil.paintPolygons(gg, divider.getWidth(), editor1, editor2, myPaintable); myFoldingModel.paintOnDivider(gg, divider, mySide); diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java index 845976dd0d1e..0ce75b9101bc 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java @@ -64,20 +64,11 @@ public class DiffDividerDrawUtil { @NotNull Editor editor1, @NotNull Editor editor2, @NotNull DividerPaintable paintable) { - paintPolygons(gg, width, true, true, editor1, editor2, paintable); - } - - public static void paintSimplePolygons(@NotNull Graphics2D gg, - int width, - @NotNull Editor editor1, - @NotNull Editor editor2, - @NotNull DividerPaintable paintable) { - paintPolygons(gg, width, true, false, editor1, editor2, paintable); + paintPolygons(gg, width, true, editor1, editor2, paintable); } public static void paintPolygons(@NotNull Graphics2D gg, int width, - boolean paintBorder, boolean curved, @NotNull Editor editor1, @NotNull Editor editor2, @@ -86,7 +77,7 @@ public class DiffDividerDrawUtil { GraphicsConfig config = GraphicsUtil.setupAAPainting(gg); for (DividerPolygon polygon : polygons) { - polygon.paint(gg, width, paintBorder, curved); + polygon.paint(gg, width, curved); } config.restore(); } @@ -160,14 +151,6 @@ public class DiffDividerDrawUtil { }; } - @NotNull - private static DividerPolygon createPolygon(@NotNull Transformation[] transformations, - int startLine1, int endLine1, - int startLine2, int endLine2, - @NotNull Color color) { - return createPolygon(transformations, startLine1, endLine1, startLine2, endLine2, color, false); - } - @NotNull private static DividerPolygon createPolygon(@NotNull Transformation[] transformations, int startLine1, int endLine1, @@ -228,10 +211,6 @@ public class DiffDividerDrawUtil { @NotNull private final Color myColor; private final boolean myResolved; - public DividerPolygon(int start1, int start2, int end1, int end2, @NotNull Color color) { - this(start1, start2, end1, end2, color, false); - } - public DividerPolygon(int start1, int start2, int end1, int end2, @NotNull Color color, boolean resolved) { myStart1 = start1; myStart2 = start2; @@ -241,7 +220,7 @@ public class DiffDividerDrawUtil { myResolved = resolved; } - public void paint(Graphics2D g, int width, boolean paintBorder, boolean curve) { + public void paint(Graphics2D g, int width, boolean curve) { int startY1; int endY1; int startY2; @@ -295,10 +274,6 @@ public class DiffDividerDrawUtil { private final int myEnd2; @Nullable private final EditorColorsScheme myScheme; - public DividerSeparator(int start1, int start2, int end1, int end2) { - this(start1, start2, end1, end2, null); - } - public DividerSeparator(int start1, int start2, int end1, int end2, @Nullable EditorColorsScheme scheme) { myStart1 = start1; myStart2 = start2; diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java index 0d448a8560eb..f44f49c35d9e 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java @@ -83,13 +83,6 @@ public class DiffDrawUtil { return gutterBackground; } - public static void drawConnectorLineSeparator(@NotNull Graphics2D g, - int x1, int x2, - int start1, int end1, - int start2, int end2) { - drawConnectorLineSeparator(g, x1, x2, start1, end1, start2, end2, null); - } - public static void drawConnectorLineSeparator(@NotNull Graphics2D g, int x1, int x2, int start1, int end1, diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java b/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java index e6d677df7588..b9c1b08b7a6d 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java @@ -40,22 +40,11 @@ public class DiffLineSeparatorRenderer implements LineMarkerRendererEx, LineSepa @NotNull private final Editor myEditor; @NotNull private final BooleanGetter myCondition; - public DiffLineSeparatorRenderer(@NotNull Editor editor) { - this(editor, BooleanGetter.TRUE); - } - public DiffLineSeparatorRenderer(@NotNull Editor editor, @NotNull BooleanGetter condition) { myEditor = editor; myCondition = condition; } - public static void drawConnectorLine(@NotNull Graphics2D g, - int x1, int x2, - int start1, int end1, - int start2, int end2) { - drawConnectorLine(g, x1, x2, start1, start2, end1 - end2, null); - } - /* * Divider */ diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/difftool/properties/SvnPropertiesDiffViewer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/difftool/properties/SvnPropertiesDiffViewer.java index 164d92a9053e..2c075edd6115 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/difftool/properties/SvnPropertiesDiffViewer.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/difftool/properties/SvnPropertiesDiffViewer.java @@ -218,7 +218,7 @@ public class SvnPropertiesDiffViewer extends TwosideTextDiffViewer { int shift2 = editor2.getScrollingModel().getVerticalScrollOffset() - headerOffset2; double rotate = shift1 == shift2 ? 0 : Math.atan2(shift2 - shift1, clip.width); - DiffDividerDrawUtil.paintPolygons(gg, divider.getWidth(), false, rotate == 0, editor1, editor2, this); + DiffDividerDrawUtil.paintPolygons(gg, divider.getWidth(), rotate == 0, editor1, editor2, this); for (DiffChange change : myDiffChanges) { int y1 = editor1.logicalPositionToXY(new LogicalPosition(change.getStartLine(Side.LEFT), 0)).y - shift1; From bbc70156d32fabac470405db0ac1c6d0976edf8f Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Thu, 11 May 2017 16:18:11 +0300 Subject: [PATCH 02/10] getCurrentCodeStyleSettings returns some meaningful CodeStyleSettings + attempt to fix flaky test --- .../SoftWrapApplianceOnDocumentModificationTest.java | 6 +++++- .../com/intellij/testFramework/LightPlatformTestCase.java | 2 -- .../src/com/intellij/testFramework/UsefulTestCase.java | 2 -- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java index 263c2b71a5a4..e9d0b5a34c1b 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java @@ -25,6 +25,7 @@ import com.intellij.openapi.editor.impl.AbstractEditorTest; import com.intellij.openapi.editor.impl.EditorImpl; import com.intellij.openapi.editor.impl.SoftWrapModelImpl; import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.fileTypes.PlainTextLanguage; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.testFramework.EditorTestUtil; import com.intellij.testFramework.TestFileType; @@ -865,7 +866,10 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorT VisualPosition caretPositionBefore = getEditor().getCaretModel().getVisualPosition(); // Change tab size. - final CommonCodeStyleSettings.IndentOptions indentOptions = getCurrentCodeStyleSettings().getIndentOptions(); + final CommonCodeStyleSettings.IndentOptions indentOptions = getCurrentCodeStyleSettings() + .getCommonSettings(PlainTextLanguage.INSTANCE) + .getIndentOptions(); + assertNotNull(indentOptions); indentOptions.TAB_SIZE++; diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index 60baf0f863fe..fd7dda38b432 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -78,7 +78,6 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFileFactory; import com.intellij.psi.PsiManager; -import com.intellij.psi.codeStyle.CodeStyleSchemes; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.psi.impl.DocumentCommitThread; @@ -607,7 +606,6 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da @NotNull @Override protected CodeStyleSettings getCurrentCodeStyleSettings() { - if (CodeStyleSchemes.getInstance().getCurrentScheme() == null) return new CodeStyleSettings(); return CodeStyleSettingsManager.getSettings(getProject()); } diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index 174d0c123fe5..747dc5ca5a39 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -35,7 +35,6 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.*; import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.codeStyle.CodeStyleSchemes; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.psi.impl.source.PostprocessReformattingAspect; @@ -296,7 +295,6 @@ public abstract class UsefulTestCase extends TestCase { @NotNull protected CodeStyleSettings getCurrentCodeStyleSettings() { - if (CodeStyleSchemes.getInstance().getCurrentScheme() == null) return new CodeStyleSettings(); return CodeStyleSettingsManager.getInstance().getCurrentSettings(); } From 6d5ab11a88aedd5ed45b439a26708d2ecaf9a265 Mon Sep 17 00:00:00 2001 From: Valentina Kiryushkina Date: Thu, 11 May 2017 15:43:09 +0300 Subject: [PATCH 03/10] Open PyCharm window on successful authorization on Stepik --- .../edu/learning/builtInServer/EduStepikRestService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduStepikRestService.java b/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduStepikRestService.java index aac88d92f170..c01ae1333352 100644 --- a/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduStepikRestService.java +++ b/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduStepikRestService.java @@ -17,9 +17,13 @@ package com.jetbrains.edu.learning.builtInServer; import com.intellij.notification.Notification; import com.intellij.notification.NotificationType; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; import com.intellij.openapi.util.io.StreamUtil; +import com.intellij.openapi.wm.IdeFrame; +import com.intellij.openapi.wm.WindowManager; +import com.intellij.ui.AppIcon; import com.jetbrains.edu.learning.StudySettings; import com.jetbrains.edu.learning.stepic.EduStepicAuthorizedClient; import com.jetbrains.edu.learning.stepic.EduStepicConnector; @@ -32,6 +36,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.ide.RestService; import org.jetbrains.io.Responses; +import javax.swing.*; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; @@ -118,6 +123,8 @@ public class EduStepikRestService extends RestService { StudySettings.getInstance().setUser(stepicUser); sendHtmlResponse(request, context, "/oauthResponsePages/okPage.html"); showStepicNotification(NotificationType.INFORMATION, "Authorized as " + stepicUser.getFirstName() + " " + stepicUser.getLastName()); + JFrame frame = WindowManager.getInstance().findVisibleFrame(); + ApplicationManager.getApplication().invokeLater(() -> AppIcon.getInstance().requestFocus((IdeFrame)frame)); return null; } } From 032713093148a3461f520764e7ce17859fefef84 Mon Sep 17 00:00:00 2001 From: Valentina Kiryushkina Date: Thu, 11 May 2017 16:46:01 +0300 Subject: [PATCH 04/10] Fix test: compress icon --- .../com/jetbrains/edu/learning/StepikOff.png | Bin 16024 -> 170 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/python/educational-core/resources/icons/com/jetbrains/edu/learning/StepikOff.png b/python/educational-core/resources/icons/com/jetbrains/edu/learning/StepikOff.png index 33f04f53a9dabb6274716f7b70a1d1fed549ac8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zA~q#1F(2TSxBw8bDRGJU0I$RafQU_rOUws&B`yF&Y)V{WKENw+0U%;i;u7-#UWp3; z5t|a1m=EwuTmXpJ6yn-h{gIP+^xvB^`Zvw5s!yKLzj!M4{!t&Hi}w-w<~xM`TG0FN z2%YH&{c#^5>qms%_J8>Lx7!F^Q4V@HkLM+H?aI@?ON#{!eTnM|%Po~kg%Uv!Wa_2I zj~{Quu;NJ%pa7Q$lh%Zoz$-99kjz3C)W4RJ_kcRyq@L%z_tB$AiFtZ@$~Uv;q$jKg z34^6~Be@_k6Jk9{z-+|9g1b`{5@m9 z#*--WmEbUVo5m*$G67z6ZT!q3>PaHNR@stjw(=6eY|NlC^W{qy_8=b$iz-N5OJ+t6 zkz4DzItu_-?#tqH0T!4w(nl7U2Sb~SOE(h@c;SmySuBD-@woqVbe*Xj+`7~I`IGzK F{sZL3iCO>v From c16ab09b1bd55a2bbfae93c79e13c981b405695d Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Thu, 11 May 2017 16:54:18 +0300 Subject: [PATCH 05/10] IDEA-172571 IntelliJ IDEA won't start on Mac OS Sierra --- platform/util/src/com/intellij/util/ui/JBUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/ui/JBUI.java b/platform/util/src/com/intellij/util/ui/JBUI.java index a288d5ce4a66..fb02c4ba7141 100644 --- a/platform/util/src/com/intellij/util/ui/JBUI.java +++ b/platform/util/src/com/intellij/util/ui/JBUI.java @@ -184,7 +184,7 @@ public class JBUI { try { gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); } catch (HeadlessException ignore) {} - if (gd != null) { + if (gd != null && gd.getDefaultConfiguration() != null) { return sysScale(gd.getDefaultConfiguration()); } return 1.0f; From 829b5717921bc200b85404e05d252e9a78e57074 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Thu, 11 May 2017 15:42:17 +0200 Subject: [PATCH 06/10] IG: save intention changes in inspection profile (IDEA-172134) --- .../src/com/siyeh/ig/psiutils/MethodMatcher.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodMatcher.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodMatcher.java index 1a4b24437484..7469d56660a3 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodMatcher.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * 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. @@ -17,6 +17,7 @@ package com.siyeh.ig.psiutils; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; +import com.intellij.profile.codeInspection.ProjectInspectionProfileManager; import com.intellij.psi.PsiCall; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiMethod; @@ -97,6 +98,7 @@ public class MethodMatcher { } myMethodNamePatterns.set(index, pattern + '|' + methodName); } + ProjectInspectionProfileManager.getInstance(method.getProject()).fireProfileChanged(); } @NotNull From 7a3862b309874953d1cae4bb6bd2e0a621d91b0c Mon Sep 17 00:00:00 2001 From: Kirill Kirichenko Date: Thu, 11 May 2017 17:40:05 +0300 Subject: [PATCH 07/10] IDEA-171869 Win10 LAF ComboBox and PasswordField completed --- .../InspectionsConfigTreeTable.java | 72 +-- .../intellij/ui/components/OnOffButton.java | 6 +- .../ide/ui/laf/darcula/DarculaUIUtil.java | 26 + .../ui/laf/darcula/ui/DarculaButtonUI.java | 12 +- .../ui/laf/darcula/ui/DarculaComboBoxUI.java | 6 +- .../ui/laf/icons/win10/comboDropTriangle.png | Bin 113 -> 15106 bytes .../laf/icons/win10/comboDropTriangle@2x.png | Bin 155 -> 15227 bytes .../icons/win10/comboDropTriangleDisabled.png | Bin 112 -> 15106 bytes .../win10/comboDropTriangleDisabled@2x.png | Bin 155 -> 15230 bytes .../laf/intellij/WinIntelliJComboBoxUI.java | 479 ++++++++++++++++-- .../intellij/WinIntelliJPasswordFieldUI.java | 93 ++++ .../laf/intellij/WinIntelliJTextFieldUI.java | 61 ++- .../ide/ui/laf/intellijlaf_native.properties | 13 +- .../ui/NotificationsConfigurablePanel.java | 3 + .../src/com/intellij/ui/EditorTextField.java | 59 ++- 15 files changed, 705 insertions(+), 125 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJPasswordFieldUI.java diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java index 9fc13c174e21..8f0291b669e4 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java @@ -115,45 +115,49 @@ public class InspectionsConfigTreeTable extends TreeTable { addMouseMotionListener(new MouseAdapter() { @Override public void mouseMoved(final MouseEvent e) { - Point point = e.getPoint(); - int column = columnAtPoint(point); - int row = rowAtPoint(point); + Point point = e.getPoint(); + int column = columnAtPoint(point); + int row = rowAtPoint(point); - UIUtil.resetEnabledRollOver(InspectionsConfigTreeTable.this, IS_ENABLED_COLUMN); + if (row < 0 || row >= getModel().getRowCount()) return; - switch (column) { - case SEVERITIES_COLUMN: - Object maybeIcon = getModel().getValueAt(row, column); - if (maybeIcon instanceof MultiScopeSeverityIcon) { - MultiScopeSeverityIcon icon = (MultiScopeSeverityIcon)maybeIcon; - LinkedHashMap scopeToAverageSeverityMap = - icon.getScopeToAverageSeverityMap(); - JComponent component; - if (scopeToAverageSeverityMap.size() == 1 && - icon.getDefaultScopeName().equals(ContainerUtil.getFirstItem(scopeToAverageSeverityMap.keySet()))) { - HighlightDisplayLevel level = ContainerUtil.getFirstItem(scopeToAverageSeverityMap.values()); - JLabel label = new JLabel(); - label.setIcon(level.getIcon()); - label.setText(SingleInspectionProfilePanel.renderSeverity(level.getSeverity())); - component = label; - } else { - component = new ScopesAndSeveritiesHintTable(scopeToAverageSeverityMap, icon.getDefaultScopeName()); + UIUtil.resetEnabledRollOver(InspectionsConfigTreeTable.this, IS_ENABLED_COLUMN); + + switch (column) { + case SEVERITIES_COLUMN: + Object maybeIcon = getModel().getValueAt(row, column); + if (maybeIcon instanceof MultiScopeSeverityIcon) { + MultiScopeSeverityIcon icon = (MultiScopeSeverityIcon)maybeIcon; + LinkedHashMap scopeToAverageSeverityMap = + icon.getScopeToAverageSeverityMap(); + JComponent component = null; + if (scopeToAverageSeverityMap.size() == 1 && + icon.getDefaultScopeName().equals(ContainerUtil.getFirstItem(scopeToAverageSeverityMap.keySet()))) { + HighlightDisplayLevel level = ContainerUtil.getFirstItem(scopeToAverageSeverityMap.values()); + if (level != null) { + JLabel label = new JLabel(); + label.setIcon(level.getIcon()); + label.setText(SingleInspectionProfilePanel.renderSeverity(level.getSeverity())); + component = label; + } + } else { + component = new ScopesAndSeveritiesHintTable(scopeToAverageSeverityMap, icon.getDefaultScopeName()); + } + IdeTooltipManager.getInstance().show( + new IdeTooltip(InspectionsConfigTreeTable.this, point, component), false); } - IdeTooltipManager.getInstance().show( - new IdeTooltip(InspectionsConfigTreeTable.this, point, component), false); - } - break; + break; - case IS_ENABLED_COLUMN: - if (Registry.is("ide.intellij.laf.win10.ui")) { - JComponent rc = (JComponent)getColumnModel().getColumn(column).getCellRenderer(); - rc.putClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY, row); - ((AbstractTableModel)getModel()).fireTableCellUpdated(row, column); - } - break; + case IS_ENABLED_COLUMN: + if (Registry.is("ide.intellij.laf.win10.ui")) { + JComponent rc = (JComponent)getColumnModel().getColumn(column).getCellRenderer(); + rc.putClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY, row); + ((AbstractTableModel)getModel()).fireTableCellUpdated(row, column); + } + break; - default: break; - } + default: break; + } } }); diff --git a/platform/platform-api/src/com/intellij/ui/components/OnOffButton.java b/platform/platform-api/src/com/intellij/ui/components/OnOffButton.java index b45ff761abc0..b61e2bd6d8ca 100644 --- a/platform/platform-api/src/com/intellij/ui/components/OnOffButton.java +++ b/platform/platform-api/src/com/intellij/ui/components/OnOffButton.java @@ -61,7 +61,11 @@ public class OnOffButton extends JToggleButton { } @Override public void updateUI() { - setUI(UIManager.get(getUIClassID()) == null ? + // Check that class name is in the UI table before creating UI delegate from it. + // If the custom class name is not listed (like for example in system LaFs) then + // use the default delegate. + Object uiClassName = UIManager.get(getUIClassID()); + setUI(uiClassName == null ? DefaultOnOffButtonUI.createUI(this) : UIManager.getUI(this)); } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaUIUtil.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaUIUtil.java index 151e37118a13..bd3b1a59ca57 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaUIUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaUIUtil.java @@ -36,6 +36,8 @@ import javax.swing.text.JTextComponent; import javax.swing.text.Position; import java.awt.*; import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.awt.geom.Path2D; import java.awt.geom.Rectangle2D; import java.util.Arrays; @@ -341,4 +343,28 @@ public class DarculaUIUtil { return false; } + + public static class MouseHoverPropertyTrigger extends MouseAdapter { + private final JComponent repaintComponent; + private final String hoverProperty; + + public MouseHoverPropertyTrigger(@NotNull JComponent repaintComponent, @NotNull String hoverProperty) { + this.repaintComponent = repaintComponent; + this.hoverProperty = hoverProperty; + } + + @Override + public void mouseEntered(MouseEvent e) { + JComponent c = (JComponent)e.getComponent(); + c.putClientProperty(hoverProperty, Boolean.TRUE); + repaintComponent.repaint(); + } + + @Override + public void mouseExited(MouseEvent e) { + JComponent c = (JComponent)e.getComponent(); + c.putClientProperty(hoverProperty, Boolean.FALSE); + repaintComponent.repaint(); + } + } } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java index e894d66a72ed..eb0ed7a5c92b 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java @@ -23,6 +23,7 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.components.JBOptionButton; import com.intellij.util.ObjectUtils; import com.intellij.util.ui.GraphicsUtil; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import sun.swing.SwingUtilities2; @@ -241,14 +242,11 @@ public class DarculaButtonUI extends BasicButtonUI { } protected String layout(AbstractButton b, String text, Icon icon, FontMetrics fm, int width, int height) { - Insets i = b.getInsets(); - viewRect.x = i.left; - viewRect.y = i.top; - viewRect.width = width - (i.right + viewRect.x); - viewRect.height = height - (i.bottom + viewRect.y); + textRect.setBounds(0, 0, 0, 0); + iconRect.setBounds(0, 0, 0, 0); - textRect.x = textRect.y = textRect.width = textRect.height = 0; - iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; + viewRect.setBounds(0, 0, width, height); + JBInsets.removeFrom(viewRect, b.getInsets()); if (isComboButton(b)) { viewRect.x += 6; diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java index 6111dcfc16a5..57eef96c30a6 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java @@ -332,7 +332,6 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB Graphics2D g2 = (Graphics2D)g.create(); try { - hasFocus = false; checkFocus(); final Rectangle arrowButtonBounds = arrowButton.getBounds(); @@ -395,6 +394,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB } protected void checkFocus() { + hasFocus = false; if (!comboBox.isEnabled()) { hasFocus = false; return; @@ -403,7 +403,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB hasFocus = hasFocus(comboBox); if (hasFocus) return; - final ComboBoxEditor ed = comboBox.getEditor(); + ComboBoxEditor ed = comboBox.getEditor(); editor = ed == null ? null : ed.getEditorComponent(); if (editor != null) { hasFocus = hasFocus(editor); @@ -411,7 +411,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB } protected static boolean hasFocus(Component c) { - final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); return owner != null && SwingUtilities.isDescendingFrom(owner, c); } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/icons/win10/comboDropTriangle.png b/platform/platform-impl/src/com/intellij/ide/ui/laf/icons/win10/comboDropTriangle.png index db1bcc06598d002b06860461dc49e8e7153cd7af..b84e6d3b2825d78578324931b09561fa17d7a6d0 100644 GIT binary patch literal 15106 zcmeI3&2QX96u>70S{mr36>7w#mQy59@%m$9$7}6w)n;1~!Imgl)bzx9?eWISuI<`R zcasBzazGrAXit0{;2+=s7bFfG5Pt&_LLw&+Z~y@k;#9`=emHM8qX>$)jHT7ioA>4U z&3j{C{N~#A=T6T(IfoEBy}D9cC;!R##G@w=ntAKbOKU_p6|CHh5PIxv@|!{LeK3zu z>1VgG8E@8KFf6}YFm1nu3;k|DtPv_->IbH^jb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#YN_Wc_}Uo2-&2#$b2v_#f1SO zn-mwB59Xz~Fd$@;;v)0Gyc8D(gltk=WImXe;=+KCO^S=m2lG-~7!a~aagq68UWy9? zLN+NbG9S!KabZBnCJ~pf^$905(07{^^nvDl5meE~os2p(mH}Yy0RWC11K{^t=>H}F zGduu4X91930^nZr`6oUcMBk74hts>ptKa2vJ3-fj+peCOpZ^hkRtj$2I(o1t>+e9f z=)V8Od^Vf?3jNmA8ge;gPVVg7>-YPkC;R?Xj_z1k{}(du+tky8K0S3rPM_;XeA%AP zx2|rZ-Zw`I~_JbGhaC_Qc^mYTrKk)UL?R|SL_g0?jd%Hh3 z@dkV0kFyuwIsVX-uXVn8+2>#Q^wl4>6s9^pJ{Ri#oa#Agd@udO=y+?8tA2OF;a=KpAV jU2o^>n@)Vo)Cb%N&fZ907&=^C?@VBL_elCufA;9#t-*#_ delta 140 zcmV;70CWHTcAEi^7k?B81^@s6jfou%0001DNkl*SV5cpfl#lQlVQ+in1^+D#A{v u3frM-Y=xSz6>7p}^a|FaJna8Na~Y$|?~cg@K&1cx002ovP6b4+LSTZEBs(Vn diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJComboBoxUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJComboBoxUI.java index 0c9c120e3a81..3019c2f28821 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJComboBoxUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJComboBoxUI.java @@ -17,88 +17,400 @@ package com.intellij.ide.ui.laf.intellij; import com.intellij.ide.ui.laf.darcula.DarculaUIUtil; import com.intellij.ide.ui.laf.darcula.ui.DarculaComboBoxUI; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.util.registry.Registry; -import com.intellij.ui.Gray; +import com.intellij.ui.EditorTextField; import com.intellij.util.IconUtil; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.UIUtil; import javax.swing.*; +import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicArrowButton; +import javax.swing.plaf.basic.BasicComboBoxEditor; +import javax.swing.text.JTextComponent; import java.awt.*; +import java.awt.event.*; +import java.awt.geom.Path2D; +import java.awt.geom.Rectangle2D; +import java.beans.PropertyChangeListener; /** * @author Konstantin Bulenkov */ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI { + private static final String HOVER_PROPERTY = "JComboBox.mouseHover"; + private static final String PRESSED_PROPERTY = "JComboBox.mousePressed"; + + private static final Border DEFAULT_EDITOR_BORDER = JBUI.Borders.empty(1, 0); + private static final Dimension BUTTON_SIZE = JBUI.size(20, 22); + + private MouseListener mouseListener; + + private MouseListener buttonReleaseListener; + private MouseListener buttonHoverListener; + private PropertyChangeListener propertyListener; + + private MouseListener editorHoverListener; + private KeyListener editorKeyListener; + private FocusListener editorFocusListener; + public WinIntelliJComboBoxUI(JComboBox comboBox) { super(comboBox); } - @SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"}) public static ComponentUI createUI(JComponent c) { return new WinIntelliJComboBoxUI((JComboBox)c); } - @Override - public void paint(Graphics g, JComponent c) { - final int w = c.getWidth(); - final int h = c.getHeight(); + @Override protected void installListeners() { + super.installListeners(); + + if (!comboBox.isEditable()) { + comboBox.addMouseListener(mouseListener = new ComboBoxMouseListener()); + } + + propertyListener = (evt) -> { + if("enabled".equals(evt.getPropertyName())) { + setEditorTextFieldBackground(); + } else if ("editable".equals(evt.getPropertyName())) { + if (evt.getNewValue() == Boolean.TRUE) { + comboBox.removeMouseListener(mouseListener); + } else { + comboBox.addMouseListener(mouseListener); + } + } + }; + + comboBox.addPropertyChangeListener(propertyListener); + } + + @Override public void uninstallListeners() { + super.uninstallListeners(); + comboBox.removeMouseListener(mouseListener); + + if (propertyListener != null) { + comboBox.removePropertyChangeListener(propertyListener); + propertyListener = null; + } + } + + @Override public void paint(Graphics g, JComponent c) { + int w = c.getWidth(); + int h = c.getHeight(); if (c.isOpaque()) { - final Container parent = c.getParent(); + Container parent = c.getParent(); if (parent != null) { g.setColor(isTableCellEditor(c) && editor != null ? editor.getBackground() : parent.getBackground()); g.fillRect(0, 0, c.getWidth(), c.getHeight()); } } - Rectangle r = rectangleForCurrentValue(); + + int bw = JBUI.scale(1); + g.setColor(getComboBackground()); - g.fillRect(JBUI.scale(1), JBUI.scale(1), w-2*JBUI.scale(1), h-2*JBUI.scale(1)); + g.fillRect(bw, bw, w-2*bw, h-2*bw); + if (!isTableCellEditor(c)) { paintBorder(c, g, 0, 0, w, h); hasFocus = comboBox.hasFocus(); - paintCurrentValueBackground(g, r, hasFocus); } - paintCurrentValue(g, r, hasFocus); + + if (!comboBox.isEditable()) { + Rectangle r = rectangleForCurrentValue(); + paintCurrentValue(g, r, hasFocus); + } } - protected Color getComboBackground() { - if (!comboBox.isEnabled() && !comboBox.isEditable()) { - return UIManager.getColor("ComboBox.disabledBackground"); + @Override protected Rectangle rectangleForCurrentValue() { + int width = comboBox.getWidth(); + int height = comboBox.getHeight(); + Insets insets = getInsets(); + int buttonSize = height - (insets.top + insets.bottom); + if ( arrowButton != null ) { + buttonSize = arrowButton.getWidth(); } - if (comboBox.isEditable()) { - final ComboBoxEditor editor = comboBox.getEditor(); - if (editor != null && editor.getEditorComponent() != null) { - return editor.getEditorComponent().getBackground(); - } else { - return Gray.xFF; + + Rectangle rect = (comboBox.getComponentOrientation().isLeftToRight()) ? + new Rectangle(insets.left, insets.top, + width - (insets.left + insets.right + buttonSize), + height - (insets.top + insets.bottom)) : + new Rectangle(insets.left + buttonSize, insets.top, + width - (insets.left + insets.right + buttonSize), + height - (insets.top + insets.bottom)); + + if (editor instanceof JComponent) { + JBInsets.removeFrom(rect, ((JComponent)editor).getInsets()); + } + + return rect; + } + + + public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { + @SuppressWarnings("unchecked") + ListCellRenderer renderer = comboBox.getRenderer(); + Component c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false); + + c.setBackground(getComboBackground()); + c.setFont(comboBox.getFont()); + c.setForeground(comboBox.isEnabled() ? UIManager.getColor("Label.foreground") : UIManager.getColor("Label.disabledForeground")); + + // paint selection in table-cell-editor mode correctly + boolean changeOpaque = c instanceof JComponent && isTableCellEditor(comboBox) && c.isOpaque(); + if (changeOpaque) { + ((JComponent)c).setOpaque(false); + } + + Rectangle r = new Rectangle(bounds); + Insets i = UIManager.getInsets("ComboBox.padding"); + if (i == null && c instanceof JComponent) { + i = ((JComponent)c).getInsets(); + } + + JBInsets.removeFrom(r, i); + + currentValuePane.paintComponent(g, c, comboBox, r.x, r.y, r.width, r.height, c instanceof JPanel); + + // return opaque for combobox popup items painting + if (changeOpaque) { + ((JComponent)c).setOpaque(true); + } + } + + private Color getComboBackground() { + if (comboBox.isEnabled() && comboBox.isEditable()) { + return UIManager.getColor("TextField.background"); + } else if (!comboBox.isEnabled()) { + return UIManager.getColor("Button.background"); + } else if (!comboBox.isEditable()) { + if (isPressed()) { + return UIManager.getColor("Button.intellij.native.pressedBackgroundColor"); + } else if (isHover()) { + return UIManager.getColor("Button.intellij.native.focusedBackgroundColor"); } } - return comboBox.getBackground(); + return UIManager.getColor("Button.background"); } @Override protected JButton createArrowButton() { - final JButton button = new BasicArrowButton(SwingConstants.SOUTH) { + JButton button = new BasicArrowButton(SwingConstants.SOUTH) { @Override public Dimension getPreferredSize() { - return JBUI.size(14, 10); + return BUTTON_SIZE; } @Override public void paint(Graphics g) { - g.setColor(getComboBackground()); - g.fillRect(0, 0, getWidth(), getHeight()); - IconUtil.paintInCenterOf(this, g, MacIntelliJIconCache.getIcon("comboDropTriangle", false, false, isEnabled())); + Graphics2D g2 = (Graphics2D)g.create(); + try { + int bw = JBUI.scale(1); + + Rectangle2D innerRect = new Rectangle2D.Double(bw, bw, getWidth() - bw*2, getHeight() - bw*2); + if (comboBox.isEditable() && comboBox.isEnabled()) { + if (isPressed()) { + g2.setColor(UIManager.getColor("Button.intellij.native.pressedBackgroundColor")); + } else if (comboBox.hasFocus() || isHover()) { + g2.setColor(UIManager.getColor("Button.intellij.native.focusedBackgroundColor")); + } else { + g2.setColor(getComboBackground()); + } + } else { + g2.setColor(getComboBackground()); + } + + if (!comboBox.isEnabled()) { + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f)); + } + + g2.fill(innerRect); + + // paint border around button when combobox is editable + if (comboBox.isEditable() && comboBox.isEnabled()) { + Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD); + border.append(new Rectangle2D.Double(0, 0, getWidth(), getHeight()), false); + border.append(innerRect, false); + + if (getModel().isPressed()) { + g2.setColor(UIManager.getColor("Button.intellij.native.pressedBorderColor")); + g2.fill(border); + } else if (comboBox.hasFocus() || isHover()) { + g2.setColor(UIManager.getColor("Button.intellij.native.focusedBorderColor")); + g2.fill(border); + } + } + + IconUtil.paintInCenterOf(this, g2, MacIntelliJIconCache.getIcon("comboDropTriangle", false, false, isEnabled())); + } finally { + g2.dispose(); + } } }; + button.setOpaque(false); - button.setBorder(JBUI.Borders.empty()); + button.setBorder(JBUI.Borders.empty(1, 0, 1, 1)); + buttonReleaseListener = new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + if (!comboBox.isEditable()) { + comboBox.repaint(); + } + } + }; + + buttonHoverListener = new DarculaUIUtil.MouseHoverPropertyTrigger(comboBox, HOVER_PROPERTY); + + button.addMouseListener(buttonHoverListener); + button.addMouseListener(buttonReleaseListener); return button; } + @Override public void unconfigureArrowButton() { + super.unconfigureArrowButton(); + if (arrowButton != null) { + arrowButton.removeMouseListener(buttonReleaseListener); + arrowButton.removeMouseListener(buttonHoverListener); + } + } + + + @Override + protected ComboBoxEditor createEditor() { + ComboBoxEditor comboBoxEditor = new BasicComboBoxEditor.UIResource() { + @Override + protected JTextField createEditorComponent() { + return new JTextField() { + { + setOpaque(false); + setBorder(DEFAULT_EDITOR_BORDER); + } + + public void setText(String s) { + if (getText().equals(s)) { + return; + } + super.setText(s); + } + + @Override public Color getBackground() { + return getComboBackground(); + } + @Override public void setBorder(Border border) {} + @Override public Border getBorder() { + return DEFAULT_EDITOR_BORDER; + } + + @Override + public Dimension getPreferredSize() { + Dimension size = super.getPreferredSize(); + return new Dimension(size.width, BUTTON_SIZE.height); + } + }; + } + }; + + Component ec = comboBoxEditor.getEditorComponent(); + if (ec != null) { + editorKeyListener = new KeyAdapter() { + @Override public void keyPressed(KeyEvent e) { + process(e); + } + @Override public void keyReleased(KeyEvent e) { + process(e); + } + + private void process(KeyEvent e) { + int code = e.getKeyCode(); + if ((code == KeyEvent.VK_UP || code == KeyEvent.VK_DOWN) && e.getModifiers() == 0) { + comboBox.dispatchEvent(e); + } + } + }; + + ec.addKeyListener(editorKeyListener); + } + return comboBoxEditor; + } + + @Override protected void configureEditor() { + if (editor != null) { + editorFocusListener = new FocusAdapter() { + @Override public void focusGained(FocusEvent e) { + update(); + } + @Override public void focusLost(FocusEvent e) { + update(); + } + + private void update() { + if (comboBox != null) { + comboBox.repaint(); + } + } + }; + + editorHoverListener = new DarculaUIUtil.MouseHoverPropertyTrigger(comboBox, HOVER_PROPERTY); + + if (editor instanceof JTextComponent) { + editor.addFocusListener(editorFocusListener); + editor.addMouseListener(editorHoverListener); + } else { + EditorTextField etf = UIUtil.findComponentOfType((JComponent)editor, EditorTextField.class); + if (etf != null) { + etf.addFocusListener(editorFocusListener); + etf.addMouseListener(editorHoverListener); + } + } + + ((JComponent)editor).setBorder(DEFAULT_EDITOR_BORDER); + ((JComponent)editor).setOpaque(false); + + setEditorTextFieldBackground(); + } + } + + private void setEditorTextFieldBackground() { + EditorTextField etf = UIUtil.findComponentOfType((JComponent)editor, EditorTextField.class); + if (etf != null && comboBox.isEditable()) { + etf.setBackground(getComboBackground()); + } + } + + @Override protected void unconfigureEditor() { + super.unconfigureEditor(); + + if (editorKeyListener != null) { + editor.removeKeyListener(editorKeyListener); + } + + if (editor instanceof JTextComponent) { + if (editorFocusListener != null) { + editor.removeFocusListener(editorFocusListener); + } + + if (editorHoverListener != null) { + editor.removeMouseListener(editorHoverListener); + } + } else { + EditorTextField etf = UIUtil.findComponentOfType((JComponent)editor, EditorTextField.class); + if (etf != null) { + if (editorHoverListener != null) { + etf.removeFocusListener(editorFocusListener); + } + + if (editorHoverListener != null) { + etf.removeMouseListener(editorHoverListener); + } + } + } + } + + @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (comboBox == null || arrowButton == null) { @@ -107,28 +419,119 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI { Graphics2D g2 = (Graphics2D)g.create(); try { - hasFocus = false; checkFocus(); - Object eop = ((JComponent)c).getClientProperty("JComponent.error.outline"); - if (Registry.is("ide.inplace.errors.outline") && Boolean.parseBoolean(String.valueOf(eop))) { - g2.translate(x, y); + g2.translate(x, y); + + if (Registry.is("ide.inplace.errors.outline") && comboBox.getClientProperty("JComponent.error.outline") == Boolean.TRUE) { DarculaUIUtil.paintErrorBorder(g2, width, height, 0, true, hasFocus); - } else if (hasFocus) { - g2.setColor(UIManager.getColor("ComboBox.activeBorderColor")); - g2.setStroke(new BasicStroke(JBUI.scale(2f))); + } else if (comboBox.isEnabled()) { + if (comboBox.isEditable()) { + if (hasFocus) { + g2.setColor(UIManager.getColor("TextField.focusedBorderColor")); + } else { + g2.setColor(UIManager.getColor(isEditorHover() ? "TextField.hoverBorderColor" : "TextField.borderColor")); + } + } else { + if (isPressed()) { + g2.setColor(UIManager.getColor("Button.intellij.native.pressedBorderColor")); + } else if (isHover() || hasFocus) { + g2.setColor(UIManager.getColor("Button.intellij.native.focusedBorderColor")); + } else { + g2.setColor(UIManager.getColor("Button.intellij.native.borderColor")); + } + } } else { - g2.setColor(UIManager.getColor("ComboBox.borderColor")); + g2.setColor(UIManager.getColor("Button.intellij.native.borderColor")); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f)); } - g2.translate(x, y); - g2.drawRect(JBUI.scale(1), JBUI.scale(1), width-2*JBUI.scale(1), height-2*JBUI.scale(1)); + + int bw = JBUI.scale(1); + Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD); + border.append(new Rectangle2D.Double(0, 0, width, height), false); + border.append(new Rectangle2D.Double(bw, bw, width - bw*2, height - bw*2), false); + g2.fill(border); } finally { g2.dispose(); } } + private boolean isHover() { + return comboBox != null && comboBox.getClientProperty(HOVER_PROPERTY) == Boolean.TRUE || + arrowButton != null && arrowButton.getClientProperty(HOVER_PROPERTY) == Boolean.TRUE; + } + + private boolean isEditorHover() { + JComponent ec = (JComponent)comboBox.getEditor().getEditorComponent(); + EditorTextField etf = UIUtil.findComponentOfType((JComponent)editor, EditorTextField.class); + Editor editor = etf != null ? etf.getEditor() : null; + + return arrowButton != null && arrowButton.getClientProperty(HOVER_PROPERTY) == Boolean.TRUE || + ec != null && ec.getClientProperty(HOVER_PROPERTY) == Boolean.TRUE || + editor != null && editor.getContentComponent().getClientProperty(HOVER_PROPERTY) == Boolean.TRUE; + } + + private boolean isPressed() { + return comboBox != null && comboBox.getClientProperty(PRESSED_PROPERTY) == Boolean.TRUE || + arrowButton != null && arrowButton.getModel().isPressed(); + } + @Override protected Insets getInsets() { - return JBUI.insets(4, 5).asUIResource(); + return JBUI.insets(0, 5, 0, 0).asUIResource(); + } + + @Override + public Insets getBorderInsets(Component c) { + return getInsets(); + } + + private Dimension getSizeWithIcon(Dimension d) { + Insets i = comboBox.getInsets(); + int iconWidth = BUTTON_SIZE.width + i.right; + int iconHeight = BUTTON_SIZE.height + i.top + i.bottom; + return new Dimension(Math.max(d.width + 7, iconWidth), iconHeight); + } + + @Override + public Dimension getPreferredSize(JComponent c) { + return getSizeWithIcon(super.getPreferredSize(c)); + } + + @Override + public Dimension getMinimumSize(JComponent c) { + return getSizeWithIcon(super.getMinimumSize(c)); + } + + private class ComboBoxMouseListener extends MouseAdapter { + @Override public void mousePressed(MouseEvent e) { + setPressedProperty(true); + } + + @Override public void mouseReleased(MouseEvent e) { + setPressedProperty(false); + } + + private void setPressedProperty(boolean isPressed) { + if (!comboBox.isEditable()) { + comboBox.putClientProperty(PRESSED_PROPERTY, Boolean.valueOf(isPressed)); + comboBox.repaint(); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + setHoverProperty(true); + } + + @Override + public void mouseExited(MouseEvent e) { + setHoverProperty(false); + } + + private void setHoverProperty(boolean isHover) { + comboBox.putClientProperty(HOVER_PROPERTY, Boolean.valueOf(isHover)); + comboBox.repaint(); + } } } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJPasswordFieldUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJPasswordFieldUI.java new file mode 100644 index 000000000000..b631ce15e227 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJPasswordFieldUI.java @@ -0,0 +1,93 @@ +/* + * 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. + */ +package com.intellij.ide.ui.laf.intellij; + +import com.intellij.ide.ui.laf.darcula.DarculaUIUtil; + +import javax.swing.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicPasswordFieldUI; +import javax.swing.text.JTextComponent; +import java.awt.*; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseListener; + +import static com.intellij.ide.ui.laf.intellij.WinIntelliJTextFieldUI.HOVER_PROPERTY; + +public class WinIntelliJPasswordFieldUI extends BasicPasswordFieldUI { + + private final JPasswordField passwordField; + private MouseListener hoverListener; + private FocusListener focusListener; + + public WinIntelliJPasswordFieldUI(JPasswordField passwordField) { + this.passwordField = passwordField; + } + + @SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"}) + public static ComponentUI createUI(JComponent c) { + return new WinIntelliJPasswordFieldUI((JPasswordField)c); + } + + @Override public void installListeners() { + super.installListeners(); + hoverListener = new DarculaUIUtil.MouseHoverPropertyTrigger(passwordField, HOVER_PROPERTY); + focusListener = new FocusListener() { + @Override public void focusGained(FocusEvent e) { + passwordField.repaint(); + } + + @Override public void focusLost(FocusEvent e) { + passwordField.repaint(); + } + }; + + passwordField.addMouseListener(hoverListener); + passwordField.addFocusListener(focusListener); + } + + @Override public void uninstallListeners() { + super.uninstallListeners(); + if (hoverListener != null) { + passwordField.removeMouseListener(hoverListener); + } + + if (focusListener != null) { + passwordField.removeFocusListener(focusListener); + } + } + + @Override + protected void paintBackground(Graphics g) { + JTextComponent c = getComponent(); + + Graphics2D g2 = (Graphics2D)g.create(); + try { + Container parent = c.getParent(); + if (c.isOpaque() && parent != null) { + g2.setColor(parent.getBackground()); + g2.fillRect(0, 0, c.getWidth(), c.getHeight()); + } + + if (c.getBorder() instanceof WinIntelliJTextBorder){ + WinIntelliJTextFieldUI.paintTextFieldBackground(c, g2); + } + } finally { + g2.dispose(); + } + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJTextFieldUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJTextFieldUI.java index 797eae885d90..eb7d3e3273e7 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJTextFieldUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/WinIntelliJTextFieldUI.java @@ -15,15 +15,16 @@ */ package com.intellij.ide.ui.laf.intellij; +import com.intellij.ide.ui.laf.darcula.DarculaUIUtil; import com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI; import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.UIUtil; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.text.JTextComponent; import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; /** * @author Konstantin Bulenkov @@ -31,38 +32,38 @@ import java.awt.event.MouseEvent; public class WinIntelliJTextFieldUI extends DarculaTextFieldUI { public static final String HOVER_PROPERTY = "JTextField.hover"; + private MouseListener hoverListener; + public WinIntelliJTextFieldUI(JTextField textField) { super(textField); } - @SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"}) + @SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"}) public static ComponentUI createUI(JComponent c) { - c.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - JComponent c = (JComponent)e.getComponent(); - c.putClientProperty(HOVER_PROPERTY, Boolean.TRUE); - c.repaint(); - } - - @Override - public void mouseExited(MouseEvent e) { - JComponent c = (JComponent)e.getComponent(); - c.putClientProperty(HOVER_PROPERTY, Boolean.FALSE); - c.repaint(); - } - }); - return new WinIntelliJTextFieldUI((JTextField)c); } + @Override public void installListeners() { + super.installListeners(); + hoverListener = new DarculaUIUtil.MouseHoverPropertyTrigger(myTextField, HOVER_PROPERTY); + myTextField.addMouseListener(hoverListener); + } + + @Override public void uninstallListeners() { + super.uninstallListeners(); + if (hoverListener != null) { + myTextField.removeMouseListener(hoverListener); + } + } + @Override protected void paintBackground(Graphics g) { + JTextComponent c = getComponent(); + if (UIUtil.getParentOfType(JComboBox.class, c) != null) return; + Graphics2D g2 = (Graphics2D)g.create(); try { - JTextComponent c = getComponent(); Container parent = c.getParent(); - if (c.isOpaque() && parent != null) { g2.setColor(parent.getBackground()); g2.fillRect(0, 0, c.getWidth(), c.getHeight()); @@ -71,17 +72,25 @@ public class WinIntelliJTextFieldUI extends DarculaTextFieldUI { if (isSearchField(c)) { Rectangle r = getDrawingRect(); paintSearchField(g2, c, r); - } else { - g2.setColor(c.isEnabled() ? c.getBackground() : UIManager.getColor("Button.background")); - - int bw = JBUI.scale(1); - g2.fillRect(bw, bw, c.getWidth() - bw*2, c.getHeight() - bw*2); + } else if (c.getBorder() instanceof WinIntelliJTextBorder){ + paintTextFieldBackground(c, g2); } } finally { g2.dispose(); } } + static void paintTextFieldBackground(JComponent c, Graphics2D g2) { + g2.setColor(c.isEnabled() ? c.getBackground() : UIManager.getColor("Button.background")); + + if (!c.isEnabled()) { + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f)); + } + + int bw = JBUI.scale(1); + g2.fillRect(bw, bw, c.getWidth() - bw*2, c.getHeight() - bw*2); + } + @Override public Dimension getPreferredSize(JComponent c) { Dimension size = super.getPreferredSize(c); size.height = isSearchField(c) ? size.height : JBUI.scale(22); diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_native.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_native.properties index a4f9c59c0b11..0e29df9553d8 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_native.properties +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_native.properties @@ -71,8 +71,8 @@ TextArea.selectionForeground=ffffff TextArea.background=ffffff PasswordField.background=ffffff -PasswordFieldUI=com.intellij.ide.ui.laf.darcula.ui.DarculaPasswordFieldUI -PasswordField.border=com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder +PasswordFieldUI=com.intellij.ide.ui.laf.intellij.WinIntelliJPasswordFieldUI +PasswordField.border=com.intellij.ide.ui.laf.intellij.WinIntelliJTextBorder ProgressBarUI=com.intellij.ide.ui.laf.darcula.ui.DarculaProgressBarUI ProgressBar.border=com.intellij.ide.ui.laf.darcula.ui.DarculaProgressBarBorder @@ -80,8 +80,8 @@ ProgressBar.foreground=808080 FormattedTextField.background=ffffff - CheckBoxUI=com.intellij.ide.ui.laf.intellij.WinIntelliJCheckBoxUI +CheckBox.disabledText=8a8a8a CheckBox.border=com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxBorder CheckBox.darcula.inactiveFillColor=00000000 CheckBox.darcula.borderColor1=444444 @@ -110,13 +110,6 @@ CheckBox.darcula.focused.backgroundColor2=eeeeee CheckBox.darcula.focused.backgroundColor2.selected=3B98FB ComboBoxUI=com.intellij.ide.ui.laf.intellij.WinIntelliJComboBoxUI -ComboBox.disabledBackground=e1e1e1 -ComboBox.squareButton=false -ComboBox.borderColor=adadad -ComboBox.activeBorderColor=0078d7 -ComboBox.background=ffffff -ComboBox.darcula.arrowFillColor=457dd7 -ComboBox.darcula.arrowFocusedFillColor=2d82ed RadioButtonUI=com.intellij.ide.ui.laf.intellij.WinIntelliJRadioButtonUI RadioButton.disabledText=8a8a8a diff --git a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java index 57715d76f42c..31c069595118 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java @@ -272,7 +272,10 @@ public class NotificationsConfigurablePanel extends JPanel implements Disposable int column = columnAtPoint(point); int row = rowAtPoint(point); + if (row < 0 || row >= getModel().getRowCount()) return; + UIUtil.resetEnabledRollOver(NotificationsTreeTable.this, LOG_COLUMN); + if (column == LOG_COLUMN) { JComponent rc = (JComponent)getColumnModel().getColumn(column).getCellRenderer(); rc.putClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY, row); diff --git a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java index 76539e010a9f..b38ce446ff41 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java +++ b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java @@ -58,10 +58,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; +import java.awt.event.*; import java.util.ArrayList; import java.util.List; @@ -69,7 +66,7 @@ import java.util.List; * @author max */ public class EditorTextField extends NonOpaquePanel implements DocumentListener, TextComponent, DataProvider, - DocumentBasedComponent, FocusListener { + DocumentBasedComponent, FocusListener, MouseListener { private static final Logger LOG = Logger.getInstance("#com.intellij.ui.EditorTextField"); public static final Key SUPPLEMENTARY_KEY = Key.create("Supplementary"); @@ -81,6 +78,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener, private boolean myWholeTextSelected; private final List myDocumentListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private final List myFocusListeners = ContainerUtil.createLockFreeCopyOnWriteList(); + private final List myMouseListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private boolean myIsListenerInstalled; private boolean myIsViewer; private boolean myIsSupplementary; @@ -395,6 +393,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener, remove(editor.getComponent()); editor.getContentComponent().removeFocusListener(this); + editor.getContentComponent().removeMouseListener(this); if (!editor.isDisposed()) { EditorFactory.getInstance().releaseEditor(editor); @@ -511,7 +510,8 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener, editor.putUserData(SUPPLEMENTARY_KEY, myIsSupplementary); editor.getContentComponent().setFocusCycleRoot(false); editor.getContentComponent().addFocusListener(this); - + editor.getContentComponent().addMouseListener(this); + editor.setPlaceholder(myHintText); initOneLineMode(editor); @@ -777,6 +777,53 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener, } } + @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod") + @Override + public void addMouseListener(MouseListener l) { + myMouseListeners.add(l); + } + + @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod") + @Override + public void removeMouseListener(MouseListener l) { + myMouseListeners.remove(l); + } + + @Override + public void mouseClicked(MouseEvent e) { + for (MouseListener listener : myMouseListeners) { + listener.mouseClicked(e); + } + } + + @Override + public void mousePressed(MouseEvent e) { + for (MouseListener listener : myMouseListeners) { + listener.mousePressed(e); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + for (MouseListener listener : myMouseListeners) { + listener.mouseReleased(e); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + for (MouseListener listener : myMouseListeners) { + listener.mouseEntered(e); + } + } + + @Override + public void mouseExited(MouseEvent e) { + for (MouseListener listener : myMouseListeners) { + listener.mouseExited(e); + } + } + @Override public Object getData(String dataId) { if (myEditor != null && myEditor.isRendererMode()) { From e7d32d45fcbde48f60a47eff0edc12748572aa71 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Thu, 11 May 2017 13:45:19 +0300 Subject: [PATCH 08/10] add new in 2017.2 --- .../FrequentlyUsedInheritorInspection.html | 1 + 1 file changed, 1 insertion(+) diff --git a/resources-en/src/inspectionDescriptions/FrequentlyUsedInheritorInspection.html b/resources-en/src/inspectionDescriptions/FrequentlyUsedInheritorInspection.html index 0cb923eb642c..f9fd4585da4b 100644 --- a/resources-en/src/inspectionDescriptions/FrequentlyUsedInheritorInspection.html +++ b/resources-en/src/inspectionDescriptions/FrequentlyUsedInheritorInspection.html @@ -3,5 +3,6 @@ The inspection finds commonly used class/interface that could be extended/implemented instead of extending too broad interface or class. The inspection works only if a project is built using IntelliJ IDEA build system and a super class is located inside project source files. +

New in 2017.2 \ No newline at end of file From 21db96b0e9b60df0037efa31ab8f740fdbe4ee96 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Thu, 11 May 2017 14:14:14 +0300 Subject: [PATCH 09/10] frequently used super class inspection: rename "ok" -> "remove" in quickfix dialog --- .../inspection/ChangeSuperClassFix.java | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/inspection/ChangeSuperClassFix.java b/java/compiler/impl/src/com/intellij/compiler/inspection/ChangeSuperClassFix.java index 60f7acb9146f..8831d772c5ad 100644 --- a/java/compiler/impl/src/com/intellij/compiler/inspection/ChangeSuperClassFix.java +++ b/java/compiler/impl/src/com/intellij/compiler/inspection/ChangeSuperClassFix.java @@ -22,7 +22,7 @@ import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.DialogBuilder; +import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; @@ -35,6 +35,7 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; +import javax.swing.*; import java.util.Collections; import java.util.List; import java.util.Set; @@ -168,7 +169,7 @@ public class ChangeSuperClassFix implements LocalQuickFix, HighPriorityAction { return !newSupers.equals(m.getSecond()); }).map(m -> m.getFirst()); - List toDelete = getOverridenMethodsToDelete(memberInfos, newSuperClass.getName()); + List toDelete = getOverridenMethodsToDelete(memberInfos, newSuperClass.getName(), aClass.getProject()); WriteAction.run(() -> { for (PsiMethod method : toDelete) { method.delete(); @@ -182,16 +183,29 @@ public class ChangeSuperClassFix implements LocalQuickFix, HighPriorityAction { } @NotNull - private static List getOverridenMethodsToDelete(Stream candidates, String newClassName) { - DialogBuilder dlg = new DialogBuilder(); - MemberSelectionPanel panel = new MemberSelectionPanel("Choose members to delete since they are already defined in " + newClassName + "", - candidates.map(m -> { - MemberInfo info = new MemberInfo(m); - info.setChecked(true); - return info; - }).collect(Collectors.toList()), null); - dlg.setCenterPanel(panel); - dlg.setTitle("Choose Members"); + private static List getOverridenMethodsToDelete(Stream candidates, + String newClassName, + Project project) { + MemberSelectionPanel panel = + new MemberSelectionPanel("Choose members to delete since they are already defined in " + newClassName + "", + candidates.map(m -> { + MemberInfo info = new MemberInfo(m); + info.setChecked(true); + return info; + }).collect(Collectors.toList()), null); + DialogWrapper dlg = new DialogWrapper(project, false) { + + { + setOKButtonText("Remove"); + setTitle("Choose Members"); + } + @NotNull + @Override + protected JComponent createCenterPanel() { + + return panel; + } + }; return dlg.showAndGet() ? panel.getTable().getSelectedMemberInfos().stream().map(info -> (PsiMethod)info.getMember()).collect(Collectors.toList()) : Collections.emptyList(); From 2fd794b883b7a12dbd34613e9682aab3ae0f44ea Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Thu, 11 May 2017 14:40:04 +0300 Subject: [PATCH 10/10] frequently used super class inspection: fix npe when classes has the same method not defined in base class --- .../inspection/ChangeSuperClassFix.java | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/inspection/ChangeSuperClassFix.java b/java/compiler/impl/src/com/intellij/compiler/inspection/ChangeSuperClassFix.java index 8831d772c5ad..a7638061e1cc 100644 --- a/java/compiler/impl/src/com/intellij/compiler/inspection/ChangeSuperClassFix.java +++ b/java/compiler/impl/src/com/intellij/compiler/inspection/ChangeSuperClassFix.java @@ -26,7 +26,6 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; -import com.intellij.psi.impl.source.PsiExtensibleClass; import com.intellij.refactoring.ui.MemberSelectionPanel; import com.intellij.refactoring.util.classMembers.MemberInfo; import com.intellij.util.ArrayUtil; @@ -38,6 +37,7 @@ import org.jetbrains.annotations.TestOnly; import javax.swing.*; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -116,15 +116,15 @@ public class ChangeSuperClassFix implements LocalQuickFix, HighPriorityAction { private static void changeSuperClass(@NotNull final PsiClass aClass, @NotNull final PsiClass oldSuperClass, @NotNull final PsiClass newSuperClass) { - List ownMethods = ((PsiExtensibleClass)aClass).getOwnMethods(); + PsiMethod[] ownMethods = aClass.getMethods(); // first is own method, second is parent List>> oldOverridenMethods = - ownMethods.stream().map(m -> { + Stream.of(ownMethods).map(m -> { if (m.isConstructor()) return null; PsiMethod[] supers = m.findSuperMethods(oldSuperClass); if (supers.length == 0) return null; return Pair.create(m, ContainerUtil.set(supers)); - }).collect(Collectors.toList()); + }).filter(Objects::nonNull).collect(Collectors.toList()); JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(aClass.getProject()); PsiElementFactory factory = psiFacade.getElementFactory(); @@ -160,21 +160,28 @@ public class ChangeSuperClassFix implements LocalQuickFix, HighPriorityAction { JavaCodeStyleManager.getInstance(aClass.getProject()).shortenClassReferences(ref); }); - if (ownMethods.isEmpty()) { - // should not override methods from a new super class - return; - } - Stream memberInfos = oldOverridenMethods.stream().filter(m -> { + List memberInfos = oldOverridenMethods.stream().filter(m -> { Set newSupers = ContainerUtil.set(m.getFirst().findSuperMethods(newSuperClass)); return !newSupers.equals(m.getSecond()); - }).map(m -> m.getFirst()); + }).map(m -> m.getFirst()) + .map(m -> { + MemberInfo info = new MemberInfo(m); + info.setChecked(true); + return info; + }).collect(Collectors.toList()); + + if (memberInfos.isEmpty()) { + return; + } List toDelete = getOverridenMethodsToDelete(memberInfos, newSuperClass.getName(), aClass.getProject()); - WriteAction.run(() -> { - for (PsiMethod method : toDelete) { - method.delete(); - } - }); + if (!toDelete.isEmpty()) { + WriteAction.run(() -> { + for (PsiMethod method : toDelete) { + method.delete(); + } + }); + } } @NotNull @@ -183,26 +190,23 @@ public class ChangeSuperClassFix implements LocalQuickFix, HighPriorityAction { } @NotNull - private static List getOverridenMethodsToDelete(Stream candidates, + private static List getOverridenMethodsToDelete(List candidates, String newClassName, Project project) { MemberSelectionPanel panel = new MemberSelectionPanel("Choose members to delete since they are already defined in " + newClassName + "", - candidates.map(m -> { - MemberInfo info = new MemberInfo(m); - info.setChecked(true); - return info; - }).collect(Collectors.toList()), null); + candidates, + null); DialogWrapper dlg = new DialogWrapper(project, false) { { setOKButtonText("Remove"); setTitle("Choose Members"); + init(); } @NotNull @Override protected JComponent createCenterPanel() { - return panel; } };