Search in sources :

Example 1 with CodeStyleScheme

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

the class CodeStyleMainPanel method processListOptions.

public Set<String> processListOptions() {
    final CodeStyleScheme defaultScheme = CodeStyleSchemes.getInstance().getDefaultScheme();
    final NewCodeStyleSettingsPanel panel = ensurePanel(defaultScheme);
    return panel.processListOptions();
}
Also used : CodeStyleScheme(com.intellij.psi.codeStyle.CodeStyleScheme)

Example 2 with CodeStyleScheme

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

the class CodeStyleSchemesActions method copyToIDE.

@Override
protected void copyToIDE(@NotNull CodeStyleScheme scheme) {
    String name = SchemeNameGenerator.getUniqueName(getProjectName(), schemeName -> getModel().containsScheme(schemeName, false));
    CodeStyleScheme newScheme = getModel().exportProjectScheme(name);
    getModel().setUsePerProjectSettings(false);
    getModel().selectScheme(newScheme, null);
    getSchemesPanel().startEdit();
}
Also used : CodeStyleScheme(com.intellij.psi.codeStyle.CodeStyleScheme)

Example 3 with CodeStyleScheme

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

the class CodeStyleSchemesActions method importExternalCodeStyle.

@Nullable
private CodeStyleScheme importExternalCodeStyle(final SchemeImporter<CodeStyleScheme> importer, @NotNull CodeStyleScheme currentScheme) throws SchemeImportException {
    final VirtualFile selectedFile = SchemeImportUtil.selectImportSource(importer.getSourceExtensions(), getSchemesPanel(), CodeStyleSchemesUIConfiguration.Util.getRecentImportFile(), null);
    if (selectedFile != null) {
        CodeStyleSchemesUIConfiguration.Util.setRecentImportFile(selectedFile);
        final SchemeCreator schemeCreator = new SchemeCreator();
        final CodeStyleScheme schemeImported = importer.importScheme(getModel().getProject(), selectedFile, currentScheme, schemeCreator);
        if (schemeImported != null) {
            if (schemeCreator.isSchemeWasCreated()) {
                getModel().fireSchemeListChanged();
            } else {
                getModel().fireSchemeChanged(schemeImported);
            }
            return schemeImported;
        }
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CodeStyleScheme(com.intellij.psi.codeStyle.CodeStyleScheme) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with CodeStyleScheme

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

the class CodeStyleSchemesActions method chooseAndImport.

private void chooseAndImport(@NotNull CodeStyleScheme currentScheme, @NotNull String importerName) {
    if (importerName.equals(SHARED_IMPORT_SOURCE)) {
        new SchemesToImportPopup<CodeStyleScheme>(getSchemesPanel()) {

            @Override
            protected void onSchemeSelected(CodeStyleScheme scheme) {
                if (scheme != null) {
                    getModel().addScheme(scheme, true);
                }
            }
        }.show(getModel().getSchemes());
    } else {
        final SchemeImporter<CodeStyleScheme> importer = SchemeImporterEP.getImporter(importerName, CodeStyleScheme.class);
        if (importer == null)
            return;
        try {
            final CodeStyleScheme scheme = importExternalCodeStyle(importer, currentScheme);
            if (scheme != null) {
                final String additionalImportInfo = StringUtil.notNullize(importer.getAdditionalImportInfo(scheme));
                getSchemesPanel().showStatus(ApplicationBundle.message("message.code.style.scheme.import.success", importerName, scheme.getName(), additionalImportInfo), MessageType.INFO);
            }
        } catch (SchemeImportException e) {
            if (e.isWarning()) {
                getSchemesPanel().showStatus(e.getMessage(), MessageType.WARNING);
                return;
            }
            final String message = ApplicationBundle.message("message.code.style.scheme.import.failure", importerName, e.getMessage());
            getSchemesPanel().showStatus(message, MessageType.ERROR);
        }
    }
}
Also used : CodeStyleScheme(com.intellij.psi.codeStyle.CodeStyleScheme)

Example 5 with CodeStyleScheme

use of com.intellij.psi.codeStyle.CodeStyleScheme 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

CodeStyleScheme (com.intellij.psi.codeStyle.CodeStyleScheme)19 Nullable (org.jetbrains.annotations.Nullable)5 CodeStyleSchemeImpl (com.intellij.psi.impl.source.codeStyle.CodeStyleSchemeImpl)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 CodeStyleSchemes (com.intellij.psi.codeStyle.CodeStyleSchemes)2 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)2 File (java.io.File)2 CodeStyleSchemesModel (com.intellij.application.options.codeStyle.CodeStyleSchemesModel)1 CodeStyleSchemesPanel (com.intellij.application.options.codeStyle.CodeStyleSchemesPanel)1 CodeStyleSettingsListener (com.intellij.application.options.codeStyle.CodeStyleSettingsListener)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 EditorSettingsExternalizable (com.intellij.openapi.editor.ex.EditorSettingsExternalizable)1 SchemeFactory (com.intellij.openapi.options.SchemeFactory)1 CodeStyleSettingsManager (com.intellij.psi.codeStyle.CodeStyleSettingsManager)1 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)1 CodeStyleSchemeXmlImporter (com.intellij.psi.impl.source.codeStyle.CodeStyleSchemeXmlImporter)1 Accessor (com.intellij.util.xmlb.Accessor)1 SerializationFilter (com.intellij.util.xmlb.SerializationFilter)1 THashSet (gnu.trove.THashSet)1