diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/DispreferImplementationsWeigher.java b/java/java-impl/src/com/intellij/codeInsight/completion/DispreferImplementationsWeigher.java deleted file mode 100644 index 7de50008b2b9..000000000000 --- a/java/java-impl/src/com/intellij/codeInsight/completion/DispreferImplementationsWeigher.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2000-2010 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.codeInsight.completion; - -import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.patterns.PsiJavaPatterns; -import com.intellij.psi.*; -import org.jetbrains.annotations.NotNull; - -/** - * @author peter -*/ -public class DispreferImplementationsWeigher extends CompletionWeigher { - - public Comparable weigh(@NotNull final LookupElement item, @NotNull final CompletionLocation location) { - final Object object = item.getObject(); - if (object instanceof PsiClass) { - if (PsiJavaPatterns.psiElement().afterLeaf(PsiKeyword.NEW).accepts(location.getCompletionParameters().getPosition())) { - return 0; - } - - final String qname = ((PsiClass)object).getQualifiedName(); - if (qname != null && qname.endsWith("Impl")) { - return -1; - } - } - - return 0; - } -} diff --git a/java/java-tests/testData/codeInsight/completion/normalSorting/DispreferImpls.java b/java/java-tests/testData/codeInsight/completion/normalSorting/DispreferImpls.java index f385d4d4ecf5..73e8206ddee2 100644 --- a/java/java-tests/testData/codeInsight/completion/normalSorting/DispreferImpls.java +++ b/java/java-tests/testData/codeInsight/completion/normalSorting/DispreferImpls.java @@ -7,5 +7,6 @@ public class Aaaaaaa { } +class XxxEx {} class XxxImpl {} class Xxy {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normalSorting/DontDispreferImplsAfterNew.java b/java/java-tests/testData/codeInsight/completion/normalSorting/DontDispreferImplsAfterNew.java index b55dc4e18219..1fde70902aa8 100644 --- a/java/java-tests/testData/codeInsight/completion/normalSorting/DontDispreferImplsAfterNew.java +++ b/java/java-tests/testData/codeInsight/completion/normalSorting/DontDispreferImplsAfterNew.java @@ -2,10 +2,9 @@ public class Aaaaaaa { private final String aaa; Aaaaaaa(Object aabbb) { - new Xx + Xxx x = new Xx } } -class XxxImpl {} -class Xxy {} \ No newline at end of file +class XxxImpl implements Xxx {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normalSorting/PreferLessHumps.java b/java/java-tests/testData/codeInsight/completion/normalSorting/PreferLessHumps.java new file mode 100644 index 000000000000..d86bea2b0ee1 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normalSorting/PreferLessHumps.java @@ -0,0 +1,12 @@ +public class Aaaaaaa { + private final String aaa; + + Aaaaaaa(Object aabbb) { + if (aabbb instanceof XY) + } + +} + +class XaYaEx {} +class XaYaImpl {} +class XyYaXa {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/style/after16.java b/java/java-tests/testData/codeInsight/completion/style/after16.java index 4726e9cc5131..2d4f8e2f468b 100644 --- a/java/java-tests/testData/codeInsight/completion/style/after16.java +++ b/java/java-tests/testData/codeInsight/completion/style/after16.java @@ -2,7 +2,7 @@ class A{ { String str; -str.subSequence(); +str.substring(); jhasgfjhsdgf(); } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java index fd8258dc7b90..dc5175f9ad86 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java @@ -223,7 +223,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase { public void testTryInExpression() throws Throwable { configureByFile(BASE_PATH + "/" + getTestName(true) + ".java"); - assertStringItems("toString", "this"); + assertStringItems("this", "toString"); } public void testNull() throws Exception{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.java index eb12841955b6..92d2147d11da 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.java @@ -7,6 +7,7 @@ package com.intellij.codeInsight.completion; import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.lookup.impl.LookupImpl; import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiMethod; @SuppressWarnings({"ALL"}) @@ -108,12 +109,19 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { public void testDispreferImpls() throws Throwable { VfsUtil.saveText(getSourceRoot().createChildDirectory(this, "foo").createChildData(this, "Xxx.java"), "package foo; public class Xxx {}"); - checkPreferredItems(0, "Xxy", "Xxx", "XxxImpl"); + checkPreferredItems(0, "Xxy", "Xxx", "XxxEx", "XxxImpl"); } public void testDontDispreferImplsAfterNew() throws Throwable { - VfsUtil.saveText(getSourceRoot().createChildDirectory(this, "foo").createChildData(this, "Xxx.java"), "package foo; public class Xxx {}"); - checkPreferredItems(0, "XxxImpl", "Xxy", "Xxx"); + VfsUtil.saveText(getSourceRoot().createChildDirectory(this, "foo").createChildData(this, "Xxx.java"), "package foo; public interface Xxx {}"); + checkPreferredItems(0, "Xxx", "XxxImpl"); + } + + public void testPreferLessHumps() throws Throwable { + final VirtualFile foo = getSourceRoot().createChildDirectory(this, "foo"); + VfsUtil.saveText(foo.createChildData(this, "XaYa.java"), "package foo; public interface XaYa {}"); + VfsUtil.saveText(foo.createChildData(this, "XyYa.java"), "package foo; public interface XyYa {}"); + checkPreferredItems(0, "XaYa", "XyYa", "XaYaEx", "XaYaImpl", "XyYaXa"); } public void testPreferLessParameters() throws Throwable { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index 11f075ae5adb..1b5954a621e4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -90,8 +90,8 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase { configureByFile("QualifiedNew1.java"); assertEquals(2, myItems.length); - assertEquals("IInner", myItems[0].getLookupString()); - assertEquals("Inner", myItems[1].getLookupString()); + assertEquals("Inner", myItems[0].getLookupString()); + assertEquals("IInner", myItems[1].getLookupString()); } public void testQualifiedNew2() throws Exception { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java index b08cbbf259a7..c106d8c771a6 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java @@ -18,7 +18,6 @@ package com.intellij.codeInsight.completion; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * @author peter @@ -26,14 +25,21 @@ import org.jetbrains.annotations.Nullable; public class PrefixMatchingWeigher extends CompletionWeigher { public Comparable weigh(@NotNull final LookupElement item, @NotNull final CompletionLocation location) { - if (location == null) { - return null; + final String prefix = item.getPrefixMatcher().getPrefix(); + + if (prefix.isEmpty()) { + return 0; } - if (location.getCompletionType() == CompletionType.CLASS_NAME) return 0; final String lookupString = item.getLookupString(); - return (StringUtil.capitalsOnly(lookupString).startsWith(StringUtil.capitalsOnly(item.getPrefixMatcher().getPrefix())) ? 4 : 0) + - (lookupString.startsWith(item.getPrefixMatcher().getPrefix()) ? 2 : 0) + - (StringUtil.startsWithIgnoreCase(lookupString, item.getPrefixMatcher().getPrefix()) ? 1 : 0); + final String prefixHumps = StringUtil.capitalsOnly(prefix); + final String itemHumps = StringUtil.capitalsOnly(lookupString); + + if (itemHumps.equals(prefixHumps)) return 20; + if (itemHumps.startsWith(prefixHumps)) return 10; + + if (lookupString.startsWith(prefix)) return 5; + if (StringUtil.startsWithIgnoreCase(lookupString, prefix)) return 1; + return 0; } } diff --git a/platform/platform-api/src/com/intellij/ui/InplaceButton.java b/platform/platform-api/src/com/intellij/ui/InplaceButton.java index 54089056f6f8..02c9f9d3a428 100644 --- a/platform/platform-api/src/com/intellij/ui/InplaceButton.java +++ b/platform/platform-api/src/com/intellij/ui/InplaceButton.java @@ -28,7 +28,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; -public final class InplaceButton extends JComponent implements ActiveComponent { +public class InplaceButton extends JComponent implements ActiveComponent { private boolean myPainting = true; private boolean myActive = true; @@ -43,6 +43,8 @@ public final class InplaceButton extends JComponent implements ActiveComponent { private int myYTransform = 0; private boolean myFill; + private boolean myHoveringEnabled; + public InplaceButton(String tooltip, final Icon icon, final ActionListener listener) { this(new IconButton(tooltip, icon, icon), listener, null); } @@ -142,7 +144,7 @@ public final class InplaceButton extends JComponent implements ActiveComponent { g.translate(myXTransform, myYTransform); - if (myBehavior.isHovered()) { + if (myBehavior.isHovered() && myHoveringEnabled) { if (myBehavior.isPressedByMouse()) { myHovered.paintIcon(this, g, 1, 1); } @@ -151,7 +153,7 @@ public final class InplaceButton extends JComponent implements ActiveComponent { } } else { - if (myActive) { + if (isActive()) { myRegular.paintIcon(this, g, 0, 0); } else { @@ -167,4 +169,13 @@ public final class InplaceButton extends JComponent implements ActiveComponent { myYTransform = y; } + public void setHoveringEnabled(boolean enabled) { + myHoveringEnabled = enabled; + } + + public boolean isActive() { + + + return myActive; + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java index 3c15d553541e..279bbbbed6ae 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java @@ -101,11 +101,8 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa private final MyDivider myDivider; private final TitlePanel myTitlePanel; private final MyTitleButton myToggleFloatingModeButton; - private final Separator myFloatingDockSeparator; private final MyTitleButton myToggleDockModeButton; - private final Separator myDockAutoHideSeparator; private final MyTitleButton myToggleAutoHideModeButton; - private final Separator myAutoHideHideSeparator; private final MyTitleButton myHideButton; private final EventListenerList myListenerList; /* @@ -139,17 +136,18 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa myToolWindow = toolWindow; myToolWindow.setDecorator(this); myDivider = new MyDivider(); - myTitlePanel = new TitlePanel(); + myTitlePanel = new TitlePanel() { + @Override + public boolean isActive() { + return computeActive(); + } + }; myTitleTabs = toolWindow.getContentUI().getTabComponent(); myToggleFloatingModeAction = new ToggleFloatingModeAction(); myToggleSideModeAction = new ToggleSideModeAction(); - myFloatingDockSeparator = new Separator(); - myFloatingDockSeparator.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); myToggleDockModeAction = new ToggleDockModeAction(); - myDockAutoHideSeparator = new Separator(); myToggleAutoHideModeAction = new TogglePinnedModeAction(); - myAutoHideHideSeparator = new Separator(); myHideAction = new HideAction(); HideSideAction hideSideAction = new HideSideAction(); myToggleContentUiTypeAction = new ToggleContentUiTypeAction(); @@ -177,6 +175,14 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa apply(info); } + private boolean computeActive() { + Component component = IdeFocusManager.getInstance(myProject).getFocusedDescendantFor(myToolWindow.getComponent()); + if (component != null) return true; + + Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + return owner != null && SwingUtilities.isDescendingFrom(owner, myToolWindow.getComponent()); + } + /** * Applies specified decoration. */ @@ -185,14 +191,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa return; } myInfo = info; - // Active - final boolean active = info.isActive(); - myTitlePanel.setActive(active); - - //todo myToolWindowBorder.setActive(active); - myFloatingDockSeparator.setActive(active); - myDockAutoHideSeparator.setActive(active); - myAutoHideHideSeparator.setActive(active); // Anchor final ToolWindowAnchor anchor = myInfo.getAnchor(); @@ -220,16 +218,16 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa if (!info.isFloating()) { myHideSideButton.setVisible(true); if (ToolWindowAnchor.TOP == anchor) { - myHideSideButton.setIcon(active ? ourHideSideUp : ourHideSideUpInactive); + myHideSideButton.setIcon(ourHideSideUp, ourHideSideUpInactive); } else if (ToolWindowAnchor.LEFT == anchor) { - myHideSideButton.setIcon(active ? ourHideSideLeft : ourHideSideLeftInactive); + myHideSideButton.setIcon(ourHideSideLeft, ourHideSideLeftInactive); } else if (ToolWindowAnchor.BOTTOM == anchor) { - myHideSideButton.setIcon(active ? ourHideSideDown : ourHideSideDownInactive); + myHideSideButton.setIcon(ourHideSideDown, ourHideSideDownInactive); } else if (ToolWindowAnchor.RIGHT == anchor) { - myHideSideButton.setIcon(active ? ourHideSideRight : ourHideSideRightInactive); + myHideSideButton.setIcon(ourHideSideRight, ourHideSideRightInactive); } } else { @@ -240,38 +238,30 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa repaint(); // Type if (myInfo.isDocked()) { - myToggleFloatingModeButton.setIcon(active ? ourFloatingIcon : ourFloatingInactiveIcon); + myToggleFloatingModeButton.setIcon(ourFloatingIcon, ourFloatingInactiveIcon); myToggleDockModeButton.setVisible(true); - myDockAutoHideSeparator.setVisible(true); - myToggleDockModeButton.setIcon(active ? ourSlidingIcon : ourSlidingInactiveIcon); + myToggleDockModeButton.setIcon(ourSlidingIcon, ourSlidingInactiveIcon); myToggleAutoHideModeButton.setVisible(true); - myAutoHideHideSeparator.setVisible(true); - myToggleAutoHideModeButton.setIcon(active - ? (myInfo.isAutoHide() ? ourAuthoHideOnIcon : ourAuthoHideOffIcon) - : (myInfo.isAutoHide() ? ourAuthoHideOnInactiveIcon : ourAuthoHideOffInactiveIcon)); + myToggleAutoHideModeButton.setIcon((myInfo.isAutoHide() ? ourAuthoHideOnIcon : ourAuthoHideOffIcon), + (myInfo.isAutoHide() ? ourAuthoHideOnInactiveIcon : ourAuthoHideOffInactiveIcon)); myHideButton.setVisible(true); } else if (myInfo.isFloating()) { - myToggleFloatingModeButton.setIcon(active ? ourFixIcon : ourFixInactiveIcon); + myToggleFloatingModeButton.setIcon(ourFixIcon, ourFixInactiveIcon); myToggleDockModeButton.setVisible(false); - myDockAutoHideSeparator.setVisible(false); myToggleAutoHideModeButton.setVisible(true); - myAutoHideHideSeparator.setVisible(true); - myToggleAutoHideModeButton.setIcon(active - ? myInfo.isAutoHide() ? ourAuthoHideOnIcon : ourAuthoHideOffIcon - : myInfo.isAutoHide() ? ourAuthoHideOnInactiveIcon : ourAuthoHideOffInactiveIcon); + myToggleAutoHideModeButton.setIcon(myInfo.isAutoHide() ? ourAuthoHideOnIcon : ourAuthoHideOffIcon, + myInfo.isAutoHide() ? ourAuthoHideOnInactiveIcon : ourAuthoHideOffInactiveIcon); myHideButton.setVisible(true); } else if (myInfo.isSliding()) { - myToggleFloatingModeButton.setIcon(active ? ourFloatingIcon : ourFloatingInactiveIcon); + myToggleFloatingModeButton.setIcon(ourFloatingIcon, ourFloatingInactiveIcon); myToggleDockModeButton.setVisible(true); - myDockAutoHideSeparator.setVisible(true); - myToggleDockModeButton.setIcon(active ? ourDockedIcon : ourDockedInactiveIcon); + myToggleDockModeButton.setIcon(ourDockedIcon, ourDockedInactiveIcon); myToggleAutoHideModeButton.setVisible(false); - myAutoHideHideSeparator.setVisible(false); myHideButton.setVisible(true); } - myHideButton.setIcon(active ? ourHideIcon : ourHideInactiveIcon); + myHideButton.setIcon(ourHideIcon, ourHideInactiveIcon); // updateTitle(); @@ -396,23 +386,13 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa // Compose title bar myTitlePanel.addTitle(myTitleTabs); - final JPanel buttonPanel = new JPanel(new GridBagLayout()); + final JPanel buttonPanel = new JPanel(new GridLayout(1, 4, 2, 0)); buttonPanel.setOpaque(false); buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); - buttonPanel.add(myToggleFloatingModeButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, - new Insets(0, 0, 0, 0), 0, 0)); - buttonPanel.add(myFloatingDockSeparator, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, - new Insets(0, 0, 0, 0), 0, 0)); - buttonPanel.add(myToggleDockModeButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, - new Insets(0, 0, 0, 0), 0, 0)); - buttonPanel.add(myDockAutoHideSeparator, new GridBagConstraints(3, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, - new Insets(0, 0, 0, 0), 0, 0)); - buttonPanel.add(myToggleAutoHideModeButton, new GridBagConstraints(4, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, - new Insets(0, 0, 0, 0), 0, 0)); - buttonPanel.add(myAutoHideHideSeparator, new GridBagConstraints(5, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, - new Insets(0, 0, 0, 0), 0, 0)); - buttonPanel.add(myHideButton, new GridBagConstraints(6, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, - new Insets(0, 0, 0, 0), 0, 0)); + buttonPanel.add(myToggleFloatingModeButton); + buttonPanel.add(myToggleDockModeButton); + buttonPanel.add(myToggleAutoHideModeButton); + buttonPanel.add(myHideButton); myTitlePanel.addButtons(buttonPanel, myHideSideButton); @@ -926,15 +906,20 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa } - private static final class MyTitleButton extends Wrapper implements ActionListener { + private class MyTitleButton extends Wrapper implements ActionListener { private final InplaceButton myButton; private final AnAction myAction; public MyTitleButton(AnAction action) { myAction = action; - myButton = new InplaceButton(null, new EmptyIcon(16), this); - //myButton.setTransform(0, -1); + myButton = new InplaceButton(null, new EmptyIcon(16), this) { + @Override + public boolean isActive() { + return MyTitleButton.this.isActive(); + } + }; + myButton.setHoveringEnabled(false); setContent(myButton); setOpaque(false); } @@ -952,8 +937,12 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa myAction.actionPerformed(event); } - public void setIcon(final Icon icon) { - myButton.setIcon(icon); + public boolean isActive() { + return InternalDecorator.this.computeActive(); + } + + public void setIcon(final Icon active, Icon inactive) { + myButton.setIcons(active, inactive, active); } @@ -1010,20 +999,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa // } //} - private static final class Separator extends JLabel { - private static final Icon ourActiveSeparator = IconLoader.getIcon("/general/separator.png"); - private static final Icon ourInactiveSeparator = IconLoader.getIcon("/general/inactiveSeparator.png"); - - public final void setActive(final boolean active) { - setIcon(active ? ourActiveSeparator : ourInactiveSeparator); - } - - public final void updateUI() { - super.updateUI(); - setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3)); - } - } - /** * Synchronizes decorator with IdeToolWindow changes. */ diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/TitlePanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/TitlePanel.java index b889514b3477..95032982d4a3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/TitlePanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/TitlePanel.java @@ -28,7 +28,7 @@ import java.awt.*; * @author Anton Katilin * @author Vladimir Kondratyev */ -public final class TitlePanel extends JPanel { +public class TitlePanel extends JPanel { private static final Color CNT_COLOR = new SameColor(184); private static final Color BND_COLOR = CNT_COLOR; @@ -80,8 +80,10 @@ public final class TitlePanel extends JPanel { final Graphics2D g2d = (Graphics2D) g; - Color bndColor = myActive ? BND_ACTIVE_COLOR : BND_COLOR; - Color cntColor = myActive ? CNT_ACTIVE_COLOR : CNT_COLOR; + boolean active = isActive(); + + Color bndColor = active ? BND_ACTIVE_COLOR : BND_COLOR; + Color cntColor = active ? CNT_ACTIVE_COLOR : CNT_COLOR; g2d.setPaint(new GradientPaint(0, STRUT, bndColor, 0, getHeight(), cntColor)); if (mySideButtons.isVisible()) { @@ -89,12 +91,12 @@ public final class TitlePanel extends JPanel { g2d.fillRect(0, STRUT, getWidth() - sideRec.width, getHeight()); g2d.setColor(UIUtil.getHeaderInactiveColor()); - final Color buttonInnerColor = myActive ? ACTIVE_SIDE_BUTTON_BG : INACTIVE_SIDE_BUTTON_BG; + final Color buttonInnerColor = active ? ACTIVE_SIDE_BUTTON_BG : INACTIVE_SIDE_BUTTON_BG; g2d.setPaint(new GradientPaint(sideRec.x, sideRec.y, Color.white, sideRec.x, (int)sideRec.getMaxY() - 1, buttonInnerColor)); g2d.fillRect(sideRec.x + 2, sideRec.y, sideRec.width - 2, sideRec.height); - Icon separator = myActive ? mySeparatorActive : mySeparatorInactive; + Icon separator = active ? mySeparatorActive : mySeparatorInactive; separator.paintIcon(this, g, sideRec.x, sideRec.y); } else { @@ -121,4 +123,8 @@ public final class TitlePanel extends JPanel { add(wrapper, BorderLayout.EAST); } + + public boolean isActive() { + return myActive; + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java index 77e00f6ae0ee..2d094b487809 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java @@ -96,7 +96,9 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements private final MyToolWindowPropertyChangeListener myToolWindowPropertyChangeListener; private final InternalDecoratorListener myInternalDecoratorListener; - private boolean myEditorComponentActive; + private boolean myEditorWasActive; + private Boolean myEditorActive; + private final ActiveStack myActiveStack; private final SideStack mySideStack; @@ -127,11 +129,20 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements } } }; + private PropertyChangeListener myFocusListener; private enum KeyState { waiting, pressed, released, hold } + private Alarm myUpdateHeadersAlarm = new Alarm(); + private Runnable myUpdateHeadersRunnable = new Runnable() { + @Override + public void run() { + updateToolWindowHeaders(); + } + }; + /** * invoked by reflection */ @@ -175,7 +186,6 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements myToolWindowPropertyChangeListener = new MyToolWindowPropertyChangeListener(); myInternalDecoratorListener = new MyInternalDecoratorListener(); - myEditorComponentActive = false; myActiveStack = new ActiveStack(); mySideStack = new SideStack(); @@ -196,6 +206,39 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements public void selectionChanged(FileEditorManagerEvent event) { } }); + + myFocusListener = new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + myEditorActive = null; + if ("focusOwner".equals(evt.getPropertyName())) { + myUpdateHeadersAlarm.cancelAllRequests(); + myUpdateHeadersAlarm.addRequest(myUpdateHeadersRunnable, 50); + } + } + }; + KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(myFocusListener); + } + + + private void updateToolWindowHeaders() { + getFocusManager().doWhenFocusSettlesDown(new Runnable() { + @Override + public void run() { + WindowInfoImpl[] infos = myLayout.getInfos(); + for (WindowInfoImpl each : infos) { + if (each.isVisible()) { + ToolWindow tw = getToolWindow(each.getId()); + if (tw instanceof ToolWindowImpl) { + InternalDecorator decorator = ((ToolWindowImpl)tw).getDecorator(); + if (decorator != null) { + decorator.repaint(); + } + } + } + } + } + }); } public boolean dispatchKeyEvent(KeyEvent e) { @@ -314,6 +357,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements } public void disposeComponent() { + KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener(myFocusListener); } public void projectOpened() { @@ -346,7 +390,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements myEditorComponentFocusWatcher.install(editorComponent); appendSetEditorComponentCmd(editorComponent, commandsList); - if (myEditorComponentActive) { + if (myEditorWasActive) { activateEditorComponentImpl(editorManager.getSplitters(), commandsList, true); } execute(commandsList); @@ -537,7 +581,6 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements } deactivateWindows(postExecute, null); myActiveStack.clear(); - myEditorComponentActive = true; execute(postExecute); } @@ -617,7 +660,6 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements if (toApplyInfo) { appendApplyWindowInfoCmd(info, commandsList); myActiveStack.push(id); - myEditorComponentActive = false; } if (autoFocusContents) { @@ -1172,7 +1214,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements } // if there is no any active tool window and editor is also inactive // then activate editor - if (!myEditorComponentActive && getActiveToolWindowId() == null) { + if (!myEditorWasActive && getActiveToolWindowId() == null) { activateEditorComponentImpl(getSplittersFromFocus(), commandList, true); } execute(commandList); @@ -1308,7 +1350,14 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements public boolean isEditorComponentActive() { ApplicationManager.getApplication().assertIsDispatchThread(); - return myEditorComponentActive; + + if (myEditorActive == null) { + Component owner = getFocusManager().getFocusOwner(); + EditorsSplitters splitters = UIUtil.getParentOfType(EditorsSplitters.class, owner); + myEditorActive = splitters != null; + } + + return myEditorActive; } ToolWindowAnchor getToolWindowAnchor(final String id) { @@ -1669,7 +1718,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements for (final Object o : element.getChildren()) { final Element e = (Element)o; if (EDITOR_ELEMENT.equals(e.getName())) { - myEditorComponentActive = Boolean.valueOf(e.getAttributeValue(ACTIVE_ATTR_VALUE)).booleanValue(); + myEditorWasActive = Boolean.valueOf(e.getAttributeValue(ACTIVE_ATTR_VALUE)).booleanValue(); } else if (DesktopLayout.TAG.equals(e.getName())) { // read layout of tool windows myLayout.readExternal(e); @@ -1709,7 +1758,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements frameElement.setAttribute(EXTENDED_STATE_ATTR, Integer.toString(myFrame.getExtendedState())); // Save whether editor is active or not final Element editorElement = new Element(EDITOR_ELEMENT); - editorElement.setAttribute(ACTIVE_ATTR_VALUE, myEditorComponentActive ? Boolean.TRUE.toString() : Boolean.FALSE.toString()); + editorElement.setAttribute(ACTIVE_ATTR_VALUE, isEditorComponentActive() ? Boolean.TRUE.toString() : Boolean.FALSE.toString()); element.addContent(editorElement); // Save layout of tool windows final Element layoutElement = new Element(DesktopLayout.TAG); @@ -1836,7 +1885,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements // Sometimes focus gained comes when editor is active. For example it can happen when // user switches between menus or closes some dialog. In that case we just ignore this event, // i.e. don't initiate deactivation of tool windows and requesting focus in editor. - if (myEditorComponentActive) { + if (isEditorComponentActive()) { return; } @@ -2044,7 +2093,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements private ActionCallback processDefaultFocusRequest(boolean forced) { if (ModalityState.NON_MODAL.equals(ModalityState.current())) { final String activeId = getActiveToolWindowId(); - if (myEditorComponentActive || activeId == null || getToolWindow(activeId) == null) { + if (isEditorComponentActive() || activeId == null || getToolWindow(activeId) == null) { activateEditorComponent(forced, true); } else { diff --git a/platform/platform-resources-en/src/messages/XmlBundle.properties b/platform/platform-resources-en/src/messages/XmlBundle.properties index 9b2e1b480bb7..479c29bcb694 100644 --- a/platform/platform-resources-en/src/messages/XmlBundle.properties +++ b/platform/platform-resources-en/src/messages/XmlBundle.properties @@ -234,7 +234,7 @@ button.text.settings=Settings... display.name.firefox.settings=Firefox Settings zen.coding.title=XML Zen Coding zen.coding.enable.label=Enable Zen Coding -zen.coding.enter.abbreviation.dialog.label=Please entrer an abbreviation +zen.coding.enter.abbreviation.dialog.label=Please enter an abbreviation zen.coding.incorrect.abbreviation.error=Incorrect abbreviation title.cannot.create.html.file=Cannot create HTML/XHTML file new.html.file.action=HTML/XHTML file diff --git a/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsDialog.java b/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsDialog.java index f33762756d67..a722a02fbb46 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsDialog.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsDialog.java @@ -33,7 +33,7 @@ public class ExportTestResultsDialog extends DialogWrapper { super(project); myProject = project; String defaultFolder = StringUtil.isNotEmpty(config.getOutputFolder()) ? - FileUtil.toSystemDependentName(config.getOutputFolder()) : FileUtil.toSystemDependentName(project.getLocation()); + FileUtil.toSystemDependentName(config.getOutputFolder()) : FileUtil.toSystemDependentName(project.getBaseDir().getPresentableUrl()); myForm = new ExportTestResultsForm(config, defaultFileName, defaultFolder); myForm.addChangeListener(new ChangeListener() { @Override diff --git a/platform/testRunner/src/com/intellij/execution/testframework/export/intellij-export.xsl b/platform/testRunner/src/com/intellij/execution/testframework/export/intellij-export.xsl index 6d234683e7fd..8238361dfcf8 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/export/intellij-export.xsl +++ b/platform/testRunner/src/com/intellij/execution/testframework/export/intellij-export.xsl @@ -1,6 +1,6 @@ - diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 46131f2b8817..79786e672b32 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -801,16 +801,14 @@ - + order="after stats"/> + order="after simple, before prefix"/>