private void doTest(boolean enabled, String document) { InspectionProfileImpl.INIT_INSPECTIONS = true; try { myFixture.configureByText(PlainTextFileType.INSTANCE, document); myFixture.enableInspections(new SpellCheckingInspection()); EditorCustomization customization = SpellCheckingEditorCustomizationProvider.getInstance().getCustomization(enabled); assertNotNull(customization); customization.customize((EditorEx)myFixture.getEditor()); myFixture.checkHighlighting(); } finally { InspectionProfileImpl.INIT_INSPECTIONS = false; } }
@NotNull private static EditorTextField createTextField(@NotNull Project project) { final EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class); List<EditorCustomization> features = ContainerUtil.packNullables(SoftWrapsEditorCustomization.ENABLED, SpellCheckingEditorCustomizationProvider.getInstance().getDisabledCustomization()); EditorTextField textField = service.getEditorField(FileTypes.PLAIN_TEXT.getLanguage(), project, features); textField.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), textField.getBorder())); textField.setOneLineMode(false); return textField; }
@Override protected EditorEx createEditor() { // editor created lazy, so we need to update editor customization after initialization EditorEx editorEx = super.createEditor(); EditorCustomization customization = SpellCheckingEditorCustomizationProvider.getInstance().getDisabledCustomization(); if (customization != null) { customization.customize(editorEx); } return editorEx; }
public static List<EditorCustomization> getVcsConfigurationCustomizations( Project project, VcsConfiguration config) { return ImmutableList.of( new RightMarginEditorCustomization( config.USE_COMMIT_MESSAGE_MARGIN, CommitMessageInspectionProfile.getBodyRightMargin(project))); }
public static List<EditorCustomization> getVcsConfigurationCustomizations( Project project, VcsConfiguration config) { return ImmutableList.of( SpellCheckingEditorCustomization.getInstance(config.CHECK_COMMIT_MESSAGE_SPELLING), new RightMarginEditorCustomization( config.USE_COMMIT_MESSAGE_MARGIN, config.COMMIT_MESSAGE_MARGIN_SIZE)); }
public static EditorTextField create(Project project, DataProvider dataProvider) { List<EditorCustomization> customizations = Arrays.<EditorCustomization>asList(SoftWrapsEditorCustomization.ENABLED, SpellCheckingEditorCustomization.DISABLED); EditorTextField editorField = ServiceManager.getService(project, EditorTextFieldProvider.class) .getEditorField(FileTypes.PLAIN_TEXT.getLanguage(), project, customizations); new CommaSeparatedTextFieldCompletion(dataProvider).apply(editorField); return editorField; }
@Override protected EditorEx createEditor() { EditorEx editor = super.createEditor(); EditorCustomization disableSpellChecking = SpellCheckingEditorCustomizationProvider.getInstance().getDisabledCustomization(); if (disableSpellChecking != null) disableSpellChecking.customize(editor); editor.putUserData(AutoPopupController.ALWAYS_AUTO_POPUP, myForceAutoPopup); if (myShowHint) { TextCompletionUtil.installCompletionHint(editor); } return editor; }
@Nullable @Override public EditorCustomization getEnabledCustomization() { return ENABLED; }
@Nullable @Override public EditorCustomization getDisabledCustomization() { return DISABLED; }
public TextFieldWithProgress(@NotNull Project project, @NotNull Collection<String> variants) { super(new BorderLayout()); setBorder(IdeBorderFactory.createEmptyBorder(3)); myProgressIcon = new AsyncProcessIcon("Loading commits"); myTextField = new TextFieldWithAutoCompletion<String>(project, new TextFieldWithAutoCompletion.StringsCompletionProvider(variants, null), false, null) { @Override public void setBackground(Color bg) { super.setBackground(bg); myProgressIcon.setBackground(bg); } @Override protected EditorEx createEditor() { // spell check is not needed EditorEx editor = super.createEditor(); EditorCustomization customization = SpellCheckingEditorCustomizationProvider.getInstance().getDisabledCustomization(); if (customization != null) { customization.customize(editor); } return editor; } @Override protected boolean processKeyBinding(KeyStroke ks, final KeyEvent e, int condition, boolean pressed) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { onOk(); return true; } return false; } }; myTextField.setBorder(IdeBorderFactory.createEmptyBorder()); myProgressIcon.setOpaque(true); myProgressIcon.setBackground(myTextField.getBackground()); add(myTextField, BorderLayout.CENTER); add(myProgressIcon, BorderLayout.EAST); hideProgress(); }
@Nullable public final EditorCustomization getCustomization(boolean enabled) { return enabled ? getEnabledCustomization() : getDisabledCustomization(); }
@Nullable public EditorCustomization getEnabledCustomization() { return null; }
@Nullable public EditorCustomization getDisabledCustomization() { return null; }
@Nonnull public EditorCustomization getCustomization(boolean enabled) { throw new UnsupportedOperationException(); }
@Nullable public EditorCustomization getEnabledCustomization() { SpellCheckerCustomization spellCheckerCustomization = SpellCheckerCustomization.getInstance(); return spellCheckerCustomization.isEnabled() ? spellCheckerCustomization.getCustomization(true) : null; }
@Nullable public EditorCustomization getDisabledCustomization() { SpellCheckerCustomization spellCheckerCustomization = SpellCheckerCustomization.getInstance(); return spellCheckerCustomization.isEnabled() ? spellCheckerCustomization.getCustomization(false) : null; }