diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/GutterIconTooltipHelper.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/GutterIconTooltipHelper.java index aad7e3982b1a..de09c0840340 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/GutterIconTooltipHelper.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/GutterIconTooltipHelper.java @@ -41,6 +41,10 @@ public class GutterIconTooltipHelper { } public static String composeText(@NotNull Iterable elements, String start, final String pattern) { + return composeText(elements, start, pattern, ""); + } + + public static String composeText(@NotNull Iterable elements, String start, final String pattern, String postfix) { @NonNls StringBuilder result = new StringBuilder(); result.append(""); result.append(start); @@ -69,7 +73,7 @@ public class GutterIconTooltipHelper { sep = "
"; result.append(name); } - + result.append(postfix); result.append(""); return result.toString(); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java index 9d9aa57af7db..6001bd4ffe21 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java @@ -24,7 +24,11 @@ import com.intellij.codeInsight.daemon.DaemonBundle; import com.intellij.codeInsight.daemon.GutterIconNavigationHandler; import com.intellij.codeInsight.navigation.ListBackgroundUpdaterTask; import com.intellij.ide.util.*; +import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.IdeActions; +import com.intellij.openapi.actionSystem.Shortcut; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.DumbService; @@ -37,7 +41,10 @@ import com.intellij.psi.search.searches.ClassInheritorsSearch; import com.intellij.psi.search.searches.FunctionalExpressionSearch; import com.intellij.psi.search.searches.OverridingMethodsSearch; import com.intellij.psi.util.PsiUtil; -import com.intellij.util.*; +import com.intellij.util.ArrayUtil; +import com.intellij.util.CommonProcessors; +import com.intellij.util.Function; +import com.intellij.util.NullableFunction; import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -109,7 +116,16 @@ public class MarkerType { else{ key = sameSignature ? "method.overrides" : "method.overrides.in"; } - return GutterIconTooltipHelper.composeText(superMethods, "", DaemonBundle.message(key)); + return composeText(superMethods, "", DaemonBundle.message(key), "GotoSuperMethod"); + } + + private static String composeText(PsiElement[] methods, String start, String pattern, String actionId) { + Shortcut[] shortcuts = ActionManager.getInstance().getAction(actionId).getShortcutSet().getShortcuts(); + Shortcut shortcut = ArrayUtil.getFirstElement(shortcuts); + String postfix = "
Click"; + if (shortcut != null) postfix += " or press " + KeymapUtil.getShortcutText(shortcut); + postfix += " to navigate
"; + return GutterIconTooltipHelper.composeText(Arrays.asList(methods), start, pattern, postfix); } public static void navigateToOverridingMethod(MouseEvent e, PsiMethod method, boolean acceptSelf) { @@ -182,7 +198,7 @@ public class MarkerType { String start = isAbstract ? DaemonBundle.message("method.is.implemented.header") : DaemonBundle.message("method.is.overriden.header"); @NonNls String pattern = "    {1}"; - return GutterIconTooltipHelper.composeText(overridings, start, pattern); + return composeText(overridings, start, pattern, IdeActions.ACTION_GOTO_IMPLEMENTATION); } public static void navigateToOverriddenMethod(MouseEvent e, final PsiMethod method) { @@ -274,7 +290,7 @@ public class MarkerType { ? DaemonBundle.message("interface.is.implemented.by.header") : DaemonBundle.message("class.is.subclassed.by.header"); @NonNls String pattern = "    {0}"; - return GutterIconTooltipHelper.composeText(subclasses, start, pattern); + return composeText(subclasses, start, pattern, IdeActions.ACTION_GOTO_IMPLEMENTATION); } public static void navigateToSubclassedClass(MouseEvent e, final PsiClass aClass) { diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ColorChooserIntentionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ColorChooserIntentionAction.java deleted file mode 100644 index dd66e7057300..000000000000 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ColorChooserIntentionAction.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright 2000-2014 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. - */ - -/* - * Created by IntelliJ IDEA. - * User: spleaner - * Date: Aug 22, 2007 - * Time: 3:44:10 PM - */ -package com.intellij.codeInsight.intention.impl; - -import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.FileModificationService; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.patterns.PsiExpressionPattern; -import com.intellij.patterns.PsiJavaPatterns; -import com.intellij.patterns.PsiMethodPattern; -import com.intellij.psi.*; -import com.intellij.psi.codeStyle.CodeStyleManager; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.ui.ColorChooser; -import com.intellij.ui.JBColor; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.awt.*; - -/** - * @author spleaner - * @author Konstantin Bulenkov - */ -public class ColorChooserIntentionAction extends BaseColorIntentionAction { - private static final PsiMethodPattern DECODE_METHOD = PsiJavaPatterns.psiMethod() - .definedInClass(JAVA_AWT_COLOR) - .withName("decode"); - private static final PsiExpressionPattern.Capture DECODE_METHOD_CALL_PARAMETER = - PsiJavaPatterns.psiExpression().methodCallParameter(0, DECODE_METHOD); - - private static final PsiMethodPattern GET_COLOR_METHOD = PsiJavaPatterns.psiMethod() - .definedInClass(JAVA_AWT_COLOR) - .withName("getColor"); - private static final PsiExpressionPattern.Capture GET_METHOD_CALL_PARAMETER = - PsiJavaPatterns.psiExpression().methodCallParameter(0, GET_COLOR_METHOD); - - - public ColorChooserIntentionAction() { - setText(CodeInsightBundle.message("intention.color.chooser.dialog")); - } - - @Override - public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) { - return super.isAvailable(project, editor, element) || isInsideDecodeOrGetColorMethod(element); - } - - public static boolean isInsideDecodeOrGetColorMethod(PsiElement element) { - if (element instanceof PsiJavaToken && ((PsiJavaToken)element).getTokenType() == JavaTokenType.STRING_LITERAL) { - element = element.getParent(); - } - - return DECODE_METHOD_CALL_PARAMETER.accepts(element) || - GET_METHOD_CALL_PARAMETER.accepts(element); - } - - @Override - @NotNull - public String getFamilyName() { - return getText(); - } - - @Override - public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { - if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return; - - final JComponent editorComponent = editor.getComponent(); - if (isInsideDecodeOrGetColorMethod(element)) { - invokeForMethodParam(editorComponent, element); - } - else { - invokeForConstructor(editorComponent, element); - } - } - - private void invokeForMethodParam(JComponent editorComponent, PsiElement element) { - final PsiLiteralExpression literal = PsiTreeUtil.getParentOfType(element, PsiLiteralExpression.class); - if (literal == null) return; - final String text = StringUtil.unquoteString(literal.getText()); - final int radix = text.startsWith("0x") || text.startsWith("0X") || text.startsWith("#") ? 16 : text.startsWith("0") ? 8 : 10; - final String hexPrefix = radix == 16 ? text.startsWith("#") ? "#" : text.substring(0, 2) : null; - - Color oldColor; - try { - oldColor = Color.decode(text); - } - catch (NumberFormatException e) { - oldColor = JBColor.GRAY; - } - Color color = ColorChooser.chooseColor(editorComponent, getText(), oldColor, true); - if (color == null) return; - final int rgb = color.getRGB() - ((255 & 0xFF) << 24); - if (color != null && rgb != oldColor.getRGB()) { - final String newText = radix == 16 ? hexPrefix + String.format("%6s", Integer.toHexString(rgb)).replace(' ', '0') - : radix == 8 ? "0" + Integer.toOctalString(rgb) - : Integer.toString(rgb); - final PsiManager manager = literal.getManager(); - final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory(); - final PsiExpression newLiteral = factory.createExpressionFromText("\"" + newText + "\"", literal); - literal.replace(newLiteral); - } - } - - private void invokeForConstructor(JComponent editorComponent, PsiElement element) { - final PsiNewExpression expression = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class); - if (expression == null) return; - - Color c = null; - - final PsiExpressionList argumentList = expression.getArgumentList(); - if (argumentList != null) { - final PsiExpression[] expressions = argumentList.getExpressions(); - int[] values = new int[expressions.length]; - float[] values2 = new float[expressions.length]; - int i = 0; - int j = 0; - for (final PsiExpression each : expressions) { - if (each instanceof PsiLiteralExpression) { - final Object o = ((PsiLiteralExpression)each).getValue(); - if (o instanceof Integer) { - values[i] = ((Integer)o).intValue(); - i++; - } - else if (o instanceof Float) { - values2[j] = ((Float)o).floatValue(); - j++; - } - } - } - - try { - if (i == expressions.length) { - switch (values.length) { - case 1: - c = new Color(values[0]); - break; - case 3: - c = new Color(values[0], values[1], values[2]); - break; - case 4: - c = new Color(values[0], values[1], values[2], values[3]); - break; - default: - break; - } - } - else if (j == expressions.length) { - switch (values2.length) { - case 3: - c = new Color(values2[0], values2[1], values2[2]); - break; - case 4: - c = new Color(values2[0], values2[1], values2[2], values2[3]); - break; - default: - break; - } - } - } - catch (Exception e) { - c = JBColor.GRAY; - } - } - - c = (c == null) ? JBColor.GRAY : c; - - replaceColor(editorComponent, expression, c); - } - - private void replaceColor(JComponent editorComponent, PsiNewExpression expression, Color oldColor) { - final Color color = ColorChooser.chooseColor(editorComponent, getText(), oldColor, true); - if (color != null) { - final PsiManager manager = expression.getManager(); - final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory(); - final PsiExpression newCall = factory.createExpressionFromText( - "new " + getFqn(expression.getClassOrAnonymousClassReference()) + "(" - + color.getRed() + ", " - + color.getGreen() + ", " - + color.getBlue() - + (color.getAlpha() < 255 ? ", " + color.getAlpha() : "") - + ")", expression); - final PsiElement insertedElement = expression.replace(newCall); - final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject()); - codeStyleManager.reformat(insertedElement); - } - } -} diff --git a/java/java-impl/src/com/intellij/codeInsight/preview/JavaPreviewHintProvider.java b/java/java-impl/src/com/intellij/codeInsight/preview/JavaPreviewHintProvider.java index 8578149c4f71..b996c2219083 100644 --- a/java/java-impl/src/com/intellij/codeInsight/preview/JavaPreviewHintProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/preview/JavaPreviewHintProvider.java @@ -15,9 +15,11 @@ */ package com.intellij.codeInsight.preview; -import com.intellij.codeInsight.intention.impl.ColorChooserIntentionAction; import com.intellij.openapi.util.text.StringUtil; import com.intellij.patterns.PlatformPatterns; +import com.intellij.patterns.PsiExpressionPattern; +import com.intellij.patterns.PsiJavaPatterns; +import com.intellij.patterns.PsiMethodPattern; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ArrayUtil; @@ -31,6 +33,27 @@ import java.awt.*; * @author yole */ public class JavaPreviewHintProvider implements PreviewHintProvider { + + private static final PsiMethodPattern DECODE_METHOD = PsiJavaPatterns.psiMethod() + .definedInClass(Color.class.getName()) + .withName("decode"); + private static final PsiExpressionPattern.Capture DECODE_METHOD_CALL_PARAMETER = + PsiJavaPatterns.psiExpression().methodCallParameter(0, DECODE_METHOD); + private static final PsiMethodPattern GET_COLOR_METHOD = PsiJavaPatterns.psiMethod() + .definedInClass(Color.class.getName()) + .withName("getColor"); + private static final PsiExpressionPattern.Capture GET_METHOD_CALL_PARAMETER = + PsiJavaPatterns.psiExpression().methodCallParameter(0, GET_COLOR_METHOD); + + private static boolean isInsideDecodeOrGetColorMethod(PsiElement element) { + if (element instanceof PsiJavaToken && ((PsiJavaToken)element).getTokenType() == JavaTokenType.STRING_LITERAL) { + element = element.getParent(); + } + + return DECODE_METHOD_CALL_PARAMETER.accepts(element) || + GET_METHOD_CALL_PARAMETER.accepts(element); + } + @Override public boolean isSupportedFile(PsiFile file) { return file instanceof PsiJavaFile; @@ -120,7 +143,7 @@ public class JavaPreviewHintProvider implements PreviewHintProvider { } } - if (ColorChooserIntentionAction.isInsideDecodeOrGetColorMethod(element)) { + if (isInsideDecodeOrGetColorMethod(element)) { final String color = StringUtil.unquoteString(element.getText()); try { return new ColorPreviewComponent(Color.decode(color)); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/navigation/JavaGotoSuperTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/navigation/JavaGotoSuperTest.java index 7aff6e06c455..5adce674ae4f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/navigation/JavaGotoSuperTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/navigation/JavaGotoSuperTest.java @@ -36,7 +36,9 @@ public class JavaGotoSuperTest extends LightDaemonAnalyzerTestCase { List markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject()); for (LineMarkerInfo info : markers) { if (info.endOffset >= offset && info.startOffset <= offset) { - assertEquals("Overrides method in I", info.getLineMarkerTooltip()); + assertEquals( + "Overrides method in I
Click or press Ctrl+U to navigate
", + info.getLineMarkerTooltip()); return; } } diff --git a/platform/lang-api/src/com/intellij/codeInsight/daemon/NavigateAction.java b/platform/lang-api/src/com/intellij/codeInsight/daemon/NavigateAction.java index 90a06ae7b13d..90ccfbffbf8b 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/daemon/NavigateAction.java +++ b/platform/lang-api/src/com/intellij/codeInsight/daemon/NavigateAction.java @@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ShortcutSet; import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.Nullable; import java.awt.event.MouseEvent; @@ -31,11 +32,13 @@ public class NavigateAction extends AnAction { public NavigateAction(String text, LineMarkerInfo info, - String originalActionId) { + @Nullable String originalActionId) { super(text); myInfo = info; - ShortcutSet set = ActionManager.getInstance().getAction(originalActionId).getShortcutSet(); - setShortcutSet(set); + if (originalActionId != null) { + ShortcutSet set = ActionManager.getInstance().getAction(originalActionId).getShortcutSet(); + setShortcutSet(set); + } } public NavigateAction(LineMarkerInfo info) { @@ -53,7 +56,7 @@ public class NavigateAction extends AnAction { } } - public static LineMarkerInfo setNavigateAction(LineMarkerInfo info, String text, String originalActionId) { + public static LineMarkerInfo setNavigateAction(LineMarkerInfo info, String text, @Nullable String originalActionId) { NavigateAction action = new NavigateAction(text, info, originalActionId); info.setNavigateAction(action); return info; diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form index 89c70182283a..f3b78745f7ed 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form @@ -393,7 +393,7 @@ - + diff --git a/platform/lang-impl/src/com/intellij/ui/ColorLineMarkerProvider.java b/platform/lang-impl/src/com/intellij/ui/ColorLineMarkerProvider.java index 5bd893ee1128..4ef4704b162b 100644 --- a/platform/lang-impl/src/com/intellij/ui/ColorLineMarkerProvider.java +++ b/platform/lang-impl/src/com/intellij/ui/ColorLineMarkerProvider.java @@ -16,10 +16,7 @@ package com.intellij.ui; import com.intellij.codeHighlighting.Pass; -import com.intellij.codeInsight.daemon.GutterIconNavigationHandler; -import com.intellij.codeInsight.daemon.LineMarkerInfo; -import com.intellij.codeInsight.daemon.LineMarkerProvider; -import com.intellij.codeInsight.daemon.MergeableLineMarkerInfo; +import com.intellij.codeInsight.daemon.*; import com.intellij.icons.AllIcons; import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; @@ -44,6 +41,7 @@ import java.util.List; * @author Konstantin Bulenkov */ public final class ColorLineMarkerProvider implements LineMarkerProvider { + private final ElementColorProvider[] myExtensions = ElementColorProvider.EP_NAME.getExtensions(); @Override @@ -51,7 +49,9 @@ public final class ColorLineMarkerProvider implements LineMarkerProvider { for (ElementColorProvider colorProvider : myExtensions) { final Color color = colorProvider.getColorFrom(element); if (color != null) { - return new MyInfo(element, color, colorProvider); + MyInfo info = new MyInfo(element, color, colorProvider); + NavigateAction.setNavigateAction(info, "Choose color", null); + return info; } } return null; @@ -78,7 +78,7 @@ public final class ColorLineMarkerProvider implements LineMarkerProvider { final Editor editor = PsiUtilBase.findEditor(element); assert editor != null; - final Color c = ColorChooser.chooseColor(editor.getComponent(), "Choose color", color, true); + final Color c = ColorChooser.chooseColor(editor.getComponent(), "Choose Color", color, true); if (c != null) { AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(ColorLineMarkerProvider.class); try { diff --git a/platform/platform-api/src/com/intellij/ui/ColorChooser.java b/platform/platform-api/src/com/intellij/ui/ColorChooser.java index 6777ed74190f..9c566e820bb3 100644 --- a/platform/platform-api/src/com/intellij/ui/ColorChooser.java +++ b/platform/platform-api/src/com/intellij/ui/ColorChooser.java @@ -15,6 +15,7 @@ */ package com.intellij.ui; +import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -32,10 +33,10 @@ public class ColorChooser { @Nullable @Deprecated /** - * @deprecated Use {@link #chooseColor(java.awt.Component, String, java.awt.Color, boolean, java.util.List, boolean)} + * @deprecated Use {@link #chooseColor(Component, String, Color, boolean, java.util.List, boolean)} */ public static Color chooseColor(Component parent, - String caption, + @Nls(capitalization = Nls.Capitalization.Title) String caption, @Nullable Color preselectedColor, boolean enableOpacity, ColorPickerListener[] listeners, @@ -45,7 +46,7 @@ public class ColorChooser { @Nullable public static Color chooseColor(Component parent, - String caption, + @Nls(capitalization = Nls.Capitalization.Title) String caption, @Nullable Color preselectedColor, boolean enableOpacity, List listeners, @@ -54,18 +55,18 @@ public class ColorChooser { } @Nullable - public static Color chooseColor(Component parent, String caption, @Nullable Color preselectedColor, boolean enableOpacity) { + public static Color chooseColor(Component parent, @Nls(capitalization = Nls.Capitalization.Title) String caption, @Nullable Color preselectedColor, boolean enableOpacity) { return chooseColor(parent, caption, preselectedColor, enableOpacity, Collections.emptyList(), false); } @Nullable - public static Color chooseColor(Component parent, String caption, @Nullable Color preselectedColor, boolean enableOpacity, + public static Color chooseColor(Component parent, @Nls(capitalization = Nls.Capitalization.Title) String caption, @Nullable Color preselectedColor, boolean enableOpacity, boolean opacityInPercent) { return chooseColor(parent, caption, preselectedColor, enableOpacity, Collections.emptyList(), opacityInPercent); } @Nullable - public static Color chooseColor(Component parent, String caption, @Nullable Color preselectedColor) { + public static Color chooseColor(Component parent, @Nls(capitalization = Nls.Capitalization.Title) String caption, @Nullable Color preselectedColor) { return chooseColor(parent, caption, preselectedColor, false); } } diff --git a/platform/platform-api/src/com/intellij/ui/ColorChooserService.java b/platform/platform-api/src/com/intellij/ui/ColorChooserService.java index 6f34e5e7fc05..9bb1273d1cc3 100644 --- a/platform/platform-api/src/com/intellij/ui/ColorChooserService.java +++ b/platform/platform-api/src/com/intellij/ui/ColorChooserService.java @@ -16,6 +16,7 @@ package com.intellij.ui; import com.intellij.openapi.components.ServiceManager; +import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -32,20 +33,20 @@ public abstract class ColorChooserService { @Nullable @Deprecated /** - * @deprecated Use {@link #showDialog(java.awt.Component, String, java.awt.Color, boolean, java.util.List, boolean)} + * @deprecated Use {@link #showDialog(Component, String, Color, boolean, java.util.List, boolean)} */ - public abstract Color showDialog(Component parent, String caption, Color preselectedColor, boolean enableOpacity, + public abstract Color showDialog(Component parent, @Nls(capitalization = Nls.Capitalization.Title) String caption, Color preselectedColor, boolean enableOpacity, ColorPickerListener[] listeners); @Nullable @Deprecated /** - * @deprecated Use {@link #showDialog(java.awt.Component, String, java.awt.Color, boolean, java.util.List, boolean)} + * @deprecated Use {@link #showDialog(Component, String, Color, boolean, java.util.List, boolean)} */ - public abstract Color showDialog(Component parent, String caption, Color preselectedColor, boolean enableOpacity, + public abstract Color showDialog(Component parent, @Nls(capitalization = Nls.Capitalization.Title) String caption, Color preselectedColor, boolean enableOpacity, ColorPickerListener[] listeners, boolean opacityInPercent); @Nullable - public abstract Color showDialog(Component parent, String caption, Color preselectedColor, boolean enableOpacity, + public abstract Color showDialog(Component parent, @Nls(capitalization = Nls.Capitalization.Title) String caption, Color preselectedColor, boolean enableOpacity, List listeners, boolean opacityInPercent); } diff --git a/platform/platform-impl/src/com/intellij/ide/actionMacro/ActionMacroManager.java b/platform/platform-impl/src/com/intellij/ide/actionMacro/ActionMacroManager.java index 29d567145512..388c22560abf 100644 --- a/platform/platform-impl/src/com/intellij/ide/actionMacro/ActionMacroManager.java +++ b/platform/platform-impl/src/com/intellij/ide/actionMacro/ActionMacroManager.java @@ -399,11 +399,12 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named public void messageEdt(PlaybackContext context, String text, Type type) { if (type == Type.message || type == Type.error) { + StatusBar statusBar = frame.getStatusBar(); if (context != null) { - frame.getStatusBar().setInfo("Line " + context.getCurrentLine() + ": " + text); + if (statusBar != null) statusBar.setInfo("Line " + context.getCurrentLine() + ": " + text); } else { - frame.getStatusBar().setInfo(text); + if (statusBar != null) statusBar.setInfo(text); } } } @@ -414,7 +415,8 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named runner.run() .doWhenDone(new Runnable() { public void run() { - frame.getStatusBar().setInfo("Script execution finished"); + StatusBar statusBar = frame.getStatusBar(); + statusBar.setInfo("Script execution finished"); } }) .doWhenProcessed(new Runnable() { diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java index 2ec15e544c5b..beaea48e5776 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java @@ -31,6 +31,7 @@ import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.*; import com.intellij.openapi.wm.ToolWindowManager; import gnu.trove.THashSet; @@ -48,8 +49,8 @@ import java.util.*; public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements ProjectComponent, PersistentStateComponent { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.fileEditor.impl.IdeDocumentHistoryImpl"); - private static final int BACK_QUEUE_LIMIT = 25; - private static final int CHANGE_QUEUE_LIMIT = 25; + private static final int BACK_QUEUE_LIMIT = Registry.intValue("editor.navigation.history.stack.size"); + private static final int CHANGE_QUEUE_LIMIT = Registry.intValue("editor.navigation.history.stack.size"); private final Project myProject; diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java index 6d7544b3acb8..88999499e3d8 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.debugger.sourcemap; import com.intellij.openapi.util.SystemInfo; @@ -93,6 +108,7 @@ public class SourceResolver { if (canonicalPath != null && !canonicalPath.equals(path)) { absoluteLocalPathToSourceIndex.put(canonicalPath, sourceIndex); } + return Urls.newLocalFileUrl(path); } } return new UrlImpl(baseUrl.getScheme(), baseUrl.getAuthority(), path, null); diff --git a/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/NameMapper.java b/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/NameMapper.java index 7d763894ae8b..7fc7bd69aa06 100644 --- a/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/NameMapper.java +++ b/platform/script-debugger/debugger-ui/src/com/jetbrains/javascript/debugger/NameMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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.jetbrains.javascript.debugger; import com.google.common.base.CharMatcher; @@ -82,7 +97,7 @@ public class NameMapper { public static void warnSeveralMapping(@NotNull PsiElement element) { // see https://dl.dropboxusercontent.com/u/43511007/s/Screen%20Shot%202015-01-21%20at%2020.33.44.png // var1 mapped to the whole "var c, notes, templates, ..." expression text + unrelated text " ;" - LOG.warn("incorrect sourcemap, several mappings for named element " + element); + LOG.warn("incorrect sourcemap, several mappings for named element " + element.getText()); } @NotNull diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralIdBasedToSMTRunnerEventsConvertor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralIdBasedToSMTRunnerEventsConvertor.java index 9e09381345af..27b4326374aa 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralIdBasedToSMTRunnerEventsConvertor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralIdBasedToSMTRunnerEventsConvertor.java @@ -96,7 +96,7 @@ public class GeneralIdBasedToSMTRunnerEventsConvertor extends GeneralTestEventsP // or it finished after all tests have been run // Lets assume, if at finish all nodes except root suite have final state (passed, failed or ignored), // then all is ok otherwise process was terminated by user - boolean completeTree = isTreeComplete(); + boolean completeTree = isTreeComplete(myRunningTestNodes, myTestsRootProxy); if (completeTree) { myTestsRootProxy.setFinished(); } else { @@ -113,19 +113,6 @@ public class GeneralIdBasedToSMTRunnerEventsConvertor extends GeneralTestEventsP }); } - private boolean isTreeComplete() { - if (!myRunningTestNodes.isEmpty()) { - return false; - } - List children = myTestsRootProxy.getChildren(); - for (SMTestProxy child : children) { - if (!child.isFinal() || child.wasTerminated()) { - return false; - } - } - return true; - } - @Override public void setPrinterProvider(@NotNull TestProxyPrinterProvider printerProvider) { myTestProxyPrinterProvider = printerProvider; diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java index 43562be8ddea..145ce234f3f6 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java @@ -29,6 +29,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.util.Collection; +import java.util.List; +import java.util.Map; /** * Processes events of test runner in general text-based form. @@ -135,4 +138,18 @@ public abstract class GeneralTestEventsProcessor implements Disposable { myTransferToEDTQueue.offer(runnable); } } + + + protected static boolean isTreeComplete(Collection runningTests, SMTestProxy.SMRootTestProxy rootNode) { + if (!runningTests.isEmpty()) { + return false; + } + List children = rootNode.getChildren(); + for (SMTestProxy child : children) { + if (!child.isFinal() || child.wasTerminated()) { + return false; + } + } + return true; + } } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java index f803a80cb55e..987bda70f2fd 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java @@ -100,7 +100,7 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso // or it finished after all tests have been run // Lets assume, if at finish all suites except root suite are passed // then all is ok otherwise process was terminated by user - if (!myTestsRootNode.equals(mySuitesStack.getCurrentSuite())) { + if (!isTreeComplete(myRunningTestsFullNameToProxy.keySet(), myTestsRootNode)) { myTestsRootNode.setTerminated(); myRunningTestsFullNameToProxy.clear(); } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestResultsPanel.java b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestResultsPanel.java index ec3844cb2308..d4df911e1d06 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestResultsPanel.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestResultsPanel.java @@ -26,6 +26,7 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.registry.Registry; +import com.intellij.ui.OnePixelSplitter; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.SideBorder; import com.intellij.util.ui.AwtVisitor; @@ -174,7 +175,7 @@ public abstract class TestResultsPanel extends JPanel implements Disposable, Dat } protected static Splitter createSplitter(final String proportionProperty, final float defaultProportion) { - final Splitter splitter = new Splitter(false); + final Splitter splitter = new OnePixelSplitter(false); splitter.setHonorComponentsMinimumSize(true); final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(); float proportion; diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestStatusLine.java b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestStatusLine.java index f88833308dc5..1ee8013eabb7 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestStatusLine.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestStatusLine.java @@ -22,6 +22,7 @@ import com.intellij.ui.JBProgressBar; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.ui.JBDimension; +import com.intellij.util.ui.JBEmptyBorder; import javax.swing.*; import java.awt.*; @@ -37,16 +38,18 @@ public class TestStatusLine extends JPanel { protected final SimpleColoredComponent myState = new SimpleColoredComponent(); public TestStatusLine() { - super(new GridLayout(1, 2)); - final JPanel progressPanel = new JPanel(new GridBagLayout()); - add(progressPanel); + super(new BorderLayout()); + JPanel progressPanel = new JPanel(new GridBagLayout()); + add(progressPanel, BorderLayout.WEST); myProgressBar.setMaximum(100); - myProgressBar.setBorder(null); - myProgressBar.setMaximumSize(new JBDimension(450, -1)); + final Dimension size = new JBDimension(450, -1); + progressPanel.setMaximumSize(size); + progressPanel.setMinimumSize(size); + progressPanel.setPreferredSize(size); progressPanel.add(myProgressBar, new GridBagConstraints(0, 0, 0, 0, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(2, 0, 0, 8), 0, 0)); + new Insets(2, 2, 0, 8), 0, 0)); setStatusColor(ColorProgressBar.GREEN); - add(myState); + add(myState, BorderLayout.CENTER); myState.append(ExecutionBundle.message("junit.runing.info.starting.label")); } diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 232de98fba03..80fb79995f18 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -138,6 +138,9 @@ editor.durable.folding.state.description=If set, collapsed fold regions will pre editor.soft.wrap.force.limit=10000 editor.soft.wrap.force.limit.description=If document contains lines longer than this value, soft wraps will be forcibly enabled in editor due to performance reasons +editor.navigation.history.stack.size=25 +editor.navigation.history.stack.size.description=Stack size limit for back/forward and last/next edit location navigation + ide.showIndexRebuildMessage=false ide.tabbedPane.bufferedPaint=true diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java index 5f79040a787b..0e485f220f02 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java @@ -354,13 +354,13 @@ public class LineStatusTrackerDrawing { } } - EditorFragmentComponent fragmentComponent = + JComponent fragmentComponent = EditorFragmentComponent.createEditorFragmentComponent(uEditor, range.getVcsLine1(), range.getVcsLine2(), false, false); int leftBorder = fragmentComponent.getBorder().getBorderInsets(fragmentComponent).left; EditorFactory.getInstance().releaseEditor(uEditor); - return Pair.create(fragmentComponent, leftBorder); + return Pair.create(fragmentComponent, leftBorder); } private static String getFileName(final Document document) { diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 5012164ab5ae..d9ed97e9257a 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -931,11 +931,6 @@ Declaration - - com.intellij.codeInsight.intention.impl.ColorChooserIntentionAction - Declaration - - com.intellij.codeInsight.intention.impl.ConvertColorRepresentationIntentionAction Declaration