Java 类com.intellij.openapi.editor.ex.EditorSettingsExternalizable 实例源码

项目:MissingInActions    文件:ApplicationSettingsForm.java   
public void apply() {
    mySettings.setCustomizedNextWordBounds(myCustomizedNextWordBounds.getValue());
    mySettings.setCustomizedNextWordEndBounds(myCustomizedNextWordEndBounds.getValue());
    mySettings.setCustomizedNextWordStartBounds(myCustomizedNextWordStartBounds.getValue());
    mySettings.setCustomizedPrevWordBounds(myCustomizedPrevWordBounds.getValue());
    mySettings.setCustomizedPrevWordEndBounds(myCustomizedPrevWordEndBounds.getValue());
    mySettings.setCustomizedPrevWordStartBounds(myCustomizedPrevWordStartBounds.getValue());
    mySettings.setRegexSampleText(myRegexSampleText);

    components.apply(mySettings);

    if (mySettings.isMouseCamelHumpsFollow()) {
        EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
        settings.setMouseClickSelectionHonorsCamelWords(settings.isCamelWords());
    }
}
项目:intellij-ce-playground    文件:AbstractToggleUseSoftWrapsAction.java   
@Override
public void setSelected(AnActionEvent e, boolean state) {
  final Editor editor = getEditor(e);
  if (editor == null) {
    return;
  }

  Point point = editor.getScrollingModel().getVisibleArea().getLocation();
  LogicalPosition anchorPosition = editor.xyToLogicalPosition(point);
  int intraLineShift = point.y - editor.logicalPositionToXY(anchorPosition).y;

  if (myGlobal) {
    EditorSettingsExternalizable.getInstance().setUseSoftWraps(state, myAppliancePlace);
  }
  else {
    editor.getSettings().setUseSoftWraps(state);
  }

  if (editor instanceof EditorEx) {
    ((EditorEx)editor).reinitSettings();
  }

  editor.getScrollingModel().disableAnimation();
  editor.getScrollingModel().scrollVertically(editor.logicalPositionToXY(anchorPosition).y + intraLineShift);
  editor.getScrollingModel().enableAnimation();
}
项目:intellij-ce-playground    文件:ToggleDistractionFreeModeAction.java   
public static void applyAndSave(@NotNull PropertiesComponent p,
                                @NotNull UISettings ui,
                                @NotNull EditorSettingsExternalizable.OptionSet eo,
                                @NotNull DaemonCodeAnalyzerSettings ds,
                                String before, String after, boolean value) {
  // @formatter:off
  p.setValue(before + "SHOW_STATUS_BAR",          valueOf(ui.SHOW_STATUS_BAR));           ui.SHOW_STATUS_BAR          = p.getBoolean(after + "SHOW_STATUS_BAR",  value); 
  p.setValue(before + "SHOW_MAIN_TOOLBAR",        valueOf(ui.SHOW_MAIN_TOOLBAR));         ui.SHOW_MAIN_TOOLBAR        = p.getBoolean(after + "SHOW_MAIN_TOOLBAR", value); 
  p.setValue(before + "SHOW_NAVIGATION_BAR",      valueOf(ui.SHOW_NAVIGATION_BAR));       ui.SHOW_NAVIGATION_BAR      = p.getBoolean(after + "SHOW_NAVIGATION_BAR", value); 

  p.setValue(before + "IS_FOLDING_OUTLINE_SHOWN", valueOf(eo.IS_FOLDING_OUTLINE_SHOWN));  eo.IS_FOLDING_OUTLINE_SHOWN = p.getBoolean(after + "IS_FOLDING_OUTLINE_SHOWN", value); 
  p.setValue(before + "IS_WHITESPACES_SHOWN",     valueOf(eo.IS_WHITESPACES_SHOWN));      eo.IS_WHITESPACES_SHOWN     = p.getBoolean(after + "IS_WHITESPACES_SHOWN", value); 
  p.setValue(before + "ARE_LINE_NUMBERS_SHOWN",   valueOf(eo.ARE_LINE_NUMBERS_SHOWN));    eo.ARE_LINE_NUMBERS_SHOWN   = p.getBoolean(after + "ARE_LINE_NUMBERS_SHOWN", value); 
  p.setValue(before + "IS_RIGHT_MARGIN_SHOWN",    valueOf(eo.IS_RIGHT_MARGIN_SHOWN));     eo.IS_RIGHT_MARGIN_SHOWN    = p.getBoolean(after + "IS_RIGHT_MARGIN_SHOWN", value); 
  p.setValue(before + "IS_INDENT_GUIDES_SHOWN",   valueOf(eo.IS_INDENT_GUIDES_SHOWN));    eo.IS_INDENT_GUIDES_SHOWN   = p.getBoolean(after + "IS_INDENT_GUIDES_SHOWN", value); 
  p.setValue(before + "SHOW_BREADCRUMBS",         valueOf(eo.SHOW_BREADCRUMBS));          eo.SHOW_BREADCRUMBS         = p.getBoolean(after + "SHOW_BREADCRUMBS", value); 

  p.setValue(before + "SHOW_METHOD_SEPARATORS",   valueOf(ds.SHOW_METHOD_SEPARATORS));    ds.SHOW_METHOD_SEPARATORS   = p.getBoolean(after + "SHOW_METHOD_SEPARATORS", value);

  p.setValue(before + "HIDE_TOOL_STRIPES",        valueOf(ui.HIDE_TOOL_STRIPES));         ui.HIDE_TOOL_STRIPES        = p.getBoolean(after + "HIDE_TOOL_STRIPES", !value);
  p.setValue(before + "EDITOR_TAB_PLACEMENT",     valueOf(ui.EDITOR_TAB_PLACEMENT));      ui.EDITOR_TAB_PLACEMENT     = p.getInt(after + "EDITOR_TAB_PLACEMENT", value ? SwingConstants.TOP : UISettings.TABS_NONE);
  // @formatter:on
}
项目:intellij-ce-playground    文件:DeleteToLineStartAndEndActionsTest.java   
public void testMoveCaretFromVirtualSpaceToRealOffset() throws IOException {
  boolean virtualSpacesBefore = EditorSettingsExternalizable.getInstance().isVirtualSpace();
  EditorSettingsExternalizable.getInstance().setVirtualSpace(true);

  try {
    doTestDeleteToStart("\n a a \n b b \n", new VisualPosition(1, 10), "\n<caret>\n b b \n", new VisualPosition(1, 0));
    doTestDeleteToStart("\n a a \n b b \n", new VisualPosition(2, 10), "\n a a \n<caret>\n", new VisualPosition(2, 0));
    doTestDeleteToStart("\n a a \n b b \n", new VisualPosition(3, 10), "\n a a \n b b \n<caret>", new VisualPosition(3, 0));

    doTestDeleteToStart("\n a a \n b b \n", new VisualPosition(20, 10), "\n a a \n b b \n<caret>", new VisualPosition(3, 0));

    doTestDeleteToEnd("\n a a \n b b \n", new VisualPosition(1, 10), "\n a a <caret> b b \n", new VisualPosition(1, 5));

    // keep old behavior - not sure if it was intentional or not
    doTestDeleteToEnd("\n a a \n b b \n", new VisualPosition(3, 10), "\n a a \n b b \n<caret>", new VisualPosition(3, 10));
  }
  finally {
    EditorSettingsExternalizable.getInstance().setVirtualSpace(virtualSpacesBefore);
  }
}
项目:intellij-ce-playground    文件:TrailingSpacesStripperTest.java   
public void testDisableStrip_Modify_Save_EnableOnModifiedLines_Modify_Save_ShouldStripModifiedOnly() throws IOException {
  EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);

  configureFromFileText("x.txt", "");
  type("xxx   \nyyy   \nzzz   \n");
  myEditor.getCaretModel().moveToOffset(0);
  end();end();
  FileDocumentManager.getInstance().saveAllDocuments();
  checkResultByText("xxx   <caret>\nyyy   \nzzz   \n");

  settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED);
  type(' ');
  myEditor.getCaretModel().moveToOffset(myEditor.getDocument().getText().length());
  FileDocumentManager.getInstance().saveAllDocuments();
  checkResultByText("xxx\nyyy   \nzzz   \n<caret>");
}
项目:intellij-ce-playground    文件:PsiDocumentManagerImplTest.java   
public void testReparseDoesNotModifyDocument() throws Exception {
  VirtualFile file = createTempFile("txt", null, "1\n2\n3\n", Charset.forName("UTF-8"));
  file.putUserData(TrailingSpacesStripper.OVERRIDE_STRIP_TRAILING_SPACES_KEY, EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED);
  final Document document = FileDocumentManager.getInstance().getDocument(file);
  assertNotNull(document);
  WriteCommandAction.runWriteCommandAction(myProject, new Runnable() {
    @Override
    public void run() {
      document.insertString(document.getTextLength(), " ");
    }
  });

  PsiDocumentManager.getInstance(myProject).reparseFiles(Collections.singleton(file), false);
  assertEquals("1\n2\n3\n ", VfsUtilCore.loadText(file));

  WriteCommandAction.runWriteCommandAction(myProject, new Runnable() {
    @Override
    public void run() {
      document.insertString(0, "-");
    }
  });
  FileDocumentManager.getInstance().saveDocument(document);
  assertEquals("-1\n2\n3\n", VfsUtilCore.loadText(file));
}
项目:intellij-ce-playground    文件:EditorSmartKeysConfigurable.java   
@Override
public void apply() throws ConfigurationException {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
  CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();

  editorSettings.setSmartHome(myCbSmartHome.isSelected());
  codeInsightSettings.SMART_END_ACTION = myCbSmartEnd.isSelected();
  codeInsightSettings.SMART_INDENT_ON_ENTER = myCbSmartIndentOnEnter.isSelected();
  codeInsightSettings.INSERT_BRACE_ON_ENTER = myCbInsertPairCurlyBraceOnEnter.isSelected();
  codeInsightSettings.JAVADOC_STUB_ON_ENTER = myCbInsertJavadocStubOnEnter.isSelected();
  codeInsightSettings.AUTOINSERT_PAIR_BRACKET = myCbInsertPairBracket.isSelected();
  codeInsightSettings.AUTOINSERT_PAIR_QUOTE = myCbInsertPairQuote.isSelected();
  codeInsightSettings.REFORMAT_BLOCK_ON_RBRACE = myCbReformatBlockOnTypingRBrace.isSelected();
  codeInsightSettings.SURROUND_SELECTION_ON_QUOTE_TYPED = myCbSurroundSelectionOnTyping.isSelected();
  editorSettings.setCamelWords(myCbCamelWords.isSelected());
  codeInsightSettings.REFORMAT_ON_PASTE = getReformatPastedBlockValue();
  codeInsightSettings.setBackspaceMode(getSmartBackspaceModeValue());

  super.apply();
}
项目:intellij-ce-playground    文件:EditorOptionsPanel.java   
private void explainTrailingSpaces(@NotNull @EditorSettingsExternalizable.StripTrailingSpaces String stripTrailingSpaces) {
  if(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE.equals(stripTrailingSpaces)) {
    myStripTrailingSpacesExplanationLabel.setVisible(false);
    return;
  }
  myStripTrailingSpacesExplanationLabel.setVisible(true);
  boolean isVirtualSpace = myCbVirtualSpace.isSelected();
  String text;
  String virtSpaceText = myCbVirtualSpace.getText();
  if (isVirtualSpace) {
    text = "Trailing spaces will be trimmed even in the line under caret.<br>To disable trimming in that line uncheck the '<b>"+virtSpaceText+"</b>' above.";
  }
  else {
    text = "Trailing spaces will <b><font color=red>NOT</font></b> be trimmed in the line under caret.<br>To enable trimming in that line too check the '<b>"+virtSpaceText+"</b>' above.";
  }
  myStripTrailingSpacesExplanationLabel.setText(XmlStringUtil.wrapInHtml(text));
}
项目:intellij-ce-playground    文件:EditorAppearanceConfigurable.java   
@Override
public void reset() {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();

  myCbShowMethodSeparators.setSelected(DaemonCodeAnalyzerSettings.getInstance().SHOW_METHOD_SEPARATORS);
  myCbBlinkCaret.setSelected(editorSettings.isBlinkCaret());
  myBlinkIntervalField.setText(Integer.toString(editorSettings.getBlinkPeriod()));
  myBlinkIntervalField.setEnabled(editorSettings.isBlinkCaret());
  myCbRightMargin.setSelected(editorSettings.isRightMarginShown());
  myCbShowLineNumbers.setSelected(editorSettings.isLineNumbersShown());
  myCbBlockCursor.setSelected(editorSettings.isBlockCursor());
  myCbShowWhitespaces.setSelected(editorSettings.isWhitespacesShown());
  myLeadingWhitespacesCheckBox.setSelected(editorSettings.isLeadingWhitespacesShown());
  myInnerWhitespacesCheckBox.setSelected(editorSettings.isInnerWhitespacesShown());
  myTrailingWhitespacesCheckBox.setSelected(editorSettings.isTrailingWhitespacesShown());
  myShowVerticalIndentGuidesCheckBox.setSelected(editorSettings.isIndentGuidesShown());
  myShowBreadcrumbsCheckBox.setSelected(editorSettings.isBreadcrumbsShown());
  //myAntialiasingInEditorCheckBox.setSelected(UISettings.getInstance().ANTIALIASING_IN_EDITOR);
  //myUseLCDRendering.setSelected(UISettings.getInstance().USE_LCD_RENDERING_IN_EDITOR);
  myShowCodeLensInEditorCheckBox.setSelected(UISettings.getInstance().SHOW_EDITOR_TOOLTIP);
  myCbShowIconsInGutter.setSelected(DaemonCodeAnalyzerSettings.getInstance().SHOW_SMALL_ICONS_IN_GUTTER);

  updateWhitespaceCheckboxesState();

  super.reset();
}
项目:intellij-ce-playground    文件:ConsoleConfigurable.java   
@Override
public void reset() {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
  UISettings uiSettings = UISettings.getInstance();

  myCbUseSoftWrapsAtConsole.setSelected(editorSettings.isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE));
  myCommandsHistoryLimitField.setText(Integer.toString(uiSettings.CONSOLE_COMMAND_HISTORY_LIMIT));

  myCbOverrideConsoleCycleBufferSize.setEnabled(ConsoleBuffer.useCycleBuffer());
  myCbOverrideConsoleCycleBufferSize.setSelected(uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE);
  myConsoleCycleBufferSizeField.setEnabled(ConsoleBuffer.useCycleBuffer() && uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE);
  myConsoleCycleBufferSizeField.setText(Integer.toString(uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB));


  myNegativePanel.resetFrom(mySettings.getNegativePatterns());
  myPositivePanel.resetFrom(mySettings.getPositivePatterns());
}
项目:intellij-ce-playground    文件:BreadcrumbsXmlWrapper.java   
@Nullable
public static BreadcrumbsInfoProvider findInfoProvider(@Nullable FileViewProvider viewProvider) {
  if (EditorSettingsExternalizable.getInstance().isBreadcrumbsShown() && viewProvider != null) {
    final Language baseLang = viewProvider.getBaseLanguage();
    BreadcrumbsInfoProvider provider = getInfoProvider(baseLang);
    if (provider != null) {
      return provider;
    }
    for (final Language language : viewProvider.getLanguages()) {
      provider = getInfoProvider(language);
      if (provider != null) {
        return provider;
      }
    }
  }
  return null;
}
项目:tools-idea    文件:FileDocumentManagerImpl.java   
@Override
public void saveDocumentAsIs(@NotNull Document document) {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();

  String trailer = editorSettings.getStripTrailingSpaces();
  boolean ensureEOLonEOF = editorSettings.isEnsureNewLineAtEOF();
  editorSettings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
  editorSettings.setEnsureNewLineAtEOF(false);
  try {
    saveDocument(document);
  }
  finally {
    editorSettings.setStripTrailingSpaces(trailer);
    editorSettings.setEnsureNewLineAtEOF(ensureEOLonEOF);
  }
}
项目:tools-idea    文件:AbstractToggleUseSoftWrapsAction.java   
@Override
public void setSelected(AnActionEvent e, boolean state) {
  final Editor editor = getEditor(e);
  if (editor == null) {
    return;
  }

  if (myGlobal) {
    EditorSettingsExternalizable.getInstance().setUseSoftWraps(state, myAppliancePlace);
  }
  else {
    editor.getSettings().setUseSoftWraps(state);
  }

  if (editor instanceof EditorEx) {
    ((EditorEx)editor).reinitSettings();
  }
}
项目:tools-idea    文件:StripTrailingSpacesTest.java   
public void testDisableStrip_Modify_Save_EnableOnModifiedLines_Modify_Save_ShouldStripModifiedOnly() throws IOException {
  EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);

  configureFromFileText("x.txt", "");
  type("xxx   \nyyy   \nzzz   \n");
  myEditor.getCaretModel().moveToOffset(0);
  end();end();
  FileDocumentManager.getInstance().saveAllDocuments();
  checkResultByText("xxx   <caret>\nyyy   \nzzz   \n");

  settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED);
  type(' ');
  myEditor.getCaretModel().moveToOffset(myEditor.getDocument().getText().length());
  FileDocumentManager.getInstance().saveAllDocuments();
  checkResultByText("xxx\nyyy   \nzzz   \n<caret>");
}
项目:tools-idea    文件:EditorSmartKeysConfigurable.java   
@Override
public void apply() throws ConfigurationException {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
  CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();

  editorSettings.setSmartHome(myCbSmartHome.isSelected());
  codeInsightSettings.SMART_END_ACTION = myCbSmartEnd.isSelected();
  codeInsightSettings.SMART_INDENT_ON_ENTER = myCbSmartIndentOnEnter.isSelected();
  codeInsightSettings.INSERT_BRACE_ON_ENTER = myCbInsertPairCurlyBraceOnEnter.isSelected();
  codeInsightSettings.JAVADOC_STUB_ON_ENTER = myCbInsertJavadocStubOnEnter.isSelected();
  codeInsightSettings.AUTOINSERT_PAIR_BRACKET = myCbInsertPairBracket.isSelected();
  codeInsightSettings.AUTOINSERT_PAIR_QUOTE = myCbInsertPairQuote.isSelected();
  codeInsightSettings.SURROUND_SELECTION_ON_QUOTE_TYPED = myCbSurroundSelectionOnTyping.isSelected();
  editorSettings.setCamelWords(myCbCamelWords.isSelected());
  codeInsightSettings.REFORMAT_ON_PASTE = getReformatPastedBlockValue();

  super.apply();
}
项目:tools-idea    文件:EditorAppearanceConfigurable.java   
@Override
public void reset() {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();

  myCbShowMethodSeparators.setSelected(DaemonCodeAnalyzerSettings.getInstance().SHOW_METHOD_SEPARATORS);
  myCbBlinkCaret.setSelected(editorSettings.isBlinkCaret());
  myBlinkIntervalField.setText(Integer.toString(editorSettings.getBlinkPeriod()));
  myBlinkIntervalField.setEnabled(editorSettings.isBlinkCaret());
  myCbRightMargin.setSelected(editorSettings.isRightMarginShown());
  myCbShowLineNumbers.setSelected(editorSettings.isLineNumbersShown());
  myCbBlockCursor.setSelected(editorSettings.isBlockCursor());
  myCbShowWhitespaces.setSelected(editorSettings.isWhitespacesShown());
  myShowVerticalIndentGuidesCheckBox.setSelected(editorSettings.isIndentGuidesShown());
  myAntialiasingInEditorCheckBox.setSelected(UISettings.getInstance().ANTIALIASING_IN_EDITOR);
  myCbShowIconsInGutter.setSelected(DaemonCodeAnalyzerSettings.getInstance().SHOW_SMALL_ICONS_IN_GUTTER);

  super.reset();
}
项目:consulo    文件:AbstractToggleUseSoftWrapsAction.java   
public static void toggleSoftWraps(@Nonnull Editor editor, @Nullable SoftWrapAppliancePlaces places, boolean state) {
  Point point = editor.getScrollingModel().getVisibleArea().getLocation();
  LogicalPosition anchorPosition = editor.xyToLogicalPosition(point);
  int intraLineShift = point.y - editor.logicalPositionToXY(anchorPosition).y;

  if (places != null) {
    EditorSettingsExternalizable.getInstance().setUseSoftWraps(state, places);
    EditorFactory.getInstance().refreshAllEditors();
  }
  if (editor.getSettings().isUseSoftWraps() != state) {
    editor.getSettings().setUseSoftWraps(state);
  }

  editor.getScrollingModel().disableAnimation();
  editor.getScrollingModel().scrollVertically(editor.logicalPositionToXY(anchorPosition).y + intraLineShift);
  editor.getScrollingModel().enableAnimation();
}
项目:consulo    文件:EditorView.java   
public void reinitSettings() {
  assertIsDispatchThread();
  synchronized (myLock) {
    myPlainSpaceWidth = -1;
    myTabSize = -1;
  }
  switch (EditorSettingsExternalizable.getInstance().getBidiTextDirection()) {
    case LTR:
      myBidiFlags = Bidi.DIRECTION_LEFT_TO_RIGHT;
      break;
    case RTL:
      myBidiFlags = Bidi.DIRECTION_RIGHT_TO_LEFT;
      break;
    default:
      myBidiFlags = Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT;
  }
  setFontRenderContext(null);
  myLogicalPositionCache.reset(false);
  myTextLayoutCache.resetToDocumentSize(false);
  invalidateFoldRegionLayouts();
  setPrefix(myPrefixText, myPrefixAttributes); // recreate prefix layout
  mySizeManager.reset();
}
项目:consulo    文件:EditorSmartKeysConfigurable.java   
@RequiredUIAccess
@Override
protected void apply(@Nonnull Panel panel) throws ConfigurationException {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
  CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();

  editorSettings.setSmartHome(panel.myCbSmartHome.getValue());
  codeInsightSettings.SMART_END_ACTION = panel.myCbSmartEnd.getValue();
  codeInsightSettings.SMART_INDENT_ON_ENTER = panel.myCbSmartIndentOnEnter.getValue();
  codeInsightSettings.INSERT_BRACE_ON_ENTER = panel.myCbInsertPairCurlyBraceOnEnter.getValue();
  codeInsightSettings.INDENT_TO_CARET_ON_PASTE = panel.mySmartIndentPastedLinesCheckBox.getValue();
  codeInsightSettings.JAVADOC_STUB_ON_ENTER = panel.myCbInsertJavadocStubOnEnter.getValue();
  codeInsightSettings.AUTOINSERT_PAIR_BRACKET = panel.myCbInsertPairBracket.getValue();
  codeInsightSettings.AUTOINSERT_PAIR_QUOTE = panel.myCbInsertPairQuote.getValue();
  codeInsightSettings.REFORMAT_BLOCK_ON_RBRACE = panel.myCbReformatBlockOnTypingRBrace.getValue();
  codeInsightSettings.SURROUND_SELECTION_ON_QUOTE_TYPED = panel.myCbSurroundSelectionOnTyping.getValue();
  editorSettings.setCamelWords(panel.myCbCamelWords.getValue());
  codeInsightSettings.REFORMAT_ON_PASTE = panel.myReformatOnPasteCombo.getValue();
  codeInsightSettings.setBackspaceMode(panel.myCbIndentingBackspace.getValue());
}
项目:consulo    文件:EditorSmartKeysConfigurable.java   
@RequiredUIAccess
@Override
protected void reset(@Nonnull Panel panel) {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
  CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();

  panel.myReformatOnPasteCombo.setValue(codeInsightSettings.REFORMAT_ON_PASTE);

  panel.myCbSmartHome.setValue(editorSettings.isSmartHome());
  panel.myCbSmartEnd.setValue(codeInsightSettings.SMART_END_ACTION);

  panel.myCbSmartIndentOnEnter.setValue(codeInsightSettings.SMART_INDENT_ON_ENTER);
  panel.myCbInsertPairCurlyBraceOnEnter.setValue(codeInsightSettings.INSERT_BRACE_ON_ENTER);
  panel.myCbInsertJavadocStubOnEnter.setValue(codeInsightSettings.JAVADOC_STUB_ON_ENTER);

  panel.myCbInsertPairBracket.setValue(codeInsightSettings.AUTOINSERT_PAIR_BRACKET);
  panel.mySmartIndentPastedLinesCheckBox.setValue(codeInsightSettings.INDENT_TO_CARET_ON_PASTE);
  panel.myCbInsertPairQuote.setValue(codeInsightSettings.AUTOINSERT_PAIR_QUOTE);
  panel.myCbReformatBlockOnTypingRBrace.setValue(codeInsightSettings.REFORMAT_BLOCK_ON_RBRACE);
  panel.myCbCamelWords.setValue(editorSettings.isCamelWords());

  panel.myCbSurroundSelectionOnTyping.setValue(codeInsightSettings.SURROUND_SELECTION_ON_QUOTE_TYPED);

  panel.myCbIndentingBackspace.setValue(codeInsightSettings.getBackspaceMode());
}
项目:consulo    文件:EditorAppearanceConfigurable.java   
@RequiredDispatchThread
@Override
public void reset() {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();

  myCbShowMethodSeparators.setSelected(DaemonCodeAnalyzerSettings.getInstance().SHOW_METHOD_SEPARATORS);
  myCbBlinkCaret.setSelected(editorSettings.isBlinkCaret());
  myBlinkIntervalField.setText(Integer.toString(editorSettings.getBlinkPeriod()));
  myBlinkIntervalField.setEnabled(editorSettings.isBlinkCaret());
  myCbRightMargin.setSelected(editorSettings.isRightMarginShown());
  myCbShowLineNumbers.setSelected(editorSettings.isLineNumbersShown());
  myCbBlockCursor.setSelected(editorSettings.isBlockCursor());
  myCbShowWhitespaces.setSelected(editorSettings.isWhitespacesShown());
  myShowVerticalIndentGuidesCheckBox.setSelected(editorSettings.isIndentGuidesShown());

  myShowParameterNameHints.setSelected(editorSettings.isShowParameterNameHints());

  super.reset();
}
项目:consulo    文件:EditorAppearanceConfigurable.java   
@RequiredDispatchThread
@Override
public void apply() throws ConfigurationException {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
  editorSettings.setBlinkCaret(myCbBlinkCaret.isSelected());
  try {
    editorSettings.setBlinkPeriod(Integer.parseInt(myBlinkIntervalField.getText()));
  }
  catch (NumberFormatException ignored) {
  }

  editorSettings.setBlockCursor(myCbBlockCursor.isSelected());
  editorSettings.setRightMarginShown(myCbRightMargin.isSelected());
  editorSettings.setLineNumbersShown(myCbShowLineNumbers.isSelected());
  editorSettings.setWhitespacesShown(myCbShowWhitespaces.isSelected());
  editorSettings.setIndentGuidesShown(myShowVerticalIndentGuidesCheckBox.isSelected());

  EditorOptionsPanel.reinitAllEditors();

  DaemonCodeAnalyzerSettings.getInstance().SHOW_METHOD_SEPARATORS = myCbShowMethodSeparators.isSelected();

  EditorOptionsPanel.restartDaemons();

  applyNameHintsSettings();
  super.apply();
}
项目:consulo    文件:BreadcrumbsWrapper.java   
@Nullable
static BreadcrumbsProvider findInfoProvider(boolean checkSettings, @Nonnull FileViewProvider viewProvider) {
  EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  if (checkSettings && !settings.isBreadcrumbsShown()) return null;

  Language baseLang = viewProvider.getBaseLanguage();
  if (checkSettings && !settings.isBreadcrumbsShownFor(baseLang.getID())) return null;

  BreadcrumbsProvider provider = BreadcrumbsUtil.getInfoProvider(baseLang);
  if (provider == null) {
    for (Language language : viewProvider.getLanguages()) {
      if (!checkSettings || settings.isBreadcrumbsShownFor(language.getID())) {
        provider = BreadcrumbsUtil.getInfoProvider(language);
        if (provider != null) break;
      }
    }
  }
  return provider;
}
项目:consulo    文件:BreadcrumbsInitializingActivity.java   
private static void reinitBreadcrumbsComponent(@Nonnull final FileEditorManager fileEditorManager, @Nonnull VirtualFile file) {
  boolean above = EditorSettingsExternalizable.getInstance().isBreadcrumbsAbove();
  for (FileEditor fileEditor : fileEditorManager.getAllEditors(file)) {
    if (fileEditor instanceof TextEditor) {
      TextEditor textEditor = (TextEditor)fileEditor;
      Editor editor = textEditor.getEditor();
      BreadcrumbsWrapper wrapper = BreadcrumbsWrapper.getBreadcrumbsComponent(editor);
      if (isSuitable(textEditor, file)) {
        if (wrapper != null) {
          if (wrapper.breadcrumbs.above != above) {
            remove(fileEditorManager, fileEditor, wrapper);
            wrapper.breadcrumbs.above = above;
            add(fileEditorManager, fileEditor, wrapper);
          }
          wrapper.queueUpdate();
        }
        else {
          registerWrapper(fileEditorManager, fileEditor, new BreadcrumbsWrapper(editor));
        }
      }
      else if (wrapper != null) {
        disposeWrapper(fileEditorManager, fileEditor, wrapper);
      }
    }
  }
}
项目:MissingInActions    文件:ToggleCamelModeAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
    EditorSettingsExternalizable settingsExternalizable = EditorSettingsExternalizable.getInstance();
    boolean camelMode = settingsExternalizable.isCamelWords();
    settingsExternalizable.setCamelWords(!camelMode);

    if (getInstance().isMouseCamelHumpsFollow()) {
        settingsExternalizable.setMouseClickSelectionHonorsCamelWords(!camelMode);
    }
}
项目:intellij-ce-playground    文件:TrailingSpacesStripper.java   
public void clearLineModificationFlags(@NotNull Document document) {
  if (document instanceof DocumentWindow) {
    document = ((DocumentWindow)document).getDelegate();
  }
  if (!(document instanceof DocumentImpl)) {
    return;
  }

  Editor activeEditor = getActiveEditor(document);

  // when virtual space enabled, we can strip whitespace anywhere
  boolean isVirtualSpaceEnabled = activeEditor == null || activeEditor.getSettings().isVirtualSpace();

  final EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  if (settings == null) return;

  boolean enabled = !Boolean.TRUE.equals(DISABLE_FOR_FILE_KEY.get(FileDocumentManager.getInstance().getFile(document)));
  if (!enabled) return;
  String stripTrailingSpaces = settings.getStripTrailingSpaces();
  final boolean doStrip = !stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
  final boolean inChangedLinesOnly = !stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE);

  int[] caretLines;
  if (activeEditor != null && inChangedLinesOnly && doStrip && !isVirtualSpaceEnabled) {
    List<Caret> carets = activeEditor.getCaretModel().getAllCarets();
    caretLines = new int[carets.size()];
    for (int i = 0; i < carets.size(); i++) {
      Caret caret = carets.get(i);
      caretLines[i] = caret.getLogicalPosition().line;
    }
  }
  else {
    caretLines = ArrayUtil.EMPTY_INT_ARRAY;
  }
  ((DocumentImpl)document).clearLineModificationFlagsExcept(caretLines);
}
项目:intellij-ce-playground    文件:SettingsImpl.java   
@Override
public boolean isVirtualSpace() {
  if (myEditor != null && myEditor.isColumnMode()) return true;
  return myIsVirtualSpace != null
         ? myIsVirtualSpace.booleanValue()
         : EditorSettingsExternalizable.getInstance().isVirtualSpace();
}
项目:intellij-ce-playground    文件:SettingsImpl.java   
@Override
public boolean isCaretInsideTabs() {
  if (myEditor != null && myEditor.isColumnMode()) return true;
  return myIsCaretInsideTabs != null
         ? myIsCaretInsideTabs.booleanValue()
         : EditorSettingsExternalizable.getInstance().isCaretInsideTabs();
}
项目:intellij-ce-playground    文件:UiInfoUsageCollector.java   
@NotNull
@Override
public Set<UsageDescriptor> getUsages() throws CollectUsagesException {
  Set<UsageDescriptor> set = new THashSet<UsageDescriptor>();

  add(set, "Nav Bar visible", navbar() ? 1 : 0);
  add(set, "Nav Bar floating", navbar() ? 0 : 1);
  add(set, "Toolbar visible", toolbar() ? 1 : 0);
  add(set, "Toolbar hidden", toolbar() ? 0 : 1);
  add(set, "Toolbar + NavBar", !toolbar() && navbar() ? 1 : 0);
  add(set, "Toolbar and NavBar hidden", !toolbar() && !navbar() ? 1 : 0);
  add(set, "Status bar visible", status() ? 1 : 0);
  add(set, "Status bar hidden", status() ? 0 : 1);
  add(set, "Tool Window buttons visible", stripes() ? 1 : 0);
  add(set, "Tool Window buttons hidden", stripes() ? 0 : 1);
  add(set, "Recent Files = 15", recent() == 15 ? 1 : 0);
  add(set, "Recent Files (15, 30]", 15 < recent() && recent() < 31 ? 1 : 0);
  add(set, "Recent Files (30, 50]", 30 < recent() && recent() < 51 ? 1 : 0);
  add(set, "Recent Files > 50", 50 < recent() ? 1 : 0);
  add(set, "Block cursor", EditorSettingsExternalizable.getInstance().isBlockCursor() ? 1 : 0);
  add(set, "Line Numbers", EditorSettingsExternalizable.getInstance().isLineNumbersShown() ? 1 : 0);
  add(set, "Soft Wraps", EditorSettingsExternalizable.getInstance().isUseSoftWraps() ? 1 : 0);
  add(set, "Tabs None", tabPlace() == 0 ? 1 : 0);
  add(set, "Tabs Top", tabPlace() == SwingConstants.TOP ? 1 : 0);
  add(set, "Tabs Bottom", tabPlace() == SwingConstants.BOTTOM ? 1 : 0);
  add(set, "Tabs Left", tabPlace() == SwingConstants.LEFT ? 1 : 0);
  add(set, "Tabs Right", tabPlace() == SwingConstants.RIGHT ? 1 : 0);
  add(set, "Retina", UIUtil.isRetina() ? 1 : 0);
  add(set, "Show tips on startup", GeneralSettings.getInstance().isShowTipsOnStartup() ? 1 : 0);

  return set;
}
项目:intellij-ce-playground    文件:ToggleDistractionFreeModeAction.java   
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  Project project = e.getProject();
  RegistryValue value = Registry.get(key);
  boolean enter = !value.asBoolean();
  value.setValue(enter);

  if (project == null) return;

  PropertiesComponent p = PropertiesComponent.getInstance();
  UISettings ui = UISettings.getInstance();
  EditorSettingsExternalizable.OptionSet eo = EditorSettingsExternalizable.getInstance().getOptions();
  DaemonCodeAnalyzerSettings ds = DaemonCodeAnalyzerSettings.getInstance();

  String before = "BEFORE.DISTRACTION.MODE.";
  String after = "AFTER.DISTRACTION.MODE.";
  if (enter) {
    applyAndSave(p, ui, eo, ds, before, after, false);
    TogglePresentationModeAction.storeToolWindows(project);
  }
  else {
    applyAndSave(p, ui, eo, ds, after, before, true);    
    TogglePresentationModeAction.restoreToolWindows(project, true, false);
  }

  UISettings.getInstance().fireUISettingsChanged();
  LafManager.getInstance().updateUI();
  EditorUtil.reinitSettings();
  DaemonCodeAnalyzer.getInstance(project).settingsChanged();
  EditorFactory.getInstance().refreshAllEditors();
}
项目:intellij-ce-playground    文件:TrailingSpacesStripperTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  oldSettings = settings.getState();
  settings.loadState(new EditorSettingsExternalizable.OptionSet());
  settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED);
  settings.setVirtualSpace(false);
}
项目:intellij-ce-playground    文件:TrailingSpacesStripperTest.java   
public void testDoNotStripModifiedLines_And_EnsureBlankLineAtTheEnd_LeavesWhitespacesAtTheEndOfFileAlone() throws IOException {
  EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
  settings.setEnsureNewLineAtEOF(true);

  Document document = configureFromFileText("x.txt", "xxx <caret>\nyyy\n\t\t\t");
  // make any modification, so that Document and file content differ. Otherwise save won't be, and "on-save" actions won't be called.
  document.insertString(0, " ");

  FileDocumentManager.getInstance().saveAllDocuments();
  checkResultByText(" xxx <caret>\nyyy\n\t\t\t\n");
}
项目:intellij-ce-playground    文件:TrailingSpacesStripperTest.java   
public void testOverrideStripTrailingSpaces() throws IOException {
  EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
  configureFromFileText("x.txt", "xxx<caret>\n   222    \nyyy");
  myVFile.putUserData(TrailingSpacesStripper.OVERRIDE_STRIP_TRAILING_SPACES_KEY,
                      EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE);
  type(' ');
  FileDocumentManager.getInstance().saveAllDocuments();
  checkResultByText("xxx <caret>\n   222\nyyy");
}
项目:intellij-ce-playground    文件:TrailingSpacesStripperTest.java   
public void testOverrideEnsureNewline() throws  IOException {
  EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  settings.setEnsureNewLineAtEOF(false);
  configureFromFileText("x.txt", "XXX<caret>\nYYY");
  myVFile.putUserData(TrailingSpacesStripper.OVERRIDE_ENSURE_NEWLINE_KEY, Boolean.TRUE);
  type(' ');
  FileDocumentManager.getInstance().saveAllDocuments();
  checkResultByText("XXX <caret>\nYYY\n");
}
项目:intellij-ce-playground    文件:TrailingSpacesStripperTest.java   
public void testModifySameLineInTwoFilesAndSaveAllShouldStripAtLeastOneFile() throws IOException {
  EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED);

  Editor editor1 = createHeavyEditor("x1.txt", "x11 <caret>\nyyy\n");
  Editor editor2 = createHeavyEditor("x2.txt", "x22 <caret>\nyyy\n");

  type(' ', editor1, getProject());
  type(' ', editor2, getProject());
  FileDocumentManager.getInstance().saveAllDocuments();
  assertEquals("x11\nyyy\n", editor1.getDocument().getText());
  assertEquals("x22  \nyyy\n", editor2.getDocument().getText()); // caret in the way in second but not in the first
}
项目:intellij-ce-playground    文件:QuickDocOnMouseOverManager.java   
@Override
public void run() {
  myAlarm.cancelAllRequests();

  // Skip the request if it's outdated (the mouse is moved other another element).
  DelayedQuickDocInfo info = myDelayedQuickDocInfo;
  if (info == null || !info.targetElement.equals(myActiveElements.get(info.editor))) {
    return;
  }

  // Skip the request if there is a control shown as a result of explicit 'show quick doc' (Ctrl + Q) invocation.
  if (info.docManager.getDocInfoHint() != null && !info.docManager.isCloseOnSneeze()) {
    return;
  }

  // We don't want to show a quick doc control if there is an active hint (e.g. the mouse is under an invalid element
  // and corresponding error info is shown).
  if (!info.docManager.hasActiveDockedDocWindow() && myHintManager.hasShownHintsThatWillHideByOtherHint(false)) {
    myAlarm.addRequest(this, EditorSettingsExternalizable.getInstance().getQuickDocOnMouseOverElementDelayMillis());
    return;
  }

  info.editor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION,
                          info.editor.offsetToVisualPosition(info.originalElement.getTextRange().getStartOffset()));
  try {
    info.docManager.showJavaDocInfo(info.editor, info.targetElement, info.originalElement, myHintCloseCallback, true);
    myDocumentationManager = new WeakReference<DocumentationManager>(info.docManager);
  }
  finally {
    info.editor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, null);
  }
}
项目:intellij-ce-playground    文件:FileInEditorProcessor.java   
private boolean shouldNotify() {
  Application application = ApplicationManager.getApplication();
  if (application.isUnitTestMode() || application.isHeadlessEnvironment()) {
    return false;
  }
  EditorSettingsExternalizable.OptionSet editorOptions = EditorSettingsExternalizable.getInstance().getOptions();
  return editorOptions.SHOW_NOTIFICATION_AFTER_REFORMAT_CODE_ACTION && myEditor != null && !myProcessSelectedText;
}
项目:intellij-ce-playground    文件:CodeFoldingConfigurable.java   
@Override
public void apply() throws ConfigurationException {
  EditorSettingsExternalizable.getInstance().setFoldingOutlineShown(myCbFolding.isSelected());
  super.apply();

  final List<Pair<Editor, Project>> toUpdate = new ArrayList<Pair<Editor, Project>>();
  for (final Editor editor : EditorFactory.getInstance().getAllEditors()) {
    final Project project = editor.getProject();
    if (project != null && !project.isDefault()) {
      toUpdate.add(Pair.create(editor, project));
    }
  }

  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
        for (Pair<Editor, Project> each : toUpdate) {
            if (each.second == null || each.second.isDisposed()) {
                continue;
            }
            final CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(each.second);
            if (foldingManager != null) {
                foldingManager.buildInitialFoldings(each.first);
            }
        }
        EditorOptionsPanel.reinitAllEditors();
    }
  }, ModalityState.NON_MODAL);
}
项目:intellij-ce-playground    文件:EditorOptionsPanel.java   
@NotNull
@EditorSettingsExternalizable.StripTrailingSpaces
private String getStripTrailingSpacesValue() {
  Object selectedItem = myStripTrailingSpacesCombo.getSelectedItem();
  if(STRIP_NONE.equals(selectedItem)) {
    return EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE;
  }
  if(STRIP_CHANGED.equals(selectedItem)){
    return EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED;
  }
  return EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE;
}
项目:intellij-ce-playground    文件:ConsoleConfigurable.java   
@Override
public void apply() throws ConfigurationException {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
  UISettings uiSettings = UISettings.getInstance();

  editorSettings.setUseSoftWraps(myCbUseSoftWrapsAtConsole.isSelected(), SoftWrapAppliancePlaces.CONSOLE);
  boolean uiSettingsChanged = false;
  if (isModified(myCommandsHistoryLimitField, uiSettings.CONSOLE_COMMAND_HISTORY_LIMIT)) {
    uiSettings.CONSOLE_COMMAND_HISTORY_LIMIT = Math.max(0, Math.min(1000, Integer.parseInt(myCommandsHistoryLimitField.getText().trim())));
    uiSettingsChanged = true;
  }
  if (ConsoleBuffer.useCycleBuffer()) {
    if (isModified(myCbOverrideConsoleCycleBufferSize, uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE)) {
      uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE = myCbOverrideConsoleCycleBufferSize.isSelected();
      uiSettingsChanged = true;
    }
    if (isModified(myConsoleCycleBufferSizeField, uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB)) {
      uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB = Math.max(0, Math.min(1024*100, Integer.parseInt(myConsoleCycleBufferSizeField.getText().trim())));
      uiSettingsChanged = true;
    }
  }
  if (uiSettingsChanged) {
    uiSettings.fireUISettingsChanged();
  }


  myNegativePanel.applyTo(mySettings.getNegativePatterns());
  myPositivePanel.applyTo(mySettings.getPositivePatterns());
}