Java 类com.intellij.openapi.editor.colors.impl.DelegateColorScheme 实例源码

项目:intellij-ce-playground    文件:EditorTextFieldCellRenderer.java   
@NotNull
private RendererComponent getEditorPanel(final JTable table) {
  RendererComponent panel = UIUtil.getClientProperty(table, MY_PANEL_PROPERTY);
  if (panel != null) {
    DelegateColorScheme scheme = (DelegateColorScheme)panel.getEditor().getColorsScheme();
    scheme.setDelegate(EditorColorsManager.getInstance().getGlobalScheme());
    return panel;
  }

  panel = createRendererComponent(myProject, myFileType, myInheritFontFromLaF);
  Disposer.register(this, panel);
  Disposer.register(this, new Disposable() {
    @Override
    public void dispose() {
      UIUtil.putClientProperty(table, MY_PANEL_PROPERTY, null);
    }
  });

  table.putClientProperty(MY_PANEL_PROPERTY, panel);
  return panel;
}
项目:tools-idea    文件:ConsoleViewUtil.java   
public static void setupConsoleEditor(final EditorEx editor, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) {
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    public void run() {
      editor.setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.CONSOLE);

      final EditorSettings editorSettings = editor.getSettings();
      editorSettings.setLineMarkerAreaShown(lineMarkerAreaShown);
      editorSettings.setIndentGuidesShown(false);
      editorSettings.setLineNumbersShown(false);
      editorSettings.setFoldingOutlineShown(foldingOutlineShown);
      editorSettings.setAdditionalPageAtBottom(false);
      editorSettings.setAdditionalColumnsCount(0);
      editorSettings.setAdditionalLinesCount(0);

      editor.putUserData(EDITOR_IS_CONSOLE_VIEW, true);

      final DelegateColorScheme scheme = updateConsoleColorScheme(editor.getColorsScheme());
      editor.setColorsScheme(scheme);
      scheme.setColor(EditorColors.CARET_ROW_COLOR, null);
      scheme.setColor(EditorColors.RIGHT_MARGIN_COLOR, null);
    }
  });
}
项目:consulo    文件:ConsoleViewUtil.java   
public static void setupConsoleEditor(@Nonnull final EditorEx editor, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) {
  ApplicationManager.getApplication().runReadAction(() -> {
    editor.setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.CONSOLE);

    final EditorSettings editorSettings = editor.getSettings();
    editorSettings.setLineMarkerAreaShown(lineMarkerAreaShown);
    editorSettings.setIndentGuidesShown(false);
    editorSettings.setLineNumbersShown(false);
    editorSettings.setFoldingOutlineShown(foldingOutlineShown);
    editorSettings.setAdditionalPageAtBottom(false);
    editorSettings.setAdditionalColumnsCount(0);
    editorSettings.setAdditionalLinesCount(0);
    editorSettings.setRightMarginShown(false);
    editorSettings.setCaretRowShown(false);
    editor.getGutterComponentEx().setPaintBackground(false);

    editor.putUserData(EDITOR_IS_CONSOLE_VIEW, true);

    final DelegateColorScheme scheme = updateConsoleColorScheme(editor.getColorsScheme());
    if (UISettings.getInstance().PRESENTATION_MODE) {
      scheme.setEditorFontSize(UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE);
    }
    editor.setColorsScheme(scheme);
  });
}
项目:consulo    文件:EditorTextFieldCellRenderer.java   
@Nonnull
private RendererComponent getEditorPanel(final JTable table) {
  RendererComponent panel = UIUtil.getClientProperty(table, MY_PANEL_PROPERTY);
  if (panel != null) {
    DelegateColorScheme scheme = (DelegateColorScheme)panel.getEditor().getColorsScheme();
    scheme.setDelegate(EditorColorsManager.getInstance().getGlobalScheme());
    return panel;
  }

  panel = createRendererComponent(myProject, myFileType, myInheritFontFromLaF);
  Disposer.register(this, panel);
  Disposer.register(this, new Disposable() {
    @Override
    public void dispose() {
      UIUtil.putClientProperty(table, MY_PANEL_PROPERTY, null);
    }
  });

  table.putClientProperty(MY_PANEL_PROPERTY, panel);
  return panel;
}
项目:intellij-ce-playground    文件:ConsoleViewUtil.java   
public static void setupConsoleEditor(@NotNull final EditorEx editor, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) {
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    @Override
    public void run() {
      editor.setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.CONSOLE);

      final EditorSettings editorSettings = editor.getSettings();
      editorSettings.setLineMarkerAreaShown(lineMarkerAreaShown);
      editorSettings.setIndentGuidesShown(false);
      editorSettings.setLineNumbersShown(false);
      editorSettings.setFoldingOutlineShown(foldingOutlineShown);
      editorSettings.setAdditionalPageAtBottom(false);
      editorSettings.setAdditionalColumnsCount(0);
      editorSettings.setAdditionalLinesCount(0);
      editorSettings.setRightMarginShown(false);
      editorSettings.setCaretRowShown(false);
      editor.getGutterComponentEx().setPaintBackground(false);

      editor.putUserData(EDITOR_IS_CONSOLE_VIEW, true);

      final DelegateColorScheme scheme = updateConsoleColorScheme(editor.getColorsScheme());
      if (UISettings.getInstance().PRESENTATION_MODE) {
        scheme.setEditorFontSize(UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE);
      }
      editor.setColorsScheme(scheme);
    }
  });
}
项目:intellij-ce-playground    文件:EditorTextField.java   
protected 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);
  editor.setColorsScheme(new DelegateColorScheme(colorsScheme) {
    @Override
    public TextAttributes getAttributes(TextAttributesKey key) {
      final TextAttributes attributes = super.getAttributes(key);
      if (!isEnabled() && attributes != null) {
        return new TextAttributes(UIUtil.getInactiveTextColor(), attributes.getBackgroundColor(), attributes.getEffectColor(), attributes.getEffectType(), attributes.getFontType());
      }

      return attributes;
    }
  });

  // color scheme settings:
  setupEditorFont(editor);
  updateBorder(editor);
  editor.setBackgroundColor(getBackgroundColor(isEnabled(), colorsScheme));
}
项目:intellij-ce-playground    文件:bigFile.java   
@Override
public void reinitSettings() {
  assertIsDispatchThread();
  clearSettingsCache();

  reinitDocumentIndentOptions();

  for (EditorColorsScheme scheme = myScheme; scheme instanceof DelegateColorScheme; scheme = ((DelegateColorScheme)scheme).getDelegate()) {
    if (scheme instanceof MyColorSchemeDelegate) {
      ((MyColorSchemeDelegate)scheme).updateGlobalScheme();
      break;
    }
  }

  boolean softWrapsUsedBefore = mySoftWrapModel.isSoftWrappingEnabled();

  mySettings.reinitSettings();
  mySoftWrapModel.reinitSettings();
  myCaretModel.reinitSettings();
  mySelectionModel.reinitSettings();
  ourCaretBlinkingCommand.setBlinkCaret(mySettings.isBlinkCaret());
  ourCaretBlinkingCommand.setBlinkPeriod(mySettings.getCaretBlinkPeriod());
  if (myUseNewRendering) {
    myView.reinitSettings();
  }
  else {
    mySizeContainer.reset();
  }
  myFoldingModel.rebuild();

  if (softWrapsUsedBefore ^ mySoftWrapModel.isSoftWrappingEnabled()) {
    mySizeContainer.reset();
    validateSize();
  }

  myHighlighter.setColorScheme(myScheme);
  myFoldingModel.refreshSettings();

  myGutterComponent.reinitSettings();
  myGutterComponent.revalidate();

  myEditorComponent.repaint();

  initTabPainter();
  updateCaretCursor();

  if (myInitialMouseEvent != null) {
    myIgnoreMouseEventsConsecutiveToInitial = true;
  }

  myCaretModel.updateVisualPosition();

  // make sure carets won't appear at invalid positions (e.g. on Tab width change)
  for (Caret caret : getCaretModel().getAllCarets()) {
    caret.moveToOffset(caret.getOffset());
  }
}
项目:intellij-ce-playground    文件:bigFile.java   
@Override
public void reinitSettings() {
  assertIsDispatchThread();
  clearSettingsCache();

  reinitDocumentIndentOptions();

  for (EditorColorsScheme scheme = myScheme;
       scheme instanceof DelegateColorScheme;
       scheme = ((DelegateColorScheme)scheme).getDelegate()) {
    if (scheme instanceof MyColorSchemeDelegate) {
      ((MyColorSchemeDelegate)scheme).updateGlobalScheme();
      break;
    }
  }

  boolean softWrapsUsedBefore = mySoftWrapModel.isSoftWrappingEnabled();

  mySettings.reinitSettings();
  mySoftWrapModel.reinitSettings();
  myCaretModel.reinitSettings();
  mySelectionModel.reinitSettings();
  ourCaretBlinkingCommand.setBlinkCaret(mySettings.isBlinkCaret());
  ourCaretBlinkingCommand.setBlinkPeriod(mySettings.getCaretBlinkPeriod());
  if (myUseNewRendering) {
    myView.reinitSettings();
  }
  else {
    mySizeContainer.reset();
  }
  myFoldingModel.rebuild();

  if (softWrapsUsedBefore ^ mySoftWrapModel.isSoftWrappingEnabled()) {
    mySizeContainer.reset();
    validateSize();
  }

  myHighlighter.setColorScheme(myScheme);
  myFoldingModel.refreshSettings();

  myGutterComponent.reinitSettings();
  myGutterComponent.revalidate();

  myEditorComponent.repaint();

  initTabPainter();
  updateCaretCursor();

  if (myInitialMouseEvent != null) {
    myIgnoreMouseEventsConsecutiveToInitial = true;
  }

  myCaretModel.updateVisualPosition();

  // make sure carets won't appear at invalid positions (e.g. on Tab width change)
  for (Caret caret : getCaretModel().getAllCarets()) {
    caret.moveToOffset(caret.getOffset());
  }
}
项目:intellij-ce-playground    文件:EditorImpl.java   
@Override
public void reinitSettings() {
  assertIsDispatchThread();
  clearSettingsCache();

  for (EditorColorsScheme scheme = myScheme; scheme instanceof DelegateColorScheme; scheme = ((DelegateColorScheme)scheme).getDelegate()) {
    if (scheme instanceof MyColorSchemeDelegate) {
      ((MyColorSchemeDelegate)scheme).updateGlobalScheme();
      break;
    }
  }

  boolean softWrapsUsedBefore = mySoftWrapModel.isSoftWrappingEnabled();

  mySettings.reinitSettings();
  mySoftWrapModel.reinitSettings();
  myCaretModel.reinitSettings();
  mySelectionModel.reinitSettings();
  ourCaretBlinkingCommand.setBlinkCaret(mySettings.isBlinkCaret());
  ourCaretBlinkingCommand.setBlinkPeriod(mySettings.getCaretBlinkPeriod());
  if (myUseNewRendering) {
    myView.reinitSettings();
  }
  else {
    mySizeContainer.reset();
  }
  myFoldingModel.rebuild();

  if (softWrapsUsedBefore ^ mySoftWrapModel.isSoftWrappingEnabled()) {
    mySizeContainer.reset();
    validateSize();
  }

  myHighlighter.setColorScheme(myScheme);
  myFoldingModel.refreshSettings();

  myGutterComponent.reinitSettings();
  myGutterComponent.revalidate();

  myEditorComponent.repaint();

  initTabPainter();
  updateCaretCursor();

  if (myInitialMouseEvent != null) {
    myIgnoreMouseEventsConsecutiveToInitial = true;
  }

  myCaretModel.updateVisualPosition();

  // make sure carets won't appear at invalid positions (e.g. on Tab width change)
  for (Caret caret : getCaretModel().getAllCarets()) {
    caret.moveToOffset(caret.getOffset());
  }
}
项目:intellij-ce-playground    文件:ConsoleViewUtil.java   
@NotNull
public static DelegateColorScheme updateConsoleColorScheme(@NotNull EditorColorsScheme scheme) {
  return new DelegateColorScheme(scheme) {
    @NotNull
    @Override
    public Color getDefaultBackground() {
      final Color color = getColor(ConsoleViewContentType.CONSOLE_BACKGROUND_KEY);
      return color == null ? super.getDefaultBackground() : color;
    }

    @NotNull
    @Override
    public FontPreferences getFontPreferences() {
      return getConsoleFontPreferences();
    }

    @Override
    public int getEditorFontSize() {
      return getConsoleFontSize();
    }

    @Override
    public String getEditorFontName() {
      return getConsoleFontName();
    }

    @Override
    public float getLineSpacing() {
      return getConsoleLineSpacing();
    }

    @Override
    public Font getFont(EditorFontType key) {
      return super.getFont(EditorFontType.getConsoleType(key));
    }

    @Override
    public void setEditorFontSize(int fontSize) {
      setConsoleFontSize(fontSize);
    }
  };
}
项目:tools-idea    文件:EditorImpl.java   
@Override
public void reinitSettings() {
  assertIsDispatchThread();
  myCharHeight = -1;
  myLineHeight = -1;
  myDescent = -1;
  myPlainFontMetrics = null;

  clearTextWidthCache();

  boolean softWrapsUsedBefore = mySoftWrapModel.isSoftWrappingEnabled();

  mySettings.reinitSettings();
  mySoftWrapModel.reinitSettings();
  myCaretModel.reinitSettings();
  mySelectionModel.reinitSettings();
  ourCaretBlinkingCommand.setBlinkCaret(mySettings.isBlinkCaret());
  ourCaretBlinkingCommand.setBlinkPeriod(mySettings.getCaretBlinkPeriod());
  mySizeContainer.reset();
  myFoldingModel.rebuild();

  if (softWrapsUsedBefore ^ mySoftWrapModel.isSoftWrappingEnabled()) {
    mySizeContainer.reset();
    validateSize();
  }

  final EditorColorsScheme scheme =
    myScheme instanceof DelegateColorScheme ? ((DelegateColorScheme)myScheme).getDelegate() : myScheme;
  if (scheme instanceof MyColorSchemeDelegate) {
    ((MyColorSchemeDelegate)scheme).updateGlobalScheme();
  }
  myHighlighter.setColorScheme(myScheme);
  myFoldingModel.refreshSettings();

  myGutterComponent.reinitSettings();
  myGutterComponent.revalidate();

  myEditorComponent.repaint();

  initTabPainter();
  updateCaretCursor();

  if (myInitialMouseEvent != null) {
    myIgnoreMouseEventsConsecutiveToInitial = true;
  }

  // There is a possible case that 'use soft wrap' setting value is changed and we need to repaint all affected lines then.
  repaintToScreenBottom(getCaretModel().getLogicalPosition().line);
  int y = getCaretModel().getVisualLineStart() * getLineHeight();
  myGutterComponent.repaint(0, y, myGutterComponent.getWidth(), myGutterComponent.getHeight() - y);
  getCaretModel().moveToOffset(getCaretModel().getOffset());
}
项目:tools-idea    文件:ConsoleViewUtil.java   
public static DelegateColorScheme updateConsoleColorScheme(EditorColorsScheme scheme) {
  return new DelegateColorScheme(scheme) {
    @NotNull
    @Override
    public Color getDefaultBackground() {
      final Color color = getColor(ConsoleViewContentType.CONSOLE_BACKGROUND_KEY);
      return color == null ? super.getDefaultBackground() : color;
    }

    @NotNull
    @Override
    public FontPreferences getFontPreferences() {
      return getConsoleFontPreferences();
    }

    @Override
    public int getEditorFontSize() {
      return getConsoleFontSize();
    }

    @Override
    public String getEditorFontName() {
      return getConsoleFontName();
    }

    @Override
    public float getLineSpacing() {
      return getConsoleLineSpacing();
    }

    @Override
    public Font getFont(EditorFontType key) {
      return super.getFont(EditorFontType.getConsoleType(key));
    }

    @Override
    public void setEditorFontSize(int fontSize) {
      setConsoleFontSize(fontSize);
    }
  };
}
项目:tools-idea    文件:EditorTextField.java   
protected void initOneLineMode(final EditorEx editor) {
  final boolean isOneLineMode = isOneLineMode();

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

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

  // Probably we need change scheme only for color schemas with white BG, but on the other hand
  // FindUsages dialog always uses FindUsages color scheme based on a default one and should be also fixed
  //
  //final EditorColorsScheme customGlobalScheme;
  //final EditorColorsScheme currentScheme = EditorColorsManager.getInstance().getGlobalScheme();
  //if (currentScheme.getDefaultBackground() == Color.WHITE) {
  //  customGlobalScheme = currentScheme;
  //} else {
  //  final EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME);
  //  customGlobalScheme = isOneLineMode ? defaultScheme : null;
  //}
  editor.setColorsScheme(editor.createBoundColorSchemeDelegate(customGlobalScheme));

  final EditorColorsScheme colorsScheme = editor.getColorsScheme();
  colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null);
  editor.setColorsScheme(new DelegateColorScheme(colorsScheme) {
    @Override
    public TextAttributes getAttributes(TextAttributesKey key) {
      final TextAttributes attributes = super.getAttributes(key);
      if (!isEnabled() && attributes != null) {
        return new TextAttributes(UIUtil.getInactiveTextColor(), attributes.getBackgroundColor(), attributes.getEffectColor(), attributes.getEffectType(), attributes.getFontType());
      }

      return attributes;
    }
  });

  // color scheme settings:
  setupEditorFont(editor);
  updateBorder(editor);
  editor.setBackgroundColor(getBackgroundColor(!myIsViewer, colorsScheme));
}
项目:consulo    文件:EditorImpl.java   
@Override
public void reinitSettings() {
  assertIsDispatchThread();

  for (EditorColorsScheme scheme = myScheme; scheme instanceof DelegateColorScheme; scheme = ((DelegateColorScheme)scheme).getDelegate()) {
    if (scheme instanceof MyColorSchemeDelegate) {
      ((MyColorSchemeDelegate)scheme).updateGlobalScheme();
      break;
    }
  }

  boolean softWrapsUsedBefore = mySoftWrapModel.isSoftWrappingEnabled();

  mySettings.reinitSettings();
  mySoftWrapModel.reinitSettings();
  myCaretModel.reinitSettings();
  mySelectionModel.reinitSettings();
  ourCaretBlinkingCommand.setBlinkCaret(mySettings.isBlinkCaret());
  ourCaretBlinkingCommand.setBlinkPeriod(mySettings.getCaretBlinkPeriod());
  myView.reinitSettings();
  myFoldingModel.rebuild();
  myInlayModel.reinitSettings();

  if (softWrapsUsedBefore ^ mySoftWrapModel.isSoftWrappingEnabled()) {
    validateSize();
  }

  myHighlighter.setColorScheme(myScheme);
  myFoldingModel.refreshSettings();

  myGutterComponent.reinitSettings();
  myGutterComponent.revalidate();

  myEditorComponent.repaint();

  updateCaretCursor();

  if (myInitialMouseEvent != null) {
    myIgnoreMouseEventsConsecutiveToInitial = true;
  }

  myCaretModel.updateVisualPosition();

  // make sure carets won't appear at invalid positions (e.g. on Tab width change)
  for (Caret caret : getCaretModel().getAllCarets()) {
    caret.moveToOffset(caret.getOffset());
  }
}
项目:consulo    文件:ConsoleViewUtil.java   
@Nonnull
public static DelegateColorScheme updateConsoleColorScheme(@Nonnull EditorColorsScheme scheme) {
  return new DelegateColorScheme(scheme) {
    @Nonnull
    @Override
    public Color getDefaultBackground() {
      final Color color = getColor(ConsoleViewContentType.CONSOLE_BACKGROUND_KEY);
      return color == null ? super.getDefaultBackground() : color;
    }

    @Nonnull
    @Override
    public FontPreferences getFontPreferences() {
      return getConsoleFontPreferences();
    }

    @Override
    public int getEditorFontSize() {
      return getConsoleFontSize();
    }

    @Override
    public String getEditorFontName() {
      return getConsoleFontName();
    }

    @Override
    public float getLineSpacing() {
      return getConsoleLineSpacing();
    }

    @Override
    public Font getFont(EditorFontType key) {
      return super.getFont(EditorFontType.getConsoleType(key));
    }

    @Override
    public void setEditorFontSize(int fontSize) {
      setConsoleFontSize(fontSize);
    }
  };
}