use of net.sf.eclipsecs.core.config.configtypes.BuiltInConfigurationType in project eclipse-cs by checkstyle.
the class GlobalCheckConfigurationWorkingSet method createCheckConfigurationsDocument.
/**
* Transforms the check configurations to a document.
*/
private static Document createCheckConfigurationsDocument(List<CheckConfigurationWorkingCopy> configurations, ICheckConfiguration defaultConfig) {
Document doc = DocumentHelper.createDocument();
Element root = doc.addElement(XMLTags.CHECKSTYLE_ROOT_TAG);
root.addAttribute(XMLTags.VERSION_TAG, CheckConfigurationFactory.CURRENT_CONFIG_FILE_FORMAT_VERSION);
if (defaultConfig != null) {
root.addAttribute(XMLTags.DEFAULT_CHECK_CONFIG_TAG, defaultConfig.getName());
}
for (ICheckConfiguration config : configurations) {
// configurations
if (config.getType() instanceof BuiltInConfigurationType || !config.isGlobal()) {
continue;
}
Element configEl = root.addElement(XMLTags.CHECK_CONFIG_TAG);
configEl.addAttribute(XMLTags.NAME_TAG, config.getName());
configEl.addAttribute(XMLTags.LOCATION_TAG, config.getLocation());
configEl.addAttribute(XMLTags.TYPE_TAG, config.getType().getInternalName());
if (config.getDescription() != null) {
configEl.addAttribute(XMLTags.DESCRIPTION_TAG, config.getDescription());
}
// Write resolvable properties
for (ResolvableProperty prop : config.getResolvableProperties()) {
Element propEl = configEl.addElement(XMLTags.PROPERTY_TAG);
propEl.addAttribute(XMLTags.NAME_TAG, prop.getPropertyName());
propEl.addAttribute(XMLTags.VALUE_TAG, prop.getValue());
}
for (Map.Entry<String, String> entry : config.getAdditionalData().entrySet()) {
Element addEl = configEl.addElement(XMLTags.ADDITIONAL_DATA_TAG);
addEl.addAttribute(XMLTags.NAME_TAG, entry.getKey());
addEl.addAttribute(XMLTags.VALUE_TAG, entry.getValue());
}
}
return doc;
}
use of net.sf.eclipsecs.core.config.configtypes.BuiltInConfigurationType in project eclipse-cs by checkstyle.
the class ProjectConfigurationWorkingCopy method writeLocalConfiguration.
/**
* Writes a local check configuration.
*
* @param checkConfig
* the local check configuration
* @param docRoot
* the root element of the project configuration
*/
private void writeLocalConfiguration(ICheckConfiguration checkConfig, Element docRoot) {
// configurations
if (checkConfig.getType() instanceof BuiltInConfigurationType || checkConfig.isGlobal()) {
return;
}
// RFE 1420212
String location = checkConfig.getLocation();
if (checkConfig.getType() instanceof ProjectConfigurationType) {
IProject project = mProjectConfig.getProject();
IWorkspaceRoot root = project.getWorkspace().getRoot();
IFile configFile = root.getFile(new Path(location));
IProject configFileProject = configFile.getProject();
// path part
if (project.equals(configFileProject)) {
location = configFile.getProjectRelativePath().toString();
}
}
Element configEl = docRoot.addElement(XMLTags.CHECK_CONFIG_TAG);
configEl.addAttribute(XMLTags.NAME_TAG, checkConfig.getName());
configEl.addAttribute(XMLTags.LOCATION_TAG, location);
configEl.addAttribute(XMLTags.TYPE_TAG, checkConfig.getType().getInternalName());
if (checkConfig.getDescription() != null) {
configEl.addAttribute(XMLTags.DESCRIPTION_TAG, checkConfig.getDescription());
}
// Write resolvable properties
for (ResolvableProperty prop : checkConfig.getResolvableProperties()) {
Element propEl = configEl.addElement(XMLTags.PROPERTY_TAG);
propEl.addAttribute(XMLTags.NAME_TAG, prop.getPropertyName());
propEl.addAttribute(XMLTags.VALUE_TAG, prop.getValue());
}
// Write additional data
for (Map.Entry<String, String> entry : checkConfig.getAdditionalData().entrySet()) {
Element addEl = configEl.addElement(XMLTags.ADDITIONAL_DATA_TAG);
addEl.addAttribute(XMLTags.NAME_TAG, entry.getKey());
addEl.addAttribute(XMLTags.VALUE_TAG, entry.getValue());
}
}
Aggregations