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

The following examples show how to use com.intellij.openapi.editor.colors.EditorColorsScheme. 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: 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 #2
Source File: IntentionUsagePanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
private 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 #3
Source File: HighlightingUtil.java    From needsmoredojo with Apache License 2.0 6 votes vote down vote up
public static void highlightElement(Editor editor, @NotNull com.intellij.openapi.project.Project project, @NotNull PsiElement[] elements)
{
    final HighlightManager highlightManager =
            HighlightManager.getInstance(project);
    final EditorColorsManager editorColorsManager =
            EditorColorsManager.getInstance();
    final EditorColorsScheme globalScheme =
            editorColorsManager.getGlobalScheme();
    final TextAttributes textattributes =
            globalScheme.getAttributes(
                    EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);

    highlightManager.addOccurrenceHighlights(
            editor, elements, textattributes, true, null);
    final WindowManager windowManager = WindowManager.getInstance();
    final StatusBar statusBar = windowManager.getStatusBar(project);
    statusBar.setInfo("Press Esc to remove highlighting");
}
 
Example #4
Source File: DefaultHighlightInfoProcessor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void highlightsOutsideVisiblePartAreProduced(@Nonnull final HighlightingSession session,
                                                    @Nullable Editor editor,
                                                    @Nonnull final List<? extends HighlightInfo> infos,
                                                    @Nonnull final TextRange priorityRange,
                                                    @Nonnull final TextRange restrictedRange, final int groupId) {
  final PsiFile psiFile = session.getPsiFile();
  final Project project = psiFile.getProject();
  final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
  if (document == null) return;
  final long modificationStamp = document.getModificationStamp();
  ((HighlightingSessionImpl)session).applyInEDT(() -> {
    if (project.isDisposed() || modificationStamp != document.getModificationStamp()) return;

    EditorColorsScheme scheme = session.getColorsScheme();

    UpdateHighlightersUtil
            .setHighlightersOutsideRange(project, document, psiFile, infos, scheme, restrictedRange.getStartOffset(), restrictedRange.getEndOffset(), ProperTextRange.create(priorityRange), groupId);
    if (editor != null) {
      repaintErrorStripeAndIcon(editor, project);
    }
  });
}
 
Example #5
Source File: IdeUtils.java    From StringManipulation with Apache License 2.0 6 votes vote down vote up
public static EditorImpl createEditorPreview(String text, boolean editable) {
	EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
	ColorAndFontOptions options = new ColorAndFontOptions();
	options.reset();
	options.selectScheme(scheme.getName());

	EditorFactory editorFactory = EditorFactory.getInstance();
	Document editorDocument = editorFactory.createDocument(text);
	EditorEx editor = (EditorEx) (editable ? editorFactory.createEditor(editorDocument) : editorFactory.createViewer(editorDocument));
	editor.setColorsScheme(scheme);
	EditorSettings settings = editor.getSettings();
	settings.setLineNumbersShown(true);
	settings.setWhitespacesShown(false);
	settings.setLineMarkerAreaShown(false);
	settings.setIndentGuidesShown(false);
	settings.setFoldingOutlineShown(false);
	settings.setAdditionalColumnsCount(0);
	settings.setAdditionalLinesCount(0);
	settings.setRightMarginShown(false);

	return (EditorImpl) editor;
}
 
Example #6
Source File: HighlightingSessionImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private HighlightingSessionImpl(@Nonnull PsiFile psiFile, @Nonnull DaemonProgressIndicator progressIndicator, EditorColorsScheme editorColorsScheme) {
  myPsiFile = psiFile;
  myProgressIndicator = progressIndicator;
  myEditorColorsScheme = editorColorsScheme;
  myProject = psiFile.getProject();
  myDocument = PsiDocumentManager.getInstance(myProject).getDocument(psiFile);
  myEDTQueue = new TransferToEDTQueue<Runnable>("Apply highlighting results", runnable -> {
    runnable.run();
    return true;
  }, o -> myProject.isDisposed() || getProgressIndicator().isCanceled()) {
    @Override
    protected void schedule(@Nonnull Runnable updateRunnable) {
      ApplicationManager.getApplication().invokeLater(updateRunnable, ModalityState.any());
    }
  };
}
 
Example #7
Source File: LookupCellRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
public LookupCellRenderer(LookupImpl lookup) {
  EditorColorsScheme scheme = lookup.getTopLevelEditor().getColorsScheme();
  myNormalFont = scheme.getFont(EditorFontType.PLAIN);
  myBoldFont = scheme.getFont(EditorFontType.BOLD);

  myLookup = lookup;
  myNameComponent = new MySimpleColoredComponent();
  myNameComponent.setIpad(JBUI.insetsLeft(2));
  myNameComponent.setMyBorder(null);

  myTailComponent = new MySimpleColoredComponent();
  myTailComponent.setIpad(JBUI.emptyInsets());
  myTailComponent.setBorder(JBUI.Borders.emptyRight(10));

  myTypeLabel = new MySimpleColoredComponent();
  myTypeLabel.setIpad(JBUI.emptyInsets());
  myTypeLabel.setBorder(JBUI.Borders.emptyRight(6));

  myPanel = new LookupPanel();
  myPanel.add(myNameComponent, BorderLayout.WEST);
  myPanel.add(myTailComponent, BorderLayout.CENTER);
  myPanel.add(myTypeLabel, BorderLayout.EAST);

  myNormalMetrics = myLookup.getTopLevelEditor().getComponent().getFontMetrics(myNormalFont);
  myBoldMetrics = myLookup.getTopLevelEditor().getComponent().getFontMetrics(myBoldFont);
}
 
Example #8
Source File: DetailViewImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
protected Editor createEditor(@Nullable Project project, Document document, VirtualFile file) {
  EditorEx editor = (EditorEx)EditorFactory.getInstance().createViewer(document, project);

  final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project);

  editor.setFile(file);
  editor.setHighlighter(highlighter);

  EditorSettings settings = editor.getSettings();
  settings.setAnimatedScrolling(false);
  settings.setRefrainFromScrolling(false);
  settings.setLineNumbersShown(true);
  settings.setFoldingOutlineShown(false);
  if (settings instanceof SettingsImpl) {
    ((SettingsImpl)settings).setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.PREVIEW);
  }
  editor.getFoldingModel().setFoldingEnabled(false);

  return editor;
}
 
Example #9
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 #10
Source File: NewClassDialog.java    From json2java4idea with Apache License 2.0 6 votes vote down vote up
private void createUIComponents() {
    final EditorFactory editorFactory = EditorFactory.getInstance();
    jsonDocument = editorFactory.createDocument(EMPTY_TEXT);
    jsonEditor = editorFactory.createEditor(jsonDocument, project, JsonFileType.INSTANCE, false);

    final EditorSettings settings = jsonEditor.getSettings();
    settings.setWhitespacesShown(true);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setLineNumbersShown(true);
    settings.setFoldingOutlineShown(false);
    settings.setRightMarginShown(false);
    settings.setVirtualSpace(false);
    settings.setWheelFontChangeEnabled(false);
    settings.setUseSoftWraps(false);
    settings.setAdditionalColumnsCount(0);
    settings.setAdditionalLinesCount(1);

    final EditorColorsScheme colorsScheme = jsonEditor.getColorsScheme();
    colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null);

    jsonEditor.getContentComponent().setFocusable(true);
    jsonPanel = (JPanel) jsonEditor.getComponent();
}
 
Example #11
Source File: EditorColorsManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public EditorColorsScheme[] getAllSchemes() {
  List<EditorColorsScheme> schemes = mySchemesManager.getAllSchemes();
  EditorColorsScheme[] result = schemes.toArray(new EditorColorsScheme[schemes.size()]);
  Arrays.sort(result, new Comparator<EditorColorsScheme>() {
    @Override
    public int compare(@Nonnull EditorColorsScheme s1, @Nonnull EditorColorsScheme s2) {
      if (isDefaultScheme(s1) && !isDefaultScheme(s2)) return -1;
      if (!isDefaultScheme(s1) && isDefaultScheme(s2)) return 1;
      if (s1.getName().equals(DEFAULT_NAME)) return -1;
      if (s2.getName().equals(DEFAULT_NAME)) return 1;
      return s1.getName().compareToIgnoreCase(s2.getName());
    }
  });
  return result;
}
 
Example #12
Source File: RecentLocationsRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList<? extends RecentLocationItem> list, RecentLocationItem value, int index, boolean selected, boolean hasFocus) {
  EditorEx editor = value.getEditor();
  if (myProject.isDisposed() || editor.isDisposed()) {
    return super.getListCellRendererComponent(list, value, index, selected, hasFocus);
  }

  EditorColorsScheme colorsScheme = editor.getColorsScheme();
  String breadcrumbs = myData.getBreadcrumbsMap(myCheckBox.isSelected()).get(value.getInfo());
  JPanel panel = new JPanel(new VerticalFlowLayout(0, 0));
  if (index != 0) {
    panel.add(createSeparatorLine(colorsScheme));
  }
  panel.add(createTitleComponent(myProject, list, mySpeedSearch, breadcrumbs, value.getInfo(), colorsScheme, selected));
  panel.add(setupEditorComponent(editor, editor.getDocument().getText(), mySpeedSearch, colorsScheme, selected));

  return panel;
}
 
Example #13
Source File: DiffDrawUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Color getDividerColorFromScheme(@Nonnull EditorColorsScheme scheme) {
  Color gutterBackground = scheme.getColor(EditorColors.GUTTER_BACKGROUND);
  if (gutterBackground == null) {
    gutterBackground = EditorColors.GUTTER_BACKGROUND.getDefaultColor();
  }
  return gutterBackground;
}
 
Example #14
Source File: SchemesPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean updateDescription(boolean modified) {
  EditorColorsScheme scheme = myOptions.getSelectedScheme();

  if (modified && (ColorAndFontOptions.isReadOnly(scheme))) {
    FontOptions.showReadOnlyMessage(this, false);
    return false;
  }

  return true;
}
 
Example #15
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 #16
Source File: RTExternalAnnotator.java    From react-templates-plugin with MIT License 5 votes vote down vote up
@Nullable
    private static ExternalLintAnnotationInput collectInformation(@NotNull PsiFile psiFile, @Nullable Editor editor) {
        if (psiFile.getContext() != null || !RTFileUtil.isRTFile(psiFile)) {
            return null;
        }
        VirtualFile virtualFile = psiFile.getVirtualFile();
        if (virtualFile == null || !virtualFile.isInLocalFileSystem()) {
            return null;
        }
        if (psiFile.getViewProvider() instanceof MultiplePsiFilesPerDocumentFileViewProvider) {
            return null;
        }
        Project project = psiFile.getProject();
        RTProjectComponent component = project.getComponent(RTProjectComponent.class);
        if (component == null || !component.isValidAndEnabled()) {
            return null;
        }
        Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
        if (document == null) {
            return null;
        }
        String fileContent = document.getText();
        if (StringUtil.isEmptyOrSpaces(fileContent)) {
            return null;
        }
        EditorColorsScheme colorsScheme = editor == null ? null : editor.getColorsScheme();
//        tabSize = getTabSize(editor);
//        tabSize = 4;
        return new ExternalLintAnnotationInput(project, psiFile, fileContent, colorsScheme);
    }
 
Example #17
Source File: FontOptions.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean updateDescription(boolean modified) {
  EditorColorsScheme scheme = myOptions.getSelectedScheme();

  if (modified && (ColorAndFontOptions.isReadOnly(scheme))) {
    return false;
  }

  myDispatcher.getMulticaster().fontChanged();

  return true;
}
 
Example #18
Source File: DesktopTextEditorImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
protected Runnable loadEditorInBackground() {
  EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myFile, scheme, myProject);
  EditorEx editor = (EditorEx)getEditor();
  highlighter.setText(editor.getDocument().getImmutableCharSequence());
  return () -> editor.setHighlighter(highlighter);
}
 
Example #19
Source File: MergePanel2.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setColorScheme(EditorColorsScheme scheme) {
  for (Editor editor : getEditors()) {
    if (editor != null) {
      ((EditorEx)editor).setColorsScheme(scheme);
    }
  }
  myPanel.setColorScheme(scheme);
}
 
Example #20
Source File: EditorColorsSchemeImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public EditorColorsScheme clone() {
  EditorColorsSchemeImpl newScheme = new EditorColorsSchemeImpl(myParentScheme, myEditorColorsManager);
  copyTo(newScheme);
  newScheme.setName(getName());
  return newScheme;
}
 
Example #21
Source File: DiffOptionsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(EditorColorsScheme scheme) {
  TextAttributesKey key = myDiffType.getAttributesKey();
  TextAttributes attrs = new TextAttributes(null, myBackgroundColor, null, EffectType.BOXED, Font.PLAIN);
  attrs.setErrorStripeColor(myStripebarColor);
  scheme.setAttributes(key, attrs);
}
 
Example #22
Source File: LineMarkersPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static LineMarkerInfo<PsiElement> createMethodSeparatorLineMarker(@Nonnull PsiElement startFrom, @Nonnull EditorColorsManager colorsManager) {
  LineMarkerInfo<PsiElement> info = new LineMarkerInfo<>(startFrom, startFrom.getTextRange(), null, Pass.LINE_MARKERS, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT);
  EditorColorsScheme scheme = colorsManager.getGlobalScheme();
  info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
  info.separatorPlacement = SeparatorPlacement.TOP;
  return info;
}
 
Example #23
Source File: DiffDividerDrawUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static List<DividerSeparator> createVisibleSeparators(@Nonnull Editor editor1,
                                                             @Nonnull Editor editor2,
                                                             @Nonnull DividerSeparatorPaintable paintable) {
  final List<DividerSeparator> separators = new ArrayList<DividerSeparator>();

  final Transformation[] transformations = new Transformation[]{getTransformation(editor1), getTransformation(editor2)};

  final Interval leftInterval = getVisibleInterval(editor1);
  final Interval rightInterval = getVisibleInterval(editor2);

  final int height1 = editor1.getLineHeight();
  final int height2 = editor2.getLineHeight();

  final EditorColorsScheme scheme = editor1.getColorsScheme();

  paintable.process(new DividerSeparatorPaintable.Handler() {
    @Override
    public boolean process(int line1, int line2) {
      if (leftInterval.startLine > line1 + 1 && rightInterval.startLine > line2 + 1) return true;
      if (leftInterval.endLine < line1 && rightInterval.endLine < line2) return false;

      separators.add(createSeparator(transformations, line1, line2, height1, height2, scheme));
      return true;
    }
  });

  return separators;
}
 
Example #24
Source File: BraceHighlightingHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void highlightBrace(@Nonnull TextRange braceRange, boolean matched) {
  EditorColorsScheme scheme = myEditor.getColorsScheme();
  final TextAttributes attributes =
          matched ? scheme.getAttributes(CodeInsightColors.MATCHED_BRACE_ATTRIBUTES)
                  : scheme.getAttributes(CodeInsightColors.UNMATCHED_BRACE_ATTRIBUTES);


  RangeHighlighter rbraceHighlighter =
          myEditor.getMarkupModel().addRangeHighlighter(
                  braceRange.getStartOffset(), braceRange.getEndOffset(), HighlighterLayer.LAST + 1, attributes, HighlighterTargetArea.EXACT_RANGE);
  rbraceHighlighter.setGreedyToLeft(false);
  rbraceHighlighter.setGreedyToRight(false);
  registerHighlighter(rbraceHighlighter);
}
 
Example #25
Source File: AbstractValueHint.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void invokeHint(Runnable hideRunnable) {
  myHideRunnable = hideRunnable;

  if (!canShowHint()) {
    hideHint();
    return;
  }

  if (myType == ValueHintType.MOUSE_ALT_OVER_HINT) {
    EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
    TextAttributes attributes = scheme.getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
    attributes = NavigationUtil.patchAttributesColor(attributes, myCurrentRange, myEditor);

    myHighlighter = myEditor.getMarkupModel().addRangeHighlighter(myCurrentRange.getStartOffset(), myCurrentRange.getEndOffset(),
                                                                  HighlighterLayer.SELECTION + 1, attributes,
                                                                  HighlighterTargetArea.EXACT_RANGE);
    Component internalComponent = myEditor.getContentComponent();
    myStoredCursor = internalComponent.getCursor();
    internalComponent.addKeyListener(myEditorKeyListener);
    internalComponent.setCursor(hintCursor());
    if (LOG.isDebugEnabled()) {
      LOG.debug("internalComponent.setCursor(hintCursor())");
    }
  }
  else {
    evaluateAndShowHint();
  }
}
 
Example #26
Source File: SeverityUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static SeverityRegistrar.SeverityBasedTextAttributes getSeverityBasedTextAttributes(@Nonnull SeverityRegistrar registrar, @Nonnull HighlightInfoType type) {
  final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  final TextAttributes textAttributes = scheme.getAttributes(type.getAttributesKey());
  if (textAttributes != null) {
    return new SeverityRegistrar.SeverityBasedTextAttributes(textAttributes, (HighlightInfoType.HighlightInfoTypeImpl)type);
  }
  return new SeverityRegistrar.SeverityBasedTextAttributes(registrar.getTextAttributesBySeverity(type.getSeverity(null)), (HighlightInfoType.HighlightInfoTypeImpl)type);
}
 
Example #27
Source File: CustomizeUIThemeStepPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void applyLaf(String lafName, Component component) {
  UIManager.LookAndFeelInfo info = getLookAndFeelInfo(lafName);
  if (info == null) return;
  try {
    UIManager.setLookAndFeel(info.getClassName());

    if (!myInitial) {
      LafManager.getInstance().setCurrentLookAndFeel(info);
      if(info instanceof LafWithColorScheme) {
        EditorColorsManager editorColorsManager = EditorColorsManager.getInstance();
        EditorColorsScheme scheme = editorColorsManager.getScheme(((LafWithColorScheme)info).getColorSchemeName());
        if(scheme != null) {
          editorColorsManager.setGlobalScheme(scheme);
        }
      }
    }
    Window window = SwingUtilities.getWindowAncestor(component);
    if (window != null) {
      window.setBackground(new Color(UIUtil.getPanelBackground().getRGB()));
      SwingUtilities.updateComponentTreeUI(window);
    }
    if (myColumnMode) {
      myPreviewLabel.setIcon(myLafNames.get(lafName));
      myPreviewLabel.setBorder(BorderFactory.createLineBorder(UIManager.getColor("Label.foreground")));
    }
  }
  catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
    e.printStackTrace();
  }
}
 
Example #28
Source File: ColorAndFontOptions.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(EditorColorsScheme scheme) {
  if (myGetSetBackground != null) {
    myGetSetBackground.apply(scheme);
  }
  if (myGetSetForeground != null) {
    myGetSetForeground.apply(scheme);
  }
}
 
Example #29
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 #30
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);
}