Search in sources :

Example 6 with ResolvableProperty

use of net.sf.eclipsecs.core.config.ResolvableProperty 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());
    }
}
Also used : BuiltInConfigurationType(net.sf.eclipsecs.core.config.configtypes.BuiltInConfigurationType) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) ResolvableProperty(net.sf.eclipsecs.core.config.ResolvableProperty) Element(org.dom4j.Element) ProjectConfigurationType(net.sf.eclipsecs.core.config.configtypes.ProjectConfigurationType) Map(java.util.Map) IProject(org.eclipse.core.resources.IProject)

Aggregations

ResolvableProperty (net.sf.eclipsecs.core.config.ResolvableProperty)6 ProjectConfigurationType (net.sf.eclipsecs.core.config.configtypes.ProjectConfigurationType)2 Element (org.dom4j.Element)2 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CheckConfiguration (net.sf.eclipsecs.core.config.CheckConfiguration)1 CheckConfigurationTester (net.sf.eclipsecs.core.config.CheckConfigurationTester)1 ICheckConfiguration (net.sf.eclipsecs.core.config.ICheckConfiguration)1 BuiltInConfigurationType (net.sf.eclipsecs.core.config.configtypes.BuiltInConfigurationType)1 IConfigurationType (net.sf.eclipsecs.core.config.configtypes.IConfigurationType)1 CheckstylePluginException (net.sf.eclipsecs.core.util.CheckstylePluginException)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 Path (org.eclipse.core.runtime.Path)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 Point (org.eclipse.swt.graphics.Point)1