com.intellij.openapi.editor.colors.EditorColorsManager Java Examples

The following examples show how to use com.intellij.openapi.editor.colors.EditorColorsManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HighlightUsagesHandlerBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void performHighlighting() {
  boolean clearHighlights = HighlightUsagesHandler.isClearHighlights(myEditor);
  EditorColorsManager manager = EditorColorsManager.getInstance();
  TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  TextAttributes writeAttributes = manager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
  HighlightUsagesHandler.highlightRanges(HighlightManager.getInstance(myEditor.getProject()),
                                         myEditor, attributes, clearHighlights, myReadUsages);
  HighlightUsagesHandler.highlightRanges(HighlightManager.getInstance(myEditor.getProject()),
                                         myEditor, writeAttributes, clearHighlights, myWriteUsages);
  if (!clearHighlights) {
    WindowManager.getInstance().getStatusBar(myEditor.getProject()).setInfo(myStatusText);

    HighlightHandlerBase.setupFindModel(myEditor.getProject()); // enable f3 navigation
  }
  if (myHintText != null) {
    HintManager.getInstance().showInformationHint(myEditor, myHintText);
  }
}
 
Example #2
Source File: SearchForUsagesRunnable.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void flashUsageScriptaculously(@Nonnull final Usage usage) {
  if (!(usage instanceof UsageInfo2UsageAdapter)) {
    return;
  }
  UsageInfo2UsageAdapter usageInfo = (UsageInfo2UsageAdapter)usage;

  Editor editor = usageInfo.openTextEditor(true);
  if (editor == null) return;
  TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES);

  RangeBlinker rangeBlinker = new RangeBlinker(editor, attributes, 6);
  List<Segment> segments = new ArrayList<>();
  Processor<Segment> processor = Processors.cancelableCollectProcessor(segments);
  usageInfo.processRangeMarkers(processor);
  rangeBlinker.resetMarkers(segments);
  rangeBlinker.startBlinking();
}
 
Example #3
Source File: ActionUsagePanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected static Editor createEditor(String text, int column, int line, int selectedLine) {
  EditorFactory editorFactory = EditorFactory.getInstance();
  Document editorDocument = editorFactory.createDocument(text);
  EditorEx editor = (EditorEx)editorFactory.createViewer(editorDocument);
  EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  editor.setColorsScheme(scheme);
  EditorSettings settings = editor.getSettings();
  settings.setWhitespacesShown(true);
  settings.setLineMarkerAreaShown(false);
  settings.setIndentGuidesShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setAdditionalColumnsCount(0);
  settings.setAdditionalLinesCount(0);
  settings.setRightMarginShown(true);
  settings.setRightMargin(60);

  LogicalPosition pos = new LogicalPosition(line, column);
  editor.getCaretModel().moveToLogicalPosition(pos);
  if (selectedLine >= 0) {
    editor.getSelectionModel().setSelection(editorDocument.getLineStartOffset(selectedLine),
                                            editorDocument.getLineEndOffset(selectedLine));
  }

  return editor;
}
 
Example #4
Source File: AbstractRefactoringPanel.java    From IntelliJDeodorant with MIT License 6 votes vote down vote up
private static void highlightPsiElement(PsiElement psiElement, boolean openInEditor) {
    if (openInEditor) {
        EditorHelper.openInEditor(psiElement);
    }

    Editor editor = FileEditorManager.getInstance(psiElement.getProject()).getSelectedTextEditor();
    if (editor == null) {
        return;
    }

    TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
    editor.getMarkupModel().addRangeHighlighter(
            psiElement.getTextRange().getStartOffset(),
            psiElement.getTextRange().getEndOffset(),
            HighlighterLayer.SELECTION,
            attributes,
            HighlighterTargetArea.EXACT_RANGE
    );
}
 
Example #5
Source File: ColorAndFontOptions.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void apply() throws ConfigurationException {
  if (myApplyCompleted) {
    return;
  }
  try {
    EditorColorsManager myColorsManager = EditorColorsManager.getInstance();

    myColorsManager.removeAllSchemes();
    for (MyColorScheme scheme : mySchemes.values()) {
      if (!scheme.isDefault()) {
        scheme.apply();
        myColorsManager.addColorsScheme(scheme.getOriginalScheme());
      }
    }

    EditorColorsScheme originalScheme = mySelectedScheme.getOriginalScheme();
    myColorsManager.setGlobalScheme(originalScheme);
    applyChangesToEditors();

    reset();
  }
  finally {
    myApplyCompleted = true;
  }
}
 
Example #6
Source File: EditorFactoryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public EditorFactoryImpl(Application application) {
  MessageBusConnection busConnection = application.getMessageBus().connect();
  busConnection.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {
    @Override
    public void projectClosed(@Nonnull Project project, @Nonnull UIAccess uiAccess) {
      // validate all editors are disposed after fireProjectClosed() was called, because it's the place where editor should be released
      Disposer.register(project, () -> {
        Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
        boolean isLastProjectClosed = openProjects.length == 0;
        // EditorTextField.releaseEditorLater defer releasing its editor; invokeLater to avoid false positives about such editors.
        ApplicationManager.getApplication().invokeLater(() -> validateEditorsAreReleased(project, isLastProjectClosed));
      });
    }
  });
  busConnection.subscribe(EditorColorsManager.TOPIC, scheme -> refreshAllEditors());

  LaterInvocator.addModalityStateListener(new ModalityStateListener() {
    @Override
    public void beforeModalityStateChanged(boolean entering) {
      for (Editor editor : myEditors) {
        ((DesktopEditorImpl)editor).beforeModalityStateChanged();
      }
    }
  }, ApplicationManager.getApplication());
}
 
Example #7
Source File: FocusModeModel.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void applyFocusMode(@Nonnull Segment focusRange) {
  EditorColorsScheme scheme = ObjectUtils.notNull(myEditor.getColorsScheme(), EditorColorsManager.getInstance().getGlobalScheme());
  Color background = scheme.getDefaultBackground();
  //noinspection UseJBColor
  Color foreground = Registry.getColor(ColorUtil.isDark(background) ? "editor.focus.mode.color.dark" : "editor.focus.mode.color.light", Color.GRAY);
  TextAttributes attributes = new TextAttributes(foreground, background, background, LINE_UNDERSCORE, Font.PLAIN);
  myEditor.putUserData(FOCUS_MODE_ATTRIBUTES, attributes);

  MarkupModel markupModel = myEditor.getMarkupModel();
  DocumentEx document = myEditor.getDocument();
  int textLength = document.getTextLength();

  int start = focusRange.getStartOffset();
  int end = focusRange.getEndOffset();

  if (start <= textLength) myFocusModeMarkup.add(markupModel.addRangeHighlighter(0, start, LAYER, attributes, EXACT_RANGE));
  if (end <= textLength) myFocusModeMarkup.add(markupModel.addRangeHighlighter(end, textLength, LAYER, attributes, EXACT_RANGE));

  myFocusModeRange = document.createRangeMarker(start, end);
}
 
Example #8
Source File: EditorTextField.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void initOneLineMode(final EditorEx editor) {
  final boolean isOneLineMode = isOneLineMode();

  // set mode in editor
  editor.setOneLineMode(isOneLineMode);

  EditorColorsManager colorsManager = EditorColorsManager.getInstance();
  final EditorColorsScheme defaultScheme = UIUtil.isUnderDarcula() ? colorsManager.getGlobalScheme() : colorsManager.getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME);
  EditorColorsScheme customGlobalScheme = isOneLineMode ? defaultScheme : null;

  editor.setColorsScheme(editor.createBoundColorSchemeDelegate(customGlobalScheme));

  EditorColorsScheme colorsScheme = editor.getColorsScheme();
  editor.getSettings().setCaretRowShown(false);

  // color scheme settings:
  setupEditorFont(editor);
  updateBorder(editor);
  editor.setBackgroundColor(getBackgroundColor(isEnabled()));
}
 
Example #9
Source File: TogglePresentationModeAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void tweakEditorAndFireUpdateUI(UISettings settings, boolean inPresentation) {
  EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
  int fontSize = inPresentation ? settings.PRESENTATION_MODE_FONT_SIZE : globalScheme.getEditorFontSize();
  if (inPresentation) {
    ourSavedConsoleFontSize = globalScheme.getConsoleFontSize();
    globalScheme.setConsoleFontSize(fontSize);
  }
  else {
    globalScheme.setConsoleFontSize(ourSavedConsoleFontSize);
  }
  for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
    if (editor instanceof EditorEx) {
      ((EditorEx)editor).setFontSize(fontSize);
    }
  }
  UISettings.getInstance().fireUISettingsChanged();
  LafManager.getInstance().updateUI();
  EditorUtil.reinitSettings();
}
 
Example #10
Source File: CoverageDataManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public CoverageDataManagerImpl(final Project project) {
  myProject = project;
  if (project.isDefault()) {
    return;
  }

  EditorColorsManager.getInstance().addEditorColorsListener(new EditorColorsAdapter() {
    @Override
    public void globalSchemeChange(EditorColorsScheme scheme) {
      chooseSuitesBundle(myCurrentSuitesBundle);
    }
  }, project);

  addSuiteListener(new CoverageViewSuiteListener(this, myProject), myProject);
}
 
Example #11
Source File: FlowInPlaceRenamer.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
private static void addHighlights(List<TextRange> ranges, Editor editor, ArrayList<RangeHighlighter> highlighters) {
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
    HighlightManager highlightManager = HighlightManager.getInstance(editor.getProject());
    Iterator iterator = ranges.iterator();

    while (iterator.hasNext()) {
        TextRange range = (TextRange) iterator.next();
        //highlightManager.addOccurrenceHighlight(editor, range.getStartOffset() + 1, range.getEndOffset() - 1, attributes, 0, highlighters, (Color) null);
        highlightManager.addRangeHighlight(editor, range.getStartOffset() + 1, range.getEndOffset() - 1, attributes, false, highlighters);
    }

    iterator = highlighters.iterator();

    while (iterator.hasNext()) {
        RangeHighlighter highlighter = (RangeHighlighter) iterator.next();
        highlighter.setGreedyToLeft(true);
        highlighter.setGreedyToRight(true);
    }

}
 
Example #12
Source File: MultiLineCellRenderer.java    From intellij-csv-validator with Apache License 2.0 6 votes vote down vote up
protected Font determineFont(@NotNull String text) {
    Font finalFont = UIUtil.getFontWithFallback(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN));

    FontFallbackIterator it = new FontFallbackIterator();
    it.setPreferredFont(finalFont.getFamily(), finalFont.getSize());
    it.setFontStyle(finalFont.getStyle());
    it.start(text, 0, text.length());
    for (; !it.atEnd(); it.advance()) {
        Font font = it.getFont();
        if (!font.getFamily().equals(finalFont.getFamily())) {
            finalFont = font;
            break;
        }
    }

    return finalFont;
}
 
Example #13
Source File: GeneralHighlightingPass.java    From consulo with Apache License 2.0 6 votes vote down vote up
public GeneralHighlightingPass(@Nonnull Project project,
                               @Nonnull PsiFile file,
                               @Nonnull Document document,
                               int startOffset,
                               int endOffset,
                               boolean updateAll,
                               @Nonnull ProperTextRange priorityRange,
                               @Nullable Editor editor,
                               @Nonnull HighlightInfoProcessor highlightInfoProcessor) {
  super(project, document, PRESENTABLE_NAME, file, editor, TextRange.create(startOffset, endOffset), true, highlightInfoProcessor);
  myUpdateAll = updateAll;
  myPriorityRange = priorityRange;

  PsiUtilCore.ensureValid(file);
  boolean wholeFileHighlighting = isWholeFileHighlighting();
  myHasErrorElement = !wholeFileHighlighting && Boolean.TRUE.equals(getFile().getUserData(HAS_ERROR_ELEMENT));
  final DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
  FileStatusMap fileStatusMap = daemonCodeAnalyzer.getFileStatusMap();
  myErrorFound = !wholeFileHighlighting && fileStatusMap.wasErrorFound(getDocument());

  // initial guess to show correct progress in the traffic light icon
  setProgressLimit(document.getTextLength() / 2); // approx number of PSI elements = file length/2
  myGlobalScheme = editor != null ? editor.getColorsScheme() : EditorColorsManager.getInstance().getGlobalScheme();
}
 
Example #14
Source File: CsvColorSettings.java    From intellij-csv-validator with Apache License 2.0 6 votes vote down vote up
public static TextAttributes getTextAttributesOfColumn(int columnIndex, UserDataHolder userDataHolder) {
    List<TextAttributes> textAttributeList = userDataHolder.getUserData(COLUMN_HIGHLIGHT_TEXT_ATTRIBUTES_KEY);
    if (textAttributeList == null) {
        EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
        textAttributeList = new ArrayList<>();
        int maxIndex = 0;
        for (int colorDescriptorIndex = 0; colorDescriptorIndex < MAX_COLUMN_HIGHLIGHT_COLORS; ++colorDescriptorIndex) {
            TextAttributesKey textAttributesKey = COLUMN_HIGHLIGHT_ATTRIBUTES.get(colorDescriptorIndex);
            TextAttributes textAttributes = editorColorsScheme.getAttributes(textAttributesKey);
            textAttributeList.add(textAttributes);
            if (!textAttributesKey.getDefaultAttributes().equals(textAttributes)) {
                maxIndex = colorDescriptorIndex;
            }
        }
        textAttributeList = textAttributeList.subList(0, maxIndex + 1);
        userDataHolder.putUserData(COLUMN_HIGHLIGHT_TEXT_ATTRIBUTES_KEY, textAttributeList);
    }
    return textAttributeList.isEmpty() ? null : textAttributeList.get(columnIndex % textAttributeList.size());
}
 
Example #15
Source File: DiffLineSeparatorRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void paintLine(@Nonnull Graphics g,
                              @Nonnull int[] xPoints, @Nonnull int[] yPoints,
                              int lineHeight,
                              @Nullable EditorColorsScheme scheme) {
  int height = getHeight(lineHeight);
  if (scheme == null) scheme = EditorColorsManager.getInstance().getGlobalScheme();

  Graphics2D gg = ((Graphics2D)g);
  AffineTransform oldTransform = gg.getTransform();

  for (int i = 0; i < height; i++) {
    Color color = getTopBorderColor(i, lineHeight, scheme);
    if (color == null) color = getBottomBorderColor(i, lineHeight, scheme);
    if (color == null) color = getBackgroundColor(scheme);

    gg.setColor(color);
    gg.drawPolyline(xPoints, yPoints, xPoints.length);
    gg.translate(0, 1);
  }
  gg.setTransform(oldTransform);
}
 
Example #16
Source File: DiffUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private static EditorHighlighter createEditorHighlighter(@Nullable Project project, @Nonnull DocumentContent content) {
  FileType type = content.getContentType();
  VirtualFile file = content.getHighlightFile();
  Language language = content.getUserData(DiffUserDataKeys.LANGUAGE);

  EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
  if (language != null) {
    SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
    return highlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());
  }
  if (file != null) {
    if ((type == null || type == PlainTextFileType.INSTANCE) || file.getFileType() == type || file instanceof LightVirtualFile) {
      return highlighterFactory.createEditorHighlighter(project, file);
    }
  }
  if (type != null) {
    return highlighterFactory.createEditorHighlighter(project, type);
  }
  return null;
}
 
Example #17
Source File: CustomHighlightInfoHolder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public TextAttributesScheme getColorsScheme() {
  if (myCustomColorsScheme != null) {
    return myCustomColorsScheme;
  }
  return EditorColorsManager.getInstance().getGlobalScheme();
}
 
Example #18
Source File: MergePanel2.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void setHighlighterSettings(@Nullable EditorColorsScheme settings, @Nonnull EditorPlace place) {
  if (settings == null) {
    settings = EditorColorsManager.getInstance().getGlobalScheme();
  }
  Editor editor = place.getEditor();
  DiffEditorState editorState = place.getState();
  if (editor != null) {
    ((EditorEx)editor).setHighlighter(EditorHighlighterFactory.getInstance().
            createEditorHighlighter(editorState.getFileType(), settings, editorState.getProject()));
  }
}
 
Example #19
Source File: EditorNotificationPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public final Color getBackground() {
  if (myBackgroundColor != null) {
    return myBackgroundColor;
  }
  Color color = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.NOTIFICATION_BACKGROUND);
  return color == null ? UIUtil.getToolTipBackground() : color;
}
 
Example #20
Source File: ArrangementColorsProviderImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Color getBorderColor(boolean selected) {
  final Color cached;
  if (selected) {
    cached = myCachedSelectedBorderColor;
  }
  else {
    cached = myCachedNormalBorderColor;
  }
  if (cached != null) {
    return cached;
  }
  
  Color result = null;
  if (myColorsAware != null) {
    result = myColorsAware.getBorderColor(EditorColorsManager.getInstance().getGlobalScheme(), selected);
  }
  if (result == null) {
    result = selected ? myDefaultSelectedBorderColor : myDefaultNormalBorderColor; 
  }
  if (selected) {
    myCachedSelectedBorderColor = result;
  }
  else {
    myCachedNormalBorderColor = result;
  }
  return result;
}
 
Example #21
Source File: ResetFontSizeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(@Nonnull Editor editor, DataContext dataContext) {
  if (!(editor instanceof EditorEx)) {
    return;
  }
  EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
  int fontSize = ConsoleViewUtil.isConsoleViewEditor(editor) ? globalScheme.getConsoleFontSize() : globalScheme.getEditorFontSize();
  EditorEx editorEx = (EditorEx)editor;
  editorEx.setFontSize(fontSize);
}
 
Example #22
Source File: AnnotationsSettings.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public List<Color> getAuthorsColors(@Nullable EditorColorsScheme scheme) {
  if (scheme == null) scheme = EditorColorsManager.getInstance().getGlobalScheme();
  List<Color> colors = getOrderedColors(scheme);

  List<Color> authorColors = new ArrayList<>();
  for (int i = 0; i < SHUFFLE_STEP; i++) {
    for (int k = 0; k <= colors.size() / SHUFFLE_STEP; k++) {
      int index = k * SHUFFLE_STEP + i;
      if (index < colors.size()) authorColors.add(colors.get(index));
    }
  }

  return authorColors;
}
 
Example #23
Source File: FragmentedEditorHighlighter.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean isUsualAttributes(final TextAttributes ta) {
  if (myUsualAttributes == null) {
    final EditorColorsManager manager = EditorColorsManager.getInstance();
    final EditorColorsScheme[] schemes = manager.getAllSchemes();
    EditorColorsScheme defaultScheme = schemes[0];
    for (EditorColorsScheme scheme : schemes) {
      if (manager.isDefaultScheme(scheme)) {
        defaultScheme = scheme;
        break;
      }
    }
    myUsualAttributes = defaultScheme.getAttributes(HighlighterColors.TEXT);
  }
  return myUsualAttributes.equals(ta);
}
 
Example #24
Source File: InplaceChangeSignature.java    From consulo with Apache License 2.0 5 votes vote down vote up
public InplaceChangeSignature(Project project, Editor editor, @Nonnull PsiElement element) {
  myDocumentManager = PsiDocumentManager.getInstance(project);
  myProject = project;
  try {
    myMarkAction = StartMarkAction.start(editor, project, ChangeSignatureHandler.REFACTORING_NAME);
  }
  catch (StartMarkAction.AlreadyStartedException e) {
    final int exitCode = Messages.showYesNoDialog(myProject, e.getMessage(), ChangeSignatureHandler.REFACTORING_NAME, "Navigate to Started", "Cancel", Messages.getErrorIcon());
    if (exitCode == Messages.CANCEL) return;
    PsiElement method = myStableChange.getMethod();
    VirtualFile virtualFile = PsiUtilCore.getVirtualFile(method);
    new OpenFileDescriptor(project, virtualFile, method.getTextOffset()).navigate(true);
    return;
  }


  myEditor = editor;
  myDetector = LanguageChangeSignatureDetectors.INSTANCE.forLanguage(element.getLanguage());
  myStableChange = myDetector.createInitialChangeInfo(element);
  myInitialSignature = myDetector.extractSignature(myStableChange);
  myInitialName = DescriptiveNameUtil.getDescriptiveName(myStableChange.getMethod());
  TextRange highlightingRange = myDetector.getHighlightingRange(myStableChange);

  HighlightManager highlightManager = HighlightManager.getInstance(myProject);
  TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.LIVE_TEMPLATE_ATTRIBUTES);
  highlightManager.addRangeHighlight(editor, highlightingRange.getStartOffset(), highlightingRange.getEndOffset(), attributes, false, myHighlighters);
  for (RangeHighlighter highlighter : myHighlighters) {
    highlighter.setGreedyToRight(true);
    highlighter.setGreedyToLeft(true);
  }
  myEditor.getDocument().addDocumentListener(this);
  myEditor.putUserData(INPLACE_CHANGE_SIGNATURE, this);
  myPreview = InplaceRefactoring.createPreviewComponent(project, myDetector.getFileType());
  showBalloon();
}
 
Example #25
Source File: PsiElementListCellRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
protected TextAttributes getNavigationItemAttributes(Object value) {
  TextAttributes attributes = null;

  if (value instanceof NavigationItem) {
    TextAttributesKey attributesKey = null;
    final ItemPresentation presentation = ((NavigationItem)value).getPresentation();
    if (presentation instanceof ColoredItemPresentation) attributesKey = ((ColoredItemPresentation)presentation).getTextAttributesKey();

    if (attributesKey != null) {
      attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey);
    }
  }
  return attributes;
}
 
Example #26
Source File: ColorAndFontOptions.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void addImportedScheme(@Nonnull final EditorColorsScheme imported) {
  MyColorScheme newScheme = new MyColorScheme(imported, EditorColorsManager.getInstance());
  initScheme(newScheme);

  mySchemes.put(imported.getName(), newScheme);
  selectScheme(newScheme.getName());
  resetSchemesCombo(null);
}
 
Example #27
Source File: ActionUsagePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ActionUsagePanel() {
  myEditor = (EditorEx)createEditor("", 10, 3, -1);
  setLayout(new BorderLayout());
  add(myEditor.getComponent(), BorderLayout.CENTER);
  TextAttributes blinkAttributes =
          EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES);
  myRangeBlinker = new RangeBlinker(myEditor, blinkAttributes, Integer.MAX_VALUE);
}
 
Example #28
Source File: LivePreview.java    From consulo with Apache License 2.0 5 votes vote down vote up
public LivePreview(@Nonnull SearchResults searchResults) {
  mySearchResults = searchResults;
  searchResultsUpdated(searchResults);
  searchResults.addListener(this);
  EditorUtil.addBulkSelectionListener(mySearchResults.getEditor(), this, myDisposable);
  ApplicationManager.getApplication().getMessageBus().connect(myDisposable).subscribe(EditorColorsManager.TOPIC, this);
}
 
Example #29
Source File: TestResultsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createOutputTab(JComponent console,
                                   AnAction[] consoleActions) {
  JPanel outputTab = new JPanel(new BorderLayout());
  console.setFocusable(true);
  final Color editorBackground = EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground();
  console.setBorder(new CompoundBorder(IdeBorderFactory.createBorder(SideBorder.RIGHT | SideBorder.TOP),
                                       new SideBorder(editorBackground, SideBorder.LEFT)));
  outputTab.add(console, BorderLayout.CENTER);
  final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, new DefaultActionGroup(consoleActions), false);
  outputTab.add(toolbar.getComponent(), BorderLayout.EAST);
  return outputTab;
}
 
Example #30
Source File: TextDiffTypeFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public TextAttributes getAttributes(@Nullable Editor editor) {
  if (editor == null) {
    return EditorColorsManager.getInstance().getGlobalScheme().getAttributes(myKey);
  }
  else {
    return editor.getColorsScheme().getAttributes(myKey);
  }
}