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">
</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>

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.CodanSeverity;
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
@ -25,12 +25,12 @@ import org.eclipse.cdt.codan.core.model.IProblemsProfile;
*/
public class CodanPreferencesLoader {
private static String LIST_SEP = ",";
private IProblemsProfile baseModel;
private IProblemProfile baseModel;
/**
* @param workspaceProfile
*/
public CodanPreferencesLoader(IProblemsProfile profile) {
public CodanPreferencesLoader(IProblemProfile profile) {
setInput(profile);
}
@ -41,7 +41,7 @@ public class CodanPreferencesLoader {
}
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,
HashMap<Object, Boolean> hashMap) {
if (element instanceof IProblemsProfile) {
IProblemsProfile profile = (IProblemsProfile) element;
if (element instanceof IProblemProfile) {
IProblemProfile profile = (IProblemProfile) element;
IProblem[] problems = profile.getProblems();
for (IProblem iProblem : problems) {
hashMap.put(iProblem, iProblem.isEnabled());

View file

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

View file

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

View file

@ -17,7 +17,7 @@ import java.util.Collection;
* @author Alena
*
*/
public class ProblemsProfile implements IProblemsProfile, Cloneable {
public class ProblemProfile implements IProblemProfile, Cloneable {
private IProblemCategory rootCategory = new CodanProblemCategory("root",
"root");
@ -25,7 +25,7 @@ public class ProblemsProfile implements IProblemsProfile, Cloneable {
* (non-Javadoc)
*
* @see
* org.eclipse.cdt.codan.core.model.IProblemsProfile#getProblem(java.lang
* org.eclipse.cdt.codan.core.model.IProblemProfile#getProblem(java.lang
* .String)
*/
@Override
@ -36,7 +36,7 @@ public class ProblemsProfile implements IProblemsProfile, Cloneable {
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.codan.core.model.IProblemsProfile#getProblems()
* @see org.eclipse.cdt.codan.core.model.IProblemProfile#getProblems()
*/
@Override
public IProblem[] getProblems() {
@ -65,7 +65,7 @@ public class ProblemsProfile implements IProblemsProfile, Cloneable {
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.codan.core.model.IProblemsProfile#getRoot()
* @see org.eclipse.cdt.codan.core.model.IProblemProfile#getRoot()
*/
@Override
public IProblemCategory getRoot() {
@ -90,7 +90,7 @@ public class ProblemsProfile implements IProblemsProfile, Cloneable {
@Override
public Object clone() {
try {
ProblemsProfile clone = (ProblemsProfile) super.clone();
ProblemProfile clone = (ProblemProfile) super.clone();
clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory)
.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.IProblem;
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.CheckStateChangedEvent;
import org.eclipse.jface.viewers.IBaseLabelProvider;
@ -112,8 +112,8 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
if (parentElement instanceof IProblemCategory) {
return ((IProblemCategory) parentElement).getChildren();
}
if (parentElement instanceof IProblemsProfile) {
return ((IProblemsProfile) parentElement).getRoot()
if (parentElement instanceof IProblemProfile) {
return ((IProblemProfile) parentElement).getRoot()
.getChildren();
}
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);
setEmptySelectionAllowed(true);
getTreeViewer().getTree().setHeaderVisible(true);