Search in sources :

Example 1 with PMDPlugin

use of net.sourceforge.pmd.eclipse.plugin.PMDPlugin in project pmd-eclipse-plugin by pmd.

the class PreferencesManagerImpl method storeRuleSetInStateLocation.

/**
 * Store the rule set in preference store
 */
private void storeRuleSetInStateLocation(RuleSet ruleSet) {
    OutputStream out = null;
    PMDPlugin plugin = PMDPlugin.getDefault();
    try {
        IPath ruleSetLocation = plugin.getStateLocation().append(PREFERENCE_RULESET_FILE);
        out = new FileOutputStream(ruleSetLocation.toOSString());
        IRuleSetWriter writer = plugin.getRuleSetWriter();
        writer.write(out, ruleSet);
        out.flush();
    } catch (IOException e) {
        plugin.logError("IO Exception when storing ruleset in state location", e);
    } catch (WriterException e) {
        plugin.logError("General PMD Eclipse Exception when storing ruleset in state location", e);
    } finally {
        IOUtil.closeQuietly(out);
    }
}
Also used : IRuleSetWriter(net.sourceforge.pmd.eclipse.runtime.writer.IRuleSetWriter) IPath(org.eclipse.core.runtime.IPath) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) PMDPlugin(net.sourceforge.pmd.eclipse.plugin.PMDPlugin) IOException(java.io.IOException) WriterException(net.sourceforge.pmd.eclipse.runtime.writer.WriterException)

Aggregations

FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 PMDPlugin (net.sourceforge.pmd.eclipse.plugin.PMDPlugin)1 IRuleSetWriter (net.sourceforge.pmd.eclipse.runtime.writer.IRuleSetWriter)1 WriterException (net.sourceforge.pmd.eclipse.runtime.writer.WriterException)1 IPath (org.eclipse.core.runtime.IPath)1