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();
}
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();
}
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;
}
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);
}
}
}
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);
}
}
Aggregations