use of com.intellij.openapi.options.SchemeImportException in project intellij-community by JetBrains.
the class CodeStyleSchemeXmlImporter method getSchemeName.
@NotNull
private static String getSchemeName(@NotNull Element rootElement) throws SchemeImportException {
String rootName = rootElement.getName();
if ("value".equals(rootElement.getName()))
return "Project";
if (!"code_scheme".equals(rootName)) {
throw new SchemeImportException(ApplicationBundle.message("settings.code.style.import.xml.error.invalid.file", rootName));
}
Attribute schemeNameAttr = rootElement.getAttribute("name");
if (schemeNameAttr == null) {
throw new SchemeImportException(ApplicationBundle.message("settings.code.style.import.xml.error.missing.scheme.name"));
}
return schemeNameAttr.getValue();
}
use of com.intellij.openapi.options.SchemeImportException in project intellij-community by JetBrains.
the class EclipseCodeStyleImportWorker method importScheme.
public void importScheme(@NotNull InputStream inputStream, @Nullable final String sourceScheme, final CodeStyleScheme scheme) throws SchemeImportException {
final CodeStyleSettings settings = scheme.getCodeStyleSettings();
EclipseXmlProfileReader reader = new EclipseXmlProfileReader(new EclipseXmlProfileReader.OptionHandler() {
private String myCurrScheme;
@Override
public void handleOption(@NotNull String eclipseKey, @NotNull String value) throws SchemeImportException {
if (sourceScheme == null || myCurrScheme != null && myCurrScheme.equals(sourceScheme)) {
setCodeStyleOption(settings, eclipseKey, value);
}
}
@Override
public void handleName(String name) {
myCurrScheme = name;
}
});
reader.readSettings(inputStream);
}
use of com.intellij.openapi.options.SchemeImportException in project intellij-community by JetBrains.
the class EclipseColorSchemeImporter method readFromStream.
private static String readFromStream(@NotNull final VirtualFile file, @Nullable final EclipseThemeReader.OptionHandler optionHandler) throws SchemeImportException {
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
EclipseThemeReader themeReader = new EclipseThemeReader(optionHandler);
themeReader.readSettings(inputStream);
return themeReader.getThemeName();
} catch (IOException e) {
throw new SchemeImportException(e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
//
}
}
}
}
Aggregations