Java Code Examples for com.intellij.openapi.editor.ex.EditorSettingsExternalizable#getInstance()
The following examples show how to use
com.intellij.openapi.editor.ex.EditorSettingsExternalizable#getInstance() .
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: BreadcrumbsUtilEx.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static BreadcrumbsProvider findProvider(boolean checkSettings, @Nonnull FileViewProvider viewProvider) { EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance(); if (checkSettings && !settings.isBreadcrumbsShown()) return null; Language baseLang = viewProvider.getBaseLanguage(); if (checkSettings && !isBreadcrumbsShownFor(baseLang)) return null; BreadcrumbsProvider provider = BreadcrumbsUtil.getInfoProvider(baseLang); if (provider == null) { for (Language language : viewProvider.getLanguages()) { if (!checkSettings || isBreadcrumbsShownFor(language)) { provider = BreadcrumbsUtil.getInfoProvider(language); if (provider != null) break; } } } return provider; }
Example 2
Source File: EditorSmartKeysConfigurable.java From consulo with Apache License 2.0 | 6 votes |
@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()); }
Example 3
Source File: EditorSmartKeysConfigurable.java From consulo with Apache License 2.0 | 6 votes |
@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()); }
Example 4
Source File: EditorAppearanceConfigurable.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess @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()); EditorGeneralConfigurable.reinitAllEditors(); DaemonCodeAnalyzerSettings.getInstance().SHOW_METHOD_SEPARATORS = myCbShowMethodSeparators.isSelected(); EditorGeneralConfigurable.restartDaemons(); applyNameHintsSettings(); super.apply(); }
Example 5
Source File: EditorAppearanceConfigurable.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess @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(); }
Example 6
Source File: FlutterConsoleLogManager.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Set our preferred settings for the run console. */ public static void initConsolePreferences() { final PropertiesComponent properties = PropertiesComponent.getInstance(); if (!properties.getBoolean(consolePreferencesSetKey)) { properties.setValue(consolePreferencesSetKey, true); // Set our preferred default settings for console text wrapping. final EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance(); editorSettings.setUseSoftWraps(true, SoftWrapAppliancePlaces.CONSOLE); } }
Example 7
Source File: BreadcrumbsConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@Override public void apply() { boolean modified = false; EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance(); if (settings.setBreadcrumbsAbove(isBreadcrumbsAbove())) modified = true; if (settings.setBreadcrumbsShown(isBreadcrumbsShown())) modified = true; for (Entry<String, JCheckBox> entry : map.entrySet()) { if (settings.setBreadcrumbsShownFor(entry.getKey(), entry.getValue().isSelected())) modified = true; } if (modified) UISettings.getInstance().fireUISettingsChanged(); }
Example 8
Source File: BreadcrumbsConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean isModified() { EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance(); if (isBreadcrumbsAbove() != settings.isBreadcrumbsAbove()) return true; if (isBreadcrumbsShown() != settings.isBreadcrumbsShown()) return true; for (Entry<String, JCheckBox> entry : map.entrySet()) { if (settings.isBreadcrumbsShownFor(entry.getKey()) != entry.getValue().isSelected()) return true; } return false; }
Example 9
Source File: BreadcrumbsConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@Override public void reset() { EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance(); setBreadcrumbsAbove(settings.isBreadcrumbsAbove()); setBreadcrumbsShown(settings.isBreadcrumbsShown()); for (Entry<String, JCheckBox> entry : map.entrySet()) { entry.getValue().setSelected(settings.isBreadcrumbsShownFor(entry.getKey())); } updateEnabled(); }
Example 10
Source File: BreadcrumbsUtilEx.java From consulo with Apache License 2.0 | 5 votes |
public static String findLanguageWithBreadcrumbSettings(Language language) { EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance(); Language base = language; while (base != null) { if (settings.hasBreadcrumbSettings(base.getID())) { return base.getID(); } base = base.getBaseLanguage(); } return language.getID(); }
Example 11
Source File: ToggleBreadcrumbsAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean isSelected(@Nonnull AnActionEvent event) { EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance(); boolean shown = settings.isBreadcrumbsShown(); Editor editor = findEditor(event); if (editor == null) return shown; Boolean forcedShown = BreadcrumbsForceShownSettings.getForcedShown(editor); if (forcedShown != null) return forcedShown; if (!shown) return false; String languageID = findLanguageID(event); return languageID == null || settings.isBreadcrumbsShownFor(languageID); }
Example 12
Source File: CodeFoldingConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Nonnull @Override protected Component createLayout(PropertyBuilder propertyBuilder) { VerticalLayout verticalLayout = VerticalLayout.create(); CheckBox outlineBox = CheckBox.create(ApplicationBundle.message("checkbox.show.code.folding.outline")); verticalLayout.add(outlineBox); EditorSettingsExternalizable externalizable = EditorSettingsExternalizable.getInstance(); propertyBuilder.add(outlineBox, externalizable::isFoldingOutlineShown, externalizable::setFoldingOutlineShown); return verticalLayout; }
Example 13
Source File: GutterIconsConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void apply() throws ConfigurationException { EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance(); if (myShowGutterIconsJBCheckBox.isSelected() != editorSettings.areGutterIconsShown()) { editorSettings.setGutterIconsShown(myShowGutterIconsJBCheckBox.isSelected()); EditorGeneralConfigurable.reinitAllEditors(); } for (GutterIconDescriptor descriptor : myDescriptors) { LineMarkerSettings.getInstance().setEnabled(descriptor, myList.isItemSelected(descriptor)); } for (Project project : ProjectManager.getInstance().getOpenProjects()) { DaemonCodeAnalyzer.getInstance(project).restart(); } }
Example 14
Source File: TrailingSpacesStripper.java From consulo with Apache License 2.0 | 5 votes |
public void clearLineModificationFlags(@Nonnull 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); }
Example 15
Source File: FlutterConsoleLogManager.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Set our preferred settings for the run console. */ public static void initConsolePreferences() { final PropertiesComponent properties = PropertiesComponent.getInstance(); if (!properties.getBoolean(consolePreferencesSetKey)) { properties.setValue(consolePreferencesSetKey, true); // Set our preferred default settings for console text wrapping. final EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance(); editorSettings.setUseSoftWraps(true, SoftWrapAppliancePlaces.CONSOLE); } }
Example 16
Source File: EditorAppearanceConfigurable.java From consulo with Apache License 2.0 | 4 votes |
private void applyNameHintsSettings() { EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance(); settings.setShowParameterNameHints(myShowParameterNameHints.isSelected()); }
Example 17
Source File: TrailingSpacesStripper.java From consulo with Apache License 2.0 | 4 votes |
private void strip(@Nonnull final Document document) { if (!document.isWritable()) return; FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance(); VirtualFile file = fileDocumentManager.getFile(document); if (file == null || !file.isValid() || Boolean.TRUE.equals(DISABLE_FOR_FILE_KEY.get(file))) return; final EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance(); if (settings == null) return; final String overrideStripTrailingSpacesData = file.getUserData(OVERRIDE_STRIP_TRAILING_SPACES_KEY); final Boolean overrideEnsureNewlineData = file.getUserData(OVERRIDE_ENSURE_NEWLINE_KEY); @EditorSettingsExternalizable.StripTrailingSpaces String stripTrailingSpaces = overrideStripTrailingSpacesData != null ? overrideStripTrailingSpacesData : settings.getStripTrailingSpaces(); final boolean doStrip = !stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE); final boolean ensureEOL = overrideEnsureNewlineData != null ? overrideEnsureNewlineData.booleanValue() : settings.isEnsureNewLineAtEOF(); if (doStrip) { final boolean inChangedLinesOnly = !stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE); boolean success = strip(document, inChangedLinesOnly, settings.isKeepTrailingSpacesOnCaretLine()); if (!success) { myDocumentsToStripLater.add(document); } } final int lines = document.getLineCount(); if (ensureEOL && lines > 0) { final int start = document.getLineStartOffset(lines - 1); final int end = document.getLineEndOffset(lines - 1); if (start != end) { final CharSequence content = document.getCharsSequence(); ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(document, null) { @Override public void run() { CommandProcessor.getInstance().runUndoTransparentAction(() -> { if (CharArrayUtil.containsOnlyWhiteSpaces(content.subSequence(start, end)) && doStrip) { document.deleteString(start, end); } else { document.insertString(end, "\n"); } }); } }); } } }
Example 18
Source File: CsvEditorSettings.java From intellij-csv-validator with Apache License 2.0 | 4 votes |
public OptionSet() { EditorSettingsExternalizable editorSettingsExternalizable = EditorSettingsExternalizable.getInstance(); CARET_ROW_SHOWN = editorSettingsExternalizable == null ? true : editorSettingsExternalizable.isCaretRowShown(); USE_SOFT_WRAP = editorSettingsExternalizable == null ? false : editorSettingsExternalizable.isUseSoftWraps(); }