Search in sources :

Example 1 with CodeStyleSettingsManager

use of com.intellij.psi.codeStyle.CodeStyleSettingsManager in project android-butterknife-zelezny by avast.

the class Utils method getPrefix.

/**
     * Load field name prefix from code style
     *
     * @return
     */
public static String getPrefix() {
    if (PropertiesComponent.getInstance().isValueSet(Settings.PREFIX)) {
        return PropertiesComponent.getInstance().getValue(Settings.PREFIX);
    } else {
        CodeStyleSettingsManager manager = CodeStyleSettingsManager.getInstance();
        CodeStyleSettings settings = manager.getCurrentSettings();
        return settings.FIELD_NAME_PREFIX;
    }
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) CodeStyleSettingsManager(com.intellij.psi.codeStyle.CodeStyleSettingsManager)

Example 2 with CodeStyleSettingsManager

use of com.intellij.psi.codeStyle.CodeStyleSettingsManager in project intellij-community by JetBrains.

the class CodeStyleSettingsUtilImpl method showCodeStyleSettings.

/**
   * Shows code style settings suitable for the project passed. I.e. it shows project code style page if one
   * is configured to use own code style scheme or global one in other case.
   * @param project
   * @return Returns true if settings were modified during editing session.
   */
@Override
public boolean showCodeStyleSettings(Project project, final Class pageToSelect) {
    CodeStyleSettingsManager settingsManager = CodeStyleSettingsManager.getInstance(project);
    CodeStyleSettings savedSettings = settingsManager.getCurrentSettings().clone();
    final CodeStyleSchemesConfigurable configurable = new CodeStyleSchemesConfigurable(project);
    ShowSettingsUtil.getInstance().editConfigurable(project, configurable, () -> {
        if (pageToSelect != null) {
            configurable.selectPage(pageToSelect);
        }
    });
    return !savedSettings.equals(settingsManager.getCurrentSettings());
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) CodeStyleSettingsManager(com.intellij.psi.codeStyle.CodeStyleSettingsManager)

Example 3 with CodeStyleSettingsManager

use of com.intellij.psi.codeStyle.CodeStyleSettingsManager in project intellij-community by JetBrains.

the class CodeStyleSchemesModel method setUsePerProjectSettings.

/**
   * Updates 'use per-project settings' value within the current model and optionally at the project settings.
   *
   * @param usePerProjectSettings  defines whether 'use per-project settings' are in use
   * @param commit                 flag that defines if current project settings should be applied as well
   */
public void setUsePerProjectSettings(final boolean usePerProjectSettings, final boolean commit) {
    if (commit) {
        final CodeStyleSettingsManager projectSettings = getProjectSettings();
        projectSettings.USE_PER_PROJECT_SETTINGS = usePerProjectSettings;
        projectSettings.PER_PROJECT_SETTINGS = myProjectScheme.getCodeStyleSettings();
    }
    if (myUsePerProjectSettings != usePerProjectSettings) {
        myUsePerProjectSettings = usePerProjectSettings;
        myDispatcher.getMulticaster().usePerProjectSettingsOptionChanged();
        myDispatcher.getMulticaster().currentSchemeChanged(this);
    }
}
Also used : CodeStyleSettingsManager(com.intellij.psi.codeStyle.CodeStyleSettingsManager)

Example 4 with CodeStyleSettingsManager

use of com.intellij.psi.codeStyle.CodeStyleSettingsManager in project intellij-community by JetBrains.

the class CodeStyleSchemesModel method apply.

public void apply() {
    CodeStyleSettingsManager projectSettingsManager = getProjectSettings();
    projectSettingsManager.USE_PER_PROJECT_SETTINGS = myUsePerProjectSettings;
    projectSettingsManager.PREFERRED_PROJECT_CODE_STYLE = myUsePerProjectSettings || myGlobalSelected == null ? null : myGlobalSelected.getName();
    projectSettingsManager.PER_PROJECT_SETTINGS = myProjectScheme.getCodeStyleSettings();
    CodeStyleSchemesImpl.getSchemeManager().setSchemes(mySchemes, myGlobalSelected, null);
}
Also used : CodeStyleSettingsManager(com.intellij.psi.codeStyle.CodeStyleSettingsManager)

Example 5 with CodeStyleSettingsManager

use of com.intellij.psi.codeStyle.CodeStyleSettingsManager in project intellij-community by JetBrains.

the class QuickChangeCodeStyleSchemeAction method fillActions.

@Override
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
    final CodeStyleSettingsManager manager = CodeStyleSettingsManager.getInstance(project);
    if (manager.PER_PROJECT_SETTINGS != null) {
        //noinspection HardCodedStringLiteral
        group.add(new AnAction("<project>", "", manager.USE_PER_PROJECT_SETTINGS ? ourCurrentAction : ourNotCurrentAction) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e) {
                manager.USE_PER_PROJECT_SETTINGS = true;
            }
        });
    }
    CodeStyleScheme currentScheme = CodeStyleSchemes.getInstance().getCurrentScheme();
    for (CodeStyleScheme scheme : CodeStyleSchemesImpl.getSchemeManager().getAllSchemes()) {
        addScheme(group, manager, currentScheme, scheme, false);
    }
}
Also used : CodeStyleSettingsManager(com.intellij.psi.codeStyle.CodeStyleSettingsManager) CodeStyleScheme(com.intellij.psi.codeStyle.CodeStyleScheme) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

CodeStyleSettingsManager (com.intellij.psi.codeStyle.CodeStyleSettingsManager)8 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)4 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)1 Project (com.intellij.openapi.project.Project)1 CodeStyleScheme (com.intellij.psi.codeStyle.CodeStyleScheme)1 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)1 XmlTag (com.intellij.psi.xml.XmlTag)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1