1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

- trying to use eclipse properties

This commit is contained in:
Alena Laskavaia 2009-04-18 02:12:37 +00:00
parent c60533c54f
commit 3ccd43f5ed
6 changed files with 42 additions and 29 deletions

View file

@ -42,6 +42,16 @@
point="org.eclipse.core.runtime.preferences"> point="org.eclipse.core.runtime.preferences">
</extension> </extension>
<extension
point="org.eclipse.cdt.codan.core.checkers"
id="org.eclipse.cdt.codan.core.categories">
<category
id="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
name="Potential programming problems"
>
</category>
</extension>
</plugin> </plugin>

View file

@ -17,7 +17,7 @@ import java.util.Map;
import org.eclipse.cdt.codan.core.model.CodanProblem; import org.eclipse.cdt.codan.core.model.CodanProblem;
import org.eclipse.cdt.codan.core.model.CodanSeverity; import org.eclipse.cdt.codan.core.model.CodanSeverity;
import org.eclipse.cdt.codan.core.model.IProblem; import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemsProfile; import org.eclipse.cdt.codan.core.model.IProblemProfile;
/** /**
* @author Alena * @author Alena
@ -25,12 +25,12 @@ import org.eclipse.cdt.codan.core.model.IProblemsProfile;
*/ */
public class CodanPreferencesLoader { public class CodanPreferencesLoader {
private static String LIST_SEP = ","; private static String LIST_SEP = ",";
private IProblemsProfile baseModel; private IProblemProfile baseModel;
/** /**
* @param workspaceProfile * @param workspaceProfile
*/ */
public CodanPreferencesLoader(IProblemsProfile profile) { public CodanPreferencesLoader(IProblemProfile profile) {
setInput(profile); setInput(profile);
} }
@ -41,7 +41,7 @@ public class CodanPreferencesLoader {
} }
public void setInput(Object model) { public void setInput(Object model) {
baseModel = (IProblemsProfile) model; baseModel = (IProblemProfile) model;
} }
/** /**
@ -133,8 +133,8 @@ public class CodanPreferencesLoader {
*/ */
private Map<Object, Boolean> fillChecked(Object element, private Map<Object, Boolean> fillChecked(Object element,
HashMap<Object, Boolean> hashMap) { HashMap<Object, Boolean> hashMap) {
if (element instanceof IProblemsProfile) { if (element instanceof IProblemProfile) {
IProblemsProfile profile = (IProblemsProfile) element; IProblemProfile profile = (IProblemProfile) element;
IProblem[] problems = profile.getProblems(); IProblem[] problems = profile.getProblems();
for (IProblem iProblem : problems) { for (IProblem iProblem : problems) {
hashMap.put(iProblem, iProblem.isEnabled()); hashMap.put(iProblem, iProblem.isEnabled());

View file

@ -35,11 +35,11 @@ public class CheckersRegisry implements Iterable<IChecker> {
private static final Object DEFAULT = "DEFAULT"; private static final Object DEFAULT = "DEFAULT";
private Collection<IChecker> checkers = new ArrayList<IChecker>(); private Collection<IChecker> checkers = new ArrayList<IChecker>();
private static CheckersRegisry instance; private static CheckersRegisry instance;
private HashMap<Object, IProblemsProfile> profiles = new HashMap<Object, IProblemsProfile>(); private HashMap<Object, IProblemProfile> profiles = new HashMap<Object, IProblemProfile>();
private CheckersRegisry() { private CheckersRegisry() {
instance = this; instance = this;
profiles.put(DEFAULT, new ProblemsProfile()); profiles.put(DEFAULT, new ProblemProfile());
readCheckersRegistry(); readCheckersRegistry();
} }
@ -127,7 +127,9 @@ public class CheckersRegisry implements Iterable<IChecker> {
if (name == null) if (name == null)
name = id; name = id;
CodanProblem p = new CodanProblem(id, name); CodanProblem p = new CodanProblem(id, name);
String category = getAtt(configurationElement, "category"); String category = getAtt(configurationElement, "category", false);
if (category == null)
category = "org.eclipse.cdt.codan.core.categories.ProgrammingProblems";
addProblem(p, category); addProblem(p, category);
return p; return p;
} }
@ -146,7 +148,8 @@ public class CheckersRegisry implements Iterable<IChecker> {
CodanCorePlugin.log("Extension " CodanCorePlugin.log("Extension "
+ configurationElement.getDeclaringExtension() + configurationElement.getDeclaringExtension()
.getUniqueIdentifier() .getUniqueIdentifier()
+ " missing required attribute: " + name); + " missing required attribute: "
+ configurationElement.getName() + "." + name);
return elementValue; return elementValue;
} }
@ -165,7 +168,7 @@ public class CheckersRegisry implements Iterable<IChecker> {
} }
public void addProblem(IProblem p, String category) { public void addProblem(IProblem p, String category) {
((ProblemsProfile) getDefaultProfile()).addProblem(p, ((ProblemProfile) getDefaultProfile()).addProblem(p,
getDefaultProfile().getRoot()); getDefaultProfile().getRoot());
} }
@ -175,18 +178,18 @@ public class CheckersRegisry implements Iterable<IChecker> {
/** /**
* @return * @return
*/ */
public IProblemsProfile getDefaultProfile() { public IProblemProfile getDefaultProfile() {
return profiles.get(DEFAULT); return profiles.get(DEFAULT);
} }
/** /**
* @return * @return
*/ */
public IProblemsProfile getWorkspaceProfile() { public IProblemProfile getWorkspaceProfile() {
IProblemsProfile wp = profiles.get(ResourcesPlugin.getWorkspace()); IProblemProfile wp = profiles.get(ResourcesPlugin.getWorkspace());
if (wp == null) { if (wp == null) {
try { try {
wp = (IProblemsProfile) getDefaultProfile().clone(); wp = (IProblemProfile) getDefaultProfile().clone();
// load default values // load default values
CodanPreferencesLoader loader = new CodanPreferencesLoader(wp); CodanPreferencesLoader loader = new CodanPreferencesLoader(wp);
String s = CodanCorePlugin.getDefault().getStorePreferences() String s = CodanCorePlugin.getDefault().getStorePreferences()
@ -203,12 +206,12 @@ public class CheckersRegisry implements Iterable<IChecker> {
* @param element * @param element
* @return * @return
*/ */
public IProblemsProfile getResourceProfile(IResource element) { public IProblemProfile getResourceProfile(IResource element) {
IProblemsProfile prof = profiles.get(element); IProblemProfile prof = profiles.get(element);
if (prof == null) { if (prof == null) {
if (element instanceof IProject) { if (element instanceof IProject) {
try { try {
prof = (IProblemsProfile) getWorkspaceProfile().clone(); prof = (IProblemProfile) getWorkspaceProfile().clone();
// load default values // load default values
CodanPreferencesLoader loader = new CodanPreferencesLoader( CodanPreferencesLoader loader = new CodanPreferencesLoader(
prof); prof);

View file

@ -14,7 +14,7 @@ package org.eclipse.cdt.codan.core.model;
* @author Alena * @author Alena
* *
*/ */
public interface IProblemsProfile extends IProblemElement { public interface IProblemProfile extends IProblemElement {
IProblemCategory getRoot(); IProblemCategory getRoot();
IProblem findProblem(String id); IProblem findProblem(String id);

View file

@ -17,7 +17,7 @@ import java.util.Collection;
* @author Alena * @author Alena
* *
*/ */
public class ProblemsProfile implements IProblemsProfile, Cloneable { public class ProblemProfile implements IProblemProfile, Cloneable {
private IProblemCategory rootCategory = new CodanProblemCategory("root", private IProblemCategory rootCategory = new CodanProblemCategory("root",
"root"); "root");
@ -25,7 +25,7 @@ public class ProblemsProfile implements IProblemsProfile, Cloneable {
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* org.eclipse.cdt.codan.core.model.IProblemsProfile#getProblem(java.lang * org.eclipse.cdt.codan.core.model.IProblemProfile#getProblem(java.lang
* .String) * .String)
*/ */
@Override @Override
@ -36,7 +36,7 @@ public class ProblemsProfile implements IProblemsProfile, Cloneable {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.codan.core.model.IProblemsProfile#getProblems() * @see org.eclipse.cdt.codan.core.model.IProblemProfile#getProblems()
*/ */
@Override @Override
public IProblem[] getProblems() { public IProblem[] getProblems() {
@ -65,7 +65,7 @@ public class ProblemsProfile implements IProblemsProfile, Cloneable {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.codan.core.model.IProblemsProfile#getRoot() * @see org.eclipse.cdt.codan.core.model.IProblemProfile#getRoot()
*/ */
@Override @Override
public IProblemCategory getRoot() { public IProblemCategory getRoot() {
@ -90,7 +90,7 @@ public class ProblemsProfile implements IProblemsProfile, Cloneable {
@Override @Override
public Object clone() { public Object clone() {
try { try {
ProblemsProfile clone = (ProblemsProfile) super.clone(); ProblemProfile clone = (ProblemProfile) super.clone();
clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory) clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory)
.clone(); .clone();
return clone; return clone;

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.codan.core.builder.CodanPreferencesLoader;
import org.eclipse.cdt.codan.core.model.CodanProblem; import org.eclipse.cdt.codan.core.model.CodanProblem;
import org.eclipse.cdt.codan.core.model.IProblem; import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemCategory; import org.eclipse.cdt.codan.core.model.IProblemCategory;
import org.eclipse.cdt.codan.core.model.IProblemsProfile; import org.eclipse.cdt.codan.core.model.IProblemProfile;
import org.eclipse.jface.viewers.BaseLabelProvider; import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.IBaseLabelProvider; import org.eclipse.jface.viewers.IBaseLabelProvider;
@ -112,8 +112,8 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
if (parentElement instanceof IProblemCategory) { if (parentElement instanceof IProblemCategory) {
return ((IProblemCategory) parentElement).getChildren(); return ((IProblemCategory) parentElement).getChildren();
} }
if (parentElement instanceof IProblemsProfile) { if (parentElement instanceof IProblemProfile) {
return ((IProblemsProfile) parentElement).getRoot() return ((IProblemProfile) parentElement).getRoot()
.getChildren(); .getChildren();
} }
return new Object[0]; return new Object[0];
@ -163,7 +163,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
} }
} }
public ProblemsTreeEditor(Composite parent, IProblemsProfile profile) { public ProblemsTreeEditor(Composite parent, IProblemProfile profile) {
super(PreferenceConstants.P_PROBLEMS, "Problems", parent); super(PreferenceConstants.P_PROBLEMS, "Problems", parent);
setEmptySelectionAllowed(true); setEmptySelectionAllowed(true);
getTreeViewer().getTree().setHeaderVisible(true); getTreeViewer().getTree().setHeaderVisible(true);