console filter: convenient way to create inactive hyperlinks
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Thu, 19 Feb 2015 14:14:42 +0000 (17:14 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Thu, 19 Feb 2015 14:15:02 +0000 (17:15 +0300)
platform/lang-api/src/com/intellij/execution/filters/Filter.java

index 66cde5b4ef2a5c114cc1b529759555278461dfe1..c1df6860065f816317c05f2f24ed984c348237c5 100644 (file)
  */
 package com.intellij.execution.filters;
 
+import com.intellij.openapi.editor.colors.CodeInsightColors;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
 import com.intellij.openapi.editor.markup.TextAttributes;
+import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -31,6 +34,18 @@ public interface Filter {
   Filter[] EMPTY_ARRAY = new Filter[0];
 
   class Result extends ResultItem {
+
+    private static final TextAttributes INACTIVE_HYPERLINK_ATTRIBUTES;
+    static {
+      TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES);
+      if (attributes != null) {
+        attributes = attributes.clone();
+        attributes.setForegroundColor(UIUtil.getInactiveTextColor());
+        attributes.setEffectColor(UIUtil.getInactiveTextColor());
+      }
+      INACTIVE_HYPERLINK_ATTRIBUTES = attributes;
+    }
+
     protected NextAction myNextAction = NextAction.EXIT;
     protected final List<ResultItem> myResultItems;
 
@@ -46,6 +61,14 @@ public interface Filter {
       myResultItems = null;
     }
 
+    public Result(final int highlightStartOffset,
+                  final int highlightEndOffset,
+                  @Nullable final HyperlinkInfo hyperlinkInfo,
+                  boolean inactiveHyperlink) {
+      super(highlightStartOffset, highlightEndOffset, hyperlinkInfo, inactiveHyperlink ? INACTIVE_HYPERLINK_ATTRIBUTES : null);
+      myResultItems = null;
+    }
+
     public Result(@NotNull List<ResultItem> resultItems) {
       super(-1, -1, null, null);
       myResultItems = resultItems;